Skip to content

Instantly share code, notes, and snippets.

@bluecmd
Last active December 20, 2020 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bluecmd/917e63d30e57e8be90ffd32d4b4f5549 to your computer and use it in GitHub Desktop.
Save bluecmd/917e63d30e57e8be90ffd32d4b4f5549 to your computer and use it in GitHub Desktop.
[WIP] Building OpenOCD 64-bit on Windows 10 with MSYS2 for ULX3S FTDI JTAG
# 32-bit build by me: https://github.com/bluecmd/tools/blob/master/openocd-32bit-ulx3s.zip
# This is for 64-bit
# BUG: Ends up depending on msys anyway: https://github.com/libusb/libusb/issues/829
# Note: We use MSYS for the shell to compile an MinGW64 target.
# That way the resulting binary will not rely on MSYS.
# Make sure the FTDI drivers are installed for the virtual COM port.
# As of this writing I am using "CDM v2.12.28 WHQL Certified"
# Install MSYS2
https://www.msys2.org/
# Update pacman until everything is updated
pacman -Syuu
# Install development tools
pacman -S base-devel mingw-w64-x86_64-gcc p7zip
# Download latest libusb
wget https://github.com/libusb/libusb/releases/download/v1.0.24/libusb-1.0.24.7z
7z x -olibusb ./libusb-1.0.22.7z
cd openocd-*/
export PATH=$PATH:/mingw64/bin
# Override pkg-config results to our mingw64 dll
export LIBUSB1_CFLAGS="-I${PWD}/../libusb/include/libusb-1.0"
export LIBUSB1_LIBS="-lusb-1.0 -L${PWD}/../libusb/MinGW64/dll/"
# The dependency libjaylink is using slightly different names
export libusb_CFLAGS="${LIBUSB1_CFLAGS}"
export libusb_LIBS="${LIBUSB1_LIBS}"
./configure --disable-doxygen-pdf --enable-ft232r --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32
# NOTE: Ignore the warning about libusb1 being old,
# it's a pkg-config bug since we are manually telling it where to find it.
make -j$(nproc)
# Usage from WSL:
# ./openocd.exe --file=ft231x.ocd --file=ecp5-85f.cfg --command 'svf debugblink-v2.0-85f.svf quiet progress; shutdown'
telnet_port 4444
gdb_port 3333
# JTAG TAPs
#jtag newtap lfe5u12 tap -expected-id 0x21111043 -irlen 8 -irmask 0xFF -ircapture 0x5
#jtag newtap lfe5u25 tap -expected-id 0x41111043 -irlen 8 -irmask 0xFF -ircapture 0x5
#jtag newtap lfe5u45 tap -expected-id 0x41112043 -irlen 8 -irmask 0xFF -ircapture 0x5
jtag newtap lfe5u85 tap -expected-id 0x41113043 -irlen 8 -irmask 0xFF -ircapture 0x5
init
scan_chain
# NOTE: If you get a bunch of LIBUSB_ERROR_PIPE or IO or TIMEOUT, it might be a poor USB hub or something between.
svf bitstream.svf quiet progress
shutdown
adapter driver ft232r
adapter speed 1000
ft232r_vid_pid 0x0403 0x6015
# ULX3S specific GPIO setting
ft232r_tck_num DSR
ft232r_tms_num DCD
ft232r_tdi_num RI
ft232r_tdo_num CTS
# trst/srst are not used but must have different values than above
ft232r_trst_num RTS
ft232r_srst_num DTR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment