summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2021-08-26 12:35:16 +1000
committerDamien George <damien@micropython.org>2021-08-31 00:16:39 +1000
commit6f19b9c08d7d8c03981a999d4eddeb3c500125ab (patch)
tree2b182a057a83c64c73985d92d3444db2afe4e44a
parentbac791c5fdde27065c8e144aee929e20a444b10a (diff)
stm32/boards/LEGO_HUB_NO6: Add make commands to backup/restore firmware.
Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--ports/stm32/boards/LEGO_HUB_NO6/README.md22
-rw-r--r--ports/stm32/boards/LEGO_HUB_NO6/mpconfigboard.mk23
2 files changed, 44 insertions, 1 deletions
diff --git a/ports/stm32/boards/LEGO_HUB_NO6/README.md b/ports/stm32/boards/LEGO_HUB_NO6/README.md
index c566ada9d..0b88cd837 100644
--- a/ports/stm32/boards/LEGO_HUB_NO6/README.md
+++ b/ports/stm32/boards/LEGO_HUB_NO6/README.md
@@ -28,6 +28,26 @@ firmware at 0x08010000. When mboot is installed it can be entered programatical
via machine.bootloader(), or by holding down the left arrow button when powering
on the Hub and waiting until the display says "B" before releasing the button.
+Backing up original Hub firmware
+--------------------------------
+
+Before install MicroPython it is advised to backup the original LEGO firmware that
+the Hub comes installed with. To do this, enter the built-in bootloader by holding
+down the Bluetooth button for 5 seconds while powering up the Hub via USB. Then
+run the following command from the root of this repository:
+
+ $ cd ports/stm32
+ $ make BOARD=LEGO_HUB_NO6 backup-hub-firmware
+
+This will create a file called `lego_hub_firmware.dfu`. Put this file in a safe
+location. To restore it, enter the built-in bootloader again and run:
+
+ $ make BOARD=LEGO_HUB_NO6 restore-hub-firmware
+
+This will restore the original firmware but not the filesystem. To recreate the
+original filesystem the Hub must be updated using the appropriate LEGO PC
+application.
+
Installing MicroPython
----------------------
@@ -76,4 +96,4 @@ To scan for BLE devices:
>>> ble.active(1)
>>> ble.gap_scan(2000, 625, 625)
-Use help("modules") to see available built-in modules. \ No newline at end of file
+Use help("modules") to see available built-in modules.
diff --git a/ports/stm32/boards/LEGO_HUB_NO6/mpconfigboard.mk b/ports/stm32/boards/LEGO_HUB_NO6/mpconfigboard.mk
index 56527af7d..8f8695a9c 100644
--- a/ports/stm32/boards/LEGO_HUB_NO6/mpconfigboard.mk
+++ b/ports/stm32/boards/LEGO_HUB_NO6/mpconfigboard.mk
@@ -20,3 +20,26 @@ endif
# Bootloader settings
MBOOT_TEXT0_ADDR = 0x08008000
MBOOT_LD_FILES = ../boards/LEGO_HUB_NO6/mboot_memory.ld stm32_sections.ld
+
+# Backup/restore original Hub firmware
+
+HUB_FIRMWARE = lego_hub_firmware.dfu
+HUB_FIRMWARE_ADDR = $(MBOOT_TEXT0_ADDR)
+HUB_FIRMWARE_SIZE = 0xf8000
+
+backup-hub-firmware:
+ $(Q)$(DFU_UTIL) -a 0 \
+ -d $(BOOTLOADER_DFU_USB_VID):$(BOOTLOADER_DFU_USB_PID) \
+ -U $(HUB_FIRMWARE).bin \
+ -s $(HUB_FIRMWARE_ADDR):$(HUB_FIRMWARE_SIZE)
+ $(Q)$(PYTHON) $(DFU) \
+ -b $(HUB_FIRMWARE_ADDR):$(HUB_FIRMWARE).bin \
+ -D $(BOOTLOADER_DFU_USB_VID):$(BOOTLOADER_DFU_USB_PID) \
+ $(HUB_FIRMWARE)
+ $(Q)$(RM) $(HUB_FIRMWARE).bin
+ $(ECHO) "Backup created in $(HUB_FIRMWARE)"
+
+restore-hub-firmware:
+ $(Q)$(DFU_UTIL) -a 0 \
+ -d $(BOOTLOADER_DFU_USB_VID):$(BOOTLOADER_DFU_USB_PID) \
+ -D $(HUB_FIRMWARE)