lpcware

CRP1: Undesirable protection programming while flashing LPC1343

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by evgs on Wed Jun 08 03:41:05 MST 2011
Using LPCXpresso 3.8.2 [Build 129],  OS: Gentoo, kernel 2.6.38-gentoo-r3 

I get CRP1 (0x12345678) programmed when I flashing LPC1343 using LPC-Link. There are no CRP active option  in binary I flash into device. ([0x000002fc]==0xffffffff)

However, device is locked after power cycle. 

Also if I start debugger, after IDE flashes my code and stops at RESET (i.e. no my code has been executed) I see  0x12345678 at 0x2fc.

I tried to flash my part using only command-line tools:

1. LPC-Link attached to clear device and system is powered on

2. loading firmware into LPC-Link and checking SWD connection...
$ dfu-util -d 0x471:0xdf55 -c 0 -t 2048 -R -D LPCXpressoWIN.enc

<output skipped...>

$ crt_emu_lpc11_13_nxp -mi -info-emu -wire=winUSB
Ni: LPCXpresso Debug Driver v2.0 (Jan 11 2011 16:08:54)
<emulators available="1" type="Debug">
<emu index="0" is_connected="false" shortname="LPCLINK_1_1" manu="Code Red - LPCXpresso">LPC-Link Driver LINUX32 v1.1</emu>
</emulators>

$ crt_emu_lpc11_13_nxp -info-target -wire=winUSB -pLPC1343
Ni: LPCXpresso Debug Driver v2.0 (Jan 11 2011 16:08:54)
GetModuleFileName path == /opt/LPCXpresso/bin/crt_emu_lpc11_13_nxp
Nc: Looked for chip XML file in /opt/LPCXpresso/bin/LPC1343.xml

Nc: Looked for vendor directory XML file in /opt/LPCXpresso/bin/nxp_directory.xml

Nc: Found generic directory XML file in /opt/LPCXpresso/bin/crt_directory.xml

Nc: Emu(0): Conn&Reset. DpID: 2BA01477. Info: LPCLINK_1_1
Nc: SWD Frequency: 3000 KHz. RTCK: False. Vector catch: False.
Nc: Packet delay: 0  Poll delay: 0.
Nc: NXP: LPC1343  Part ID: 0x3D00002B
Chip=LPC1343, from NXP (formerly Philips), in family LPC13xx, version=unknown
Chip Description: NXP LPC1343

<output skipped...>
3. Ensuring my code has no CRP:
$ hexdump -C ~/kaplya/firmware/Kaplya/Release/kaplya.bin -s 0x2f0 |head
000002f0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00000300  12 4b 10 b5 d3 f8 80 20  11 4c 42 f4 a0 32 c3 f8  |.K..... .LB..2..|
00000310  80 20 10 4b 10 48 da 6a  22 f0 1f 02 da 62 da 6a  |. .K.H.j"....b.j|
00000320  42 f0 01 02 da 62 da 6c  22 f0 07 02 da 64 da 6c  |B....b.l"....d.l|
00000330  42 f0 01 02 da 64 09 4b  1b 68 1b 68 23 60 9b 68  |B....d.K.h.h#`.h|
00000340  98 47 23 68 01 20 db 68  98 47 10 bd 00 80 04 40  |.G#h. .h.G.....@|
00000350  28 0f 00 10 00 40 04 40  a4 3c 00 00 f8 1f ff 1f  |(....@.@.<......|
00000360  37 b5 0c 46 05 46 b0 b1  29 46 01 20 01 f0 82 f8  |7..F.F..)F. ....|
00000370  c0 f1 3c 00 00 eb d0 70  40 10 36 21 2a 46 01 f0  |..<....p@.6!*F..|
00000380  31 fa 03 23 00 93 01 3b  01 93 00 20 35 21 3c 22  |1..#...;... 5!<"|
(OK) - I see 0xffffffff at 0x2fc

4. Flashing...
$ crt_emu_lpc11_13_nxp -wire=winUSB -pLPC1343 -flash-load-exec=/home/evgs/kaplya/firmware/Kaplya/Release/kaplya.bin 
Ni: LPCXpresso Debug Driver v2.0 (Jan 11 2crt_emu_lpc11_13_nxp -mi -info-target -wire=winUSB -pLPC1343
Ni: LPCXpresso Debug Driver v2.0 (Jan 11 2011 16:08:54)
GetModuleFileName path == /opt/LPCXpresso/bin/crt_emu_lpc11_13_nxp
Nc: Looked for chip XML file in /opt/LPCXpresso/bin/LPC1343.xml

Nc: Looked for vendor directory XML file in /opt/LPCXpresso/bin/nxp_directory.xml

Nc: Found generic directory XML file in /opt/LPCXpresso/bin/crt_directory.xml

Nc: Emu(0): Conn&Reset. DpID: 2BA01477. Info: LPCLINK_1_1
Nc: SWD Frequency: 3000 KHz. RTCK: False. Vector catch: False.
Nc: Packet delay: 0  Poll delay: 0.
Nc: NXP: LPC1343  Part ID: 0x3D00002B011 16:08:54)
GetModuleFileName path == /opt/LPCXpresso/bin/crt_emu_lpc11_13_nxp
Nc: Looked for chip XML file in /opt/LPCXpresso/bin/LPC1343.xml

Nc: Looked for vendor directory XML file in /opt/LPCXpresso/bin/nxp_directory.xml

Nc: Found generic directory XML file in /opt/LPCXpresso/bin/crt_directory.xml

Nc: Emu(0): Conn&Reset. DpID: 2BA01477. Info: LPCLINK_1_1
Nc: SWD Frequency: 3000 KHz. RTCK: False. Vector catch: False.
Nc: Packet delay: 0  Poll delay: 0.
Nc: NXP: LPC1343  Part ID: 0x3D00002B
Cr:v Registered license, download limit of 128K
Nt: Loading binary file 'kaplya.bin' at location 00000000
Nc: nSRST assert (if available)
Nc: Executing in user flash.
5. Checking my device is up and running - you should beleive me, it's OK - no printable output to paste here :)

6. Checking SWD is still work...
crt_emu_lpc11_13_nxp -mi -info-target -wire=winUSB -pLPC1343
Ni: LPCXpresso Debug Driver v2.0 (Jan 11 2011 16:08:54)
GetModuleFileName path == /opt/LPCXpresso/bin/crt_emu_lpc11_13_nxp
Nc: Looked for chip XML file in /opt/LPCXpresso/bin/LPC1343.xml

Nc: Looked for vendor directory XML file in /opt/LPCXpresso/bin/nxp_directory.xml

Nc: Found generic directory XML file in /opt/LPCXpresso/bin/crt_directory.xml

Nc: Emu(0): Conn&Reset. DpID: 2BA01477. Info: LPCLINK_1_1
Nc: SWD Frequency: 3000 KHz. RTCK: False. Vector catch: False.
Nc: Packet delay: 0  Poll delay: 0.
Nc: NXP: LPC1343  Part ID: 0x3D00002B

<output skipped>
7. Cycling device power or just doing hardware reset. Device is up and running again

8. Reloading LPC-Link firmware after previous power cycle (step 7)
$ dfu-util -d 0x471:0xdf55 -c 0 -t 2048 -R -D LPCXpressoWIN.enc
dfu-util - (C) 2007-2008 by OpenMoko Inc.
This program is Free Software and has ABSOLUTELY NO WARRANTY

Opening USB Device 0x0471:0xdf55...
Claiming USB DFU Runtime Interface...
Determining device status: state = dfuIDLE, status = 0
WARNING: Runtime device already in DFU state ?!?
Found Runtime: [0x0471:0xdf55] devnum=41, cfg=0, intf=0, alt=0, name="UNDEFINED"
Claiming USB DFU Interface...
Setting Alternate Setting ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
Transfer Size = 0x0800
bytes_per_hash=604
Starting download: [##################################################] finished!
state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present
Done!
can't detach: error sending control message: Broken pipe
Resetting USB to switch back to runtime mode
9. Checking SWD connection:

$ crt_emu_lpc11_13_nxp -mi -info-target -wire=winUSB -pLPC1343
Ni: LPCXpresso Debug Driver v2.0 (Jan 11 2011 16:08:54)
GetModuleFileName path == /opt/LPCXpresso/bin/crt_emu_lpc11_13_nxp
Nc: Looked for chip XML file in /opt/LPCXpresso/bin/LPC1343.xml

Nc: Looked for vendor directory XML file in /opt/LPCXpresso/bin/nxp_directory.xml

Nc: Found generic directory XML file in /opt/LPCXpresso/bin/crt_directory.xml

Ed:02: Failed on connect: Ee(07). Bad ACK returned from status - wire error.
Et: Emu(0): Connected. Was: None. DpID:     EDB6. Info: LPCLINK_1_1
Error 0: (null)
Last sticky: 0. AIndex: 0
No MemAp selected
No Speed test
SWD Frequency: 50 KHz. RTCK: False. Vector catch: False.
Packet delay: 0  Poll delay: 0.
Now I haven't SWD working.  :-(

10. Finally if I switch my locked device into ISP i can see mass storage device marked with Volume label CRP1_ENABLD

11. Now if i write my binary in ISP mode device will be unlocked. (Until next flashing via SWD)

I have two LPC1343, all this parts locks when I tried SWD-flashing.

What I did wrong? All worked fine for me before I updated my Linux.

Outcomes