首页 > 代码库 > 在Ubutu14.04下,如何用OpenJTAG+OPENOCD烧写程序
在Ubutu14.04下,如何用OpenJTAG+OPENOCD烧写程序
OPENOCD INSTALL
一:安装openocd:
cd /path/you/install/openocd
(1) 通过 git 获取openocd
git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd
(2)源码编译安装
sudo apt-get install autoconf
./bootstrap
(3) 驱动安装
sudo apt-get install libftdi-dev libftdi1 libtool git-core asciidoc
./configure --help
./configure --enable-maintainer-mode --enable-usb_blaster_libftdi --enable-openjtag_ftdi
make
make install
输出版本信息
openocd -v
Open On-Chip Debugger 0.9.0-dev-00251-g1fa4c72 (2015-01-30-19:44)
Licensed under GNU GPL v2For bug reports, read
http://openocd.sourceforge.net/doc/doxygen/bugs.html
二:配置openocd.cfg
参考百问网的配置修改
# # 100ASK OpenJTAG # # http://www.100ask.net # # modified by xnus 2015 # interface ft2232 ft2232_device_desc "USB<=>JTAG&RS232" ft2232_layout jtagkey ft2232_vid_pid 0x1457 0x5118 # Target configuration for the Samsung 2440 system on chip # Tested on a S3C2440 Evaluation board by keesj # Processor : ARM920Tid(wb) rev 0 (v4l) # Info: JTAG tap: s3c2440.cpu tap/device found: 0x0032409d (Manufacturer: 0x04e, Part: 0x0324, Version: 0x0) if { [info exists CHIPNAME] } { set _CHIPNAME $CHIPNAME } else { set _CHIPNAME s3c2440 } if { [info exists ENDIAN] } { set _ENDIAN $ENDIAN } else { # this defaults to a bigendian set _ENDIAN little } if { [info exists CPUTAPID ] } { set _CPUTAPID $CPUTAPID } else { # force an error till we get a good number set _CPUTAPID 0x0032409d } #jtag scan chain jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0x0f -expected-id $_CPUTAPID # #jtag_rclk 3000 adapter_khz 1234 set _TARGETNAME $_CHIPNAME.cpu target create $_TARGETNAME arm920t -endian $_ENDIAN -chain-position $_TARGETNAME -variant arm920t $_TARGETNAME configure -work-area-phys 0x200000 -work-area-size 0x4000 -work-area-backup 1 arm7_9 fast_memory_access enable #reset configuration reset_config trst_and_srst #Flash CFG<openocd.pdf P[74~] #flash bank name driver base size chip_width bus_width target [driver_options] #usage: flash bank <name> <driver> <base> <size> <chip_width> <bus_width> <target> #flash bank bank_id driver_name base_address size_bytes chip_width_bytes bus_width_bytes target [driver_options ...] flash bank 0 cfi 0x0 0x200000 2 2 $_TARGETNAME #NAND CFG <openocd.pdf P[88~92]> #nand device name driver target [ configparams... ] nand device 0 s3c2440 $_TARGETNAME
大家可以到这个网站下载openocd.pdf以便参考。
三:启动OpenOCD
将开发板连接的OpenJTAG的USB端口接入PC,终端输入openocd
xnus@xnus-P43E:~$openocd
Open On-Chip Debugger 0.8.0 (2015-01-30-21:54)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.sourceforge.net/doc/doxygen/bugs.html
Info : only one transport option; autoselect ‘jtag‘
adapter speed: 1234 kHz
fast memory access is enabled
trst_and_srst separate srst_gates_jtag trst_push_pull srst_open_drain connect_deassert_srst
Warn : Using DEPRECATED interface driver ‘ft2232‘
Info : Consider using the ‘ftdi‘ interface driver, with configuration files in interface/ftdi/...
Info : clock speed 1200 kHz
Info : JTAG tap: s3c2440.cpu tap/device found: 0x0032409d (mfg: 0x04e, part: 0x0324, ver: 0x0)
Info : Embedded ICE version 2
Info : s3c2440.cpu: hardware has 2 breakpoint/watchpoint units
四:启动telnet
xnus@xnus-P43E:~$ telnet localhost 4444
Trying 127.0.0.1...
Connected to localhost.
Escape character is ‘^]‘.
Open On-Chip Debugger
> halt
target state: halted
target halted in ARM state due to debug-request, current mode: Supervisor
cpsr: 0x900000d3 pc: 0x004f1c8c
MMU: disabled, D-Cache: disabled, I-Cache: disabled
>nand probe 0
NAND flash device ‘NAND 256MiB 3.3V 8-bit (Samsung)‘ found
>load_image /home/xnus/Downloads/leds.bin 0x0
136 bytes written at address 0x00000000
downloaded 136 bytes in 0.275141s (0.483 KiB/s)
> resume 0x0
可以看到灯开始闪烁了(注意,应设置为NAND启动)
GOODLUCK
在Ubutu14.04下,如何用OpenJTAG+OPENOCD烧写程序