Skip to content

Commit

Permalink
extend firmware size to max 896KB for ESP8266 4MB
Browse files Browse the repository at this point in the history
shared by @pedro-es

* add FLASH_4MB_C1 : (1024KB+1024KB)
* add new esptool.py ET_FS format
* add ESP_FLASH_MAX and ET_DEFAULTS  for all ESP boards
  • Loading branch information
MaBecker committed Feb 26, 2017
1 parent 03709a8 commit b41210b
Show file tree
Hide file tree
Showing 4 changed files with 463 additions and 9 deletions.
38 changes: 30 additions & 8 deletions Makefile
Expand Up @@ -582,39 +582,56 @@ else
# DISABLE_LTO is necessary in order to analyze static string sizes (see: topstring makefile target)
OPTIMIZEFLAGS+=-Os -std=gnu11 -fgnu89-inline -Wl,--allow-multiple-definition
endif
ESP_FLASH_MAX ?= 479232 # max bin file: 468KB

ifdef FLASH_4MB

ifdef FLASH_4MB_C1
ESP_FLASH_MAX ?= 917504 # max bin file: 896KB
ESP_FLASH_SIZE ?= 6 # 6->4MB (1024KB+1024KB)
ESP_FLASH_MODE ?= 0 # 0->QIO, 2->DIO
ESP_FLASH_FREQ_DIV ?= 15 # 15->80Mhz
ET_FS ?= 4MB-c1 # 32Mbit (4MB) flash size in esptool flash command
ET_FF ?= 80m # 80Mhz flash speed in esptool flash command
ET_BLANK ?= 0x3FE000 # where to flash blank.bin to erase wireless settings
ET_DEFAULTS ?= 0x3FC000 # where to flash esp_init_data_default.bin to default SDK settings
else ifdef FLASH_4MB
ESP_FLASH_MAX ?= 479232 # max bin file: 468KB
ESP_FLASH_SIZE ?= 4 # 4->4MB (512KB+512KB)
ESP_FLASH_MODE ?= 0 # 0->QIO, 2->DIO
ESP_FLASH_FREQ_DIV ?= 15 # 15->80Mhz
ET_FS ?= 32m # 32Mbit (4MB) flash size in esptool flash command
ET_FS ?= 4MB # 32Mbit (4MB) flash size in esptool flash command
ET_FF ?= 80m # 80Mhz flash speed in esptool flash command
ET_BLANK ?= 0x3FE000 # where to flash blank.bin to erase wireless settings
ET_DEFAULTS ?= 0x3FC000 # where to flash esp_init_data_default.bin to default SDK settings
else ifdef 2MB
ESP_FLASH_MAX ?= 479232 # max bin file: 468KB
ESP_FLASH_SIZE ?= 3 # 3->2MB (512KB+512KB)
ESP_FLASH_MODE ?= 0 # 0->QIO, 2->DIO
ESP_FLASH_FREQ_DIV ?= 15 # 15->80Mhz
ET_FS ?= 16m # 16Mbit (2MB) flash size in esptool flash command
ET_FS ?= 2MB # 16Mbit (2MB) flash size in esptool flash command
ET_FF ?= 80m # 80Mhz flash speed in esptool flash command
ET_BLANK ?= 0x1FE000 # where to flash blank.bin to erase wireless settings
ET_DEFAULTS ?= 0x1FC000 # where to flash esp_init_data_default.bin to default SDK settings
else ifdef 1MB
ESP_FLASH_MAX ?= 479232 # max bin file: 468KB
ESP_FLASH_SIZE ?= 2 # 2->1MB (512KB+512KB)
ESP_FLASH_MODE ?= 0 # 0->QIO, 2->DIO
ESP_FLASH_FREQ_DIV ?= 15 # 15->80Mhz
ET_FS ?= 8m # 8Mbit (1MB) flash size in esptool flash command
ET_FS ?= 1MB # 8Mbit (1MB) flash size in esptool flash command
ET_FF ?= 80m # 80Mhz flash speed in esptool flash command
ET_BLANK ?= 0xFE000 # where to flash blank.bin to erase wireless settings
ET_DEFAULTS ?= 0xFC000 # where to flash esp_init_data_default.bin to default SDK settings
else # 512KB
ESP_FLASH_MAX ?= 479232 # max bin file: 468KB
ESP_FLASH_SIZE ?= 0 # 0->512KB
ESP_FLASH_MODE ?= 0 # 0->QIO
ESP_FLASH_FREQ_DIV ?= 0 # 0->40Mhz
ET_FS ?= 4m # 4Mbit (512KB) flash size in esptool flash command
ET_FS ?= 512KB # 4Mbit (512KB) flash size in esptool flash command
ET_FF ?= 40m # 40Mhz flash speed in esptool flash command
ET_BLANK ?= 0x7E000 # where to flash blank.bin to erase wireless settings
ET_DEFAULTS ?= 0x7C000 # where to flash esp_init_data_default.bin to default SDK settings
endif

FLASH_BAUD ?= 115200 # The flash baud rate
FLASH_BAUD ?= 460800 # The flash baud rate
# End of ESP8266_BOARD
else
ifeq ($(shell uname -m),armv6l)
Expand Down Expand Up @@ -1996,8 +2013,13 @@ USER2_BIN = espruino_esp8266_user2.bin
USER1_ELF = espruino_esp8266_user1.elf
USER2_ELF = espruino_esp8266_user2.elf
PARTIAL = espruino_esp8266_partial.o
ifdef FLASH_4MB
LD_SCRIPT1 = ./targets/esp8266/eagle.app.v6.new.2048.app1.ld
LD_SCRIPT2 = ./targets/esp8266/eagle.app.v6.new.2048.app2.ld
else
LD_SCRIPT1 = ./targets/esp8266/eagle.app.v6.new.1024.app1.ld
LD_SCRIPT2 = ./targets/esp8266/eagle.app.v6.new.1024.app2.ld
endif
APPGEN_TOOL = $(ESP8266_SDK_ROOT)/tools/gen_appbin.py
BOOTLOADER = $(ESP8266_SDK_ROOT)/bin/boot_v1.6.bin
BLANK = $(ESP8266_SDK_ROOT)/bin/blank.bin
Expand Down Expand Up @@ -2107,7 +2129,7 @@ flash: all $(USER1_BIN) $(USER2_BIN)
ifndef COMPORT
$(error "In order to flash, we need to have the COMPORT variable defined")
endif
-$(ESPTOOL) --port $(COMPORT) --baud $(FLASH_BAUD) write_flash --flash_freq $(ET_FF) --flash_mode qio --flash_size $(ET_FS) 0x0000 $(BOOTLOADER) 0x1000 $(USER1_BIN) $(ET_BLANK) $(BLANK)
-$(ESPTOOL) --port $(COMPORT) --baud $(FLASH_BAUD) write_flash --flash_freq $(ET_FF) --flash_mode qio --flash_size $(ET_FS) 0x0000 $(BOOTLOADER) 0x1000 $(USER1_BIN) $(ET_DEFAULTS) $(INIT_DATA) $(ET_BLANK) $(BLANK)

# just flash user1 and don't mess with bootloader or wifi settings
quickflash: all $(USER1_BIN) $(USER2_BIN)
Expand Down
216 changes: 216 additions & 0 deletions targets/esp8266/eagle.app.v6.new.2048.app1.ld
@@ -0,0 +1,216 @@
/* This linker script generated from xt-genldscripts.tpp for LSP . */
/* Linker Script for ld -N */
MEMORY
{
dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40201010, len = 0xE0000
}

PHDRS
{
dport0_0_phdr PT_LOAD;
dram0_0_phdr PT_LOAD;
dram0_0_bss_phdr PT_LOAD;
iram1_0_phdr PT_LOAD;
irom0_0_phdr PT_LOAD;
}


/* Default entry point: */
ENTRY(call_user_start)
EXTERN(_DebugExceptionVector)
EXTERN(_DoubleExceptionVector)
EXTERN(_KernelExceptionVector)
EXTERN(_NMIExceptionVector)
EXTERN(_UserExceptionVector)
PROVIDE(_memmap_vecbase_reset = 0x40000000);
/* Various memory-map dependent cache attribute settings: */
_memmap_cacheattr_wb_base = 0x00000110;
_memmap_cacheattr_wt_base = 0x00000110;
_memmap_cacheattr_bp_base = 0x00000220;
_memmap_cacheattr_unused_mask = 0xFFFFF00F;
_memmap_cacheattr_wb_trapnull = 0x2222211F;
_memmap_cacheattr_wba_trapnull = 0x2222211F;
_memmap_cacheattr_wbna_trapnull = 0x2222211F;
_memmap_cacheattr_wt_trapnull = 0x2222211F;
_memmap_cacheattr_bp_trapnull = 0x2222222F;
_memmap_cacheattr_wb_strict = 0xFFFFF11F;
_memmap_cacheattr_wt_strict = 0xFFFFF11F;
_memmap_cacheattr_bp_strict = 0xFFFFF22F;
_memmap_cacheattr_wb_allvalid = 0x22222112;
_memmap_cacheattr_wt_allvalid = 0x22222112;
_memmap_cacheattr_bp_allvalid = 0x22222222;
PROVIDE(_memmap_cacheattr_reset = _memmap_cacheattr_wb_trapnull);

SECTIONS
{

.dport0.rodata : ALIGN(4)
{
_dport0_rodata_start = ABSOLUTE(.);
*(.dport0.rodata)
*(.dport.rodata)
_dport0_rodata_end = ABSOLUTE(.);
} >dport0_0_seg :dport0_0_phdr

.dport0.literal : ALIGN(4)
{
_dport0_literal_start = ABSOLUTE(.);
*(.dport0.literal)
*(.dport.literal)
_dport0_literal_end = ABSOLUTE(.);
} >dport0_0_seg :dport0_0_phdr

.dport0.data : ALIGN(4)
{
_dport0_data_start = ABSOLUTE(.);
*(.dport0.data)
*(.dport.data)
_dport0_data_end = ABSOLUTE(.);
} >dport0_0_seg :dport0_0_phdr

.data : ALIGN(4)
{
_data_start = ABSOLUTE(.);
*(.data)
*(.data.*)
*(.gnu.linkonce.d.*)
*(.data1)
*(.sdata)
*(.sdata.*)
*(.gnu.linkonce.s.*)
*(.sdata2)
*(.sdata2.*)
*(.gnu.linkonce.s2.*)
*(.jcr)
_data_end = ABSOLUTE(.);
} >dram0_0_seg :dram0_0_phdr

.rodata : ALIGN(4)
{
_rodata_start = ABSOLUTE(.);
*(.sdk.version)
*(.rodata)
*(.rodata.*)
*(.gnu.linkonce.r.*)
*(.rodata1)
__XT_EXCEPTION_TABLE__ = ABSOLUTE(.);
*(.xt_except_table)
*(.gcc_except_table)
*(.gnu.linkonce.e.*)
*(.gnu.version_r)
*(.eh_frame)
/* C++ constructor and destructor tables, properly ordered: */
KEEP (*crtbegin.o(.ctors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
/* C++ exception handlers table: */
__XT_EXCEPTION_DESCS__ = ABSOLUTE(.);
*(.xt_except_desc)
*(.gnu.linkonce.h.*)
__XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
*(.xt_except_desc_end)
*(.dynamic)
*(.gnu.version_d)
. = ALIGN(4); /* this table MUST be 4-byte aligned */
_bss_table_start = ABSOLUTE(.);
LONG(_bss_start)
LONG(_bss_end)
_bss_table_end = ABSOLUTE(.);
_rodata_end = ABSOLUTE(.);
} >dram0_0_seg :dram0_0_phdr

.bss ALIGN(8) (NOLOAD) : ALIGN(4)
{
. = ALIGN (8);
_bss_start = ABSOLUTE(.);
*(.dynsbss)
*(.sbss)
*(.sbss.*)
*(.gnu.linkonce.sb.*)
*(.scommon)
*(.sbss2)
*(.sbss2.*)
*(.gnu.linkonce.sb2.*)
*(.dynbss)
*(.bss)
*(.bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN (8);
_bss_end = ABSOLUTE(.);
_heap_start = ABSOLUTE(.);
/* _stack_sentry = ALIGN(0x8); */
} >dram0_0_seg :dram0_0_bss_phdr
/* __stack = 0x3ffc8000; */

.text : ALIGN(4)
{
_stext = .;
_text_start = ABSOLUTE(.);
*(.UserEnter.text)
. = ALIGN(16);
*(.DebugExceptionVector.text)
. = ALIGN(16);
*(.NMIExceptionVector.text)
. = ALIGN(16);
*(.KernelExceptionVector.text)
LONG(0)
LONG(0)
LONG(0)
LONG(0)
. = ALIGN(16);
*(.UserExceptionVector.text)
LONG(0)
LONG(0)
LONG(0)
LONG(0)
. = ALIGN(16);
*(.DoubleExceptionVector.text)
LONG(0)
LONG(0)
LONG(0)
LONG(0)
. = ALIGN (16);
*(.entry.text)
*(.init.literal)
*(.init)
*(.literal .text .iram1 .literal.* .text.* .iram1.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
*(.fini.literal)
*(.fini)
*(.gnu.version)
_text_end = ABSOLUTE(.);
_etext = .;
} >iram1_0_seg :iram1_0_phdr

.lit4 : ALIGN(4)
{
_lit4_start = ABSOLUTE(.);
*(*.lit4)
*(.lit4.*)
*(.gnu.linkonce.lit4.*)
_lit4_end = ABSOLUTE(.);
} >iram1_0_seg :iram1_0_phdr

.irom0.text : ALIGN(4)
{
_irom0_text_start = ABSOLUTE(.);
*(.irom0.literal .irom.literal .irom.literal2 .irom.text.literal .irom0.text .irom.text)
_irom0_text_end = ABSOLUTE(.);
} >irom0_0_seg :irom0_0_phdr

bigflash_free_size = (0x100000 - 0x1010 - SIZEOF(.irom0.text) - 8 - SIZEOF(.data) - 8 - SIZEOF(.rodata) - 8 - SIZEOF(.text) - 32) & 0xff000;
_bigflash_free_start = 0x100000 - bigflash_free_size;
_bigflash_free_end = _bigflash_free_start + bigflash_free_size;

}

/* get ROM code address */
INCLUDE "../ld/eagle.rom.addr.v6.ld"

0 comments on commit b41210b

Please sign in to comment.