Skip to content

Commit a67e24d

Browse files
committed
bricks/ev3: fix entry point address in uImage
The entry point address in the uImage was hardcoded to 0xC0008000, but the actual entry point address is determined by the linker. It was just by luck that the entry point was close to the load address and there weren't any jumps between, so it eventually got to the entry point after executing some random code. Instead, we can scrape the entry point address from the ELF file using `readelf`, which will adapt to any changes. For good measure, we also scrape the load address, which is also determined by the linker script.
1 parent 8d22ed4 commit a67e24d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

bricks/_common/arm_none_eabi.mk

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,10 @@ $(BUILD)/firmware.zip: $(ZIP_FILES)
662662
$(Q)$(ZIP) -j $@ $^
663663

664664
# firmware in uImage format (for EV3)
665-
$(BUILD)/uImage: $(BUILD)/firmware-obj.bin
666-
mkimage -C none -A arm -T standalone -O u-boot -a 0xC0008000 -e 0xC0008000 -d $< $@
665+
$(BUILD)/uImage: $(BUILD)/firmware-obj.bin $(BUILD)/firmware.elf
666+
$(eval LOAD_ADDR := $(shell $(CROSS_COMPILE)readelf -l $(BUILD)/firmware.elf | grep "LOAD" | awk '{print $$4}'))
667+
$(eval ENTRY_POINT := $(shell $(CROSS_COMPILE)readelf -h $(BUILD)/firmware.elf | grep "Entry point" | cut -d: -f2))
668+
mkimage -C none -A arm -T standalone -O u-boot -a $(LOAD_ADDR) -e $(ENTRY_POINT) -d $< $@
667669

668670
# PRU firmware
669671
$(BUILD)/pru_suart.bin.o: $(PBTOP)/lib/pbio/drv/uart/uart_ev3_pru_lib/pru_suart.bin

0 commit comments

Comments
 (0)