2015年5月12日 星期二

Use J-Link to Program NOR Flash of ARM11 (OpenOCD)

Buy a J-Link debugger first.

Use the official J-Flash can program the NOR flash by JTAG, but the speed is too slow.
If I use the SRAM feature of J-Flash, it can not program with my ARM1176JZF, has some issue at cpu reset.
Switch to use OpenOCD can program the NOR Falsh of ARM1176JZF.

Tools:
OpenOCD (official): http://openocd.org/
OpenOCD (Windows): http://www.freddiechopin.info/en/download/category/4-openocd
OpenOCD (another Windows): http://gnutoolchains.com/arm-eabi/openocd/
Zadig: http://zadig.akeo.ie/

Windows Platform:
1. Download OpenOCD for Windows and extract it.
2. Download Zadig and install the libusb driver for J-Link.
3. Connect PC <-> J-Link <-> CPU JTAG
4. Run "bin/openocd.exe -f interface/jlink.cfg". if the libusb driver and J-Link connect OK, we can see some information of CPU and JTAG.
5. Write a configuration for the CPU.

ARM1176JZF.cfg
# For a ARM1176JZF CPU
# With J-Link

interface jlink
# Set Chip Name
if { [info exists CHIPNAME] } {
   set _CHIPNAME $CHIPNAME
} else {
   set _CHIPNAME ARM1176JZF
}

# Set CPU Endian
if { [info exists ENDIAN] } {
   set _ENDIAN $ENDIAN
} else {
   # this defaults to a little-endian
   set _ENDIAN little
}

# Set The CPUAPID
if { [info exists CPUTAPID] } {
   set _CPUTAPID $CPUTAPID
} else {
   set _CPUTAPID 0x07b76f0f
}

jtag newtap $_CHIPNAME cpu -irlen 5 -ircapture 0x1 -irmask 0x1f -expected-id $_CPUTAPID

set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME arm11 -endian $_ENDIAN -chain-position $_TARGETNAME -variant arm1176

adapter_nsrst_delay 500
jtag_ntrst_delay 500

# Set Speed
adapter_khz 2000

# reset configuration
reset_config trst_and_srst

# Set Flash Device
# (ex.) Flash is an NOR Flash (CFI)
# (ex.) Flash base address at 0x44000000
# (ex.) Flash size is 0x01000000 (16MB)
set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME cfi 0x44000000 0x01000000 2 2 $_TARGETNAME jedec_probe

# Add RAM/SRAM space to Speed Up the program process
# (ex.) Ready initialized RAM base addr: 0xC0000000
# (ex.) Ready initialized RAM size: 0x00010000
$_TARGETNAME configure -work-area-phys 0xC0000000  -work-area-size 0x00010000 -work-area-backup 0

# Remote Connect Port
#telnet_port 4444
#gdb_port 3333

# Run Command
init
reset halt
# Program an Image to NOR Flash # (ex.) Need erase/unlock the NOR Flash first # (ex.) Image file: C:/ROM.BIN flash write_image erase unlock C:/ROM.BIN 0x44000000 bin
reset

shutdown

6. Run "openocd.exe -f ARM1176JZF.cfg" to program NOR Flash of ROM.BIN file.

沒有留言: