Flash-programming LPC4337 (any LPC43x3,x5,x7) using OpenOCD

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Flash-programming LPC4337 (any LPC43x3,x5,x7) using OpenOCD

1,502 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Pacman on Wed Sep 11 19:36:07 MST 2013
Does anyone have a working lpc4337.cfg file for OpenOCD ?
(A LPC43x3, LPC43x5 or LPC43x7 .cfg file will do just fine too)

I successfully got OpenOCD to write to a LPC1768. I can also communicate with a LPC4330, a LPC4310 and a LPC4337.
But attempting to write to the LPC4337 fails; it seems to have something to do with the reset signal.

I've tried both the flash write commands, which I use for the LPC1768, but also the convenience command "program".
("program" seems to be a bit slow, though)
Labels (1)
0 Kudos
11 Replies

1,072 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by maximevince on Fri Nov 29 06:01:20 MST 2013
I have extended it so that is supports an SST39VF3201 NOR Flash on CS0, address 0x1c000000,
such as on the Hitex LPC4357 development board I'm using.

Config file attached!

BR,
Maxime
0 Kudos

1,072 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by maximevince on Fri Nov 29 03:32:49 MST 2013
Awesome,saved my day!
I am going to extend it to use the CFI flash interface as well.

BR,
Maxime
0 Kudos

1,072 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mdittrich on Mon Sep 23 08:41:31 MST 2013
Nemui,

After fighting with OpenOCD 0.8.0 a bit, I finally was able to rebuild 0.7.0 with your IAP init patches and everything seems to be working great!  Thanks! 

Do you plan on contributing them back to the main project?

Thanks again

0 Kudos

1,072 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Nemuisan on Wed Sep 18 17:53:06 MST 2013
Hi,Pacman

Sorry,The URL that I suggested is wrong.
Correct URL is here.
http://cid-36f4d1230f8a673c.skydrive.live.com/browse.aspx/.Public/tool/OpenOCD

Currently cfg-fileset name is "OpenOCD_special_cfgs_20130918.7z".
You can find "lpc435x_spifi_flash.cfg" in this archive.

To program internal flash,MUST use tcl procedure call "mt_flash"!
Attachment files is my simple gcc project for lpc4357(can easily migrate to lpc4337).
MAKEFILE in this project wrote how to use OpenOCD with procedure call named "mt_flash".

Cheers,
Nemui
0 Kudos

1,072 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Pacman on Wed Sep 18 11:58:40 MST 2013
@Nemui:

I had trouble getting the .cfg-files ("OpenOCD_special_cfgs_xxxxxxxx.7z") - it seems both links link directly to the patches ?

Right now I'm in the process of rebuilding OpenOCD 0.8.0. I'm looking forward to trying it out. =)
0 Kudos

1,072 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Pacman on Wed Sep 18 06:36:26 MST 2013
@Nemui

Awesome. I'll download them immediately and see if I can apply them to my 0.7.0 (or if I can succeed in cloning 0.8.0 and building that one).
Thank you so much for sharing your hard work. I hope this patch makes it into the final version. =)
0 Kudos

1,072 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Pacman on Wed Sep 18 06:34:30 MST 2013
This is excellent. I'll try changing my configuration file today.
I can see there's a difference in this, both from my .cfg file for the LPC1768 and my original .cfg file for LPC43xx.
I am very, very grateful for your help! Thank you again! :)
0 Kudos

1,072 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Nemuisan on Tue Sep 17 18:19:40 MST 2013
Hi,guys.


I bought LPC4357 China devboard last year and got same problem long time....

But I noticed that LPC43x7 flash model needs "IAP-Init Command(49)"
before erase / write internal flash.

I made OpenOCD0.8.0's patch(to lpc2000.c) to throwing "IAP-Init Command"
before erase and write command,and got work very well.
So We don't need to be P2_7 pulled low everytime to write internal flash anymore!

Patches for OpenOCD0.8.0 and LPC4357's cfg detail were posted below threads.
http://groups.yahoo.com/neo/groups/versaloon/conversations/messages/405


Best regards,
Nemui Trinomius
0 Kudos

1,072 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mdittrich on Tue Sep 17 14:34:22 MST 2013
Pulling it down will boot into the ROM bootloader... so you don't want to add a permanent pull-down.  For some reason, it will only program FLASH when the bootloader runs, so it is doing something (or not doing something important.

I am using a Tin Can Tools Flyswatter, my cfg file is not very pretty, but here is the core of it:


#################### daemon config ####################
telnet_port 4444
gdb_port 3333
tcl_port 6666

#################### interface config ####################

interface ft2232
ft2232_layout "flyswatter"
ft2232_device_desc "Flyswatter A"
ft2232_vid_pid 0x0403 0x6010

##################### JTAG config #####################

adapter_nsrst_assert_width 20
jtag_ntrst_assert_width 
adapter_khz 500

reset_config trst_and_srst trst_open_drain srst_open_drain

jtag newtap lpc4300_m4 cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id 0x4ba00477
jtag newtap lpc4300_m0 cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id 0x0ba01477  

set _TARGETNAME lpc4300.m4
target create $_TARGETNAME cortex_m3 -chain-position lpc4300_m4.cpu
#cortex_m3 reset_config sysresetreq

# work area is 16k on AHB0
$_TARGETNAME configure -work-area-phys 0x10000000 -work-area-size 0x8000 -work-area-backup 0

$_TARGETNAME configure -event gdb-attach { 
    echo "--- gdb-attach, hello gdb ---"
    soft_reset_halt
}

$_TARGETNAME configure -event gdb-detach { 
    echo "--- gdb-detach, shutting down ---"
    shutdown
}

set _FLASHNAME $_TARGETNAME.flash
set _SPIFINAME $_TARGETNAME.spifi

#debug_level 3

flash bank $_FLASHNAME lpc2000 0x1A000000 0x80000 0 0 $_TARGETNAME lpc4300 96000 calc_checksum
flash bank $_SPIFINAME lpcspifi 0x14000000 0 0 0 $_TARGETNAME

init

halt

#display VTOR
mdw 0xE000ED08

#M4 Mem map - shadow pointer that shows up at address 0
mdw 0x40043100

flash write_image erase YOURFILEHERE.hex 0 ihex
#flash write_image erase YOURSPIFIFILEHERE.hex 0 ihex

soft_reset_halt

# set M4MEMMAP to the base of flash bank A
mww 0x40043100 0x1A000000
mdw 0x40043100

# set VTOR to 0 (which will map to flash)
mww 0xE000ED08 0x00000000
mdw 0xE000ED08

echo "\n---- ready for GDB connection ----\n"



I usually just use this to flash my own "level 2" bootloader that I use for all subsequent FLASH'ings.  It certainly would be nice if I could get it to FLASH via OpenOCD without pulling down P2_7. 

This same config works for debugging with the "flash write_image" commented out.  The "mww" may or may not be necessary.  They are from a while back when I was trying to figure you why it always failed unless booting into the ROM bootloader first...
0 Kudos

1,072 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Pacman on Tue Sep 17 10:07:57 MST 2013
Thank you very much for this information, this is very valuable to me.
I find it strange, though that it has to be pulled down.
Currently I have a pull-up on it, and I can read it but have not been able to write.
I'll try making it a pull-down and see if I can get any further.

Is there a chance I could have the .cfg file you're using ?
Oh, and which adapter(s) are you using ?
0 Kudos

1,072 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mdittrich on Mon Sep 16 06:26:55 MST 2013
I can only get OpenOCD to program LPC43xx FLASH when I boot with P2_7 pulled low.  Debugging has always worked fine.

Some time ago I rebuilt OpenOCD with debug output enabled to try to determine why, but I never found a solution.
0 Kudos