Hello,
I'm working on LPC1768 ISP application through LPC1768 UART commands.
I designed an external PCB with second MCU and SPI flash that receive form PC hex file to download in LPC1768 (the hex file is saved in SPI flash) and then wrote data in LCP1768 via ISP commands.
PC to second MCU protocol got CRC on command, so I'm quite sure hex file is transfered correctly inside SPI flash.
I developed LPC ISP protocol and commands.
What happens is that I got "OK" for all LPC1768 ISP commands, but program is not running.
My ISP commands sequence to download in LPC1768 flash is (ISP UART protocol is working because LPC1768 reply is always OK):
// binSize is the hex file size, in byte. Then I got needed sector count
flashNeededSectorCount = _get_flash_sector_index(binSize);
// Set LPC1768 in ISP mode
lpc1768IspManagerEnterIspMode();
// LPC1768 baudrate syncro
lpc1768IspManagerBaudRateSyncro(uartBusPtr);
// Disasble echo
lpc1768IspManagerDisableEcho(uartBusPtr);
// UnLock
lpc1768IspManagerUnlock(uartBusPtr);
// Prepare needed sector
lpc1768IspManagerPrepareSector(uartBusPtr, 0, flashNeededSectorCount - 1);
// Erase needed sector
lpc1768IspManagerEraseSector(uartBusPtr, 0, flashNeededSectorCount - 1);
// Load program (flashAddress is LPC1768 write flash address)
for(flashAddress = 0; flashAddress < binSize; ) {
// Write to LPC1768 RAM data
lpc1768IspManagerWriteToRAM(uartBusPtr, 0x10000200 + (uint32_t)index, &binData[index], writeLen);
// Prepare selected flash sector
flashSectorCount = _get_flash_sector_index(flashAddress);
lpc1768IspManagerPrepareSector(uartBusPtr, 0, flashSectorCount);
// Copy from RAM to FLASH
lpc1768IspManagerCopyRAMToFlash(uartBusPtr, flashAddress, 0x10000200, sizeof(binData));
flashAddress += binDataLen;
}
// Go
lpc1768IspManagerGo(uartBusPtr, 0);
// Remove ISP mode
lpc1768Reset();
lpc1768RemoveForISP();
tommRoCOsDelayMsec(1500);
lpc1768RemoveReset();
Hi Davide,
Please make sure that the *.hex file you are flashing to the MCU contains a valid image checksum, see this document for more information:
https://community.nxp.com/thread/389046
Hope it helps!
Best Regards,
Carlos Mendoza
Technical Support Engineer
Hello.
Thank you for your reply.
I was missing the CHECKSUM; now I added it in HEX file and try to download file but still I have problems.
Question: for checksum, uint32_t data are written in little-endian or big-endian?
I try both solutions and still bootloader never works; but I want to know to be sure of what I'm doing.
It's possible to have an example of CHECKSUM input 28 byte data array and output 32 byte data array?
Thank you
The way to debug that is, program a known good example "blinky" via SWD first, open the debugger memory windows (make sure your have VTOR register set correctly) to look at the flash content checksum field from 0x1C to 0x1F , then use the hex editor (you need to convert elf or axf file to hex file first) to compare and insert the same checksum manually. Then, use your flash ISP to program this hex file into the flash.