We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello
I got a application for a Cortex-m0 device.
the application has no entry point, so no main(). This is the way it was designed.
In a way the application does what is supposed to do, but now my problem. I got a few global variables, but they don't get initialized the way i want them to.
When i do add the main function and call that from my startup.s file it does work fine. I read something about scatter loading has something to do with it.
Can someone maybe explain how this works? Or just help with the initialization of the global variables.
Thank you!
Martijn
I got 2 binaries if you must know. 1 with a main and 1 without. 1 is located in the start of the memory the second the second part. The first and second part both have a vector table. when the application starts the reset handler of the first part is called. And in the reset handler i call the resethandler of the second part and from there the main is called. but apperently only the second part gets initialised properly. The first part never did this step. So... is there a way to trigger this without a main?
The linker brings in the code that sets up the C runtime library and your variables when it sees that you have a main(). If you don't have a main(), then it isn't a normal C application and the linker assumes that you have the skills to set up whatever environment your program requires.
When people write boot loaders and applications to load from the boot loader, they normally either write all of the boot loader in assembler. Or they make the boot loader as a normal C program with its own main().