裸机程序一:Ubuntu、Mac OS、Windows下EasyOpenJTAG+OpenOCD的安装和使用

来源:互联网 发布:深入理解java反射机制 编辑:程序博客网 时间:2024/05/16 09:33

操作系统:  VMware fusion + Ubuntu 16.04.1 LTS

    开发板:  JZ2440 V3 + EasyOpenJTAG

 参考资料:《Eclipse,OpenOCD,OpenJTAG 嵌入式开发教程》

   《OpenOCD User’s Guide》

   《关于OpenOCD的安装配置(以mini2440+OpenJTAG为例)》

           《Ubuntu下配置OpenOCD+FT2232

           《在Ubutu14.04,如何用OpenJTAG+OPENOCD烧写程序》

《如何烧写S3C2440裸板程序》

一、OpenJTAG、OpenOCD简介

OpenJTag是一个开源项目(包含软件和硬件)。
硬件是一个USB接口转JTag接口的适配器。
借助开源软件OpenOCD可以完成程序的烧写,调试等任务
OpenJTag的功能:
1. 往Flash烧写程序: 支持NOR Flash 和 NAND Flash
2. 支持Windows以及Linux
3. 能够用在支持GDB调试协议的工具上: 如IAR, Eclipse
4. USB转串口功能

开发板和OpenJTAG的连接方式:

二、Ubuntu下安装OpenOCD


安装libftdiftdi-eeprom

下载地址http://www.intra2net.com/en/developer/libftdi/download.php

1、下载confuse-2.5.tar.gz  libftdi1-1.3.tar.bz2并解压:

root@ubuntu:/work/tmp# ls /mnt/hgfs/jz2440/download/confuse-2.5.tar.gz  libftdi1-1.3.tar.bz2root@ubuntu:/work/tmp# tar -jxvf /mnt/hgfs/jz2440/download/libftdi1-1.3.tar.bz2 -C ./root@ubuntu:/work/tmp# tar -zxvf /mnt/hgfs/jz2440/download/confuse-2.5.tar.gz -C ./

2、安装libftdi,参考源码目录下的README.build:

root@ubuntu:/work/tmp/libftdi1-1.3# mkdir build; cd build:root@ubuntu:/work/tmp/libftdi1-1.3# cmake  -DCMAKE_INSTALL_PREFIX="/usr" ../; make; sudo make install


3、安装ftdi-eeprom,参考源码目录下的INSTALL

root@ubuntu:/work/tmp# cd confuse-2.5/; ./configure; make; make install

安装OpenOCD

1、下载OpenOCD

root@ubuntu:/work/tmp# git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd

2、编译并安装,请参考源码目录下的README.build

root@ubuntu:/work/tmp/openocd# ./bootstrap
root@ubuntu:/work/tmp/openocd# ./configure --enable-ftdiroot@ubuntu:/work/tmp/openocd# make; make install

编译后的版本为:

root@ubuntu:/work/tmp/openocd# openocd -vOpen On-Chip Debugger 0.10.0-dev-00371-g81631e4 (2016-09-11-18:21)Licensed under GNU GPL v2For bug reports, readhttp://openocd.org/doc/doxygen/bugs.html


3、增加udev规则,以便使用普通用户权限操作调试器。root权限创建/etc/udev/rules.d/45-openjtag.rules(文件名可以换成别的):

SYSFS{idProduct}=="5118", SYSFS{idVendor}=="1457", MODE="666", GROUP="plugdev"

4、添加OpenOCD配置文件openocd.cfg:

interface ftdi#通过描述来指定设备,应当和dmesg中的Product一致#ftdi_device_desc "USB<=>JTAG&RS232"#通过PID VID指定调试器,比描述更准确些ftdi_vid_pid 0x1457 0x5118#如果有多个同样的调试器,还可以指定要使用的调试器序列号#ftdi_serial#引脚定义,相当于旧版中的 ft2232_layout jtagkeyftdi_layout_init 0x0c08 0x0f1bftdi_layout_signal nTRST -data 0x0100 -noe 0x0400ftdi_layout_signal nSRST -data 0x0200 -noe 0x0800# 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 chainjtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0x0f -expected-id $_CPUTAPID##jtag_rclk 3000adapter_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 0#arm7_9 fast_memory_access enableset _TARGETNAME $_CHIPNAME.cputarget create $_TARGETNAME arm920t -chain-position $_TARGETNAME$_TARGETNAME configure -work-area-phys 0x00200000 \-work-area-size 0x4000 -work-area-backup 0#reset configurationreset_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:首先将EasyOpenJTAG USB连接至PC,然后开发板上电,最后在和配置文件openocd.cfg相同目录执行openocd

root@ubuntu:~# openocd Open On-Chip Debugger 0.10.0-dev-00371-g81631e4 (2016-09-11-22:15)Licensed under GNU GPL v2For bug reports, readhttp://openocd.org/doc/doxygen/bugs.htmlInfo : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.adapter speed: 1234 kHztrst_and_srst separate srst_gates_jtag trst_push_pull srst_open_drain connect_deassert_srstInfo : clock speed 1234 kHzInfo : JTAG tap: s3c2440.cpu tap/device found: 0x0032409d (mfg: 0x04e (Samsung), part: 0x0324, ver: 0x0)Info : Embedded ICE version 2Info : s3c2440.cpu: hardware has 2 breakpoint/watchpoint units

可以看到设备已经识别成功

三、Mac OS下安装OpenOCD

在mac os下安装openocd只需要执行命令:

brew install openocd

注:brew类似于apt-get,是Mac下一个常见的软件管理工具,需要自己安装:
cd ~ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

四、Windows下安装OpnOCD

首先是安装Windows下的驱动程序,然后安装01.OpenOCD with GUI setup.exe即可,参考《如何烧写S3C2440裸板程序》安装即可

五、使用OpenOCD烧录裸机程序

                                             
0 0
原创粉丝点击