Page 1 of 1

[USB] Jump to internal bootloader

Posted: Mon Oct 14, 2024 4:17 pm
by mma
Hi everyone,

I'm trying to jump to the USB DFU flash with Stm32cubeprogrammer using this code :

"uint32_t address = 0x1FFFD800;
am3_reset_watchdog_counter();
jump_to(address);

void clear_and_disable_isr(void)
{
/* Clear pending interrupts just to be on the safe side*/
SCB->ICSR = SCB_ICSR_PENDSVCLR_Msk;

/* Disable all interrupts */
uint8_t i;
for(i=0; i<8; i++)
NVIC->ICER[i] = 0xFFFFFFFF;//NVIC->IABR[i];
}

void jump_to(uint32_t addr)
{
typedef void (*pFunction)(void);

/* get jump address from application vector table */
pFunction jump_app_function = (pFunction) (((uint32_t*) addr)[1]);
clear_and_disable_isr();


/* set stack pointer as in application's vector table */
__set_MSP((uint32_t) ( (((uint32_t*) addr)[0])));
jump_app_function();
}"


But it's not working.

I'm using ChibiOS 17.6.0
My chip is an stm32f303cbt6.

Can you help me to make it work ?
Thanks.

Re: [USB] Jump to internal bootloader

Posted: Mon Oct 14, 2024 5:18 pm
by Giovanni
Hi,

Have you tried to single step at asm level? "not working" is a bit generic.

Giovanni

Re: [USB] Jump to internal bootloader

Posted: Tue Oct 15, 2024 8:48 am
by mma
Giovanni wrote:Hi,

Have you tried to single step at asm level? "not working" is a bit generic.

Giovanni


Hi Giovanni,
Thanks for your reply.
I just did it but i don't know what i supposed to get.
i got this as a last message : "No source available for "0x1ffff1bc""

Re: [USB] Jump to internal bootloader

Posted: Tue Oct 15, 2024 10:58 am
by Giovanni
It jumped at that address, the debugger is unable to proceed because there is no source code for that address.

Giovanni

Re: [USB] Jump to internal bootloader

Posted: Tue Oct 15, 2024 1:37 pm
by mma
Giovanni wrote:It jumped at that address, the debugger is unable to proceed because there is no source code for that address.

Giovanni

How can i know it going to work without debugger ? what i have supposed to get at the end ?

Re: [USB] Jump to internal bootloader

Posted: Tue Oct 15, 2024 5:00 pm
by Giovanni
Apparently it jumped into the bootloader or whatever code is there, why it does not work I have no idea, it is possible you need to undo any initialization performed by the application, not just those NVIC registers. This should be directed to ST support.

Giovanni

Re: [USB] Jump to internal bootloader

Posted: Wed Oct 16, 2024 8:38 am
by steved
I make sure virtually everything is reset to startup values, which may well be overkill. In particular, I found that not clearing down the MPU caused some problems.

Re: [USB] Jump to internal bootloader

Posted: Wed Oct 16, 2024 4:35 pm
by mma
Hi,
Thanks for your replies.
I added lines to disable initializations and the MPU, i still have the same result.
I checked the design(it's not mine) i found that the 1.5K resistance of D+ is connected to another pin to generate enable and disable for the USB and initialize it in a function, can you tell me if it's correct or i should connect it to 3.3V ? The boot_0 is connected to the ground, i think this one is correct.