EmbeddedRelated.com
Forums

flash write_image doesn't do anything

Started by "log...@sbcglobal.net" December 5, 2010
Hi I'm new to ARM processors and JTAG but have some previous experience with other micros like AVR's.

I am currently trying to program my LPC2138 on my custom made board with an Olimex ARM-USB-TINY JTAG adapter. So far I've managed to get almost everything working, except for the config/script files for flashing to device with JTAG.

When I tell it to program, the console outputs this:

Open On-Chip Debugger 1.0 (2008-10-04-10:00) svn:exported
$URL: http://svn.berlios.de/svnroot/repos/ope ... /openocd.c $
Info: options.c:50 configuration_output_handler(): jtag_speed: 10, 10
Info: options.c:50 configuration_output_handler(): Open On-Chip Debugger 1.0 (2008-10-04-10:00) svn:exported
Info: jtag.c:1389 jtag_examine_chain(): JTAG device found: 0x4f1f0f0f (Manufacturer: 0x787, Part: 0xf1f0, Version: 0x4)
Info: jtag.c:1389 jtag_examine_chain(): JTAG device found: 0x4f1f0f0f (Manufacturer: 0x787, Part: 0xf1f0, Version: 0x4)
Info: target.c:237 target_init_handler(): executing reset script 'lpc2138_flash.script'
Info: options.c:50 configuration_output_handler(): dcc downloads are enabled
User: target.c:957 target_arch_state(): target state: halted
User: armv4_5.c:307 armv4_5_arch_state(): target halted in Thumb state due to debug request, current mode: Supervisor
cpsr: 0x800000f3 pc: 0x7fffd2d6
Info: options.c:50 configuration_output_handler(): flash 'lpc2000' found at 0x00000000
Info: options.c:50 configuration_output_handler(): erased sectors 0 through 0 on flash bank 0 in 0.188011s

[info about writing to flash should be here!!]

Info: jtag.c:1389 jtag_examine_chain(): JTAG device found: 0x4f1f0f0f (Manufacturer: 0x787, Part: 0xf1f0, Version: 0x4)
Warning: arm7_9_common.c:743 arm7_9_poll(): DBGACK set, but the target did not end up in the halted stated 1
User: target.c:436 target_process_reset(): Timed out waiting for halt after reset
My lpc2138_flash.script file looks like this:

arm7_9 dcc_downloads enable
wait_halt
sleep 10
poll
flash probe 0

flash erase_sector 0 0 0
flash write_image 0 main.bin 0x00

reset run

sleep 10
shutdown
It looks like it detects and erases the memory fine...but the write_image line does nothing. I also get the same result when I take the line out. If I try to use the older "flash write" it says unknown function and if I use "flash write_bank" same thing happens as write_image.

Anyone know what could be wrong?

An Engineer's Guide to the LPC2100 Series

Okay I got the console output I wanted, but still haven't gotten my code to work.

I changed the flash write_image line to: "flash write_image main.hex" and got this:
Open On-Chip Debugger 1.0 (2008-10-04-10:00) svn:exported
$URL: http://svn.berlios.de/svnroot/repos/openocd/trunk/src/openocd.c $
Info: options.c:50 configuration_output_handler(): jtag_speed: 10, 10
Info: options.c:50 configuration_output_handler(): Open On-Chip Debugger 1.0 (2008-10-04-10:00) svn:exported
Info: jtag.c:1389 jtag_examine_chain(): JTAG device found: 0x4f1f0f0f (Manufacturer: 0x787, Part: 0xf1f0, Version: 0x4)
Info: jtag.c:1389 jtag_examine_chain(): JTAG device found: 0x4f1f0f0f (Manufacturer: 0x787, Part: 0xf1f0, Version: 0x4)
Info: target.c:237 target_init_handler(): executing reset script 'lpc2138_flash.script'
Info: options.c:50 configuration_output_handler(): dcc downloads are enabled
User: target.c:957 target_arch_state(): target state: halted
User: armv4_5.c:307 armv4_5_arch_state(): target halted in Thumb state due to debug request, current mode: Supervisor
cpsr: 0x800000f3 pc: 0x7fffd2d8
Info: options.c:50 configuration_output_handler(): flash 'lpc2000' found at 0x00000000
Info: options.c:50 configuration_output_handler(): erased sectors 0 through 26 on flash bank 0 in 0.206012s
Info: options.c:50 configuration_output_handler(): wrote 692 byte from file main.hex in 0.228013s (2.963784 kb/s)
Info: jtag.c:1389 jtag_examine_chain(): JTAG device found: 0x4f1f0f0f (Manufacturer: 0x787, Part: 0xf1f0, Version: 0x4)
Warning: arm7_9_common.c:743 arm7_9_poll(): DBGACK set, but the target did not end up in the halted stated 1
User: target.c:436 target_process_reset(): Timed out waiting for halt after reset
So it looks like it worked....but nothing is happening on my board.

Okay I got it working! Still trying to figure out what exactly I did but at least I know it works!

Hi
Just an observation; I notice you are using OpenOCD 1.0 of October 2008. I'm using version 0.4.0 of February 2010 under Ubuntu. I see 1.0 was a branch from the main OpenOCD development. The commands you list are quite a bit different from the ones I use to program an LPC2138 which are:
..............
# erase first bank only
echo "erasing:"
ocd_flash erase_sector 0 0 1
sleep 20
# erase all banks
ocd_flash erase_sector 0 0 26
sleep 20
## flash erase_address 0 0

# blank check
echo "blank check:"
ocd_flash erase_check 0
sleep 20

# write
echo "writing:"
ocd_flash write_image Flt12.hex 0x0 ihex
.................

-Scott

--- In l..., "logantsmith@..." wrote:
>
> Okay I got it working! Still trying to figure out what exactly I did but at least I know it works!
>

Oh that makes a lot more sense. I noticed that and was wondering how I had version "1.0" from 2008 where as the latest version is 0.4.0. That explains things... I just used the out-of-the-box installation that Olimex provided.

On a side note I figured out how I can program it but it's a pretty weird procedure I came up with. It goes:

1. Device Off, Plug in JTAG Interface
2. Download program, wait until it times out
3. Press Reset
4. Remove JTAG
5. Toggle Power

Does everyone have to remove their JTAG interface from their boards in order to run their software?
--- In l..., "Scott" wrote:
>
> Hi
> Just an observation; I notice you are using OpenOCD 1.0 of October 2008. I'm using version 0.4.0 of February 2010 under Ubuntu. I see 1.0 was a branch from the main OpenOCD development. The commands you list are quite a bit different from the ones I use to program an LPC2138 which are:
> ..............
> # erase first bank only
> echo "erasing:"
> ocd_flash erase_sector 0 0 1
> sleep 20
> # erase all banks
> ocd_flash erase_sector 0 0 26
> sleep 20
> ## flash erase_address 0 0
>
> # blank check
> echo "blank check:"
> ocd_flash erase_check 0
> sleep 20
>
> # write
> echo "writing:"
> ocd_flash write_image Flt12.hex 0x0 ihex
> .................
>
> -Scott
>
> --- In l..., "logantsmith@" wrote:
> >
> > Okay I got it working! Still trying to figure out what exactly I did but at least I know it works!
>

Yes I found there is an order of doing things to make it work. Assuming JTAG is already plugged in, I:

1. Power up LPC board
2. Unplug USB to JTAG from PC, wait, plug it back in
3. Press reset on LPC board
4. From terminal prompt run "sudo openocd -f program-lpc2138.cfg"

Step 2 only needs to be done the first time (probably related to Ubuntu recognising the USB port). Subsequent iterations only require step 3 and 4.

--- In l..., "logantsmith@..." wrote:
>
> Oh that makes a lot more sense. I noticed that and was wondering how I had version "1.0" from 2008 where as the latest version is 0.4.0. That explains things... I just used the out-of-the-box installation that Olimex provided.
>
> On a side note I figured out how I can program it but it's a pretty weird procedure I came up with. It goes:
>
> 1. Device Off, Plug in JTAG Interface
> 2. Download program, wait until it times out
> 3. Press Reset
> 4. Remove JTAG
> 5. Toggle Power
>
> Does everyone have to remove their JTAG interface from their boards in order to run their software?
> --- In l..., "Scott" wrote:
> >
> > Hi
> > Just an observation; I notice you are using OpenOCD 1.0 of October 2008. I'm using version 0.4.0 of February 2010 under Ubuntu. I see 1.0 was a branch from the main OpenOCD development. The commands you list are quite a bit different from the ones I use to program an LPC2138 which are:
> > ..............
> > # erase first bank only
> > echo "erasing:"
> > ocd_flash erase_sector 0 0 1
> > sleep 20
> > # erase all banks
> > ocd_flash erase_sector 0 0 26
> > sleep 20
> > ## flash erase_address 0 0
> >
> > # blank check
> > echo "blank check:"
> > ocd_flash erase_check 0
> > sleep 20
> >
> > # write
> > echo "writing:"
> > ocd_flash write_image Flt12.hex 0x0 ihex
> > .................
> >
> > -Scott
> >
> > --- In l..., "logantsmith@" wrote:
> > >
> > > Okay I got it working! Still trying to figure out what exactly I did but at least I know it works!
> > >
>