From d92c541b1a75d7ced244e73b5c840511f03e348a Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Tue, 18 Jul 2017 09:56:23 +1000 Subject: [PATCH 1/3] esptool: Optimise generated image size by using RAM-loaded data for padding Can save almost 128KB from some images. --- components/esp32/ld/esp32.ld | 2 +- components/esptool_py/esptool | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/esp32/ld/esp32.ld b/components/esp32/ld/esp32.ld index d6b0ac42d1..efb97a5cf1 100644 --- a/components/esp32/ld/esp32.ld +++ b/components/esp32/ld/esp32.ld @@ -37,7 +37,7 @@ MEMORY len = 0x50000 - CONFIG_TRACEMEM_RESERVE_DRAM - CONFIG_BT_RESERVE_DRAM /* Flash mapped constant data */ - drom0_0_seg (R) : org = 0x3F400010, len = 0x800000 + drom0_0_seg (R) : org = 0x3F400018, len = 0x800000 /* RTC fast memory (executable). Persists over deep sleep. */ diff --git a/components/esptool_py/esptool b/components/esptool_py/esptool index ffde3f07b3..325f01637b 160000 --- a/components/esptool_py/esptool +++ b/components/esptool_py/esptool @@ -1 +1 @@ -Subproject commit ffde3f07b3ed735b6c9b9dfd0c12073a081444c1 +Subproject commit 325f01637b667af02cc6390965b09d50e6a31dac From c230e4280c039b0b709d54e974f63eed358c1c2a Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Wed, 19 Jul 2017 16:33:48 +1000 Subject: [PATCH 2/3] linker scripts: Limit DROM/IROM section lengths correctly --- components/esp32/ld/esp32.ld | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/esp32/ld/esp32.ld b/components/esp32/ld/esp32.ld index efb97a5cf1..8648021cb4 100644 --- a/components/esp32/ld/esp32.ld +++ b/components/esp32/ld/esp32.ld @@ -26,7 +26,7 @@ MEMORY iram0_0_seg (RX) : org = 0x40080000, len = 0x20000 /* Even though the segment name is iram, it is actually mapped to flash */ - iram0_2_seg (RX) : org = 0x400D0018, len = 0x330000 + iram0_2_seg (RX) : org = 0x400D0018, len = 0x330000-0x18 /* Shared data RAM, excluding memory reserved for ROM bss/data/stack. @@ -37,7 +37,7 @@ MEMORY len = 0x50000 - CONFIG_TRACEMEM_RESERVE_DRAM - CONFIG_BT_RESERVE_DRAM /* Flash mapped constant data */ - drom0_0_seg (R) : org = 0x3F400018, len = 0x800000 + drom0_0_seg (R) : org = 0x3F400018, len = 0x400000-0x18 /* RTC fast memory (executable). Persists over deep sleep. */ From 2d9770fd0036479362bb019e807604255985d8cc Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Wed, 19 Jul 2017 17:38:05 +1000 Subject: [PATCH 3/3] linker script: Add some comments about significance of 0x18 byte offset --- components/esp32/ld/esp32.ld | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/components/esp32/ld/esp32.ld b/components/esp32/ld/esp32.ld index 8648021cb4..b27a49eeb2 100644 --- a/components/esp32/ld/esp32.ld +++ b/components/esp32/ld/esp32.ld @@ -25,9 +25,17 @@ MEMORY /* IRAM for PRO cpu. Not sure if happy with this, this is MMU area... */ iram0_0_seg (RX) : org = 0x40080000, len = 0x20000 - /* Even though the segment name is iram, it is actually mapped to flash */ + /* Even though the segment name is iram, it is actually mapped to flash + */ iram0_2_seg (RX) : org = 0x400D0018, len = 0x330000-0x18 + /* + (0x18 offset above is a convenience for the app binary image generation. Flash cache has 64KB pages. The .bin file + which is flashed to the chip has a 0x18 byte file header. Setting this offset makes it simple to meet the flash + cache MMU's constraint that (paddr % 64KB == vaddr % 64KB).) + */ + + /* Shared data RAM, excluding memory reserved for ROM bss/data/stack. Enabling Bluetooth & Trace Memory features in menuconfig will decrease @@ -39,6 +47,8 @@ MEMORY /* Flash mapped constant data */ drom0_0_seg (R) : org = 0x3F400018, len = 0x400000-0x18 + /* (See iram0_2_seg for meaning of 0x18 offset in the above.) */ + /* RTC fast memory (executable). Persists over deep sleep. */ rtc_iram_seg(RWX) : org = 0x400C0000, len = 0x2000