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

[Gen 3] SoftDevice update support #1816

Merged
merged 9 commits into from Aug 1, 2019

Conversation

@avtolstoy
Copy link
Member

commented Jun 10, 2019

Problem

https://app.clubhouse.io/particle/story/31496/nordic-softdevice-upgrade

Currently, the only way to upgrade the SoftDevice is by using the debugger and manually flashing the SoftDevice binary into the appropriate location.

We've specifically decoupled our Gen 3 bootloader from SoftDevice, so it should be possible for us to employ current OTA update mechanics to update the SoftDevice, where the module is first copied into the OTA region by the DeviceOS, the device is reset and then the bootloader copies the module from the OTA region to the appropriate location in the internal flash. The only caveat is that we'll need to strip off the header/footer.

It should ideally also be possible to flash the SoftDevice over DFU as a means of recovery.

Solution

This PR:

  • adds a new module function definition MODULE_FUNCTION_RADIO_STACK
  • adds module_radio_stack module on Gen 3 devices
  • adds platform_radio_stack_xxx functions to retrieve version info of the radio stack module and update it
  • changes a reserved field in module_info_t into flags of type module_info_flags_t and introduces a new module flag MODULE_INFO_FLAG_DROP_MODULE_INFO which indicates that module info needs to be stripped when this module is flashed into its location
  • adds a simple python script to generate modules out of raw binaries/hex files

sidenote: https://github.com/particle-iot/device-os/compare/feature/softdevice-update?expand=1#diff-3c500a02247f461f914ecdf1380550ebR29

Steps to Test

Update

  1. Generate SoftDevice radio stack module for the platform of interest e.g.:
// Optional, but might be required
$ pip install intelhex

$ python3 build/create_module.py --platform argon --function radio_stack ../third_party/nrf5_sdk/nrf5_sdk/components/softdevice/s140/hex/s140_nrf52_6.1.1_softdevice.hex argon-softdevice-6.1.1.bin
  1. By default this module will depend on system-part1 version 1301 and bootloader version 312, so manually bump them and build both out of this branch and flash onto the device
  2. Put the device into listening mode and retrieve the module info with particle serial inspect (CLI 1.43.2 required). Make sure that there is a radio stack module with version 169 (6.0.0).
  3. Flash the SoftDevice module OTA or using serial e.g.:
$ particle flash --serial argon-softdevice-6.1.1.bin
$ particle flash %deviceid% argon-softdevice-6.1.1.bin
  1. Put the device into listening mode, retrieve module info and make sure that the SoftDevice has been upgraded: the version should change to 182 (6.1.1)

MBR read-only

DFU writes into address range 0x0000 - 0x1000 should not be possible.

Recovery

The device should still able to boot into the bootloader even if SoftDevice upgrade is interrupted in the middle of the copying process from OTA region into the correct location.

  1. Write some garbage data into the SoftDevice area (0x1000 - 0x30000)
  2. The device will crash on boot
  3. Attempt to enter DFU should succeed

SoftDevice DFU upgrade

It should be possible to upgrade SoftDevice using DFU. Particle CLI supports MODULE_INFO_FLAG_DROP_MODULE_INFO flag since 1.43.2.

  1. Flash the SoftDevice e.g.:
$ particle flash --usb argon-softdevice-6.1.1.bin
  1. The device should function correctly

Release plan

Introduction of this feature will require two release.

The first release will only include this PR, but will not trigger the SoftDevice upgrade using our standard dependency mechanism. This will be the mandatory release and its system-part1 and bootloader versions will be used as dependencies in generated SoftDevice binaries.

The second release will add a dependency to system-part1 on a new SoftDevice version, which will trigger the upgrade. For example, a simplified upgrade path from 0.9.0 to 1.4.0 via a mandatory 1.3.0 will look like this:

  1. 1.4.0 user-part
  2. 1.3.0 bootloader
  3. 1.3.0 system-part1
  4. 6.1.1 SoftDevice
  5. 1.4.0 system-part1

Example App

N/A

References

TODO

  • PRs updating binary-version-reader and particle-cli.
  • Update submodule reference once particle-iot/firmware-protobuf#5 is merged
  • Update openthread submodule reference once SoftDevice 7.0.0 support is backported

Completeness

  • [feature] [Gen 3] Nordic SoftDevice update support
@m-mcgowan

This comment has been minimized.

Copy link
Contributor

commented Jun 10, 2019

Rather than call this a radio module, perhaps we generalize it as a 3rd party module? Future hardware may have different 3rd party modules not specifically focused on the radio.

@avtolstoy

This comment has been minimized.

Copy link
Member Author

commented Jun 10, 2019

@m-mcgowan I have no strong preferences towards the naming, but honestly I prefer to call things what they really are. This naming was proposed in https://app.clubhouse.io/particle/story/31496/nordic-softdevice-upgrade and I didn't hear any negative feedback towards it. This naming also somewhat coincides with what we have on Photons and P1s for example, where there is a a proprietary WiFi firmware blob, which could also be considered a 'radio stack` module.

@m-mcgowan
Copy link
Contributor

left a comment

I have not tested, just comments after reviewing the code.

dynalib/inc/module_info.h Outdated Show resolved Hide resolved
hal/inc/hal_platform.h Outdated Show resolved Hide resolved
platform/MCU/nRF52840/src/flash_mal.c Show resolved Hide resolved
system/src/system_update.cpp Show resolved Hide resolved

@technobly technobly modified the milestones: 1.3.0-rc.1, 1.3.1-rc.1 Jun 14, 2019

@avtolstoy avtolstoy force-pushed the feature/softdevice-update branch from db2b23c to 538b5c6 Jul 29, 2019

@avtolstoy avtolstoy requested a review from technobly Jul 31, 2019

@avtolstoy avtolstoy force-pushed the feature/softdevice-update branch from cecd4d9 to cb5448b Aug 1, 2019

@avtolstoy avtolstoy merged commit 8f8fddb into develop Aug 1, 2019

3 checks passed

Codacy/PR Quality Review Up to standards. A positive pull request.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@avtolstoy avtolstoy deleted the feature/softdevice-update branch Aug 1, 2019

@technobly technobly removed the request for review from sergeuz Aug 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.