cancel
Showing results for 
Search instead for 
Did you mean: 

usb bootloader in cortex-m3

nicolacodogno
Associate II
Posted on October 16, 2014 at 12:50

Hi everybody,

this is my first post on STe2e, so be patient with me.

I've read a good amount of threads related to bootloaders/interrupt/VTOR but I cannot find a final word to my problem so I decided to start a new thread.

I'm working on stm32f103 and my application is using USB for communication.

I wrote a simple bootloader based on AN2557 for application update through USB.

For various reasons I must start the application code without resetting the MCU and after using USB.

Once jumped to application code, the USB_IRQHandler is never executed, leading to usb fault.

NOTE: before jumping I successfully shut down USB interface and disable all interrupts and the vector table is remapped at beginning of user application.

After trying different approaches I disabled USB interrupts in bootloader and manage USB by polling. So USB_IRQHandler is correctly executed in user application now.. but I don't like this solution so much.

Is there a way to use the same interrupt in booltloader AND in application?

Thank you for your kind help,

Nicola
12 REPLIES 12
nicolacodogno
Associate II
Posted on October 22, 2014 at 16:20

hi sung.chen_chung,

the solution you are suggesting is certainly a possibility.

I did something similar locating the ''firmware upgrade'' flag in flash, but I agree that using ram would be more elegant.

Thank you.
Posted on October 22, 2014 at 17:50

You suggest to pass

''information between the two about the configuration and state''

is unclear, what

''adequate information''

would you pass considering I'm killing peripherals and cleaning interrupts register before jumping to the application code?

Think of it like a meal order ticket in a restaurant and it's shift change time in the kitchen. You need to hand-over the order, so what the order is, what's been done so far, how many minutes are left on the steak, etc. In computer science this is often referred to as ''state'' information. If you've configured pins, or have interrupts enabled/pending, or in the midst of a multi-block transfer or sequence, that kind of stuff. Anything that's not in a reset state, or you've spent a lot of cycles initializing, and would take lots more cycles to reinitialize.

Please explain your point.

 

 

''You'll probably want to rework the application's SystemInit() code so that it doesn't tear down and reconfigure the clocking and PLL, and you'd want it to point the vector table at the one owned by the application.''

Your car is running, you jump in and crank the starter again? Much unnecessary screeching and grinding occurs, don't do that. You're driving along at 72 MPH on the motorway, and suddenly decide to shift into first gear, in the STM32 you won't tear the gear box and transmission out, but the speed differential may leave peripherals (the registers and flip-flops you can't see) in indeterminate states.

I wonder if my issue could be related to a specific choice or bug in the IC design.

Frankly one of the least likely causes of failure. Check what the validation engineers identified in the errata.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
nicolacodogno
Associate II
Posted on October 22, 2014 at 21:16

Dear clive1,

thank you so much for explaining to me what

''computer science''

deals with.

Carefully reading all the details I gave in this thread would spare you from giving inappropriate replies.

Treating people with condescension is considered rude in almost all cultures in the world but yours.