Arduino Zero bonus bin (openocd supported)

Rick Kimball
Wed Jun 17, 2015 3:21 pm
Seems that now that the Arduino Zero is out openocd is in : )

The Zero uses a cortex-m0+. The programming plug on the Zero board uses a CMSIS-DAP device. I guess Atmel/Arduino decided the quickest way to get support for that device was to just use openocd as it already supports CMSIS-DAP. So to upload programs to the Zero, they setup openocd in the platform.txt. Openocd is the richer cousin to the texane st utility package, getting support from various vendors. The good thing for us is that we could start using their binary instead of texane stuff and have less to code to support. All our users would have to do is install the SAMD package instead of the DUE one. That would bring in the arm-none-eabi-gcc and openocd 0.9.0. Certainly something to ponder in the future.

Looking at the way the platform is written here, I’m not sure if they are running openocd 3 times with different parameters:

https://github.com/arduino/ArduinoCore- … m.txt#L120

The good thing about openocd 0.9.0, it supports all the stlink devices we might want to use, st-link v2, and v2.1. And there is support for all the different stm32 targets, STM32F0, F1, F2, F3, F4.

-rick


Rick Kimball
Wed Jun 17, 2015 3:29 pm
Rick Kimball wrote:The platform is written here, I’m not sure if they are running openocd 3 times with different parameters:

https://github.com/arduino/ArduinoCore- … m.txt#L120


sheepdoll
Wed Jun 17, 2015 5:18 pm
Rick;
Is there a direct link to openocd? One that can be used as a standalone tool install?

Rick Kimball
Wed Jun 17, 2015 5:46 pm
sheepdoll wrote:Rick;
Is there a direct link to openocd? One that can be used as a standalone tool install?

Rick Kimball
Wed Jun 17, 2015 5:49 pm
Actually I was looking at a cached version in my browser …

http://downloads.arduino.cc/packages/package_index.json

Look for openocd there ..

{
"name": "openocd",
"version": "0.9.0-arduino",
"systems": [
{
"host": "i686-mingw32",
"url": "http://downloads.arduino.cc/tools/OpenOCD-0.9.0-arduino-i686-pc-cygwin.tar.bz2",
"archiveFileName": "OpenOCD-0.9.0-arduino-i686-pc-cygwin.tar.bz2",
"checksum": "SHA-256:5310bdd3730168a33b09b68558e908ca8b2fec25620c488f50a5fb35d0d1effd",
"size": "2360705"
},
{
"host": "x86_64-apple-darwin",
"url": "http://downloads.arduino.cc/tools/OpenOCD-0.9.0-arduino-x86_64-apple-darwin14.3.0.tar.bz2",
"archiveFileName": "OpenOCD-0.9.0-arduino-x86_64-apple-darwin14.3.0.tar.bz2",
"checksum": "SHA-256:ef90769c07b8018cec3a5054e690ac6c196e03720e102ac5038c3f9da4e44782",
"size": "2275101"
},
{
"host": "x86_64-pc-linux-gnu",
"url": "http://downloads.arduino.cc/tools/OpenOCD-0.9.0-arduino-x86_64-linux-gnu.tar.bz2",
"archiveFileName": "OpenOCD-0.9.0-arduino-x86_64-linux-gnu.tar.bz2",
"checksum": "SHA-256:c350409f7badf213dfcc516ea34289461ad92d87806e8e33945508a2c6b2c0b3",
"size": "1210796"
},
{
"host": "i686-pc-linux-gnu",
"url": "http://downloads.arduino.cc/tools/OpenOCD-0.9.0-arduino-i486-linux-gnu.tar.bz2",
"archiveFileName": "OpenOCD-0.9.0-arduino-i486-linux-gnu.tar.bz2",
"checksum": "SHA-256:4c9793dfd7822b0fc959d039e5ecabfa89092ee2911abfdc7b5905deb171499a",
"size": "1129654"
}
] },


martinayotte
Wed Jun 17, 2015 6:48 pm
Interestingly, I’ve started playing with openocd-0.9.0 few days ago. On Linux, I’ve simply untared, configured, compiled, and it was working.

sheepdoll
Wed Jun 17, 2015 7:23 pm
Rick Kimball wrote:Actually I was looking at a cached version in my browser …

http://downloads.arduino.cc/packages/package_index.json

Look for openocd there ..


Rick Kimball
Wed Jun 17, 2015 7:55 pm
The secret sauce is in the scripts, on linux they are here:

/home/kimballr/.arduino15/packages/arduino/tools/openocd/0.9.0-arduino/share/openocd/scripts

for you with your discovery/nucleo boards they are in the board directory. I don’t have one of your m4f boards, I do have a stm32l-discovery board though .. so i used:
$ export OPENOCD_BASE=~/.arduino15/packages/arduino/tools/openocd/0.9.0-arduino
$ export OPENOCD_PATH=${OPENOCD_BASE}/share/openocd/scripts
$ export PATH=$PATH:${OPENOCD_BASE}/bin
$ type openocd
openocd is /home/kimballr/.arduino15/packages/arduino/tools/openocd/0.9.0-arduino//bin/openocd
$ openocd -s ${OPENOCD_PATH} -f board/stm32ldiscovery.cfg
Open On-Chip Debugger 0.9.0-gd4b7679 (2015-06-10-18:22)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
adapter speed: 300 kHz
adapter_nsrst_delay: 100
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : Unable to match requested speed 300 kHz, using 240 kHz
Info : Unable to match requested speed 300 kHz, using 240 kHz
Info : clock speed 240 kHz
Info : STLINK v2 JTAG v21 API v2 SWIM v0 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 2.950209
Info : stm32l1.cpu: hardware has 6 breakpoints, 4 watchpoints


martinayotte
Wed Jun 17, 2015 7:58 pm
Hi Sheepdoll,

I’m newbie with openocd, but if I understood, “openocd.cfg” should be you “prefered” configs, but you can run it without it if you provide all required arguments, such as :

openocd -f interface/stlink-v2.cfg -c “transport select hla_swd” -f target/stm32f1x.cfg


Rick Kimball
Wed Jun 17, 2015 8:02 pm
BTW: openocd doesn’t know anything about the Arduino Zero so they had to provide their own configuration scripts for it:

https://github.com/arduino/ArduinoCore- … o_zero.cfg

source [find interface/cmsis-dap.cfg] # chip name
set CHIPNAME at91samd21g18
set ENDIAN little
# choose a port here
set telnet_port 0
source [find target/at91samdXX.cfg]


sheepdoll
Wed Jun 17, 2015 9:44 pm
I found the obvious “http://openocd.org” that is what I was looking for. Who bothers to read comment URLs in install files Wonder why giggle failed to find it when I searched last week? It may have taken me to the source forge page which looked like a sketchy wal-o-text for some guys thesis project.

Anyway the source forge page links to the eclipse plugin, which is sort of what I was looking for. Apart that I can not get eclipse to run unser OSX 10.7.5 It keeps looking for java 1.6. I had installed the jre1.8 to run cube. All the searches to make eclipse work have the user hacking paths to java JDK1.7 blech. I really did not want to download jdk1.8 but am doing it now.

Rather nasty install, as there seem to be no one click installs on the oracle page. The installer page is practically useless with what should be a click able link as outdated text.

Edit: I got eclipse to run after the install of the JDK. Not user friendly at all. I expect to see a text editor/tree browser for c/c++ on creation of a target project. Does look pretty powerful though.

Edit Edit! well that was a waste of an afternoon. After attempting to install openocd as an eclipse plugin, it crashes with illegal instruction 4. This install is stupid and ignorant. I just want a nice standalone GUI gdb debugger, not the kitchen sink.

One step of an installer wants me to remove the macports path from the .profile. WHAT!!! that breaks the links to ghostscript X11 and the tools I need to use for my everyday work.

This stuff is a joke, or it is for people who like hacking around the path system.

It may be possible to point the eclipse/gdb/openocd to the openocd I downloaded this morning from the Arduino.cc toolchain per the instructions above. That one at least gives me help and a version number when prompted. (It should give help an a naked run, but these tools are not created by professionals that need to get work done.)


Rick Kimball
Thu Jun 18, 2015 12:37 pm
The openocd that comes with Zero seems to work fine with those ebay stlink v2 devices. I grabbed my discovery vl board (stm32f100rb with an STLink V1) and tried it with the ebay stlink v2 device instead to see how it easy it would be to upload a binary:

$ openocd -s ${OPENOCD_PATH} -f ./stm32vldiscovery_v2.cfg -c 'telnet_port disabled; program stm32f100_blink_register.elf verify reset exit'


Rick Kimball
Thu Jun 18, 2015 12:42 pm
sheepdoll wrote:One step of an installer wants me to remove the macports path from the .profile. WHAT!!! that breaks the links to ghostscript X11 and the tools I need to use for my everyday work.

RogerClark
Mon Jul 06, 2015 6:46 am
Guys,

Is this all still using Eclipse as the debugger ?

Any sign of any debugger support in the Arduino IDE ?? (or is it Atmel studio for Zero users)


Rick Kimball
Mon Jul 06, 2015 2:34 pm
To be honest, I’m not actually using any of this. I mostly use a BMP debugger with arm-none-eabi-gdb launched in an xterm.

-rick


sheepdoll
Mon Jul 06, 2015 5:25 pm
TexannSTLink/GDB works for what I have. Not spent any more time with openOCD/eclipse other than it seems to be installed.

May get back to it, but I have other more interesting things to play with.


victor_pv
Tue Jul 07, 2015 5:17 am
I started using GDB to troubleshoot some code, and it helped my find some variables did not have the value expected, but I really hate having to type commands.
Has any of you found a good GDB GUI for Windows?

GDB is way better than nothing, thanks to Rick for showing how to load it automatically in Linux, now I do the same in Windows, but I really need a GUI.


RogerClark
Tue Jul 07, 2015 5:37 am
Victor

I have researched this, and there currently isn’t a GUI for GDB on Windows.

Eclipse where supposed to have released their Standalone Debugger (part of Their C development tools package), but I’m not sure if that has happened yet, and to be honest Eclipse is a massive install and the config is not that easy.

Nothing else that I have tried works on windows, e.g. I tried DDD using cygwin, but it had issues with slashes in paths, which meant it didnt work, I found some Java based editor with a GDB plugin, but the whole thing i.e. the editor, was no longer supported, so I could not get the GDB plugin to work.

It may be possible to use MS Visual Studio, but again I think its a sledgehammer to crack a nut.

To be honest, I think we should investigate how we can build some sort of simple UI to GDB into the Arduino IDE.
But the IDE won’t even open C files (except in its sketch folder), so there would probably need to be a lot of hacking / changes to get that to work.


Rick Kimball
Tue Jul 07, 2015 11:24 am
victor_pv wrote:… but I really hate having to type commands. …

Leave a Reply

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