Want to make a custom bootloader for Cube Orange that uploads and runs specific firmware and rejects uploading and running 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.

Have replied here.

@sidbh