折腾rp2040的时候要用下openocd, 官方的不能用,于是自己想要编译一个, 搞了cygwin和mingw的编译环境, 编译未果, 后面还是借用了官方的编译方式, 具体如下

官方方法如下:
https://github.com/xpack-dev-tools/openocd-xpack/blob/xpack/README-DEVELOPER.md

过程:

  1. 环境准备,windows 机器上需要配置docker和wsl
  2. 下载编译脚本, 这里可以checkout 不同版本的openocd-xpack来获取响应的配套编译环境
rm -rf ~/Downloads/openocd-xpack.git; \
git clone \
  --recurse-submodules \
  https://github.com/xpack-dev-tools/openocd-xpack.git \
  ~/Downloads/openocd-xpack.git
  1. 编译编译需要的docker image
 bash ~/Downloads/openocd-xpack.git/scripts/build.sh preload-images
  1. 替换编译rp2040需要的仓库地址
diff --git a/scripts/defs-source.sh b/scripts/defs-source.sh
index 2487d58..f19131e 100644
--- a/scripts/defs-source.sh
+++ b/scripts/defs-source.sh
@@ -42,6 +42,6 @@ COMMON_APPS_FUNCTIONS_SCRIPT_NAME=${COMMON_APPS_FUNCTIONS_SCRIPT_NAME:-"common-a
 # than the xPack Project repo then uncomment the following defines and tweak
 # as needed.

-# OPENOCD_GIT_URL=git://git.code.sf.net/p/openocd/code
-# OPENOCD_GIT_BRANCH=master
-# OPENOCD_GIT_COMMIT=HEAD
+OPENOCD_GIT_URL=https://github.com/raspberrypi/openocd
+OPENOCD_GIT_BRANCH=rp2040
+#OPENOCD_GIT_COMMIT=HEAD
  1. 编译需要的windows下的程序
bash ~/Downloads/openocd-xpack.git/scripts/build.sh --win64 --win32

编译结束后编译的结果会出现在

 ~/Work/openocd-*/deploy

copy 出来就能用了

其他參考資料:
https://shawnhymel.com/2168/how-to-build-openocd-and-picotool-for-the-raspberry-pi-pico-on-windows/

Logo

更多推荐