Spark Logic

Debugging Arduino sketch with STM32 Nucleo in Eclipse .. works !

michael_l Sat Aug 29, 2015 7:17 pm

I have followed this site http://gnuarmeclipse.livius.net/blog/install/ to install GNU arm toolchain, build tools, etc. Compiling works okay, binary is created. I’m using toolchain: gcc-arm-none-eabi-4_9-2015q2-20150609-win32
Debugging does not work. I am quite new to STM32, OpenOCD etc so I might do something wrong.

Based on this log I’m asking what could be wrong ? LD1 flashes red/green and nothing happens after this. It seems to be sort of stuck.

GNU ARM Eclipse 32-bits Open On-Chip Debugger 0.9.0-00073-gdd34716-dirty (2015-05-19-09:56)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Started by GNU ARM Eclipse
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Info : STLINK v2 JTAG v24 API v2 SWIM v11 VID 0x0483 PID 0x374B
Info : using stlink api v2
Info : Target voltage: 3.243243
Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : accepting 'gdb' connection on tcp/3333
Info : device id = 0x20036410
Warn : STM32 flash size failed, probe inaccurate - assuming 128k flash
Info : flash size = 128kbytes
undefined debug reason 7 - target needs reset
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
semihosting is enabled
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc, semihosting
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000003a msp: 0xfffffffc, semihosting
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 00000000 pc: 0x20000000 msp: 0x08000028, semihosting
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 00000000 pc: 0x20000000 msp: 0x08000028, semihosting
===== arm v7m registers
(0) r0 (/32): 0x00000020
(1) r1 (/32): 0x00000000
(2) r2 (/32): 0x2000003C
(3) r3 (/32): 0x2000083C
(4) r4 (/32): 0x08000028
(5) r5 (/32): 0x2000006C
(6) r6 (/32): 0x00000020
(7) r7 (/32): 0x00000014
(8) r8 (/32): 0x00000000
(9) r9 (/32): 0x00000000
(10) r10 (/32): 0x00000000
(11) r11 (/32): 0x00000000
(12) r12 (/32): 0x00000000
(13) sp (/32): 0x08000028
(14) lr (/32): 0xFFFFFFFF
(15) pc (/32): 0x20000000
(16) xPSR (/32): 0x00000000
(17) msp (/32): 0x08000028
(18) psp (/32): 0x00000000
(19) primask (/1): 0x00
(20) basepri (/8): 0x00
(21) faultmask (/1): 0x00
(22) control (/2): 0x00
===== Cortex-M 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)

Replies

robca Tue Dec 22, 2015 11:25 pm

Yes, I tried… but I’m getting a lot of compile errors, and it’s really clunkier than the modified IDE and a worse workflow. So I decided to ask (why make an effort when you can ask instead :)) and see if I can find the modified IDE. I hope someone downloaded a copy and is open to share

BTW: Michael’s writeup is really good, I would suggest adding it to the SMT32duino wiki. I read all the wiki, and kept wondering how I could debug. Sure, people can find it by searching the forum, but if proven to work, Michael’s writeup deserves to be in the wiki, imho

stevech Wed Dec 23, 2015 12:38 am

robca wrote:Windows x64…. everything works when used normally, I simply need the modified Arduino IDE at this point, to create the right .elf file

robca Wed Dec 23, 2015 2:33 pm

stevech wrote:robca wrote:Windows x64…. everything works when used normally, I simply need the modified Arduino IDE at this point, to create the right .elf file

stevech Wed Dec 23, 2015 7:26 pm

robca wrote:stevech wrote:robca wrote:Windows x64…. everything works when used normally, I simply need the modified Arduino IDE at this point, to create the right .elf file

robca Wed Dec 23, 2015 11:50 pm

Atollic seems promising, and even the free edition seems to support SWD. I’ll give it a try tomorrow, thanks for the pointer

Meanwhile, if anyone can find the modified IDE, please post a note here :)

zmemw16 Thu Dec 24, 2015 12:26 am

the odd site and books i’ve looked in say to export from as truestudio from CubeMX if arm-gcc compiler is to be used.
some other actions are also needed, such as to how the files or libraries are copied or not.
srp

robca Fri Dec 25, 2015 2:38 pm

To close the loop: I figured out how to use the rick of having an empty *.INO and use a *.CPP of the same name to hold the code. I kept getting a meaningless error “multiple definition” for every function. The trick is to:

create an empty *.ino with only an include to a *.h with the same name and a 2 added to the end (i.e. foo.ino, foo2.h, foo2.cpp). In that *.h file you need to “declare” the function that you will call from the *.ino

i.e. the foo.ino file will have:

#include “<full path>foo2.h”
void setup() {
// put your setup code here, to run once:
}

void loop() {
// put your main code here, to run repeatedly:
foomain();
}

foo2.h will have

void foomain(void); (or whatever parameters the function uses)

and foo2.cpp will contain your foomain() function plus anything else you need

At this point Michael’s instructions will allow you to use Eclipse+OpenOCD+STLink to debug your code in the device. I’m still struggling to wrap my head around Eclipse’s quirks and its debugger interface

zmemw16 Fri Dec 25, 2015 3:40 pm

out of curiosity i tried these files 1.6.5r5 andarduino_stm32 from 111215
so i created the files foo.ino, foo2.h & foo2.cpp as in attachment
well it compiles and didn’t stop after error was printed
this is for a maple mini
haven’t tried running it either:D

racemaniac Sun Feb 21, 2016 8:42 pm

stevech wrote:robca wrote:Windows x64…. everything works when used normally, I simply need the modified Arduino IDE at this point, to create the right .elf file

RogerClark Sun Feb 21, 2016 9:13 pm

You’d need to speak to the Visual Mirco guys about this.

I know they have general support for ArduinoSTM32 but I have not investigated the debugging side of things

(Note. Visual Micro registered as a user on this forum, so you could PM them)

stevech Mon Feb 22, 2016 5:07 am

Tim, Mr. Visual Mico, is very good about responding.
He put extra effort into getting Teensy ARM M4 (Freescale) working as Arduino folks kept dorking with the boards.txt strategy.

I prefer to use ST’s CubeMX and HAL. Preference. Much broader support base in the HAL than Arduino-esque.
But I know many people are comfortable with Arduino concept.

racemaniac Mon Feb 22, 2016 7:42 am

RogerClark wrote:You’d need to speak to the Visual Mirco guys about this.

I know they have general support for ArduinoSTM32 but I have not investigated the debugging side of things

(Note. Visual Micro registered as a user on this forum, so you could PM them)

racemaniac Mon Feb 22, 2016 6:12 pm

racemaniac wrote:RogerClark wrote:You’d need to speak to the Visual Mirco guys about this.

I know they have general support for ArduinoSTM32 but I have not investigated the debugging side of things

(Note. Visual Micro registered as a user on this forum, so you could PM them)

stevech Tue Feb 23, 2016 2:50 am

upload and debugging (per thread title)?

debugging = SWD or JTAG.

racemaniac Tue Feb 23, 2016 7:28 am

stevech wrote:upload and debugging (per thread title)?

debugging = SWD or JTAG.

stevech Tue Feb 23, 2016 7:59 pm

racemaniac wrote:stevech wrote:upload and debugging (per thread title)?

debugging = SWD or JTAG.

michael_l Fri Jul 15, 2016 8:26 pm

After a long pause decided to try Arduino IDE 1.6.9 and latest Arduino_STM32 .zip package. It looks like Arduino IDE produces .elf binary with correct paths! So I just compiled a OLED sample project and started a debug session with Eclipse. I am using blue pill with St-Link V2 dongle. It worked just fine and I could even add ‘global’ expressions in Eclipse IDE. Just wanted to tell this if someone is trying so there’s no need to use modified Arduino IDE

RogerClark Fri Jul 15, 2016 9:43 pm

Which OS are you using ?

michael_l Sat Jul 16, 2016 7:33 am

RogerClark wrote:Which OS are you using ?

Sign in to reply