單片機MCU的價格不斷下降內含Flash與RAM,開發的工具也越來越成熟與穩定,隨著IOT興起推動MCU的熱潮!!!
手上剛好有一片STM32F407的核心板子,正好可以進入ARM 32bits MCU的世界。
STM32系列是很廣泛被使用在各領域的MCU,內含Cotex-M1到M7的ARM 32bits CPU,是值得深入學習的晶片系列。
在淘寶買到的核心板與Jtag
單片機
MCU
的價格不斷下降內含Flash
與RAM
,開發的工具也越來越成熟與穩定,隨著IOT興起推動MCU的熱潮!!!
手上剛好有一片
STM32F407
的核心板子,正好可以進入ARM 32bits MCU
的世界。
STM32系列是很廣泛被使用在各領域的MCU,內含
Cotex-M1
到M7的ARM 32bits CPU,是值得深入學習的晶片系列。在淘寶買到的核心板與Jtag
<zu’zh
OpenOCD 安裝 installation
Regis-MacPro:~ regis$ brew update
Already up-to-date.
Regis-MacPro:~ regis$ brew install openocd
結果
==> Installing dependencies for open-ocd: libusb, libusb-compat, libftdi, hidapi
==> Installing open-ocd dependency: libusb
==> Downloading https://homebrew.bintray.com/bottles/libusb-1.0.22.high_sierra.b
######################################################################## 100.0%
==> Pouring libusb-1.0.22.high_sierra.bottle.tar.gz
🍺 /usr/local/Cellar/libusb/1.0.22: 29 files, 514.8KB
==> Installing open-ocd dependency: libusb-compat
==> Downloading https://homebrew.bintray.com/bottles/libusb-compat-0.1.5_1.high_
######################################################################## 100.0%
==> Pouring libusb-compat-0.1.5_1.high_sierra.bottle.tar.gz
🍺 /usr/local/Cellar/libusb-compat/0.1.5_1: 14 files, 94.3KB
==> Installing open-ocd dependency: libftdi
==> Downloading https://homebrew.bintray.com/bottles/libftdi-1.4.high_sierra.bot
######################################################################## 100.0%
==> Pouring libftdi-1.4.high_sierra.bottle.1.tar.gz
🍺 /usr/local/Cellar/libftdi/1.4: 19 files, 164.3KB
==> Installing open-ocd dependency: hidapi
==> Downloading https://homebrew.bintray.com/bottles/hidapi-0.8.0-rc1.high_sierr
######################################################################## 100.0%
==> Pouring hidapi-0.8.0-rc1.high_sierra.bottle.2.tar.gz
🍺 /usr/local/Cellar/hidapi/0.8.0-rc1: 17 files, 131.2KB
==> Installing open-ocd
==> Downloading https://homebrew.bintray.com/bottles/open-ocd-0.10.0.high_sierra
######################################################################## 100.0%
==> Pouring open-ocd-0.10.0.high_sierra.bottle.1.tar.gz
🍺 /usr/local/Cellar/open-ocd/0.10.0: 632 files, 4.7MB
接上 J-Link Jtag
首先,尋找
interface\
是否有J-Link
的設定檔。但是,如何找到這個interface\
的folder?
sudo find / |grep interface/jlink.cfg
出現在這裡!!!
/usr/local/Cellar/open-ocd/0.10.0/share/openocd/scripts/interface/jlink.cfg
再來就下命令來連上
STM32F4核心板
Regis-MacPro:50_openocd regis$ openocd -f interface/jlink.cfg -f target/stm32f4x.cfg
結果成功透過
J-Link
連上STM32F4核心板
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
jtag_ntrst_delay: 100
none separate
cortex_m reset_config sysresetreq
Info : No device selected, using first device.
Info : J-Link V9 compiled Jun 2 2222 22:22:22
Info : Hardware version: 9.40
Info : VTarget = 3.192 V
Info : clock speed 2000 kHz
Info : JTAG tap: stm32f4x.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x4)
Info : JTAG tap: stm32f4x.bs tap/device found: 0x06413041 (mfg: 0x020 (STMicroelectronics), part: 0x6413, ver: 0x0)
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
到這裡就成功把OpenOCD執行,並開通port 4444接收telnet來連線執行命令。
測試 Test
打開另一個terminal終端,輸入以下telnet指令
telnet localhost 4444
出現
Open On-Chip Debugger
,表示連上
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
> poll
background polling: on
TAP: stm32f4x.cpu (enabled)
用
help
指令了解更多> help
adapter_khz [khz]
With an argument, change to the specified maximum jtag speed. For
JTAG, 0 KHz signifies adaptive clocking. With or without argument,
display current setting. (command valid any time)
adapter_name
Returns the name of the currently selected adapter (driver) (command
valid any time)
adapter_nsrst_assert_width [milliseconds]
delay after asserting SRST in ms (command valid any time)
adapter_nsrst_delay [milliseconds]
delay after deasserting SRST in ms (command valid any time)
add_help_text command_name helptext_string
Add new command help text; Command can be multiple tokens. (command
valid any time)
add_script_search_dir <directory>
dir to search for config files and scripts (command valid any time)
add_usage_text command_name usage_string
Add new command usage text; command can be multiple tokens. (command
valid any time)
arm
ARM command group (command valid any time)
arm core_state ['arm'|'thumb']
display/change ARM core state
arm disassemble address [count ['thumb']]
disassemble instructions
arm mcr cpnum op1 CRn CRm op2 value
write coprocessor register
arm mrc cpnum op1 CRn CRm op2
read coprocessor register
arm reg
display ARM core registers
arm semihosting ['enable'|'disable']
activate support for semihosting operations
arm semihosting_fileio ['enable'|'disable']
activate support for semihosting fileio operations
array2mem arrayname bitwidth address count
convert a TCL array to memory locations and write the 8/16/32 bit
values
bindto [name]
Specify address by name on which to listen for incoming TCP/IP
connections (command valid any time)
bp <address> [<asid>]<length> ['hw'|'hw_ctx']
list or set hardware or software breakpoint
command
core command group (introspection) (command valid any time)
command mode [command_name ...]
Returns the command modes allowed by a command:'any', 'config', or
'exec'. If no command isspecified, returns the current command
mode. Returns 'unknown' if an unknown command is given. Command
can be multiple tokens. (command valid any time)
command type command_name [...]
Returns the type of built-in command:'native', 'simple', 'group',
or 'unknown'. Command can be multiple tokens. (command valid any
time)
cortex_m
Cortex-M command group
cortex_m maskisr ['auto'|'on'|'off']
mask cortex_m interrupts
cortex_m reset_config ['srst'|'sysresetreq'|'vectreset']
configure software reset handling (command valid any time)
cortex_m vector_catch ['all'|'none'|('bus_err'|'chk_err'|...)*]
configure hardware vectors to trigger debug entry
dap
DAP command group
dap apcsw [sprot]
Set csw access bit
dap apid [ap_num]
return ID register from AP (default currently selected AP)
dap apreg ap_num reg [value]
read/write a register from AP (reg is byte address of a word
register, like 0 4 8...)
dap apsel [ap_num]
Set the currently selected AP (default 0) and display the result
dap baseaddr [ap_num]
return debug base address from MEM-AP (default currently selected
AP)
dap info [ap_num]
display ROM table for MEM-AP (default currently selected AP)
dap memaccess [cycles]
set/get number of extra tck for MEM-AP memory bus access [0-255]
dap ti_be_32_quirks [enable]
set/get quirks mode for TI TMS450/TMS570 processors (configuration
command)
debug_level number
Sets the verbosity level of debugging output. 0 shows errors only; 1
adds warnings; 2 (default) adds other info; 3 adds debugging.
(command valid any time)
drscan tap_name [num_bits value]* ['-endstate' state_name]
Execute Data Register (DR) scan for one TAP. Other TAPs must be in
BYPASS mode.
dump_image filename address size
echo [-n] string
Logs a message at "user" priority. Output message to stdout. Option
"-n" suppresses trailing newline (command valid any time)
exit
exit telnet session
fast_load
loads active fast load image to current target - mainly for profiling
purposes
fast_load_image filename address ['bin'|'ihex'|'elf'|'s19'] [min_address [max_length]]
Load image into server memory for later use by fast_load; primarily
for profiling (command valid any time)
find <file>
print full path to file according to OpenOCD search rules (command
valid any time)
flash
NOR flash command group (command valid any time)
flash bank bank_id driver_name base_address size_bytes chip_width_bytes
bus_width_bytes target [driver_options ...]
Define a new bank with the given name, using the specified NOR
flash driver. (configuration command)
flash banks
Display table with information about flash banks. (command valid
any time)
flash erase_address ['pad'] ['unlock'] address length
Erase flash sectors starting at address and continuing for length
bytes. If 'pad' is specified, data outside that range may also be
erased: the start address may be decreased, and length increased,
so that all of the first and last sectors are erased. If 'unlock'
is specified, then the flash is unprotected before erasing.
flash erase_check bank_id
先到這裡,下次再研究深入些。
沒有留言:
張貼留言