Want to make a custom bootloader for Cube Orange that uploads and runs specific firmware and rejects uploading and running of any other firmware

Hello, I have a cube orange and I want to upload my custom bootloader to it. So my doubts are,-
How and what is the best way to easily upload the custom bootloader in cube Orange? for example I saw one method using dfu but I can’t find how to change the state of boot0 pin. Hence, if that is the best way then please tell me how to do it or if any other better way is there that also you can tell.

Along with that, how can I later use this custom bootloader to upload a specific firmware that I have?
Also, I have used some print statements in bootloader code present at ardupilot/Tools/AP_Bootloader at master · ArduPilot/ardupilot · GitHub and modified it. So also confirm if that’s the correct location to modify the code. I used ./waf bootloader to build the binary for Cube Orange after modifying the code.
My custom bootloader should upload only one specific firmware and if I try to upload any other firmware from Mission planner or any other way, it should not work.


I don’t think you can access Boot0 without breaking the Cube casing. At least as per DF-17 connector pinout, there’s not access for it on carrier. Unless the bootloader has different board ID, memory sector mapping, You should be able to do it without Boot0.
There are few ST tools to do this by removing write access. How are you planning to implement? You can make a PR on git.