diff --git a/esp-link/config.c b/esp-link/config.c index b670c08..7d5d3b4 100644 --- a/esp-link/config.c +++ b/esp-link/config.c @@ -204,3 +204,43 @@ getFlashSize() { return 0; return 1 << size_id; } + +const uint32_t getUserPageSectionStart() +{ + enum flash_size_map map = system_get_flash_size_map(); + switch(map) + { + case FLASH_SIZE_4M_MAP_256_256: + return FLASH_SECT + FIRMWARE_SIZE - 3*FLASH_SECT;// bootloader + firmware - 12KB (highly risky...) + case FLASH_SIZE_8M_MAP_512_512: + return FLASH_SECT + FIRMWARE_SIZE; + case FLASH_SIZE_16M_MAP_512_512: + case FLASH_SIZE_16M_MAP_1024_1024: + case FLASH_SIZE_32M_MAP_512_512: + case FLASH_SIZE_32M_MAP_1024_1024: + return 0x0FC000; + default: + return 0xFFFFFFFF; + } +} + +const uint32_t getUserPageSectionEnd() +{ + enum flash_size_map map = system_get_flash_size_map(); + switch(map) + { + case FLASH_SIZE_4M_MAP_256_256: + return FLASH_SECT + FIRMWARE_SIZE - 2*FLASH_SECT; + case FLASH_SIZE_8M_MAP_512_512: + return FLASH_SECT + FIRMWARE_SIZE + 2*FLASH_SECT; + case FLASH_SIZE_16M_MAP_512_512: + case FLASH_SIZE_16M_MAP_1024_1024: + return 0x1FC000; + case FLASH_SIZE_32M_MAP_512_512: + case FLASH_SIZE_32M_MAP_1024_1024: + return 0x3FC000; + default: + return 0xFFFFFFFF; + } +} + diff --git a/esp-link/config.h b/esp-link/config.h index 37c82e4..65195d2 100644 --- a/esp-link/config.h +++ b/esp-link/config.h @@ -49,4 +49,7 @@ bool configRestore(void); void configWipe(void); const size_t getFlashSize(); +const uint32_t getUserPageSectionStart(); +const uint32_t getUserPageSectionEnd(); + #endif