Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Can't get breakpoints working correctly on an STM32 with ST-Link #782

Open
@alexwhittemore

Description

@alexwhittemore

I'm trying to get single stepping up and running on either my macOS machine, or a Ubuntu VM. We'll focus on the Ubuntu VM for now. I've got https://github.com/stm32duino/Arduino_Core_STM32 installed and I'm targeting an STM32F103 Blue Pill. With the following launch.json, I can load code to the flash, but any breakpoints I set get completely ignored and the pause button doesn't pause execution. I'm sure there's something wrong with my GDB commands or order, but don't know enough to fix it - hopefully it's an easy error:

{
    "version": "0.2.0",
    "configurations": [
    
        {
            "name": "Arduino",
            "type": "arduino",
            "request": "launch",
            "program": "${file}",
            "cwd": "${workspaceRoot}",
            "MIMode": "gdb",
            "targetArchitecture": "arm",
            "miDebuggerPath": "/usr/bin/gdb-multiarch",
            "debugServerPath": "/usr/bin/openocd",
            "debugServerArgs": "-f interface/stlink-v2.cfg -f target/stm32f1x.cfg",
            "customLaunchSetupCommands": [
                {
                    "text": "set architecture arm"
                },
                {
                    "text": "target remote localhost:3333"
                },
                {
                    "text": "file ${file}"
                },
                {
                    "text": "load"
                },
                {
                    "text": "monitor reset halt"
                },
                {
                    "text": "monitor reset init"
                }
            ],
            "stopAtEntry": true,
            "serverStarted": "Info\\ :\\ [\\w\\d\\.]*:\\ hardware",
            "launchCompleteCommand": "exec-continue",
            "filterStderr": true,
            "args": [],
            "logging": { "engineLogging": true }
        }
    ]
}

Here's the logging output for the GDB terminal window:

1: (115) LaunchOptions<LocalLaunchOptions xmlns='http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014'
1: (124) LaunchOptions  ExePath='/home/alexw/Arduino/Projects/Blink/.build/GenF1/Blink.ino.elf'
1: (124) LaunchOptions  WorkingDirectory='/home/alexw/Arduino/Projects/Blink'
1: (125) LaunchOptions  TargetArchitecture='arm'
1: (125) LaunchOptions  ExeArguments=''
1: (125) LaunchOptions  MIMode='gdb'
1: (125) LaunchOptions  MIDebuggerPath='/usr/bin/gdb-multiarch'
1: (125) LaunchOptions  WaitDynamicLibLoad='false'
1: (125) LaunchOptions  DebugServer='/usr/bin/openocd'
1: (125) LaunchOptions  DebugServerArgs='-f interface/stlink-v2.cfg -f target/stm32f1x.cfg'
1: (125) LaunchOptions  ServerStarted='Info\ :\ [\w\d\.]*:\ hardware'
1: (125) LaunchOptions  FilterStderr='true'
1: (126) LaunchOptions>
1: (126) LaunchOptions    <CustomLaunchSetupCommands>
1: (126) LaunchOptions        <Command IgnoreFailures='false' Description=''>set architecture arm</Command>
1: (126) LaunchOptions        <Command IgnoreFailures='false' Description=''>target remote localhost:3333</Command>
1: (126) LaunchOptions        <Command IgnoreFailures='false' Description=''>file /home/alexw/Arduino/Projects/Blink/.build/GenF1/Blink.ino.elf</Command>
1: (126) LaunchOptions        <Command IgnoreFailures='false' Description=''>load</Command>
1: (126) LaunchOptions        <Command IgnoreFailures='false' Description=''>monitor reset halt</Command>
1: (126) LaunchOptions        <Command IgnoreFailures='false' Description=''>monitor reset init</Command>
1: (126) LaunchOptions    </CustomLaunchSetupCommands>
1: (126) LaunchOptions    <LaunchCompleteCommand>exec-continue</LaunchCompleteCommand>
1: (126) LaunchOptions</LocalLaunchOptions>
1: (211) Starting: "/usr/bin/openocd" -f interface/stlink-v2.cfg -f target/stm32f1x.cfg
1: (490) Starting: "/usr/bin/gdb-multiarch" --interpreter=mi
1: (492) DebuggerPid=24867
1: (556) ->=thread-group-added,id="i1"
1: (557) ->~"GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git\n"
1: (557) ->~"Copyright (C) 2018 Free Software Foundation, Inc.\n"
1: (560) ->~"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.  Type \"show copying\"\nand \"show warranty\" for details.\n"
1: (560) ->~"This GDB was configured as \"x86_64-linux-gnu\".\nType \"show configuration\" for configuration details."
1: (560) ->~"\nFor bug reporting instructions, please see:\n"
1: (560) ->~"<http://www.gnu.org/software/gdb/bugs/>.\n"
1: (560) ->~"Find the GDB manual and other documentation resources online at:\n<http://www.gnu.org/software/gdb/documentation/>.\n"
1: (560) ->~"For help, type \"help\".\n"
1: (560) ->~"Type \"apropos word\" to search for commands related to \"word\".\n"
1: (561) ->(gdb)
1: (564) <-1001-gdb-set target-async on
1: (564) ->1001^done
1: (564) ->(gdb)
1: (566) 1001: elapsed time 3
1: (574) <-1002-interpreter-exec console "set pagination off"
1: (575) ->=cmd-param-changed,param="pagination",value="off"
1: (575) ->1002^done
1: (576) ->(gdb)
1: (576) 1002: elapsed time 1
1: (576) <-1003-gdb-set auto-solib-add on
1: (576) ->1003^done
1: (576) ->(gdb)
1: (577) 1003: elapsed time 0
1: (577) <-1004-gdb-set solib-search-path /home/alexw/Arduino/Projects/Blink/.build/GenF1:
1: (577) ->1004^done
1: (577) ->(gdb)
1: (578) 1004: elapsed time 0
1: (579) <-1005-interpreter-exec console "set architecture arm"
1: (580) ->~"The target architecture is assumed to be arm\n"
1: (580) ->=cmd-param-changed,param="architecture",value="arm"
1: (580) ->1005^done
1: (580) ->(gdb)
1: (581) 1005: elapsed time 1
1: (582) <-1006-interpreter-exec console "target remote localhost:3333"
1: (582) ->~"Remote debugging using localhost:3333\n"
1: (616) ->=thread-group-started,id="i1",pid="42000"
1: (616) ->&"warning: No executable has been specified and target does not support\ndetermining executable automatically.  Try using the \"file\" command."
1: (616) ->&"\n"
1: (616) ->=thread-created,id="1",group-id="i1"
1: (768) ->~"0x00000000 in ?? ()\n"
1: (768) ->*stopped,frame={addr="0x00000000",func="??",args=[]},thread-id="1",stopped-threads="all"
1: (776) ->1006^done
1: (776) ->(gdb)
1: (776) 1006: elapsed time 194
1: (777) <-1007-thread-info 1
1: (777) ->1007^done,threads=[{id="1",target-id="Remote target",frame={level="0",addr="0x00000000",func="??",args=[]},state="stopped"}]
1: (778) ->(gdb)
1: (779) 1007: elapsed time 1
1: (779) <-1008-interpreter-exec console "file /home/alexw/Arduino/Projects/Blink/.build/GenF1/Blink.ino.elf"
1: (781) ->~"A program is being debugged already.\nAre you sure you want to change the file? "
1: (781) ->~"(y or n) [answered Y; input not from terminal]\n"
1: (781) ->~"Reading symbols from /home/alexw/Arduino/Projects/Blink/.build/GenF1/Blink.ino.elf..."
1: (781) ->~"(no debugging symbols found)...done.\n"
1: (782) ->1008^done
1: (782) ->(gdb)
1: (787) 1008: elapsed time 8
1: (787) <-1009-interpreter-exec console "load"
1: (1591) ->~"Loading section .isr_vector, size 0x10c lma 0x8000000\n"
1: (1594) ->1009+download,{section=".isr_vector",section-size="268",total-size="13992"}
1: (1594) ->1009+download,{section=".isr_vector",section-sent="268",section-size="268",total-sent="268",total-size="13992"}
1: (1594) ->~"Loading section .text, size 0x27c8 lma 0x800010c\n"
1: (1594) ->1009+download,{section=".text",section-size="10184",total-size="13992"}
1: (1595) ->~"Loading section .rodata, size 0x314 lma 0x80028d4\n"
1: (1595) ->1009+download,{section=".rodata",section-size="788",total-size="13992"}
1: (1595) ->~"Loading section .init_array, size 0x10 lma 0x8002be8\n"
1: (1595) ->1009+download,{section=".init_array",section-size="16",total-size="13992"}
1: (1595) ->~"Loading section .fini_array, size 0x4 lma 0x8002bf8\n"
1: (1595) ->1009+download,{section=".fini_array",section-size="4",total-size="13992"}
1: (1595) ->~"Loading section .data, size 0x24 lma 0x8002bfc\n"
1: (1595) ->1009+download,{section=".data",section-size="36",total-size="13992"}
1: (2577) ->~"Start address 0x8002388, load size 11296\n"
1: (2578) ->~"Transfer rate: 6 KB/sec, 1882 bytes/write.\n"
1: (2578) ->1009^done
1: (2578) ->(gdb)
1: (2579) 1009: elapsed time 1791
1: (2579) <-1010-interpreter-exec console "monitor reset halt"
1: (2740) ->@"target halted due to debug-request, current mode: Thread \n"
1: (2740) ->@"xPSR: 0x01000000 pc: 0x08002388 msp: 0x20005000\n"
1: (2748) ->1010^done
1: (2748) ->(gdb)
1: (2749) 1010: elapsed time 169
1: (2749) <-1011-interpreter-exec console "monitor reset init"
1: (2907) ->@"target halted due to debug-request, current mode: Thread \n"
1: (2907) ->@"xPSR: 0x01000000 pc: 0x08002388 msp: 0x20005000\n"
1: (2920) ->1011^done
1: (2921) ->(gdb)
1: (2921) 1011: elapsed time 172
1: (2983) <-1012-break-insert -f Blink.ino:36
1: (2984) ->&"No symbol table is loaded.  Use the \"file\" command.\n"
1: (3143) ->1012^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="<PENDING>",pending="Blink.ino:36",times="0",original-location="Blink.ino:36"}
1: (3143) ->(gdb)
1: (3144) 1012: elapsed time 160
openocd: Open On-Chip Debugger 0.10.0
openocd: Licensed under GNU GPL v2
openocd: For bug reports, read
openocd: 	http://openocd.org/doc/doxygen/bugs.html
openocd: Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
openocd: Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
openocd: adapter speed: 1000 kHz
openocd: adapter_nsrst_delay: 100
openocd: none separate
openocd: Info : Unable to match requested speed 1000 kHz, using 950 kHz
openocd: Info : Unable to match requested speed 1000 kHz, using 950 kHz
openocd: Info : clock speed 950 kHz
openocd: Info : STLINK v2 JTAG v17 API v2 SWIM v4 VID 0x0483 PID 0x3748
openocd: Info : using stlink api v2
openocd: Info : Target voltage: 3.250331
openocd: Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
=thread-group-added,id="i1"
GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
=cmd-param-changed,param="pagination",value="off"
openocd: Info : accepting 'gdb' connection on tcp/3333
openocd: Info : device id = 0x20036410
openocd: Info : flash size = 64kbytes
openocd: undefined debug reason 7 - target needs reset
openocd: target halted due to debug-request, current mode: Thread 
openocd: xPSR: 0x01000000 pc: 0x08002388 msp: 0x20005000
openocd: target halted due to breakpoint, current mode: Thread 
openocd: xPSR: 0x61000000 pc: 0x2000003a msp: 0x20005000
openocd: target halted due to debug-request, current mode: Thread 
openocd: xPSR: 0x01000000 pc: 0x08002388 msp: 0x20005000
openocd: target halted due to debug-request, current mode: Thread 
openocd: xPSR: 0x01000000 pc: 0x08002388 msp: 0x20005000
openocd: target halted due to debug-request, current mode: Thread 
openocd: xPSR: 0x01000000 pc: 0x08002388 msp: 0x20005000
1: (3194) <-1013-thread-info
1: (3195) ->1013^done,threads=[{id="1",target-id="Remote target",frame={level="0",addr="0x08002388",func="Reset_Handler",args=[]},state="stopped"}],current-thread-id="1"
1: (3195) ->(gdb)
1: (3197) 1013: elapsed time 2
1: (3206) <-1014-stack-list-frames 0 1000
1: (3207) ->1014^done,stack=[frame={level="0",addr="0x08002388",func="Reset_Handler"}]
1: (3207) ->(gdb)
1: (3209) 1014: elapsed time 2
1: (3217) <--exec-continue
1: (3217) ->^running
1: (3217) ->*running,thread-id="all"
1: (3217) ->(gdb)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions