Giter Site home page Giter Site logo

Comments (22)

liamfraser avatar liamfraser commented on May 27, 2024 1

I have built it here. Can you try it out?

https://drive.google.com/file/d/1SgZJepJWYQqCeC7m8se-yJLK9sv_AH8n/view?usp=sharing

from debugprobe.

mcuee avatar mcuee commented on May 27, 2024 1

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.

from debugprobe.

SubaruArai avatar SubaruArai commented on May 27, 2024 1

@mcuee My bad, didn't notice that.
I recently tried to build under msys2 but failed, which led to me doing cross-compile.

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!).
Btw, being in a container is a HUGE benefit, IMHO.

But then again, this is going off-topic, so I'd end my bragging.

from debugprobe.

mcuee avatar mcuee commented on May 27, 2024 1

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.

from debugprobe.

Gnomey123 avatar Gnomey123 commented on May 27, 2024 1

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 script
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.

I'd like to update this script since the git clone branches aren't correct.

Modifying them fixed it for me.

sudo 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 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 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 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 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 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

from debugprobe.

Gnomey123 avatar Gnomey123 commented on May 27, 2024 1

oops, forgot to properly attach quote by SubaruArai

from debugprobe.

lurch avatar lurch commented on May 27, 2024

paging @liamfraser

from debugprobe.

liamfraser avatar liamfraser commented on May 27, 2024

I'll investigate this today

from debugprobe.

liamfraser avatar liamfraser commented on May 27, 2024

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.

from debugprobe.

benevpi avatar benevpi commented on May 27, 2024

I've only got one pico free at the moment. It outputs this:

C:\Users\ben\Downloads\openocd_picoprobe>openocd.exe  -f interface/picoprobe.cfg -f target/rp2040.cfg -s tcl            
Open On-Chip Debugger 0.10.0+dev-g14c0d0d-dirty (2021-01-27-15:43)                                                      
Licensed under GNU GPL v2                                                                                              
For bug reports, read                                                                                                           http://openocd.org/doc/doxygen/bugs.html                                                                       
 Info : only one transport option; autoselect 'swd'                                                                      
Warn : Transport "swd" was already selected                                                                             
adapter speed: 5000 kHz                                                                                                                                                                                                                         Info : Hardware thread awareness created                                                                               
 Info : Hardware thread awareness created                                                                                
Info : RP2040 Flash Bank Command                                                                                        
Info : Listening on port 6666 for tcl connections                                                                      
 Info : Listening on port 4444 for telnet connections                                                                   
 Info : clock speed 5000 kHz                                                                                             
Info : DAP init failed  

Is this expected when it doesn't have another one to talk to? I'll try and test it out properly tomorrow.

from debugprobe.

liamfraser avatar liamfraser commented on May 27, 2024

Yes. That looks like it's working

from debugprobe.

johnholman avatar johnholman commented on May 27, 2024

Just hit the same segfault problem with openocd so tried the build offered by @liamfraser.
I got the same messages as above, but when I pulled out the USB connection to the pico Windows gave an error message about trying to reference memory at 0.

from debugprobe.

MimitechIndustries avatar MimitechIndustries commented on May 27, 2024

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:

Thread 5 received signal SIGSEGV, Segmentation fault.
Thread 5 (Thread 47944.0xbfa8):
#0  0x00007ff8c5d46e11 in ?? () from C:\msys64\mingw64\bin\libusb-1.0.dll
#1  0x00007ff8c5d49ffa in ?? () from C:\msys64\mingw64\bin\libusb-1.0.dll
#2  0x00007ff8f6e6b04a in msvcrt!_beginthreadex () from C:\WINDOWS\System32\msvcrt.dll
#3  0x00007ff8f6e6b11c in msvcrt!_endthreadex () from C:\WINDOWS\System32\msvcrt.dll
#4  0x00007ff8f7737bd4 in KERNEL32!BaseThreadInitThunk () from C:\WINDOWS\System32\kernel32.dll
#5  0x00007ff8f7d8ced1 in ntdll!RtlUserThreadStart () from C:\WINDOWS\SYSTEM32\ntdll.dll
#6  0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

from debugprobe.

MimitechIndustries avatar MimitechIndustries commented on May 27, 2024

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:

Thread 5 (Thread 32732.0xbd4c):
#0  0x000000006b606e11 in usbi_signal_transfer_completion (itransfer=0x18df6d0) at io.c:1734
#1  0x000000006b609ffa in windows_iocp_thread (arg=0x3833900) at os/windows_common.c:442
#2  0x00007ff8f6e6b04a in msvcrt!_beginthreadex () from C:\WINDOWS\System32\msvcrt.dll
#3  0x00007ff8f6e6b11c in msvcrt!_endthreadex () from C:\WINDOWS\System32\msvcrt.dll
#4  0x00007ff8f7737bd4 in KERNEL32!BaseThreadInitThunk () from C:\WINDOWS\System32\kernel32.dll
#5  0x00007ff8f7d8ced1 in ntdll!RtlUserThreadStart () from C:\WINDOWS\SYSTEM32\ntdll.dll
#6  0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

from debugprobe.

planetchili avatar planetchili commented on May 27, 2024

Following the Getting Started guide and getting same segmentation fault issue. (binary provided above seems to be working)

from debugprobe.

maxgerhardt avatar maxgerhardt commented on May 27, 2024

Just hit this problem too after compiling it myself using the official .

When I run it with GDB I see

[New Thread 19280.0x2f48]

Thread 5 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 19280.0x2f48]
0x00007ff807217734 in libusb_transfer_get_stream_id@4 ()
   from C:\Users\Max\AppData\Local\Programs\Python\Python38\libusb-1.0.dll
(gdb) backtrace
#0  0x00007ff807217734 in libusb_transfer_get_stream_id@4 ()
   from C:\Users\Max\AppData\Local\Programs\Python\Python38\libusb-1.0.dll
#1  0x00007ff80721a809 in libusb_interrupt_transfer@24 ()
   from C:\Users\Max\AppData\Local\Programs\Python\Python38\libusb-1.0.dll
#2  0x00007ff866791bb2 in ucrtbase!_configthreadlocale () from C:\windows\System32\ucrtbase.dll
#3  0x00007ff867447034 in KERNEL32!BaseThreadInitThunk () from C:\windows\System32\kernel32.dll
#4  0x00007ff868da2651 in ntdll!RtlUserThreadStart () from C:\windows\SYSTEM32\ntdll.dll
#5  0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

Mind that my libusb-1.0.dll comes from the pyusb instructions telling me to use https://github.com/libusb/libusb/releases, that is currently version info 1.0.24.11584.

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.

from debugprobe.

lurch avatar lurch commented on May 27, 2024

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

from debugprobe.

maxgerhardt avatar maxgerhardt commented on May 27, 2024

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?

from debugprobe.

mcuee avatar mcuee commented on May 27, 2024

https://github.com/libusb/libusb/wiki/Windows#Driver_Installation
Recommended: Use the most recent version of Zadig, an Automated Driver Installer GUI application for WinUSB (recommended), libusb-win32 (not working well, not recommended) and libusbK (only if you hit WinUSB limitations)

from debugprobe.

SubaruArai avatar SubaruArai commented on May 27, 2024

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 script
sudo 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.

from debugprobe.

mcuee avatar mcuee commented on May 27, 2024

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?

from debugprobe.

lurch avatar lurch commented on May 27, 2024

I'd like to update this script since the git clone branches aren't correct.

Huh, which script are you referring to exactly?

from debugprobe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.