[Resolution: the problem seems related to the OpenOCD specific scripts]
Operating System: Windows 7 Enterprise SP1 64bit
Eclipse version: IDE for C/C++ Developers Luna Service Release 2 (4.4.2)
Eclipse Installation Details:
Features: Eclipse CDT 8.6, GNU ARM C/C++ Cross Compiler 1.13, GNU ARM C/C++ OpenOCD Debugging 3.2
Plug-ins: GNU ARM C/C++ Core 2.8, GNU ARM C/C++ Cross Compiler 1.13, GNU ARM C/C++ OpenOCD Debugging 3.2
Build tools folder: \GNU ARM Eclipse\Build Tools\2.4-201503242026\bin
Toolchain folder: /GNU Tools ARM Embedded/4.9 2015q1/bin
Java: jre1.8.0_45
Toolchain: gcc-arm-none-eabi-4_9-2015q1-20150306-win32
OpenOCD: 0.7 (had some issues on the past with later versions and found this working)
Debugger: ST-LINK/V2 ISOL
I am trying to build a basic project, tried with STM32L-Discovery-Blinky project (http://shukra.cedt.iisc.ernet.in/edwiki/EmSys:Getting_Started_with_STM32L-Discovery_Board)
and Hello-World (http://gnuarmeclipse.livius.net/blog/test-project/) and have full breakpoint & code-stepping functionality as well as printf function through semi-hosting.
1) Build Configuration having in the settings the toolchain "Cross ARM GCC" and "GNU Make builder"
a) I run openOCD as external tool with arguments "-f board/stm32ldiscovery.cfg" and execute a "GDB Hardware Debugging" configuration that uses the GDB Command "arm-none-eabi-gdb" connecting to a remote target over "Generic TCP/IP", localhost 3333 using the initialization commands:
monitor reset init
monitor halt
monitor flash probe 0
monitor sleep 500
monitor poll on
RESULT on Hello-World:
Info : accepting 'gdb' connection from 3333
Info : STM32L flash size is 8kb, base address is 0x8000000
Warn : acknowledgment received, but no packet pending
undefined debug reason 6 - target needs reset
Warn : target stm32lx.cpu is not halted
Error: can't add breakpoint: target running
RESULT on Blinky:
Code starts and reaches first break-point. Able to step over but not step into. Nothing happening on printf. If "run" is pressed and there is no breakpoint after that then the code cannot be paused, pausing returns "Program received signal SIGINT, Interrupt.
0x0800019c in ?? ()"
b) Instead I run a "GDB OpenOCD Debugging" configuration that executes the 0.7.0 openocd.exe, 3333, 4444, "-f board/stm32ldiscovery.cfg", executable "${cross_prefix}gdb${cross_suffix}", commands "set mem inaccessible-by-default off", no specific initialization commands
RESULT on Hello-World:
Execution not stopping on breakpoints, no printf either
Info : accepting 'gdb' connection from 3333
Info : STM32L flash size is 8kb, base address is 0x8000000
Warn : acknowledgment received, but no packet pending
undefined debug reason 6 - target needs reset
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080003d8 msp: 0x20004000
STM32L: Enabling HSI
semihosting is enabled
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080003d8 msp: 0x20004000, semihosting
===== arm v7m registers
(0) r0 (/32): 0x00000000
(1) r1 (/32): 0x00000000
(2) r2 (/32): 0x00000000
(3) r3 (/32): 0x00000000
(4) r4 (/32): 0x00000000
(5) r5 (/32): 0x00000000
(6) r6 (/32): 0x00000000
(7) r7 (/32): 0x00000000
(8) r8 (/32): 0x00000000
(9) r9 (/32): 0x00000000
(10) r10 (/32): 0x00000000
(11) r11 (/32): 0x00000000
(12) r12 (/32): 0x00000000
(13) sp (/32): 0x20004000
(14) lr (/32): 0xFFFFFFFF
(15) pc (/32): 0x080003D8
(16) xPSR (/32): 0x01000000
(17) msp (/32): 0x20004000
(18) psp (/32): 0x00000000
(19) primask (/1): 0x00
(20) basepri (/8): 0x00
(21) faultmask (/1): 0x00
(22) control (/2): 0x00
===== cortex-m3 dwt registers
(23) dwt_ctrl (/32)
(24) dwt_cyccnt (/32)
(25) dwt_0_comp (/32)
(26) dwt_0_mask (/4)
(27) dwt_0_function (/32)
(28) dwt_1_comp (/32)
(29) dwt_1_mask (/4)
(30) dwt_1_function (/32)
(31) dwt_2_comp (/32)
(32) dwt_2_mask (/4)
(33) dwt_2_function (/32)
(34) dwt_3_comp (/32)
(35) dwt_3_mask (/4)
(36) dwt_3_function (/32)
2) Build Configuration having in the settings the toolchain "Cross GCC" and "GNU Make builder". The C/C++ build -> Settings -> Cross Settings -> Path is set to "C:\Program Files (x86)\GNU Tools ARM Embedded\4.9 2015q1\arm-none-eabi\bin" but I see on the building console codesourcery used:
Target: arm-none-eabi
Configured with: /scratch/julian/2010q1-release-eabi-lite/src/gcc-4.4-2010q1/configure --build=i686-pc-linux-gnu --host=i686-mingw32 --target=arm-none-eabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --enable-extra-sgxxlite-multilibs --with-gnu-as --with-gnu-ld --with-specs='%{O2:%{!fno-remove-local-statics: -fremove-local-statics}} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}' --enable-languages=c,c++ --disable-shared --disable-lto --with-newlib --with-pkgversion='Sourcery G++ Lite 2010q1-188' --with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-headers=yes --with-sysroot=/opt/codesourcery/arm-none-eabi --with-build-sysroot=/scratch/julian/2010q1-release-eabi-lite/install/host-i686-mingw32/arm-none-eabi --with-libiconv-prefix=/scratch/julian/2010q1-release-eabi-lite/obj/host-libs-2010q1-188-arm-none-eabi-i686-mingw32/usr --with-gmp=/scratch/julian/2010q1-release-eabi-lite/obj/host-libs-2010q1-188-arm-none-eabi-i686-mingw32/usr --with-mpfr=/scratch/julian/2010q1-release-eabi-lite/obj/host-libs-2010q1-188-arm-none-eabi-i686-mingw32/usr --with-ppl=/scratch/julian/2010q1-release-eabi-lite/obj/host-libs-2010q1-188-arm-none-eabi-i686-mingw32/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-cloog=/scratch/julian/2010q1-release-eabi-lite/obj/host-libs-2010q1-188-arm-none-eabi-i686-mingw32/usr --disable-libgomp --enable-poison-system-directories --with-build-time-tools=/scratch/julian/2010q1-release-eabi-lite/obj/tools-i686-pc-linux-gnu-2010q1-188-arm-none-eabi-i686-mingw32/arm-none-eabi/bin --with-build-time-tools=/scratch/julian/2010q1-release-eabi-lite/obj/tools-i686-pc-linux-gnu-2010q1-188-arm-none-eabi-i686-mingw32/arm-none-eabi/bin
Thread model: single
gcc version 4.4.1 (Sourcery G++ Lite 2010q1-188)
COMPILER_PATH=c:/program files (x86)/codesourcery/sourcery g++ lite/bin/../libexec/gcc/arm-none-eabi/4.4.1/;c:/program files (x86)/codesourcery/sourcery g++ lite/bin/../libexec/gcc/;c:/program files (x86)/codesourcery/sourcery g++ lite/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/bin/
RESULT on Blinky:
I run the 1a configuration and I am able to step over, step into, start and pause the code, use break-points but not printf (I don't know if this Toolchain provides some NewLib printf function or I have to include explicitly some implementation).
Any hint or working project to verify that my debugger and setup can support semihosting is welcome. I attach the project file for anyone that wants to inspect the build settings
Thanks
the project created by the wizard has functional semihosting, as long as you use the latest debuggers (J-Link or OpenOCD). QEMU semihosting is also functional for the test project (although it is still experimental).
I cannot comment on your STM32L-Discovery-Blinky project and I would strongly discourage the use of OpenOCD older than 0.9.
Ok, let's try this. I want to figure out if I have wrong settings or there is a real incompatibility in my setup and debugger (I only have the ST-Link/V2 Isol now available and the target is a STM32L151).
1) New test project, following exactly the screens of http://gnuarmeclipse.livius.net/blog/test-project/
2) Build successful.
3) I remove openOCD 0.7.0 from my windows env path and install the version 0.9.0 for 64bit, without adding it to any path, all steps default.
4) The guide on http://gnuarmeclipse.livius.net/blog/openocd-debugging/.
5) Running the debug doesn't stop on the break points, produces a 0x80008ce tab with 'No source available for "0x80008ce"' and the openOCD console reports:
Trying to pause the program does not stop in a specific line and gives output on the debugging console:
I don't have a STM32L151 board, but with Nucleo STM32L152 the behaviour is similar to the one presented, i.e. the breakpoint in main() is not effective.
the same .exe, on the same board, but with J-Link, works flowlesly.
I would first suspect a problem with the OpenOCD scripts.
Thanks for checking this.
Another hint: Disabling on the Startup tab of the debug Configuration the 'initial reset', 'Pre-run..', 'Set breakpoint at main' and giving explicitly the initialization commands:
makes it possible to put breakpoints on startup.c and actually step over its lines from the very beginning of the execution until _exit (code);
Would you think there is a workaround or do I have to replace either OpenOCD or Cross Arm Gcc with something else that can give semihosting for STM32L?
I don't know, the scripts are public, you can try to understand what's going on there, but you're on your own, I can't help you.
J-Link is always the preferred debugger, if you are searching for a professional solution, go for it.
I verify that J-Link is fully working also with STM32L151.
I am not currently working on fixing the openocd scripts, so feel free to close the ticket or suspend it. Thanks.
Diff: