Some weeks i think about why need special bootloader ?Why not use NXp method as flash = usb disk. Some man try make it but no RTU project for stm32 - only for nxp chip. after 2 weeks i make simplest way to map internal flash to ext disk. copy file with a name fw.bin - it's flash to flash. file with name ramfw.bin to device - copy soft to ran and execute. it's the same as dfu - buy dfu need drivers/ this schema not need any.
Question to map guru - why you not realize this simplest way (for customer) and use unworking code for bootloader ?
Second quenstion more difficult
in all your code you use gpio, pin but in real (if you see disasm) only 2-5 bits used. for code economy (if any knowns it) better use all bits for reduce code size. i say about that enough one u32 for exactly define port and pin.
May be my q stupid - but with this suggestions i reduce code size from 18KB to 7KB.
Of course - i undersand than 99% super developers (which no more than only blink a led) say me that this no need.
After some beer - this forum looks funny
And my own opinion - 99% prof developers not understand how it works. only beginners read DS and not ask a stupid Q/ i i prefer beginners (who read DS) and not a profi (who ask Q before read).
This is my opinion and not as not related to Leaflabs