cancel
Showing results for 
Search instead for 
Did you mean: 

Would like to enter DFU mode programmatically (on STM32F7)

dhylands
Associate
Posted on July 28, 2015 at 03:27

Hi,

I have some code for entering DFU mode from my application which works on the STM32F4: https://github.com/micropython/micropython/blob/master/stmhal/modpyb.c#L70-L87

I'd like to do something equivalent on the STM32F7 (I have an STM32F7 Discovery board which has the STM32F746 MCU)

There doesn't seem to be any __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH macro defined in the STMCubef7 files.

I'm able to successfully enter DFU mode by wiring in a switch between VCC and R42 (the BOOT0 line). I'd really like to be able to enter DFU mode without having to flip any switches.
2 REPLIES 2
Posted on July 28, 2015 at 05:04

It doesn't have the same sort of mapping.

The following would probably suffice:

// arm-none-eabi-gcc 4.9.0 does not correctly inline this
// MSP function, so we write it out explicitly here.
//__set_MSP(*((uint32_t*) 0x1FF00000));
__ASM volatile (''movs r3, #0x1FF00000
ldr r3, [r3, #0]
MSR msp, r3
'' : : : ''r3'', ''sp'');
((void (*)(void)) *((uint32_t*) 0x1FF00004))();

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
dhylands
Associate
Posted on July 29, 2015 at 19:44

Thanks.

I had to change it slightly. This seems to work:

// arm-none-eabi-gcc 4.9.0 does not correctly inline this
// MSP function, so we write it out explicitly here.
//__set_MSP(*((uint32_t*) 0x1FF00000));
__ASM 
volatile
(
''movw r3, #0x0000
movt r3, #0x1FF0
ldr r3, [r3, #0]
MSR msp, r3
''
: : : 
''r3''
, 
''sp''
);
((
void
(*)(
void
)) *((uint32_t*) 0x1FF00004))();