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

bootloaders/riotboot_vfs: add VFS based bootloader #17379

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

benpicco
Copy link
Contributor

@benpicco benpicco commented Dec 10, 2021

Contribution description

Often it's not feasible to partition the internal flash into two halves simple because the required firmware is too large for just half of the flash. With the current chip shortage larger chips are not always available (if such parts even exist).

If the board has an external flash with a filesystem, we can store the new firmware there and use riotboot to transfer it to the internal flash.

Before flashing the new firmware, we make a backup of the current one so that the board can recover on it's own in case of a bad firmware. (In a follow-up we can add a watchdog timer to do an automated reboot if the new firmware does not clear it in time).

The path to firmware file to flash is stored in a do_update file as text. Once the firmware is flashed, the file contains the path of the backup firmware. It is the job of the new firmware to remove this file, otherwise the backup is applied on reboot.

Testing procedure

I have not figured out how to create a combined image yet and whenever I flash the application firmware the bootloader also gets erased. So whenever you flash the application, you also have to flash the bootloader:

  • flash tests/riotboot_vfs on a board with external storage
  • flash bootloaders/riotboot_vfs

Now on the shell, save the current firmware with dump_rom /nvm0/test.bin
You can re-flash the current firmware with flash_rom /nvm0/test.bin

same54-xpro

2022-03-22 12:51:37,456 # riotboot VFS
2022-03-22 12:51:37,466 # jump to 0xa000
2022-03-22 12:51:37,505 # main(): This is RIOT! (Version: 2022.04-devel-924-g0f6a3-bootloaders/riotboot_vfs)
> dump_rom /nvm/image.bin
2022-03-22 12:53:29,692 # wrote 57344 bytes to /nvm/image.bin
> flash_rom /nvm/image.bin
2022-03-22 12:53:36,727 # riotboot VFS
2022-03-22 12:53:36,742 # flashing /nvm/image.bin…
2022-03-22 12:53:40,027 # erase page 5
2022-03-22 12:53:40,070 # erase page 6
2022-03-22 12:53:40,114 # erase page 7
2022-03-22 12:53:40,155 # erase page 8
2022-03-22 12:53:40,198 # erase page 9
2022-03-22 12:53:40,240 # erase page 10
2022-03-22 12:53:40,283 # erase page 11
2022-03-22 12:53:40,324 # erase page 12
2022-03-22 12:53:40,367 # write 57344 bytes
2022-03-22 12:53:40,561 # done.
2022-03-22 12:53:40,562 # jump to 0xa000
2022-03-22 12:53:40,609 # main(): This is RIOT! (Version: 2022.04-devel-924-g0f6a3-bootloaders/riotboot_vfs)
ls /nvm
2022-03-22 12:54:14,020 # ls /nvm
2022-03-22 12:54:14,022 # ./
2022-03-22 12:54:14,023 # ../
2022-03-22 12:54:14,033 # fdb_kvdb1/
2022-03-22 12:54:14,042 # fdb_tsdb1/
2022-03-22 12:54:14,050 # image.bin	57344 B
2022-03-22 12:54:14,056 # old_image.bin	52224 B
2022-03-22 12:54:14,057 # total 2 files

nrf52840dk

Flash a modified image and store it on the flash

2022-05-17 20:16:22,869 # main(): This is RIOT! (Version: 2022.07-devel-460-g0a82d-bootloaders/riotboot_vfs)
2022-05-17 20:16:22,871 # riotboot VFS example
2022-05-17 20:16:22,873 #  > With Modifications! <

2022-05-17 20:16:43,974 # > dump_rom /nvm0/modi.bin
2022-05-17 20:16:45,781 # wrote 49152 bytes to /nvm0/modi.bin

Flash the vanilla image again and load the modified image from external Flash

2022-05-17 20:17:05,556 # main(): This is RIOT! (Version: 2022.07-devel-460-g0a82d-bootloaders/riotboot_vfs)
2022-05-17 20:17:05,558 # riotboot VFS example

2022-05-17 20:17:11,238 # > flash_rom /nvm0/modi.bin
2022-05-17 20:17:14,730 # main(): This is RIOT! (Version: 2022.07-devel-460-g0a82d-bootloaders/riotboot_vfs)
2022-05-17 20:17:14,732 # riotboot VFS example
2022-05-17 20:17:14,734 #  > With Modifications! <

Issues/PRs references

depends on and includes #17341

@github-actions github-actions bot added Area: boards Area: Board ports Area: build system Area: Build system Area: core Area: RIOT kernel. Handle PRs marked with this with care! Area: cpu Area: CPU/MCU ports Area: drivers Area: Device drivers Area: examples Area: Example Applications Area: pkg Area: External package ports Area: sys Area: System Area: tests Area: tests and testing framework Platform: ARM Platform: This PR/issue effects ARM-based platforms Platform: native Platform: This PR/issue effects the native platform labels Dec 10, 2021
@benpicco benpicco force-pushed the bootloaders/riotboot_vfs branch from c6c3b34 to 39ad6a4 Compare February 9, 2022 21:04
@github-actions github-actions bot removed Area: examples Area: Example Applications Platform: native Platform: This PR/issue effects the native platform labels Feb 9, 2022
@benpicco benpicco force-pushed the bootloaders/riotboot_vfs branch from 39ad6a4 to 699e993 Compare March 22, 2022 14:12
@benpicco benpicco added the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Mar 22, 2022
@benpicco benpicco marked this pull request as ready for review March 22, 2022 14:13
@fjmolinas
Copy link
Contributor

@benpicco Could you split out all the unrelated commits as well as document the added vfs/riotboot functions?

@benpicco benpicco force-pushed the bootloaders/riotboot_vfs branch from 699e993 to 8131421 Compare May 17, 2022 18:40
@github-actions github-actions bot removed Area: pkg Area: External package ports Area: drivers Area: Device drivers Area: core Area: RIOT kernel. Handle PRs marked with this with care! labels May 17, 2022
@benpicco benpicco added Area: core Area: RIOT kernel. Handle PRs marked with this with care! Area: pkg Area: External package ports Area: drivers Area: Device drivers and removed State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet labels May 17, 2022
@benpicco benpicco force-pushed the bootloaders/riotboot_vfs branch from 8131421 to efd638f Compare May 17, 2022 18:50
@github-actions github-actions bot removed Area: pkg Area: External package ports Area: core Area: RIOT kernel. Handle PRs marked with this with care! Area: drivers Area: Device drivers labels May 17, 2022
@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 26, 2022
@benpicco benpicco force-pushed the bootloaders/riotboot_vfs branch 2 times, most recently from 4577836 to 470045d Compare May 26, 2022 14:18
@benpicco benpicco force-pushed the bootloaders/riotboot_vfs branch from 470045d to bff8a78 Compare May 26, 2022 19:30
@benpicco benpicco added the State: waiting for maintainer State: Action by a maintainer is required label Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: boards Area: Board ports Area: build system Area: Build system Area: cpu Area: CPU/MCU ports 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 Platform: ARM Platform: This PR/issue effects ARM-based platforms State: waiting for maintainer State: Action by a maintainer is required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants