This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Bootloader debugging

I want my application to cooperate with DFU. I am using example DFU project from SDK (6.1) (from nrf6310 folder, i simplified it so it could work on PCA10000), but i need some bigger changes.

My problem is that i cannot start debug session in keil. Is bootloader debugging the same as normal application debugging? I can start application, but i cannot set traps and check where the program is at the moment. Should i do some extra settings in keil?

What i do is: erase chip -> flash s110 SD (v7) -> load bootloader by keil -> start debugging -> no profit :(

  • Hi,

    The bootloader firmware is by default configured with optimization at level 3 and therefore not very friendly for debugging.

    What you need to do with the bootloader project is to change the otimization level to 0 - turn off all optimization. However, when doing that the size of the bootloader will be about 22kB , bigger than the default 15kB IROM1 size. The bootloader already located at the top of the flash area so we can't simply increase the size of IROM1 but have to move the start address of the bootloader down to make space for it.

    So what you need to do in bootloader project -> Target Options is the following:

    - C/C++ Tab: Select optimization "Level 0"

    - Target Tab: IROM1 Start: 0x3A000; IROM Size: 0x5C00; (to make room for bigger bootloader)

    - Uncheck the "Use Cross-Module Optimization" checkbox

    - Debug Tab: Use J-LINK / J-TRACE Cortex debugger and press the settings button to select the serial number for your evaluation kit/development kit. Also check "Load application at startup" and "Run to main" checkboxes.

    We also write to UICR.BOOTLOADERADDR the start address of bootloader, so we need to update it as well:

    - In dfu_types.h file update: #define BOOTLOADER_REGION_START 0x0003A000

    Note that if you already write to UICR the default start address of the bootloader (0x0003C000) , this address won't be updated unless you erase the whole chip. So you should do an erase all before you program the softdevice and the new bootloader.

    Now you should be able to debug the bootloader as a normal application.

  • I have try according to your suggestion but i am not able to start point at main function.

    I have also put break point immediate after main function in my code but i am not able to reach breakpoint.

    I am using keil.

  • Hi, are you able to make the debugger work right now? Could you please tell me what the trick is if you resolved this problem? I am having the exact same issue as you described above. Thanks in advance.

  • As far as i remember, Stefan post solved this problem for me. Turning off optimization is the key.

  • Thanks for the reply! I followed all the steps mentioned above but result is that the bootloader runs as expected but the debugger lose track of the process: Not hitting breakpoints or resetting to the start of main function. I wonder if the setting in Keil is incorrect so that the debugger cannot locate which line it is running.

Related