Hi,
I have a couple of executables [ while(1) {...} loop programs within a main() function ] generated ( hex or bin or s19 ; for simplicity lets say hex ) and I want to allocate each hex file at a specific starting address in the flash memory, so that in a main program I can jump to a specific starting address depending on the input to execute the present code.
1. Any help to solve this problem ? 2. Is there any way to merge these hex files together and then I can can jump to their specific location ?
Thank you, Walid Farid
-------------------------------------- More about the problem ------------------------------
So, I've 3 developed projects where each project interfaces with specific peripherals on the development board. And, I want to load all 3 hex files ( or any other form of executable ) corresponding to each project to the flash memory and execute one of these codes at a time from the flash. I'm not sure why did you mention executing the code from the RAM, if I can execute it directly from the flash.
I thought, if I'm able to load the 3 hex files to the flash memory, I can load a 4th hex file, which given a specific input will run one of the 3 hex files at a time directly from the flash.
I'm using KEIL-MDK evaluation version and looking at the hex file, I can see that the starting/entry point of the code is 0x8000_00ED. So, I'm sure that all hex files will have the same entry point.
In KEIL-MDK, If I changed the code memory area to start at a different location than 0x8000_0000 ( say 0x8000_0100 ), will this change the starting/entry point ? Will the bootloader start executing the code at 0x8000_0100 which maps to the RESET routine? Or does the bootloader, regardless of the entry point in the hex file, places the code starting at 0x8000_0000 ?
I hope I clarified what I want to do ... so, regardless of or with regard to using hex files, how can I solve this problem ?
----------------------------------------------------------------------------------------------
P.S. : This question has already been posted on the STM32 forums
You shouldn't just mention the STM32 board but should post a link to the relevant thread.
Sorry, but it sounds meaningless to store multiple small applications like that.
Just have a small main() that looks at some GPIO signals to decide what to do:
function my_app1() { init1(); for (;;) { do_something1(); } } function my_app2() { init2(); for (;;) { do_something2(); } } function my_app3() { init3(); for (;;) { do_something3(); } } void main(void) { unsigned pins; pins = check_gpio_stimuli(); switch (pins & 0x03) { case 0: my_app1(); break; case 1: my_app2(); break; case 2: my_app3(); break; default: init_serial(); printf("Sorry - no such application\n"); } for (;;) ; }
The compilation time to build everything is no much longer than to compile one tiny app. The download time time is not much longer. The time saved from not having to jump between applications is well worth it. The ability to switch and run without reprogramming is well worth it. Too simple solution? Well, why make it more complicated than needed?
View all questions in Keil forum