Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rttConfig.enable does nothing (arm gdb + blackmagicprobe on stlink). here is the proof + workaround #1065

Open
albmef opened this issue Dec 1, 2024 · 5 comments
Assignees

Comments

@albmef
Copy link

albmef commented Dec 1, 2024

hi !
below is the proof that enabling rtt with just rttconfig.enable just does not work (on my config)

setup:

  • VSCODE on archlinux, with cortex debug extension V1.12.1
  • board st nucleo-f441re with blackmagicprobe (target = cortexm, stm and rtt enabled)

prior each test i manually disable the rtt by either doing a cold start, or typing monitor rtt disable in a gdb CLI

first test:
launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "BMP Launch RTT",
            "type": "cortex-debug",
            "request": "launch",
            "executable": "${workspaceFolder}/build/zephyr/zephyr.elf",
            "cwd": "${workspaceFolder}",
            "servertype": "bmp",
            "BMPGDBSerialPort": "/dev/ttyBmpGdb",
            "interface": "swd",
            "runToEntryPoint": "main",
            // "runToEntryPoint": "__start",
            "breakAfterReset": true,
            "showDevDebugOutput": "raw",
            "svdPath": "${workspaceFolder}/boards/arm/nucleo_f411re_bmp/support/STM32F411.svd",
            "rttConfig": {
                "enabled": true,
            }
        }
    ]
}

here is the log from debug console

Cortex-Debug: VSCode debugger extension version 1.12.1 git(652d042). Usage info: https://github.com/Marus/cortex-debug#usage
"configuration": {
    "name": "BMP Launch RTT",
    "type": "cortex-debug",
    "request": "launch",
    "executable": "/home/alban/zephyr_workspace/blinky_f411re_BMP/build/zephyr/zephyr.elf",
    "cwd": "/home/alban/zephyr_workspace/blinky_f411re_BMP",
    "servertype": "bmp",
    "BMPGDBSerialPort": "/dev/ttyBmpGdb",
    "interface": "swd",
    "runToEntryPoint": "main",
    "breakAfterReset": true,
    "showDevDebugOutput": "raw",
    "svdPath": "/home/alban/zephyr_workspace/blinky_f411re_BMP/boards/arm/nucleo_f411re_bmp/support/STM32F411.svd",
    "rttConfig": {
        "enabled": true,
        "decoders": []
    },
    "__configurationTarget": 6,
    "gdbServerConsolePort": 55878,
    "pvtAvoidPorts": [],
    "chainedConfigurations": {
        "enabled": false
    },
    "debuggerArgs": [],
    "swoConfig": {
        "enabled": false,
        "decoders": [],
        "cpuFrequency": 0,
        "swoFrequency": 0,
        "source": "probe"
    },
    "graphConfig": [],
    "preLaunchCommands": [],
    "postLaunchCommands": [],
    "preAttachCommands": [],
    "postAttachCommands": [],
    "preRestartCommands": [],
    "postRestartCommands": [],
    "preResetCommands": [],
    "postResetCommands": [],
    "powerOverBMP": "lastState",
    "targetId": 1,
    "toolchainPath": "/home/alban/zephyr-sdk-0.16.8/arm-zephyr-eabi/bin/",
    "toolchainPrefix": "arm-zephyr-eabi",
    "extensionPath": "/home/alban/.vscode-oss/extensions/marus25.cortex-debug-1.12.1-universal",
    "registerUseNaturalFormat": true,
    "variableUseNaturalFormat": true,
    "pvtVersion": "1.12.1",
    "__sessionId": "59008cd4-aa6a-4bcc-bbd6-345e87a6d881",
    "pvtShowDevDebugOutput": "raw"
}
Reading symbols from /home/alban/zephyr-sdk-0.16.8/arm-zephyr-eabi/bin/arm-zephyr-eabi-objdump --syms -C -h -w /home/alban/zephyr_workspace/blinky_f411re_BMP/build/zephyr/zephyr.elf
Reading symbols from /home/alban/zephyr-sdk-0.16.8/arm-zephyr-eabi/bin/arm-zephyr-eabi-nm --defined-only -S -l -C -p /home/alban/zephyr_workspace/blinky_f411re_BMP/build/zephyr/zephyr.elf
Launching GDB: /home/alban/zephyr-sdk-0.16.8/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb -q --interpreter=mi2
1-gdb-version
Finished reading symbols from objdump: Time: 49 ms
INFO: "rttConfig.address" not specified. Defaulting to "auto"
Finished reading symbols from nm: Time: 86 ms
-> =thread-group-added,id="i1"
-> ~"GNU gdb (Zephyr SDK 0.16.8) 12.1\n"
-> ~"Copyright (C) 2022 Free Software Foundation, Inc.\n"
-> ~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law."
-> ~"\nType \"show copying\" and \"show warranty\" for details.\n"
-> ~"This GDB was configured as \"--host=x86_64-build_pc-linux-gnu --target=arm-zephyr-eabi\".\n"
-> ~"Type \"show configuration\" for configuration details.\n"
-> ~"For bug reporting instructions, please see:\n"
-> ~"<https://github.com/zephyrproject-rtos/sdk-ng/issues>.\n"
-> ~"Find the GDB manual and other documentation resources online at:\n    <http://www.gnu.org/software/gdb/documentation/>."
-> ~"\n\n"
-> ~"For help, type \"help\".\n"
-> ~"Type \"apropos word\" to search for commands related to \"word\".\n"
-> 1^done
2-gdb-set mi-async on
-> 2^done
3-interpreter-exec console "set print demangle on"
-> 3^done
4-interpreter-exec console "set print asm-demangle on"
-> =cmd-param-changed,param="print asm-demangle",value="on"
-> 4^done
5-enable-pretty-printing
-> 5^done
6-interpreter-exec console "source /home/alban/.vscode-oss/extensions/marus25.cortex-debug-1.12.1-universal/support/gdbsupport.init"
-> 6^done
7-interpreter-exec console "source /home/alban/.vscode-oss/extensions/marus25.cortex-debug-1.12.1-universal/support/gdb-swo.init"
-> =cmd-param-changed,param="language",value="c"
-> =cmd-param-changed,param="language",value="auto"
-> 7^done
8-interpreter-exec console "set output-radix 0xa"
-> ~"Output radix now set to decimal 10, hex a, octal 12.\n"
Output radix now set to decimal 10, hex a, octal 12.
-> 8^done
9-interpreter-exec console "set input-radix 0xa"
-> ~"Input radix now set to decimal 10, hex a, octal 12.\n"
Input radix now set to decimal 10, hex a, octal 12.
-> 9^done
10-file-exec-and-symbols "/home/alban/zephyr_workspace/blinky_f411re_BMP/build/zephyr/zephyr.elf"
-> 10^done
11-target-select extended-remote /dev/ttyBmpGdb
-> 11^connected
12-interpreter-exec console "monitor swdp_scan"
-> @"Target voltage: 3.29V\n"
Target voltage: 3.29V
-> @"Available Targets:\n"
Available Targets:
-> @"No. Att Driver\n"
No. Att Driver
-> @" 1      STM32F411 M4\n"
 1      STM32F411 M4
-> 12^done
13-interpreter-exec console "attach 1"
-> ~"Attaching to program: /home/alban/zephyr_workspace/blinky_f411re_BMP/build/zephyr/zephyr.elf, Remote target\n"
Attaching to program: /home/alban/zephyr_workspace/blinky_f411re_BMP/build/zephyr/zephyr.elf, Remote target
-> =thread-group-started,id="i1",pid="1"
-> =thread-created,id="1",group-id="i1"
-> *running,thread-id="1"
mi2.status = running
-> 13^done
-> ~"__enable_irq () at /home/alban/zephyr_workspace/modules/hal/cmsis/CMSIS/Core/Include/cmsis_gcc.h:951\n"
__enable_irq () at /home/alban/zephyr_workspace/modules/hal/cmsis/CMSIS/Core/Include/cmsis_gcc.h:951
14-interpreter-exec console "set mem inaccessible-by-default off"
-> ~"951\t  __ASM volatile (\"cpsie i\" : : : \"memory\");\n"
951	  __ASM volatile ("cpsie i" : : : "memory");
-> *stopped,frame={addr="0x080048ba",func="__enable_irq",args=[],file="/home/alban/zephyr_workspace/modules/hal/cmsis/CMSIS/Core/Include/cmsis_gcc.h",fullname="/home/alban/zephyr_workspace/modules/hal/cmsis/CMSIS/Core/Include/cmsis_gcc.h",line="951",arch="armv7e-m"},thread-id="1",stopped-threads="all"
mi2.status = stopped
Program stopped, probably due to a reset and/or halt issued by debugger
-> =cmd-param-changed,param="mem inaccessible-by-default",value="off"
-> 14^done
15-target-download
-> 15+download,{section="rom_start",section-size="408",total-size="610782"}
-> 15+download,{section="rom_start",section-sent="408",section-size="408",total-sent="408",total-size="610782"}
-> 15+download,{section="text",section-size="23000",total-size="610782"}
-> 15+download,{section=".ARM.exidx",section-size="8",total-size="610782"}
-> 15+download,{section="initlevel",section-size="152",total-size="610782"}
-> 15+download,{section="device_area",section-size="260",total-size="610782"}
-> 15+download,{section="sw_isr_table",section-size="688",total-size="610782"}
-> 15+download,{section="log_const_area",section-size="64",total-size="610782"}
-> 15+download,{section="log_backend_area",section-size="16",total-size="610782"}
-> 15+download,{section="rodata",section-size="3148",total-size="610782"}
-> 15+download,{section="datas",section-size="88",total-size="610782"}
-> 15+download,{section="device_states",section-size="26",total-size="610782"}
-> 15+download,{section="log_mpsc_pbuf_area",section-size="56",total-size="610782"}
-> 15+download,{section="log_msg_ptr_area",section-size="4",total-size="610782"}
-> 15+download,{section=".last_section",section-size="4",total-size="610782"}
-> 15^done,address="0x08001ae4",load-size="27922",transfer-rate="251264",write-rate="698"
16-interpreter-exec console "SoftwareReset"
-> =cmd-param-changed,param="language",value="c"
-> ~"Warning: the current language does not match this frame.\n"
Warning: the current language does not match this frame.
-> =memory-changed,thread-group="i1",addr="0xe000ed0c",len="0x4"
-> =cmd-param-changed,param="language",value="auto"
-> 16^done
Returning dummy thread-id to workaround VSCode issue with pause button not working
Returning dummy stack frame to workaround VSCode issue with pause button not working: {"threadId":1,"startFrame":0,"levels":20}
17-break-insert -t --function main
-> ~"Note: automatically using hardware breakpoints for read-only addresses.\n"
Note: automatically using hardware breakpoints for read-only addresses.
-> 17^done,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x0800047c",func="main",file="/home/alban/zephyr_workspace/blinky_f411re_BMP/src/main.c",fullname="/home/alban/zephyr_workspace/blinky_f411re_BMP/src/main.c",line="29",thread-groups=["i1"],times="0",original-location="-function main"}
18-exec-continue --all
-> 18^running
-> *running,thread-id="all"
mi2.status = running
Info: Received readMemory request while busy. {"memoryReference":"0x40020000","count":40}
-> =breakpoint-modified,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x0800047c",func="main",file="/home/alban/zephyr_workspace/blinky_f411re_BMP/src/main.c",fullname="/home/alban/zephyr_workspace/blinky_f411re_BMP/src/main.c",line="29",thread-groups=["i1"],times="1",original-location="-function main"}
-> ~"\n"

-> ~"Temporary breakpoint 1, main () at /home/alban/zephyr_workspace/blinky_f411re_BMP/src/main.c:29\n"
Temporary breakpoint 1, main () at /home/alban/zephyr_workspace/blinky_f411re_BMP/src/main.c:29
-> ~"29\t{\n"
29	{
-> *stopped,reason="breakpoint-hit",disp="del",bkptno="1",frame={addr="0x0800047c",func="main",args=[],file="/home/alban/zephyr_workspace/blinky_f411re_BMP/src/main.c",fullname="/home/alban/zephyr_workspace/blinky_f411re_BMP/src/main.c",line="29",arch="armv7e-m"},thread-id="1",stopped-threads="all"
mi2.status = stopped
-> =breakpoint-deleted,id="1"
Failed to update peripheral GPIOA: Error: peripheral-viewer: readMemory failed @ 0x40020000 for 40 bytes: CodeExpectedError: Busy, session=59008cd4-aa6a-4bcc-bbd6-345e87a6d881
19-thread-list-ids
-> 19^done,thread-ids={thread-id="1"},current-thread-id="1",number-of-threads="1"
20-thread-info 1
-> 20^done,threads=[{id="1",target-id="Thread 1",frame={level="0",addr="0x0800047c",func="main",args=[],file="/home/alban/zephyr_workspace/blinky_f411re_BMP/src/main.c",fullname="/home/alban/zephyr_workspace/blinky_f411re_BMP/src/main.c",line="29",arch="armv7e-m"},state="stopped"}]
21-data-read-memory-bytes "0x40020000" 40
-> 21^done,memory=[{begin="0x40020000",offset="0x00000000",end="0x40020028",contents="a00000a8000000000000000c100000640cc000000000000000000000000000000077000000000000"}]
22-stack-list-frames --thread 1 0 19
-> 22^done,stack=[frame={level="0",addr="0x0800047c",func="main",file="/home/alban/zephyr_workspace/blinky_f411re_BMP/src/main.c",fullname="/home/alban/zephyr_workspace/blinky_f411re_BMP/src/main.c",line="29",arch="armv7e-m"}]

RESULT : nothing in the RTT output console (attached to /dev/ttyDmpTarg) !!!!


second test:
launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "BMP Launch RTT",
            "type": "cortex-debug",
            "request": "launch",
            "executable": "${workspaceFolder}/build/zephyr/zephyr.elf",
            "cwd": "${workspaceFolder}",
            "servertype": "bmp",
            "BMPGDBSerialPort": "/dev/ttyBmpGdb",
            "interface": "swd",
            "runToEntryPoint": "main",
            // "runToEntryPoint": "__start",
            "breakAfterReset": true,
            "showDevDebugOutput": "raw",
            "svdPath": "${workspaceFolder}/boards/arm/nucleo_f411re_bmp/support/STM32F411.svd",
            "postLaunchCommands": ["monitor rtt enable"],
            // "rttConfig": {
            //     "enabled": true,
            // }
        }
    ]
}

here the log:

Cortex-Debug: VSCode debugger extension version 1.12.1 git(652d042). Usage info: https://github.com/Marus/cortex-debug#usage
"configuration": {
    "name": "BMP Launch RTT",
    "type": "cortex-debug",
    "request": "launch",
    "executable": "/home/alban/zephyr_workspace/blinky_f411re_BMP/build/zephyr/zephyr.elf",
    "cwd": "/home/alban/zephyr_workspace/blinky_f411re_BMP",
    "servertype": "bmp",
    "BMPGDBSerialPort": "/dev/ttyBmpGdb",
    "interface": "swd",
    "runToEntryPoint": "main",
    "breakAfterReset": true,
    "showDevDebugOutput": "raw",
    "svdPath": "/home/alban/zephyr_workspace/blinky_f411re_BMP/boards/arm/nucleo_f411re_bmp/support/STM32F411.svd",
    "postLaunchCommands": [
        "monitor rtt enable"
    ],
    "__configurationTarget": 6,
    "gdbServerConsolePort": 55878,
    "pvtAvoidPorts": [],
    "chainedConfigurations": {
        "enabled": false
    },
    "debuggerArgs": [],
    "swoConfig": {
        "enabled": false,
        "decoders": [],
        "cpuFrequency": 0,
        "swoFrequency": 0,
        "source": "probe"
    },
    "rttConfig": {
        "enabled": false,
        "decoders": []
    },
    "graphConfig": [],
    "preLaunchCommands": [],
    "preAttachCommands": [],
    "postAttachCommands": [],
    "preRestartCommands": [],
    "postRestartCommands": [],
    "preResetCommands": [],
    "postResetCommands": [],
    "powerOverBMP": "lastState",
    "targetId": 1,
    "toolchainPath": "/home/alban/zephyr-sdk-0.16.8/arm-zephyr-eabi/bin/",
    "toolchainPrefix": "arm-zephyr-eabi",
    "extensionPath": "/home/alban/.vscode-oss/extensions/marus25.cortex-debug-1.12.1-universal",
    "registerUseNaturalFormat": true,
    "variableUseNaturalFormat": true,
    "pvtVersion": "1.12.1",
    "__sessionId": "7035b9b4-eb7d-4ee5-a0e6-6acc36ad9774",
    "pvtShowDevDebugOutput": "raw"
}
Reading symbols from /home/alban/zephyr-sdk-0.16.8/arm-zephyr-eabi/bin/arm-zephyr-eabi-objdump --syms -C -h -w /home/alban/zephyr_workspace/blinky_f411re_BMP/build/zephyr/zephyr.elf
Reading symbols from /home/alban/zephyr-sdk-0.16.8/arm-zephyr-eabi/bin/arm-zephyr-eabi-nm --defined-only -S -l -C -p /home/alban/zephyr_workspace/blinky_f411re_BMP/build/zephyr/zephyr.elf
Launching GDB: /home/alban/zephyr-sdk-0.16.8/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb -q --interpreter=mi2
1-gdb-version
Finished reading symbols from objdump: Time: 49 ms
Finished reading symbols from nm: Time: 85 ms
-> =thread-group-added,id="i1"
-> ~"GNU gdb (Zephyr SDK 0.16.8) 12.1\n"
-> ~"Copyright (C) 2022 Free Software Foundation, Inc.\n"
-> ~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law."
-> ~"\nType \"show copying\" and \"show warranty\" for details.\n"
-> ~"This GDB was configured as \"--host=x86_64-build_pc-linux-gnu --target=arm-zephyr-eabi\".\n"
-> ~"Type \"show configuration\" for configuration details.\n"
-> ~"For bug reporting instructions, please see:\n"
-> ~"<https://github.com/zephyrproject-rtos/sdk-ng/issues>.\n"
-> ~"Find the GDB manual and other documentation resources online at:\n    <http://www.gnu.org/software/gdb/documentation/>."
-> ~"\n\n"
-> ~"For help, type \"help\".\n"
-> ~"Type \"apropos word\" to search for commands related to \"word\".\n"
-> 1^done
2-gdb-set mi-async on
-> 2^done
3-interpreter-exec console "set print demangle on"
-> 3^done
4-interpreter-exec console "set print asm-demangle on"
-> =cmd-param-changed,param="print asm-demangle",value="on"
-> 4^done
5-enable-pretty-printing
-> 5^done
6-interpreter-exec console "source /home/alban/.vscode-oss/extensions/marus25.cortex-debug-1.12.1-universal/support/gdbsupport.init"
-> 6^done
7-interpreter-exec console "source /home/alban/.vscode-oss/extensions/marus25.cortex-debug-1.12.1-universal/support/gdb-swo.init"
-> =cmd-param-changed,param="language",value="c"
-> =cmd-param-changed,param="language",value="auto"
-> 7^done
8-interpreter-exec console "set output-radix 0xa"
-> ~"Output radix now set to decimal 10, hex a, octal 12.\n"
Output radix now set to decimal 10, hex a, octal 12.
-> 8^done
9-interpreter-exec console "set input-radix 0xa"
-> ~"Input radix now set to decimal 10, hex a, octal 12.\n"
Input radix now set to decimal 10, hex a, octal 12.
-> 9^done
10-file-exec-and-symbols "/home/alban/zephyr_workspace/blinky_f411re_BMP/build/zephyr/zephyr.elf"
-> 10^done
11-target-select extended-remote /dev/ttyBmpGdb
-> 11^connected
12-interpreter-exec console "monitor swdp_scan"
-> @"Target voltage: 3.29V\n"
Target voltage: 3.29V
-> @"Available Targets:\n"
Available Targets:
-> @"No. Att Driver\n"
No. Att Driver
-> @" 1      STM32F411 M4\n"
 1      STM32F411 M4
-> 12^done
13-interpreter-exec console "attach 1"
-> ~"Attaching to program: /home/alban/zephyr_workspace/blinky_f411re_BMP/build/zephyr/zephyr.elf, Remote target\n"
Attaching to program: /home/alban/zephyr_workspace/blinky_f411re_BMP/build/zephyr/zephyr.elf, Remote target
-> =thread-group-started,id="i1",pid="1"
-> =thread-created,id="1",group-id="i1"
-> *running,thread-id="1"
mi2.status = running
-> 13^done
-> ~"__enable_irq () at /home/alban/zephyr_workspace/modules/hal/cmsis/CMSIS/Core/Include/cmsis_gcc.h:951\n"
__enable_irq () at /home/alban/zephyr_workspace/modules/hal/cmsis/CMSIS/Core/Include/cmsis_gcc.h:951
14-interpreter-exec console "set mem inaccessible-by-default off"
-> ~"951\t  __ASM volatile (\"cpsie i\" : : : \"memory\");\n"
951	  __ASM volatile ("cpsie i" : : : "memory");
-> *stopped,frame={addr="0x080048ba",func="__enable_irq",args=[],file="/home/alban/zephyr_workspace/modules/hal/cmsis/CMSIS/Core/Include/cmsis_gcc.h",fullname="/home/alban/zephyr_workspace/modules/hal/cmsis/CMSIS/Core/Include/cmsis_gcc.h",line="951",arch="armv7e-m"},thread-id="1",stopped-threads="all"
mi2.status = stopped
Program stopped, probably due to a reset and/or halt issued by debugger
-> =cmd-param-changed,param="mem inaccessible-by-default",value="off"
-> 14^done
15-target-download
-> 15+download,{section="rom_start",section-size="408",total-size="610782"}
-> 15+download,{section="rom_start",section-sent="408",section-size="408",total-sent="408",total-size="610782"}
-> 15+download,{section="text",section-size="23000",total-size="610782"}
-> 15+download,{section=".ARM.exidx",section-size="8",total-size="610782"}
-> 15+download,{section="initlevel",section-size="152",total-size="610782"}
-> 15+download,{section="device_area",section-size="260",total-size="610782"}
-> 15+download,{section="sw_isr_table",section-size="688",total-size="610782"}
-> 15+download,{section="log_const_area",section-size="64",total-size="610782"}
-> 15+download,{section="log_backend_area",section-size="16",total-size="610782"}
-> 15+download,{section="rodata",section-size="3148",total-size="610782"}
-> 15+download,{section="datas",section-size="88",total-size="610782"}
-> 15+download,{section="device_states",section-size="26",total-size="610782"}
-> 15+download,{section="log_mpsc_pbuf_area",section-size="56",total-size="610782"}
-> 15+download,{section="log_msg_ptr_area",section-size="4",total-size="610782"}
-> 15+download,{section=".last_section",section-size="4",total-size="610782"}
-> 15^done,address="0x08001ae4",load-size="27922",transfer-rate="244656",write-rate="698"
16-interpreter-exec console "SoftwareReset"
-> =cmd-param-changed,param="language",value="c"
-> ~"Warning: the current language does not match this frame.\n"
Warning: the current language does not match this frame.
-> =memory-changed,thread-group="i1",addr="0xe000ed0c",len="0x4"
-> =cmd-param-changed,param="language",value="auto"
-> 16^done
17-interpreter-exec console "monitor rtt enable"   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HERE !
-> 17^done
Returning dummy thread-id to workaround VSCode issue with pause button not working
Info: Received readMemory request while busy. {"memoryReference":"0x40020000","count":40}
Returning dummy stack frame to workaround VSCode issue with pause button not working: {"threadId":1,"startFrame":0,"levels":20}
Failed to update peripheral GPIOA: Error: peripheral-viewer: readMemory failed @ 0x40020000 for 40 bytes: CodeExpectedError: Busy, session=7035b9b4-eb7d-4ee5-a0e6-6acc36ad9774
18-break-insert -t --function main
-> ~"Note: automatically using hardware breakpoints for read-only addresses.\n"
Note: automatically using hardware breakpoints for read-only addresses.
-> 18^done,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x0800047c",func="main",file="/home/alban/zephyr_workspace/blinky_f411re_BMP/src/main.c",fullname="/home/alban/zephyr_workspace/blinky_f411re_BMP/src/main.c",line="29",thread-groups=["i1"],times="0",original-location="-function main"}
19-exec-continue --all
-> 19^running
-> *running,thread-id="all"
mi2.status = running
-> =breakpoint-modified,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x0800047c",func="main",file="/home/alban/zephyr_workspace/blinky_f411re_BMP/src/main.c",fullname="/home/alban/zephyr_workspace/blinky_f411re_BMP/src/main.c",line="29",thread-groups=["i1"],times="1",original-location="-function main"}
-> ~"\n"

-> ~"Temporary breakpoint 1, main () at /home/alban/zephyr_workspace/blinky_f411re_BMP/src/main.c:29\n"
Temporary breakpoint 1, main () at /home/alban/zephyr_workspace/blinky_f411re_BMP/src/main.c:29
-> ~"29\t{\n"
29	{
-> *stopped,reason="breakpoint-hit",disp="del",bkptno="1",frame={addr="0x0800047c",func="main",args=[],file="/home/alban/zephyr_workspace/blinky_f411re_BMP/src/main.c",fullname="/home/alban/zephyr_workspace/blinky_f411re_BMP/src/main.c",line="29",arch="armv7e-m"},thread-id="1",stopped-threads="all"
mi2.status = stopped
-> =breakpoint-deleted,id="1"
20-thread-list-ids
-> 20^done,thread-ids={thread-id="1"},current-thread-id="1",number-of-threads="1"
21-thread-info 1
-> 21^done,threads=[{id="1",target-id="Thread 1",frame={level="0",addr="0x0800047c",func="main",args=[],file="/home/alban/zephyr_workspace/blinky_f411re_BMP/src/main.c",fullname="/home/alban/zephyr_workspace/blinky_f411re_BMP/src/main.c",line="29",arch="armv7e-m"},state="stopped"}]
22-stack-list-frames --thread 1 0 19
-> 22^done,stack=[frame={level="0",addr="0x0800047c",func="main",file="/home/alban/zephyr_workspace/blinky_f411re_BMP/src/main.c",fullname="/home/alban/zephyr_workspace/blinky_f411re_BMP/src/main.c",line="29",arch="armv7e-m"}]
23-data-read-memory-bytes "0x40020000" 40
-> 23^done,memory=[{begin="0x40020000",offset="0x00000000",end="0x40020028",contents="a00000a8000000000000000c100000640cc000000000000000000000000000000077000000000000"}]

RESULT: RTT shows something

1:LED state: OFF
[00:00:00.000,000] <dbg> main: main: 1:LED state: OFF
2:LED state: ON
[00:00:01.000,000] <dbg> main: main: 2:LED state: ON
3:LED state: OFF
[00:00:02.000,000] <dbg> main: main: 3:LED state: OFF
4:LED state: ON
[00:00:03.001,000] <dbg> main: main: 4:LED state: ON
5:LED state: OFF
[00:00:04.001,000] <dbg> main: main: 5:LED state: OFF
6:LED state: ON
[00:00:05.001,000] <dbg> main: main: 6:LED state: ON
7:LED state: OFF
[00:00:06.002,000] <dbg> main: main: 7:LED state: OFF
8:LED state: ON
[00:00:07.002,000] <dbg> main: main: 8:LED state: ON
9:LED state: OFF
[00:00:08.002,000] <dbg> main: main: 9:LED state: OFF
10:LED state: ON
[00:00:09.002,000] <dbg> main: main: 10:LED state: ON
11:LED state: OFF
[00:00:10.003,000] <dbg> main: main: 11:LED state: OFF
12:LED state: ON
[00:00:11.003,000] <dbg> main: main: 12:LED state: ON
13:LED state: OFF
[00:00:12.003,000] <dbg> main: mai*** Booting Zephyr OS build v4.0.0-514-g684324019635 ***
*** Booting Zephyr OS build v4.0.0-514-g684324019635 ***
1:LED state: OFF
[00:00:00.000,000] <dbg> main: main: 1:LED state: OFF
2:LED state: ON
[00:00:01.000,000] <dbg> main: main: 2:LED state: ON
3:LED state: OFF
[00:00:02.000,000] <dbg> main: main: 3:LED state: OFF

TADAAAWWWWW !

feel free to ask if you need more info i'd be happy to help
AM

@haneefdm
Copy link
Collaborator

We don't have BMP hardware. We only enabled what we could test. Questions/comments

  • All you had to do was to use "monitor rtt enable". OpenOCD and JLink require much more setup than that.
  • Where does the output show up? We normally direct RTT output to the TERMINAL tab just like SWO
  • BMP uses serial ports for output so not sure where/what serial port you used. Did you just use something like PuTTY to capture the serial output?
  • How does BMP know where the RTT buffer is? And, what to look for? Searching the entire memory space may not be a good idea.

Usage or RTT implies that BMP implemented what SEGGER does.

prior each test i manually disable the rtt by either doing a cold start, or typing monitor rtt disable in a gdb CLI

What happens if you don't disable it when the debug session ends?

CC: @ssimek Do you know about this? RTT is far more performant than SWO can ever be. Both require manual instrumentation and flow control. Since SEGGER put it in the public domain, more gdb servers are implementing it.

@ssimek
Copy link
Contributor

ssimek commented Jan 16, 2025

@albmef true, rttConfig is currently not handled on BMP but it easily could, I'll look into it.

@haneefdm the simple config is what BMP is about :) And yes, BMP has RTT support, just not in the standard builds for some reason. I have never played with it until now, I just remember looking at it some time ago but I was quite happy with SWO until now. SEGGER's performance claim is marketing BS to a degree, they are comparing filling a memory buffer that will be later read by the debug probe with synchronously waiting on a UART-like device. Running SWO at reasonable speeds (several MHz) removes most of the waiting. They also need a pretty beefy MCU to make the claim that they were outputting 82 characters in a microsecond - an average ~80 MHz one would hardly be able to output more than one character in one CPU clock cycle 🙄

@haneefdm
Copy link
Collaborator

SEGGER's performance claim is marketing BS to a degree, they are comparing filling a memory buffer that will be later read by the debug probe with synchronously waiting on a UART-like device.

Yes, I know and I have tried it in a real application. While it is faster than SWO, definitely not 100x. The 100x is mostly FW performance (cycles) for writing to SRAM vs SWO writing to registers with a tiny FIFO. Not the gdb-server reading the RTT buffer. I was limited by the probe USB performance though. And, our board TX-UART (SWO) is unreliable even at 1 Mbit. It doesn't matter how fast the processor could run. Our IOs were limited to 33 MHz toggle rate as well.

In my application I was not just banging on the buffer in a loop. I had things to sense and calculate and then shove semi-large quantities of bytes into a buffer for the host to see. We also could not afford a pin to dedicate to SWO and using the SWD pins was more convenient.

Looking at https://black-magic.org/usage/rtt.html they do have the other config items for RTT. Most important of those is this

monitor rtt ram startaddress endaddress

There is also a question of timing. Since the RTT control block is initialized in FW sometime after main, looking for it will fail if done at reset. Or you may pickup stale/wrong information from a previous run. Especially if the linker moved the control block.

Btw, some of the new crop of chips may not even have SWO. I was already part of developing one chip with no SWO because it was a multi-core setup and had to go with ARMs recommendation.

@ssimek
Copy link
Contributor

ssimek commented Jan 17, 2025

Yep, I'm definitely intrigued in RTT and will work on adding proper support with the BMP. Regarding the config - I presume they are doing an autoscan if the addresses are not specified, I guess JLink is doing the same from what I understood.

There definitely are cores without SWO, for example M0/M0+, and I completely understand the need for an extra pin can be an issue sometimes. Another thing that comes to mind is the USB-C SBU1/2 connection to SWCLK/SWDIO would be a lot more useful with RTT.

@haneefdm can you assign this ticket to me so it's not lost in the sands of time?

@haneefdm
Copy link
Collaborator

Regarding the config - I presume they are doing an autoscan if the addresses are not specified, I guess JLink is doing the same from what I understood.

Yes, but it takes quite a bit of SWD bandwidth to scan the entire SRAM. One scan may not work. They could also find the wrong control block. With other gdb-servers, we typically know the exact address and we pass that along. It is almost free.

Just assigned this to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants