feat: use rmk-boot.x linker script for DFU partition layout - #1018
feat: use rmk-boot.x linker script for DFU partition layout#1018Schievel1 wants to merge 2 commits into
Conversation
2d22a39 to
b9a6d44
Compare
|
The symbol existence is checked in rmk when bootloader feature like And I think it should not be overwritten by The last point from me is the storage size, default 128KB is a little bit more. For example, nRF52833 has only 512KB flash(I just realized that it's impossible to use rmk-boot on it). I want it to be tunable, or default to 32KB. |
b9a6d44 to
aae555f
Compare
Size Report
|
aae555f to
c50e87d
Compare
…_flash_from_linkerscript Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
c50e87d to
02022c8
Compare
for now I prefer to bind everything bootloader related to the The offsets and sizes are now bound to symbols defined in Storage size is not easily changeable in RMK when using embassy-boot, because when changing the storage size (offset) this also changes the size of the ACTIVE and DFU partitions. So you end up with new sizes and offsets for them as well. I tuned down the default to 32K and in rmk-boot I added the possibility to easily change the storage size. Then users just need to do change that, build rmk-boot, flash it and copy the |
| println!("cargo:rustc-link-search={}", out.display()); | ||
| println!("cargo:rerun-if-changed=memory.x"); | ||
|
|
||
| if Path::new("rmk-boot.x").exists() { |
There was a problem hiding this comment.
I prefer to have rmk-boot.x in rmk-boot project only and keep memory.x. When users want to use rmk-boot, just add 1 line like:
println!("cargo:rustc-link-arg=-Trmk-boot.x");This is the pattern of many Rust embedded projects, like cortex-m-rt, defmt. I don't know if it's possible for rmk-boot. I prefer this way if it's possible.
This PR should simplify the process of setting the right flash layout when using rmk-boot.
The calculation formula is still the same (flash size - what the bootloader takes up - storage = rest. ACTIVE = rest/2 - 1 page, DFU = rest/2 + 1 page) and rmk-boot's
build.rscreates amemory.xaccordingly. Additionally it should create armk-boot.xwith the matching flash layout of the (RMK-)application + a few linker symbols that the application can use to initialize the flash and its partitions.e.g. a
rmk-boot.xlooks like this:rmk-boot not only creates that
rmk-boot.xat build, it also provides matchingrmk-boot.x-files for its pre-built variants. (rmk-boot-rp2040-16mb.x for example)The users
build.rsthen uses thatrmk-boot.xif it exists in the project directory instead of amemory.x. It creates amemory.xfrom it and both get fed to the linker.The users code can then use
rmk::dfu::init_flash_from_linkerscript()instead ofrmk::dfu::init_flash()to partition the flash without giving any offsets and sizes. For use_config this happens automatically.If users do provide
dfu_offset,dfu_sizeetc. in the [dfu] section of thekeyboard.toml,init_flash()is used instead and the linker symbols are ignored. For use_rust keyboards users can useinit_flash()directly for that. This way users can still go wild with their flash setup if they want something completely different.Related PRs:
rmk-rs/rmk-template#26
rmk-rs/rmk-boot#2