Skip to content

Commit c1559dc

Browse files
committed
bricks/ev3: Build flashable firmware.
1 parent 0cd5838 commit c1559dc

File tree

7 files changed

+21
-9
lines changed

7 files changed

+21
-9
lines changed

bricks/_common/arm_none_eabi.mk

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,12 +525,24 @@ $(BUILD)/firmware.elf: $(LD_FILES) $(OBJ)
525525
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
526526
$(Q)$(SIZE) -A $@
527527

528-
# firmware blob without main.mpy or checksum - use as base for appending other .mpy
529-
$(BUILD)/firmware-base.bin: $(BUILD)/firmware.elf
528+
# firmware blob without checksum
529+
$(BUILD)/firmware-obj.bin: $(BUILD)/firmware.elf
530530
$(ECHO) "BIN creating firmware base file"
531531
$(Q)$(OBJCOPY) -O binary $(FW_SECTIONS) $^ $@
532532
$(ECHO) "`wc -c < $@` bytes"
533533

534+
ifeq ($(PB_MCU_FAMILY),TIAM1808)
535+
UBOOT_FILE = $(PBTOP)/bricks/ev3/u-boot.bin
536+
MAKE_BOOTABLE_IMAGE = $(PBTOP)/bricks/ev3/make_bootable_image.py
537+
# For EV3, merge firmware blob with u-boot to create a bootable image.
538+
$(BUILD)/firmware-base.bin: $(BUILD)/uImage $(BUILD)/firmware-obj.bin
539+
python make_bootable_image.py $(UBOOT_FILE) $(BUILD)/uImage $(BUILD)/firmware-base.bin
540+
else
541+
# For embeded systems, the firmware is just the base file.
542+
$(BUILD)/firmware-base.bin: $(BUILD)/firmware-obj.bin
543+
$(Q)cp $< $@
544+
endif
545+
534546
$(BUILD)/firmware.metadata.json: $(BUILD)/firmware.elf $(METADATA)
535547
$(ECHO) "META creating firmware metadata"
536548
$(Q)$(METADATA) $(FW_VERSION) $(PBIO_PLATFORM) $<.map $@
@@ -545,6 +557,10 @@ $(BUILD)/firmware.zip: $(ZIP_FILES)
545557
$(ECHO) "ZIP creating firmware package"
546558
$(Q)$(ZIP) -j $@ $^
547559

560+
# firmware in uImage format (for EV3)
561+
$(BUILD)/uImage: $(BUILD)/firmware-obj.bin
562+
mkimage -C none -A arm -T kernel -O linux -a 0xC0008000 -e 0xC0008000 -d $< $@
563+
548564
# firmware in DFU format
549565
$(BUILD)/%.dfu: $(BUILD)/%-base.bin
550566
$(ECHO) "DFU Create $@"
File renamed without changes.

bricks/ev3/Makefile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,3 @@ PB_MCU_FAMILY = TIAM1808
66
DEBUG = 2
77

88
include ../_common/arm_none_eabi.mk
9-
10-
$(BUILD)/uImage: $(BUILD)/firmware-base.bin
11-
mkimage -C none -A arm -T kernel -O linux -a 0xC0008000 -e 0xC0008000 -d $< $@
12-
13-
uImage: $(BUILD)/uImage
File renamed without changes.
File renamed without changes.

bricks/ev3rt/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,10 @@ prepare-obj-folder:
197197
cp $(EV3RT_BRICK_DIR)/ev3rt.mk $(EV3RT_BRICK_DIR)/build/Makefile
198198

199199
# Use custom u-boot image, or use any official EV3 firmware. u-boot will be extracted from it.
200-
UBOOT_FILE = $(EV3RT_BRICK_DIR)/u-boot.bin
200+
UBOOT_FILE = $(EV3RT_BRICK_DIR)/../ev3/u-boot.bin
201201

202202
$(BUILD)/firmware-base.bin: uImage
203-
python $(EV3RT_BRICK_DIR)/make_bootable_image.py $(UBOOT_FILE) $(BUILD)/uImage $(BUILD)/firmware-base.bin
203+
python $(EV3RT_BRICK_DIR)/../ev3/make_bootable_image.py $(UBOOT_FILE) $(BUILD)/uImage $(BUILD)/firmware-base.bin
204204

205205
$(BUILD)/firmware.metadata.json: $(BUILD)/firmware-base.bin $(METADATA)
206206
$(ECHO) "META creating firmware metadata"

tools/metadata.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"essential_hub": {"device-id": 0x83, "checksum-type": "crc32"},
5353
"rcx": {"device-id": 0xE0, "checksum-type": "none"},
5454
"nxt": {"device-id": 0xE1, "checksum-type": "none"},
55+
"ev3": {"device-id": 0xE2, "checksum-type": "none"},
5556
"ev3rt": {"device-id": 0xE2, "checksum-type": "none"},
5657
}
5758

0 commit comments

Comments
 (0)