-
Notifications
You must be signed in to change notification settings - Fork 2k
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
riotboot: implement serial flasher #15493
Conversation
For the CI, I would also add:
Otherwise the code in this PR is not built on Murdock. |
How about creating a new application under |
a044e5a
to
0abd083
Compare
02f418c
to
9ea597b
Compare
These change requests seem to still be pending. I'll give this a test |
RIOTBOOT_SERIAL := $(RIOTTOOLS)/riotboot_serial/riotboot_serial | ||
|
||
FLASHER ?= $(RIOTBOOT_SERIAL) | ||
FLASHFILE ?= $(HEXFILE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why a hex file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it contains the target addresses and is easy to parse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should check that the firmware to be flashed is a hex then (should still be overridable in case a user specifies a firmware path)
@benpicco do you think it's possible to add a README.md for the new bootloader? Something simple on how the BOARD needs to be bootstrapped and flashed? |
fcd15fc
to
b999329
Compare
# Include riotboot flash partition functionality | ||
# USEMODULE += riotboot_slot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to remove riotboot_slot
, right now the bootloader can't possible support riotboot_slot
since it can only flash hexfiles
and all riotboot functionality relies on flashing bin
.
Sure it could initially be bootstrapped with a riotboot_serial + riotboot_slot firmware but no firmware upgrades over serial can be made.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, although that's not a limitation of the bootloader but the flasher tool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but will it make sense to use the bootloader in that case?
Please squash! |
Ah wai
Ah wait this is still missing:
|
@benpicco can you add:
You can squash afterwards. |
this saves a few bytes of ROM
86b9ded
to
414c24d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK, I think there is still some improvements to be had (in the future) like being able to flash binaries, but the current state works already and is usable for many applications BOARD's where an external programmer is currently needed.
Thank you for the review! |
Contribution description
I got annoyed by boards that require wiring up a programmer and that are finicky to flash.
Therefore I added a simple protocol to
riotboot
that allows to erase sectors / write data over a serial connection.There are only four commands:
This comes with a custom flash tool (
riotboot_serial
) that is used to transfer the firmware onto a board using riotboot.So far, this is only wired up for the sam0 family (and comes with a patch that fixes a hard fault on samd5x when writing small chunks).
edit also added efm32 and nrf52, successfully flashed boards using riotboot serial with those platforms.
The flash tool is rather simple and does not do proper error handling yet (it expects the user to just interrupt it if it gets stuck).
The lines from the
.hex
file are converted to binaryI considered sending raw lines from the
.hex
file directly, but decided against so the bootloader doesn't have to parse text.Also sending binary over the wire should be faster.
If the sync protocol makes sense / the 'double sync' is necessary is up for debate, also batching multiple lines of the hex file would probably be faster.
There is also no support for doing anything with riotboot headers yet.
If they are part of the hex file and can be handled transparently, it should just work, but I did not test this.
Testing procedure
For the riotboot bootloader, enable the
riotboot_serial
and disableriotboot_slot
.It is possible to have both modules active at the same time, but then riotboot will also check if the slot has a valid header, which makes testing/firmware generation more complicated.
With this configuration, 'raw' images (plain RIOT firmware) will boot.
Now you should be able to flash any RIOT application using
PROGRAMMER=riotboot_serial
. Start the flashing procedure, then reset the board for the flasher to sync up with the bootloader.You can also enable the
riotboot_reset
module which gives you thebootloader
command to reboot to the bootloader from the shell.Issues/PRs references