Skip to content

Commit 68195a8

Browse files
committed
Update NVM_BYTEARRAY_BUFFER_LEN
1 parent 5f7e517 commit 68195a8

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

ports/stm/boards/thunderpack/mpconfigboard.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,18 @@
2626
#define MICROPY_HW_BOARD_NAME "THUNDERPACK"
2727
#define MICROPY_HW_MCU_NAME "STM32F411CE"
2828

29-
#define FLASH_SIZE (0x80000)
30-
#define FLASH_PAGE_SIZE (0x4000)
29+
// Non-volatile memory config
3130
#define CIRCUITPY_INTERNAL_NVM_SIZE (0x4000)
3231
#define CIRCUITPY_INTERNAL_NVM_START_ADDR (0x0800C000)
3332
#define CIRCUITPY_INTERNAL_NVM_SECTOR FLASH_SECTOR_3
33+
34+
// Putting the entire flash sector in the NVM byte array buffer
35+
// would take up too much RAM. This limits how much of the sector we use.
36+
#define NVM_BYTEARRAY_BUFFER_LEN 512
37+
38+
// Flash config
39+
#define FLASH_SIZE (0x80000)
40+
#define FLASH_PAGE_SIZE (0x4000)
3441
#define BOARD_FLASH_SIZE (FLASH_SIZE - CIRCUITPY_INTERNAL_NVM_SIZE- 0x2000 - 0xC000)
3542

3643
#define BOARD_OSC_DIV (24)

ports/stm/common-hal/microcontroller/__init__.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ const nvm_bytearray_obj_t common_hal_mcu_nvm_obj = {
116116
.base = {
117117
.type = &nvm_bytearray_type,
118118
},
119-
.len = NVM_BYTEARRAY_BUFFER,
119+
.len = NVM_BYTEARRAY_BUFFER_LEN,
120120
.start_address = (uint8_t*) (CIRCUITPY_INTERNAL_NVM_START_ADDR)
121121
};
122122
#endif

ports/stm/common-hal/nvm/ByteArray.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
// STM flash is saved in sectors (not pages), at a minimum size of 16k.
3333
// To limit the RAM usage during writing, we want to set a smaller
3434
// maximum value.
35-
#define NVM_BYTEARRAY_BUFFER 512
35+
#ifndef NVM_BYTEARRAY_BUFFER_LEN
36+
#define NVM_BYTEARRAY_BUFFER_LEN 512
37+
#endif
3638

3739
typedef struct {
3840
mp_obj_base_t base;

0 commit comments

Comments
 (0)