デバッグプルーブとして、stlink、cmsis-dapをつかっているのですが、ft232rもデバッグプルーブとして使いたいなと思ったところ、(windowsではlinux gpio bitbangだけはつかえませんが)Windows64ビット向けのOpenOCDのバイナリー配布で、すべてのプローブをサポートしているものがなかったので、WSL2/Debian 10 上でビルドしてみました。とりあえず動いてはいるようなので、ビルドスクリプトを、備忘録代わりにアップしてみました。
ちなみに、libusbは新しいバージョンではcmsis-dapが動かず、動いたバージョンは1.0.21でした。(ここがわからず苦労しました...)
スクリプトの実行は、例えばスクリプトをbuild-ocd-for-win.shとした場合、 sh ではなくbashで実行してください。また、スクリプト実行するまえに、以下のようにしておいてください。(capstone disassembler(linux用にはlibgpiodも含む)をビルドするのに、debianのソースパッケージを使っているためです。)
(追記2021/02/14:linux native buildに対応させました。)
(追記2021/02/15:openocd for esp32 を別途ビルド・別Destinationへインストールするようにしました。)
(追記2021/02/21:OpenOCDコンフィグ時の設定を一部修正しました。
sudo apt-get build-dep capstone sudo apt-get build-dep libgpiodなお、クロスコンパイル環境は以下のコマンドです。
sudo apt-get install mingw-w64これら以外のビルド環境を整える場合、以下のようにしました。(ぬけがあるかもしれません。)
sudo apt-get install build-essential debhelper flex make cmake binutils gcc automake autoconf libtool unzip wget gitビルドスクリプトは、以下の通りです。
(追記2021/02/14:linux native buildに対応させました。)
(追記2021/02/15:openocd for esp32 を別途ビルド・別Destinationへインストールするようにしました。)
(追記2021/02/21:OpenOCDコンフィグ時の設定を一部修正しました。
#!/bin/bash HOST_TRIPLET=x86_64-w64-mingw32 #HOST_TRIPLET=x86_64-linux-gnu WORK_DIR=~/OpenOCD BUILD_DIR=$WORK_DIR/$HOST_TRIPLET-build LIBUSB1_VER=1.0.21 #LIBUSB1_VER=1.0.18 MAKE_JOBS=4 SYSROOT=$WORK_DIR/$HOST_TRIPLET-root PREFIX=/usr # do not build LIBGPIOD under windows if [ "${HOST_TRIPLET}" = "x86_64-w64-mingw32" ] || \ [ "${HOST_TRIPLET}" = "i686-w64-mingw32" ] ; then \ BLD_LIBGPIOD=false; fi LIBUSB0_SRC=${WORK_DIR}/libusb-compat LIBUSB1_SRC=${WORK_DIR}/libusb LIBCONFUSE_SRC=${WORK_DIR}/libconfuse HIDAPI_SRC=${WORK_DIR}/hidapi LIBFTDI_SRC=${WORK_DIR}/libftdi LIBJAYLINK_SRC=${WORK_DIR}/libjaylink CAPSTONE_SRC=${WORK_DIR}/capstone LIBGPIOD_SRC=${WORK_DIR}/libgpiod OPENOCD_SRC=${WORK_DIR}/openocd OPENOCD_ESP32_SRC=${WORK_DIR}/openocd-esp32 LIBUSB0_BUILD=${BUILD_DIR}/libusb-compat LIBUSB1_BUILD=${BUILD_DIR}/libusb LIBCONFUSE_BUILD=${BUILD_DIR}/libconfuse HIDAPI_BUILD=${BUILD_DIR}/hidapi LIBFTDI_BUILD=${BUILD_DIR}/libftdi LIBJAYLINK_BUILD=${BUILD_DIR}/libjaylink CAPSTONE_BUILD=${BUILD_DIR}/capstone LIBGPIOD_BUILD=${BUILD_DIR}/libgpiod OPENOCD_BUILD=${BUILD_DIR}/openocd OPENOCD_ESP32_BUILD=${BUILD_DIR}/openocd-esp32 #### if true; then rm -rf ${WORK_DIR} mkdir -p ${WORK_DIR} mkdir -p ${BUILD_DIR} cd ${WORK_DIR} ## libusb #git clone https://github.com/libusb/libusb.git libusb -b v$LIBUSB1_VER wget https://github.com/libusb/libusb/archive/v$LIBUSB1_VER.zip unzip v$LIBUSB1_VER.zip mv libusb-$LIBUSB1_VER libusb cd ${LIBUSB1_SRC} ./bootstrap.sh mkdir -p ${LIBUSB1_BUILD} cd ${LIBUSB1_BUILD} ${LIBUSB1_SRC}/configure \ --host=${HOST_TRIPLET} \ --with-sysroot=$SYSROOT \ --prefix=$PREFIX \ --enable-static --disable-shared make -j ${MAKE_JOBS} #make install DESTDIR=${SYSROOT} cd ${WORK_DIR} ## libusb-compat git clone https://github.com/libusb/libusb-compat-0.1.git ${LIBUSB0_SRC} cd ${LIBUSB0_SRC} ./autogen.sh make distclean mkdir -p ${LIBUSB0_BUILD} cd ${LIBUSB0_BUILD} LIBUSB_1_0_CFLAGS="-I${LIBUSB1_SRC}/libusb" \ LIBUSB_1_0_LIBS="-L${LIBUSB1_BUILD}/libusb/.libs -lusb-1.0" \ PKG_CONFIG_PATH=${LIBUSB1_BUILD} \ ${LIBUSB0_SRC}/configure \ --host=${HOST_TRIPLET} \ --with-sysroot=${SYSROOT} \ --prefix=${PREFIX} \ --enable-static --disable-shared make -j ${MAKE_JOBS} #make install DESTDIR=${SYSROOT} cd ${WORK_DIR} ## libjaylink git clone https://github.com/syntacore/libjaylink ${LIBJAYLINK_SRC} cd ${LIBJAYLINK_SRC} ./autogen.sh mkdir -p ${LIBJAYLINK_BUILD} cd ${LIBJAYLINK_BUILD} libusb_CFLAGS="-I${LIBUSB1_SRC}/libusb" \ libusb_LIBS="-L${LIBUSB1_BUILD}/libusb/.libs -lusb-1.0" \ ${LIBJAYLINK_SRC}/configure \ --host=${HOST_TRIPLET} \ --with-sysroot=${SYSROOT} \ --prefix=${PREFIX} \ --enable-static --disable-shared make -j ${MAKE_JOBS} #make install DESTDIR=${SYSROOT} cd ${WORK_DIR} ## libconfuse git clone https://github.com/martinh/libconfuse.git ${LIBCONFUSE_SRC} cd ${LIBCONFUSE_SRC} ./autogen.sh mkdir -p ${LIBCONFUSE_BUILD} cd ${LIBCONFUSE_BUILD} ${LIBCONFUSE_SRC}/configure \ --host=${HOST_TRIPLET} \ --with-sysroot=${SYSROOT} \ --prefix=${PREFIX} \ --enable-static --disable-shared \ --disable-examples make -j ${MAKE_JOBS} #make install DESTDIR=${SYSROOT} cd ${WORK_DIR} ## libftdi if [ "${HOST_TRIPLET}" = "x86_64-w64-mingw32" ] || \ [ "${HOST_TRIPLET}" = "i686-w64-mingw32" ] ; then \ git clone git://developer.intra2net.com/libftdi ${LIBFTDI_SRC} mkdir -p ${LIBFTDI_BUILD} cd ${LIBFTDI_BUILD} cmake -DCMAKE_TOOLCHAIN_FILE=${LIBFTDI_SRC}/cmake/Toolchain-${HOST_TRIPLET}.cmake \ -DLIBUSB_LIBRARIES=${LIBUSB1_BUILD}/libusb/.libs/ \ -DLIBUSB_INCLUDE_DIR=${LIBUSB1_SRC}/libusb \ -DCONFUSE_LIBRARY=${LIBCONFUSE_BUILD}/src/.libs/ \ -DCONFUSE_INCLUDE_DIR=${LIBCONFUSE_BUILD}/src/ ${LIBFTDI_SRC} make ftdi1-static -j ${MAKE_JOBS} #make install DESTDIR=${SYSROOT} elif [ "${HOST_TRIPLET}" = "x86_64-linux-gnu" ] || \ [ "${HOST_TRIPLET}" = "i386-linux-gnu" ] ; then \ git clone git://developer.intra2net.com/libftdi ${LIBFTDI_SRC} mkdir -p ${LIBFTDI_BUILD} cd ${LIBFTDI_BUILD} cmake \ -DLIBUSB_LIBRARIES=${LIBUSB1_BUILD}/libusb/.libs/ \ -DLIBUSB_INCLUDE_DIR=${LIBUSB1_SRC}/libusb \ -DCONFUSE_LIBRARY=${LIBCONFUSE_BUILD}/src/.libs/ \ -DCONFUSE_INCLUDE_DIR=${LIBCONFUSE_BUILD}/src/ ${LIBFTDI_SRC} make ftdi1-static -j ${MAKE_JOBS} #make install DESTDIR=${SYSROOT} fi cd ${WORK_DIR} ## hidapi git clone https://github.com/signal11/hidapi.git ${HIDAPI_SRC} cd ${HIDAPI_SRC} ./bootstrap mkdir -p ${HIDAPI_BUILD} cd ${HIDAPI_BUILD} ${HIDAPI_SRC}/configure \ --host=${HOST_TRIPLET} \ --with-sysroot=${SYSROOT} \ --prefix=${PREFIX} \ --enable-static --disable-shared make -j ${MAKE_JOBS} #make install DESTDIR=${SYSROOT} cd ${WORK_DIR} ## capstone CAPSTONE_CONFIG="CAPSTONE_BUILD_CORE_ONLY=yes CAPSTONE_STATIC=yes CAPSTONE_SHARED=no" rm -rf ${CAPSTONE_SRC} ${CAPSTONE_BUILD} mkdir tmp cd tmp apt-get source capstone-tool cp -a `ls -d */` ${CAPSTONE_SRC} cp -a `ls -d */` ${CAPSTONE_BUILD} cd ${WORK_DIR} rm -rf tmp cd ${CAPSTONE_BUILD} CC=$HOST_TRIPLET-gcc make CROSS="${HOST_TRIPLET}-" $CAPSTONE_CONFIG pushd cstool CC=$HOST_TRIPLET-gcc make CROSS="${HOST_TRIPLET}-" $CAPSTONE_CONFIG cp -a cstool.exe cstool popd #CC=HOST_TRIPLET-gcc make install DESTDIR=${SYSROOT} PREFIX=${PREFIX} \ # CROSS="${HOST_TRIPLET}-" \ # $CAPSTONE_CONFIG cp -a include capstone mv ${SYSROOT}/${PREFIX}/bin/cstool ${SYSROOT}/${PREFIX}/bin/cstool.exe cd ${WORK_DIR} ## libgpiod (do not build for windows) if $BLD_LIBGPIOD; then rm -rf ${LIBGPIOD_SRC} ${LIBGPIOD_BUILD} mkdir tmp cd tmp apt-get source libgpiod cp -a `ls -d */` ${LIBGPIOD_SRC} cd ${WORK_DIR} rm -rf tmp cd ${LIBGPIOD_SRC} ./autogen.sh make distclean mkdir -p ${LIBGPIOD_BUILD} cd ${LIBGPIOD_BUILD} ${LIBGPIOD_SRC}/configure \ --host=${HOST_TRIPLET} \ --with-sysroot=${SYSROOT} \ --prefix=${PREFIX} \ --enable-static --disable-shared make -j ${MAKE_JOBS} #make install DESTDIR=${SYSROOT} fi cd ${WORK_DIR} ## openocd #rm -rf ${OPENOCD_SRC} ${OPENOCD_BUILD} git clone https://git.code.sf.net/p/openocd/code ${OPENOCD_SRC} #git clone https://repo.or.cz/r/openocd.git openocd #git clone https://github.com/sysprogs/openocd openocd cd ${OPENOCD_SRC} patch -p0 --ignore-whitespace << EOF --- src/jtag/drivers/libftdi_helper.h 2021-02-11 19:00:10.340000000 +0900 +++ src/jtag/drivers/libftdi_helper.h 2021-02-11 19:02:27.850000000 +0900 @@ -8,17 +8,17 @@ #ifndef HAVE_LIBFTDI_TCIOFLUSH /* Backward compatibility with libftdi pre 1.5 */ -static inline int ftdi_tciflush(struct ftdi_context *ftdi) +int ftdi_tciflush(struct ftdi_context *ftdi) { return ftdi_usb_purge_rx_buffer(ftdi); } -static inline int ftdi_tcoflush(struct ftdi_context *ftdi) +inline int ftdi_tcoflush(struct ftdi_context *ftdi) { return ftdi_usb_purge_tx_buffer(ftdi); } -static inline int ftdi_tcioflush(struct ftdi_context *ftdi) +inline int ftdi_tcioflush(struct ftdi_context *ftdi) { return ftdi_usb_purge_buffers(ftdi); } EOF ./bootstrap mkdir -p ${OPENOCD_BUILD} cd ${OPENOCD_BUILD} if [ "${HOST_TRIPLET}" = "x86_64-w64-mingw32" ] || \ [ "${HOST_TRIPLET}" = "i686-w64-mingw32" ] ; then \ HIDAPI_CFLAGS="-I${HIDAPI_SRC}/hidapi" \ HIDAPI_LIBS="-L${HIDAPI_BUILD}/windows/.libs -lhidapi" \ LIBUSB0_CFLAGS="-I${LIBUSB0_SRC}/libusb" \ LIBUSB0_LIBS="-L${LIBUSB0_BUILD}/libusb/.libs -lusb" \ LIBUSB1_CFLAGS="-I${LIBUSB1_SRC}/libusb" \ LIBUSB1_LIBS="-L${LIBUSB1_BUILD}/libusb/.libs -lusb-1.0" \ LIBFTDI_CFLAGS="-I${LIBFTDI_SRC}/src" \ LIBFTDI_LIBS="-L${LIBFTDI_BUILD}/src -lftdi1" \ LIBJAYLINK_CFLAGS="-I${LIBJAYLINK_SRC}/libjaylink" \ LIBJAYLINK_LIBS="-L${LIBJAYLINK_BUILD}/libjaylink -ljaylink" \ CAPSTONE_CFLAGS="-I${CAPSTONE_BUILD}" \ CAPSTONE_LIBS="-L${CAPSTONE_BUILD} -lcapstone" \ PKG_CONFIG_PATH=${HIDAPI_BUILD}/pc:${LIBUSB1_BUILD}:${LIBUSB0_BUILD}:${LIBFTDI_BUILD}:${LIBJAYLINK_BUILD} \ libusb_CFLAGS="-I${LIBUSB1_SRC}/libusb" \ libusb_LIBS="-L${LIBUSB1_BUILD_DIR}/libusb/.libs/ -lusb-1.0" \ CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 -DHAVE_LIBFTDI_TCIOFLUSH -DHAVE_LIBUSB_ERROR_NAME -Wno-deprecated -Wno-deprecated-declarations" \ ${OPENOCD_SRC}/configure \ --enable-maintainer-mode \ --host=${HOST_TRIPLET} \ --enable-cmsis-dap \ --enable-cmsis-dap-v2 \ --enable-ft232r \ --with-sysroot=${SYSROOT} \ --prefix=${PREFIX} elif [ "${HOST_TRIPLET}" = "x86_64-linux-gnu" ] || \ [ "${HOST_TRIPLET}" = "i386-linux-gnu" ] ; then \ HIDAPI_CFLAGS="-I${HIDAPI_SRC}/hidapi" \ HIDAPI_LIBS="-L${HIDAPI_BUILD}/linux/.libs -lhidapi-hidraw" \ LIBUSB0_CFLAGS="-I${LIBUSB0_SRC}/libusb" \ LIBUSB0_LIBS="-L${LIBUSB0_BUILD}/libusb/.libs -lusb" \ LIBUSB1_CFLAGS="-I${LIBUSB1_SRC}/libusb" \ LIBUSB1_LIBS="-L${LIBUSB1_BUILD}/libusb/.libs -lusb-1.0" \ LIBFTDI_CFLAGS="-I${LIBFTDI_SRC}/src" \ LIBFTDI_LIBS="-L${LIBFTDI_BUILD}/src -lftdi1" \ LIBJAYLINK_CFLAGS="-I${LIBJAYLINK_SRC}/libjaylink" \ LIBJAYLINK_LIBS="-L${LIBJAYLINK_BUILD}/libjaylink -ljaylink" \ CAPSTONE_CFLAGS="-I${CAPSTONE_BUILD}" \ CAPSTONE_LIBS="-L${CAPSTONE_BUILD} -lcapstone" \ LIBGPIOD_CFLAGS="-I${LIBGPIOD_SRC}/include" \ LIBGPIOD_LIBS="-L${LIBGPIOD_BUILD}/src/lib/.libs -lgpiod" \ PKG_CONFIG_PATH=${HIDAPI_BUILD}/pc:${LIBUSB1_BUILD}:${LIBUSB0_BUILD}:${LIBFTDI_BUILD}:${LIBJAYLINK_BUILD}:${LIBGPIOD_BUILD} \ libusb_CFLAGS="-I${LIBUSB1_SRC}/libusb" \ libusb_LIBS="-L${LIBUSB1_BUILD_DIR}/libusb/.libs/ -lusb-1.0" \ CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 -DHAVE_LIBFTDI_TCIOFLUSH -DHAVE_LIBUSB_ERROR_NAME -Wno-deprecated -Wno-deprecated-declarations" \ ${OPENOCD_SRC}/configure \ --enable-maintainer-mode \ --host=${HOST_TRIPLET} \ --enable-cmsis-dap \ --enable-cmsis-dap-v2 \ --enable-ft232r \ --enable-bcm2835gpio \ --enable-sysfsgpio \ --with-sysroot=${SYSROOT} \ --prefix=${PREFIX} fi make -j ${MAKE_JOBS} make install DESTDIR=${SYSROOT} #### #fi ## openocd-esp32 rm -rf ${OPENOCD_ESP32_SRC} ${OPENOCD_ESP32_BUILD} git clone https://github.com/espressif/openocd-esp32 ${OPENOCD_ESP32_SRC} cd ${OPENOCD_ESP32_SRC} patch -p0 --ignore-whitespace << EOF --- src/jtag/drivers/libftdi_helper.h 2021-02-11 19:00:10.340000000 +0900 +++ src/jtag/drivers/libftdi_helper.h 2021-02-11 19:02:27.850000000 +0900 @@ -8,17 +8,17 @@ #ifndef HAVE_LIBFTDI_TCIOFLUSH /* Backward compatibility with libftdi pre 1.5 */ -static inline int ftdi_tciflush(struct ftdi_context *ftdi) +int ftdi_tciflush(struct ftdi_context *ftdi) { return ftdi_usb_purge_rx_buffer(ftdi); } -static inline int ftdi_tcoflush(struct ftdi_context *ftdi) +inline int ftdi_tcoflush(struct ftdi_context *ftdi) { return ftdi_usb_purge_tx_buffer(ftdi); } -static inline int ftdi_tcioflush(struct ftdi_context *ftdi) +inline int ftdi_tcioflush(struct ftdi_context *ftdi) { return ftdi_usb_purge_buffers(ftdi); } EOF ./bootstrap mkdir -p ${OPENOCD_ESP32_BUILD} cd ${OPENOCD_ESP32_BUILD} if [ "${HOST_TRIPLET}" = "x86_64-w64-mingw32" ] || \ [ "${HOST_TRIPLET}" = "i686-w64-mingw32" ] ; then \ HIDAPI_CFLAGS="-I${HIDAPI_SRC}/hidapi" \ HIDAPI_LIBS="-L${HIDAPI_BUILD}/windows/.libs -lhidapi" \ LIBUSB0_CFLAGS="-I${LIBUSB0_SRC}/libusb" \ LIBUSB0_LIBS="-L${LIBUSB0_BUILD}/libusb/.libs -lusb" \ LIBUSB1_CFLAGS="-I${LIBUSB1_SRC}/libusb" \ LIBUSB1_LIBS="-L${LIBUSB1_BUILD}/libusb/.libs -lusb-1.0" \ LIBFTDI_CFLAGS="-I${LIBFTDI_SRC}/src" \ LIBFTDI_LIBS="-L${LIBFTDI_BUILD}/src -lftdi1" \ LIBJAYLINK_CFLAGS="-I${LIBJAYLINK_SRC}/libjaylink" \ LIBJAYLINK_LIBS="-L${LIBJAYLINK_BUILD}/libjaylink -ljaylink" \ CAPSTONE_CFLAGS="-I${CAPSTONE_BUILD}" \ CAPSTONE_LIBS="-L${CAPSTONE_BUILD} -lcapstone" \ PKG_CONFIG_PATH=${HIDAPI_BUILD}/pc:${LIBUSB1_BUILD}:${LIBUSB0_BUILD}:${LIBFTDI_BUILD}:${LIBJAYLINK_BUILD} \ libusb_CFLAGS="-I${LIBUSB1_SRC}/libusb" \ libusb_LIBS="-L${LIBUSB1_BUILD_DIR}/libusb/.libs/ -lusb-1.0" \ CFLAGS="-DHAVE_LIBFTDI_TCIOFLUSH -DHAVE_LIBUSB_ERROR_NAME -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -Wno-deprecated -Wno-deprecated-declarations" \ ${OPENOCD_ESP32_SRC}/configure \ --enable-maintainer-mode \ --host=${HOST_TRIPLET} \ --enable-cmsis-dap \ --enable-cmsis-dap-v2 \ --enable-ft232r \ --with-sysroot=${SYSROOT} \ --prefix=${PREFIX} make -j ${MAKE_JOBS} make install DESTDIR=${SYSROOT}-esp32 elif [ "${HOST_TRIPLET}" = "x86_64-linux-gnu" ] || \ [ "${HOST_TRIPLET}" = "i386-linux-gnu" ] ; then \ HIDAPI_CFLAGS="-I${HIDAPI_SRC}/hidapi" \ HIDAPI_LIBS="-L${HIDAPI_BUILD}/linux/.libs -lhidapi-hidraw" \ LIBUSB0_CFLAGS="-I${LIBUSB0_SRC}/libusb" \ LIBUSB0_LIBS="-L${LIBUSB0_BUILD}/libusb/.libs -lusb" \ LIBUSB1_CFLAGS="-I${LIBUSB1_SRC}/libusb" \ LIBUSB1_LIBS="-L${LIBUSB1_BUILD}/libusb/.libs -lusb-1.0" \ LIBFTDI_CFLAGS="-I${LIBFTDI_SRC}/src" \ LIBFTDI_LIBS="-L${LIBFTDI_BUILD}/src -lftdi1" \ LIBJAYLINK_CFLAGS="-I${LIBJAYLINK_SRC}/libjaylink" \ LIBJAYLINK_LIBS="-L${LIBJAYLINK_BUILD}/libjaylink -ljaylink" \ CAPSTONE_CFLAGS="-I${CAPSTONE_BUILD}" \ CAPSTONE_LIBS="-L${CAPSTONE_BUILD} -lcapstone" \ LIBGPIOD_CFLAGS="-I${LIBGPIOD_SRC}/include" \ LIBGPIOD_LIBS="-L${LIBGPIOD_BUILD}/src/lib/.libs -lgpiod" \ PKG_CONFIG_PATH=${HIDAPI_BUILD}/pc:${LIBUSB1_BUILD}:${LIBUSB0_BUILD}:${LIBFTDI_BUILD}:${LIBJAYLINK_BUILD}:${LIBGPIOD_BUILD} \ libusb_CFLAGS="-I${LIBUSB1_SRC}/libusb" \ libusb_LIBS="-L${LIBUSB1_BUILD_DIR}/libusb/.libs/ -lusb-1.0" \ CFLAGS="-DHAVE_LIBFTDI_TCIOFLUSH -DHAVE_LIBUSB_ERROR_NAME -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -Wno-deprecated -Wno-deprecated-declarations" \ ${OPENOCD_ESP32_SRC}/configure \ --enable-maintainer-mode \ --host=${HOST_TRIPLET} \ --enable-cmsis-dap \ --enable-cmsis-dap-v2 \ --enable-ft232r \ --enable-bcm2835gpio \ --with-sysroot=${SYSROOT} \ --prefix=${PREFIX} make -j ${MAKE_JOBS} make install DESTDIR=${SYSROOT}-esp32 fi #### fi exit 0(追記:2021/02/15: ESP32のlinuxビルドで--enable-sysfsgpioをconfigureで指定するとビルドできないので、オプションから外しました。) ビルドログは以下の様になります。
(前略) checking for LIBUSB1... yes configure: WARNING: libusb-1.x older than 1.0.9 detected, consider updating configure: libusb-1.0 header bug workaround: LIBUSB1_CFLAGS changed to "-isystem /home/XXXXXX/OpenOCD/libusb/libusb" checking for LIBUSB0... yes checking for CAPSTONE... yes checking for HIDAPI... yes checking for LIBFTDI... yes checking for LIBGPIOD... no checking for LIBJAYLINK... yes (中略) OpenOCD configuration summary -------------------------------------------------- MPSSE mode of FTDI based devices yes (auto) ST-Link Programmer yes (auto) TI ICDI JTAG Programmer yes (auto) Keil ULINK JTAG Programmer yes (auto) Altera USB-Blaster II Compatible yes (auto) Bitbang mode of FT232R based devices yes Versaloon-Link JTAG Programmer yes (auto) TI XDS110 Debug Probe yes (auto) CMSIS-DAP v2 Compliant Debugger yes OSBDM (JTAG only) Programmer yes (auto) eStick/opendous JTAG Programmer yes (auto) Andes JTAG Programmer yes (auto) USBProg JTAG Programmer yes (auto) Raisonance RLink JTAG Programmer yes (auto) Olimex ARM-JTAG-EW Programmer yes (auto) CMSIS-DAP Compliant Debugger yes Nu-Link Programmer yes (auto) Cypress KitProg Programmer yes (auto) Altera USB-Blaster Compatible yes (auto) ASIX Presto Adapter yes (auto) OpenJTAG Adapter yes (auto) Linux GPIO bitbang through libgpiod no SEGGER J-Link Programmer yes (auto) Use Capstone disassembly framework yes (auto) (後略)スクリプトをホームディレクトリに保存し実行した場合、以下の様になります。
$ ls ~/OpenOCD capstone libconfuse libjaylink libusb-compat openocd-esp32 x86_64-w64-mingw32-build x86_64-w64-mingw32-root-esp32 hidapi libftdi libusb openocd v1.0.21.zip x86_64-w64-mingw32-root出来上がったOpenOCDをたとえばC:\Devz\OpenOCD以下に置く場合は、以下の様にします。
cd ~/OpenOCD cp -a x86_64-w64-mingw32-root/usr /mnt/c/Devz/OpenOCDwsl2から、openocd.exeを起動してみます。
$ PATH=/mnt/c/Devz/OpenOCD/bin:$PATH $ which openocd.exe /mnt/c/Devz/OpenOCD/bin/openocd.exe $ openocd.exe -f interface/stlink.cfg -f target/stm32f1x.cfg Open On-Chip Debugger 0.11.0-rc2+dev-00009-gba0f38213-dirty (2021-02-14-03:47) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html Info : auto-selecting first available session transport "hla_swd". To override use 'transport select追記:2020/02/14: OpenOCD for ESP32をたとえばC:\Devz\OpenOCD-ESP32以下に置く場合は、以下の様にします。'. Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD Info : Listening on port 6666 for tcl connections Info : Listening on port 4444 for telnet connections Info : clock speed 1000 kHz Info : STLINK V2J37S7 (API v2) VID:PID 0483:3748 Info : Target voltage: 3.240795 Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints Info : starting gdb server for stm32f1x.cpu on 3333 Info : Listening on port 3333 for gdb connections shutdown command invoked $ openocd.exe -f interface/cmsis-dap.cfg -f target/stm32f1x.cfg Open On-Chip Debugger 0.11.0-rc2+dev-00009-gba0f38213-dirty (2021-02-14-03:47) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html Info : auto-selecting first available session transport "swd". To override use 'transport select '. Info : Listening on port 6666 for tcl connections Info : Listening on port 4444 for telnet connections Info : CMSIS-DAP: SWD Supported Info : CMSIS-DAP: JTAG Supported Info : CMSIS-DAP: FW Version = 2.0.0 Info : CMSIS-DAP: Interface Initialised (SWD) Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1 Info : CMSIS-DAP: Interface ready Info : clock speed 1000 kHz Info : SWD DPIDR 0x1ba01477 Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints Info : starting gdb server for stm32f1x.cpu on 3333 Info : Listening on port 3333 for gdb connections shutdown command invoked $ openocd.exe -f interface/ft232r.cfg -f target/stm32f1x.cfg Open On-Chip Debugger 0.11.0-rc2+dev-00009-gba0f38213-dirty (2021-02-14-03:47) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html Info : only one transport option; autoselect 'jtag' adapter speed: 1000 kHz Info : Listening on port 6666 for tcl connections Info : Listening on port 4444 for telnet connections Info : clock speed 1000 kHz Info : JTAG tap: stm32f1x.cpu tap/device found: 0x3ba00477 (mfg: 0x23b (ARM Ltd), part: 0xba00, ver: 0x3) Info : JTAG tap: stm32f1x.bs tap/device found: 0x16410041 (mfg: 0x020 (STMicroelectronics), part: 0x6410, ver: 0x1) Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints Info : starting gdb server for stm32f1x.cpu on 3333 Info : Listening on port 3333 for gdb connections shutdown command invoked
cd ~/OpenOCD cp -a x86_64-w64-mingw32-root-esp32/usr /mnt/c/Devz/OpenOCD-ESP32OpenOCD for ESP32をWSL2から起動してみます。
$ PATH=/mnt/c/Devz/OpenOCD-ESP32/bin:$PATH $ which openocd.exe /mnt/c/Devz/OpenOCD-ESP32/bin/openocd.exe $ openocd.exe -f interface/cmsis-dap.cfg -c "adapter_khz 4000" -c "set ESP_RTOS none" -f board/esp-wroom-32.cfg Open On-Chip Debugger v0.10.0-esp32-20201202-14-gde9e630c-dirty (2021-02-15-03:49) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html adapter speed: 4000 kHz none WARNING: boards/esp-wroom-32.cfg is deprecated, and may be removed in a future release. Info : Listening on port 6666 for tcl connections Info : Listening on port 4444 for telnet connections Info : CMSIS-DAP: SWD Supported Info : CMSIS-DAP: JTAG Supported Info : CMSIS-DAP: FW Version = 2.0.0 Info : CMSIS-DAP: Interface Initialised (JTAG) Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 1 Info : CMSIS-DAP: Interface ready Info : clock speed 4000 kHz Info : cmsis-dap JTAG TLR_RESET Info : cmsis-dap JTAG TLR_RESET Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1) Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1) Info : esp32.cpu0: Debug controller was reset. Info : esp32.cpu0: Core was reset. Info : Listening on port 3333 for gdb connections Info : esp32.cpu0: Debug controller was reset.追記2021/02/21:wslから "openocd.exe" を起動している場合、telnet接続はwslからは接続できませんが、powershellからtelnet接続できます。Windowsのtelnetクライアントは"Windowsの機能の有効化または無効化"でインストールできます。 openocdのソースは、git cloneで2021/02現在のソースを使っていますので、他のバージョンではpatch部分が不要になったりCFLAGSの設定が変わるかもしれません。OpenOCD for ESP32のソースも同様です。なおFT232RをWindowsでデバッグプルーブとして使う場合、zadigでドライバをWinUSBにした場合、USB Comポートとしては使えなくなりますが、 (追記:2021/02/21)こちらのソフトをつかうと、シリアルドライバとWinUSBドライバの切り替えが比較的簡単にできます。 また、gpio bitbangを含めてすべての機能をつかうにはLinuxということになります。やはりlinuxは偉大ですね... 今回は以上です。それでは。
コメント
コメントを投稿