From 68195a8dfe0bec239a38cc01ad2b74160bbdacd6 Mon Sep 17 00:00:00 2001 From: jgillick Date: Sun, 22 Mar 2020 15:19:53 -0700 Subject: [PATCH] Update NVM_BYTEARRAY_BUFFER_LEN --- ports/stm/boards/thunderpack/mpconfigboard.h | 11 +++++++++-- ports/stm/common-hal/microcontroller/__init__.c | 2 +- ports/stm/common-hal/nvm/ByteArray.h | 4 +++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ports/stm/boards/thunderpack/mpconfigboard.h b/ports/stm/boards/thunderpack/mpconfigboard.h index 62bf7609da..270600b3c8 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 85e66fb00d..b69407eff7 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 8ad64cb81b..0d7ecf6ab7 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;