Hello,
I'm working on an application where I need a firmware update. I wrote a bootloader, but I don't get a right solution how to jump to a fixed memory address. I read many forums but those solution wasn't good. I check with my bootlader, that if the uploaded binary file (stored in the flash memory of microcontroller) is a new firmware?, need a firmware update?, if yes the program sholud jump to the application code address in the memory. If isn't new firmware the program should jump in default to the application address.
Can You tell me how can I implement it in C, or better in inline assembly?
Please help me to find a good solution, Kind regards, Szabolcs
P.s.: I'm working with STM32F407 microcontroller, and I use the Keil environment with ARM C51 compiler
Jumping to a fixed address shows a basic lack of understanding of the Cortex-M4 with multiple firmware images, I'd suggest you start by reading some technical manuals so you know a little bit about how it functions. Review the other forum answers until you do understand them.
Review ST's IAP Examples, there are ones using the USART, others for the STM32F4-DISCO that use USB Flash Sticks (fw_upgrade), and check for new images, etc.
In C use function pointers to transfer control.
typedef void (*pFunction)(void); pFunction Jump_To_Fixed; Jump_To_Fixed = (pFunction) 0x08012345; // ODD Thumb Addr Jump_To_Fixed();
Thank You so much, Your rapid answer and Your advice. Excuse me for my questions, but I'm new in this area and I would like to understand very well the bootloader operation on Arm processors.
I got those examples and technical manuals what You referred. I tried to implement the firmware upgrade based on examples but when the program reached to Jump_To_Application() was crashed.
In this examples I didn't see the Vector table address relocating, but I read that if we want to jump to another firmware the vector table offset should be set to the right value. I tried but neither help.
Can You tell me, why chrashes the program?
Kind regards, Szabolcs Vass
You should first understand the processor, and how it executes code.
There are a lot of reasons things crash, your code is broken, and I can't see it remotely, you have a debugger, step the code and understand where it goes. ST provides working examples, try those first.
I got the problem. I wrote my bootloader code in Keil and my application code in SystemWorkbench for STM32, because the limitation of code size in Keil.
Today I write a little test code in both environment and built them. The beginning of two binary file are different. When I loaded the bootloader and the test program (written in Keil) to the appropriate address of flash, the program worked fine. The bootloader jumped to the right address and run the test code.
But if I did the same thing with the test code written in System Workbench, the program chrashed. In this environment a little bit complex to define the load address than in the Keil toolchain. Here are linkerscript and other files where we should do modifies. So problem comes from it. I try to find solutions.
One mor time thank You for Your help, Sincerelly, Szabolcs Vass