Skip to content

Commit 38d4dce

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 c35e78d commit 38d4dce

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
@@ -663,8 +663,10 @@ $(BUILD)/firmware.zip: $(ZIP_FILES)
663663
$(Q)$(ZIP) -j $@ $^
664664

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

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

0 commit comments

Comments
 (0)