Skip to content

Commit 3e05df7

Browse files
committed
esp8266/modesp: flash_user_start: Use value from linker script.
Make esp8266_common.ld export size reserved to all code segments, and use that in esp.flash_user_start() implementation.
1 parent 0987ad5 commit 3e05df7

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

esp8266/esp8266_common.ld

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ EXTERN(_KernelExceptionVector)
1919
EXTERN(_NMIExceptionVector)
2020
EXTERN(_UserExceptionVector)
2121

22+
_firmware_size = ORIGIN(irom0_0_seg) + LENGTH(irom0_0_seg) - 0x40200000;
23+
2224
PROVIDE(_memmap_vecbase_reset = 0x40000000);
2325

2426
/* Various memory-map dependent cache attribute settings: */

esp8266/modesp.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,10 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(esp_flash_size_obj, esp_flash_size);
159159
// we assume there's a yaota8266 bootloader.
160160
#define IS_OTA_FIRMWARE() ((*(uint32_t*)0x40200000 & 0xff00) == 0x100)
161161

162+
extern byte _firmware_size[];
163+
162164
STATIC mp_obj_t esp_flash_user_start(void) {
163-
if (IS_OTA_FIRMWARE()) {
164-
return MP_OBJ_NEW_SMALL_INT(0x3c000 + 0x90000);
165-
} else {
166-
return MP_OBJ_NEW_SMALL_INT(0x90000);
167-
}
165+
return MP_OBJ_NEW_SMALL_INT((uint32_t)_firmware_size);
168166
}
169167
STATIC MP_DEFINE_CONST_FUN_OBJ_0(esp_flash_user_start_obj, esp_flash_user_start);
170168

0 commit comments

Comments
 (0)