ubuntu18.04 安装JLinkOB驱动以及问题解决

ubuntu18.04 安装JLinkOB驱动以及问题解决

  • 安装方式
    • deb方式安装
    • 解压文件的方式安装
  • 解决问题
    • FAILED: Can not connect to J-Link via USB.
    • STM32 (connect): Can not attach to CPU. Trying connect under reset.

安装方式

  1. deb方式安装
  2. 解压文件方式安装(主要是在ARM板上安装时使用)

deb方式安装

在segger官网下载deb文件。
ubuntu18.04 安装JLinkOB驱动以及问题解决_第1张图片
这里有Windows、Mac、Linux各个系统的安装包,以及各个版本(需要下载以前的版本点击Older versions选择),根据自己使用的电脑系统选择,同时需要看一下自己电脑是32bit还是64位。Linux查看方法:

$ uname -a
Linux pan-pc 4.15.0-42-generic #45-Ubuntu SMP Thu Nov 15 19:32:57 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

我的电脑输出的是x86_64表示为64bit,如果输出i386就为32bit,下载对应的deb文件后通过sudo dpkg -i xxx.deb安装软件,xxx为刚刚下载软件时保存的名称。执行该命令后可以输入JLinkExe查看是否安装成功。

$ JLinkExe 
SEGGER J-Link Commander V5.12j (Compiled Jul 18 2016 18:53:43)
DLL version V5.12j, compiled Jul 18 2016 18:53:38

Connecting to J-Link via USB...O.K.
Firmware: J-Link ARM-OB STM32 compiled Aug 22 2012 19:52:04
Hardware version: V7.00
S/N: 20090928
License(s): RDI,FlashDL,FlashBP,JFlash,GDBFull
VTref = 3.300V

Type "connect" to establish a target connection, '?' for help
J-Link>

到目前为止,通过deb安装就安装完成了,不过可能会出现问题,最后介绍解决办法。

解压文件的方式安装

同样在segger官网上下载Jlink的驱动压缩包,图中最后一个即为ARM构建的压缩包。
ubuntu18.04 安装JLinkOB驱动以及问题解决_第2张图片下载后得到xxx.tgz文件,将该文件拷贝到运行在ARM板上的Linux系统中,然后通过tar -xvf xxx.tgz解压,得到相应的可执行文件。查看解压得到的Readme文件。

$ cat README.txt 

Requirements
============
libusb is no longer required.

Running JLinkExe (or J-Link via USB in general) with standard user rights
=========================================================================
In order to run JLinkExe with standard user rights you have to do the following:

- Copy the file "99-jlink.rules" provided with this J-Link software package 
  in the /etc/udev/rules.d/ directory using this command:
  
  sudo cp 99-jlink.rules /etc/udev/rules.d/
  
  Note: For older systems it might be necessary to replace the "ATTRS" calls in the 99-jlink.rules by "SYSFS" calls

- Restart your system

文件中描述应该向将99-Jlink.rules拷贝到/etc/udev/rules.d/中,添加可执行文件路径到PATH环境变量中,重启系统就可以执行JLinkExe命令了。

解决问题

FAILED: Can not connect to J-Link via USB.

前面描述的两种安装方式安装之后会出现FAILED: Can not connect to J-Link via USB.的情况。出现这个提示信息时首先应该检查Jlink是否已经连接到系统。

$ lsusb
Bus 002 Device 002: ID 8087:8000 Intel Corp. 
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:8008 Intel Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 018: ID 1366:0101 SEGGER J-Link PLUS
Bus 003 Device 004: ID 5986:0702 Acer, Inc 
Bus 003 Device 003: ID 8087:07dc Intel Corp. 
Bus 003 Device 005: ID 17ef:6050 Lenovo 
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

如果没有出现Bus 003 Device 018: ID 1366:0101 SEGGER J-Link PLUS类似的提示,说明JLink没有连接到电脑,此时应该检查USB线,JLink等。
如果出现了上述提示表示JLink已经连接到系统,接下来就可以修改/etc/udev/rules.d/99-jlink.rules文件,将里面的文件内容替换成:

SUBSYSTEM=="usb", ATTRS{idVendor}=="1366", ATTRS{idProduct}=="0101", MODE="664", GROUP="plugdev"

此时再执行JLinkExe:

$ JLinkExe 
SEGGER J-Link Commander V5.12j (Compiled Jul 18 2016 18:53:43)
DLL version V5.12j, compiled Jul 18 2016 18:53:38

Connecting to J-Link via USB...O.K.
Firmware: J-Link ARM-OB STM32 compiled Aug 22 2012 19:52:04
Hardware version: V7.00
S/N: 20090928
License(s): RDI,FlashDL,FlashBP,JFlash,GDBFull
VTref = 3.300V


Type "connect" to establish a target connection, '?' for help
J-Link>

提示Connecting to J-Link via USB...O.K.。如果未出现,重启一次系统。

STM32 (connect): Can not attach to CPU. Trying connect under reset.

$ JLinkExe 
SEGGER J-Link Commander V5.12j (Compiled Jul 18 2016 18:53:43)
DLL version V5.12j, compiled Jul 18 2016 18:53:38
Connecting to J-Link via USB...O.K.
Firmware: J-Link ARM-OB STM32 compiled Aug 22 2012 19:52:04
Hardware version: V7.00
S/N: 20090928
License(s): RDI,FlashDL,FlashBP,JFlash,GDBFull
VTref = 3.300V
Type "connect" to establish a target connection, '?' for help
J-Link>connect
Please specify device / core. : STM32F103VE
Type '?' for selection dialog
Device>
Please specify target interface:
  J) JTAG (Default)
  S) SWD
TIF>S
Specify target interface speed [kHz]. : 4000 kHz
Speed>
Device "STM32F103VE" selected.
STM32 (connect): Can not attach to CPU. Trying connect under reset.
****** Error: STM32: Connecting to CPU via connect under reset failed.
STM32 (connect): Can not attach to CPU. Trying connect under reset.
****** Error: STM32: Connecting to CPU via connect under reset failed.
STM32 (connect): Can not attach to CPU. Trying connect under reset.
****** Error: STM32: Connecting to CPU via connect under reset failed.
STM32 (connect): Can not attach to CPU. Trying connect under reset.
****** Error: STM32: Connecting to CPU via connect under reset failed.
Cannot connect to target.
J-Link>

出现这个问题找了半天,板子的供电等各方面都没问题,就是连不上,还怀疑是Jlink驱动的版本有问题,更换了好几个版本的驱动都没解决,最后找到问题是复位线的座子被氧化没有连接(复位线断路),找到问题后很快就解决了。

你可能感兴趣的:(STM32)