Emulating Eclipse ‘Run’ with ‘Debug’ Configuration

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!”

 

Run and Debug in Eclipse

Run and Debug in Eclipse

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:

  1. With ‘Run‘, the application code gets downloaded and the application gets started.
  2. 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:

P&E Debug Configuration for Run

P&E Debug Configuration for Run

Segger for Run

Same thing for the Segger J-Link connection: disable that it sets a breakpoint at main:

Segger J-Link configuration for running

Segger J-Link configuration for running

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:

Running Debug Thread

Running Debug Thread

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):

Segger GDB commands to run the target and to disconnect

Segger GDB commands to run the target and to disconnect

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:

Terminated debug session

Terminated debug 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 🙂

Advertisements

20 thoughts on “Emulating Eclipse ‘Run’ with ‘Debug’ Configuration

  1. Pingback: Comparing CodeWarrior with Kinetis Design Studio | MCU on Eclipse

    • 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.

      Like

      • 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!

        Like

  2. 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!

    Like

    • 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.

      Like

      • 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

        Like

        • 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.

          Like

    • 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.

      Like

  3. Pingback: Using Eclipse to Program Binary Files to an Embedded Target | MCU on Eclipse

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.