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: ..........................|.........................|.........................|.........................