1. 程式人生 > >Centos下使用jlink下載、除錯stm32

Centos下使用jlink下載、除錯stm32

我下的 JLink_Linux_V634g_x86_64.rpm  (我的系統是64位),然後安裝之

rpm -ivh JLink_Linux_V634g_x86_64.rpm

安裝好之後就可以開啟終端,輸入 sudo  JLinkExe 回車,  這裡大小寫注意,最重要的是非root使用者前面要加sudo

否則報錯:  

Connecting to J-Link via USB...FAILED: Cannot connect to J-Link via USB. J-Link>

這種情況只能先退出jlink提示符,重新來過:

J-Link>exit

sudo JLinkExe

SEGGER J-Link Commander V6.34g(Compiled Sep 27 2018 18:11:40) DLL version V6.34g, compiled Sep 27 2018 18:11:29

Connecting to J-Link via USB...O.K. Firmware: J-Link V9 compiled Sep 26 2018 11:49:43 Hardware version: V9.40 S/N: xxxxxxxx License(s): RDI, GDB, FlashDL, FlashBP, JFlash VTref=3.333V

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

OK ,輸入 connect

J-Link>connect Please specify device / core. <Default>: STM32F042K6 Type '?' for selection dialog Device> Please specify target interface:   J) JTAG (Default)   S) SWD   T) cJTAG TIF>

上面輸入 connect 之後提示輸入device 型號,我以前輸入過 STM32F042K6,所以這裡回車預設

接下來選擇模擬器介面, 我用的SWD形式,則輸入S, 接下來速度也是採用預設值4000 kHz

TIF>S Specify target interface speed [kHz]. <Default>: 4000 kHz Speed> Device "STM32F042K6" selected.

Connecting to target via SWD Found SW-DP with ID 0x0BB11477 Found SW-DP with ID 0x0BB11477 Scanning AP map to find all available APs AP[1]: Stopped AP scan as end of AP map has been reached AP[0]: AHB-AP (IDR: 0x04770021) Iterating through AP map to find AHB-AP to use AP[0]: Core found AP[0]: AHB-AP ROM base: 0xE00FF000 CPUID register: 0x410CC200. Implementer code: 0x41 (ARM) Found Cortex-M0 r0p0, Little endian. FPUnit: 4 code (BP) slots and 0 literal slots CoreSight components: ROMTbl[0] @ E00FF000 ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 000BB008 SCS ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 000BB00A DWT ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 000BB00B FPB Cortex-M0 identified. J-Link>

來到這裡,已經識別到了晶片的架構,接下來就是下載燒寫檔案,執行等指令了

燒寫:

J-Link>r 回車             // 先復位

J-Link>Loadbin   /xx/xx/xx.hex   0x08000000   回車

J-Link>g 回車          //  執行

其他的如 h(停止執行),s(單步執行)等指令在網上都能找到,就不贅述了