-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
openocd with picoprobe segfaulting on windows #3
Comments
paging @liamfraser |
I'll investigate this today |
This works with mingw-w64-x86_64-libusb-1.0.23-1-any.pkg.tar.xz. The latest libusb (mingw64/mingw-w64-x86_64-libusb 1.0.24-2) segfaults. |
I have built it here. Can you try it out? https://drive.google.com/file/d/1SgZJepJWYQqCeC7m8se-yJLK9sv_AH8n/view?usp=sharing |
I've only got one pico free at the moment. It outputs this:
Is this expected when it doesn't have another one to talk to? I'll try and test it out properly tomorrow. |
Yes. That looks like it's working |
Just hit the same segfault problem with openocd so tried the build offered by @liamfraser. |
I encountered this as well with the one I built just now, so instead I am using the binary provided here for now. Here is some basic stuff I got out of GDB:
|
I built both libusb v1.0.24 and the latest master manually and used the resulting DLLs -- v1.0.24 has the Segmentation Fault, latest master does not. Here's a better backtrace for the thread that is segfault'ing:
|
Following the Getting Started guide and getting same segmentation fault issue. (binary provided above seems to be working) |
Just hit this problem too after compiling it myself using the official . When I run it with GDB I see
Mind that my Using the release provided above, it works nicely. It also works if I self-compile the latest branch and just put in the libusb-1.0.dll that has version info 1.0.23.11397. I think this is very crucial for Windows users and the instructions at https://datasheets.raspberrypi.org/pico/getting-started-with-pico.pdf should be updated. |
I think that requests for changes to the documentation should be created at https://github.com/raspberrypi/pico-feedback |
In the linked libusb issue above I was also able to find out that when I use Zadig to load WinUSB drivers as opposed to libusb-win32 what the Raspberry Pi foundation's PDF is saying, using the latest released libusb-1.0.dll version 1.0.24 does not cause a crash. It is also explicitly said in libusb/libusb#954 (comment) to not use use libusb-win32 but prefer WinUSB. Can someone reproduce this non-crashing on WinUSB with latest libusb-1.0.dll besides me? |
https://github.com/libusb/libusb/wiki/Windows#Driver_Installation |
The following libusb issue has been resolved in libusb release 1.0.25. Latest libusb version is 1.0.26. But WinUSB driver is still recommended and not libusb0.sys. |
Alright, I decided to bite the bullet and tried to cross-compile from Linux(Ubuntu 22.04 LTS) to Windows, and finally succeeded. Also, I do highly recommend building in a container. build scriptsudo apt install automake autoconf build-essential texinfo libtool pkg-config mingw-w64 autopoint flex cmake git
BUILD_DIR="$(pwd)/openocd_build"
LIBUSB1_BUILD_DIR=${BUILD_DIR}/libusb
LIBUSB0_BUILD_DIR=${BUILD_DIR}/libusb-compat
LIBCONFUSE_BUILD_DIR=${BUILD_DIR}/libconfuse
HIDAPI_BUILD_DIR=${BUILD_DIR}/hidapi
LIBFTDI_BUILD_DIR=${BUILD_DIR}/libftdi
mkdir -p ${BUILD_DIR}
pushd ${BUILD_DIR}
git clone --depth 1 --branch tags/v1.0.26 https://github.com/libusb/libusb.git libusb
pushd libusb
./bootstrap.sh
./configure --host=x86_64-w64-mingw32 --enable-static --disable-shared
make
popd
git clone --depth 1 --branch tags/v0.1.7 https://github.com/libusb/libusb-compat-0.1.git libusb-compat
pushd libusb-compat
./autogen.sh
LIBUSB_1_0_CFLAGS="-I${LIBUSB1_BUILD_DIR}/libusb" \
LIBUSB_1_0_LIBS="-L${LIBUSB1_BUILD_DIR}/libusb/.libs -lusb-1.0" \
PKG_CONFIG_PATH=${LIBUSB1_BUILD_DIR} \
./configure --host=x86_64-w64-mingw32 --enable-static --disable-shared
make
popd
git clone --depth 1 --branch tags/v3.3 https://github.com/martinh/libconfuse.git libconfuse
pushd libconfuse
./autogen.sh
# --disable-examples is needed for building with mingw
./configure --host=x86_64-w64-mingw32 --enable-static --disable-shared --disable-examples
make
popd
git clone --depth 1 --branch tags/v1.5 git://developer.intra2net.com/libftdi libftdi
pushd libftdi
mkdir build
pushd build
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-x86_64-w64-mingw32.cmake \
-DLIBUSB_LIBRARIES=${LIBUSB1_BUILD_DIR}/libusb/.libs/ \
-DLIBUSB_INCLUDE_DIR=${LIBUSB1_BUILD_DIR}/libusb \
-DCONFUSE_LIBRARY=${LIBCONFUSE_BUILD_DIR}/src/.libs/ \
-DCONFUSE_INCLUDE_DIR=${LIBCONFUSE_BUILD_DIR}/src/ ../
make ftdi1-static
popd
popd
git clone --depth 1 --branch tags/hidapi-0.12.0 https://github.com/libusb/hidapi.git hidapi
pushd hidapi
./bootstrap
./configure --host=x86_64-w64-mingw32 --enable-static --disable-shared
make
popd
git clone https://github.com/raspberrypi/openocd.git --branch rp2040
pushd openocd
# this is the tested version of openocd, change as needed
git checkout 228ede43db3665e470d2e518730de013a8c74411
./bootstrap
HIDAPI_CFLAGS="-I${HIDAPI_BUILD_DIR}/hidapi" \
HIDAPI_LIBS="-L${HIDAPI_BUILD_DIR}/windows/.libs -lhidapi" \
LIBUSB0_CFLAGS="-I${LIBUSB0_BUILD_DIR}/libusb" \
LIBUSB0_LIBS="-L${LIBUSB0_BUILD_DIR}/libusb/.libs -lusb" \
LIBUSB1_CFLAGS="-I${LIBUSB1_BUILD_DIR}/libusb" \
LIBUSB1_LIBS="-L${LIBUSB1_BUILD_DIR}/libusb/.libs -lusb-1.0" \
LIBFTDI_CFLAGS="-I${LIBFTDI_BUILD_DIR}/src " \
LIBFTDI_LIBS="-L${LIBFTDI_BUILD_DIR}/build/src -lftdi1" \
PKG_CONFIG_PATH=${HIDAPI_BUILD_DIR}/pc:${LIBUSB1_BUILD_DIR}:${LIBUSB0_BUILD_DIR}:${LIBFTDI_BUILD_DIR}/build \
libusb_CFLAGS="-I${LIBUSB1_BUILD_DIR}/libusb" \
libusb_LIBS="-L${LIBUSB1_BUILD_DIR}/libusb/.libs/ -lusb-1.0" \
./configure --host=x86_64-w64-mingw32 --enable-static --disable-shared --enable-picoprobe
make
popd
# now copy the built files to your windows system with the following structure:
# openocd
# |-openocd.exe (copy from openocd/src/openocd.exe)
# |-tcl (copy from openocd/tcl)
# | |- (everything under tcl must be here)
# `.\openocd.exe -f interface/picoprobe.cfg -f target/rp2040.cfg -s tcl` to run in windows Credits goes to this blog post and openocd's readme. While waiting for the official fix and documentation update, I think this will do the trick. |
It is actually pretty easy to build openocd under Windows natively using MSYS2 ming32/mingw64. They have the formula for latest version of libusb-1.0, libusb-compat-0.1, libftdi1 and hidapi. They also have capstone. So you do not need to build them by yourselves. On the other hand, I understand why people like to use Cross Build -- the speed might be a bit faster once you have the build scripts ready. And if you are more familiar with Linux than Windows, why not? |
@mcuee My bad, didn't notice that. I also find it being much more stable - everything is statically linked, and every library version (except mingw) is defined (no more build failure due to system updates!). But then again, this is going off-topic, so I'd end my bragging. |
All in all, I think this issue can be closed as the upstream libusb issue has been resolved. You should really use libusb-1.0.26 for new build of OpenOCD. For people who are still using libusb-1.0.24, you can have a easy work-around as well -- just use Zadig to install WinUSB driver. |
I'd like to update this script since the git clone branches aren't correct. Modifying them fixed it for me.
|
Huh, which script are you referring to exactly? |
oops, forgot to properly attach quote by SubaruArai |
I followed the instructions in the Getting Started with Pico guide, and built OpenOCD for windows, but when I try to start it, it segfaults. I'm not even sure where to start with this. Is the info and warn details what are expected?
The text was updated successfully, but these errors were encountered: