Skip to content

Commit 2550d7d

Browse files
committed
esp8266: Add support for building firmware version for 512K modules.
To build, "make 512k". Disabled are FatFs support (no space for filesystem), Python functionality related to files, btree module, and recently enabled features. With all this, there's only one free FlashROM page.
1 parent b78144c commit 2550d7d

3 files changed

Lines changed: 336 additions & 3 deletions

File tree

esp8266/Makefile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ QSTR_DEFS = qstrdefsport.h #$(BUILD)/pins_qstr.h
55

66
MICROPY_PY_USSL = 1
77
MICROPY_SSL_AXTLS = 1
8+
MICROPY_FATFS = 1
89
MICROPY_PY_BTREE = 1
910

1011
FROZEN_DIR = scripts
@@ -45,7 +46,8 @@ CFLAGS_XTENSA = -fsingle-precision-constant -Wdouble-promotion \
4546
CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -ansi -std=gnu99 -nostdlib -DUART_OS=$(UART_OS) \
4647
$(CFLAGS_XTENSA) $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
4748

48-
LDFLAGS = -nostdlib -T esp8266.ld -Map=$(@:.elf=.map) --cref
49+
LDSCRIPT = esp8266.ld
50+
LDFLAGS = -nostdlib -T $(LDSCRIPT) -Map=$(@:.elf=.map) --cref
4951
LIBS = -L$(ESP_SDK)/lib -lmain -ljson -llwip_open -lpp -lnet80211 -lwpa -lphy -lnet80211 $(LDFLAGS_MOD)
5052

5153
LIBGCC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
@@ -131,10 +133,14 @@ LIB_SRC_C = $(addprefix lib/,\
131133
utils/pyexec.c \
132134
utils/pyhelp.c \
133135
utils/interrupt_char.c \
134-
fatfs/ff.c \
135-
fatfs/option/ccsbcs.c \
136136
)
137137

138+
ifeq ($(MICROPY_FATFS), 1)
139+
LIB_SRC_C += \
140+
lib/fatfs/ff.c \
141+
lib/fatfs/option/ccsbcs.c
142+
endif
143+
138144
DRIVERS_SRC_C = $(addprefix drivers/,\
139145
dht/dht.c \
140146
)
@@ -153,7 +159,9 @@ OBJ += $(addprefix $(BUILD)/, $(STM_SRC_C:.c=.o))
153159
OBJ += $(addprefix $(BUILD)/, $(EXTMOD_SRC_C:.c=.o))
154160
OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
155161
OBJ += $(addprefix $(BUILD)/, $(DRIVERS_SRC_C:.c=.o))
162+
ifneq ($(FROZEN_MPY_DIR),)
156163
OBJ += $(BUILD)/$(BUILD)/frozen_mpy.o
164+
endif
157165
#OBJ += $(BUILD)/pins_$(BOARD).o
158166

159167
# List of sources for qstr extraction
@@ -206,6 +214,9 @@ $(BUILD)/firmware.elf: $(OBJ)
206214
$(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
207215
$(Q)$(SIZE) $@
208216

217+
512k:
218+
$(MAKE) LDSCRIPT=esp8266_512k.ld CFLAGS_EXTRA='-DMP_CONFIGFILE="<mpconfigport_512k.h>"' MICROPY_FATFS=0 MICROPY_PY_BTREE=0
219+
209220
#MAKE_PINS = boards/make-pins.py
210221
#BOARD_PINS = boards/$(BOARD)/pins.csv
211222
#AF_FILE = boards/stm32f4xx_af.csv

esp8266/esp8266_512k.ld

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

esp8266/mpconfigport_512k.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <mpconfigport.h>
2+
3+
#undef MICROPY_FSUSERMOUNT
4+
#define MICROPY_FSUSERMOUNT (0)
5+
#undef MICROPY_VFS_FAT
6+
#define MICROPY_VFS_FAT (0)
7+
8+
#undef MICROPY_PERSISTENT_CODE_LOAD
9+
#define MICROPY_PERSISTENT_CODE_LOAD (0)
10+
11+
#undef MICROPY_PY_IO_FILEIO
12+
#define MICROPY_PY_IO_FILEIO (0)
13+
14+
#undef MICROPY_PY_SYS_STDIO_BUFFER
15+
#define MICROPY_PY_SYS_STDIO_BUFFER (0)
16+
#undef MICROPY_PY_BUILTINS_SLICE_ATTRS
17+
#define MICROPY_PY_BUILTINS_SLICE_ATTRS (0)
18+
#undef MICROPY_PY_ALL_SPECIAL_METHODS
19+
#define MICROPY_PY_ALL_SPECIAL_METHODS (0)

0 commit comments

Comments
 (0)