cancel
Showing results for 
Search instead for 
Did you mean: 

How to customize startup file?

trieunguyen
Associate II

I am a newbie in embedded programming. My idea is to build 3 applications with 3 separate project file. These 3 applications will work together in 1 CPU as shown in the image below:

trieunguyen_0-1722178081604.png

To jump from App to another APP, I do the same way bootloader jumps to application:

 

#define ADDR_APP_2_PROGRAM 0x08120000
#define ADDR_APP_3_PROGRAM 0x08140000

typedef void (*pJumpFunc)(void);
pJumpFunc	Jump_To_App;

void Jum_To_APP_2(void);

int main(void)
{
	Jum_To_APP_2();
}

void Jum_To_APP_2(void)
{
	Jump_To_App = (pJumpFunc)*(volatile uint32_t*)(ADDR_APP_2_PROGRAM + 4);
	
//	__disable_irq();
	__set_MSP(*(volatile uint32_t*) ADDR_APP_2_PROGRAM);
	Jump_To_App();
}

 

Jump from one application to another was successful. But the obvious problem here is that data segment initializers copy from flash to SRAM of APP_2 and APP_3 will be performed repeatedly in a loop. I thought of a few ideas like: skipping the copy instructions in the startup code from the 2nd loop onwards, but I'm stuck. I don't find any commands related to _sdata, _sidata... or bss in the startup file generated by STM32CubeMX.  Is there some hidden code associated with the current startup file? Can I create a custom startup file to replace the current startup file?

If you can I would love for you to give me an idea! Thank you very much!

(I'm using Keil.I used the label STM32CubeIDE because I couldn't find a more suitable label.)

15 REPLIES 15
Andrew Neil
Evangelist III

@trieunguyen wrote:

I am a newbie in embedded programming. My idea is to build 3 applications with 3 separate project file. .)


Why 3 separate apps?

It sounds like what you really have is just one application, with 3 modes.

That can easily be implemented as 3 functions:

do_app1_stuff();

while(1)
{
   do_app2_stuff();
   do_app3_stuff();
}

 

Well, if the ultimate goal is to implement a technological process, the simplest and most efficient way is to create an application. But 3 separate apps instead of one will allow members to work completely independently but still achieve a common goal.

You can easily do that without the unnecessary complication of 3 separate apps.

Each function can be implemented in its own separate (set of) file(s).

This is how most development is done - with various people/teams working separately on different parts of the one "app".

 


@trieunguyen wrote:

separate apps instead of one will allow members to work completely independently but still achieve a common goal.


Not completely independently - they still have to collaborate to bring the 3 apps together to run on the target!

I see what you mean. I also know some ways to organize the source code as you said but the solution that suits my requirements (and some other requirements) is to divide the program into separate applications. Of course, in terms of logic and data, the applications are not independent, I need to organize the data and coordinate the logic so that the applications can work together. But in terms of each person's work, the respective application is independent.
!!! I think my poor English ability also caused unnecessary confusion!

trieunguyen
Associate II

Thank you everyone! I solved this!

Good to hear.

For the benefit of others who may find this, please describe the solution, and mark it:

https://community.st.com/t5/community-guidelines/help-others-to-solve-their-issues/ta-p/575256