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

[WIP] [TF:OTA] OTA updates common work branch #9969

Closed
wants to merge 41 commits into from

Conversation

kYc0o
Copy link
Contributor

@kYc0o kYc0o commented Sep 19, 2018

Contribution description

DO NOT MERGE! - PLEASE DON'T TRIGGER THE CI UNLESS IT'S REALLY NEEDED

This is a PR to track the work in progress for the OTA updates task force. Some PRs were already merged under different contexts, but they are essential to achieve this goal.

Basically, this PR represents what's described in #9342 as a "ready to test" environment, on which all the features are already (dirty) implemented and work as expected (no bug free warranties). The goal is to extract little by little the features and cleanly integrate them into RIOT, which is a lesson learned from the several previous attempts.

Testing procedure

Basically, we provide two applications (which might be PRed conveniently and might differ of what they are now) :

  • examples/ota: simple push-based OTA update example. The README.md in there provides enough information to test it.
  • examples/suit_updater: this application leverages the SUIT manifest format to perform updates from an internet server. It's quite complex and we don't have a README.md yet, but I'm working on it and will post it soon.

Both applications embed security prototypes to perform signature and validation of it with Ed25519, currently with the tweetnacl package.

Following what is described on examples/ota/README.md, the first step is to generate the keys with the following commands:

$ cd dist/tools/firmware
$ make
$ bin/firmware genkeys sec.key pub.key

To flash the device (currently tested only on samr21-xpro and iotlab-m3) with either ota or suit_updater:

  • BOARD=samr21-xpro APP_VER=$(date +%s) make -C examples/ota riotboot/flash: flash bootloader plus application firmware on slot1 (initial state).
  • BOARD=samr21-xpro APP_VER=$(date +%s) make -C examples/ota riotboot/slot2: generate an "update" of the same firmware, since the date is used as a version it will be always higher. The output file has the following format ota_example-slot2.signed.bin. That's the file that needs to be sent to the device via CoAP, e.g. for ota example. For suit_updater there are more steps, as the generation of the manifest requires more input data.

I hope with this some people can already play a bit.

Issues/PRs references

#9342 as the tracking issue
https://github.com/RIOT-OS/RIOT/projects/11 as the tracking project with the ongoing PRs, already merged PRs and superseded PRs.

Thanks (really) a lot to @kaspar030 @cladmi and @bergzand for their invaluable help to achieve this feature!

@kYc0o kYc0o added Platform: ARM Platform: This PR/issue effects ARM-based platforms State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable Type: new feature The issue requests / The PR implemements a new feature for RIOT State: waiting for other PR State: The PR requires another PR to be merged first Community: help wanted The contributors require help from other members of the community Area: OTA Area: Over-the-air updates labels Sep 19, 2018
@kYc0o kYc0o self-assigned this Sep 19, 2018
@kYc0o
Copy link
Contributor Author

kYc0o commented Sep 19, 2018

Ping to interested people:

@fedepell
@danpetry
@OYTIS
@emmanuelsearch

@fedepell
Copy link
Contributor

@kYc0o : thanks for the ping!

I had just still one more problem compared to the wip. After this kYc0o#10 now it works very well! (did a few rebuilds and swaps between two slots)

Will try to test further from tomorrow (OOO today) and try to give more inputs.

Thanks for your work!

@kYc0o
Copy link
Contributor Author

kYc0o commented Sep 20, 2018

Thanks @fedepell for your interest and contributions! We'll review that asap.

I also forgot to ping @basilfx who was testing older versions of this.

@RIOT-OS RIOT-OS deleted a comment Sep 20, 2018
@bergzand bergzand mentioned this pull request Sep 20, 2018
@RIOT-OS RIOT-OS deleted a comment Sep 24, 2018
@fedepell
Copy link
Contributor

Just some more feedback from testing on my side:

I completed also the upgrade via CoAP via serial on a saml-xpro21 using ethos. Sorry for the late feedback but I had quite some problems but at the end unrelated to this issue (see issue #10068) but once that was solved now it works like a charm, so can switch also by transfering via CoAP (over ethos in my case).

I'll do a smal PR with some tiny doc fixes.

Question: would it be interesting for the patch to have a couple of lines in the readme on how you can test it via ethos as an additional example? If so I could prepare.

Just some output ;)

ota: received bytes 0-64
ota: initializing update to target slot 2
ota: received bytes 64-128
ota: received bytes 128-192
ota: received bytes 192-256
ota: verifying metadata ...
ota: verification successful
ota: received bytes 192-256 of 54620 (left=54364)
coap_ota_handler(): ignoring already received block
...
ota: received bytes 54592-54620 of 54620 (left=0)
coap_ota_handler(): ignoring already received block
ota: firmware flashing completed successfully
ota: firmware flashing completed successfully

@kYc0o
Copy link
Contributor Author

kYc0o commented Oct 2, 2018

Question: would it be interesting for the patch to have a couple of lines in the readme on how you can test it via ethos as an additional example? If so I could prepare.

Highly appreciated!! Thanks for testing!!

kaspar030 and others added 2 commits October 30, 2018 17:05
TODO Rebase message edit at the end.

 * updated to edbg/openocd new variables
 * Use RIOTBOOT_FW_SLOT_SIZE: upcomming PRs should remove
   RIOTBOOT_SLOT1_SIZE and RIOTBOOT_SLOT2_SIZE
 * Use ROM_START_ADDR for 'firmware' to handle iotlab-m3
 * Use ROM_OFFSET and FW_ROM_LEN
 * Info on non supported existing bootloader for the moment in dist/riotboot
 * dist/riotboot: allow running different targets and not only flash
 * RIOTBOOT_HDR_LEN as hexadecimal and can be overwritten
cladmi and others added 17 commits October 30, 2018 17:13
* Add information on the current flashpage

Currently the information is not 100% consistent as 'offset' is relative to
the beginning and flashpage is absolute but I find it useful this way.
`RIOTBOOT_FW_SLOT_SIZE` contains both the metadata and the firmware.
TODO describe somewhere.
Variables must be exported for `openocd.sh` on `iotlab-m3`.
Variables must be exported for `openocd.sh` on `iotlab-m3`.
As it us using 'export' to the shell for openocd, it does not work properly.
Replace it with calculating the value in a subshell.
make is a bit strange sometimes and considers various factors to decide
the precedence of the rule to be applied: definition order is one (and
the %.signed.bin is after %.bin, and would be also if we put it at the
end of Makefile.include), but also if a rule is implicit is then
preferred no matter the order.

A quite complete and coincise overview of the topic can be found here:
https://stackoverflow.com/questions/28842851/force-make-to-use-a-more-specific-rule

Given the inclusion mechanism used in RIOT it should be safer to
explicitly state things, although may seem ugly sometimes.
@kYc0o
Copy link
Contributor Author

kYc0o commented Oct 30, 2018

Rebased to current master. Removed commits related to coap block2 support and "fake" dependencies on stm32 devices for flashpage_write_common.

@fedepell
Copy link
Contributor

@kYc0o: any plans on continuing this effort? I would be interested to continue and was wondering if this could align to current master (with the riotboot changes there) so I would not be using this branch.

@kYc0o
Copy link
Contributor Author

kYc0o commented Jan 13, 2019

@fedepell yes! It's in my plans to continue. I'd like #10215 to come first before I rebase this branch, since it would be less work. Let's try to merge #10215 soon so we can continue here.

@fedepell
Copy link
Contributor

@fedepell yes! It's in my plans to continue. I'd like #10215 to come first before I rebase this branch, since it would be less work. Let's try to merge #10215 soon so we can continue here.

Ok, didn't notice that PR sorry (please if you remember just ping me when you have related work, I sometimes get lost ;) ) .
Will join testing/reviewing effort in the next days for sure, was looking forward to that and firmware tools! Thanks!

@kYc0o
Copy link
Contributor Author

kYc0o commented Mar 23, 2019

What's the status here? Several related PRs were merged and this got super outdated. Is of some use to still having it open?

@fedepell
Copy link
Contributor

I agree, I believe mostly the OTA suit is still missing for this to be complete. I had a short chat at FOSDEM BOH with @bergzand , not sure if something continued after that (gave a search on github but didn't find anything).

@emmanuelsearch
Copy link
Member

emmanuelsearch commented Mar 25, 2019

@kaspar030 @bergzand does it make more sense to close this indeed?
The plan is to consider bits of another branch such as this one right?

@emmanuelsearch
Copy link
Member

@kYc0o let's close this in favor of the cluster of PRs around #11818
(but feel free to reopen if you feel it's necessary)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: OTA Area: Over-the-air updates CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable Community: help wanted The contributors require help from other members of the community Platform: ARM Platform: This PR/issue effects ARM-based platforms State: waiting for other PR State: The PR requires another PR to be merged first State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants