Re: OpenOCD on STM32 boards


Lawrence King
 

Hi Marti:

Thanks, setting the udev rules did the trick.

Just so other people know what to do:

$ sudo cp ${HOME}/opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/share/openocd/contrib/60-openocd.rules /etc/udev/rules.d/
$ sudo udevadm control --reload-rules
$ sudo usermod -aG plugdev $USER

Hi Charles:

This probably should be added somewhere in the 'Getting Started' guide after the Zephyr SDK is installed. It should also be made clear that you don't need to use the compilers in the SDK, but you do need to install the SDK (see the first half of this thread) to get the working version of openocd. I had also put in the rules for pyOCD but these are part of the instructions from pyOCD:

$ git clone https://github.com/mbedmicro/pyOCD.git
$ sudo cp pyOCD/udev/*.rules /etc/udev/rules.d
$ sudo udevadm control --reload
$ sudo udevadm trigger

Lawrence King
Principal Developer
+1(416)627-7302

-----Original Message-----
From: Bolivar, Marti <Marti.Bolivar@nordicsemi.no>
Sent: Tuesday, November 5, 2019 5:51 PM
To: Lawrence King <lawrence.king@irdeto.com>; Zephyr-users@lists.zephyrproject.org
Cc: users@lists.zephyrproject.org
Subject: RE: [Zephyr-users] OpenOCD on STM32 boards

Lawrence King <lawrence.king@irdeto.com> writes:

Hi Marti:

Thanks for your help.
Sure thing!


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/zep
hyr.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
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: 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
^^ judging from this, my guess is you need some udev rules to make the USB device accessible to your user.

Marti

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/script
s -f
/home/lawrence/workspace/rc-demo/zephyrproject/zephyr/boards/arm/stm32
f746g_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/zep
hyr.hex' -c 'reset halt' -c 'verify_image
/home/lawrence/workspace/rc-demo/zephyrproject/zephyr/build/zephyr/zep
hyr.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
+1(416)627-7302

-----Original Message-----
From: Bolivar, Marti <Marti.Bolivar@nordicsemi.no>
Sent: Tuesday, November 5, 2019 4:55 PM
To: Lawrence King <lawrence.king@irdeto.com>;
Zephyr-users@lists.zephyrproject.org
Cc: users@lists.zephyrproject.org
Subject: Re: [Zephyr-users] OpenOCD on STM32 boards

"Lawrence King via Lists.Zephyrproject.Org"
<lawrence.king=irdeto.com@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?
Thanks
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 users@lists.zephyrproject.org to automatically receive all group messages.