LPC1788 CRP Erase All

Started by realwarder, November 27, 2013, 07:12:01 PM

Previous topic - Next topic

realwarder

Hi,

I have a LPC1788.  I can get into the ISP using the reinvokeisp call from code (am disabling all interrupts before call), and can connect to it using FlashMagic to read the Device Signature etc.

Read Security shows CRP is 2 or 3.  I think it's 3.

I had assumed that I could wipe the entire Flash even if it was level 2 or 3 using the "Erase all Flash+Code Rd Prot" option.  Or the same option through the menu "Erase Flash" dialog/checkbox.  When I run this it says Erase OK, but the device still maintains the same bootloader/protection.  After power cycle.

Am I missing something fundamental here assuming I can wipe even a CRP 3 flash from the ISP?

Going behind the scenes to the ISP console, I used these commands which I thought are the closest to erase all flash:

U 23130    (Unlock)
0 = SUCCESS response

E 0 29        (Erase all sectors for 512K Flash)
9 = SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION


Am I trying the wrong command here or does anyone know why this response might be returned?

Thanks

RW

realwarder

I've just realized the manual says this for the E command:

QuoteDescription This command is used to erase one or more sector(s) of on-chip flash memory. This command is blocked
when code read protection level CRP3 is enabled. When code read protection level CRP1 is enabled,
individual sectors other than sector 0 can be erased. All sectors can be erased at once in CRP1 and CRP2.

Odd, because earlier it says:

QuoteCRP3 0x4321 8765
This is similar to CRP2, but ISP entry by pulling P2[10] LOW is disabled if a valid user code
is present in flash sector 0.
This mode effectively disables ISP override using the P2[10] pin. It is up to the user's
application to provide for flash updates by using IAP calls or by invoking ISP with UART0.
Caution: If CRP3 is selected, no future factory testing can be performed on the
device

I thought an erase would work from the ISP.  Do I have to use an IAP call to erase all sectors?

realwarder

Ok, so it is possible to break the CRP3 which is what I thought:

From: http://www.nxp.com/documents/application_note/AN10851.pdf

QuoteWhen we use Re-Invoke ISP, we are breaking CRP3 protection, which ultimately means we are downgrading to level CRP2. Although in this level we can't read the flash, we can download a new code.

Which goes back to my original question... any ideas why the Erase isn't working from the ISP?

I'll be quiet now! :)

Thanks

realwarder

How odd.  The Erase all did work.  I think the ISP must time out and I was too slow after running the Read Security commands.

All sorted.

Andy Ayre

Before erasing you must prepare the sectors using the 'P' command. That is why you were getting 'SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION'.

Glad you have it solved.

Andy
Embedded Systems Academy, Inc.
support at esacademy dot com