• Welcome to Andy's Workshop Forums. Please login or sign up.
 
April 19, 2024, 10:14:50 pm

News:

SMF - Just Installed!


Toolchain setup in Ubuntu 16.04

Started by Carlos47, August 14, 2016, 09:54:35 pm

Previous topic - Next topic

Carlos47

Hi,
I'm Carlos from México, i would like to start programming microcontrollers with C++ (and try to see advantages/disadvantages versus C) and this library is perfect to get started.
I downloaded Eclipse Neon, installed the CDT and GNU ARM Eclipse Toolchain plugins, imported all the projects, compile the library project and then the blink project. Everything went perfect until this point but i'm unable to debug the project.
The problem i get is:
Error while launching command gdb-arm-none-eabi --version

Also i couldn't flash the .hex file with the command line, at the last step i got:
couldn't open stm32plus-examples-blink.hex

Hope somebody can help me, i Google about it and found that i had to mass_erase the stm32 before program it, so i did, then tried to program it and got the same error.

Thanks in advance
Carlos

My PC: Ubuntu 16.04 64x in case it matters

Andy Brown

Hi Carlos,

I haven't got around to trying Neon for C++ projects yet, I'm still a way behind using Kepler. Have you tried using OpenOCD external to Eclipse as I described in my article?
It's worse than that, it's physics Jim!

Andy Brown

August 18, 2016, 02:13:35 pm #2 Last Edit: August 18, 2016, 02:20:55 pm by Andy Brown
I'm now happily using Neon having upgraded from Kepler with no problems. After running Neon I accepted the option to upgrade the workspace. This left all the projects with a red 'x' over them because the GNU ARM Eclipse plugin needed upgrading. I went to the Eclipse Marketplace, selected the plugin and installed it. I removed all the offered debug options (JLink etc) except OpenOCD because that's the one I use.

Nothing needed changing to build the projects. They just worked.

To debug with OpenOCD I first had to update the 'Run/Debug -> OpenOCD' section in the main Eclipse preferences pages. My OpenOCD installation is 0.9.0 I set the 'Executable' field to 'openocd.exe' and the 'Folder' field to the full path of the 'bin-x64' folder that contains openocd.exe.

Then I created a new Run/Debug configuration for the 'blink' project. The type of the configuration was 'GDB OpenOCD Debugging'. On the 'Main' tab, 'Project' was correctly set to 'stm32plus-examples-blink'. In the 'C/C++ Application' field I entered the full path to the 'stm32plus-examples-blink.elf' output file.

On the 'Debugger' tab the only field I changed was the 'Config options' in which I entered '-f ../scripts/board/stm32f0discovery.cfg'. Modify the board file to match the one you are using. I was using my own F042 development board that is compatible for debugging with the STM32 F0 discovery. The other fields on that page were left as the defaults.

I was then able to run the debug session without having OpenOCD permanently running in a terminal behind Eclipse because the 'Start OpenOCD locally' option starts up the server and then tears it down after the debug session. This is nice.

One weird thing was that I was unable to set breakpoints at first - the 'Toggle breakpoint' option in the eclipse context menu was greyed out. This was fixed by selecting 'Breakpoints -> C/C++ Breakpoints' from the context menu that you get when you right-click in the breakpoints margin. It was initially set to 'default'.

Neon is a worthwhile upgrade. I like a dark 'zenburn' low contrast theme and in Neon they've managed to style virtually all the UI elements and at least some of the visual wastes of space (borders, frames etc) have gone. Only the main menu bar still looks wrong.
It's worse than that, it's physics Jim!

Carlos47

September 01, 2016, 06:44:55 pm #3 Last Edit: September 05, 2016, 01:55:33 pm by Carlos47
Hi Andy,
Thanks for the description, i were out this time but i will give Eclipse a try this weekend and let you know the results, i'm using a STM32F4-Discovery board, i do not remember if i was able to use oocd external to eclipse, i were getting some weird errors, it wasn't able to flash the program into the board.
Just tried flash the stm32f4discovery board using oocd from the terminal, i successfully flashed a elf generated by the OpenSTM32 IDE, then i tried to flash the generated elf of the blink example with c++ and i got the following error:
Quote
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
> reset init
Unable to match requested speed 2000 kHz, using 1800 kHz
Unable to match requested speed 2000 kHz, using 1800 kHz
adapter speed: 1800 kHz
stm32f4x.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800022c msp: 0x20020000
Unable to match requested speed 8000 kHz, using 4000 kHz
Unable to match requested speed 8000 kHz, using 4000 kHz
adapter speed: 4000 kHz
> flash write_image erase stm32plus-examples-blink.elf
auto erase enabled
couldn't open stm32plus-examples-blink.elf

I was on the directory that contains stm32plus-examples-blink.elf so i have not to use the full path.

Will investigate further.

Thanks again.
Carlos