diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index 28a844ffc0..04ad98c22a 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -109,6 +109,9 @@ #define CIRCUITPY_DEFAULT_STACK_SIZE 4096 #endif +// Smallest unit of flash that can be erased. +#define FLASH_ERASE_SIZE NVMCTRL_ROW_SIZE + #endif // SAMD21 //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -123,6 +126,9 @@ #define CIRCUITPY_DEFAULT_STACK_SIZE (24*1024) #endif +// Smallest unit of flash that can be erased. +#define FLASH_ERASE_SIZE NVMCTRL_BLOCK_SIZE + // If CIRCUITPY is internal, use half of flash for it. #if INTERNAL_FLASH_FILESYSTEM #ifndef CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE @@ -187,25 +193,25 @@ #error BOOTLOADER_START_ADDR must be on a flash page boundary. #endif -#if CIRCUITPY_INTERNAL_NVM_START_ADDR % FLASH_PAGE_SIZE != 0 -#error CIRCUITPY_INTERNAL_NVM_START_ADDR must be on a flash page boundary. +#if CIRCUITPY_INTERNAL_NVM_START_ADDR % FLASH_ERASE_SIZE != 0 +#error CIRCUITPY_INTERNAL_NVM_START_ADDR must be on a flash erase (row or block) boundary. #endif -#if CIRCUITPY_INTERNAL_NVM_SIZE % FLASH_PAGE_SIZE != 0 -#error CIRCUITPY_INTERNAL_NVM_SIZE must be a multiple of FLASH_PAGE_SIZE. +#if CIRCUITPY_INTERNAL_NVM_SIZE % FLASH_ERASE_SIZE != 0 +#error CIRCUITPY_INTERNAL_NVM_SIZE must be a multiple of FLASH_ERASE_SIZE. #endif -#if CIRCUITPY_INTERNAL_CONFIG_START_ADDR % FLASH_PAGE_SIZE != 0 -#error CIRCUITPY_INTERNAL_CONFIG_SIZE must be on a flash page boundary. +#if CIRCUITPY_INTERNAL_CONFIG_START_ADDR % FLASH_ERASE_SIZE != 0 +#error CIRCUITPY_INTERNAL_CONFIG_SIZE must be on a flash erase (row or block) boundary. #endif -#if CIRCUITPY_INTERNAL_CONFIG_SIZE % FLASH_PAGE_SIZE != 0 -#error CIRCUITPY_INTERNAL_CONFIG_SIZE must be a multiple of FLASH_PAGE_SIZE. +#if CIRCUITPY_INTERNAL_CONFIG_SIZE % FLASH_ERASE_SIZE != 0 +#error CIRCUITPY_INTERNAL_CONFIG_SIZE must be a multiple of FLASH_ERASE_SIZE. #endif -#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR % FLASH_PAGE_SIZE != 0 -#error CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE must be on a flash page boundary. +#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR % FLASH_ERASE_SIZE != 0 +#error CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE must be on a flash erase (row or block) boundary. #endif -#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE % FLASH_PAGE_SIZE != 0 -#error CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE must be a multiple of FLASH_PAGE_SIZE. +#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE % FLASH_ERASE_SIZE != 0 +#error CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE must be a multiple of FLASH_ERASE_SIZE. #endif #if CIRCUITPY_FIRMWARE_SIZE < 0 diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index db082ab51c..473169e946 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -104,6 +104,9 @@ #define ISR_START_ADDR (SD_FLASH_START_ADDR + SD_FLASH_SIZE) #define ISR_SIZE (0x1000) // 4kiB +// Smallest unit of flash that can be erased. +#define FLASH_ERASE_SIZE FLASH_PAGE_SIZE + #define CIRCUITPY_FIRMWARE_START_ADDR (ISR_START_ADDR + ISR_SIZE) // Define these regions starting down from the bootloader: @@ -129,29 +132,29 @@ // The firmware space is the space left over between the fixed lower and upper regions. #define CIRCUITPY_FIRMWARE_SIZE (CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR - CIRCUITPY_FIRMWARE_START_ADDR) -#if BOOTLOADER_START_ADDR % FLASH_PAGE_SIZE != 0 -#error BOOTLOADER_START_ADDR must be on a flash page boundary. +#if BOOTLOADER_START_ADDR % FLASH_ERASE_SIZE != 0 +#error BOOTLOADER_START_ADDR must be on a flash erase boundary. #endif -#if CIRCUITPY_INTERNAL_NVM_START_ADDR % FLASH_PAGE_SIZE != 0 -#error CIRCUITPY_INTERNAL_NVM_START_ADDR must be on a flash page boundary. +#if CIRCUITPY_INTERNAL_NVM_START_ADDR % FLASH_ERASE_SIZE != 0 +#error CIRCUITPY_INTERNAL_NVM_START_ADDR must be on a flash erase boundary. #endif -#if CIRCUITPY_INTERNAL_NVM_SIZE % FLASH_PAGE_SIZE != 0 -#error CIRCUITPY_INTERNAL_NVM_SIZE must be a multiple of FLASH_PAGE_SIZE. +#if CIRCUITPY_INTERNAL_NVM_SIZE % FLASH_ERASE_SIZE != 0 +#error CIRCUITPY_INTERNAL_NVM_SIZE must be a multiple of FLASH_ERASE_SIZE. #endif -#if CIRCUITPY_BLE_CONFIG_START_ADDR % FLASH_PAGE_SIZE != 0 -#error CIRCUITPY_BLE_CONFIG_SIZE must be on a flash page boundary. +#if CIRCUITPY_BLE_CONFIG_START_ADDR % FLASH_ERASE_SIZE != 0 +#error CIRCUITPY_BLE_CONFIG_SIZE must be on a flash erase boundary. #endif -#if CIRCUITPY_BLE_CONFIG_SIZE % FLASH_PAGE_SIZE != 0 -#error CIRCUITPY_BLE_CONFIG_SIZE must be a multiple of FLASH_PAGE_SIZE. +#if CIRCUITPY_BLE_CONFIG_SIZE % FLASH_ERASE_SIZE != 0 +#error CIRCUITPY_BLE_CONFIG_SIZE must be a multiple of FLASH_ERASE_SIZE. #endif -#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR % FLASH_PAGE_SIZE != 0 -#error CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE must be on a flash page boundary. +#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR % FLASH_ERASE_SIZE != 0 +#error CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE must be on a flash erase boundary. #endif -#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE % FLASH_PAGE_SIZE != 0 -#error CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE must be a multiple of FLASH_PAGE_SIZE. +#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE % FLASH_ERASE_SIZE != 0 +#error CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE must be a multiple of FLASH_ERASE_SIZE. #endif #if CIRCUITPY_FIRMWARE_SIZE < 0