Difference between revisions of "PineTime SD MCUBoot"

From PINE64
Jump to navigation Jump to search
Line 7: Line 7:
 
- But some firmware (wasp-os, ATCwatch) require Nordic SoftDevice to be installed to support the BLE and DFU functions
 
- But some firmware (wasp-os, ATCwatch) require Nordic SoftDevice to be installed to support the BLE and DFU functions
  
- InfiniTime Firmware does not support flashing of SoftDevice as firmware update, because SoftDevice needs to be flashed at address 0x0, which is used by the MCUBoot Bootloader
+
- InfiniTime Firmware does not support flashing of SoftDevice as firmware update, because SoftDevice needs to be flashed at address 0x1000, which is currently used by the MCUBoot Bootloader
  
 
- How do we allow SoftDevice-based firmware to be flashed to PineTime via DFU?
 
- How do we allow SoftDevice-based firmware to be flashed to PineTime via DFU?

Revision as of 16:55, 10 August 2020

The Problem:

- PineTime ships with the MCUBoot Bootloader which boots to the InfiniTime Firmware

- This assumes that the firmware (InfiniTime, Mynewt, Zephyr, ...) has its own Bluetooth LE (BLE) stack and can handle firmware updates (DFU)

- But some firmware (wasp-os, ATCwatch) require Nordic SoftDevice to be installed to support the BLE and DFU functions

- InfiniTime Firmware does not support flashing of SoftDevice as firmware update, because SoftDevice needs to be flashed at address 0x1000, which is currently used by the MCUBoot Bootloader

- How do we allow SoftDevice-based firmware to be flashed to PineTime via DFU?

Preferred Solution:

- We will use DFU to flash a SoftDevice Loader Firmware, which will boot and replace MCUBoot by SoftDevice

- Thereafter, when PineTime boots, it will start SoftDevice and will be ready to accept SoftDevice-based firmware for DFU: wasp-os, ATCWatch

- When we need to switch back to MCUBoot-based firmware (InfiniTime, Mynewt, Zephyr, ...), we will run an MCUBoot Loader to replace SoftDevice by MCUBoot plus a Minimal DFU Firmware that accepts DFU commands

- After rebooting, MCUBoot starts the Minimal DFU Firmware, which will accept MCUBoot-based firmware for flashing

- The MCUBoot-based firmware replaces the Minimal DFU Firmware

- SoftDevice Loader, https://github.com/daniel-thompson/wasp-reloader.

Alternative Solution:

- Custom MBR: https://forum.pine64.org/showthread.php?tid=9779&pid=65203#pid65203

wasp-reloader


wasp-reloader is a simple bare-metal C program that, in a fairly brutal fashion, can rewrite critical parts of the internal flash. It has fairly robust checksumming to avoid flashing problems and verifies that what it written is what is supposed to be written. Having said that more checks (no self-overwrite, battery level) would be nice. When complete it stops updating the watchdog in order to provoke get a clean reset. As a standalone app it can be loaded into the secondary slot using Infinitime DFU upgrade.

Currently it has linker scripts for SD132 V6.1.1 and can flash any payload smaller than SD132.

To be used to install SoftDevice from mcuboot it would need linker scripts for mcuboot (to ensure the reloader sits high enough in flash to avoid a self-overwrite). To install mcuboot we need an Intel HEX file of the mcuboot payload *and* InfiniTime (we have to write it in one shot to keep BLE updates working after switching bootloaders). This may need custom linker scripts depending on how big the Infinitime binaries are.