mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
bootloader, menuconfig: add flash size setting support
This commit is contained in:
parent
7104284e31
commit
42827ff869
@ -51,7 +51,7 @@ enum {
|
||||
SPI_SPEED_20M,
|
||||
SPI_SPEED_80M = 0xF
|
||||
};
|
||||
/*suppport flash size in esp32 */
|
||||
/*supported flash sizes*/
|
||||
enum {
|
||||
SPI_SIZE_1MB = 0,
|
||||
SPI_SIZE_2MB,
|
||||
|
@ -58,6 +58,7 @@ void IRAM_ATTR set_cache_and_start_app(uint32_t drom_addr,
|
||||
uint32_t irom_load_addr,
|
||||
uint32_t irom_size,
|
||||
uint32_t entry_addr);
|
||||
static void update_flash_config(struct flash_hdr* pfhdr);
|
||||
|
||||
|
||||
void IRAM_ATTR call_start_cpu0()
|
||||
@ -258,7 +259,7 @@ void bootloader_main()
|
||||
memset(&bs, 0, sizeof(bs));
|
||||
|
||||
ESP_LOGI(TAG, "compile time " __TIME__ );
|
||||
/* close watch dog here */
|
||||
/* disable watch dog here */
|
||||
REG_CLR_BIT( RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_FLASHBOOT_MOD_EN );
|
||||
REG_CLR_BIT( TIMG_WDTCONFIG0_REG(0), TIMG_WDT_FLASHBOOT_MOD_EN );
|
||||
SPIUnlock();
|
||||
@ -269,6 +270,8 @@ void bootloader_main()
|
||||
|
||||
print_flash_info(&fhdr);
|
||||
|
||||
update_flash_config(&fhdr);
|
||||
|
||||
if (!load_partition_table(&bs, PARTITION_ADD)) {
|
||||
ESP_LOGE(TAG, "load partition table error!");
|
||||
return;
|
||||
@ -364,7 +367,7 @@ void unpack_load_app(const partition_pos_t* partition)
|
||||
uint32_t irom_size = 0;
|
||||
|
||||
/* Reload the RTC memory sections whenever a non-deepsleep reset
|
||||
is occuring */
|
||||
is occurring */
|
||||
bool load_rtc_memory = rtc_get_reset_reason(0) != DEEPSLEEP_RESET;
|
||||
|
||||
ESP_LOGD(TAG, "bin_header: %u %u %u %u %08x", image_header.magic,
|
||||
@ -482,6 +485,36 @@ void IRAM_ATTR set_cache_and_start_app(
|
||||
(*entry)();
|
||||
}
|
||||
|
||||
static void update_flash_config(struct flash_hdr* pfhdr)
|
||||
{
|
||||
uint32_t size;
|
||||
switch(pfhdr->spi_size) {
|
||||
case SPI_SIZE_1MB:
|
||||
size = 1;
|
||||
break;
|
||||
case SPI_SIZE_2MB:
|
||||
size = 2;
|
||||
break;
|
||||
case SPI_SIZE_4MB:
|
||||
size = 4;
|
||||
break;
|
||||
case SPI_SIZE_8MB:
|
||||
size = 8;
|
||||
break;
|
||||
case SPI_SIZE_16MB:
|
||||
size = 16;
|
||||
break;
|
||||
default:
|
||||
size = 2;
|
||||
}
|
||||
Cache_Read_Disable( 0 );
|
||||
// Set flash chip size
|
||||
SPIParamCfg(g_rom_flashchip.deviceId, size * 0x100000, 0x10000, 0x1000, 0x100, 0xffff);
|
||||
// TODO: set mode
|
||||
// TODO: set frequency
|
||||
Cache_Flush(0);
|
||||
Cache_Read_Enable( 0 );
|
||||
}
|
||||
|
||||
void print_flash_info(struct flash_hdr* pfhdr)
|
||||
{
|
||||
|
@ -503,6 +503,12 @@ void SPI_Write_Encrypt_Disable(void);
|
||||
*/
|
||||
SpiFlashOpResult SPI_Encrypt_Write(uint32_t flash_addr, uint32_t *data, uint32_t len);
|
||||
|
||||
|
||||
/** @brief Global SpiFlashChip structure used by ROM functions
|
||||
*
|
||||
*/
|
||||
extern SpiFlashChip g_rom_flashchip;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
@ -286,6 +286,7 @@ PROVIDE ( _global_impure_ptr = 0x3ffae0b0 );
|
||||
PROVIDE ( gmtime = 0x40059848 );
|
||||
PROVIDE ( gmtime_r = 0x40059868 );
|
||||
PROVIDE ( g_phyFuns_instance = 0x3ffae0c4 );
|
||||
PROVIDE ( g_rom_flashchip = 0x3ffae270 );
|
||||
PROVIDE ( gpio_init = 0x40009c20 );
|
||||
PROVIDE ( gpio_input_get = 0x40009b88 );
|
||||
PROVIDE ( gpio_input_get_high = 0x40009b9c );
|
||||
|
@ -94,4 +94,31 @@ config ESPTOOLPY_FLASHFREQ
|
||||
default "26m" if ESPTOOLPY_FLASHFREQ_26M
|
||||
default "20m" if ESPTOOLPY_FLASHFREQ_20M
|
||||
|
||||
|
||||
choice ESPTOOLPY_FLASHSIZE
|
||||
prompt "Flash size"
|
||||
default ESPTOOLPY_FLASHSIZE_2MB
|
||||
help
|
||||
SPI flash size, in megabytes
|
||||
|
||||
config ESPTOOLPY_FLASHSIZE_1MB
|
||||
bool "1 MB"
|
||||
config ESPTOOLPY_FLASHSIZE_2MB
|
||||
bool "2 MB"
|
||||
config ESPTOOLPY_FLASHSIZE_4MB
|
||||
bool "4 MB"
|
||||
config ESPTOOLPY_FLASHSIZE_8MB
|
||||
bool "8 MB"
|
||||
config ESPTOOLPY_FLASHSIZE_16MB
|
||||
bool "16 MB"
|
||||
endchoice
|
||||
|
||||
config ESPTOOLPY_FLASHSIZE
|
||||
string
|
||||
default "1MB" if ESPTOOLPY_FLASHSIZE_1MB
|
||||
default "2MB" if ESPTOOLPY_FLASHSIZE_2MB
|
||||
default "4MB" if ESPTOOLPY_FLASHSIZE_4MB
|
||||
default "8MB" if ESPTOOLPY_FLASHSIZE_8MB
|
||||
default "16MB" if ESPTOOLPY_FLASHSIZE_16MB
|
||||
|
||||
endmenu
|
||||
|
@ -4,6 +4,7 @@ ESPPORT ?= $(CONFIG_ESPTOOLPY_PORT)
|
||||
ESPBAUD ?= $(CONFIG_ESPTOOLPY_BAUD)
|
||||
ESPFLASHMODE ?= $(CONFIG_ESPTOOLPY_FLASHMODE)
|
||||
ESPFLASHFREQ ?= $(CONFIG_ESPTOOLPY_FLASHFREQ)
|
||||
ESPFLASHSIZE ?= $(CONFIG_ESPTOOLPY_FLASHSIZE)
|
||||
|
||||
PYTHON ?= $(call dequote,$(CONFIG_PYTHON))
|
||||
|
||||
@ -15,13 +16,15 @@ ESPTOOLPY_SRC := $(COMPONENT_PATH)/esptool/esptool.py
|
||||
ESPTOOLPY := $(PYTHON) $(ESPTOOLPY_SRC) --chip esp32
|
||||
ESPTOOLPY_SERIAL := $(ESPTOOLPY) --port $(ESPPORT) --baud $(ESPBAUD)
|
||||
|
||||
ESPTOOL_FLASH_OPTIONS := --flash_mode $(ESPFLASHMODE) --flash_freq $(ESPFLASHFREQ) --flash_size $(ESPFLASHSIZE)
|
||||
|
||||
# the no-stub argument is temporary until esptool.py fully supports compressed uploads
|
||||
ESPTOOLPY_WRITE_FLASH=$(ESPTOOLPY_SERIAL) write_flash $(if $(CONFIG_ESPTOOLPY_COMPRESSED),-z) --flash_mode $(ESPFLASHMODE) --flash_freq $(ESPFLASHFREQ)
|
||||
ESPTOOLPY_WRITE_FLASH=$(ESPTOOLPY_SERIAL) write_flash $(if $(CONFIG_ESPTOOLPY_COMPRESSED),-z) $(ESPTOOL_FLASH_OPTIONS)
|
||||
|
||||
ESPTOOL_ALL_FLASH_ARGS += $(CONFIG_APP_OFFSET) $(APP_BIN)
|
||||
|
||||
$(APP_BIN): $(APP_ELF) $(ESPTOOLPY_SRC)
|
||||
$(Q) $(ESPTOOLPY) elf2image --flash_mode $(ESPFLASHMODE) --flash_freq $(ESPFLASHFREQ) -o $@ $<
|
||||
$(Q) $(ESPTOOLPY) elf2image $(ESPTOOL_FLASH_OPTIONS) -o $@ $<
|
||||
|
||||
flash: all_binaries $(ESPTOOLPY_SRC)
|
||||
@echo "Flashing binaries to serial port $(ESPPORT) (app at offset $(CONFIG_APP_OFFSET))..."
|
||||
|
Loading…
x
Reference in New Issue
Block a user