Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow the bootloader to be flashed over DFU #1788

Merged
merged 1 commit into from
Jun 14, 2019
Merged

Conversation

m-mcgowan
Copy link
Contributor

@m-mcgowan m-mcgowan commented May 22, 2019

This PR will be cherry-picked into another PR based on release/1.2.1 (for 1.2.1-rc.3).

Problem

When preparing a new firmware release for Gen2 and Gen3 platforms that don't contain the bootloader, we currently prepare an Ascender app that allows updating the bootloader of the device. This causes unnecessary delay in the release process.

Solution

This PR allows the bootloader (and other DeviceOS images) to be flashed via DFU.

The image is flashed to the OTA update region, and a flag set in the DCT. When the system reboots, the image is applied just as if it were sent OTA or OTW. This enables the bootloader to be flashed via DFU (such as by the CLI.)

Steps to Test

  1. Flash the Device OS from this PR to your target device
  2. Use particle serial inspect to retrieve the bootloader version of the current bootloader
  3. edit modules/shared/system_module_version.mk, and change BOOTLOADER_VERSION to higher than the bootloader version in the previous step. Build the bootloader for your device.
  4. echo -e "\xA3" > A3
  5. echo -e "\xA5" > A5
  6. flash the bootloader to your device via dfu using the address of the OTA region. E.g. 0x80C0000 on Gen2 platforms. dfu-util -d 2b04:d006 -a 0 -s 0x80C0000 -D bootloader.bin
  7. Restart the device
  8. Use particle serial inspect and verify that the bootloader version has NOT changed
  9. dfu-util -d 2b04:d006 -a 1 -s 1753:leave -D A3 . (deliberately the incorrect flag value.)
  10. Use particle serial inspect and verify that the bootloader version has NOT changed
  11. dfu-util -d 2b04:d006 -a 1 -s 1753:leave -D A5 . (correct flag value.)
  12. Use particle serial inspect and verify that the bootloader version has changed to match BOOTLOADER_VERSION.
  13. Verify that the OTA flag has been cleared:
  14. dfu-util -d 2b04:d006 -a 1 -s 1753:1 -U ota_flag
  15. xxd ota_flag
00000000: ff                         

Example App

References


Completeness

  • User is totes amazing for contributing!
  • Contributor has signed CLA (Info here)
  • Problem and Solution clearly stated
  • Run unit/integration/application tests on device
  • Added documentation
  • Added to CHANGELOG.md after merging (add links to docs and issues)

  • [enhancement] allow the bootloader to be flashed over DFU #1788

Copy link
Member

@sergeuz sergeuz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍. Please fix the build for gcc and core platforms.

platform/MCU/nRF52840/inc/dct.h Outdated Show resolved Hide resolved
…ashing them to the OTA backup region and then having them applied by the system firmware as a regular OTA. [CH32507]
@technobly technobly added enhancement ready to merge PR has been reviewed and tested and removed DO NOT MERGE in progress labels Jun 14, 2019
@markterrill
Copy link

I think there are issues with particle-cli 1.43 and this new DFU bootloader.

Simply, it fails half the time to complete particle update. Info at
https://github.com/particle-iot/device-os/issues/1856
particle-iot/particle-cli#498

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ready to merge PR has been reviewed and tested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants