cancel
Showing results for 
Search instead for 
Did you mean: 

Hi, i use the stm32f405rgt6 and like to jump to the system memory 0x1fff0000. It never stays at DFU stm32_bootloader, it always starts application again.

MOtto.1
Associate II

I tryed two methodes, one just jumping to that address 0x1fff0000 via function pointer and second writing some magic numbers at 0x2001fffc and placing some asm code in the startup *.s file to jump branch to the system bootloader. I had to change controller typ recently. Before that i had the stm32f105 worked perfectly.

Here parts of my code

*.s file

/* Call the clock system intitialization function.*/

 bl SystemInit

/* check for a magic number in RAM, if present */

/* branch to bootloader */

LDR R0, =0x2001fff8

LDR R1, =0x12345678

LDR R2, [R0, #0]

STR R0, [R0, #0]

CMP R2, R1

BEQ Bootloader

/* Call static constructors */

  bl __libc_init_array

/* Call the application's entry point.*/

 bl main

 bx lr   

.size Reset_Handler, .-Reset_Handler

/* Start systemmemory bootloader */

Bootloader:

LDR R0, =0x1fff0000

LDR SP, [R0, #0]

LDR R0, [R0, #4]

BX R0

it does not stay in bootloader and in windows device manager could not see the device as an dfu bootloader device.

rest of code

void JumptoSysMem()

{

volatile uint32_t addr = boot_addr;

USB_OTG_GlobalTypeDef *USBx = hpcd_USB_OTG_FS.Instance;

//Enumeration_USB();

USB_DevDisconnect(USBx);

HAL_Delay(1000);

HAL_RCC_DeInit();

HAL_DeInit();

SysTick->CTRL = 0;

SysTick->VAL = 0;

SysTick->LOAD = 0;

  __HAL_RCC_SYSCFG_CLK_ENABLE();

  __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();

__set_MSP(*(uint32_t *)addr);

#if 0

SysMemBootJump = (void (*) (void)) (*((uint32_t *)(addr + 4)));

SysMemBootJump();

#else

//place magic at flash address 0x2001fffc

volatile uint32_t * magic_number_addr = (uint32_t *)0x2001fff8;

*magic_number_addr = magic_number;

__NVIC_SystemReset();

#endif

while(1);

}

what am i doing wrong please give me some detailed information.

Thanks in advance

8 REPLIES 8
TDK
Guru

Here's how to jump to bootloader on the F4:

https://stm32f4-discovery.net/2017/04/tutorial-jump-system-memory-software-stm32/

Looks to be the same as what you're doing. If that's not working, you'll need to debug further. Ensure hardware watchdog isn't enabled. If it doesn't stay in the bootloader, figure out where it's going. If it's resetting, look at RCC->CSR bits to determine why. If you have other signals active, it may be jumping to those bootloaders rather than USB DFU.

If you feel a post has answered your question, please click "Accept as Solution".
MOtto.1
Associate II

Hi,

thanks for answering. i have disabled my watchdog for now and still it does not stay in dfu bootloader it always start appliation. I also capture the RCC->CSR = 0x14000000 and all the time i like to jump i get this result. I do not have any other signals that could trigger a dfu bootloader.

You should use the method as I originally posted it.

The System Memory needs to be remapped in the assembler function, it doesn't survive the reset.

One of the purposes of the reset is to clear up whatever non-sense state the application left the processor/system in.

;*****************************************************************************
 
                ALIGN
 
Reboot_Loader   PROC
                EXPORT  Reboot_Loader
                LDR     R0, =0x40023844 ; RCC_APB2ENR
                LDR     R1, =0x00004000 ; ENABLE SYSCFG CLOCK
                STR     R1, [R0, #0]
                LDR     R0, =0x40013800 ; SYSCFG_MEMRMP
                LDR     R1, =0x00000001 ; MAP ROM AT ZERO
                STR     R1, [R0, #0]
                LDR     R0, =0x1FFF0000 ; ROM BASE
                LDR     SP,[R0, #0]
                LDR     R0,[R0, #4]
                BX      R0
                ENDP
 
;*****************************************************************************

#PoorlyPlagarised

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
MOtto.1
Associate II

Hi,

i placed your code into mine with no better result. It still jumps to somewhere and just starts again the application.

In my opinion i do a clean up before jumping but not with my assembler code but with the c code. Both are not working. The only way to get there is to set the BOOT1 jumper, but that is not sufficient for me. Any advice.

Thanks for reply

MOtto.1
Associate II

Hi,

one thing to add. When usb cable is not connected to the PC the bootloader runs. But as soon you plug in the usb cable it starts the application and does not initialize as a dfu device.

Please could you give me some hint because i am stucked right now.

Thanks

MOtto.1
Associate II

Hi,

i was able to stay in bootloader for now by just adding the disable_irq() that had been missing. But now got error code 43 in device manager. it could not get any device descriptor. But when placing a jumper to BOOT0 pin it is recognising as an stm32 Bootloader?

Any ideas?

Thanks

TDK
Guru

Everything you've described can be explained by the vector table not pointing to the correct location. USB DFU requires interrupts be enabled.

If you feel a post has answered your question, please click "Accept as Solution".
MOtto.1
Associate II

Hi,

i had also tried to switch the vector table but i not sure if had done that right.

SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */

VECT_TAB_BASE_ADDRESS ---> address?

VECT_TAB_OFFSET ---> offset?

When placing the system memory to address 0x00000000 via macro and placed the vector table to that also

__HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();

SCB->VTOR = 0x00000000;

I tried this did not work either.

Thanks