Build OpenOCD

http://www.openplug.org/plugwiki/index.php/Build_OpenOCD

Build OpenOCD

From PlugWiki

Jump to: navigation, search

1. OpenOCD Linux (version = 0.2.0)

a. Change to working directory (cd ~/work/)

b. Install libusb libraries: sudo aptitude install libusb-dev

c. Download libftdi library

  1) Download the open source from [1] 
  2) Unpack it to your working directory (tar -czf libftdi-0.16.tar.gz)

d. Build libftdi library

  1) Run the commands -
     a) cd libftdi-0.16
     b) ./configure --prefix=/usr
     c) make
     d) sudo make install

e. Download OpenOCD

  1) Change to working directory (cd ~/work/)
  2) Download open OCD from [2]

f. Build the OpenOCD

  1) Change to working directory (cd ~/work/openocd-<version>)
  2) Run the commands -
     a) ./configure --enable-ft2232_libftdi
     b) make
  5) You should have in the ~/work/openocd-<version>/src/ directory a binary named openocd.

OpenOCD Windows (version = 0.2.0)

a. Install Cygwin

 1) install Cygwin from: http://www.cygwin.com/setup.exe
 2) Select the install from internet
 3) Use default installation path: c:/cygwin
 4) Pick the Local Package Directory (this is the download cache directory)
 5) Select Direct Connection
 6) Select the mirror you want to use
 7) In the package selection click the plus sign on the left hand of the Devel category and install the
     following packages (by clicking the circled arrows till you see a check box in the Bin? column):
    1) gcc4
    2) make
    3) boost        (click on the Src checkbox too)
    4) libusb-win32 (click on the Src checkbox too)
    5) boost-devel  (click on the Src checkbox too)
     and press the Install button and then the Finish button
 8) For the above packages, Make sure that the boost directory is in the /usr/include directory

b. Cygwin working directory

 1) Create a Cygwin working directory; be sure not to place it in a path that includes spaces!
     (my example working path is C:/cygwin/work)
 2) From this point on, references to directories are from within Cygwin console (note that
     paths differ between windows file browser and Cygwin console)

c. Build libftdi support to OpenOCD

  1) Download the latest driver for windows from:
      [3]
  2) Unpack the libftdi-0.16.tar.gz file into C:/cygwin/work/libftdi-0.16
  3) Open the Cygwin console (via the desktop shortcut or start menu) and change directory to
      the work directory we created ($ cd /cygdrive/c/work)
  4) Run the commands -
     a) cd libftdi-0.16
     b) ./configure --prefix=/usr
  5) Edit the Makefile, change the following line:
     from: SUBDIRS = src bindings $(LIBFTDI_MODULES) examples doc
     to:   SUBDIRS = src bindings $(LIBFTDI_MODULES)
  6) Run the commands -
     d) make
     e) make install

d. Download OpenOCD

  There are two option to get the source:
  1) SVN snapshot:
     a. Open the Cygwin console (via the desktop shortcut or start menu) and change directory
         to the work directory we created ($ cd /cygdrive/c/work)
     b. Run the command        svn checkout svn://svn.berlios.de/openocd/trunk trunk
        If behind firewall try svn checkout http://svn.berlios.de/svnroot/repos/openocd/trunk
  2) Latest release based from [4]

e. Build the OpenOCD

  1) If svn based, rename the trunk directory to the version of OpenOCD you downloaded and change to that
      directory (/cygdrive/c/cygwin/work/openopcd-<version>)
  2) Open the Cygwin console
  3) Run the commands:
     a) export CFLAGS=-D__NO_INLINE__
     b) ./configure --enable-ft2232_libftdi --disable-werror
     c) Edit the Makefile, change the following line:
        from: SUBDIRS = src doc
        to:   SUBDIRS = src
     d) And run make
     e) You should have in the cygdrive/c/cygwin/work/trunk/src/ directory a binary named openocd.exe.

f. OpenOCD invocation can be done from Windows Dos (cmd), make sure the Cygwin libraries are in your PATH:

  1) Right click the My Computer and select the Properties
  2) Click on the Advanced tab
  3) Click on the Environment Variables button
  4) Click on the path variable and click on the Edit button
  5) Add to the Variable value path: ;c:/cygwin/bin/ and click the OK button all the way
  6) Now you can open a Dos window and openOCD should work for you
Visual Studio Code (VSCode) 配置 OpenOCD 主要是为了让 VSCode 能够调试支持 JTAG 接口的嵌入式芯片。以下是简单的步骤和配置: 1. 安装插件:首先,你需要安装 "C/C++ Extension Pack" 或者单独的 "OpenOCD Extension for Visual Studio Code" 插件。这两个插件都包含了对 OpenOCD 的集成支持。 2. 设置环境变量:确保你的系统里已经安装了 OpenOCD,并配置好其路径。在 VSCode 中,创建一个名为 ".vscode" 的文件夹(如果不存在就新建),然后在其中创建一个名为 "c_cpp_properties.json" 的文件,添加以下内容: ```json { "configurations": [ { "name": "Open OCD Debug", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/${fileDirname}/${fileNameWithoutExtension}.elf", // elf文件路径 "miDebuggerPath": "${env.OPENOCD_PATH}/bin/openocd", // OpenOCD可执行文件路径 "gdbServerMode": "server", "cwd": "${workspaceFolder}", "logging": { "engineLogging": true, "trace": true }, "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ] } ], "version": 4 } ``` 3. 指定设备:在上述配置中,`miDebuggerPath` 需要指向 OpenOCD 的 bin 文件夹,`setupCommands` 可能需要根据你的目标板型号和 OpenOCD 配置文件(如 `interface ftdi`、`target cortex-m` 等)做相应调整。 4. 创建启动任务:点击任务管理器(Tasks)图标,创建一个新的 C/C++ debug 任务,选择刚才配置好的 "Open OCD Debug"。 5. 运行调试:现在你可以直接从 VSCode 中启动调试任务,它会自动连接到 OpenOCD 并开始调试。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值