mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
flash-size agnostic builds (#6690)
* flash: mapping definition by sketch at runtime depending on flash chip size and user configuration
This commit is contained in:
parent
3027acaf11
commit
f60defc3d3
641
boards.txt
641
boards.txt
File diff suppressed because it is too large
Load Diff
@ -186,6 +186,9 @@ void attachInterrupt(uint8_t pin, void (*)(void), int mode);
|
|||||||
void detachInterrupt(uint8_t pin);
|
void detachInterrupt(uint8_t pin);
|
||||||
void attachInterruptArg(uint8_t pin, void (*)(void*), void* arg, int mode);
|
void attachInterruptArg(uint8_t pin, void (*)(void*), void* arg, int mode);
|
||||||
|
|
||||||
|
#if FLASH_MAP_SUPPORT
|
||||||
|
#include "flash_hal.h"
|
||||||
|
#endif
|
||||||
void preinit(void);
|
void preinit(void);
|
||||||
void setup(void);
|
void setup(void);
|
||||||
void loop(void);
|
void loop(void);
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include "MD5Builder.h"
|
#include "MD5Builder.h"
|
||||||
#include "umm_malloc/umm_malloc.h"
|
#include "umm_malloc/umm_malloc.h"
|
||||||
#include "cont.h"
|
#include "cont.h"
|
||||||
|
#include "flash_hal.h"
|
||||||
#include "coredecls.h"
|
#include "coredecls.h"
|
||||||
#include "umm_malloc/umm_malloc.h"
|
#include "umm_malloc/umm_malloc.h"
|
||||||
#include <pgmspace.h>
|
#include <pgmspace.h>
|
||||||
@ -291,6 +291,9 @@ uint32_t EspClass::getFlashChipRealSize(void)
|
|||||||
|
|
||||||
uint32_t EspClass::getFlashChipSize(void)
|
uint32_t EspClass::getFlashChipSize(void)
|
||||||
{
|
{
|
||||||
|
#if FLASH_MAP_SUPPORT
|
||||||
|
return getFlashChipRealSize();
|
||||||
|
#else
|
||||||
uint32_t data;
|
uint32_t data;
|
||||||
uint8_t * bytes = (uint8_t *) &data;
|
uint8_t * bytes = (uint8_t *) &data;
|
||||||
// read first 4 byte (magic byte + flash config)
|
// read first 4 byte (magic byte + flash config)
|
||||||
@ -298,6 +301,7 @@ uint32_t EspClass::getFlashChipSize(void)
|
|||||||
return magicFlashChipSize((bytes[3] & 0xf0) >> 4);
|
return magicFlashChipSize((bytes[3] & 0xf0) >> 4);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t EspClass::getFlashChipSpeed(void)
|
uint32_t EspClass::getFlashChipSpeed(void)
|
||||||
@ -323,6 +327,7 @@ FlashMode_t EspClass::getFlashChipMode(void)
|
|||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !FLASH_MAP_SUPPORT
|
||||||
uint32_t EspClass::magicFlashChipSize(uint8_t byte) {
|
uint32_t EspClass::magicFlashChipSize(uint8_t byte) {
|
||||||
switch(byte & 0x0F) {
|
switch(byte & 0x0F) {
|
||||||
case 0x0: // 4 Mbit (512KB)
|
case 0x0: // 4 Mbit (512KB)
|
||||||
@ -343,6 +348,7 @@ uint32_t EspClass::magicFlashChipSize(uint8_t byte) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
uint32_t EspClass::magicFlashChipSpeed(uint8_t byte) {
|
uint32_t EspClass::magicFlashChipSpeed(uint8_t byte) {
|
||||||
switch(byte & 0x0F) {
|
switch(byte & 0x0F) {
|
||||||
@ -612,14 +618,12 @@ uint32_t EspClass::getSketchSize() {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" uint32_t _FS_start;
|
|
||||||
|
|
||||||
uint32_t EspClass::getFreeSketchSpace() {
|
uint32_t EspClass::getFreeSketchSpace() {
|
||||||
|
|
||||||
uint32_t usedSize = getSketchSize();
|
uint32_t usedSize = getSketchSize();
|
||||||
// round one sector up
|
// round one sector up
|
||||||
uint32_t freeSpaceStart = (usedSize + FLASH_SECTOR_SIZE - 1) & (~(FLASH_SECTOR_SIZE - 1));
|
uint32_t freeSpaceStart = (usedSize + FLASH_SECTOR_SIZE - 1) & (~(FLASH_SECTOR_SIZE - 1));
|
||||||
uint32_t freeSpaceEnd = (uint32_t)&_FS_start - 0x40200000;
|
uint32_t freeSpaceEnd = (uint32_t)FS_start - 0x40200000;
|
||||||
|
|
||||||
#ifdef DEBUG_SERIAL
|
#ifdef DEBUG_SERIAL
|
||||||
DEBUG_SERIAL.printf("usedSize=%u freeSpaceStart=%u freeSpaceEnd=%u\r\n", usedSize, freeSpaceStart, freeSpaceEnd);
|
DEBUG_SERIAL.printf("usedSize=%u freeSpaceStart=%u freeSpaceEnd=%u\r\n", usedSize, freeSpaceStart, freeSpaceEnd);
|
||||||
|
59
cores/esp8266/FlashMap.h
Normal file
59
cores/esp8266/FlashMap.h
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
|
||||||
|
// - do not edit - autogenerated by boards.txt.py
|
||||||
|
|
||||||
|
#ifndef __FLASH_MAP_H
|
||||||
|
#define __FLASH_MAP_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t eeprom_start;
|
||||||
|
uint32_t fs_start;
|
||||||
|
uint32_t fs_end;
|
||||||
|
uint32_t fs_block_size;
|
||||||
|
uint32_t fs_page_size;
|
||||||
|
uint32_t flash_size_kb;
|
||||||
|
} flash_map_s;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Following definitions map the above structure, one per line.
|
||||||
|
FLASH_MAP_* is a user choice in sketch:
|
||||||
|
`FLASH_MAP_SETUP_CONFIG(FLASH_MAP_OTA_FS)`
|
||||||
|
Configuration is made at boot with detected flash chip size (last argument 512..16384)
|
||||||
|
Other values are defined from `tools/boards.txt.py`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define FLASH_MAP_OTA_FS \
|
||||||
|
{ \
|
||||||
|
{ .eeprom_start = 0x402fb000, .fs_start = 0x402eb000, .fs_end = 0x402fb000, .fs_block_size = 0x1000, .fs_page_size = 0x100, .flash_size_kb = 1024 }, \
|
||||||
|
{ .eeprom_start = 0x403fb000, .fs_start = 0x403c0000, .fs_end = 0x403fb000, .fs_block_size = 0x1000, .fs_page_size = 0x100, .flash_size_kb = 2048 }, \
|
||||||
|
{ .eeprom_start = 0x405fb000, .fs_start = 0x40400000, .fs_end = 0x405fa000, .fs_block_size = 0x2000, .fs_page_size = 0x100, .flash_size_kb = 4096 }, \
|
||||||
|
{ .eeprom_start = 0x409fb000, .fs_start = 0x40400000, .fs_end = 0x409fa000, .fs_block_size = 0x2000, .fs_page_size = 0x100, .flash_size_kb = 8192 }, \
|
||||||
|
{ .eeprom_start = 0x411fb000, .fs_start = 0x40400000, .fs_end = 0x411fa000, .fs_block_size = 0x2000, .fs_page_size = 0x100, .flash_size_kb = 16384 }, \
|
||||||
|
{ .eeprom_start = 0x4027b000, .fs_start = 0x40273000, .fs_end = 0x4027b000, .fs_block_size = 0x1000, .fs_page_size = 0x100, .flash_size_kb = 512 }, \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define FLASH_MAP_MAX_FS \
|
||||||
|
{ \
|
||||||
|
{ .eeprom_start = 0x402fb000, .fs_start = 0x4027b000, .fs_end = 0x402fb000, .fs_block_size = 0x2000, .fs_page_size = 0x100, .flash_size_kb = 1024 }, \
|
||||||
|
{ .eeprom_start = 0x403fb000, .fs_start = 0x40300000, .fs_end = 0x403fa000, .fs_block_size = 0x2000, .fs_page_size = 0x100, .flash_size_kb = 2048 }, \
|
||||||
|
{ .eeprom_start = 0x405fb000, .fs_start = 0x40300000, .fs_end = 0x405fa000, .fs_block_size = 0x2000, .fs_page_size = 0x100, .flash_size_kb = 4096 }, \
|
||||||
|
{ .eeprom_start = 0x409fb000, .fs_start = 0x40300000, .fs_end = 0x409fa000, .fs_block_size = 0x2000, .fs_page_size = 0x100, .flash_size_kb = 8192 }, \
|
||||||
|
{ .eeprom_start = 0x411fb000, .fs_start = 0x40300000, .fs_end = 0x411fa000, .fs_block_size = 0x2000, .fs_page_size = 0x100, .flash_size_kb = 16384 }, \
|
||||||
|
{ .eeprom_start = 0x4027b000, .fs_start = 0x4025b000, .fs_end = 0x4027b000, .fs_block_size = 0x1000, .fs_page_size = 0x100, .flash_size_kb = 512 }, \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define FLASH_MAP_NO_FS \
|
||||||
|
{ \
|
||||||
|
{ .eeprom_start = 0x402fb000, .fs_start = 0x402fb000, .fs_end = 0x402fb000, .fs_block_size = 0x0, .fs_page_size = 0x0, .flash_size_kb = 1024 }, \
|
||||||
|
{ .eeprom_start = 0x403fb000, .fs_start = 0x403fb000, .fs_end = 0x403fb000, .fs_block_size = 0x0, .fs_page_size = 0x0, .flash_size_kb = 2048 }, \
|
||||||
|
{ .eeprom_start = 0x405fb000, .fs_start = 0x405fb000, .fs_end = 0x405fb000, .fs_block_size = 0x0, .fs_page_size = 0x0, .flash_size_kb = 4096 }, \
|
||||||
|
{ .eeprom_start = 0x409fb000, .fs_start = 0x409fb000, .fs_end = 0x409fb000, .fs_block_size = 0x0, .fs_page_size = 0x0, .flash_size_kb = 8192 }, \
|
||||||
|
{ .eeprom_start = 0x411fb000, .fs_start = 0x411fb000, .fs_end = 0x411fb000, .fs_block_size = 0x0, .fs_page_size = 0x0, .flash_size_kb = 16384 }, \
|
||||||
|
{ .eeprom_start = 0x4027b000, .fs_start = 0x4027b000, .fs_end = 0x4027b000, .fs_block_size = 0x0, .fs_page_size = 0x0, .flash_size_kb = 512 }, \
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __FLASH_MAP_H
|
||||||
|
|
@ -24,8 +24,7 @@ extern "C" {
|
|||||||
#include "user_interface.h"
|
#include "user_interface.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" uint32_t _FS_start;
|
#include <flash_hal.h> // not "flash_hal.h": can use hijacked MOCK version
|
||||||
extern "C" uint32_t _FS_end;
|
|
||||||
|
|
||||||
UpdaterClass::UpdaterClass()
|
UpdaterClass::UpdaterClass()
|
||||||
{
|
{
|
||||||
@ -118,7 +117,7 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) {
|
|||||||
|
|
||||||
if (command == U_FLASH) {
|
if (command == U_FLASH) {
|
||||||
//address of the end of the space available for sketch and update
|
//address of the end of the space available for sketch and update
|
||||||
uintptr_t updateEndAddress = (uintptr_t)&_FS_start - 0x40200000;
|
uintptr_t updateEndAddress = FS_start - 0x40200000;
|
||||||
|
|
||||||
updateStartAddress = (updateEndAddress > roundedSize)? (updateEndAddress - roundedSize) : 0;
|
updateStartAddress = (updateEndAddress > roundedSize)? (updateEndAddress - roundedSize) : 0;
|
||||||
|
|
||||||
@ -135,14 +134,14 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (command == U_FS) {
|
else if (command == U_FS) {
|
||||||
if((uintptr_t)&_FS_start + roundedSize > (uintptr_t)&_FS_end) {
|
if(FS_start + roundedSize > FS_end) {
|
||||||
_setError(UPDATE_ERROR_SPACE);
|
_setError(UPDATE_ERROR_SPACE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ATOMIC_FS_UPDATE
|
#ifdef ATOMIC_FS_UPDATE
|
||||||
//address of the end of the space available for update
|
//address of the end of the space available for update
|
||||||
uintptr_t updateEndAddress = (uintptr_t)&_FS_start - 0x40200000;
|
uintptr_t updateEndAddress = FS_start - 0x40200000;
|
||||||
|
|
||||||
updateStartAddress = (updateEndAddress > roundedSize)? (updateEndAddress - roundedSize) : 0;
|
updateStartAddress = (updateEndAddress > roundedSize)? (updateEndAddress - roundedSize) : 0;
|
||||||
|
|
||||||
@ -151,7 +150,7 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
updateStartAddress = (uintptr_t)&_FS_start - 0x40200000;
|
updateStartAddress = FS_start - 0x40200000;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -314,7 +313,7 @@ bool UpdaterClass::end(bool evenIfRemaining){
|
|||||||
eboot_command ebcmd;
|
eboot_command ebcmd;
|
||||||
ebcmd.action = ACTION_COPY_RAW;
|
ebcmd.action = ACTION_COPY_RAW;
|
||||||
ebcmd.args[0] = _startAddress;
|
ebcmd.args[0] = _startAddress;
|
||||||
ebcmd.args[1] = (uintptr_t)&_FS_start - 0x40200000;
|
ebcmd.args[1] = FS_start - 0x40200000;
|
||||||
ebcmd.args[2] = _size;
|
ebcmd.args[2] = _size;
|
||||||
eboot_command_write(&ebcmd);
|
eboot_command_write(&ebcmd);
|
||||||
#endif
|
#endif
|
||||||
@ -460,6 +459,9 @@ bool UpdaterClass::_verifyEnd() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// it makes no sense to check flash size in auto flash mode
|
||||||
|
// (sketch size would have to be set in bin header, instead of flash size)
|
||||||
|
#if !FLASH_MAP_SUPPORT
|
||||||
uint32_t bin_flash_size = ESP.magicFlashChipSize((buf[3] & 0xf0) >> 4);
|
uint32_t bin_flash_size = ESP.magicFlashChipSize((buf[3] & 0xf0) >> 4);
|
||||||
|
|
||||||
// check if new bin fits to SPI flash
|
// check if new bin fits to SPI flash
|
||||||
@ -468,6 +470,7 @@ bool UpdaterClass::_verifyEnd() {
|
|||||||
_setError(UPDATE_ERROR_NEW_FLASH_CONFIG);
|
_setError(UPDATE_ERROR_NEW_FLASH_CONFIG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else if(_command == U_FS) {
|
} else if(_command == U_FS) {
|
||||||
|
@ -393,6 +393,12 @@ extern "C" void __disableWiFiAtBootTime (void)
|
|||||||
wifi_fpm_do_sleep(0xFFFFFFF);
|
wifi_fpm_do_sleep(0xFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if FLASH_MAP_SUPPORT
|
||||||
|
#include "flash_hal.h"
|
||||||
|
extern "C" void flashinit (void);
|
||||||
|
uint32_t __flashindex;
|
||||||
|
#endif
|
||||||
|
|
||||||
extern "C" void user_init(void) {
|
extern "C" void user_init(void) {
|
||||||
struct rst_info *rtc_info_ptr = system_get_rst_info();
|
struct rst_info *rtc_info_ptr = system_get_rst_info();
|
||||||
memcpy((void *) &resetInfo, (void *) rtc_info_ptr, sizeof(resetInfo));
|
memcpy((void *) &resetInfo, (void *) rtc_info_ptr, sizeof(resetInfo));
|
||||||
@ -421,6 +427,9 @@ extern "C" void user_init(void) {
|
|||||||
|
|
||||||
#if defined(MMU_IRAM_HEAP)
|
#if defined(MMU_IRAM_HEAP)
|
||||||
umm_init_iram();
|
umm_init_iram();
|
||||||
|
#endif
|
||||||
|
#if FLASH_MAP_SUPPORT
|
||||||
|
flashinit();
|
||||||
#endif
|
#endif
|
||||||
preinit(); // Prior to C++ Dynamic Init (not related to above init() ). Meant to be user redefinable.
|
preinit(); // Prior to C++ Dynamic Init (not related to above init() ). Meant to be user redefinable.
|
||||||
__disableWiFiAtBootTime(); // default weak function disables WiFi
|
__disableWiFiAtBootTime(); // default weak function disables WiFi
|
||||||
|
@ -68,3 +68,13 @@ int32_t flash_hal_erase(uint32_t addr, uint32_t size) {
|
|||||||
}
|
}
|
||||||
return FLASH_HAL_OK;
|
return FLASH_HAL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if FLASH_MAP_SUPPORT
|
||||||
|
|
||||||
|
// default weak configuration:
|
||||||
|
FLASH_MAP_SETUP_CONFIG_ATTR(__attribute__((weak)), FLASH_MAP_OTA_FS)
|
||||||
|
|
||||||
|
// can be overridden by user with:
|
||||||
|
//FLASH_MAP_SETUP_CONFIG(FLASH_MAP_some_configuration)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -24,18 +24,58 @@
|
|||||||
License along with this library; if not, write to the Free Software
|
License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
#ifdef ARDUINO
|
|
||||||
extern "C" uint32_t _FS_start;
|
|
||||||
extern "C" uint32_t _FS_end;
|
|
||||||
extern "C" uint32_t _FS_page;
|
|
||||||
extern "C" uint32_t _FS_block;
|
|
||||||
|
|
||||||
#define FS_PHYS_ADDR ((uint32_t) (&_FS_start) - 0x40200000)
|
#ifdef __cplusplus
|
||||||
#define FS_PHYS_SIZE ((uint32_t) (&_FS_end) - (uint32_t) (&_FS_start))
|
extern "C" {
|
||||||
#define FS_PHYS_PAGE ((uint32_t) &_FS_page)
|
|
||||||
#define FS_PHYS_BLOCK ((uint32_t) &_FS_block)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if FLASH_MAP_SUPPORT
|
||||||
|
#include <FlashMap.h>
|
||||||
|
|
||||||
|
extern uint32_t spi_flash_get_id (void); // <user_interface.h>
|
||||||
|
extern void flashinit(void);
|
||||||
|
extern uint32_t __flashindex;
|
||||||
|
extern const flash_map_s __flashdesc[];
|
||||||
|
|
||||||
|
#define FLASH_MAP_SETUP_CONFIG(conf) FLASH_MAP_SETUP_CONFIG_ATTR(,conf)
|
||||||
|
#define FLASH_MAP_SETUP_CONFIG_ATTR(attr, conf...) \
|
||||||
|
const flash_map_s __flashdesc[] PROGMEM = conf; \
|
||||||
|
void flashinit (void) attr; \
|
||||||
|
void flashinit (void) \
|
||||||
|
{ \
|
||||||
|
uint32_t flash_chip_size_kb = 1 << (((spi_flash_get_id() >> 16) & 0xff) - 10); \
|
||||||
|
for (__flashindex = 0; __flashindex < sizeof(__flashdesc) / sizeof(__flashdesc[0]); __flashindex++) \
|
||||||
|
if (__flashdesc[__flashindex].flash_size_kb == flash_chip_size_kb) \
|
||||||
|
return; \
|
||||||
|
panic(); /* configuration not found */ \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define EEPROM_start (__flashdesc[__flashindex].eeprom_start)
|
||||||
|
#define FS_start (__flashdesc[__flashindex].fs_start)
|
||||||
|
#define FS_end (__flashdesc[__flashindex].fs_end)
|
||||||
|
#define FS_block (__flashdesc[__flashindex].fs_block_size)
|
||||||
|
#define FS_page (__flashdesc[__flashindex].fs_page_size)
|
||||||
|
|
||||||
|
#else // !FLASH_MAP_SUPPORT
|
||||||
|
|
||||||
|
extern uint32_t _FS_start;
|
||||||
|
extern uint32_t _FS_end;
|
||||||
|
extern uint32_t _FS_page;
|
||||||
|
extern uint32_t _FS_block;
|
||||||
|
extern uint32_t _EEPROM_start;
|
||||||
|
#define EEPROM_start ((uint32_t)&_EEPROM_start)
|
||||||
|
#define FS_start ((uint32_t)&_FS_start)
|
||||||
|
#define FS_end ((uint32_t)&_FS_end)
|
||||||
|
#define FS_page ((uint32_t)&_FS_page)
|
||||||
|
#define FS_block ((uint32_t)&_FS_block)
|
||||||
|
|
||||||
|
#endif // FLASH_MAP_SUPPORT
|
||||||
|
|
||||||
|
#define FS_PHYS_ADDR ((uint32_t)FS_start - 0x40200000)
|
||||||
|
#define FS_PHYS_SIZE ((uint32_t)(FS_end - FS_start))
|
||||||
|
#define FS_PHYS_PAGE ((uint32_t)FS_page)
|
||||||
|
#define FS_PHYS_BLOCK ((uint32_t)FS_block)
|
||||||
|
|
||||||
// Return values of the following functions
|
// Return values of the following functions
|
||||||
#define FLASH_HAL_OK (0)
|
#define FLASH_HAL_OK (0)
|
||||||
#define FLASH_HAL_READ_ERROR (-1)
|
#define FLASH_HAL_READ_ERROR (-1)
|
||||||
@ -46,4 +86,8 @@ extern int32_t flash_hal_write(uint32_t addr, uint32_t size, const uint8_t *src)
|
|||||||
extern int32_t flash_hal_erase(uint32_t addr, uint32_t size);
|
extern int32_t flash_hal_erase(uint32_t addr, uint32_t size);
|
||||||
extern int32_t flash_hal_read(uint32_t addr, uint32_t size, uint8_t *dst);
|
extern int32_t flash_hal_read(uint32_t addr, uint32_t size, uint8_t *dst);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // !defined(flash_hal_h)
|
#endif // !defined(flash_hal_h)
|
||||||
|
@ -186,3 +186,8 @@ indeed off at boot and is powered on only when starting to be used with the
|
|||||||
regular API.
|
regular API.
|
||||||
|
|
||||||
Read more at `former WiFi persistent mode <../esp8266wifi/generic-class.rst#persistent>`__.
|
Read more at `former WiFi persistent mode <../esp8266wifi/generic-class.rst#persistent>`__.
|
||||||
|
|
||||||
|
How to resolve "undefined reference to ``flashinit`'" error ?
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Please read `flash layout <../filesystem.rst>`__ documentation entry.
|
||||||
|
@ -20,41 +20,43 @@ environment:
|
|||||||
Sketch OTA update File system EEPROM WiFi config (SDK)
|
Sketch OTA update File system EEPROM WiFi config (SDK)
|
||||||
|
|
||||||
File system size depends on the flash chip size. Depending on the board
|
File system size depends on the flash chip size. Depending on the board
|
||||||
which is selected in IDE, you have the following options for flash size:
|
which is selected in IDE, the following table shows options for flash size.
|
||||||
|
|
||||||
+---------------------------------+--------------------------+---------------------------+
|
Another option called ``Mapping defined by Hardware and Sketch`` is available.
|
||||||
| Board | Flash chip size, bytes | File system size, bytes |
|
It allows a sketch, not the user, to select FS configuration at boot
|
||||||
+=================================+==========================+===========================+
|
according to flash chip size.
|
||||||
| Generic module | 512k | 64k, 128k |
|
|
||||||
+---------------------------------+--------------------------+---------------------------+
|
This option is also enabled with this compilation define: ``-DFLASH_MAP_SUPPORT=1``.
|
||||||
| Generic module | 1M | 64k, 128k, 256k, 512k |
|
|
||||||
+---------------------------------+--------------------------+---------------------------+
|
There are three possible configurations:
|
||||||
| Generic module | 2M | 1M |
|
|
||||||
+---------------------------------+--------------------------+---------------------------+
|
- ``FLASH_MAP_OTA_FS``: largest available space for onboard FS, allowing OTA (noted 'OTA' in the table)
|
||||||
| Generic module | 4M | 1M, 2M, 3M |
|
- ``FLASH_MAP_MAX_FS``: largest available space for onboard FS (noted 'MAX' in the table)
|
||||||
+---------------------------------+--------------------------+---------------------------+
|
- ``FLASH_MAP_NO_FS``: no onboard FS
|
||||||
| Adafruit HUZZAH | 4M | 1M, 2M, 3M |
|
|
||||||
+---------------------------------+--------------------------+---------------------------+
|
Sketch can invoke a particular configuration by adding this line:
|
||||||
| ESPresso Lite 1.0 | 4M | 1M, 2M, 3M |
|
|
||||||
+---------------------------------+--------------------------+---------------------------+
|
.. code:: cpp
|
||||||
| ESPresso Lite 2.0 | 4M | 1M, 2M, 3M |
|
|
||||||
+---------------------------------+--------------------------+---------------------------+
|
FLASH_MAP_SETUP_CONFIG(FLASH_MAP_OTA_FS)
|
||||||
| NodeMCU 0.9 | 4M | 1M, 2M, 3M |
|
void setup () { ... }
|
||||||
+---------------------------------+--------------------------+---------------------------+
|
void loop () { ... }
|
||||||
| NodeMCU 1.0 | 4M | 1M, 2M, 3M |
|
|
||||||
+---------------------------------+--------------------------+---------------------------+
|
+-------+--------------------------+----------------------------------------------------------+
|
||||||
| Olimex MOD-WIFI-ESP8266(-DEV) | 2M | 1M |
|
| Board | Flash chip size (bytes) | File system size (bytes) |
|
||||||
+---------------------------------+--------------------------+---------------------------+
|
+=======+==========================+==========================================================+
|
||||||
| SparkFun Thing | 512k | 64k |
|
| Any | 512KBytes | 32KB(OTA), 64KB, 128KB(MAX) |
|
||||||
+---------------------------------+--------------------------+---------------------------+
|
+-------+--------------------------+----------------------------------------------------------+
|
||||||
| SweetPea ESP-210 | 4M | 1M, 2M, 3M |
|
| Any | 1MBytes | 64KB(OTA), 128KB, 144KB, 160KB, 192KB, 256KB, 512KB(MAX) |
|
||||||
+---------------------------------+--------------------------+---------------------------+
|
+-------+--------------------------+----------------------------------------------------------+
|
||||||
| WeMos D1 R1, R2 & mini | 4M | 1M, 2M, 3M |
|
| Any | 2MBytes | 64KB, 128KB, 256KB(OTA), 512KB, 1MB(MAX) |
|
||||||
+---------------------------------+--------------------------+---------------------------+
|
+-------+--------------------------+----------------------------------------------------------+
|
||||||
| ESPDuino | 4M | 1M, 2M, 3M |
|
| Any | 4MBytes | 1MB, 2MB(OTA), 3MB(MAX) |
|
||||||
+---------------------------------+--------------------------+---------------------------+
|
+-------+--------------------------+----------------------------------------------------------+
|
||||||
| WiFiduino | 4M | 1M, 2M, 3M |
|
| Any | 8MBytes | 6MB(OTA), 7MB(MAX) |
|
||||||
+---------------------------------+--------------------------+---------------------------+
|
+-------+--------------------------+----------------------------------------------------------+
|
||||||
|
| Any | 16MBytes | 14MB(OTA), 15MB(MAX) |
|
||||||
|
+-------+--------------------------+----------------------------------------------------------+
|
||||||
|
|
||||||
**Note:** to use any of file system functions in the sketch, add the
|
**Note:** to use any of file system functions in the sketch, add the
|
||||||
following include to the sketch:
|
following include to the sketch:
|
||||||
@ -63,6 +65,7 @@ following include to the sketch:
|
|||||||
|
|
||||||
//#include "FS.h" // SPIFFS is declared
|
//#include "FS.h" // SPIFFS is declared
|
||||||
#include "LittleFS.h" // LittleFS is declared
|
#include "LittleFS.h" // LittleFS is declared
|
||||||
|
//#include "SDFS.h" // SDFS is declared
|
||||||
|
|
||||||
SPIFFS Deprecation Warning
|
SPIFFS Deprecation Warning
|
||||||
--------------------------
|
--------------------------
|
||||||
|
@ -31,7 +31,7 @@ extern "C" {
|
|||||||
#include "spi_flash.h"
|
#include "spi_flash.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" uint32_t _EEPROM_start;
|
#include <flash_hal.h>
|
||||||
|
|
||||||
EEPROMClass::EEPROMClass(uint32_t sector)
|
EEPROMClass::EEPROMClass(uint32_t sector)
|
||||||
: _sector(sector)
|
: _sector(sector)
|
||||||
@ -39,7 +39,7 @@ EEPROMClass::EEPROMClass(uint32_t sector)
|
|||||||
}
|
}
|
||||||
|
|
||||||
EEPROMClass::EEPROMClass(void)
|
EEPROMClass::EEPROMClass(void)
|
||||||
: _sector((((uint32_t)&_EEPROM_start - 0x40200000) / SPI_FLASH_SEC_SIZE))
|
: _sector(((EEPROM_start - 0x40200000) / SPI_FLASH_SEC_SIZE))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ void ESP8266HTTPUpdateServerTemplate<ServerType>::setup(ESP8266WebServerTemplate
|
|||||||
if (_serial_output)
|
if (_serial_output)
|
||||||
Serial.printf("Update: %s\n", upload.filename.c_str());
|
Serial.printf("Update: %s\n", upload.filename.c_str());
|
||||||
if (upload.name == "filesystem") {
|
if (upload.name == "filesystem") {
|
||||||
size_t fsSize = ((size_t) &_FS_end - (size_t) &_FS_start);
|
size_t fsSize = ((size_t)FS_end - (size_t)FS_start);
|
||||||
close_all_fs();
|
close_all_fs();
|
||||||
if (!Update.begin(fsSize, U_FS)){//start with max available size
|
if (!Update.begin(fsSize, U_FS)){//start with max available size
|
||||||
if (_serial_output) Update.printError(Serial);
|
if (_serial_output) Update.printError(Serial);
|
||||||
|
@ -25,9 +25,7 @@
|
|||||||
|
|
||||||
#include "ESP8266httpUpdate.h"
|
#include "ESP8266httpUpdate.h"
|
||||||
#include <StreamString.h>
|
#include <StreamString.h>
|
||||||
|
#include <flash_hal.h>
|
||||||
extern "C" uint32_t _FS_start;
|
|
||||||
extern "C" uint32_t _FS_end;
|
|
||||||
|
|
||||||
ESP8266HTTPUpdate::ESP8266HTTPUpdate(void)
|
ESP8266HTTPUpdate::ESP8266HTTPUpdate(void)
|
||||||
: _httpClientTimeout(8000)
|
: _httpClientTimeout(8000)
|
||||||
@ -234,7 +232,7 @@ HTTPUpdateResult ESP8266HTTPUpdate::handleUpdate(HTTPClient& http, const String&
|
|||||||
if(len > 0) {
|
if(len > 0) {
|
||||||
bool startUpdate = true;
|
bool startUpdate = true;
|
||||||
if(spiffs) {
|
if(spiffs) {
|
||||||
size_t spiffsSize = ((size_t) &_FS_end - (size_t) &_FS_start);
|
size_t spiffsSize = ((size_t)FS_end - (size_t)FS_start);
|
||||||
if(len > (int) spiffsSize) {
|
if(len > (int) spiffsSize) {
|
||||||
DEBUG_HTTP_UPDATE("[httpUpdate] spiffsSize to low (%d) needed: %d\n", spiffsSize, len);
|
DEBUG_HTTP_UPDATE("[httpUpdate] spiffsSize to low (%d) needed: %d\n", spiffsSize, len);
|
||||||
startUpdate = false;
|
startUpdate = false;
|
||||||
@ -292,6 +290,9 @@ HTTPUpdateResult ESP8266HTTPUpdate::handleUpdate(HTTPClient& http, const String&
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// it makes no sense to check flash size in auto flash mode
|
||||||
|
// (sketch size would have to be set in bin header, instead of flash size)
|
||||||
|
#if !FLASH_MAP_SUPPORT
|
||||||
if (buf[0] == 0xe9) {
|
if (buf[0] == 0xe9) {
|
||||||
uint32_t bin_flash_size = ESP.magicFlashChipSize((buf[3] & 0xf0) >> 4);
|
uint32_t bin_flash_size = ESP.magicFlashChipSize((buf[3] & 0xf0) >> 4);
|
||||||
|
|
||||||
@ -303,6 +304,7 @@ HTTPUpdateResult ESP8266HTTPUpdate::handleUpdate(HTTPClient& http, const String&
|
|||||||
return HTTP_UPDATE_FAILED;
|
return HTTP_UPDATE_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if(runUpdate(*tcp, len, md5, command)) {
|
if(runUpdate(*tcp, len, md5, command)) {
|
||||||
ret = HTTP_UPDATE_OK;
|
ret = HTTP_UPDATE_OK;
|
||||||
|
10
platform.txt
10
platform.txt
@ -52,11 +52,17 @@ build.sdk=NONOSDK22x_190703
|
|||||||
#build.sdk=NONOSDK22x_191024
|
#build.sdk=NONOSDK22x_191024
|
||||||
#build.sdk=NONOSDK22x_191105
|
#build.sdk=NONOSDK22x_191105
|
||||||
|
|
||||||
|
# These are not overriden when FS is not configured
|
||||||
|
build.eeprom_start=
|
||||||
|
build.spiffs_start=
|
||||||
|
build.spiffs_end=
|
||||||
|
build.spiffs_blocksize=
|
||||||
|
|
||||||
compiler.path={runtime.tools.xtensa-lx106-elf-gcc.path}/bin/
|
compiler.path={runtime.tools.xtensa-lx106-elf-gcc.path}/bin/
|
||||||
compiler.sdk.path={runtime.platform.path}/tools/sdk
|
compiler.sdk.path={runtime.platform.path}/tools/sdk
|
||||||
|
|
||||||
compiler.libc.path={runtime.platform.path}/tools/sdk/libc/xtensa-lx106-elf
|
compiler.libc.path={runtime.platform.path}/tools/sdk/libc/xtensa-lx106-elf
|
||||||
compiler.cpreprocessor.flags=-D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ -D_GNU_SOURCE "-I{compiler.sdk.path}/include" "-I{compiler.sdk.path}/{build.lwip_include}" "-I{compiler.libc.path}/include" "-I{build.path}/core"
|
compiler.cpreprocessor.flags=-D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ -D_GNU_SOURCE -DESP8266 "-I{compiler.sdk.path}/include" "-I{compiler.sdk.path}/{build.lwip_include}" "-I{compiler.libc.path}/include" "-I{build.path}/core"
|
||||||
|
|
||||||
# support precompiled libraries in IDE v1.8.6+
|
# support precompiled libraries in IDE v1.8.6+
|
||||||
compiler.libraries.ldflags=
|
compiler.libraries.ldflags=
|
||||||
@ -86,7 +92,7 @@ compiler.elf2hex.flags=
|
|||||||
compiler.size.cmd=xtensa-lx106-elf-size
|
compiler.size.cmd=xtensa-lx106-elf-size
|
||||||
|
|
||||||
# This can be overridden in boards.txt
|
# This can be overridden in boards.txt
|
||||||
build.extra_flags=-DESP8266
|
build.extra_flags=
|
||||||
|
|
||||||
# These can be overridden in platform.local.txt
|
# These can be overridden in platform.local.txt
|
||||||
compiler.c.extra_flags=
|
compiler.c.extra_flags=
|
||||||
|
@ -2,18 +2,26 @@
|
|||||||
#define flash_hal_mock_h
|
#define flash_hal_mock_h
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <../../cores/esp8266/flash_hal.h>
|
||||||
|
|
||||||
|
#undef FS_start
|
||||||
|
#undef FS_end
|
||||||
|
#define FS_start 0
|
||||||
|
#define FS_end 0
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
extern uint32_t s_phys_addr;
|
|
||||||
extern uint32_t s_phys_size;
|
extern uint32_t s_phys_addr;
|
||||||
extern uint32_t s_phys_page;
|
extern uint32_t s_phys_size;
|
||||||
extern uint32_t s_phys_block;
|
extern uint32_t s_phys_page;
|
||||||
extern uint8_t* s_phys_data;
|
extern uint32_t s_phys_block;
|
||||||
}
|
extern uint8_t* s_phys_data;
|
||||||
|
|
||||||
extern int32_t flash_hal_read(uint32_t addr, uint32_t size, uint8_t *dst);
|
extern int32_t flash_hal_read(uint32_t addr, uint32_t size, uint8_t *dst);
|
||||||
extern int32_t flash_hal_write(uint32_t addr, uint32_t size, const uint8_t *src);
|
extern int32_t flash_hal_write(uint32_t addr, uint32_t size, const uint8_t *src);
|
||||||
extern int32_t flash_hal_erase(uint32_t addr, uint32_t size);
|
extern int32_t flash_hal_erase(uint32_t addr, uint32_t size);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -3,6 +3,8 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "flash_hal.h"
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
uint32_t s_phys_addr = 0;
|
uint32_t s_phys_addr = 0;
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include "flash_hal_mock.h"
|
|
||||||
|
|
||||||
#define LITTLEFS_FILE_NAME "littlefs.bin"
|
#define LITTLEFS_FILE_NAME "littlefs.bin"
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <FS.h>
|
#include <FS.h>
|
||||||
#include "flash_hal_mock.h"
|
#include "flash_hal.h"
|
||||||
|
|
||||||
#define DEFAULT_LITTLEFS_FILE_NAME "littlefs.bin"
|
#define DEFAULT_LITTLEFS_FILE_NAME "littlefs.bin"
|
||||||
|
|
||||||
|
@ -28,8 +28,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
|
||||||
#include "flash_hal_mock.h"
|
|
||||||
|
|
||||||
#define SPIFFS_FILE_NAME "spiffs.bin"
|
#define SPIFFS_FILE_NAME "spiffs.bin"
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <FS.h>
|
#include <FS.h>
|
||||||
#include "flash_hal_mock.h"
|
#include "flash_hal.h"
|
||||||
|
|
||||||
#define DEFAULT_SPIFFS_FILE_NAME "spiffs.bin"
|
#define DEFAULT_SPIFFS_FILE_NAME "spiffs.bin"
|
||||||
|
|
||||||
|
@ -792,15 +792,15 @@ boards = collections.OrderedDict([
|
|||||||
( '.menu.BoardModel.primo', 'Primo' ),
|
( '.menu.BoardModel.primo', 'Primo' ),
|
||||||
( '.menu.BoardModel.primo.build.board', 'ESP8266_ARDUINO_PRIMO' ),
|
( '.menu.BoardModel.primo.build.board', 'ESP8266_ARDUINO_PRIMO' ),
|
||||||
( '.menu.BoardModel.primo.build.variant', 'arduino_spi' ),
|
( '.menu.BoardModel.primo.build.variant', 'arduino_spi' ),
|
||||||
( '.menu.BoardModel.primo.build.extra_flags', '-DF_CRYSTAL=40000000 -DESP8266' ),
|
( '.menu.BoardModel.primo.build.extra_flags', '-DF_CRYSTAL=40000000' ),
|
||||||
( '.menu.BoardModel.unowifideved', 'Uno WiFi' ),
|
( '.menu.BoardModel.unowifideved', 'Uno WiFi' ),
|
||||||
( '.menu.BoardModel.unowifideved.build.board', 'ESP8266_ARDUINO_UNOWIFI' ),
|
( '.menu.BoardModel.unowifideved.build.board', 'ESP8266_ARDUINO_UNOWIFI' ),
|
||||||
( '.menu.BoardModel.unowifideved.build.variant', 'arduino_uart' ),
|
( '.menu.BoardModel.unowifideved.build.variant', 'arduino_uart' ),
|
||||||
( '.menu.BoardModel.unowifideved.build.extra_flags=-DF_CRYSTAL', '40000000 -DESP8266' ),
|
( '.menu.BoardModel.unowifideved.build.extra_flags=-DF_CRYSTAL', '40000000' ),
|
||||||
( '.menu.BoardModel.starottodeved', 'Star OTTO' ),
|
( '.menu.BoardModel.starottodeved', 'Star OTTO' ),
|
||||||
( '.menu.BoardModel.starottodeved.build.variant', 'arduino_uart' ),
|
( '.menu.BoardModel.starottodeved.build.variant', 'arduino_uart' ),
|
||||||
( '.menu.BoardModel.starottodeved.build.board', 'ESP8266_ARDUINO_STAR_OTTO' ),
|
( '.menu.BoardModel.starottodeved.build.board', 'ESP8266_ARDUINO_STAR_OTTO' ),
|
||||||
( '.menu.BoardModel.starottodeved.build.extra_flags', '-DF_CRYSTAL=40000000 -DESP8266' ),
|
( '.menu.BoardModel.starottodeved.build.extra_flags', '-DF_CRYSTAL=40000000' ),
|
||||||
]),
|
]),
|
||||||
'macro': [
|
'macro': [
|
||||||
'resetmethod_ck',
|
'resetmethod_ck',
|
||||||
@ -949,7 +949,6 @@ boards = collections.OrderedDict([
|
|||||||
'opts': {
|
'opts': {
|
||||||
'.build.board': 'ESP8266_SONOFF_SV',
|
'.build.board': 'ESP8266_SONOFF_SV',
|
||||||
'.build.variant': 'itead',
|
'.build.variant': 'itead',
|
||||||
'.build.extra_flags': '-DESP8266',
|
|
||||||
'.build.flash_size': '1M',
|
'.build.flash_size': '1M',
|
||||||
'.menu.BoardModel.sonoffSV': 'ITEAD Sonoff SV',
|
'.menu.BoardModel.sonoffSV': 'ITEAD Sonoff SV',
|
||||||
'.menu.BoardModel.sonoffSV.build.board': 'ESP8266_SONOFF_SV',
|
'.menu.BoardModel.sonoffSV.build.board': 'ESP8266_SONOFF_SV',
|
||||||
@ -1072,7 +1071,7 @@ macros = {
|
|||||||
'crystalfreq_menu': collections.OrderedDict([
|
'crystalfreq_menu': collections.OrderedDict([
|
||||||
( '.menu.CrystalFreq.26', '26 MHz' ),
|
( '.menu.CrystalFreq.26', '26 MHz' ),
|
||||||
( '.menu.CrystalFreq.40', '40 MHz' ),
|
( '.menu.CrystalFreq.40', '40 MHz' ),
|
||||||
( '.menu.CrystalFreq.40.build.extra_flags', '-DF_CRYSTAL=40000000 -DESP8266' ),
|
( '.menu.CrystalFreq.40.build.extra_flags', '-DF_CRYSTAL=40000000' ),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
'flashfreq_menu': collections.OrderedDict([
|
'flashfreq_menu': collections.OrderedDict([
|
||||||
@ -1372,7 +1371,7 @@ def all_debug ():
|
|||||||
################################################################
|
################################################################
|
||||||
# flash size
|
# flash size
|
||||||
|
|
||||||
def flash_map (flashsize_kb, fs_kb = 0):
|
def flash_map (flashsize_kb, fs_kb = 0, conf_name = ''):
|
||||||
|
|
||||||
# mapping:
|
# mapping:
|
||||||
# flash | reserved | empty | spiffs | eeprom | rf-cal | sdk-wifi-settings
|
# flash | reserved | empty | spiffs | eeprom | rf-cal | sdk-wifi-settings
|
||||||
@ -1403,7 +1402,7 @@ def flash_map (flashsize_kb, fs_kb = 0):
|
|||||||
fs_blocksize = 8192
|
fs_blocksize = 8192
|
||||||
|
|
||||||
# Adjust FS_end to be a multiple of the block size
|
# Adjust FS_end to be a multiple of the block size
|
||||||
fs_end = fs_blocksize * (int)((fs_end - fs_start)/fs_blocksize) + fs_start;
|
fs_end = fs_blocksize * (int)((fs_end - fs_start)/fs_blocksize) + fs_start
|
||||||
|
|
||||||
max_ota_size = min(max_upload_size, fs_start / 2) # =(max_upload_size+empty_size)/2
|
max_ota_size = min(max_upload_size, fs_start / 2) # =(max_upload_size+empty_size)/2
|
||||||
strsize = str(int(flashsize_kb / 1024)) + 'M' if (flashsize_kb >= 1024) else str(flashsize_kb) + 'K'
|
strsize = str(int(flashsize_kb / 1024)) + 'M' if (flashsize_kb >= 1024) else str(flashsize_kb) + 'K'
|
||||||
@ -1417,12 +1416,13 @@ def flash_map (flashsize_kb, fs_kb = 0):
|
|||||||
d = collections.OrderedDict([
|
d = collections.OrderedDict([
|
||||||
( menu, strsize + 'B (FS:' + desc + ' OTA:~%iKB)' % (max_ota_size / 1024)),
|
( menu, strsize + 'B (FS:' + desc + ' OTA:~%iKB)' % (max_ota_size / 1024)),
|
||||||
( menub + 'flash_size', strsize ),
|
( menub + 'flash_size', strsize ),
|
||||||
( menub + 'flash_size_bytes', "0x%X" % (flashsize_kb * 1024)),
|
#( menub + 'flash_size_bytes', "0x%X" % (flashsize_kb * 1024)),
|
||||||
( menub + 'flash_ld', ld ),
|
( menub + 'flash_ld', ld ),
|
||||||
( menub + 'spiffs_pagesize', '256' ),
|
( menub + 'spiffs_pagesize', '256' ),
|
||||||
( menu + '.upload.maximum_size', "%i" % max_upload_size ),
|
#( menu + '.upload.maximum_size', "%i" % max_upload_size ),
|
||||||
( menub + 'rfcal_addr', "0x%X" % rfcal_addr)
|
( menub + 'rfcal_addr', "0x%X" % rfcal_addr)
|
||||||
])
|
])
|
||||||
|
|
||||||
if fs_kb > 0:
|
if fs_kb > 0:
|
||||||
d.update(collections.OrderedDict([
|
d.update(collections.OrderedDict([
|
||||||
( menub + 'spiffs_start', "0x%05X" % fs_start ),
|
( menub + 'spiffs_start', "0x%05X" % fs_start ),
|
||||||
@ -1430,6 +1430,10 @@ def flash_map (flashsize_kb, fs_kb = 0):
|
|||||||
( menub + 'spiffs_blocksize', "%i" % fs_blocksize ),
|
( menub + 'spiffs_blocksize', "%i" % fs_blocksize ),
|
||||||
]))
|
]))
|
||||||
|
|
||||||
|
#d.update(collections.OrderedDict([
|
||||||
|
# ( menub + 'eeprom_start', "0x%05X" % eeprom_start ),
|
||||||
|
# ]))
|
||||||
|
|
||||||
if ldshow:
|
if ldshow:
|
||||||
if ldgen:
|
if ldgen:
|
||||||
|
|
||||||
@ -1450,6 +1454,16 @@ def flash_map (flashsize_kb, fs_kb = 0):
|
|||||||
else:
|
else:
|
||||||
page = 0x100
|
page = 0x100
|
||||||
|
|
||||||
|
if not conf_name == '':
|
||||||
|
if not conf_name in c_flash_map:
|
||||||
|
c_flash_map[conf_name] = collections.OrderedDict([])
|
||||||
|
c_flash_map[conf_name][flashsize_kb] = \
|
||||||
|
'.eeprom_start = ' + hex(spi + eeprom_start) + ', ' \
|
||||||
|
+ '.fs_start = ' + hex(spi + fs_start) + ', ' \
|
||||||
|
+ '.fs_end = ' + hex(spi + fs_end) + ', ' \
|
||||||
|
+ '.fs_block_size = ' + hex(fs_blocksize)+ ', ' \
|
||||||
|
+ '.fs_page_size = ' + hex(page) + ', ' \
|
||||||
|
|
||||||
print("/* Flash Split for %s chips */" % strsize)
|
print("/* Flash Split for %s chips */" % strsize)
|
||||||
print("/* sketch @0x%X (~%dKB) (%dB) */" % (spi, (max_upload_size / 1024), max_upload_size))
|
print("/* sketch @0x%X (~%dKB) (%dB) */" % (spi, (max_upload_size / 1024), max_upload_size))
|
||||||
empty_size = fs_start - max_upload_size
|
empty_size = fs_start - max_upload_size
|
||||||
@ -1469,15 +1483,15 @@ def flash_map (flashsize_kb, fs_kb = 0):
|
|||||||
print(" irom0_0_seg : org = 0x40201010, len = 0x%x" % max_upload_size)
|
print(" irom0_0_seg : org = 0x40201010, len = 0x%x" % max_upload_size)
|
||||||
print("}")
|
print("}")
|
||||||
print("")
|
print("")
|
||||||
print("PROVIDE ( _FS_start = 0x%08X );" % (0x40200000 + fs_start))
|
print("PROVIDE ( _FS_start = 0x%08X );" % (spi + fs_start))
|
||||||
print("PROVIDE ( _FS_end = 0x%08X );" % (0x40200000 + fs_end))
|
print("PROVIDE ( _FS_end = 0x%08X );" % (spi + fs_end))
|
||||||
print("PROVIDE ( _FS_page = 0x%X );" % page)
|
print("PROVIDE ( _FS_page = 0x%X );" % page)
|
||||||
print("PROVIDE ( _FS_block = 0x%X );" % fs_blocksize)
|
print("PROVIDE ( _FS_block = 0x%X );" % fs_blocksize)
|
||||||
print("PROVIDE ( _EEPROM_start = 0x%08x );" % (0x40200000 + eeprom_start))
|
print("PROVIDE ( _EEPROM_start = 0x%08x );" % (spi + eeprom_start))
|
||||||
# Re-add deprecated symbols pointing to the same address as the new standard ones
|
# Re-add deprecated symbols pointing to the same address as the new standard ones
|
||||||
print("/* The following symbols are DEPRECATED and will be REMOVED in a future release */")
|
print("/* The following symbols are DEPRECATED and will be REMOVED in a future release */")
|
||||||
print("PROVIDE ( _SPIFFS_start = 0x%08X );" % (0x40200000 + fs_start))
|
print("PROVIDE ( _SPIFFS_start = 0x%08X );" % (spi + fs_start))
|
||||||
print("PROVIDE ( _SPIFFS_end = 0x%08X );" % (0x40200000 + fs_end))
|
print("PROVIDE ( _SPIFFS_end = 0x%08X );" % (spi + fs_end))
|
||||||
print("PROVIDE ( _SPIFFS_page = 0x%X );" % page)
|
print("PROVIDE ( _SPIFFS_page = 0x%X );" % page)
|
||||||
print("PROVIDE ( _SPIFFS_block = 0x%X );" % fs_blocksize)
|
print("PROVIDE ( _SPIFFS_block = 0x%X );" % fs_blocksize)
|
||||||
print("")
|
print("")
|
||||||
@ -1498,44 +1512,101 @@ def all_flash_map ():
|
|||||||
f8m = collections.OrderedDict([])
|
f8m = collections.OrderedDict([])
|
||||||
f16m = collections.OrderedDict([])
|
f16m = collections.OrderedDict([])
|
||||||
|
|
||||||
# flash(KB) spiffs(KB)
|
global c_flash_map
|
||||||
|
c_flash_map = collections.OrderedDict([])
|
||||||
|
|
||||||
f1m.update( flash_map( 1024, 64 ))
|
# flash(KB) spiffs(KB) confname(C)
|
||||||
|
|
||||||
|
f1m.update( flash_map( 1024, 64, 'OTA_FS' ))
|
||||||
f1m.update( flash_map( 1024, 128 ))
|
f1m.update( flash_map( 1024, 128 ))
|
||||||
f1m.update( flash_map( 1024, 144 ))
|
f1m.update( flash_map( 1024, 144 ))
|
||||||
f1m.update( flash_map( 1024, 160 ))
|
f1m.update( flash_map( 1024, 160 ))
|
||||||
f1m.update( flash_map( 1024, 192 ))
|
f1m.update( flash_map( 1024, 192 ))
|
||||||
f1m.update( flash_map( 1024, 256 ))
|
f1m.update( flash_map( 1024, 256 ))
|
||||||
f1m.update( flash_map( 1024, 512 ))
|
f1m.update( flash_map( 1024, 512, 'MAX_FS' ))
|
||||||
f1m.update( flash_map( 1024))
|
f1m.update( flash_map( 1024, 0, 'NO_FS' ))
|
||||||
|
|
||||||
f2m.update( flash_map( 2*1024, 64 ))
|
f2m.update( flash_map( 2*1024, 64 ))
|
||||||
f2m.update( flash_map( 2*1024, 128 ))
|
f2m.update( flash_map( 2*1024, 128 ))
|
||||||
f2m.update( flash_map( 2*1024, 256 ))
|
f2m.update( flash_map( 2*1024, 256, 'OTA_FS' ))
|
||||||
f2m.update( flash_map( 2*1024, 512 ))
|
f2m.update( flash_map( 2*1024, 512 ))
|
||||||
f2m.update( flash_map( 2*1024, 1024 ))
|
f2m.update( flash_map( 2*1024, 1024, 'MAX_FS' ))
|
||||||
f2m.update( flash_map( 2*1024))
|
f2m.update( flash_map( 2*1024, 0, 'NO_FS' ))
|
||||||
|
|
||||||
f4m.update( flash_map( 4*1024, 2*1024 ))
|
f4m.update( flash_map( 4*1024, 2*1024, 'OTA_FS' ))
|
||||||
f4m.update( flash_map( 4*1024, 3*1024 ))
|
f4m.update( flash_map( 4*1024, 3*1024, 'MAX_FS' ))
|
||||||
f4m.update( flash_map( 4*1024, 1024 ))
|
f4m.update( flash_map( 4*1024, 1024 ))
|
||||||
f4m.update( flash_map( 4*1024))
|
f4m.update( flash_map( 4*1024, 0, 'NO_FS' ))
|
||||||
|
|
||||||
f8m.update( flash_map( 8*1024, 6*1024 ))
|
f8m.update( flash_map( 8*1024, 6*1024, 'OTA_FS' ))
|
||||||
f8m.update( flash_map( 8*1024, 7*1024 ))
|
f8m.update( flash_map( 8*1024, 7*1024, 'MAX_FS' ))
|
||||||
|
f8m.update( flash_map( 8*1024, 0, 'NO_FS' ))
|
||||||
|
|
||||||
f16m.update(flash_map( 16*1024, 14*1024 ))
|
f16m.update(flash_map( 16*1024, 14*1024, 'OTA_FS' ))
|
||||||
f16m.update(flash_map( 16*1024, 15*1024 ))
|
f16m.update(flash_map( 16*1024, 15*1024, 'MAX_FS' ))
|
||||||
|
f16m.update(flash_map( 16*1024, 0, 'NO_FS' ))
|
||||||
|
|
||||||
f512.update(flash_map( 512, 32 ))
|
f512.update(flash_map( 512, 32, 'OTA_FS' ))
|
||||||
f512.update(flash_map( 512, 64 ))
|
f512.update(flash_map( 512, 64 ))
|
||||||
f512.update(flash_map( 512, 128 ))
|
f512.update(flash_map( 512, 128, 'MAX_FS' ))
|
||||||
f512.update(flash_map( 512))
|
f512.update(flash_map( 512, 0, 'NO_FS' ))
|
||||||
|
|
||||||
if ldgen:
|
if ldgen:
|
||||||
print("generated: ldscripts (in %s)" % lddir)
|
print("generated: ldscripts (in %s)" % lddir)
|
||||||
|
|
||||||
|
if ldshow:
|
||||||
|
if ldgen:
|
||||||
|
realstdout = sys.stdout
|
||||||
|
sys.stdout = open('cores/esp8266/FlashMap.h', 'w')
|
||||||
|
|
||||||
|
define = '\n'
|
||||||
|
define += '// - do not edit - autogenerated by boards.txt.py\n'
|
||||||
|
define += '\n'
|
||||||
|
define += '#ifndef __FLASH_MAP_H\n'
|
||||||
|
define += '#define __FLASH_MAP_H\n'
|
||||||
|
define += '\n'
|
||||||
|
define += '#include <stdint.h>\n'
|
||||||
|
define += '#include <stddef.h>\n'
|
||||||
|
define += '\n'
|
||||||
|
define += 'typedef struct\n'
|
||||||
|
define += '{\n'
|
||||||
|
define += ' uint32_t eeprom_start;\n'
|
||||||
|
define += ' uint32_t fs_start;\n'
|
||||||
|
define += ' uint32_t fs_end;\n'
|
||||||
|
define += ' uint32_t fs_block_size;\n'
|
||||||
|
define += ' uint32_t fs_page_size;\n'
|
||||||
|
define += ' uint32_t flash_size_kb;\n'
|
||||||
|
define += '} flash_map_s;\n'
|
||||||
|
define += '\n'
|
||||||
|
define += '/*\n'
|
||||||
|
define += ' Following definitions map the above structure, one per line.\n'
|
||||||
|
define += ' FLASH_MAP_* is a user choice in sketch:\n'
|
||||||
|
define += ' `FLASH_MAP_SETUP_CONFIG(FLASH_MAP_OTA_FS)`\n'
|
||||||
|
define += ' Configuration is made at boot with detected flash chip size (last argument 512..16384)\n'
|
||||||
|
define += ' Other values are defined from `tools/boards.txt.py`.\n'
|
||||||
|
define += '*/\n'
|
||||||
|
for i in c_flash_map:
|
||||||
|
define += '\n#define FLASH_MAP_' + i + ' \\\n { \\\n'
|
||||||
|
for d in c_flash_map[i]:
|
||||||
|
define += ' { ' + c_flash_map[i][d] + '.flash_size_kb = ' + str(d) + ' }, \\\n'
|
||||||
|
define += ' }\n'
|
||||||
|
define += '\n#endif // __FLASH_MAP_H\n'
|
||||||
|
|
||||||
|
print(define)
|
||||||
|
|
||||||
|
if ldgen:
|
||||||
|
sys.stdout.close()
|
||||||
|
sys.stdout = realstdout
|
||||||
|
print("generated: flash map config file (in cores/esp8266/FlashMap.h)")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
'autoflash': {
|
||||||
|
'.menu.eesz.autoflash': 'Mapping defined by Hardware and Sketch',
|
||||||
|
'.menu.eesz.autoflash.build.flash_size': '16M',
|
||||||
|
'.menu.eesz.autoflash.build.flash_ld': 'eagle.flash.auto.ld',
|
||||||
|
'.menu.eesz.autoflash.build.extra_flags': '-DFLASH_MAP_SUPPORT=1',
|
||||||
|
'.menu.eesz.autoflash.upload.maximum_size': '1044464',
|
||||||
|
},
|
||||||
'512K': f512,
|
'512K': f512,
|
||||||
'1M': f1m,
|
'1M': f1m,
|
||||||
'2M': f2m,
|
'2M': f2m,
|
||||||
@ -1551,7 +1622,7 @@ def led (name, default, ledList):
|
|||||||
led = collections.OrderedDict([
|
led = collections.OrderedDict([
|
||||||
('.menu.led.' + str(default), str(default)),
|
('.menu.led.' + str(default), str(default)),
|
||||||
('.menu.led.' + str(default) + '.build.led', '-DLED_BUILTIN=' + str(default)),
|
('.menu.led.' + str(default) + '.build.led', '-DLED_BUILTIN=' + str(default)),
|
||||||
]);
|
])
|
||||||
for i in ledList: # Make range incluside of max (16), since there are really 16 GPIOS not 15
|
for i in ledList: # Make range incluside of max (16), since there are really 16 GPIOS not 15
|
||||||
if not i == default:
|
if not i == default:
|
||||||
led.update(
|
led.update(
|
||||||
@ -1666,7 +1737,7 @@ def all_boards ():
|
|||||||
sortedrequiredfirst = requiredboards + [ item for item in boardlistsortedbydisplayedname if item not in requiredboards ]
|
sortedrequiredfirst = requiredboards + [ item for item in boardlistsortedbydisplayedname if item not in requiredboards ]
|
||||||
for id in sortedrequiredfirst:
|
for id in sortedrequiredfirst:
|
||||||
if id not in boards:
|
if id not in boards:
|
||||||
missingboards += [ id ];
|
missingboards += [ id ]
|
||||||
continue
|
continue
|
||||||
|
|
||||||
print('##############################################################')
|
print('##############################################################')
|
||||||
@ -1692,6 +1763,8 @@ def all_boards ():
|
|||||||
else:
|
else:
|
||||||
macrolist += speeds[default_speed]
|
macrolist += speeds[default_speed]
|
||||||
|
|
||||||
|
macrolist += [ 'autoflash' ]
|
||||||
|
|
||||||
for block in macrolist:
|
for block in macrolist:
|
||||||
for optname in macros[block]:
|
for optname in macros[block]:
|
||||||
if not ('opts' in board) or not (optname in board['opts']):
|
if not ('opts' in board) or not (optname in board['opts']):
|
||||||
|
11
tools/sdk/ld/eagle.flash.auto.ld
Normal file
11
tools/sdk/ld/eagle.flash.auto.ld
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/* Flash Split */
|
||||||
|
/* sketch @0x40200000 (~1019KB) (1044464B) = MAX */
|
||||||
|
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
dport0_0_seg : org = 0x3FF00000, len = 0x10
|
||||||
|
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
|
||||||
|
irom0_0_seg : org = 0x40201010, len = 0xfeff0
|
||||||
|
}
|
||||||
|
|
||||||
|
INCLUDE "local.eagle.app.v6.common.ld"
|
Loading…
x
Reference in New Issue
Block a user