Rework support for >4MB modules: place SPIFFS after SDK data (#1646)
This commit is contained in:
parent
543f438b6b
commit
c57af8972f
|
@ -35,6 +35,12 @@ uint32_t flash_safe_get_size_byte(void)
|
|||
if (flash_size == 0)
|
||||
{
|
||||
flash_size = flash_detect_size_byte();
|
||||
#if !defined(FLASH_SAFE_API)
|
||||
// clip maximum flash size to 4MByte if "SAFE API" is not used
|
||||
if (flash_size > FLASH_SIZE_4MBYTE) {
|
||||
flash_size = FLASH_SIZE_4MBYTE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return flash_size;
|
||||
}
|
||||
|
|
|
@ -53,8 +53,14 @@ static bool myspiffs_set_location(spiffs_config *cfg, int align, int offset, int
|
|||
#ifdef SPIFFS_FIXED_LOCATION
|
||||
cfg->phys_addr = (SPIFFS_FIXED_LOCATION + block_size - 1) & ~(block_size-1);
|
||||
#else
|
||||
cfg->phys_addr = ( u32_t )platform_flash_get_first_free_block_address( NULL ) + offset;
|
||||
cfg->phys_addr = (cfg->phys_addr + align - 1) & ~(align - 1);
|
||||
if (flash_safe_get_size_byte() <= FLASH_SIZE_4MBYTE) {
|
||||
// 256kByte - 4MByte modules: SPIFFS partition starts right after firmware image
|
||||
cfg->phys_addr = ( u32_t )platform_flash_get_first_free_block_address( NULL ) + offset;
|
||||
cfg->phys_addr = (cfg->phys_addr + align - 1) & ~(align - 1);
|
||||
} else {
|
||||
// > 4MByte modules: SPIFFS partition starts after SDK data
|
||||
cfg->phys_addr = flash_rom_get_size_byte();
|
||||
}
|
||||
#endif
|
||||
#ifdef SPIFFS_SIZE_1M_BOUNDARY
|
||||
cfg->phys_size = ((0x100000 - (SYS_PARAM_SEC_NUM * INTERNAL_FLASH_SECTOR_SIZE) - ( ( u32_t )cfg->phys_addr )) & ~(block_size - 1)) & 0xfffff;
|
||||
|
|
|
@ -122,17 +122,26 @@ void nodemcu_init(void)
|
|||
return;
|
||||
}
|
||||
|
||||
#if defined(FLASH_SAFE_API)
|
||||
if( flash_safe_get_size_byte() != flash_rom_get_size_byte()) {
|
||||
NODE_ERR("Self adjust flash size.\n");
|
||||
// Fit hardware real flash size.
|
||||
flash_rom_set_size_byte(flash_safe_get_size_byte());
|
||||
if( flash_safe_get_size_byte() <= FLASH_SIZE_4MBYTE ) {
|
||||
if( flash_safe_get_size_byte() != flash_rom_get_size_byte() ) {
|
||||
NODE_ERR("Self adjust flash size.\n");
|
||||
// Fit hardware real flash size.
|
||||
flash_rom_set_size_byte(flash_safe_get_size_byte());
|
||||
|
||||
system_restart ();
|
||||
// Don't post the start_lua task, we're about to reboot...
|
||||
return;
|
||||
}
|
||||
} else if( (flash_rom_get_size_byte() < FLASH_SIZE_1MBYTE) ||
|
||||
(flash_rom_get_size_byte() > FLASH_SIZE_4MBYTE) ) {
|
||||
NODE_ERR("Locking flash size for SDK to 1MByte.\n");
|
||||
// SDK/ROM can't handle flash size > 4MByte, ensure a minimum of 1MByte for firmware image
|
||||
flash_rom_set_size_byte(FLASH_SIZE_1MBYTE);
|
||||
|
||||
system_restart ();
|
||||
// Don't post the start_lua task, we're about to reboot...
|
||||
return;
|
||||
}
|
||||
#endif // defined(FLASH_SAFE_API)
|
||||
|
||||
#if defined ( CLIENT_SSL_ENABLE ) && defined ( SSL_BUFFER_SIZE )
|
||||
espconn_secure_set_size(ESPCONN_CLIENT, SSL_BUFFER_SIZE);
|
||||
|
|
|
@ -32,6 +32,8 @@ Run the following command to flash an *aggregated* binary as is produced for exa
|
|||
- esptool.py is under heavy development. It's advised you run the latest version (check with `esptool.py version`). Since this documentation may not have been able to keep up refer to the [esptool flash modes documentation](https://github.com/themadinventor/esptool#flash-modes) for current options and parameters.
|
||||
- In some uncommon cases, the [SDK init data](#sdk-init-data) may be invalid and NodeMCU may fail to boot. The easiest solution is to fully erase the chip before flashing:
|
||||
`esptool.py --port <serial-port-of-ESP8266> erase_flash`
|
||||
- Modules with flash chips larger than 4 MByte (e.g. WeMos D1 mini pro) need to be manually configured to at least 1 MByte: Firmware image and SDK init data occupy the first MByte, while the remaining 7/15 MByte of the flash are used for SPIFFS:
|
||||
`esptool.py --port <serial-port-of-ESP8266> write_flash -fm <mode> -fs 8m 0x00000 <nodemcu-firmware>.bin`
|
||||
|
||||
### NodeMCU Flasher
|
||||
> A firmware Flash tool for NodeMCU...We are working on next version and will use QT framework. It will be cross platform and open-source.
|
||||
|
|
Loading…
Reference in New Issue