看到J-Link官网上有ARM linux 上的烧录软件, 于是想用树莓派做主机来给产品烧录固件,于是新买了一个J-Link V8,从https://www.segger.com/downloads/jlink下载了JLink_Linux_V600i_arm.tgz, 把它放到树莓派上解压,这里就放下~目录下,新建一个jlink一个文件夹,把下载下来的文件放到里面解压:
1 |
pi@raspberrypi:~/jlink $ tar zxvf JLink_Linux_V600i_arm.tgz |
进入解压后的文件夹,看到有个README.txt, 先打看瞄瞄,原来为了让标准权根用户也可以用,要把一个文件放到指定文件夹,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
pi@raspberrypi:~/jlink $ cd JLink_Linux_V600i_arm pi@raspberrypi:~/jlink/JLink_Linux_V600i_arm $ 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 |
于是照做,然后重启:
1 2 |
pi@raspberrypi:~/jlink/JLink_Linux_V600i_arm $ sudo cp 99-jlink.rules /etc/udev/rules.d/ pi@raspberrypi:~/jlink/JLink_Linux_V600i_arm $ sudo init 6 |
重启后, 第一次运行./JLinkExe, 发现固件会自动升级, 后面第二次运行就没有升级了:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
pi@raspberrypi:~/jlink/JLink_Linux_V600i_arm $ ./JLinkExe SEGGER J-Link Commander V6.00i (Compiled Sep 2 2016 19:28:33) DLL version V6.00i, compiled Sep 2 2016 19:28:11 Connecting to J-Link via USB...Updating firmware: J-Link ARM V8 compiled Nov 28 2014 13:44:46 <strong>Replacing firmware: J-Link ARM V8 compiled Dec 1 2009 11:42:48 Waiting for new firmware to boot New firmware booted successfully O.K.</strong> Firmware: J-Link ARM V8 compiled Nov 28 2014 13:44:46 Hardware version: V8.00 S/N: xxxxxxxxx License(s): RDI,FlashDL,FlashBP,JFlash,GDBFULL VTref = 3.351V Type "connect" to establish a target connection, '?' for help J-Link>q pi@raspberrypi:~/jlink/JLink_Linux_V600i_arm $ ./JLinkExe SEGGER J-Link Commander V6.00i (Compiled Sep 2 2016 19:28:33) DLL version V6.00i, compiled Sep 2 2016 19:28:11 Connecting to J-Link via USB...O.K. Firmware: J-Link ARM V8 compiled Nov 28 2014 13:44:46 Hardware version: V8.00 S/N: xxxxxxxxx License(s): RDI,FlashDL,FlashBP,JFlash,GDBFULL VTref = 3.351V Type "connect" to establish a target connection, '?' for help J-Link>q |
S/N:一行做了处理,用xxxxxxxxx代替
看了2天的文档,终于知道如何只用一个命令完成烧录了。 新建一个文件1.sh, 写入以下内容,保存在跟JLinkExe同一个目录下,在调用JLinkExe时指定将烧录的芯片, 手头上刚好有上次做的小项目用到的STM32F103C8T6, 查了一下支持列表里只有STM32F103C8,就写成这个了。同时指定打开JLinkExe打开后要执行的命令脚本,随意写成了1.jlink.
1.sh文件:
1 2 |
#!/bin/bash ./JLinkExe -device STM32F103C8 -CommanderScript 1.jlink |
1.jlink文件:
1 2 3 4 5 |
si swd speed 4000 erase loadbin short_scanner.bin 0x08000000 SWDSelect qc |
这些是在下载的压缩包,解压后的JLink_Linux_V600i_arm/Doc/UM08001_JLink.pdf文件里找到的说明,89页:
然后给1.sh添加可执行权限, 就可以执行了,执行完后程就可以运行来下载程序到芯片上了:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
pi@raspberrypi:~/jlink/JLink_Linux_V600i_arm $ chmod +x 1.sh pi@raspberrypi:~/jlink/JLink_Linux_V600i_arm $ ./1.sh SEGGER J-Link Commander V6.00i (Compiled Sep 2 2016 19:28:33) DLL version V6.00i, compiled Sep 2 2016 19:28:11 Script file read successfully. Processing script file... J-Link connection not established yet but required for command. Connecting to J-Link via USB...O.K. Firmware: J-Link ARM V8 compiled Nov 28 2014 13:44:46 Hardware version: V8.00 S/N: 304423265 License(s): RDI,FlashDL,FlashBP,JFlash,GDBFULL VTref = 3.338V Selecting SWD as current target interface. Selecting 4000 kHz as target interface speed Target connection not established yet but required for command. Device "STM32F103C8" selected. Found SWD-DP with ID 0x1BA01477 Found SWD-DP with ID 0x1BA01477 AP-IDR: 0x14770011, Type: AHB-AP Found Cortex-M3 r1p1, Little endian. FPUnit: 6 code (BP) slots and 2 literal slots CoreSight components: ROMTbl 0 @ E00FF000 ROMTbl 0 [0]: FFF0F000, CID: B105E00D, PID: 001BB000 SCS ROMTbl 0 [1]: FFF02000, CID: B105E00D, PID: 001BB002 DWT ROMTbl 0 [2]: FFF03000, CID: B105E00D, PID: 000BB003 FPB ROMTbl 0 [3]: FFF01000, CID: B105E00D, PID: 001BB001 ITM ROMTbl 0 [4]: FFF41000, CID: B105900D, PID: 001BB923 TPIU-Lite Cortex-M3 identified. Erasing device (STM32F103C8)... Comparing flash [100%] Done. Erasing flash [100%] Done. Verifying flash [100%] Done. J-Link: Flash download: Total time needed: 1.456s (Prepare: 0.038s, Compare: 0.000s, Erase: 1.411s, Program: 0.000s, Verify: 0.000s, Restore: 0.006s) Erasing done. Downloading file [short_scanner.bin]... Comparing flash [100%] Done. Erasing flash [100%] Done. Programming flash [100%] Done. Verifying flash [100%] Done. J-Link: Flash download: Flash programming performed for 1 range (24576 bytes) J-Link: Flash download: Total time needed: 0.803s (Prepare: 0.067s, Compare: 0.024s, Erase: 0.024s, Program: 0.654s, Verify: 0.001s, Restore: 0.031s) O.K. Script processing completed. pi@raspberrypi:~/jlink/JLink_Linux_V600i_arm $ |
可以看到烧录过程只要几秒钟,看来树莓派做这事还是蛮快的哈!上个合照:
再记录一下系统版本信息,感觉明年4代的树莓派,系统可能会上64位。
1 2 3 4 5 6 7 8 9 10 11 |
pi@raspberrypi:~ $ cat /etc/issue Raspbian GNU/Linux 8 \n \l pi@raspberrypi:~ $ lsb_release -a No LSB modules are available. Distributor ID: Raspbian Description: Raspbian GNU/Linux 8.0 (jessie) Release: 8.0 Codename: jessie pi@raspberrypi:~ $ uname -a Linux raspberrypi 4.1.19-v7+ #858 SMP Tue Mar 15 15:56:00 GMT 2016 armv7l GNU/Linux |
最后加几个链接:
J-Link官网:https://www.segger.com/downloads/jlink
有关于arm的不错链接: http://www.21ic.com/jszt/arm.htm
gdb: https://sourceware.org/gdb/current/onlinedocs/gdb/