cancel
Showing results for 
Search instead for 
Did you mean: 

Replace STM32 firmware from application code

MikeH2112
Associate II

I have an STM32F429 custom board that when in product only supports CAN bus.

I need to be able to upgrade firmware while in product over CAN bus. I know the bootloader supports this but sadly our custom board has been designed to use different CAN bus Tx/RX pins than the bootloader expects:

In our design we use the default CAN1 pins:

PD0 - RX, PD1 - TX

The bootloader is doing CAN over non-standard CAN2 pins:

PB5 - RX, PB13 - TX

I already have code in place to allow bitmap data to be uploaded over CAN and programmed to flash. I'd like to leverage this to upload a binary firmware image and load it over the currently running firmware. Not sure if anyone has a better idea. Is there an example of how to do this anywhere?

Thank you. Any help appreciated.

4 REPLIES 4
MM..1
Chief III

You need two points

  1. Method to activate switch to upgrade mode. If system loader is used normal way is start on AN2606 boot pattern for example BOOT0 pin. Second way is jump to bootloader code from app after an event. Here you can jump to your own or system bootloader
  2. Your pins is other then you need write own bootloader code and jump to it. For example on addr 0x8000000 your bootloader and on 0x8008000 app code. Ofcourse upgrade only app is possible.

ST has some IAP (In-App Programming) examples in various Cube repositories

Some of the F4 Disco boards has a "FWUpgrade" type example using USB MSC Host.

I'd generally recommend splitting the FLASH such that you have a Boot Loader, App, and staged update. If you have external flash to stage the update that might help if it is large, or you have issues with real-time responsiveness when flash writes stall the processor. Can also run from RAM to avoid that.

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

Thank you Tesla. Could you please post a link to these examples you mentioned that I couldn't find:

  1. ST has some IAP (In-App Programming) examples in various Cube repositories
  2. Some of the F4 Disco boards has a "FWUpgrade" type example using USB MSC Host.

I agree splitting flash would be the best option. I don't have external flash but my memory footprint is very small. When a flash update is in progress nothing else will be happening.

I have a way for my host device to command the STM target to jump to the bootloader. That works fine. But my board is hardwired to listen on the wrong CAN signals so that won't do me any good now (can't redesign the board as we already built a quantity).

I'll use the ST-LINK to program my application into the raw boards from the factory. After that though I don't want to use ST-LINK anymore.

With my current application (v1.0) I can upload the new application (v2.0) into RAM but then I need to overwrite the currently executing application with the new one. Sorry, it's a bit hard to explain.