Enter DFU mode with stm32F401 (bootloader Issue)

24 Oct 2018

Hello,

I'm having troubles with mbed-os 5. With the previous version of mbed (v163) it worked perfectly. With the following piece of assembler code, the micro (stm32F401) enters DFU mode. But with the newest version of mbed-os 5 doesn't work.

void enterDFU(){

	 __asm ("LDR     R0, =0x40023844");// RCC_APB2ENR
	 __asm ("LDR     R1, =0x00004000");// ENABLE SYSCFG CLOCK
	 __asm ("STR     R1, [R0, #0]");

	 __asm ("LDR     R0, =0x40013800");// remap ROM at zero
	 __asm ("LDR     R1, =0x00000001");// SYSCFG_MEMRMP
	 __asm ("STR     R1, [R0, #0]");

	 __asm ("LDR     R0, =0x1FFF0000");// ROM BASE
	 __asm ("LDR     SP,[R0, #0]");	   // SP @ +0
	 __asm ("LDR     R0,[R0, #4]");	   // PC @ +4

	 __asm ("BX      R0");			   // Jump to Bootloader
}

I've been doing some tests and I think that the problem is in the last line (ln:15), when it should jump to the Bootloader. If I try to connect the device on the PC it says "descriptor request error".

Any ideas what may be happening, Thank you.