1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

Added dependencies for eboot.ld and Makefile to Makefile. (#7047)

Updated eboot.ld to not fill with zeros through the CS field
on its way to the CRC.
Added size test to elf2bin.py
This commit is contained in:
Earle F. Philhower, III 2020-02-03 09:49:13 -08:00 committed by GitHub
commit 6be561617f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 11 deletions

View File

@ -29,11 +29,11 @@ CFLAGS += $(INC)
CFLAGS += $(UZLIB_FLAGS) CFLAGS += $(UZLIB_FLAGS)
LDFLAGS += -nostdlib -Wl,--no-check-sections -Wl,--gc-sections -umain LDFLAGS += -nostdlib -Wl,--no-check-sections -Wl,--gc-sections -umain -Wl,-Map,$(@:.elf=.map)
LD_SCRIPT := -Teboot.ld LD_SCRIPT := -Teboot.ld
APP_OUT:= eboot.elf APP_OUT := eboot.elf
APP_AR := eboot.a APP_AR := eboot.a
APP_FW := eboot.bin APP_FW := eboot.bin
@ -49,13 +49,14 @@ tinfgzip.o: $(UZLIB_PATH)/tinfgzip.c $(UZLIB_PATH)/uzlib.h $(UZLIB_PATH)/uzlib_c
$(APP_AR): $(TARGET_OBJ_PATHS) tinflate.o tinfgzip.o $(APP_AR): $(TARGET_OBJ_PATHS) tinflate.o tinfgzip.o
$(AR) cru $@ $^ $(AR) cru $@ $^
$(APP_OUT): $(APP_AR) $(APP_OUT): $(APP_AR) eboot.ld | Makefile
$(LD) $(LD_SCRIPT) $(LDFLAGS) -Wl,--start-group -Wl,--whole-archive $(APP_AR) -Wl,--end-group -o $@ $(LD) $(LD_SCRIPT) $(LDFLAGS) -Wl,--start-group -Wl,--whole-archive $(APP_AR) -Wl,--end-group -o $@
clean: clean:
rm -f *.o rm -f *.o
rm -f $(APP_AR) rm -f $(APP_AR)
rm -f $(APP_OUT) rm -f $(APP_OUT)
rm -f *.map
.PHONY: all clean default .PHONY: all clean default

Binary file not shown.

View File

@ -154,12 +154,24 @@ SECTIONS
*(.gnu.linkonce.b.*) *(.gnu.linkonce.b.*)
. = ALIGN (8); . = ALIGN (8);
_bss_end = ABSOLUTE(.); _bss_end = ABSOLUTE(.);
/* CRC stored in last 8 bytes */ _free_space = 4096 - 17 - (. - _stext);
ASSERT((. < 4096 - 8), "Error: No space for CRC in bootloader sector."); /*
. = _stext + 4096 - 8; The boot loader checksum must be before the CRC, which is written by elf2bin.py.
_crc_size = .; This leaves 16 bytes after the checksum for the CRC placed at the end of the
. = . + 4; 4096-byte sector. */
_crc_val = .; _cs_here = (ALIGN((. + 1), 16) == ALIGN(16)) ? (ALIGN(16) - 1) : (. + 0x0F);
/*
The filling (padding) and values for _crc_size and _crc_val are handled by
elf2bin.py. With this, we give values to the symbols without explicitly
assigning space. This avoids the linkers back *fill* operation that causes
trouble.
The CRC info is stored in last 8 bytes. */
_crc_size = _stext + 4096 - 8;
_crc_val = _stext + 4096 - 4;
ASSERT((4096 > (17 + (. - _stext))), "Error: No space for CS and CRC in bootloader sector.");
ASSERT((_crc_size > _cs_here), "Error: CRC must be located after CS.");
} >iram1_0_seg :iram1_0_phdr } >iram1_0_seg :iram1_0_phdr
.lit4 : ALIGN(4) .lit4 : ALIGN(4)

View File

@ -93,6 +93,8 @@ def write_bin(out, elf, segments, to_addr, flash_mode, flash_size, flash_freq, p
out.write(bytearray([0])) out.write(bytearray([0]))
out.write(bytearray([checksum])) out.write(bytearray([checksum]))
if to_addr != 0: if to_addr != 0:
if total_size + 8 > to_addr:
raise Exception('Bin image of ' + elf + ' is too big, actual size ' + str(total_size + 8) + ', target size ' + str(to_addr) + '.')
while total_size < to_addr: while total_size < to_addr:
out.write(bytearray([0xaa])) out.write(bytearray([0xaa]))
total_size += 1 total_size += 1