New try with Olimex lpc2148 and OpenOCD

I tried again to program my olimex lpc2148 board. This time, I had some success. The last times, I got stuck when trying to program a hex file in the flash of the chip. With the current version of OpenOCD (Open On-Chip Debugger 0.4.0 (2010-10-08-15:44)), it seems to be working.

What is needed:

  • an openocd.cfg file that loads target/lpc2148.cfg as a target and interface/olimex-jtag-tiny.cfg for the interface
  • a hex file to program.

Here are the config files, openocd.cfg:

source [find interface/olimex-jtag-tiny.cfg] 
source [find target/lpc2148.cfg]

#daemon configuration
telnet_port 4444
gdb_port 3333

#daemon_startup reset

# reset config
#reset_config trst_and_srst separate
#jtag_nsrst_delay 2000
#jtag_ntrst_delay 2000

target arm7tdmi little run_and_init 0
run_and_halt_time 0 30

target_script 0 reset lpc2148.script

working_area 0 0x40000000 0x80000 nobackup
#flash configuration
flash bank lpc2000 0x0 0x7D000 0 0 0 lpc2000_v2 14765 calc_checksum

and the flash script:

# The following commands will be executed on
# reset (because of run_and_init in the config-file)
# - wait for target halt
# - erase memory
# - flash content of file main.bin into target-memory
# - shutdown openocd
# created by Martin Thomas
# http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects
# based on information from Dominic Rath
arm7_9 dcc_downloads enable
sleep 10
mwb 0xe01fc040 1
flash probe 0
# erase first bank only:
flash erase_sector 0 0 10
#flash write 0 scripts/lpc2148_freertos.bin 0x0
flash write_image jm/main.hex
reset run
#sleep 10

Those are loaded at startup of openocd, but I think the flash script is not needed for the moment, as I flash by hand. Just not sure what is happening at preconfiguration of OpenOCD. Here is how flashing by hand goes.

Start openocd in the directory containing the openocd.cfg file:

~/prog/olimex$ openocd

Connect to it with a telnet session:

~/prog/olimex$ telnet localhost 4444

halt the target:

~/prog/olimex$ halt

erase the memory:

~/prog/olimex$ flash erase_sector 0 0 10

write the image

~/prog/olimex$ flash write_image main.hex

Start the target again:

~/prog/olimex$ reset run

And this does it. I currently use a hex file made by a friend and another one found on the web to test my flashing setup. Now, I need to get a cross-compiler toolchain working under ubuntu

  • Created: 12/02/12 10:32
  • Modified: 12/02/12 10:32