Revisiting the CH32V303 bootloader (with gemini), it is now FAST
The DFU bootloader i wrote a while back for the swindle running on the CH32V303/CH32V307 was a quick job.
It contained a cut down version of Esprit (the framework) with FreeRTOS and everything. It was about 14kB big.
Since i'm playing with antigravity/gemini, it was a good sample task to run it.
(On the antigravity front : it does a good job. But you really want to give small tasks, with clear instructions and check whatever it wants to do. It tends to circumcumvent/hide problems rather than solving them.)
Now back to the bootloader. The previous scheme was to use the native 256 bytes for erase and write. Write is actually fast, but erasing the whole 240kB was slow.
It happens than the CH32v3xx chips have 2 extra modes compared the the bluepill family : 32 kB and 64 kB erase.
So i switched to a slightly incorrect algorithm (basically if asked to erase 4Kb at the beginning of a 32kB block address, erase the full 32 kB, and dont erase already erased blocks).
And now it's blazingly fast and small ( ~ 7kB, did not care about optimizing it)
It went from ~ 1mn to erase and write the full swindle code (~ 220kB) to about 15 secs!
Comments
Post a Comment