Unable to use 4k blocks for progamming when calling ISP from user code

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

Unable to use 4k blocks for progamming when calling ISP from user code

689 Views
bartvdmeulen
Contributor I

Hi,

I try to program an LPC1114/333 using the ISP.

When I enter the ISP pulling PIO0_1 low during reset, I program the flash with any problems sector by sector by uploading blocks of 4k data to the RAM and program the flash.

However when I enter the ISP from user space, using the IAP command, I have to program the flash using 1k blocks, If i try to use 4k, the ISP crashes during the write action to RAM.

In both cases I start to write to ram starting at address 0x10000300 (as per the user manual

Labels (1)
0 Kudos
3 Replies

507 Views
jeremyzhou
NXP Employee
NXP Employee

Hi 

Thank you for your interest in NXP Semiconductor products and 
the opportunity to serve you.

I'd like to get the more  information, whether you can introduce the steps of replicating the issue in details.

I'm looking forward to your reply.

Have a great day,
TIC
 
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
0 Kudos

507 Views
bartvdmeulen
Contributor I

What works:

Place the LPC in ISP mode by pulling  PIO0_1 low during poweron.

call:

lpc21isp -hex image.hex /dev/ttyUSB0 19200 12000

lpc21isp version 1.97
File image.hex:
loaded...
Start Address = 0x00001011
converted to binary format...
image size : 4588
Image size : 4588
Synchronizing (ESC to abort). OK
Read bootcode version: 2
7
Read part ID: LPC1114.../333, 32 kiB FLASH / 8 kiB SRAM (0x00040070)
Will start programming at Sector 1 if possible, and conclude with Sector 0 to ensure that checksum is written last.
Erasing sector 0 first, to invalidate checksum. OK
Sector 1: ...............
Sector 0: ..............................................................................................
Download Finished... taking 0 seconds
Now launching the brand new code

The code programmed also contains code to jump to the ISP mode so I can reprogam without having to use the ISP pin

My code to start the ISP:


typedef void (*IAP)(uint32_t[], uint32_t[]);
static IAP iap_entry = (IAP) 0x1fff1ff1;
static uint32_t command[5];
static uint32_t result[4];

void bootloader_start(void)
{
   __disable_irq();

    LPC_SYSCON->SYSAHBCLKCTRL |= SYSAHBCLKCTRL_CT32B1;
    LPC_SYSCON->SYSAHBCLKCTRL |= SYSAHBCLKCTRL_GPIO;
    LPC_SYSCON->SYSAHBCLKCTRL |= SYSAHBCLKCTRL_IOCON;
   LPC_SYSCON->SYSAHBCLKDIV = 1;

   command[0] = 57;

   __set_MSP(*((uint32_t *) 0x1FFF0000));

   iap_entry(command, result);
}

It enters the ISP, and I can communicate with the target, but if I then try to program the same lpc21isp command failes:

File image.hex:
loaded...
Start Address = 0x00001011
converted to binary format...
image size : 4588
Image size : 4588
Synchronizing (ESC to abort). OK
Read bootcode version: 2
7
Read part ID: LPC1114.../333, 32 kiB FLASH / 8 kiB SRAM (0x00040070)
Will start programming at Sector 1 if possible, and conclude with Sector 0 to ensure that checksum is written last.
Erasing sector 0 first, to invalidate checksum. OK
Sector 1: ...............
Sector 0: ...........................................................................Error on writing data (1)

I ran lpc21isp with debug info enabled and discovered that the error occured during the writing of data to RAM,

By default lpc21isp uses 4k blocks for the LPC1114/333 and the failure occurs between bytes 3195 and 3240.

If I do the same but now using a adjusted version of lpc21isp to limit it the transfer size to RAM to 1024 it works:

File image.hex:
loaded...

Start Address = 0x00001011
converted to binary format...
image size : 4588
Image size : 4588
Synchronizing (ESC to abort). OK
Read bootcode version: 2
7
Read part ID: LPC1114.../333, 56 kiB FLASH / 8 kiB SRAM (0x00040070)
Will start programming at Sector 1 if possible, and conclude with Sector 0 to ensure that checksum is written last.
Erasing sector 0 first, to invalidate checksum. OK
Sector 1: ...............
Sector 0: ..........................|.........................|.........................|.........................

0 Kudos

507 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Bart vd. Meulen,

Thanks for your reply.

As I know, the Flash Magic which is another tool used to update the firmware of MCU via the ISP mode, it select the 512 bytes when calling the ISP Copy RAM to flash command to avoid some potential issues.

Hope it helps.

Have a great day,

TIC

 
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
0 Kudos