Student: “Professor, my application does not work!”
Professor: “What is the problem?”
Student: “I don’t know, but the LED on my board is not blinking.”
Professor: “Can you step through the port initialization sequence and check if the clocks are initialized correctly?”
Student: “I have pressed the ‘Run’ button, I’m not debugging”.
Professor: “Why are you not debugging?”
Student: “I always do a ‘Run’, and I do ‘Debug’ only if needed.”
Professor: “Ahhhhhhrrrrgggg!”
Clearly, I’m not immune to the ‘déformation professionelle‘. I very rarely use ‘Run’, because it simply does not offer much value compared to ‘Debug’ during development. If using ‘Run’ and then there is a problem, I have to ‘Debug’ anyway, why not ‘Debug’ from the beginning? It is simply not an efficient way to work for me. Or I’m missing something?
Well, I see that users who never used a debugger and are used to do ‘printf() debugging’ could take advantage of the ‘Run’ function in Eclipse. But why do ‘printf()’ debugging if you have a debugger which is able to solve the real problems. Printf() debugging is like driving a car handcuffed ;-). Or how can someone seriously develop a firmware without a debugger?
So I was kind of happy to see that both the GNU ARM Eclipse plugins and Kinetis Design Studio do not offer a ‘Run’ function. CodeWarrior for MCU has ‘Run’ implemented, see “Comparing CodeWarrior with Kinetis Design Studio“. And guess what? I received questions how to do ‘Run’ with Kinetis Design Studio ;-).
Emulating ‘Run’ with ‘Debug’
So let me jump over my own shadow, and I show how a ‘Run’ can be done with a ‘Debug’ configuration: The differences between ‘Run’ and ‘Debug’ are:
- With ‘Run‘, the application code gets downloaded and the application gets started.
- With ‘Debug‘, the same thing as ‘Run’ happens, except that it usually sets a breakpoint n main() to stop the target there.
So to do the same as ‘Run’ in a ‘Debug’ configuration, I need to set it up that it does not stop at main.
P&E for Run
For the P&E debug configuration, simply disable the ‘Set breakpoint at’ option in the ‘Startup’ tab of the debug configuration:
Segger for Run
Same thing for the Segger J-Link connection: disable that it sets a breakpoint at main:
Terminating the debugging thread
So while the settings above make the program run, there is still one difference between the original ‘Run’ configuration: in the debug view the thread is still shown:
Which is great for me, as I can halt the target and start debugging. However, if I want to do another ‘run’, I need first to terminate the debug session. I can do this with the following settings (Segger J-Link GDB server):
With this, right after the reset, it sends the ‘monitor go’ command to the J-Link to run the target, followed by a ‘disconnect’ which terminates the Eclipse debugging session:
Now I can load the program to the board, it runs the application and automatically disconnects the debugger.
Summary
It is possible to emulate the ‘Run’ configuration with a modified ‘Debug’ configuration. Basically it simply means not to set a breakpoint and run the target. To extend this with disconnecting from the target, this requires extra gdb or monitor commands, and I was able to make it work for example with the Segger J-Link.
Happy Running 🙂
Pingback: Comparing CodeWarrior with Kinetis Design Studio | MCU on Eclipse
Hi Erich! I want to ask you if we can emulating the hardware for debug without the frdm board. Thanks!
LikeLike
Hi Carlos,
Yes, technicall you can. But you would need a full chip simulator which simulates all parts of the chip and the board. You probably will not find that, because to develop this costs probably >$100k. The hardware is much cheaper ($15), so there is not much economical sense for it.
LikeLike
It’s a shame the cost of the full chip simulation. Sometimes I want develop and try parts of this code in my laptop at the university and the boards are in home, maybe I need carry always the boards with me. Thanks!
LikeLike
Hi Erich! i have a little problem, i had debug my code and is ok but when i disconnect the board and reconnect, my code doesnt run i am using codewarrior 10.6, i remember that in version 10.3 the code remain “programed” i want to run my code without a pc connection
Thanks!
LikeLike
Hi Jorge,
I’m not sure if I understand, but I think you must have a problem in your code or setup. Because I use 10.6 and I can download/debug, and that program remains in the target flash, and the application runs after reset too. Are you using your own custom board? What debug connection (Segger, P&E) are you using? It indeed could be a problem with your board, e.g. with the reset line.
LikeLike
Hello
I am using a freedom kl25z board i am going to check again the setup and re-install codewarrior because i never had this problem before… until now
Thanks Erich
LikeLike
Hi Jorge,
I don’t believe that a re-install of CodeWarrior will help. I guess it is a problem how you have configured/used your project. Could it be that you download to RAM only? I would create a new project with the wizard and try it with that program/project. Or use one of my projects on GitHub.
LikeLike
i hade same problem with code worrior 10.2 i setup project for internal flash and using P&E-usb-ml-ppcnesus
ihad my custom board with pxn2020
LikeLike
You might check the type of project you created. Some times if you create a project with console support the application does not run properly when not connected to a BDM (no pc). Also look at what Erich, said: RAM only applications will not run stand-alone.
LikeLike
Hi Jorge,
Did you find the cause of the problem? What was it? Or are you still trying to track it down?
Thanks.
LikeLike
Hi Erich! Can we run tests for our programs in FRDM Boards?
LikeLike
Hi Carlos,
yes, why not?
LikeLike
I mean run tests in batch like junit in Java.
LikeLike
Well, that depends. If you want to run this on the target itself, then you need to run an interpreter or something like this on the board itself. Not sure if you really want to do this?
LikeLike
Pingback: Using Eclipse to Program Binary Files to an Embedded Target | MCU on Eclipse
Is there a way to automatically switch back to Eclipse’ development perspective?
LikeLike
To my knowledge, there is no such way. Because Eclipse does not track/store from which perspective it is coming from.
LikeLike
Ah, I found something better now: I modified the default perspective for “P&E” in “Preferences -> Run/Debug -> Perspectives”. This way, there is no need to switch back because it simply won’t switch at all when running the “P&E” configuration. Thank you for the blog post!
LikeLike
Hi Martin,
you are welcome :-).
Another thought is: you could give the CodRed perspective a try: https://mcuoneclipse.com/2015/05/10/codered-debug-perspective-in-kinetis-design-studio/
LikeLike
Hi Erich I did your suggestion for P&E in S32 DS. but still it is in debug mode. I want to get the elf files in release mode and upload them on board. I try it but ı get error. Do you have any idea how can i do it?
LikeLike
There should be no difference in how S32 IDE handles this. What is the error?
LikeLike