Skip to content

Error writing data to flash (from target-download) - rp2040 #1985

@0x3333

Description

@0x3333

I'm using a F411CE probe with a rp2040 target in VSCode with Cortex-Debug extension.

When I first try to 'launch' the debugger, I get the error:

Failed to launch GDB: Error writing data to flash (from target-download)

When I try again, it works as expected. I notice that the first run, the board is running, application wise. After the error, the CPU halts. That's why the second attempt works.

When the Program stops, when it works is in frame={addr="0xfffffffe",func="<signal handler called>"}, when it fails is in frame={addr="0x10008e16",func="prvIdleTask"...., which is FreeRTOS.

Am I missing something here?

Here is the Cortex-Debug full debug output with the error(Focus on last 30 lines or so):

0000000002+00002: Cortex-Debug: VSCode debugger extension version 1.12.1 git(652d042). Usage info: https://github.com/Marus/cortex-debug#usage
0000000002+00000: "configuration": {
    "name": "BMP Launch",
    "cwd": "/Users/0x3333/Code/Home/g6",
    "executable": "/Users/0x3333/Code/Home/g6/build/gateway.elf",
    "request": "launch",
    "type": "cortex-debug",
    "servertype": "bmp",
    "interface": "swd",
    "device": "rp2040",
    "numberOfProcessors": 2,
    "BMPGDBSerialPort": "/dev/cu.usbmodem316F333331321",
    "runToEntryPoint": "main",
    "preLaunchCommands": [
        "set mem inaccessible-by-default off"
    ],
    "showDevDebugOutput": "raw",
    "showDevDebugTimestamps": true,
    "__configurationTarget": 6,
    "gdbServerConsolePort": 55878,
    "pvtAvoidPorts": [],
    "chainedConfigurations": {
        "enabled": false
    },
    "debuggerArgs": [],
    "swoConfig": {
        "enabled": false,
        "decoders": [],
        "cpuFrequency": 0,
        "swoFrequency": 0,
        "source": "probe"
    },
    "rttConfig": {
        "enabled": false,
        "decoders": []
    },
    "graphConfig": [],
    "postLaunchCommands": [],
    "preAttachCommands": [],
    "postAttachCommands": [],
    "preRestartCommands": [],
    "postRestartCommands": [],
    "preResetCommands": [],
    "postResetCommands": [],
    "powerOverBMP": "lastState",
    "targetId": 1,
    "toolchainPrefix": "arm-none-eabi",
    "extensionPath": "/Users/0x3333/.vscode/extensions/marus25.cortex-debug-1.12.1",
    "registerUseNaturalFormat": true,
    "variableUseNaturalFormat": true,
    "pvtVersion": "1.12.1",
    "__sessionId": "97be7950-053a-47ac-beb9-6cf92857e148",
    "pvtShowDevDebugOutput": "raw"
}
0000000004+00002: Reading symbols from arm-none-eabi-objdump --syms -C -h -w /Users/0x3333/Code/Home/g6/build/gateway.elf
0000000006+00002: Reading symbols from arm-none-eabi-nm --defined-only -S -l -C -p /Users/0x3333/Code/Home/g6/build/gateway.elf
0000000007+00001: Launching GDB: arm-none-eabi-gdb -q --interpreter=mi2
0000000009+00002: 1-gdb-version
0000000016+00007: Finished reading symbols from objdump: Time: 12 ms
0000000031+00015: Finished reading symbols from nm: Time: 25 ms
0000000206+00175: -> =thread-group-added,id="i1"
0000000206+00000: -> ~"GNU gdb (Arm GNU Toolchain 13.3.Rel1 (Build arm-13.24)) 14.2.90.20240526-git\n"
0000000206+00000: -> ~"Copyright (C) 2023 Free Software Foundation, Inc.\n"
0000000206+00000: -> ~"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."
0000000206+00000: -> ~"\nType \"show copying\" and \"show warranty\" for details.\n"
0000000206+00000: -> ~"This GDB was configured as \"--host=aarch64-apple-darwin20.6.0 --target=arm-none-eabi\".\n"
0000000206+00000: -> ~"Type \"show configuration\" for configuration details.\n"
0000000207+00001: -> ~"For bug reporting instructions, please see:\n"
0000000207+00000: -> ~"<https://bugs.linaro.org/>.\n"
0000000207+00000: -> ~"Find the GDB manual and other documentation resources online at:\n    <"
0000000207+00000: -> ~"http://www.gnu.org/software/gdb/documentation/>.\n\n"
0000000207+00000: -> ~"For help, type \"help\".\n"
0000000207+00000: -> ~"Type \"apropos word\" to search for commands related to \"word\".\n"
0000000207+00000: -> 1^done
0000000207+00000: 2-gdb-set mi-async on
0000000207+00000: -> 2^done
0000000207+00000: 3-interpreter-exec console "set print demangle on"
0000000207+00000: -> 3^done
0000000207+00000: 4-interpreter-exec console "set print asm-demangle on"
0000000207+00000: -> =cmd-param-changed,param="print asm-demangle",value="on"
0000000208+00001: -> 4^done
0000000208+00000: 5-enable-pretty-printing
0000000208+00000: -> 5^done
0000000208+00000: 6-interpreter-exec console "source /Users/0x3333/.vscode/extensions/marus25.cortex-debug-1.12.1/support/gdbsupport.init"
0000000212+00004: -> 6^done
0000000212+00000: 7-interpreter-exec console "source /Users/0x3333/.vscode/extensions/marus25.cortex-debug-1.12.1/support/gdb-swo.init"
0000000214+00002: -> =cmd-param-changed,param="language",value="c"
0000000214+00000: -> =cmd-param-changed,param="language",value="auto"
0000000215+00001: -> 7^done
0000000215+00000: 8-interpreter-exec console "set output-radix 0xa"
0000000216+00001: -> ~"Output radix now set to decimal 10, hex a, octal 12.\n"
0000000216+00000: Output radix now set to decimal 10, hex a, octal 12.
0000000216+00000: -> 8^done
0000000216+00000: 9-interpreter-exec console "set input-radix 0xa"
0000000216+00000: -> ~"Input radix now set to decimal 10, hex a, octal 12.\n"
0000000216+00000: Input radix now set to decimal 10, hex a, octal 12.
0000000216+00000: -> 9^done
0000000216+00000: 10-file-exec-and-symbols "/Users/0x3333/Code/Home/g6/build/gateway.elf"
0000000218+00002: -> 10^done
0000000218+00000: Debug Time: GDB Ready...
0000000218+00000: Debug Time: GDB Server post start events done...
0000000218+00000: Debug Time: objdump and nm done...
0000000218+00000: Debug Time: All pending items done, proceed to gdb connect...
0000000218+00000: 11-target-select extended-remote /dev/cu.usbmodem316F333331321
0000000261+00043: -> 11^connected
0000000261+00000: 12-interpreter-exec console "monitor swdp_scan"
0000000261+00000: -> @"Target voltage: Unknown\n"
0000000261+00000: Target voltage: Unknown
0000000292+00031: -> @"Available Targets:\n"
0000000292+00000: Available Targets:
0000000293+00001: -> @"No. Att Driver\n"
0000000293+00000: No. Att Driver
0000000293+00000: -> @" 1      RP2040 M0+\n"
0000000293+00000:  1      RP2040 M0+
0000000293+00000: -> @" 2      RP2040 M0+\n"
0000000293+00000:  2      RP2040 M0+
0000000293+00000: -> @" 3      RP2040 Rescue (Attach to reset) \n"
0000000293+00000:  3      RP2040 Rescue (Attach to reset)
0000000293+00000: -> 12^done
0000000294+00001: 13-interpreter-exec console "attach 1"
0000000294+00000: -> ~"Attaching to program: /Users/0x3333/Code/Home/g6/build/gateway.elf, Remote target\n"
0000000294+00000: Attaching to program: /Users/0x3333/Code/Home/g6/build/gateway.elf, Remote target
0000000346+00052: -> =thread-group-started,id="i1",pid="1"
0000000346+00000: -> =thread-created,id="1",group-id="i1"
0000000347+00001: -> *running,thread-id="1"
0000000347+00000: mi2.status = running
0000000360+00013: -> 13^done
0000000360+00000: -> ~"prvIdleTask (pvParameters=<optimized out>) at /Users/0x3333/Code/Home/g6/deps/FreeRTOS-Kernel/tasks.c:5785\n"
0000000360+00000: prvIdleTask (pvParameters=<optimized out>) at /Users/0x3333/Code/Home/g6/deps/FreeRTOS-Kernel/tasks.c:5785
0000000360+00000: 14-interpreter-exec console "set mem inaccessible-by-default off"
0000000361+00001: -> ~"5785\t        prvCheckTasksWaitingTermination();\n"
0000000361+00000: 5785	        prvCheckTasksWaitingTermination();
0000000361+00000: -> *stopped,frame={addr="0x10008e16",func="prvIdleTask",args=[{name="pvParameters",value="<optimized out>"}],file="/Users/0x3333/Code/Home/g6/deps/FreeRTOS-Kernel/tasks.c",fullname="/Users/0x3333/Code/Home/g6/deps/FreeRTOS-Kernel/tasks.c",line="5785",arch="armv6s-m"},thread-id="1",stopped-threads="all"
0000000361+00000: mi2.status = stopped
0000000361+00000: Program stopped, probably due to a reset and/or halt issued by debugger
0000000361+00000: -> =cmd-param-changed,param="mem inaccessible-by-default",value="off"
0000000361+00000: -> 14^done
0000000361+00000: 15-interpreter-exec console "set mem inaccessible-by-default off"
0000000361+00000: -> 15^done
0000000361+00000: 16-target-download
0000001059+00698: -> 16+download,{section=".boot2",section-size="256",total-size="1037794"}
0000001059+00000: -> 16+download,{section=".boot2",section-sent="256",section-size="256",total-sent="256",total-size="1037794"}
0000001062+00003: -> 16+download,{section=".text",section-size="44224",total-size="1037794"}
0000001103+00041: -> 16^error,msg="Error writing data to flash"
0000001105+00002: 17-interpreter-exec console "SoftwareReset"
0000001106+00001: Failed to launch GDB: Error writing data to flash (from target-download)

Here is the Cortex-Debug full debug output the second attempt(No errors):

0000000003+00003: Cortex-Debug: VSCode debugger extension version 1.12.1 git(652d042). Usage info: https://github.com/Marus/cortex-debug#usage
0000000003+00000: "configuration": {
    "name": "BMP Launch",
    "cwd": "/Users/0x3333/Code/Home/g6",
    "executable": "/Users/0x3333/Code/Home/g6/build/gateway.elf",
    "request": "launch",
    "type": "cortex-debug",
    "servertype": "bmp",
    "interface": "swd",
    "device": "rp2040",
    "numberOfProcessors": 2,
    "BMPGDBSerialPort": "/dev/cu.usbmodem316F333331321",
    "runToEntryPoint": "main",
    "preLaunchCommands": [
        "set mem inaccessible-by-default off"
    ],
    "showDevDebugOutput": "raw",
    "showDevDebugTimestamps": true,
    "__configurationTarget": 6,
    "gdbServerConsolePort": 55878,
    "pvtAvoidPorts": [],
    "chainedConfigurations": {
        "enabled": false
    },
    "debuggerArgs": [],
    "swoConfig": {
        "enabled": false,
        "decoders": [],
        "cpuFrequency": 0,
        "swoFrequency": 0,
        "source": "probe"
    },
    "rttConfig": {
        "enabled": false,
        "decoders": []
    },
    "graphConfig": [],
    "postLaunchCommands": [],
    "preAttachCommands": [],
    "postAttachCommands": [],
    "preRestartCommands": [],
    "postRestartCommands": [],
    "preResetCommands": [],
    "postResetCommands": [],
    "powerOverBMP": "lastState",
    "targetId": 1,
    "toolchainPrefix": "arm-none-eabi",
    "extensionPath": "/Users/0x3333/.vscode/extensions/marus25.cortex-debug-1.12.1",
    "registerUseNaturalFormat": true,
    "variableUseNaturalFormat": true,
    "pvtVersion": "1.12.1",
    "__sessionId": "6a94b56f-4823-410f-8f62-6e34a7685c5b",
    "pvtShowDevDebugOutput": "raw"
}
0000000005+00002: Reading symbols from arm-none-eabi-objdump --syms -C -h -w /Users/0x3333/Code/Home/g6/build/gateway.elf
0000000007+00002: Reading symbols from arm-none-eabi-nm --defined-only -S -l -C -p /Users/0x3333/Code/Home/g6/build/gateway.elf
0000000008+00001: Launching GDB: arm-none-eabi-gdb -q --interpreter=mi2
0000000010+00002: 1-gdb-version
0000000017+00007: Finished reading symbols from objdump: Time: 12 ms
0000000032+00015: Finished reading symbols from nm: Time: 25 ms
0000000207+00175: -> =thread-group-added,id="i1"
0000000207+00000: -> ~"GNU gdb (Arm GNU Toolchain 13.3.Rel1 (Build arm-13.24)) 14.2.90.20240526-git\n"
0000000207+00000: -> ~"Copyright (C) 2023 Free Software Foundation, Inc.\n"
0000000207+00000: -> ~"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."
0000000207+00000: -> ~"\nType \"show copying\" and \"show warranty\" for details.\n"
0000000207+00000: -> ~"This GDB was configured as \"--host=aarch64-apple-darwin20.6.0 --target=arm-none-eabi\".\n"
0000000207+00000: -> ~"Type \"show configuration\" for configuration details.\n"
0000000207+00000: -> ~"For bug reporting instructions, please see:\n"
0000000207+00000: -> ~"<https://bugs.linaro.org/>.\n"
0000000208+00001: -> ~"Find the GDB manual and other documentation resources online at:\n    <"
0000000208+00000: -> ~"http://www.gnu.org/software/gdb/documentation/>.\n\n"
0000000208+00000: -> ~"For help, type \"help\".\n"
0000000208+00000: -> ~"Type \"apropos word\" to search for commands related to \"word\".\n"
0000000208+00000: -> 1^done
0000000208+00000: 2-gdb-set mi-async on
0000000208+00000: -> 2^done
0000000208+00000: 3-interpreter-exec console "set print demangle on"
0000000208+00000: -> 3^done
0000000208+00000: 4-interpreter-exec console "set print asm-demangle on"
0000000208+00000: -> =cmd-param-changed,param="print asm-demangle",value="on"
0000000208+00000: -> 4^done
0000000208+00000: 5-enable-pretty-printing
0000000209+00001: -> 5^done
0000000209+00000: 6-interpreter-exec console "source /Users/0x3333/.vscode/extensions/marus25.cortex-debug-1.12.1/support/gdbsupport.init"
0000000213+00004: -> 6^done
0000000213+00000: 7-interpreter-exec console "source /Users/0x3333/.vscode/extensions/marus25.cortex-debug-1.12.1/support/gdb-swo.init"
0000000215+00002: -> =cmd-param-changed,param="language",value="c"
0000000215+00000: -> =cmd-param-changed,param="language",value="auto"
0000000216+00001: -> 7^done
0000000216+00000: 8-interpreter-exec console "set output-radix 0xa"
0000000216+00000: -> ~"Output radix now set to decimal 10, hex a, octal 12.\n"
0000000216+00000: Output radix now set to decimal 10, hex a, octal 12.
0000000217+00001: -> 8^done
0000000217+00000: 9-interpreter-exec console "set input-radix 0xa"
0000000217+00000: -> ~"Input radix now set to decimal 10, hex a, octal 12.\n"
0000000217+00000: Input radix now set to decimal 10, hex a, octal 12.
0000000217+00000: -> 9^done
0000000217+00000: 10-file-exec-and-symbols "/Users/0x3333/Code/Home/g6/build/gateway.elf"
0000000219+00002: -> 10^done
0000000219+00000: Debug Time: GDB Ready...
0000000219+00000: Debug Time: GDB Server post start events done...
0000000219+00000: Debug Time: objdump and nm done...
0000000219+00000: Debug Time: All pending items done, proceed to gdb connect...
0000000219+00000: 11-target-select extended-remote /dev/cu.usbmodem316F333331321
0000000261+00042: -> 11^connected
0000000261+00000: 12-interpreter-exec console "monitor swdp_scan"
0000000262+00001: -> @"Target voltage: Unknown\n"
0000000262+00000: Target voltage: Unknown
0000000292+00030: -> @"Available Targets:\n"
0000000293+00001: Available Targets:
0000000293+00000: -> @"No. Att Driver\n"
0000000293+00000: No. Att Driver
0000000293+00000: -> @" 1      RP2040 M0+\n"
0000000293+00000:  1      RP2040 M0+
0000000293+00000: -> @" 2      RP2040 M0+\n"
0000000293+00000:  2      RP2040 M0+
0000000293+00000: -> @" 3      RP2040 Rescue (Attach to reset) \n"
0000000293+00000:  3      RP2040 Rescue (Attach to reset)
0000000294+00001: -> 12^done
0000000294+00000: 13-interpreter-exec console "attach 1"
0000000294+00000: -> ~"Attaching to program: /Users/0x3333/Code/Home/g6/build/gateway.elf, Remote target\n"
0000000294+00000: Attaching to program: /Users/0x3333/Code/Home/g6/build/gateway.elf, Remote target
0000000346+00052: -> =thread-group-started,id="i1",pid="1"
0000000346+00000: -> =thread-created,id="1",group-id="i1"
0000000347+00001: -> *running,thread-id="1"
0000000347+00000: mi2.status = running
0000000355+00008: -> 13^done
0000000355+00000: -> ~"<signal handler called>\n"
0000000355+00000: <signal handler called>
0000000356+00001: -> *stopped,frame={addr="0xfffffffe",func="<signal handler called>"},thread-id="1",stopped-threads="all"
0000000356+00000: mi2.status = stopped
0000000356+00000: Program stopped, probably due to a reset and/or halt issued by debugger
0000000356+00000: 14-interpreter-exec console "set mem inaccessible-by-default off"
0000000356+00000: -> =cmd-param-changed,param="mem inaccessible-by-default",value="off"
0000000356+00000: -> 14^done
0000000356+00000: 15-interpreter-exec console "set mem inaccessible-by-default off"
0000000356+00000: -> 15^done
0000000356+00000: 16-target-download
0000001071+00715: -> 16+download,{section=".boot2",section-size="256",total-size="1037794"}
0000001071+00000: -> 16+download,{section=".boot2",section-sent="256",section-size="256",total-sent="256",total-size="1037794"}
0000001073+00002: -> 16+download,{section=".text",section-size="44224",total-size="1037794"}
0000001475+00402: -> 16+download,{section=".rodata",section-size="11548",total-size="1037794"}
0000001548+00073: -> 16+download,{section=".binary_info",section-size="40",total-size="1037794"}
0000001550+00002: -> 16+download,{section=".data",section-size="3480",total-size="1037794"}
0000001578+00028: -> 16+download,{section=".data",section-sent="1932",section-size="3480",total-sent="58000",total-size="1037794"}
0000001612+00034: -> 16^done,address="0x100001e8",load-size="59548",transfer-rate="381104",write-rate="930"
0000001612+00000: 17-interpreter-exec console "SoftwareReset"
0000001614+00002: -> =cmd-param-changed,param="language",value="c"
0000001615+00001: -> ~"Warning: the current language does not match this frame.\n"
0000001615+00000: Warning: the current language does not match this frame.
0000001616+00001: -> =memory-changed,thread-group="i1",addr="0xe000ed0c",len="0x4"
0000001620+00004: -> =cmd-param-changed,param="language",value="auto"
0000001620+00000: -> 17^done
0000001623+00003: 18-break-insert "/Users/0x3333/Code/Home/g6/src/main.c:48"
0000001627+00004: -> ~"Note: automatically using hardware breakpoints for read-only addresses.\n"
0000001627+00000: Note: automatically using hardware breakpoints for read-only addresses.
0000001628+00001: -> 18^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x1000045a",func="main",file="/Users/0x3333/Code/Home/g6/src/main.c",fullname="/Users/0x3333/Code/Home/g6/src/main.c",line="48",thread-groups=["i1"],times="0",original-location="/Users/0x3333/Code/Home/g6/src/main.c:48"}
0000001762+00134: Returning dummy thread-id to workaround VSCode issue with pause button not working
0000001763+00001: Returning dummy stack frame to workaround VSCode issue with pause button not working: {"threadId":1,"startFrame":0,"levels":20}
0000001864+00101: 19-break-insert -t --function main
0000001865+00001: -> 19^done,bkpt={number="2",type="breakpoint",disp="del",enabled="y",addr="0x10000428",func="main",file="/Users/0x3333/Code/Home/g6/src/main.c",fullname="/Users/0x3333/Code/Home/g6/src/main.c",line="22",thread-groups=["i1"],times="0",original-location="-function main"}
0000001865+00000: 20-exec-continue --all
0000001865+00000: -> 20^running
0000001865+00000: -> *running,thread-id="all"
0000001865+00000: mi2.status = running
0000001873+00008: -> =breakpoint-modified,bkpt={number="2",type="breakpoint",disp="del",enabled="y",addr="0x10000428",func="main",file="/Users/0x3333/Code/Home/g6/src/main.c",fullname="/Users/0x3333/Code/Home/g6/src/main.c",line="22",thread-groups=["i1"],times="1",original-location="-function main"}
0000001874+00001: -> ~"\n"
0000001874+00000:
0000001874+00000: -> ~"Temporary breakpoint 2, main () at /Users/0x3333/Code/Home/g6/src/main.c:22\n"
0000001874+00000: Temporary breakpoint 2, main () at /Users/0x3333/Code/Home/g6/src/main.c:22
0000001875+00001: -> &"warning: Source file is more recent than executable.\n"
0000001875+00000: warning: Source file is more recent than executable.
0000001875+00000: -> ~"22\t{\n"
0000001875+00000: 22	{
0000001875+00000: -> *stopped,reason="breakpoint-hit",disp="del",bkptno="2",frame={addr="0x10000428",func="main",args=[],file="/Users/0x3333/Code/Home/g6/src/main.c",fullname="/Users/0x3333/Code/Home/g6/src/main.c",line="22",arch="armv6s-m"},thread-id="1",stopped-threads="all"
0000001875+00000: mi2.status = stopped
0000001875+00000: -> =breakpoint-deleted,id="2"
0000001876+00001: 21-thread-list-ids
0000001876+00000: -> 21^done,thread-ids={thread-id="1"},current-thread-id="1",number-of-threads="1"
0000001877+00001: 22-thread-info 1
0000001877+00000: -> 22^done,threads=[{id="1",target-id="Thread 1",frame={level="0",addr="0x10000428",func="main",args=[],file="/Users/0x3333/Code/Home/g6/src/main.c",fullname="/Users/0x3333/Code/Home/g6/src/main.c",line="22",arch="armv6s-m"},state="stopped"}]
0000001878+00001: 23-stack-list-frames --thread 1 0 19
0000001878+00000: -> 23^done,stack=[frame={level="0",addr="0x10000428",func="main",file="/Users/0x3333/Code/Home/g6/src/main.c",fullname="/Users/0x3333/Code/Home/g6/src/main.c",line="22",arch="armv6s-m"}]
0000002284+00406: 24-stack-info-frame --thread 1 --frame 0
0000002284+00000: -> 24^done,frame={level="0",addr="0x10000428",func="main",file="/Users/0x3333/Code/Home/g6/src/main.c",fullname="/Users/0x3333/Code/Home/g6/src/main.c",line="22",arch="armv6s-m"}
0000002288+00004: 25-stack-list-variables --thread 1 --frame 0 --simple-values
0000002288+00000: -> 25^done,variables=[{name="wait",type="uint_fast8_t",value="<optimized out>"}]
0000002289+00001: 26-var-create --thread 1 --frame 0 var_wait_4096 @ "wait"
0000002289+00000: -> 26^done,name="var_wait_4096",numchild="0",value="<optimized out>",type="uint_fast8_t",has_more="0"

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugConfirmed bug

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions