summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/stm/boards/thunderpack/mpconfigboard.h11
-rw-r--r--ports/stm/common-hal/microcontroller/__init__.c2
-rw-r--r--ports/stm/common-hal/nvm/ByteArray.h4
3 files changed, 13 insertions, 4 deletions
diff --git a/ports/stm/boards/thunderpack/mpconfigboard.h b/ports/stm/boards/thunderpack/mpconfigboard.h
index 62bf7609d..270600b3c 100644
--- a/ports/stm/boards/thunderpack/mpconfigboard.h
+++ b/ports/stm/boards/thunderpack/mpconfigboard.h
@@ -26,11 +26,18 @@
#define MICROPY_HW_BOARD_NAME "THUNDERPACK"
#define MICROPY_HW_MCU_NAME "STM32F411CE"
-#define FLASH_SIZE (0x80000)
-#define FLASH_PAGE_SIZE (0x4000)
+// Non-volatile memory config
#define CIRCUITPY_INTERNAL_NVM_SIZE (0x4000)
#define CIRCUITPY_INTERNAL_NVM_START_ADDR (0x0800C000)
#define CIRCUITPY_INTERNAL_NVM_SECTOR FLASH_SECTOR_3
+
+// Putting the entire flash sector in the NVM byte array buffer
+// would take up too much RAM. This limits how much of the sector we use.
+#define NVM_BYTEARRAY_BUFFER_LEN 512
+
+// Flash config
+#define FLASH_SIZE (0x80000)
+#define FLASH_PAGE_SIZE (0x4000)
#define BOARD_FLASH_SIZE (FLASH_SIZE - CIRCUITPY_INTERNAL_NVM_SIZE- 0x2000 - 0xC000)
#define BOARD_OSC_DIV (24)
diff --git a/ports/stm/common-hal/microcontroller/__init__.c b/ports/stm/common-hal/microcontroller/__init__.c
index 85e66fb00..b69407eff 100644
--- a/ports/stm/common-hal/microcontroller/__init__.c
+++ b/ports/stm/common-hal/microcontroller/__init__.c
@@ -116,7 +116,7 @@ const nvm_bytearray_obj_t common_hal_mcu_nvm_obj = {
.base = {
.type = &nvm_bytearray_type,
},
- .len = NVM_BYTEARRAY_BUFFER,
+ .len = NVM_BYTEARRAY_BUFFER_LEN,
.start_address = (uint8_t*) (CIRCUITPY_INTERNAL_NVM_START_ADDR)
};
#endif
diff --git a/ports/stm/common-hal/nvm/ByteArray.h b/ports/stm/common-hal/nvm/ByteArray.h
index 8ad64cb81..0d7ecf6ab 100644
--- a/ports/stm/common-hal/nvm/ByteArray.h
+++ b/ports/stm/common-hal/nvm/ByteArray.h
@@ -32,7 +32,9 @@
// STM flash is saved in sectors (not pages), at a minimum size of 16k.
// To limit the RAM usage during writing, we want to set a smaller
// maximum value.
-#define NVM_BYTEARRAY_BUFFER 512
+#ifndef NVM_BYTEARRAY_BUFFER_LEN
+#define NVM_BYTEARRAY_BUFFER_LEN 512
+#endif
typedef struct {
mp_obj_base_t base;