2007-09-06 5:04 AM
2007-08-31 8:37 AM
I'm currently working with an STR710FZ2T6 on an STR710-EVAL board. I am very new to MCU development and my background consists mostly of traditional C/C++ software development on x86 hosts.
For a few days now, I've been trying to figure out why I can't get a simple application to boot from the embedded flash (at 0x40000000) when I depress the Reset switch or reconnect power to the board. However I am able to run my app by sending a Startup/Go command to the board from the debugger. I am using the Realview Debugger software and an RVICE-ME. I realized that the declaration of my main function included arguments, and that doesn't work, but if I change it to take in no arguments, then it boots on reset or from a power cycle just fine. This won't run on reset or bootCode:
int main (int argc, char** argv)
But this worksCode:
int main (void)
So I have a few questions which I'd be happy if anyone could shed some light on. What are the differences between running a program through the debugger versus running at boot time with regards to passing arguments into the main function? Is it possible to pass in arguments to the main function, either through the debugger or at system boot? Thanks in advance.2007-08-31 8:41 PM
With IAR EWARM software, the disassembly shows no difference in generated code for main() with or without arguments. It could be different with the RealView compiler. Try examining disassembly listings for main().
Normally it is not possible to pass arguments to main() in a microcontroller-based system. You certainly could modify the pre-main() code to communicate arguments to the system via some communications link and pass them to main(), but it is not practical and no-one ever does that.2007-09-06 5:04 AM
Volius, thanks for the reply. That's what I was thinking as well; using arguments to main with a microcontroller doesn't make sense to me either.
2025-03-20 10:48 PM - edited 2025-03-20 10:49 PM
Hello all,
sorry for answering this dinosaur-old thread, but i can't agree at all. I am thinking of arguments from bootloader to main. And it would be useful if bootloader can load arguments of updateinformation, version information, memory locations, e.g. to the applikation, WITHOUT knowing fixed memory addresses.
Imagine what benefits that solution would bring with it. You can write very applikation independent bootloader solutions And they will be very portable and easy to use, no need to do additional lincerscript magic or stuff.
maybe someone can find a solutions to get parameters from Bootloader to applikation main.
I am thinking of calling void(*)(argc, argv) ptr instead of void(*)(void), maybe it is easy like that, but i am not sure if the startupcode applikation, called prior to main doesn't override the registers.
best regards
2025-03-20 11:01 PM - edited 2025-03-21 12:29 AM
By now i tried to give Arguments from bootloader to main, easily by calling an function pointer with arguments, after setting VTOR and resetting stackpointer.
The parameter is correctly stored in #R0 and visible in application, but gets overridden by the default startupcode cause it uses #R0 itself, and does not push the used registers onto stack.
To be honest, i didn't expect that is works without modifications, but to change the asm startupscript would be easy, I will give it a try ...
=>
It is possible, with small modifications of the startupscript, to start main with "int argc, char *argv[]" Arguments.
So if anyone needs the bootloader to tell some information in a smart and portable way to the applications, this may be a good way.