rustworks
rustworks copied to clipboard
Bootloader & flasher for QPI external flash
Need to finish QSPI flash and then create a boot loader so RustWorks can be flashed to external flash. Potentially useful links:
- flashAlgorithm docs: https://www.keil.com/pack/doc/CMSIS/Pack/html/flashAlgorithm.html
- flashAlgorithm for RP2040: https://github.com/rp-rs/flash-algo
Todo:
- [ ] Read external flash
- [ ] Write external flash
- [x] Flash algorithm implementation so that cargo flash can access external flash (done in willemml/rsworks-flash-algo)
- [ ] Make
probe-rs
andcargo-embed
use flash algorithm - [x] Enable writing external flash using
dfu-util
As of ab411664f85e reading external flash seems to work correctly, but writing to it and erasing it does not. Unsetting memory mapped mode no longer causes a crash.
Note that external flash is actually supposed to be read as 32 bit integers, not individual bytes. This is shown (working) in a3d80abc002f.
One issue I noticed in external_flash.rs
is that you use self.qspi.cr.write
instead of modify
in send_command_full
, which will some settings to their reset value.
Hmm, I tried using modify instead of write for cr
but now attempts to write memory cause the calculator to either crash or freeze (without reseting, so I am going to assume it is waiting for the abort).
For reference, here are the changes I made:
self.qspi.cr.write(|w| w.abort().set_bit());
to
self.qspi.cr.modify(|_, w| w.abort().set_bit());
and then I also tried
self.qspi.cr.write(|r, w| unsafe { w.bits(r.bits()) }.abort().set_bit());
Thanks to #8 all that is left is to create a bootloader that also allows flashing of the QPI external flash via tools such as probe-rs
and dfu-util
.
There is a boot loader project called loadstone that looks interesting and is probably worth exploring...
EDIT: Might be worth waiting for loadstone to directly use embedded-hal to make porting it to stm32f730 easier if the loadstone route is taken. Will continue to explore alternative methods of using external flash for main program storage.
Flash algo ~~attempt~~ (fixed by rfuest in willemml/rsworks-flash-algo#1): https://github.com/willemml/rsworks-flash-algo
Do you still have the issue? I have worked on QSPI flash drivers, I can help if needed.
Currently the only things left to do are to allow probe-run to use the flash also (so add a command line argument to take custom chip definition yaml, which needs to be done in the probe-run repo), add dfu support and a boot loader.
@Npc15 if you have any tips (or want to help with) creating a dfu bootloader (or even just a bootloader in general for the QSPI flash) it would be greatly appreciated, my current blocker is moving the code off of internal flash and onto QSPI (the end goal being to have the bare minimum on the internal flash).
@Npc15 if you have any tips (or want to help with) creating a dfu bootloader (or even just a bootloader in general for the QSPI flash) it would be greatly appreciated, my current blocker is moving the code off of internal flash and onto QSPI (the end goal being to have the bare minimum on the internal flash).
Ok sure, will give you an update soon
As of 5a52fe6 DFU flashing of external flash works, booting not yet implemented.