Skip to content

Commit 6f19b9c

Browse files
committed
stm32/boards/LEGO_HUB_NO6: Add make commands to backup/restore firmware.
Signed-off-by: Damien George <[email protected]>
1 parent bac791c commit 6f19b9c

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

ports/stm32/boards/LEGO_HUB_NO6/README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,26 @@ firmware at 0x08010000. When mboot is installed it can be entered programatical
2828
via machine.bootloader(), or by holding down the left arrow button when powering
2929
on the Hub and waiting until the display says "B" before releasing the button.
3030

31+
Backing up original Hub firmware
32+
--------------------------------
33+
34+
Before install MicroPython it is advised to backup the original LEGO firmware that
35+
the Hub comes installed with. To do this, enter the built-in bootloader by holding
36+
down the Bluetooth button for 5 seconds while powering up the Hub via USB. Then
37+
run the following command from the root of this repository:
38+
39+
$ cd ports/stm32
40+
$ make BOARD=LEGO_HUB_NO6 backup-hub-firmware
41+
42+
This will create a file called `lego_hub_firmware.dfu`. Put this file in a safe
43+
location. To restore it, enter the built-in bootloader again and run:
44+
45+
$ make BOARD=LEGO_HUB_NO6 restore-hub-firmware
46+
47+
This will restore the original firmware but not the filesystem. To recreate the
48+
original filesystem the Hub must be updated using the appropriate LEGO PC
49+
application.
50+
3151
Installing MicroPython
3252
----------------------
3353

@@ -76,4 +96,4 @@ To scan for BLE devices:
7696
>>> ble.active(1)
7797
>>> ble.gap_scan(2000, 625, 625)
7898

79-
Use help("modules") to see available built-in modules.
99+
Use help("modules") to see available built-in modules.

ports/stm32/boards/LEGO_HUB_NO6/mpconfigboard.mk

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,26 @@ endif
2020
# Bootloader settings
2121
MBOOT_TEXT0_ADDR = 0x08008000
2222
MBOOT_LD_FILES = ../boards/LEGO_HUB_NO6/mboot_memory.ld stm32_sections.ld
23+
24+
# Backup/restore original Hub firmware
25+
26+
HUB_FIRMWARE = lego_hub_firmware.dfu
27+
HUB_FIRMWARE_ADDR = $(MBOOT_TEXT0_ADDR)
28+
HUB_FIRMWARE_SIZE = 0xf8000
29+
30+
backup-hub-firmware:
31+
$(Q)$(DFU_UTIL) -a 0 \
32+
-d $(BOOTLOADER_DFU_USB_VID):$(BOOTLOADER_DFU_USB_PID) \
33+
-U $(HUB_FIRMWARE).bin \
34+
-s $(HUB_FIRMWARE_ADDR):$(HUB_FIRMWARE_SIZE)
35+
$(Q)$(PYTHON) $(DFU) \
36+
-b $(HUB_FIRMWARE_ADDR):$(HUB_FIRMWARE).bin \
37+
-D $(BOOTLOADER_DFU_USB_VID):$(BOOTLOADER_DFU_USB_PID) \
38+
$(HUB_FIRMWARE)
39+
$(Q)$(RM) $(HUB_FIRMWARE).bin
40+
$(ECHO) "Backup created in $(HUB_FIRMWARE)"
41+
42+
restore-hub-firmware:
43+
$(Q)$(DFU_UTIL) -a 0 \
44+
-d $(BOOTLOADER_DFU_USB_VID):$(BOOTLOADER_DFU_USB_PID) \
45+
-D $(HUB_FIRMWARE)

0 commit comments

Comments
 (0)