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

suit/transport/vfs: add VFS as source for firmware updates #18045

Merged
merged 5 commits into from
Jun 7, 2022

Conversation

benpicco
Copy link
Contributor

@benpicco benpicco commented May 2, 2022

Contribution description

This allows to load firmware updates from files on local storage.

Testing procedure

make SUIT_COAP_ROOT=file:///sd0/fw suit/publish

Place the two slot files as well as the latest manifest on an SD card in the fw/ folder.

> suit fetch file:///nvm0/fw/riot.suit.1653475132.bin
2022-05-25 12:52:51,855 # suit fetch file:///nvm0/fw/riot.suit.1653475132.bin
2022-05-25 12:52:51,858 # suit_worker: trigger received
2022-05-25 12:52:51,864 # suit_worker: downloading "file:///nvm0/fw/riot.suit.1653475132.bin"
2022-05-25 12:52:51,874 # suit_worker: got manifest with size 421
2022-05-25 12:52:51,877 # suit: verifying manifest signature
2022-05-25 12:52:53,020 # suit: validated manifest version
2022-05-25 12:52:53,025 # )Manifest seq_no: 1653475132, highest available: 1653474249
2022-05-25 12:52:53,028 # suit: validated sequence number
2022-05-25 12:52:53,031 # )Formatted component name: 
2022-05-25 12:52:53,035 # Comparing manifest offset 4000 with other slot offset
2022-05-25 12:52:53,040 # Comparing manifest offset 82000 with other slot offset
2022-05-25 12:52:53,042 # validating vendor ID
2022-05-25 12:52:53,051 # Comparing 547d0d74-6d3a-5a92-9662-4881afd9407b to 547d0d74-6d3a-5a92-9662-4881afd9407b from manifest
2022-05-25 12:52:53,053 # validating vendor ID: OK
2022-05-25 12:52:53,055 # validating class id
2022-05-25 12:52:53,064 # Comparing 50244518-6a7c-5ce7-932b-88b318336c82 to 50244518-6a7c-5ce7-932b-88b318336c82 from manifest
2022-05-25 12:52:53,066 # validating class id: OK
2022-05-25 12:52:53,070 # Comparing manifest offset 4000 with other slot offset
2022-05-25 12:52:53,075 # Comparing manifest offset 82000 with other slot offset
2022-05-25 12:52:53,077 # SUIT policy check OK.
2022-05-25 12:52:53,079 # Formatted component name: 
2022-05-25 12:52:53,084 # riotboot_flashwrite: initializing update to target slot 1
2022-05-25 12:52:53,130 # Fetching firmware |█████████████████████████| 100%
2022-05-25 12:53:02,231 # Fetching firmware |█████████████████████████| 100%
2022-05-25 12:53:02,243 # Finalizing payload store
2022-05-25 12:53:02,245 # Verifying image digest
2022-05-25 12:53:02,249 # Starting digest verification against image
2022-05-25 12:53:02,341 # Install correct payload
2022-05-25 12:53:02,343 # Verified installed payload
2022-05-25 12:53:02,345 # Verifying image digest
2022-05-25 12:53:02,349 # Starting digest verification against image
2022-05-25 12:53:02,441 # Verified installed payload
2022-05-25 12:53:02,444 # Image magic_number: 0x544f4952
2022-05-25 12:53:02,446 # Image Version: 0x628e073c
2022-05-25 12:53:02,449 # Image start address: 0x00082400
2022-05-25 12:53:02,451 # Header chksum: 0xea1d2b74
2022-05-25 12:53:02,451 # 
> 2022-05-25 12:53:03,453 # suit_worker: rebooting...
2022-05-25 12:53:03,506 # main(): This is RIOT! (Version: 2022.07-devel-556-ga669bb-suit/transport-vfs)
2022-05-25 12:53:03,509 # RIOT SUIT update example application
2022-05-25 12:53:03,511 # Running from slot 1
2022-05-25 12:53:03,514 # Image magic_number: 0x544f4952
2022-05-25 12:53:03,516 # Image Version: 0x628e073c
2022-05-25 12:53:03,519 # Image start address: 0x00082400
2022-05-25 12:53:03,521 # Header chksum: 0xea1d2b74
2022-05-25 12:53:03,521 # 
2022-05-25 12:53:03,523 # suit_worker: started.
2022-05-25 12:53:03,525 # Starting the shell

Issues/PRs references

includes #18038

@github-actions github-actions bot added Area: OTA Area: Over-the-air updates Area: sys Area: System labels May 2, 2022
@benpicco benpicco marked this pull request as ready for review May 9, 2022 12:27
@fjmolinas
Copy link
Contributor

Nice! I would only suggest splitting the transport/coap part frojm the transport/vfs side.

@github-actions github-actions bot added the Area: examples Area: Example Applications label May 17, 2022
@benpicco benpicco force-pushed the suit/transport-vfs branch 2 times, most recently from 03634a2 to 17ad4ee Compare May 17, 2022 11:04
@benpicco
Copy link
Contributor Author

benpicco commented May 17, 2022

I've moved the transport worker thread to it's own file, now the separation worker thread <-> CoAP transport is also cleaner.

I would then also rename suit_coap_run()/suit_coap_trigger() -> suit_worker_start()/suit_worker_trigger(), but this will be an API change.

Should I do this here or in a separate PR?

@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label May 23, 2022
@benpicco benpicco force-pushed the suit/transport-vfs branch 3 times, most recently from c610265 to ba49ac5 Compare May 24, 2022 15:23
Copy link
Contributor

@fjmolinas fjmolinas left a comment

Choose a reason for hiding this comment

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

Took a second look I like the new direction, there are some comments that are against code that was only moved around, but still... Main concern right now is that I'm not sure that the storage_helper code or print_download code should be in handlers_command_seq, wouldn't it fit better in worker or common?

sys/suit/transport/vfs.c Outdated Show resolved Hide resolved
sys/suit/transport/vfs.c Outdated Show resolved Hide resolved
sys/include/suit.h Outdated Show resolved Hide resolved
sys/Makefile.dep Show resolved Hide resolved
sys/suit/transport/worker.c Outdated Show resolved Hide resolved
@benpicco benpicco added the State: waiting for author State: Action by the author of the PR is required label May 24, 2022
@maribu maribu added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels May 25, 2022
@benpicco benpicco removed the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label May 25, 2022
@benpicco benpicco removed the State: waiting for author State: Action by the author of the PR is required label May 25, 2022
@github-actions github-actions bot added the Area: tests Area: tests and testing framework label May 25, 2022
@benpicco benpicco added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed Area: tests Area: tests and testing framework labels May 25, 2022
@github-actions github-actions bot added the Area: tests Area: tests and testing framework label May 25, 2022
@benpicco benpicco force-pushed the suit/transport-vfs branch 2 times, most recently from 974fb3c to 3e65754 Compare May 26, 2022 11:53
@fjmolinas
Copy link
Contributor

Took a second look I like the new direction, there are some comments that are against code that was only moved around, but still... Main concern right now is that I'm not sure that the storage_helper code or print_download code should be in handlers_command_seq, wouldn't it fit better in worker or common?

I think this is still unaddressed no?

@fjmolinas
Copy link
Contributor

Do you agree with moving the printbar and helper code to the worker file?

@benpicco
Copy link
Contributor Author

But it's not related to the worker thread, is it?

@fjmolinas
Copy link
Contributor

But it's not related to the worker thread, is it?

Hmm maybe not, but it's not related to the common handlers either I think, I think its best to keep only SUIT manifest parsing in those files, maybe @bergzand has a better suggestion of where to place that?

@fjmolinas
Copy link
Contributor

But it's not related to the worker thread, is it?

Hmm maybe not, but it's not related to the common handlers either I think, I think its best to keep only SUIT manifest parsing in those files, maybe @bergzand has a better suggestion of where to place that?

Personally, I would rather have an extra common.c for those functions if worker.c is not adequate.

@benpicco
Copy link
Contributor Author

_storage_helper() (and in it _print_download_progress()) are only used in _dtv_fetch which is part of suit_command_sequence_handlers - I don't know where else it would make sense to place those private functions.

@fjmolinas
Copy link
Contributor

_storage_helper() (and in it _print_download_progress()) are only used in _dtv_fetch which is part of suit_command_sequence_handlers - I don't know where else it would make sense to place those private functions.

Hmm true I guess it's already a bit mixed up with _start_storage being there as well... If @bergzand doesn't have an opinion I'll ACK as is tomorrow.

@fjmolinas
Copy link
Contributor

@benpicco can you re-test after all the changes for good measure? I don't have hw with an sdcard right now....

@fjmolinas
Copy link
Contributor

@benpicco can you re-test after all the changes for good measure? I don't have hw with an sdcard right now....

Also I realize there is no changes to the README.md, would be good to have something there. But the README is already huge, so maybe documenting in the headers would be better?

@benpicco
Copy link
Contributor Author

benpicco commented Jun 1, 2022

Jup still works:

2022-06-01 13:15:03,405 - INFO # RIOT SUIT update example application
2022-06-01 13:15:03,405 - INFO # Running from slot 0
2022-06-01 13:15:03,406 - INFO # Image magic_number: 0x544f4952
2022-06-01 13:15:03,406 - INFO # Image Version: 0x00000000
2022-06-01 13:15:03,407 - INFO # Image start address: 0x00004400
2022-06-01 13:15:03,408 - INFO # Header chksum: 0xe57ae1a1
2022-06-01 13:15:03,408 - INFO # 
2022-06-01 13:15:03,410 - INFO # suit_worker: started.
2022-06-01 13:15:03,411 - INFO # Starting the shell

2022-06-01 13:15:07,505 - INFO # > suit fetch file:///sd0/fw/same54-xpro.suit
2022-06-01 13:15:07,506 - INFO # 
2022-06-01 13:15:07,508 - INFO # suit_worker: trigger received
2022-06-01 13:15:07,513 - INFO # suit_worker: downloading "file:///sd0/fw/same54-xpro.suit"
2022-06-01 13:15:07,519 - INFO # > suit_worker: got manifest with size 417
2022-06-01 13:15:07,522 - INFO # suit: verifying manifest signature
2022-06-01 13:15:08,664 - INFO # suit: validated manifest version
2022-06-01 13:15:08,668 - INFO # )Manifest seq_no: 1, highest available: 0
2022-06-01 13:15:08,670 - INFO # suit: validated sequence number
2022-06-01 13:15:08,673 - INFO # )Formatted component name: 
2022-06-01 13:15:08,678 - INFO # Comparing manifest offset 4000 with other slot offset
2022-06-01 13:15:08,683 - INFO # Comparing manifest offset 82000 with other slot offset
2022-06-01 13:15:08,684 - INFO # validating vendor ID
2022-06-01 13:15:08,693 - INFO # Comparing 95b2a5c5-125f-5a84-ada0-116139c70207 to 95b2a5c5-125f-5a84-ada0-116139c70207 from manifest
2022-06-01 13:15:08,695 - INFO # validating vendor ID: OK
2022-06-01 13:15:08,697 - INFO # validating class id
2022-06-01 13:15:08,706 - INFO # Comparing 7a90fa82-735d-5809-8fc7-fb5553b56557 to 7a90fa82-735d-5809-8fc7-fb5553b56557 from manifest
2022-06-01 13:15:08,708 - INFO # validating class id: OK
2022-06-01 13:15:08,713 - INFO # Comparing manifest offset 4000 with other slot offset
2022-06-01 13:15:08,718 - INFO # Comparing manifest offset 82000 with other slot offset
2022-06-01 13:15:08,720 - INFO # SUIT policy check OK.
2022-06-01 13:15:08,722 - INFO # Formatted component name: 
2022-06-01 13:15:08,727 - INFO # riotboot_flashwrite: initializing update to target slot 1
2022-06-01 13:15:08,771 - INFO # 
2022-06-01 13:15:21,364 - INFO # Fetching firmware |█████████████████████████| 100%
2022-06-01 13:15:21,365 - INFO # 
2022-06-01 13:15:21,367 - INFO # Finalizing payload store
2022-06-01 13:15:21,369 - INFO # Verifying image digest
2022-06-01 13:15:21,373 - INFO # Starting digest verification against image
2022-06-01 13:15:21,498 - INFO # Install correct payload
2022-06-01 13:15:21,501 - INFO # Verified installed payload
2022-06-01 13:15:21,503 - INFO # Verifying image digest
2022-06-01 13:15:21,507 - INFO # Starting digest verification against image
2022-06-01 13:15:21,632 - INFO # Verified installed payload
2022-06-01 13:15:21,635 - INFO # Image magic_number: 0x544f4952
2022-06-01 13:15:21,637 - INFO # Image Version: 0x00000001
2022-06-01 13:15:21,640 - INFO # Image start address: 0x00082400
2022-06-01 13:15:21,642 - INFO # Header chksum: 0xa586c1aa
2022-06-01 13:15:21,643 - INFO # 
2022-06-01 13:15:22,645 - INFO # suit_worker: rebooting...
2022-06-01 13:15:22,710 - INFO # main(): This is RIOT! (Version: 2022.07-devel-631-g3bfd1-2022.07-mlpa-3)
2022-06-01 13:15:22,712 - INFO # Hello Update!
2022-06-01 13:15:22,886 - INFO # > suit: verifying manifest signature
2022-06-01 13:15:24,029 - INFO # suit: validated manifest version
2022-06-01 13:15:24,033 - INFO # )Manifest seq_no: 1, highest available: 1
2022-06-01 13:15:24,035 - INFO # seq_nr <= running image

@benpicco benpicco added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jun 2, 2022
@benpicco
Copy link
Contributor Author

benpicco commented Jun 3, 2022

@fjmolinas is the documentation in the header sufficient?

Copy link
Contributor

@fjmolinas fjmolinas left a comment

Choose a reason for hiding this comment

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

ACK and GO

@fjmolinas fjmolinas enabled auto-merge June 7, 2022 06:31
@fjmolinas fjmolinas merged commit f6d5a54 into RIOT-OS:master Jun 7, 2022
@benpicco benpicco deleted the suit/transport-vfs branch June 7, 2022 06:59
@chrysn chrysn added this to the Release 2022.07 milestone Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: examples Area: Example Applications Area: OTA Area: Over-the-air updates Area: sys Area: System Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants