Debugging Bootloader and Application with one Debug Session

If having a boot loader running on a micro-controller, it is very useful if both the boot loader and the loaded application can be debugged together:

Bootloader with Application Code

Bootloader with Application Code

So how to make this work?

First have the boot loader flashed and have it loaded an application (see https://mcuoneclipse.com/2019/10/06/linking-bootloader-applications-with-eclipse-and-freemarker-scripts/).

Then have in the application project a debug launch configuration created (I’m using a J-Link here):

Launch Configuration for application

Launch Configuration for application

The trick is to configure this launch so it does not flash/overwrite anything on the target and does an ‘attach’ instead:

Attach to a running target

Attach to a running target

To prevent writing a new binary, make sure ‘Load image’ is unchecked and ‘Load Symbols’ for the application is checked:

Load Image and Load Symbols

Load Image and Load Symbols

Finally, load the extra symbols of the boot loader itself:

Load Other Symbols

Load Other Symbols

💡 If I have more parts for which I want the debug symbols, I can use the ‘+’ and add more files.

With this, I have source level debugging for both the boot loader *and* the application 🙂

Debugging Application on Top of Bootloader

Debugging Application on Top of Bootloader

Happy Bootloading 🙂

Links

6 thoughts on “Debugging Bootloader and Application with one Debug Session

  1. Hello Erich,
    I was EXACTLY wondering if there was such an article on MCUonEclipse.
    Out of curiosity, how would you debug THREE executables? I am thinking of a boot manager, a bootloader and an application, for example. Assuming non-overlapping sessions (but also overlapping) I would merge the hex files, but I don’t know if this approach would be feasibile with elf files.
    K.R.

    Luca

    Like

  2. Hello, i have bootloader and my application. After flash bootloader i want to flash and debug my application only. Is it possible? thanks so much.

    Like

      • I think the question was about whether it is possible to launch debugger and provide it with signed application and symbols somehow. In this approach debugger writes into partition and once bootloader finishes you can stop at the breakpoint in the application. This way you don’t need to attach.

        Like

        • Yes, this is possible. It depends somewhat on the debug probe used, as some perform an erase on sectors. If the load keeps the bootloader, you can simply add loading the application and then debug it. For the resident bootloader use the ‘symbols’ to debug it.

          Like

What do you think?

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