[USB] Jump to internal bootloader

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
mma
Posts: 4
Joined: Thu Nov 09, 2023 12:32 pm

[USB] Jump to internal bootloader

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: [USB] Jump to internal bootloader

Post by Giovanni »

Hi,

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

Giovanni
mma
Posts: 4
Joined: Thu Nov 09, 2023 12:32 pm

Re: [USB] Jump to internal bootloader

Post 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""
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: [USB] Jump to internal bootloader

Post by Giovanni »

It jumped at that address, the debugger is unable to proceed because there is no source code for that address.

Giovanni
mma
Posts: 4
Joined: Thu Nov 09, 2023 12:32 pm

Re: [USB] Jump to internal bootloader

Post 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 ?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: [USB] Jump to internal bootloader

Post 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
steved
Posts: 834
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 138 times

Re: [USB] Jump to internal bootloader

Post 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.
mma
Posts: 4
Joined: Thu Nov 09, 2023 12:32 pm

Re: [USB] Jump to internal bootloader

Post 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.
Post Reply