ubuntu 编译安装 openocd(支持cmsis-dap)(转载)

The following post is a guide for compiling and installing a fresh copy of openOCD. This guide will go through the necessary steps to configure openOCD to support CMSIS-DAP devices. In order to do this we will need to first download and install HID API library.

We will also be going to the process of adding USB auto mount rules which will allow any user to access our board USB drivers without root privileges.

With regard to testing the install, we will be using the NUCLEO-F030R8 board to test the openOCD interface. However, for the exception of Freescale kinetis, you should be able to use any other supported debugger/programmer board.

Follow this link for the guide we’ve writting on installing Freescale’s version of OpenOCD which can be use on the kinetis devices.

NUCLEO-F030R8

 

Table Of Content 

 

Key Notes and Assumptions

Throughout this guide we will be using colour boxes to highlight terminal command and notes. This will make it easier for us to highlight useful information.

The following are the colour boxes keys:

Linux Terminal Commands

Interesting Notes

Warning Notes

 

Assumptions

sudo apt-get install

  • You are running Ubuntu 14.04 LTS and have confidence with terminal command.
  • Have access to root privileges.
  • You have OpenOCD compatible debugger and have install all necessary required drivers. For this example, I will be using FRDM-KL05Z
  • You have GIT installed.

Even those this guide assumes that you are running Ubuntu, any advance Linux user should be able to follow this guide and make the changes required to make it work on their prefer Linux OS.

Installing libraries and tools Dependency

Run the following commands on your terminal. this will install all the tools and library that we are going to need for openOCD and HIDAPI.

sudo apt-get install autotools-dev make libtool pkg-config autoconf automake texinfo libudev1 libudev-dev libusb-1.0-0-dev libfox-1.6-dev

Installing HIDAPI

Start by going to your home directory.

cd ~/

Now we are going to clone the hid api project.

git clone https://github.com/signal11/hidapi.git

Go into the hidapi directory.

cd hidapi/

We are going to run the botstrap and configuration script.

./bootstrap

./configure

We are going to run make and compiled the hid api.

make

Now that the project has been compiled. We can go ahead that install the hid api tool so that openOCD can use it. Will need to make sure that we run this command as root using sudo.

sudo make install

Now we are going to need to add the location of the hid libary into our system PATH variable. This will vary depeding on your setup, but for a clean Ubuntu setup this is what we need to do.

nano ~/.profile

Editing system PATH variable

At the bottom of .profile, add the following line.

PATH="$HOME/bin:/usr/local/lib:$PATH"

It should look like this.
Editing system PATH variable With changes

To save the file, press Ctrl+X then Press Y and finally to accept and exit the editor press Enter.

Inorder order to reload the system PATH variable, you will need to logout and back in of your user account. Then you should be able to see the new path in the system PATH variable when you run this echo command.

echo $PATH

Echo System PATH variable

And finally, will need to update our system shared libray cache by running the ldconfig command.

sudo ldconfig

Ok, now that we have the HID api inatall, we can go ahead and remove the hidapi folder.

cd ~/

sudo rm -R hidapi

Installing OpenOCD

Go to you home directory.

cd ~/

Clone the the git repository. This will create a folder called openocd.

git clone git://repo.or.cz/openocd.git

Go into this new folder.

cd openocd/

Now bootstrap and configure OpenOCD.

./bootstrap

./configure --enable-cmsis-dap --enable-jlink --enable-stlink --enable-ti-icdi

Note that “--enable-jlink”, “--enable-stlink” and “--enable-ti-icdi” are optional and aren’t needed for CMSIS-DAP to work.
the jlink enable the segger interface, stlink enable ST-Link interface for NXP devices and -ti-icdi enabled the interface for TI programmer.

Now compile and install openOCD into our system.

make

sudo make install

Now that openOCD is installed, we can go ahead and remove all of the source files and folders we’ve just created.

cd ~/

sudo rm -R openocd

Adding udev rule

At this point you might be able to use OpenOCD without any issue. However, chances are that you will face with this error message when you try to use OpenOCD on the terminal.

udev CMSIS Error Message

Assuming that you have your board connected, this is likely to be caused by the current user not having the right access permission to your board USB HID driver. You can verify this by running OpenOCD as root using sudo.

However, if we are planning on using OpenOCD with an IDE (for example Eclipse) or some other development environment, then to make our life a little easier we should add a system rule that will automatically mount the our board usb with an open permission so that any user can use it.

To do this, we need to first find out our board USB vendor and product id.
We can do this by running the USB list command. However, we may need to run this command a few times with and without the board connected to identify which of the USB devices listed belong to our board.

lsusb

You should get a message like this.

lsusb

These are two set of hexadecimal characters that you need to make a note of for your device.
lsusb - with lable

Using this command we are going to create a new udev rule for our USB device. This command will simply create a new text file in the udev rule.d folder which will be invoked when ever out board is connected.

sudo nano /etc/udev/rules.d/CMSIS.rules

linux CMSIS rules nano

Type in the following lines into the new file. Make sure that you replace the idVendor and idProduct hexadecimal values between the double quotes with the ones that you noted earlier.

KERNEL=="hidraw*", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", MODE="0666"
SUBSYSTEM=="usb_device", ATTRS{idVendor}=="0483", MODE="0666"

CMSIS udev Rule STM32

To save the file, press Ctrl+X. Then Press Y and to accept and exit the editor press Enter.

You will need to reboot your computer for the new changes to take effect but apart from that you are ready to start using OpenOCD.

Test OpenOCD

This section will go run through quick test to verify our setup. We will simply check that OpenOCD is working by getting it to connect to our board via CMSIS-DAP interface using the NUCLEO configuration file.

Connect the board to the computer and then run this command. This command gets the newly installed OpenOCD to connection to our board using the configuration file we given it. In this case, we are using st_nucleo_f0.cfg.

openocd -f /usr/local/share/openocd/scripts/board/st_nucleo_f0.cfg

You should get the following terminal message. Notice the lines where it says INFO, it tell you the type of board connected, the target voltage and even the number of supported breakpoints.

openOCD termonal test ouput

To exit this program, you can press Ctrl+C.

That is it, you are now ready to use openOCD in your next project.

Useful To Know

While I’ve been developing with openOCD, I have collected some useful information that might save you some time if you ever needed it.

/usr/local/bin/openocd

/usr/local/share/openocd/scripts

  • openOCD install directory
  • openOCD configuration files (target, board and cpu)

Are you looking for help?

If you are having issues with your project or are looking for some advice to get your next project started then feel free to contact us. We can provide a bespoke services that suite your needs.

Alternatively, if you are new to electronics and are interesting in learning more about developing your own embedded software and hardware then Contextual electronics is the perfect place to go to. its a pay service that I am part of that provides an apprenticeship style of teaching. You can work at your own pace and have access to any of the instructors for help you may need for your projects.

  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
nanoDAP-wl 是实验室推出的基于cmsis-dap的无线调试器,即插即用,速度快,支持虚拟串口。无线调试器包括发射机/接收机,基于2.4G无线通信,可对10m范围内的目标进行调试下载、单步调试等操作,在某些有线仿真器不便调试的场景,如目标始终处于移动状态(飞行器、小车、机器人等),目标已经组装成产品形态,并且已安装在墙上或者高处等。此时使用无线调试器能较好的解决这些场景下调试问题,有效提高研发效率。 产品特点 使用极简,PC端无需安装额外软件,只需将发射机和接收器分别上电,等待连接成功,即可开始调试 支持SWD协议,典型的基于ARM Cortex-M系列芯片均支持SWD调试,常见的芯片如STM32系列,GD32系列,ATMEL-SAM系列,NORDIC-NRF51/52系列,NXP-LPC系列等芯片均支持SWD调试下载 支持JTAG协议,配合开源调试器OpenOCD支持全球范围内几乎所有SoC芯片的调试,如ARM Cortex-A系列、DSP、FPGA、MIPS等,因为SWD协议只是ARM自己定义的私有协议,而JTAG则是国际IEEE 1149标准 支持虚拟串口,而且支持同时进行仿真调试和串口输出 接收机支持向目标板供电(5V、3.3V),以及从目标板取电(5V、3.3V)两种方式进行工作 支持MDK/IAR/OpenOCD支持Windows/Linux/Mac 下进行调试开发 软件基于CMSIS-DAP实现,使用USB HID协议,无需安装驱动即可下载调试 v1.0版本硬件开源、固件开放,可供爱好者自行制作 使用场景用于调试飞行器,小车,机器人,由于调试目标为通常处于移动状态,若使用传统下载器不仅下载比较麻烦,而且无法进行单步调试。 目标板已经组装好外壳,成为产品形态,此时传统的有线方式不便调试。 产品安装在高处,如路灯、高塔等位置,此时使用有线方式不便调试。 产品链接(见附件) 说明 nanoDAP-wl v1.0 版本硬件开源,供爱好者自行制作研究。 固件针对个人开放,请大家加入QQ群 698319017 向群主索取。 更多信息 更多详情,用户手册和原理图等,请在https://github.com/wuxx/nanoDAP-wireless查看。 感兴趣的朋友请加入QQ群 698319017 研究讨论学习。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值