-
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/flashwrite: use chunks instead of pages, support flashpage_write_raw #11705
Conversation
@kaspar030 After your comments in #11683 I realized I had been too focused on the problem in front of me to see the whole picture. I opened this PR as a more global approach to what was done in #11683. There are more changes involved and the objective is not exactly the same so I rather open a separate PR, as its a different approach. PS: Sorry for taking so long to address your comments, I was a little bit busy and distracted last week :) |
@kaspar030 As discussed offline, what would you think of this approach (assuming chunk are replaced by blocks)? |
- chunk are arbitrary data sizes that must be FLASHPAGE_RAW_BLOCKSIZE aligned. If flashpage_raw is not supported the chunk size will be FLASHPAGE_SIZE
712f9a0
to
07d7ae9
Compare
@kaspar030 testing is much easier with #11808 :). |
BTW, changes chunks base size to BLOCKSIZE |
Why WIP? |
@fjmolinas please provide an explanation ;-). |
I had answered offline, but good to put it here. This PR has diverged enough from master that it is no longer working, I'll close unless I get it working again. |
Contribution description
The following PR changes the approach used for flashwrite. Instead of always writing pages it writes chunks into flash. If
flashpage_raw
is supported these chunk can be smalled than FLASHPAGE_SIZE allowing for buffers as small asFLASHPAGE_RAW_BLOCKSIZE
. This will also allow supporting stm32f4/2/7` or sectors based CPU since we can pick when to erase the flash.The PR involves three changes (I can open separate PR's if the spirit of the PR is agreed upon):
FLASH_ERASE_STATE
variable so the when skipping an offset or in this caseRIOTBOOT_MAGIC
we keep those bytes in an erase state so they don't need to be overwritten.flashpage_write_and_verify_raw
andflashpage_write_raw
. These are convenience functions.flashwrite
to be based on chunksWhen implementing #11683 I was too focused on making it work for
stm32f2/4
and not on the global picture I think this approach works better by still having the same behavior for the base case an completely removing the use of page buffers when possible.A buffer is still kept in
riotboot_flashwrite_t
for convenience, it makes it easier and more robust to handle unalignedriotboot_flashwrite_putbytes
. The buffer could always be defined toFLASHPAGE_RAW_BLOCKSIZE
. The choice of 64 bytes I made is based on having it the same size as a coap_block. But it could be changedTesting procedure
for nucleo-l073rz:
make -C tests/riotboot_flashwrite/ BOARD= nucleo-l073rz riotboot/flash term
make -C tests/riotboot_flashwrite/ BOARD= nucleo-l073rzriotboot
coap-client -m post coap://[fe80::2%tap0]/flashwrite -f tests/riotboot_flashwrite/bin/ nucleo-l073rz/tests_riotboot_flashwrite-slot1.riot.bin -b 64
for samr21-xpro:
make -C tests/riotboot_flashwrite/ BOARD= samr21-xpro riotboot/flash term
make -C tests/riotboot_flashwrite/ BOARD= samr21-xpro rzriotboot
coap-client -m post coap://[fe80::2%tap0]/flashwrite -f tests/riotboot_flashwrite/bin/ samr21-xpro/tests_riotboot_flashwrite-slot1.riot.bin -b 64
When the update finished reboot the node manually it should have started from a different slot.
nucleo-f446re
make -C tests/riotboot_flashwrite/ BOARD=nucleo-f446re riotboot/flash term
make -C tests/riotboot_flashwrite/ BOARD=nucleo-f446re riotboot
coap-client -m post coap://[fe80::2%tap0]/flashwrite -f tests/riotboot_flashwrite/bin/ nucleo-f446retests_riotboot_flashwrite-slot1.riot.bin -b 64
Issues/PRs references
Replaces #11683
Related to #11682 and #1168