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)


michael_l
Sat Aug 29, 2015 9:01 pm
There seems to be some problem with the build itself. I flashed the outputted file with STM32 ST-Link utility and it does not seem to work. I’m using Blink example. So that needs to be fixed first.

michael_l
Sun Aug 30, 2015 9:04 am
Using OpenOCD 0.9.0 and flashing an image from Arduino STM32 build I was able to flash it to my nucleo board. And it works too! I would like to say thanks for all the guys who have worked to get Arduino IDE working with STM32. This means building in Eclipse does something wrong and the image does not work. To be honest this was a bit of a disappointment for me I was expecting it to work. In Eclipse have used correct Template (STM32F10x) but obviously something goes wrong in the building. On the other hand it might be possible to manually start debugging session: First build flash image (debug) in Arduino IDE and then use Eclipse as IDE. It does sound clumsy. I am looking for solution to get proper image build in Eclipse.

I have connected SB16 and SB50. So I’m thinking does Eclipse GNU ARM plugin not expect that. Maybe there is some build flag involved that needs to be changed. The build uses flag: -DHSE_VALUE=8000000 . I wonder if that is correct?

Here’s log from telnet connection to OpenOCD.

First start OpenOCD:

C:\Program Files (x86)\GNU ARM Eclipse\OpenOCD\0.9.0-201505190955\bin>openocd.exe -f ..\scripts\board\st_nucleo_f103rb.cfg


michael_l
Sun Aug 30, 2015 9:18 am
Here’s objdump from Arduino:

C:\Users\mika\AppData\Local\Temp\build263234916124862537.tmp\sketch_aug29a.cpp.elf: file format elf32-littlearm
C:\Users\mika\AppData\Local\Temp\build263234916124862537.tmp\sketch_aug29a.cpp.elf
architecture: arm, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x080001d5

Program Header:
0x70000001 off 0x00009408 vaddr 0x08001408 paddr 0x08001408 align 2**2
filesz 0x00000008 memsz 0x00000008 flags r--
LOAD off 0x00008000 vaddr 0x08000000 paddr 0x08000000 align 2**15
filesz 0x00001404 memsz 0x00001408 flags rwx
LOAD off 0x00009408 vaddr 0x08001408 paddr 0x08001408 align 2**15
filesz 0x00000008 memsz 0x00000008 flags r--
LOAD off 0x00010000 vaddr 0x20000000 paddr 0x08001410 align 2**15
filesz 0x00000910 memsz 0x00000910 flags rw-
LOAD off 0x00011d20 vaddr 0x08001d20 paddr 0x08001d20 align 2**15
filesz 0x000000f4 memsz 0x000000f4 flags r--
LOAD off 0x00018910 vaddr 0x20000910 paddr 0x20000910 align 2**15
filesz 0x00000000 memsz 0x00000098 flags rw-
private flags = 5000002: [Version5 EABI] [has entry point]

Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00001404 08000000 08000000 00008000 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .text.align 00000004 08001404 08001404 00009404 2**0
ALLOC, CODE
2 .ARM.exidx 00000008 08001408 08001408 00009408 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .data 00000910 20000000 08001410 00010000 2**3
CONTENTS, ALLOC, LOAD, DATA
4 .rodata 000000f4 08001d20 08001d20 00011d20 2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .bss 00000098 20000910 20000910 00018910 2**2
ALLOC
6 .debug_aranges 00000778 00000000 00000000 00011e18 2**3
CONTENTS, READONLY, DEBUGGING
7 .debug_info 00010602 00000000 00000000 00012590 2**0
CONTENTS, READONLY, DEBUGGING
8 .debug_abbrev 00003619 00000000 00000000 00022b92 2**0
CONTENTS, READONLY, DEBUGGING
9 .debug_line 00005708 00000000 00000000 000261ab 2**0
CONTENTS, READONLY, DEBUGGING
10 .debug_frame 0000114c 00000000 00000000 0002b8b4 2**2
CONTENTS, READONLY, DEBUGGING
11 .debug_str 00004306 00000000 00000000 0002ca00 2**0
CONTENTS, READONLY, DEBUGGING
12 .debug_loc 00003a56 00000000 00000000 00030d06 2**0
CONTENTS, READONLY, DEBUGGING
13 .ARM.attributes 00000029 00000000 00000000 0003475c 2**0
CONTENTS, READONLY
14 .debug_ranges 00000a28 00000000 00000000 00034785 2**0
CONTENTS, READONLY, DEBUGGING
15 .comment 00000070 00000000 00000000 000351ad 2**0
CONTENTS, READONLY
SYMBOL TABLE:
08000000 l d .text 00000000 .text
08001404 l d .text.align 00000000 .text.align
08001408 l d .ARM.exidx 00000000 .ARM.exidx
20000000 l d .data 00000000 .data
08001d20 l d .rodata 00000000 .rodata
20000910 l d .bss 00000000 .bss
00000000 l d .debug_aranges 00000000 .debug_aranges
00000000 l d .debug_info 00000000 .debug_info
00000000 l d .debug_abbrev 00000000 .debug_abbrev
00000000 l d .debug_line 00000000 .debug_line
00000000 l d .debug_frame 00000000 .debug_frame
00000000 l d .debug_str 00000000 .debug_str
00000000 l d .debug_loc 00000000 .debug_loc
00000000 l d .ARM.attributes 00000000 .ARM.attributes
00000000 l d .debug_ranges 00000000 .debug_ranges
00000000 l d .comment 00000000 .comment
00000000 l df *ABS* 00000000 crtstuff.c
080013d8 l O .text 00000000 __EH_FRAME_BEGIN__
080000ec l F .text 00000000 __do_global_dtors_aux
20000910 l .bss 00000000 completed.7857
08001400 l O .text 00000000 __do_global_dtors_aux_fini_array_entry
08000110 l F .text 00000000 frame_dummy
20000914 l .bss 00000000 object.7862
080013e8 l O .text 00000000 __frame_dummy_init_array_entry
00000000 l df *ABS* 00000000 sketch_aug29a.cpp
00000000 l df *ABS* 00000000 C:\Users\mika\AppData\Local\Temp\build263234916124862537.tmp\start.S.o
00000000 l df *ABS* 00000000 start_c.c
00000000 l df *ABS* 00000000 syscalls.c
00000000 l df *ABS* 00000000 board.cpp
0800027c l F .text 000001b0 _GLOBAL__sub_I__Z9boardInitv
00000000 l df *ABS* 00000000 boards.cpp
0800042c l F .text 0000001c _ZL18adc_default_configPK7adc_dev
08000448 l F .text 0000009e _ZL20timer_default_configP9timer_dev
00000000 l df *ABS* 00000000 boards_setup.cpp
200002e8 l O .data 00000004 _ZN6wirish4privL8pll_dataE
00000000 l df *ABS* 00000000 exc.S.o
080005e4 l F .text 00000000 __default_exc
0800061c l .text 00000000 NVIC_CCR
08000620 l .text 00000000 SYSTICK_CSR
08000610 l .text 00000000 CPSR_MASK
08000618 l .text 00000000 TARGET_PC
08000614 l .text 00000000 EXC_RETURN
00000000 l df *ABS* 00000000 isrs.S.o
00000000 l df *ABS* 00000000 adc.c
00000000 l df *ABS* 00000000 adc_f1.c
200002f8 l O .data 00000008 adc1
20000300 l O .data 00000008 adc2
00000000 l df *ABS* 00000000 flash.c
00000000 l df *ABS* 00000000 gpio_f1.c
00000000 l df *ABS* 00000000 nvic.c
00000000 l df *ABS* 00000000 rcc.c
00000000 l df *ABS* 00000000 rcc_f1.c
20000330 l O .data 0000000c enable_regs.4397
2000033c l O .data 00000008 reset_regs.4401
08001d6c l O .rodata 00000014 masks.4406
00000000 l df *ABS* 00000000 systick.c
20000978 l O .bss 00000004 systick_user_callback
00000000 l df *ABS* 00000000 timer.c
08000968 l F .text 0000003a timer_oc_set_mode
20000344 l O .data 00000008 timer3
20000368 l O .data 00000008 timer4
2000039c l O .data 00000008 timer1
200003c4 l O .data 00000008 timer2
00000000 l df *ABS* 00000000 usart_f1.c
08000cf8 l F .text 00000044 rb_push_insert
200003f4 l O .data 00000050 usart1
20000444 l O .data 00000050 usart2
20000494 l O .data 00000050 usart3
2000097c l O .bss 0000000c usart1_rb
20000988 l O .bss 0000000c usart2_rb
20000994 l O .bss 0000000c usart3_rb
00000000 l df *ABS* 00000000 usart_private.c
00000000 l df *ABS* 00000000 util.c
00000000 l df *ABS* 00000000 HardwareSerial.cpp
00000000 l df *ABS* 00000000 main.cpp
00000000 l df *ABS* 00000000 Print.cpp
00000000 l df *ABS* 00000000 wirish_digital_f1.cpp
00000000 l df *ABS* 00000000 wirish_digital.cpp
00000000 l df *ABS* 00000000 wirish_time.cpp
00000000 l df *ABS* 00000000 gpio.c
00000000 l df *ABS* 00000000 usart.c
00000000 l df *ABS* 00000000 exit.c
00000000 l df *ABS* 00000000 init.c
00000000 l df *ABS* 00000000 __call_atexit.c
080011f0 l F .text 00000014 register_fini
00000000 l df *ABS* 00000000 atexit.c
00000000 l df *ABS* 00000000 fini.c
00000000 l df *ABS* 00000000 __atexit.c
00000000 l df *ABS* 00000000 c:/users/mika/appdata/roaming/arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/armv7-m/crti.o
00000000 l df *ABS* 00000000 c:/users/mika/appdata/roaming/arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/armv7-m/crtn.o
00000000 l df *ABS* 00000000 impure.c
200004e8 l O .data 00000428 impure_data
00000000 l df *ABS* 00000000 cxxabi-compat.cpp
00000000 l df *ABS* 00000000 libgcc2.c
00000000 l df *ABS* 00000000 libgcc2.c
00000000 l df *ABS* 00000000 bpabi.c
00000000 l df *ABS* 00000000 libgcc2.c
00000000 l df *ABS* 00000000 libgcc2.c
00000000 l df *ABS* 00000000 errno.c
00000000 l df *ABS* 00000000 memset.c
00000000 l df *ABS* 00000000
00000000 l *UND* 00000000 __irq_sdio
00000000 l *UND* 00000000 __irq_fsmc
00000000 l *UND* 00000000 __irq_tim6
08001410 l .ARM.exidx 00000000 __exidx_end
00000000 l *UND* 00000000 __irq_uart5
00000000 l *UND* 00000000 __irq_adc3
00000000 l *UND* 00000000 __irq_dma2_channel2
00000000 l *UND* 00000000 __irq_tim8_brk
08001408 l .text.align 00000000 __exidx_start
00000000 l *UND* 00000000 __irq_tim8_up
200009a8 l .bss 00000000 _lm_heap_start
00000000 l *UND* 00000000 __irq_uart4
00000000 l *UND* 00000000 __irq_dma2_channel4_5
00000000 l *UND* 00000000 software_init_hook
00000000 l *UND* 00000000 boardUsedPins
00000000 l *UND* 00000000 hardware_init_hook
00000000 l *UND* 00000000 __irq_tim8_trg_com
00000000 l *UND* 00000000 __irq_tim5
00000000 l *UND* 00000000 __irq_tim8_cc
00000000 l *UND* 00000000 __stack
00000000 l *UND* 00000000 __irq_dma2_channel3
00000000 l *UND* 00000000 __irq_tim7
00000000 l *UND* 00000000 __irq_spi3
00000000 l *UND* 00000000 __irq_dma2_channel1
28006d20 l .rodata 00000000 _lm_heap_end
00000000 l *UND* 00000000 __lm_enable_error_usart
080005d8 g F .text 00000000 __exc_memmanage
08000630 w F .text 00000000 __stm32reservedexception9
20000320 g O .data 00000008 gpioc
08000000 g O .text 000000ec __stm32_vector_table
08000718 g F .text 00000030 gpio_init_all
08000dd8 g F .text 0000001c __irq_usart2
08000654 g F .text 00000030 adc_set_sample_rate
08000630 w F .text 00000000 __irq_dma1_channel3
20000000 g .data 00000000 __data_start__
08000630 w F .text 00000000 __irq_i2c2_er
080008e8 g F .text 00000034 rcc_reset_dev
08000630 w F .text 00000000 __irq_i2c1_er
080009a4 g F .text 00000030 timer_foreach
08001020 g F .text 00000018 _ZN5Print7printlnEv
08001d64 g O .rodata 00000004 GPIOC
08000e10 g F .text 00000024 _usart_clock_freq
08000630 w F .text 00000000 __irq_usb_lp_can_rx0
200002ec w O .data 00000001 _ZN6wirish4priv9w_adc_smpE
080006cc g F .text 00000036 adc_enable_single_swstart
08000ee6 g F .text 00000018 _ZN14HardwareSerial4peekEv
200003ec g O .data 00000004 USART2
08000b54 g F .text 00000054 __irq_tim1_cc
08001408 g .text.align 00000000 __text_end__
08000886 g F .text 00000018 rcc_is_clk_ready
08000630 w F .text 00000000 __irq_dma1_channel6
20000948 g O .bss 00000018 Serial1
08000000 g .text 00000000 __text_start__
08000748 g F .text 00000050 gpio_set_mode
08000140 g F .text 00000038 _Z5setupv
08001d80 g O .rodata 0000005c rcc_dev_table
08001164 g F .text 0000001a usart_tx
08000ba8 g F .text 00000070 __irq_tim2
0800091c g F .text 00000020 rcc_set_prescaler
08000ec0 g F .text 00000026 _ZN14HardwareSerial9availableEv
08000630 w F .text 00000000 __exc_debug_monitor
08000630 w F .text 00000000 __irq_dma1_channel1
080006b0 g F .text 0000001c adc_foreach
08000f08 g F .text 0000001e _ZN14HardwareSerial5writeEh
08000830 g F .text 00000020 rcc_switch_sysclk
080010e4 g F .text 00000018 _Z5delaym
0800104c g F .text 0000006c _Z7pinModeh13WiringPinMode
08001150 g F .text 00000014 usart_enable
08000630 w F .text 00000000 __exc_svc
08001404 g .text 00000000 __fini_array_end
08000178 g F .text 0000005c _Z4loopv
00000000 w *UND* 00000000 malloc
08000d7e g F .text 0000003c usart_set_baud_rate
08000798 g F .text 00000012 afio_init
20000910 g .bss 00000000 __bss_start__
08000630 w F .text 00000000 __irq_dma1_channel4
08000630 w F .text 00000000 __irq_adc
08000684 g F .text 00000024 adc_calibrate
080007f4 g F .text 00000030 nvic_init
08000c88 g F .text 00000070 __irq_tim4
08000646 g F .text 0000000e adc_set_extsel
08000704 g F .text 00000014 flash_set_latency
08000630 w F .text 00000000 __irq_dma1_channel7
08000fd2 g F .text 0000001c _ZN5Print5writeEPKc
08000fbc g F .text 00000006 _ZN14HardwareSerial5beginEm
08000630 w F .text 00000000 __irq_exti0
080005e0 g F .text 00000000 __exc_usagefault
080005a4 w F .text 00000002 _ZN6wirish4priv15board_reset_pllEv
080010b8 g F .text 0000002c _Z12digitalWritehh
08000630 w F .text 00000000 __irq_can_rx1
20000390 g O .data 00000004 TIMER2
200002ee w O .data 00000002 _ZN6wirish4priv9w_adc_preE
08001e0c g O .rodata 00000004 _global_impure_ptr
080011a0 g F .text 00000050 __libc_init_array
0800024c g F .text 00000030 _Z9boardInitv
080005cc w F .text 00000004 _ZN6wirish4priv11series_initEv
080001e4 g F .text 00000064 start_c
080013d8 g F .text 00000000 _init
08000630 w F .text 00000000 __irq_spi2
08001300 g F .text 00000030 __libc_fini_array
080006a8 g F .text 00000008 adc_set_prescaler
0800086a g F .text 0000001c rcc_turn_off_clk
080009d4 g F .text 00000014 timer_init
08000efe g F .text 0000000a _ZN14HardwareSerial5flushEv
08000630 w F .text 00000000 __irq_can_sce
00000000 w *UND* 00000000 __deregister_frame_info
08001038 g F .text 00000014 _ZN5Print7printlnEPKc
200003f0 g O .data 00000004 USART3
200009a0 g O .bss 00000004 systick_uptime_millis
08000630 w F .text 00000000 __irq_exti2
080008a0 g F .text 00000018 rcc_configure_pll
20000930 g O .bss 00000018 Serial
080009e8 g F .text 00000030 timer_has_cc_channel
0800094c g F .text 0000001c __exc_systick
20000910 g .data 00000000 __data_end__
08001de0 g O .rodata 00000024 _ZTV14HardwareSerial
20000310 g O .data 00000008 gpioa
2000038c g O .data 00000004 TIMER1
200009a8 g .bss 00000000 __bss_end__
0800100c g F .text 0000000a _ZN5Print5printEc
08000af4 g F .text 00000028 __irq_tim1_up
08001e10 g .rodata 00000000 _lm_rom_img_cfgp
080005a6 w F .text 00000020 _ZN6wirish4priv28board_setup_clock_prescalersEv
08001204 g F .text 000000f0 __call_exitprocs
08000630 w F .text 00000000 __irq_exti3
08000f44 g F .text 00000078 _ZN14HardwareSerial5beginEmh
08000850 g F .text 0000001a rcc_turn_on_clk
080007cc g F .text 00000028 nvic_irq_set_priority
08000e80 g F .text 00000014 __error
08000630 w F .text 00000000 __irq_exti9_5
080005dc g F .text 00000000 __exc_busfault
20000398 g O .data 00000004 TIMER4
08001330 g F .text 000000a8 __register_exitproc
0800093c g F .text 00000010 systick_init
08000630 w F .text 00000000 __irq_pvd
08000630 w F .text 00000000 __irq_tamper
08000630 g F .text 00000000 __default_handler
08000630 w F .text 00000000 __irq_wwdg
08000630 w F .text 00000000 __stm32reservedexception10
08000630 w F .text 00000000 __irq_flash
08000f28 g F .text 0000001c _ZN14HardwareSerialC2EP9usart_devhh
080005c6 w F .text 00000004 _ZN6wirish4priv16board_setup_gpioEv
08001400 g .text 00000000 __fini_array_start
2000030c g O .data 00000004 ADC2
08000630 w F .text 00000000 __irq_i2c2_ev
08001110 g F .text 00000040 usart_init
08000a18 g F .text 0000001e timer_detach_interrupt
20000008 g O .data 000002e0 PIN_MAP
2000092c g O .bss 00000001 flip
08000fc6 g F .text 0000000c main
20005000 g *ABS* 00000000 __msp_init
20000394 g O .data 00000004 TIMER3
08000fee g F .text 0000001e _ZN5Print5writeEPKvm
080013f4 g .text 00000000 __init_array_end
08000e34 g F .text 0000004c throb
08000d3c g F .text 00000042 usart_config_gpios_async
08000acc g F .text 00000028 __irq_tim1_brk
08001016 g F .text 0000000a _ZN5Print5printEPKc
080001d4 g F .text 00000000 __exc_reset
08001d5c g O .rodata 00000004 GPIOA
00000000 w *UND* 00000000 __libc_fini
08000630 w F .text 00000000 __irq_dma1_channel2
00000000 w *UND* 00000000 __lm_error
08000dbc g F .text 0000001c __irq_usart1
08000630 w F .text 00000000 __irq_dma1_channel5
08000630 w F .text 00000000 __stm32reservedexception13
080005d4 g F .text 00000000 __exc_hardfault
080013f4 g F .text 00000000 _fini
08000630 w F .text 00000000 __irq_rtc
080012f4 g F .text 0000000c atexit
080008b8 g F .text 00000030 rcc_clk_enable
08000630 w F .text 00000000 __irq_spi1
08000b1c g F .text 00000038 __irq_tim1_trg_com
08000632 g F .text 00000014 adc_init
080005ca w F .text 00000002 _ZN6wirish4priv15board_setup_usbEv
080013e4 g .text 00000000 __preinit_array_end
08000630 w F .text 00000000 __stm32reservedexception7
08000630 w F .text 00000000 __irq_usb_hp_can_tx
200002f0 w O .data 00000008 _ZN6wirish4priv15w_board_pll_cfgE
08000824 g F .text 0000000c rcc_dev_clk
08000630 w F .text 00000000 __irq_exti15_10
08000630 w F .text 00000000 __irq_exti4
080005d0 g F .text 00000000 __exc_nmi
20000328 g O .data 00000008 gpiod
08000630 w F .text 00000000 __irq_rtcalarm
200009a8 g .bss 00000000 _end
200003e8 g O .data 00000004 USART1
08001d68 g O .rodata 00000004 GPIOD
08000630 w F .text 00000000 __stm32reservedexception8
08001180 g F .text 00000020 exit
08000e94 g F .text 0000002c _ZN14HardwareSerial4readEv
080004e8 g F .text 000000bc _Z4initv
08000a36 g F .text 00000094 timer_set_mode
080013e4 g .text 00000000 __init_array_start
080007ac g F .text 00000020 afio_remap
08000630 w F .text 00000000 __exc_pendsv
08000630 w F .text 00000000 __irq_i2c1_ev
08000248 w F .text 00000002 _exit
08001d60 g O .rodata 00000004 GPIOB
08000630 w F .text 00000000 __irq_usbwakeup
080001d4 g F .text 00000000 __start__
08000630 w F .text 00000000 __irq_exti1
08000630 w F .text 00000000 __irq_rcc
20000318 g O .data 00000008 gpiob
08000c18 g F .text 00000070 __irq_tim3
080010fc g F .text 00000014 gpio_init
08000df4 g F .text 0000001c __irq_usart3
00000000 w *UND* 00000000 _Jv_RegisterClasses
080013e4 g .text 00000000 __preinit_array_start
08000fc2 g F .text 00000004 _Z7premainv
00000000 w *UND* 00000000 __register_frame_info
08000f28 g F .text 0000001c _ZN14HardwareSerialC1EP9usart_devhh
20000308 g O .data 00000004 ADC1
00000000 w *UND* 00000000 free
20000960 g O .bss 00000018 Serial2


michael_l
Sun Aug 30, 2015 9:50 am
Ok, it works!

I just created a new project (STM32F10x C/C++ Project) and debugging started to work ! Something magical has happened :)

Now the next thing would be to try to get Arduino .ino files compiled so that debugging is possible.


madias
Sun Aug 30, 2015 10:48 am
Well, done!
Because this is more eclipse related than nucleo I would suggest to Roger to move it into the “IDE’s” section of this forum?

michael_l
Sun Aug 30, 2015 11:05 am
Yes, that’s a good idea. Belongs to IDE section. Thanks.

Since compiling Arduino .ino files in Eclipse seems to involve quite a lot of work I’ve thought to compile sketches in Arduino and debug in Eclipse. Does that sound reasonable ?

I already found the “intermediate” files that Arduino IDE creates but I didn’t find symbol file for use with GDB. Is there an easy way to enable creating that in Arduino?

EDIT: seems Arduino compilier already uses -g flag. Fair enough. :)


michael_l
Sun Aug 30, 2015 2:11 pm
Ok. Looks like I got debugging a project that was originally compiled in Arduino IDE working in Eclipse under Win32 that is. Eclipse IDE is quite good for debugging IMHO.

Here’s a few shots. I have to play with this a bit more to see how good it is but looks promising. Next thing is to do some tricks to get for example core library sources into project path to enable breakpoints there (not necessarily needed). For example C:\Users\me\Documents\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple\libmaple contains a lot of interesting stuff that I’d like to debug – mainly just for fun :)

Image

Image

Image


michael_l
Sun Aug 30, 2015 8:04 pm
Debugger works reliably but I’m having hard time to have Eclipse find the actual Arduino source file (.ino). It finds easily everything else that is in build.tmp folder created by Arduino

Currently I’m stuck at this:

Image

ANy help is appreciated. The directory it is referring to seems a bit weird ?


sheepdoll
Sun Aug 30, 2015 9:10 pm
michael_l wrote:

ANy help is appreciated. The directory it is referring to seems a bit weird ?

RogerClark
Sun Aug 30, 2015 9:19 pm
I had the same issue when attempting to use DDD under cygwin .

However this was when compiling using the IDE i.e a Windows program and then running DDD, a unix program, inside a cygwin shell.

Its odd the Eclipse has this issue when you have not used any other programs in the build process.

One quick hack could be to process the file that contains these paths and replace the slash with the appropriate one. I think this is in the .elf file.

However when I tried to do this run running DDD, it read the back slashes as escape chars, so it still didn’t work. And I could not find an easy way to process the elf file to replace / with \\ and \ with \\, without breaking the structure of the .elf binary file.

However you may have more success if you just need to convert forward slashes to back slashes


michael_l
Sun Aug 30, 2015 11:01 pm
sheepdoll wrote:michael_l wrote:

ANy help is appreciated. The directory it is referring to seems a bit weird ?

michael_l
Sun Aug 30, 2015 11:02 pm
RogerClark wrote:I had the same issue when attempting to use DDD under cygwin .

However this was when compiling using the IDE i.e a Windows program and then running DDD, a unix program, inside a cygwin shell.

Its odd the Eclipse has this issue when you have not used any other programs in the build process.

One quick hack could be to process the file that contains these paths and replace the slash with the appropriate one. I think this is in the .elf file.

However when I tried to do this run running DDD, it read the back slashes as escape chars, so it still didn’t work. And I could not find an easy way to process the elf file to replace / with \\ and \ with \\, without breaking the structure of the .elf binary file.

However you may have more success if you just need to convert forward slashes to back slashes


RogerClark
Sun Aug 30, 2015 11:15 pm
Ummm.

From what I recall the Arduino IDE compiles a binary that is then converted to a bin.

Perhaps Eclipse does it a different way.


michael_l
Mon Aug 31, 2015 5:46 am
RogerClark wrote:Ummm.

From what I recall the Arduino IDE compiles a binary that is then converted to a bin.

Perhaps Eclipse does it a different way.


RogerClark
Mon Aug 31, 2015 5:54 am
Ah.

I didn’t realise you are trying to do that.

We’ve already investigated something very similar.

There is something called the Eclipse CDT Standalone Debugger, which we were hoping to use, but I posted to the Eclipse forum, and they said the debugger doesnt work on Windows.
Actually I think someone else from this forum also posted to the Eclipse forum, and I know the Eclipse team, were investigating how to get it to work, but that was at least a month ago.

You may be better of posting to the Eclipse forum

Take a look at this thread, as I think some things you tried, may have already been tried by other people

http://www.stm32duino.com/viewtopic.php … =cdt#p1149


michael_l
Mon Aug 31, 2015 6:10 am
RogerClark wrote:Ah.

I didn’t realise you are trying to do that.

We’ve already investigated something very similar.

There is something called the Eclipse CDT Standalone Debugger, which we were hoping to use, but I posted to the Eclipse forum, and they said the debugger doesnt work on Windows.
Actually I think someone else from this forum also posted to the Eclipse forum, and I know the Eclipse team, were investigating how to get it to work, but that was at least a month ago.

You may be better of posting to the Eclipse forum

Take a look at this thread, as I think some things you tried, may have already been tried by other people

http://www.stm32duino.com/viewtopic.php … =cdt#p1149


RogerClark
Mon Aug 31, 2015 6:15 am
OK

I had to log into their forum to find it

https://www.eclipse.org/forums/index.ph … th=1006944&

I hijacked an existing thread on the same subject, and also “Stuart” from this forum posted independently to the same thread.

The post to the thread mentions a patch

https://dev.eclipse.org/mhonarc/lists/c … 29420.html

However I’m not sure if that means you have to patch your Eclipse installation of whether its been merged into their core, in which case if you have a recent copy of Eclipse, perhaps its supposed to work now.


michael_l
Mon Aug 31, 2015 6:24 am
RogerClark wrote:OK

I had to log into their forum to find it

https://www.eclipse.org/forums/index.ph … th=1006944&

I hijacked an existing thread on the same subject, and also “Stuart” from this forum posted independently to the same thread.

The post to the thread mentions a patch

https://dev.eclipse.org/mhonarc/lists/c … 29420.html

However I’m not sure if that means you have to patch your Eclipse installation of whether its been merged into their core, in which case if you have a recent copy of Eclipse, perhaps its supposed to work now.


RogerClark
Mon Aug 31, 2015 6:28 am
Thanks! I’ll read those threads. I’m using Eclipse IDE C/C++ with GNU Arm plugins and build tools. Downloaded from here http://www.eclipse.org/downloads/packag … opers/mars a few days ago.

Its possible Eclipse has a bug that they are not aware of.


michael_l
Mon Aug 31, 2015 6:52 am
RogerClark wrote:Thanks! I’ll read those threads. I’m using Eclipse IDE C/C++ with GNU Arm plugins and build tools. Downloaded from here http://www.eclipse.org/downloads/packag … opers/mars a few days ago.

Its possible Eclipse has a bug that they are not aware of.


michael_l
Mon Aug 31, 2015 7:09 am
Actually if the bug is in the IDE itself then I guess that manually starting GDB session and inserting breakpoints from commandline should work ?

RogerClark
Mon Aug 31, 2015 7:18 am
Yes.
You can manually run GDB.

I wrote instructions on how to do it ages ago

http://www.stm32duino.com/viewtopic.php … =4242#p808


michael_l
Mon Aug 31, 2015 9:57 am
Loaded a another .elf compiled in Arduino. “info sources” in GDB shows this:


D:\Users\me\Documents\Arduino\libraries\U8glib\utility\u8g_com_api_16gr.c, D:\Users\me\Documents\Arduino\libraries\U8glib\utility\u8g_com_api.c,
D:\Users\me\Documents\Arduino\libraries\U8glib\utility\u8g_clip.c, D:\Users\me\Documents\Arduino\libraries\U8glib\utility\u8g_circle.c,
D:\Users\me\Documents\Arduino\libraries\U8glib\utility\u8g_bitmap.c, D:\Users\me\Documents\Arduino\libraries\U8glib\utility\chessengine.c,
D:\Users\me\Documents\Arduino\libraries\U8glib\U8glib.h, D:\Users\me\Documents\Arduino\libraries\U8glib\U8glib.cpp,
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial.h, C:\Program Files (x86)\Arduino/Blink3.ino,
D:\Users\me\AppData\Local\Temp\build321087032653580089.tmp\Blink3.cpp

I don’t know if this is an error because the path – at least to me – is wrong in elf. I have a hard time to believe this would be a bug in GDB? No wonder Eclipse gets upset.

I still wonder where does “C:\Program Files (x86)\Arduino” come from.

If I command:
(gdb) break loop()
Breakpoint 1 at 0x5ee: file Blink3.ino, line 247.


RogerClark
Mon Aug 31, 2015 10:34 am
Looks line some rubbish the Arduino IDE generates :-(

michael_l
Mon Aug 31, 2015 10:57 am
I’m using Arduino IDE 1.6.5

ahull
Mon Aug 31, 2015 11:04 am
Looks like ” C:\Program Files (x86)\Arduino/Blink3.ino” is a Windowsland mistake.. surely ” C:\Program Files (x86)\Arduino\Blink3.ino” or ” C:/Program Files (x86)/Arduino/Blink3.ino”, but mixing both “\” and “/” in the path is asking for disaster.

michael_l
Mon Aug 31, 2015 11:14 am
ahull wrote:Looks like ” C:\Program Files (x86)\Arduino/Blink3.ino” is a Windowsland mistake.. surely ” C:\Program Files (x86)\Arduino\Blink3.ino” or ” C:/Program Files (x86)/Arduino/Blink3.ino”, but mixing both “\” and “/” in the path is asking for disaster.

RogerClark
Mon Aug 31, 2015 11:21 am
The Arduino IDE takes your_file.ino and adds various things like the necessary includes etc and generates you_file.cpp

You can open the cpp from the temporary directory

e.g. it adds this to the top of a blink sketch called GD32_test.ino

#line 1 "GD32_test.ino"
#include "Arduino.h"
void setup();
void loop();
#line 1


michael_l
Mon Aug 31, 2015 11:25 am
Thanks!

Is there any chance to modify the Arduino build process a little ?

I’d like to modify this:

#line 1 “GD32_test.ino”

into hardcoded path e.g.

#line 1 “C:\users\me\My Documents\Arduino\…\GD32_test.ino”


zmemw16
Mon Aug 31, 2015 11:31 am
i did a quick look in ~/.arduino15, i suspect its from a .mk or Makefile
platform debian8 and arduino stock 1.6.5 linux 32bit binary
there is a ino.mk, actually a few, Makefiles and *.mk both way past my ability to follow:-)

stephen


RogerClark
Mon Aug 31, 2015 11:45 am
This stuff is done internally by the IDE

The only place you could look to see if there is any slashes in the wrong direction is the platform.txt file.

its

Arduino\hardware\Arduino_STM32\GD32F1\platform.txt

However I took a quick look and I can’t see anyhing in there that looks like it would be doing what you’ve seen

Your best option is probably to post an issue to github.com/Arduino/Arduino


michael_l
Mon Aug 31, 2015 12:05 pm
Is the whole source for Arduino IDE located here?

https://github.com/arduino/Arduino/tree/master/

I could try to hack something in first when I get a little bit of more time.

https://github.com/arduino/Arduino/comm … 359d886ccb

Looks like Sketch.java is the file to modify

EDIT: I was able to modify the .elf. I changed string Blinky.ino into c:\kky.ino (make sure you only overwrite)

‘info sources’ shows now this.

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\hooks.c, C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\main.cpp,
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\wiring_digital.c,
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\wiring.c, c:\kky.ino,
D:\Users\lainemi\AppData\Local\Temp\build321087032653580089.tmp\Blinky.cpp

Let’s see what Eclipse says about that :-) Before that I have to copy original Blinky.ino –> c:\kky.ino.


michael_l
Mon Aug 31, 2015 1:11 pm
Looks like someone else found the same problem too.

https://github.com/arduino/Arduino/issues/1337


michael_l
Mon Aug 31, 2015 7:09 pm
michael_l wrote:
EDIT: I was able to modify the .elf. I changed string Blinky.ino into c:\kky.ino (make sure you only overwrite)

Let’s see what Eclipse says about that :-) Before that I have to copy original Blinky.ino –> c:\kky.ino.


RogerClark
Mon Aug 31, 2015 9:22 pm
What do you mean when you say it doesnt work.

Do you mean it doesnt find that file, or is there some other error?


michael_l
Mon Aug 31, 2015 9:44 pm
Ah.. Sorry. I mean that it still says it can’t find the source. In this case ‘c:\kky.ino’. Same path is now in .elf too but still it can’t find it. Unbelievable :shock:

michael_l
Mon Aug 31, 2015 10:24 pm
It works with a small tweak !! Finally :-)

Image

.ino file in .elf –> not good. Have to get rid of that.

myblink.ino file contains only this line:

#include “C:\Program Files (x86)\Arduino\examples\01.Basics\myblink\myblink2.cpp”

myblink2.cpp:

#include <arduino.h>
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
Serial.begin(9600);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for a second
Serial.println(2);
}


mrburnette
Mon Aug 31, 2015 11:08 pm
So this means it’s possible to get Eclipse debugging working with your STM32 with OpenOCD in WIndows in “5 minutes” without knowing much about GDB or OpenOcd. Eclipse is only used as debugging IDE and needs to have GDB and OpenOCD plugins installed.

@michael_l

OK, this is pretty darn cool… Looks like I will have to try and recreate this stew… always something to pimp my time :lol:

Ray


RogerClark
Mon Aug 31, 2015 11:22 pm
Michael,

Thats fantastic news

Would it be possible for you to write some step by step instructions on how to do this.

Including which Eclipse to install etc


michael_l
Tue Sep 01, 2015 6:07 am
Thanks, Ray and Roger.

Yeah, I’m happy to do that and save someone else’s time trying to do the same ! For some parts I’ll just refer to a great site which I found when investigating this. My order of Maple Mini’s and external ST-Link USB dongles are on their way so when they arrive I’ll try debugging with them also.

Now that debugging is working it’s time to start porting my Arduino Nano project for Nucleo and Maple Mini :) I posted an issue about this “.ino” to Arduino github – so let’s see what they think about that.

So for now getting .ino file opened in debugger remains as a mystery. When I have time I’ll try to do the same in Linux (or Linux in VirtualBox) just to see if the same problem exists there.


RogerClark
Tue Sep 01, 2015 6:49 am
Michael

The IDE including the Ino file seems like a mistake / bug to me. I suspect they didnt realise there was a reference to it in the elf file as AFIK they its not possible to do in-circuit debugging on AVR and for debugging on the new Arduino Zero people have to use Atmel Studio as their IDE.

I took a quick look on github at the Arduino sources, but there are 168 references to “.ino” so it would take quite a while to figure out precisely which one of those instances is the problem. :-(


michael_l
Tue Sep 01, 2015 7:14 am
I’m not sure but it looks like this commit introduced using ‘#line’ with the .ino source file name the first time:
https://github.com/arduino/Arduino/comm … 359d886ccb

Reason is:
// These #line directives help the compiler report errors with
// correct the filename and line number (issue 281 & 907)

The same function is now in master branch in file: arduino-core/src/processing/app/debug/Compiler.java at around line 1383

and this line most probably makes the compiler to include the .ino file in the .elf too. I’m not an expert in this area but there seems to be a good reason to include the .ino file BUT Eclipse is having a hard time with that :)

EDIT: Does Atmel Studio handle the .ino file correctly or does it compile it so that it does not include .ino in the .elf at all ?


michael_l
Tue Sep 01, 2015 7:44 pm
I’m quite sure now that this looks like a bug in Eclipse under Win32. While debugging I watched trace windows in Eclipse: what is sent to GDB and what GBD responds.

Hitting a breakpoint. this is what GDB prints:

Breakpoint 7, loop () at C:\cygwin\tmp\untitled8842960513440007790.tmp\sketch_sep01a/sketch_sep01a.ino:6
6 void loop() {


Rick Kimball
Tue Sep 01, 2015 8:56 pm
The code probably got optimized out of the source. arm-none-eabi-objdump -CS foo.elf is your friend.

RogerClark
Tue Sep 01, 2015 9:35 pm
you could change the optimization settings in platform.txt, just for debugging.

michael_l
Wed Sep 02, 2015 5:08 am
Yes, I should test this with a code that actually does something. I’ll try the optimization settings too. Would you suggest using -O0 or something else ?

michael_l
Wed Sep 02, 2015 8:28 am
Rick Kimball wrote:The code probably got optimized out of the source. arm-none-eabi-objdump -CS foo.elf is your friend.

RogerClark
Wed Sep 02, 2015 8:42 am
But GDB does show the code ? Am I missing something ?

If you run GDB on the command line, it has commands to list the code i.e show the code around the current program counter, and to set breakpoints.

But normally an IDE like Exclipse handles this all for you.

So I’m not to sure what your question is really??


michael_l
Wed Sep 02, 2015 8:56 am
RogerClark wrote:But GDB does show the code ? Am I missing something ?

If you run GDB on the command line, it has commands to list the code i.e show the code around the current program counter, and to set breakpoints.

But normally an IDE like Exclipse handles this all for you.

So I’m not to sure what your question is really??


RogerClark
Wed Sep 02, 2015 10:05 am
Sorry Michael

I can’t help with that one. It sounds like a question for the Eclipse forum


michael_l
Wed Sep 02, 2015 10:11 am
RogerClark wrote:Sorry Michael

I can’t help with that one. It sounds like a question for the Eclipse forum


michael_l
Wed Sep 02, 2015 2:29 pm
here’s a little bit different situation:

I modified Arduino source code so that full path of .ino file is used

The .cpp generated by Arduino contains now:

#line 1 “c:\\sketch.ino”

in the first line. File is there in c:\sketch.ino

IDE Log:
!ENTRY org.eclipse.cdt.dsf.ui 2 0 2015-09-02 17:25:07.768
!MESSAGE Unable to locate file: c:\sketch.ino

and

Image

So that didn’t work.


Rick Kimball
Wed Sep 02, 2015 3:17 pm
Did you press the “Locate File…” button and point it at the source code?

michael_l
Wed Sep 02, 2015 3:25 pm
Rick Kimball wrote:Did you press the “Locate File…” button and point it at the source code?

Rick Kimball
Wed Sep 02, 2015 3:37 pm
Sounds like you need to setup the file associations in eclipse so that the IDE knows that your .ino file is a C++ file and that the default is to use the Eclipse editor not the System editor (.ino must be associated with the arduino.exe)

A quick search on google indicates it might be a windows only issue, although I haven’t tried on windows. I did test my gdb setup ( command line arm-none-eabi-gdb ) with windows a while back and I was able to make that work. But of course eclipse wasn’t in that mix.

Please let us know exactly what your setup is and maybe we can try to recreate. There are so many places this can fall down, it is hard to guess what is different, what you have changed and what you have set.

-rick

PS I’m often on IRC, and it is often easier to solve these types of problems with a question answer format than a forum.


michael_l
Wed Sep 02, 2015 3:51 pm
Rick,

Yeah, would be great to talk in IRC and try out different things. Thanks for your suggestion. I will ll try that too. Actually that really makes sense when I think about that. Eclipse can’t open the file in the IDE because it’s opened by Arduino IDE. However I think Eclipse should just load the file and not try to execute it with default program.

I did test my gdb setup ( command line arm-none-eabi-gdb ) with windows a while back and I was able to make that work. But of course eclipse wasn’t in that mix.

Yes, there’s some small mistake in Eclipse in the file handling part I believe. GBD plays nicely.

In the meanwhile looks like I got this working!! Hacked Arduino IDE sources so that it does not print #line directives:

Here’s the .cpp file produce by Arduino. NOrmally there would be “#line 1 “sketch_02sepb.ino”

#include "Arduino.h"
void setup();
void loop();
void setup() {

}

void loop() {

Serial.println("1234");
Serial.println("5678");
delay(2000);
}


Rick Kimball
Wed Sep 02, 2015 4:08 pm
I compiled a simple blink sketch and then loaded the /tmp/xxxx/blink_std.cpp.elf into the eclipse debugger. I didn’t have to modify the arduino ide or mess with #line directives or include a .cpp. When the file associations are correct it should just work …

eclipse_screen.jpg
eclipse_screen.jpg (204.69 KiB) Viewed 812 times

michael_l
Wed Sep 02, 2015 7:25 pm
Rick Kimball wrote:I compiled a simple blink sketch and then loaded the /tmp/xxxx/blink_std.cpp.elf into the eclipse debugger. I didn’t have to modify the arduino ide or mess with #line directives or include a .cpp. When the file associations are correct it should just work …

eclipse_screen.jpg


RogerClark
Wed Sep 02, 2015 8:21 pm
michael, can you post your hacked IDE somewhere, i know a lot of people would be interested in trying it.

Rick Kimball
Wed Sep 02, 2015 9:10 pm
michael_l wrote:Tried this and does not work. It still says can’t locate the file. Oh well, I have a hacked Arduino IDE that strips off those ‘#line’ directives and debugging the main sketch file works – this is ok for me for now.

RogerClark
Wed Sep 02, 2015 9:17 pm
Michael,

I can concur with Rick.

GDB on the command line works fine.

I had to use it yesterday to find a nasty bug which caused __error() to be called, and I used backtrace “bt” to show the stack and work out precisely which line number things were on.

Well, I must admit, I didn’t list / display the code when I was doing by debugging yesterday, but I’m sure I’ve done it in the past, so I’m fairly sure that GDB knows where to look even with the Arduino IDE adding the Ino into the elf file etc


michael_l
Thu Sep 03, 2015 4:22 am
Thanks guys for your support. It is a bug in Eclipse IDE. I submitted an issue – let’s see what happens. Would be nice to fix it but I could not find any instruction on how to download and build Eclipse C/C++ plus CDT from source.

Well, I do seem to have a problem too with my new progam receiving SIGINT. I compiled and ran for the first time my original program for Nano.

Then I pressed ‘Suspend’ on the IDE

#0 0x080022fe in gpio_write_bit (dev=0x20000324 <gpiob>, pin=1 '\001', val=1 '\001') at C:\Users\mika\Documents\Arduino\hardware\Arduino_STM32\STM32F1\system/libmaple/include/libmaple/gpio.h:92
#1 0x080023c6 in throb () at C:\Users\mika\Documents\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple\libmaple\util.c:141
#2 0x08002348 in __error () at C:\Users\mika\Documents\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple\libmaple\util.c:56
#3 0x08002348 in __error () at C:\Users\mika\Documents\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple\libmaple\util.c:56
#4 0x00000000 in ?? ()


RogerClark
Thu Sep 03, 2015 6:28 am
Michael

I had the throb() problem the other day.

Well, throb() is not the problem, its a symptom of the problem.

There is a error exception callback defined in one of the jump tables, called __error() and __error() calls throb() which flashes the LED

When I was debugging an issue I had with USB Serial, it ended up in throb() but i was able to use backtrace “bt” to see the call stack and work out which line in the boards setup source had really caused the problem. I just opened the file in notepad++ and looked at the line and it was then obvious what I’d been doing wrong.,
In my case it was an issue of variables not being initialised when they were used (read)

Anyway, lets hope the Eclipse team accept it as a bug and fix it.


michael_l
Thu Sep 03, 2015 9:21 am
Instructions to debug Arduino sketches in Eclipse C/C++ IDE with STM32 and OpenOCD

Most of the stuff has been taken from: http://gnuarmeclipse.livius.net/blog/ which I followed. Here it is in a little more compact form.

# Eclipse IDE

Download and unzip Eclipse Mars for C/C++ (Win32) here:

https://www.eclipse.org/downloads/packa … pers/marsr

# GNU ARM plug-ins

The recommended way to install these plug-ins is to use the Eclipse standard install/update mechanism: In the Eclipse menu: Help ? Install New Software… -> Add

fill in Name: with GNU ARM Eclipse Plug-ins
fill in Location: with http://gnuarmeclipse.sourceforge.net/updates

Select all the plugins and install. It might warn you about untrusted plugins. Ignore that.

Next we’ll install :
– toolchain
– optional build tools (if you are running on Windows)
– debugging tools

# Toolchain

https://launchpad.net/gcc-arm-embedded

and from right select the second one which should be this:

https://launchpad.net/gcc-arm-embedded/ … -win32.exe

Install to (default): C:\Program Files (x86)\GNU Tools ARM Embedded\4.9 2015q2

!! leave unchecked: ‘Add path to environment variable’ and ‘launch gccvar.bat’

# Build tools (for windows)

http://sourceforge.net/projects/gnuarme … d%20Tools/

Download the first one on the list: (win32 2.6.xx)
http://sourceforge.net/projects/gnuarme … e/download

Install to (default) C:\Program Files\GNU ARM Eclipse\Build Tools folder:

Check the global tools path: Windows->Preferences->Build->Global Tools Path. If you installed toolchain and built tools in default locations these should have been found by IDE

Image

# Debugging tools (OpenOCD)

Install GNU ARM OpenOcd plugin from here: http://sourceforge.net/projects/gnuarme … D/Windows/ . I installed 0.9.0 which was latest. Installation goes by default here: C:\Program Files (x86)\GNU ARM Eclipse\OpenOCD\0.9.0-201505190955

This will enable OpenOCD Debugging.

Check Preferences->Run/Debug->OpenOCD to see if openocd.exe points to correct folder. It was filled automatically by IDE.

Board config file goes into ‘Config’ section: “-f board\st_nucleo_f103rb.cfg”. In my case there was a ready made config file for Nucleo-F103RB. There are more board config files to choose in directory scripts\board.

It’s time to test if OpenOCD can connect to your board. In my case there was ready made config for Nucleo-F103RB. As you might understand this is a mandatory step to get debugging working. OpenOCD will talk to your debugging interface forwarding commands from IDE.

C:\Program Files (x86)\GNU ARM Eclipse\OpenOCD\0.9.0-201505190955\bin>openocd.exe -f ..\scripts\board\st_nucleo_f103rb.cfg
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 mi
ght 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
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.247525
Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints


RogerClark
Thu Sep 03, 2015 10:13 am
Hi Michael

I think its best to leave it here until a few people have tried the instructions and have ironed out any kinks etc

Once we are sure the instructions work for most people, we can move it to the top of the thread

Thanks again

Roger


michael_l
Thu Sep 03, 2015 3:06 pm
Here’s the DL link for modified Arduino IDE I have used.
http://www.megafileupload.com/54w6/ardu … p-2015.zip

RogerClark
Thu Sep 03, 2015 8:54 pm
thanks for the link

RogerClark
Sun Sep 06, 2015 10:33 am
michael

I have tried following your instructions, and have installed Eclipse etc

However I had a problem with the Arduino IDE.

I changed my bink_pc13.ino to just have an include to my cpp e.g.

#include "C:\Users\roger\Documents\Arduino\blink_pc13\blink_src.cpp"


michael_l
Sun Sep 06, 2015 6:27 pm
Roger,

Very good points here and a few mistakes from me. I just edited and added more information.

The error message you’re seeing is because you most probably didn’t create a ‘dummy’ STM32 project from File->New C Project->STM32F10x, did you ? This sets the correct path for ARM compiler and enables variables: {cross_prefix} and {cross_suffix}. I did get the same error. If you dont’ get this working I believe you can hard-code the full path to arm-none-eabi-gdb.exe because that’s what it uses.

Yes, you’ll have to have ST-Link drivers installed and working. I have Nucleo-F103RB which has on-board ST-Link v2.1.I just installed driver package from ST’s website. Anyway.. for Nucleo-F103RB there’s a ready made configuration under OpenOCD’s directory. It’s a script that executes several other config files:

# This is an ST NUCLEO F103RB board with a single STM32F103RBT6 chip.
# http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/LN1847/PF259875

source [find interface/stlink-v2-1.cfg]

transport select hla_swd

source [find target/stm32f1x.cfg]

reset_config srst_only


RogerClark
Sun Sep 06, 2015 9:11 pm
Hi Michael

I think I made the dummy project correctly, but as you say, I must be missing some config.

The laptop I was using for testing did not have STM’s STLink driver, but I have now installed this.

I will take another look this evening to see if I can figure out which paths are missing, but I have followed all of your instructions as far as I can tell.


michael_l
Mon Sep 07, 2015 7:28 pm
Yes, this is interesting. I don’t remember setting those cross_prefix and cross_suffix variables anywhere. They must come within toolchain I think. Also where to find those variables under preferences or project settings is a bit of a mystery to me. Eclipse surely is a very nice IDE and there are many configuration options.

michael_l
Wed Sep 09, 2015 3:03 pm
Roger, did you have any time to test this further ?

I just received my first “blue pill” and St-Link V2 dongle (clone). I’ll try how debugging works in next few days I believe.


michael_l
Wed Sep 09, 2015 7:49 pm
Just tried debugging with ST-Link V2 “Dongle” Mini Metal Shield and ‘Blue Pill’ and it works okay. I used STLINK for uploading and I don’t have uploaded a bootloader.

For OpenOCD config I created a new file with this contents (thanks to Rick)


# This is for the $4.29 ebay ST-Link V2 Mini Metal Shell and an stm32f103 board
# http://www.ebay.com/itm/251642538698

source [find interface/stlink-v2.cfg]

transport select hla_swd

set WORKAREASIZE 0x2000
source [find target/stm32f1x.cfg]

reset_config none


ilg
Fri Oct 09, 2015 7:25 am
RogerClark wrote:Anyway, lets hope the Eclipse team accept it as a bug and fix it.

robca
Tue Dec 22, 2015 10:44 am
I’m trying to install the full toolchain to debug. I’ve done everything, but I can’t get the last step. The file http://www.megafileupload.com/54w6/ardu … p-2015.zip has been removed from megaupload due to lack of activity

I tried using the xxx.cpp trick (admittedly with a slightly more complex project), but I’m getting a lot of compile errors in the last phase. So I wanted to use the modified IDE instead but, well :)


stevech
Tue Dec 22, 2015 3:25 pm
using what OS?

robca
Tue Dec 22, 2015 3:43 pm
Windows x64…. everything works when used normally, I simply need the modified Arduino IDE at this point, to create the right .elf file

martinayotte
Tue Dec 22, 2015 4:01 pm
What do you mean by “create the right .elf file” ?
It is already generated in the /tmp folder, and from it, the .bin is created.
This mechanism is driven by commands and flags located in the platform.txt

robca
Tue Dec 22, 2015 4:08 pm
I’m referring to this:

Switch to Arduino IDE

enable ‘Show verbose output during [x] compilation’ from Arduino IDE

Now you have two choices:

1) Use regular Arduino IDE:
because of a bug in Eclipse Win32 IDE you have to make a small change in your .ino file. Without this step you won’t be able to debug original .ino file. Let’s say you have a sketch called blink.ino

for ‘blink.ino’ create blink2.cpp file (not blink.cpp)

copy contents of blink.ino into blink2.cpp

edit original blink.ino file so that it contains only this line: #include “C:\Program Files (x86)\Arduino\examples\01.Basics\myblink\myblink2.cpp” and add #include <Arduino.h> to the first line.

2) use modified Arduino IDE. Download link is here: http://www.megafileupload.com/54w6/ardu … p-2015.zip. During compilation of .ino file it will remove #line directives from the .cpp that Arduino generates. #line directive generates reference to blink.ino file in the .elf and it seems to confuse Eclipse IDE (Win32 at least) so that it can’t find the file. More about that in this thread.

In this post http://www.stm32duino.com/viewtopic.php … t=60#p5475

Or has that problem been since fixed?


martinayotte
Tue Dec 22, 2015 6:24 pm
Ah ! I see …
No, the issue still probably there.
Did you try what Roger tried, ie : having a *.ino only to include a *.cpp and having all the code itself into the *.cpp ?

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

michael_l
Sun Jan 03, 2016 6:47 pm
Found the modified ide zip. Please save and share this:

http://phenoboy.kapsi.fi/arduino-02-Sep-2015.zip


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 ?

Vitalhb
Mon Jan 16, 2017 6:23 pm
michael_l wrote: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

michael_l
Mon Jan 16, 2017 8:02 pm
Hi, please Check my post on 03 Sep 2015 for instructions.

stevestrong
Mon Jan 16, 2017 8:15 pm
I think, this is it:
http://www.stm32duino.com/viewtopic.php … t=60#p5475

Leave a Reply

Your email address will not be published. Required fields are marked *