Cannot get past bt_enable with debugger connected.

Hi, I have this problem and I couldn't find any working solutions.

I am developing my own hardware and there weren't any problems until I started to use debugger. 

My program (and also periphetial example) doesn't go past bt_enable(NULL); function when I'm running it with gdb debugger. 
I'm using Jlink GDB server and VS Code with configuration:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug with J-Link (External Server)",
            "cwd": "${workspaceRoot}",
            "executable": "${workspaceRoot}/build/peripheral/zephyr/zephyr.elf",
            "request": "launch",
            "type": "cortex-debug",
            "servertype": "external", // Use "external" to connect to an already running server
            "gdbTarget": "localhost:2331", // Connect to the server running on port 2331
            "device": "nrf52", // Replace with your target device (e.g., "stm32f4x", "nrf52840", etc.)
            "interface": "swd", // Use "swd" or "jtag" depending on your setup
            "gdbPath": "C:/Program Files (x86)/GNU Arm Embedded Toolchain/10 2021.10/bin/arm-none-eabi-gdb.exe", // Path to your GDB executable
            "runToMain": true, // Optional: Run to main() automatically
            "showDevDebugOutput": "raw" // Optional: Show verbose GDB transactions for debugging
        }
    ]
}
When program is ran without dbg (just uploaded with JFlash and then using JFlash's Start application [F9] ) it is working great. However when I connect to gdb server and run it in debug mode (both builded with -Og) it stops on assert in function  bt_hci_cmd_send_sync on assert: 

BT_ASSERT_MSG(err == 0,
              "Controller unresponsive, command opcode 0x%04x timeout with err %d",
              opcode, err);

where I can see variable values err = -11 and opcode = 3075
Do you have any idea, what the problem may be?
Thank you!
Parents Reply
  • Hi,

    basically this is the workflow to replicate the fault > 

    choose sample project e.g. https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/bluetooth/peripheral

    build, connect debbuger via SWD (SWDIO, SWCLK)

    run Jlink GDB server add VS script for debugging and run it.
    It will flash the software to board and will break at the start of the main.

    From this point if you just press "continue" or "run" without any stepping. It will end up halted in endless loop after u press pause after some time. This is the call stack:

    I also tried to add breakpoint after the bt_enable(NULL); function in main, and then it just breaks on the mentioned assert (with variable values being err = -11 and opcode = 3075).

    Same case with ADC measurement. When the debugger is connected and debugging through gdb, program does not work even when I'm letting it run without any stepping. 

    Hope my explanation is clear, thank you!

Children
Related