Alternate way to trigger DFU mode?

Hi,

Is there an other way to force the core to go in DFU mode for flashing (instead of mode+reset button combi) in order to speed up and automate flashing locally during development. That would reduce test cycles.

Thanks

1 Like

Hey @focsic,

Yes! The easiest way to do this is to add the following define to your local build:

#define DFU_BUILD_ENABLE

You can also tell the bootloader your code shouldn’t be run again, and to reboot into dfu mode with the following code. This way your firmware could receive a message, and reboot into a flashable state again:

 //RESET INTO DFU MODE - NOTE THIS WILL STOP RUNNING YOUR FIRMWARE
 //Don't do this unless you are comfortable flashing over USB / DFU
 //and maybe have a programmer shield / st-link programmer
 FLASH_OTA_Update_SysFlag = 0x0000;
 Save_SystemFlags();
 BKP_WriteBackupRegister(BKP_DR10, 0x0000);
 USB_Cable_Config(DISABLE);
 NVIC_SystemReset();      
3 Likes

Thanks Dave, will try it out.

Any idea where’s the bootloader code ? I found old ref to https://github.com/spark/bootloader but doesn’t exist anymore apparently.

Hey @focsic,

That code I provided can be run directly from the normal user-space firmware, it communicates with the bootloader by manipulating flags that it checks. You are correct that the bootloader repo is here: https://github.com/spark/bootloader We plan on releasing it again, but we were hoping to clean it up first :slight_smile: We’ll also be releasing details on how to overwrite the bootloader, turn off the overwrite protection, etc.

Thanks,
David

Does “#define DFU_BUILD_ENABLE” still put the core in DFU-mode by default? I’m trying to build locally without having to push the buttons first, but have not yet succeeded. Any suggestion?

Thanks!

This works for me