EmbeddedRelated.com
Forums

Code Read Protection

Started by kathy_wright_ca September 29, 2006
I'm using an LPC2138 and I've figure out how to enable code read
protection by writing 0x87654321 to 0x01FC. Is there any way to load
new firmware, do a full chip erase, or disable this feature now?

Since the JTAG debugger and relevant ISP commands are now not
available, I'm thinking that having a bit of code that uses IAP calls
to read the sector, substitute a new value, then re-write the sector,
then cycle the power. I do see issues with that, since I'd have to
assure I'm not running code from that sector at the time.

Is there a good trick or workaround for doing a total erase once Code
Read Protection is enabled?

Kathy Wright
Staff Engineer
Endwave

An Engineer's Guide to the LPC2100 Series

Code Read Protection doesn't stop you using IAP calls to do a full erase. So
the simplest answer is connect to the serial port and use philips LPC2000
Flash programmer to simply erase the chip before you try to re-flash it.
Personally I disable the code protection until I'm ready to make a formal
release, then simply turn it on in the build.
Which compiler are you using though? I put up a recent post with a link of
how to do it using Realview in KEIL for example.

Andy
Sorry that should have read 'doesn't stop you using ISP calls to do a full
erase'. IAP is unaffected as it's called from within your code in flash
anyway.
To clarify from the manual...

CODE READ PROTECTION
This feature is available as of Bootloader revision 1.61.
Code read protection is enabled by programming the flash address location
0x1FC (User flash sector 0) with value 0x87654321
(2271560481 Decimal). Address 0x1FC is used to allow some room for the fiq
exception handler. When the code read protection
is enabled the JTAG debug port, external memory boot and the following ISP
commands are disabled:
. Read Memory
. Write to RAM
. Go
. Copy RAM to Flash
The ISP commands mentioned above terminate with return code
CODE_READ_PROTECTION_ENABLED.
The ISP erase command only allows erasure of all user sectors when the code
read protection is enabled. This limitation does
not exist if the code read protection is not enabled. IAP commands are not
affected by the code read protection.

Hope that makes it clearer...

Andy
I've been working with code read protection this week. I've modified
the lpc21isp program so every time I try to send a new code for flash
the program automatically sends the erase command and it worked well.

Note that, when you are with code read protection activated, the only
erase command available for ISP is to erase all sectors. It's made by
sending the erase command (remember to prepare sectors first!) with
parameters '0' for start sector and the last sector of your device for
the end sector. I've tried to send a number greater than the sector's
number of my device and it failed to erase the memory, so you need to
send exactly <NUMBER_OF_SECTORS - 1> for last sector.

The Philips application works well for erasing the protected flash, too.

Thiago Takehara
Computer Engineer
Engworks Industrial LTDA - R&D Division