[USB] Jump to internal bootloader

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

Moderators: tfAteba, barthess, RoccoMarco, lbednarz, utzig

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

[USB] Jump to internal bootloader

Postby mma » Mon Oct 14, 2024 4:17 pm

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: 14563
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1111 times
Been thanked: 937 times
Contact:

Re: [USB] Jump to internal bootloader

Postby Giovanni » Mon Oct 14, 2024 5:18 pm

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

Postby mma » Tue Oct 15, 2024 8:48 am

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: 14563
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1111 times
Been thanked: 937 times
Contact:

Re: [USB] Jump to internal bootloader

Postby Giovanni » Tue Oct 15, 2024 10:58 am

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

Postby mma » Tue Oct 15, 2024 1:37 pm

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: 14563
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1111 times
Been thanked: 937 times
Contact:

Re: [USB] Jump to internal bootloader

Postby Giovanni » Tue Oct 15, 2024 5:00 pm

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: 833
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 137 times

Re: [USB] Jump to internal bootloader

Postby steved » Wed Oct 16, 2024 8:38 am

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

Postby mma » Wed Oct 16, 2024 4:35 pm

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.


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 9 guests