Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added dependencies for eboot.ld and Makefile to Makefile.
Updated eboot.ld to not fill with zeros through the CS field
on its way to the CRC.
Added size test to elf2bin.py
  • Loading branch information
mhightower83 committed Jan 29, 2020
commit fe7faf701e69a70896901961a9c9ae2eb31a56d0
11 changes: 6 additions & 5 deletions bootloaders/eboot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ CFLAGS += $(INC)

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

APP_OUT:= eboot.elf
APP_AR := eboot.a
APP_FW := eboot.bin
APP_OUT := eboot.elf
APP_AR := eboot.a
APP_FW := eboot.bin


all: $(APP_OUT)
Expand All @@ -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
$(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 $@

clean:
rm -f *.o
rm -f $(APP_AR)
rm -f $(APP_OUT)
rm -f *.map


.PHONY: all clean default
Binary file modified bootloaders/eboot/eboot.elf
Binary file not shown.
24 changes: 18 additions & 6 deletions bootloaders/eboot/eboot.ld
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,24 @@ SECTIONS
*(.gnu.linkonce.b.*)
. = ALIGN (8);
_bss_end = ABSOLUTE(.);
/* CRC stored in last 8 bytes */
ASSERT((. < 4096 - 8), "Error: No space for CRC in bootloader sector.");
. = _stext + 4096 - 8;
_crc_size = .;
. = . + 4;
_crc_val = .;
_free_space = 4096 - 17 - (. - _stext);
/*
The boot loader checksum must be before the CRC, which is written by elf2bin.py.
This leaves 16 bytes after the checksum for the CRC placed at the end of the
4096-byte sector. */
_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

.lit4 : ALIGN(4)
Expand Down
2 changes: 2 additions & 0 deletions tools/elf2bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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([checksum]))
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:
out.write(bytearray([0xaa]))
total_size += 1
Expand Down