cherry-embedded / CherryUSB

CherryUSB is a tiny, beautiful and portable USB host and device stack for embedded system with USB IP
https://cherryusb.readthedocs.io/
Apache License 2.0
1.21k stars 256 forks source link

Uf2 bootloader for BL616 #229

Closed marchingband closed 1 month ago

marchingband commented 1 month ago

How can I port the UF2 bootloader to BL616 MCU? Is it primarily just the read/write flash functions that need to be completed? I am looking at the template file, but it is not obvious to me how to proceed. thank you!

sakumisu commented 1 month ago

You can implement bootuf2_flash_write api to write your firmware and use bootuf2_is_write_done to check if firmware is writing done and then reboot or jump.

marchingband commented 1 month ago

The API does not match the version of CherryUsb which the Bouffalo SDK contains. Looking through the tagged versions of CherryUsb, I notice that demo/bootuf2/ does not exist in the previous releases. Will it be possible to port? Any tips?

marchingband commented 1 month ago

I believe I have it working. Of course it throws an exception_entry as soon as it tries to flush the first chunk to flash, because your repo does not include a bootloader, so it is writing over the running application. I have put in a request to Cherryuf2 to port it: https://github.com/zhaqian12/Cherryuf2/issues/7 Do I understand this all correctly? thank you.

sakumisu commented 1 month ago

You can copy bootuf2 to your old cherryusb ,that's easy to port.

marchingband commented 1 month ago

It was easy to port, but I do not see an example of updating code OTA, or using partition table in the BL SDK. There are some examples in the bluetooth examples folder, such as oad_client but they are not documented well enough for me to follow.

sakumisu commented 1 month ago

This is example for all mcu not only for one chip like bl.