Here is a quick update on what I've found these last 2 days. These are mostly random notes I've taken while discovering how it's working. I hope they will be useful to anyone wanting to work on OTA updates and DFU ![Wink Wink](https://forum.pine64.org/images/smilies/wink.png)
My firmware (https://github.com/JF002/Pinetime) works out of the box with wasp-bootloader. This is because they are built around the same version of Noric's BLE SoftDevice (BLE stack).
@SteveA (on the chat) tried his own firmware (https://github.com/xriss/timecake, which does not use the SoftDevice) without success for now : the bootloader just resets every 1/2 second.
I've also tried to run @Koen's (on the chat too) firmware (https://github.com/bosmoment/PineTime-apps) with no much luck either. This firmware uses Nimble bluetooth stack. I did some modification to the code and the linker script but it would also reset every 500ms. A quick analysis on GDB showed me that it would hardfault in cortex_vector_base() which is pretty bad...
I don't know what causes this issue. It could be a conflict with the softdevice and Nimble, as they both try to drive the BLE radio.
Also, the softdevice is accompanied by an MBR : a small block of code the receives all the IRQ and forward them to the bootloader, softdevice and the application. And I really don't know what happens when the MBR expect the softdevice to be there, but it's not there because the application does not use it...
On the technical side, wasp-bootloader uses GPRERET (General Purpose Retention registers) and UICR (User Information Configuration Register) to store state and other info even when the MCU is reset. It also provides a factory reset option, which is a quite good idea!
Here is the general workflow of the wasp-bootloader:
Some links:
![Wink Wink](https://forum.pine64.org/images/smilies/wink.png)
My firmware (https://github.com/JF002/Pinetime) works out of the box with wasp-bootloader. This is because they are built around the same version of Noric's BLE SoftDevice (BLE stack).
@SteveA (on the chat) tried his own firmware (https://github.com/xriss/timecake, which does not use the SoftDevice) without success for now : the bootloader just resets every 1/2 second.
I've also tried to run @Koen's (on the chat too) firmware (https://github.com/bosmoment/PineTime-apps) with no much luck either. This firmware uses Nimble bluetooth stack. I did some modification to the code and the linker script but it would also reset every 500ms. A quick analysis on GDB showed me that it would hardfault in cortex_vector_base() which is pretty bad...
I don't know what causes this issue. It could be a conflict with the softdevice and Nimble, as they both try to drive the BLE radio.
Also, the softdevice is accompanied by an MBR : a small block of code the receives all the IRQ and forward them to the bootloader, softdevice and the application. And I really don't know what happens when the MBR expect the softdevice to be there, but it's not there because the application does not use it...
On the technical side, wasp-bootloader uses GPRERET (General Purpose Retention registers) and UICR (User Information Configuration Register) to store state and other info even when the MCU is reset. It also provides a factory reset option, which is a quite good idea!
Here is the general workflow of the wasp-bootloader:
- Init board (watchdog, buttons, leds, task scheduler, timer and display)
- Init bootloader (from the lib nrf_bootloader, provided by NRF52-SDK)
- Init SoftDevice
- Start DFU and wait for completion / error / timeout
- Disable Softdevice
- Teardown board peripheral
- If there is a valid image : Jump to the image code
- else reset and start again
Some links:
- Nordic MBR, Bootloader and Softdevice : https://infocenter.nordicsemi.com/topic/...oader.html
- Nordic DFU : https://infocenter.nordicsemi.com/topic/...dules.html
- Nordic DFU protocol : https://infocenter.nordicsemi.com/topic/...sport.html
Working on InfiniTime, the FOSS firmware for the PineTime: https://github.com/InfiniTimeOrg/InfiniTime
Mastodon : https://mastodon.codingfield.com/@JF
Twitter : https://twitter.com/codingfield
Matrix : @JF002:matrix.org
Mastodon : https://mastodon.codingfield.com/@JF
Twitter : https://twitter.com/codingfield
Matrix : @JF002:matrix.org