Skip to content

Commit ee7ad7e

Browse files
committed
esp8266: Add "ota" target to produce firmware binary for use with yaota8266.
https://github.com/pfalcon/yaota8266 is a (WIP) OTA-enabled bootloader which doesn't require reserving space 2x size of a firmware.
1 parent e8f2db7 commit ee7ad7e

2 files changed

Lines changed: 310 additions & 1 deletion

File tree

esp8266/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ reset:
186186
$(BUILD)/firmware-combined.bin: $(BUILD)/firmware.elf
187187
$(ECHO) "Create $@"
188188
$(Q)esptool.py elf2image $^
189-
$(Q)$(PYTHON) makeimg.py $(BUILD)/firmware.elf-0x00000.bin $(BUILD)/firmware.elf-0x0[1-f]000.bin $@
189+
$(Q)$(PYTHON) makeimg.py $(BUILD)/firmware.elf-0x00000.bin $(BUILD)/firmware.elf-0x[0-5][1-f]000.bin $@
190190

191191
$(BUILD)/firmware.elf: $(OBJ)
192192
$(ECHO) "LINK $@"
@@ -196,6 +196,9 @@ $(BUILD)/firmware.elf: $(OBJ)
196196
512k:
197197
$(MAKE) LDSCRIPT=esp8266_512k.ld CFLAGS_EXTRA='-DMP_CONFIGFILE="<mpconfigport_512k.h>"' MICROPY_FATFS=0 MICROPY_PY_BTREE=0
198198

199+
ota:
200+
$(MAKE) LDSCRIPT=esp8266_ota.ld
201+
199202
#MAKE_PINS = boards/make-pins.py
200203
#BOARD_PINS = boards/$(BOARD)/pins.csv
201204
#AF_FILE = boards/stm32f4xx_af.csv

esp8266/esp8266_ota.ld

Lines changed: 306 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,306 @@
1+
/* GNU linker script for ESP8266 */
2+
3+
MEMORY
4+
{
5+
dport0_0_seg : org = 0x3ff00000, len = 0x10
6+
dram0_0_seg : org = 0x3ffe8000, len = 0x14000
7+
iram1_0_seg : org = 0x40100000, len = 0x8000
8+
/* 0x3c000 is size of bootloader, 0x9000 is size of packed RAM segments */
9+
irom0_0_seg : org = 0x40200000 + 0x3c000 + 0x9000, len = 0x87000
10+
}
11+
12+
/* define the top of RAM */
13+
_heap_end = ORIGIN(dram0_0_seg) + LENGTH(dram0_0_seg);
14+
15+
PHDRS
16+
{
17+
dport0_0_phdr PT_LOAD;
18+
dram0_0_phdr PT_LOAD;
19+
dram0_0_bss_phdr PT_LOAD;
20+
iram1_0_phdr PT_LOAD;
21+
irom0_0_phdr PT_LOAD;
22+
}
23+
24+
ENTRY(firmware_start)
25+
EXTERN(_DebugExceptionVector)
26+
EXTERN(_DoubleExceptionVector)
27+
EXTERN(_KernelExceptionVector)
28+
EXTERN(_NMIExceptionVector)
29+
EXTERN(_UserExceptionVector)
30+
31+
PROVIDE(_memmap_vecbase_reset = 0x40000000);
32+
33+
/* Various memory-map dependent cache attribute settings: */
34+
_memmap_cacheattr_wb_base = 0x00000110;
35+
_memmap_cacheattr_wt_base = 0x00000110;
36+
_memmap_cacheattr_bp_base = 0x00000220;
37+
_memmap_cacheattr_unused_mask = 0xFFFFF00F;
38+
_memmap_cacheattr_wb_trapnull = 0x2222211F;
39+
_memmap_cacheattr_wba_trapnull = 0x2222211F;
40+
_memmap_cacheattr_wbna_trapnull = 0x2222211F;
41+
_memmap_cacheattr_wt_trapnull = 0x2222211F;
42+
_memmap_cacheattr_bp_trapnull = 0x2222222F;
43+
_memmap_cacheattr_wb_strict = 0xFFFFF11F;
44+
_memmap_cacheattr_wt_strict = 0xFFFFF11F;
45+
_memmap_cacheattr_bp_strict = 0xFFFFF22F;
46+
_memmap_cacheattr_wb_allvalid = 0x22222112;
47+
_memmap_cacheattr_wt_allvalid = 0x22222112;
48+
_memmap_cacheattr_bp_allvalid = 0x22222222;
49+
PROVIDE(_memmap_cacheattr_reset = _memmap_cacheattr_wb_trapnull);
50+
51+
SECTIONS
52+
{
53+
54+
.dport0.rodata : ALIGN(4)
55+
{
56+
_dport0_rodata_start = ABSOLUTE(.);
57+
*(.dport0.rodata)
58+
*(.dport.rodata)
59+
_dport0_rodata_end = ABSOLUTE(.);
60+
} >dport0_0_seg :dport0_0_phdr
61+
62+
.dport0.literal : ALIGN(4)
63+
{
64+
_dport0_literal_start = ABSOLUTE(.);
65+
*(.dport0.literal)
66+
*(.dport.literal)
67+
_dport0_literal_end = ABSOLUTE(.);
68+
} >dport0_0_seg :dport0_0_phdr
69+
70+
.dport0.data : ALIGN(4)
71+
{
72+
_dport0_data_start = ABSOLUTE(.);
73+
*(.dport0.data)
74+
*(.dport.data)
75+
_dport0_data_end = ABSOLUTE(.);
76+
} >dport0_0_seg :dport0_0_phdr
77+
78+
.irom0.text : ALIGN(4)
79+
{
80+
_irom0_text_start = ABSOLUTE(.);
81+
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
82+
83+
/* we put some specific text in this section */
84+
85+
*py/argcheck.o*(.literal* .text*)
86+
*py/asm*.o*(.literal* .text*)
87+
*py/bc.o*(.literal* .text*)
88+
*py/binary.o*(.literal* .text*)
89+
*py/builtin*.o*(.literal* .text*)
90+
*py/compile.o*(.literal* .text*)
91+
*py/emit*.o*(.literal* .text*)
92+
*py/persistentcode*.o*(.literal* .text*)
93+
*py/formatfloat.o*(.literal* .text*)
94+
*py/frozenmod.o*(.literal* .text*)
95+
*py/gc.o*(.literal* .text*)
96+
*py/reader*.o*(.literal* .text*)
97+
*py/lexer*.o*(.literal* .text*)
98+
*py/malloc*.o*(.literal* .text*)
99+
*py/map*.o*(.literal* .text*)
100+
*py/mod*.o*(.literal* .text*)
101+
*py/mpprint.o*(.literal* .text*)
102+
*py/mpstate.o*(.literal* .text*)
103+
*py/mpz.o*(.literal* .text*)
104+
*py/native*.o*(.literal* .text*)
105+
*py/nlr*.o*(.literal* .text*)
106+
*py/obj*.o*(.literal* .text*)
107+
*py/opmethods.o*(.literal* .text*)
108+
*py/parse*.o*(.literal* .text*)
109+
*py/qstr.o*(.literal* .text*)
110+
*py/repl.o*(.literal* .text*)
111+
*py/runtime.o*(.literal* .text*)
112+
*py/scope.o*(.literal* .text*)
113+
*py/sequence.o*(.literal* .text*)
114+
*py/showbc.o*(.literal* .text*)
115+
*py/smallint.o*(.literal* .text*)
116+
*py/stackctrl.o*(.literal* .text*)
117+
*py/stream.o*(.literal* .text*)
118+
*py/unicode.o*(.literal* .text*)
119+
*py/vm.o*(.literal* .text*)
120+
*py/vstr.o*(.literal* .text*)
121+
*py/warning.o*(.literal* .text*)
122+
123+
*extmod/*.o*(.literal* .text*)
124+
125+
*lib/fatfs/*.o*(.literal*, .text*)
126+
*/libaxtls.a:(.literal*, .text*)
127+
*lib/berkeley-db-1.xx/*.o(.literal*, .text*)
128+
*lib/libm/*.o*(.literal*, .text*)
129+
*lib/mp-readline/*.o(.literal*, .text*)
130+
*lib/netutils/*.o*(.literal*, .text*)
131+
*lib/timeutils/*.o*(.literal*, .text*)
132+
*lib/utils/*.o*(.literal*, .text*)
133+
134+
*stmhal/pybstdio.o(.literal*, .text*)
135+
136+
build/main.o(.literal* .text*)
137+
*gccollect.o(.literal* .text*)
138+
*gchelper.o(.literal* .text*)
139+
*help.o(.literal* .text*)
140+
*lexerstr32.o(.literal* .text*)
141+
*utils.o(.literal* .text*)
142+
*modpyb.o(.literal*, .text*)
143+
*machine_pin.o(.literal*, .text*)
144+
*machine_pwm.o(.literal*, .text*)
145+
*machine_rtc.o(.literal*, .text*)
146+
*machine_adc.o(.literal*, .text*)
147+
*machine_uart.o(.literal*, .text*)
148+
*modpybi2c.o(.literal*, .text*)
149+
*modmachine.o(.literal*, .text*)
150+
*machine_wdt.o(.literal*, .text*)
151+
*machine_spi.o(.literal*, .text*)
152+
*machine_hspi.o(.literal*, .text*)
153+
*hspi.o(.literal*, .text*)
154+
*modesp.o(.literal* .text*)
155+
*modnetwork.o(.literal* .text*)
156+
*moduos.o(.literal* .text*)
157+
*modutime.o(.literal* .text*)
158+
*modlwip.o(.literal* .text*)
159+
*modsocket.o(.literal* .text*)
160+
*modonewire.o(.literal* .text*)
161+
162+
/* we put as much rodata as possible in this section */
163+
/* note that only rodata accessed as a machine word is allowed here */
164+
*py/qstr.o(.rodata.const_pool)
165+
*.o(.rodata.mp_type_*) /* catches type: mp_obj_type_t */
166+
*.o(.rodata.*_locals_dict*) /* catches types: mp_obj_dict_t, mp_map_elem_t */
167+
*.o(.rodata.mp_module_*) /* catches types: mp_obj_module_t, mp_obj_dict_t, mp_map_elem_t */
168+
*/frozen.o(.rodata.mp_frozen_sizes) /* frozen modules */
169+
*/frozen.o(.rodata.mp_frozen_content) /* frozen modules */
170+
171+
/* for -mforce-l32 */
172+
build/*.o(.rodata*)
173+
174+
_irom0_text_end = ABSOLUTE(.);
175+
} >irom0_0_seg :irom0_0_phdr
176+
177+
.text : ALIGN(4)
178+
{
179+
_stext = .;
180+
_text_start = ABSOLUTE(.);
181+
*(.UserEnter.text)
182+
. = ALIGN(16);
183+
*(.DebugExceptionVector.text)
184+
. = ALIGN(16);
185+
*(.NMIExceptionVector.text)
186+
. = ALIGN(16);
187+
*(.KernelExceptionVector.text)
188+
LONG(0)
189+
LONG(0)
190+
LONG(0)
191+
LONG(0)
192+
. = ALIGN(16);
193+
*(.UserExceptionVector.text)
194+
LONG(0)
195+
LONG(0)
196+
LONG(0)
197+
LONG(0)
198+
. = ALIGN(16);
199+
*(.DoubleExceptionVector.text)
200+
LONG(0)
201+
LONG(0)
202+
LONG(0)
203+
LONG(0)
204+
. = ALIGN (16);
205+
*(.entry.text)
206+
*(.init.literal)
207+
*(.init)
208+
*(.literal .text .literal.* .text.* .iram0.literal .iram0.text .iram0.text.*.literal .iram0.text.*)
209+
*(.stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
210+
*(.fini.literal)
211+
*(.fini)
212+
*(.gnu.version)
213+
_text_end = ABSOLUTE(.);
214+
_etext = .;
215+
} >iram1_0_seg :iram1_0_phdr
216+
217+
.lit4 : ALIGN(4)
218+
{
219+
_lit4_start = ABSOLUTE(.);
220+
*(*.lit4)
221+
*(.lit4.*)
222+
*(.gnu.linkonce.lit4.*)
223+
_lit4_end = ABSOLUTE(.);
224+
} >iram1_0_seg :iram1_0_phdr
225+
226+
.data : ALIGN(4)
227+
{
228+
_data_start = ABSOLUTE(.);
229+
*(.data)
230+
*(.data.*)
231+
*(.gnu.linkonce.d.*)
232+
*(.data1)
233+
*(.sdata)
234+
*(.sdata.*)
235+
*(.gnu.linkonce.s.*)
236+
*(.sdata2)
237+
*(.sdata2.*)
238+
*(.gnu.linkonce.s2.*)
239+
*(.jcr)
240+
_data_end = ABSOLUTE(.);
241+
} >dram0_0_seg :dram0_0_phdr
242+
243+
.rodata : ALIGN(4)
244+
{
245+
_rodata_start = ABSOLUTE(.);
246+
*(.sdk.version)
247+
*(.rodata)
248+
*(.rodata.*)
249+
*(.gnu.linkonce.r.*)
250+
*(.rodata1)
251+
__XT_EXCEPTION_TABLE__ = ABSOLUTE(.);
252+
*(.xt_except_table)
253+
*(.gcc_except_table)
254+
*(.gnu.linkonce.e.*)
255+
*(.gnu.version_r)
256+
*(.eh_frame)
257+
/* C++ constructor and destructor tables, properly ordered: */
258+
KEEP (*crtbegin.o(.ctors))
259+
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
260+
KEEP (*(SORT(.ctors.*)))
261+
KEEP (*(.ctors))
262+
KEEP (*crtbegin.o(.dtors))
263+
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
264+
KEEP (*(SORT(.dtors.*)))
265+
KEEP (*(.dtors))
266+
/* C++ exception handlers table: */
267+
__XT_EXCEPTION_DESCS__ = ABSOLUTE(.);
268+
*(.xt_except_desc)
269+
*(.gnu.linkonce.h.*)
270+
__XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
271+
*(.xt_except_desc_end)
272+
*(.dynamic)
273+
*(.gnu.version_d)
274+
. = ALIGN(4); /* this table MUST be 4-byte aligned */
275+
_bss_table_start = ABSOLUTE(.);
276+
LONG(_bss_start)
277+
LONG(_bss_end)
278+
_bss_table_end = ABSOLUTE(.);
279+
_rodata_end = ABSOLUTE(.);
280+
} >dram0_0_seg :dram0_0_phdr
281+
282+
.bss ALIGN(8) (NOLOAD) : ALIGN(4)
283+
{
284+
. = ALIGN (8);
285+
_bss_start = ABSOLUTE(.);
286+
*(.dynsbss)
287+
*(.sbss)
288+
*(.sbss.*)
289+
*(.gnu.linkonce.sb.*)
290+
*(.scommon)
291+
*(.sbss2)
292+
*(.sbss2.*)
293+
*(.gnu.linkonce.sb2.*)
294+
*(.dynbss)
295+
*(.bss)
296+
*(.bss.*)
297+
*(.gnu.linkonce.b.*)
298+
*(COMMON)
299+
. = ALIGN (8);
300+
_bss_end = ABSOLUTE(.);
301+
_heap_start = ABSOLUTE(.);
302+
} >dram0_0_seg :dram0_0_bss_phdr
303+
}
304+
305+
/* get ROM code address */
306+
INCLUDE "eagle.rom.addr.v6.ld"

0 commit comments

Comments
 (0)