Re: OpenOCD on STM32 boards

Lawrence King

Hi Marti:

Thanks for your help.

I had stopped using the zephyr-sdk because I was bisecting the kernel to find a problem, depending on where I was I needed 0.10.0, 0.10.1, 0.10.2 or 0.10.3 versions of the SDK to compile, however when I was using gnuarmemb it worked around this annoyance for me.

I removed openocd (and autoremoved the assorted packages) and installed SDK 0.10.3 into /opt/zephyr-sdk. I also set 'export ZEPHYR_SDK_INSTALL_DIR=/opt/zephyr-sdk' in my bashrc and started a new shell. Quick check and openocd is gone from my path.

The west build went cleanly, and now I have a new error from openocd:

lawrence@VM:~/workspace/rc-demo/zephyrproject/zephyr$ west flash
-- west flash: rebuilding
ninja: no work to do.
-- west flash: using runner openocd
-- runners.openocd: Flashing file: /home/lawrence/workspace/rc-demo/zephyrproject/zephyr/build/zephyr/zephyr.hex
Open On-Chip Debugger 0.10.0+dev-00992-g3333261df-dirty (2019-08-16-00:14)
Licensed under GNU GPL v2
For bug reports, read
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : clock speed 2000 kHz
Error: libusb_open() failed with LIBUSB_ERROR_ACCESS
Error: open failed

ERROR: command exited with status 1: /opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/openocd -s /opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/share/openocd/scripts -f /home/lawrence/workspace/rc-demo/zephyrproject/zephyr/boards/arm/stm32f746g_disco/support/openocd.cfg -c init -c targets -c 'reset halt' -c 'flash write_image erase /home/lawrence/workspace/rc-demo/zephyrproject/zephyr/build/zephyr/zephyr.hex' -c 'reset halt' -c 'verify_image /home/lawrence/workspace/rc-demo/zephyrproject/zephyr/build/zephyr/zephyr.hex' -c 'reset run' -c shutdown

This is 'better' than the missing files, but I still haven't successfully flashed the blinky program onto the Nucleo board. Anything else I missed?

Lawrence King
Principal Developer

-----Original Message-----
From: Bolivar, Marti <>
Sent: Tuesday, November 5, 2019 4:55 PM
To: Lawrence King <>;
Subject: Re: [Zephyr-users] OpenOCD on STM32 boards

"Lawrence King via Lists.Zephyrproject.Org"
<> writes:

Of course I got complaints about OPENOCD-MISSING, OK, I can fix that:
sudo apt-get install openocd
It's not always wise to trust in your distro's openocd. It has been hard to get support patches merged into upstream openocd, so the downstream version in the Zephyr SDK is usually the right one to use.

Obviously I am doing something silly wrong. Can anyone give me a hint?
Use the openocd in the Zephyr SDK. You can do this even if you're not using the Zephyr SDK's toolchain -- as long as ZEPHYR_SDK_INSTALL_DIR points at a Zephyr SDK install, the build system will use its host tools (like openocd) even if ZEPHYR_TOOLCHAIN_VARIANT != zephyr.

Join to automatically receive all group messages.