davidgfnet / stm32-dfu-bootloader

A DFU bootloader targeting STM32F103 in just 4KB
GNU General Public License v3.0
113 stars 40 forks source link

provide how-to erase write locked devices #11

Open diggit opened 1 year ago

diggit commented 1 year ago

It's almost impossible to erase device with enabled write protection in bootloader, because you need to change option bytes, then do power cycle and then mass erase. Issues it, after power cycle, bootloader again re-locks write access and erasing is not possible. The only solution was manual write of magic value into upper 8 bytes of RAM to prevent auto flash write lock and then doing mass erase.

davidgfnet commented 1 year ago

Just for clarification, do you refer to -DENABLE_WRITEPROT feature? Have you checked out upgrade/README and the upgrade firmware? The idea is: you flash an upgrader app, then use it to disable the protection mecanism. Since you need a power cycle to unlock it for real (as you correctly mention), you can use the upgrade/client.exe to reset into "update mode", which essentially tells the bootloader not to lock the bootloader. During that time window, you can upgrade the bootloader.

Does that make sense? Of course if your bootloader is older than 1c4802 then the bootloader doesnt do the right thing and indeed, it re-locks the flash on reset. Hope this helps!