flashing firmware through CAN  (LPC11C24)

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by miccio on Wed Jun 17 11:03:26 MST 2015
Hello everybody,

I decided I want to try and flash my microcontrollers through CAN using the built-in bootloader while avoiding to use flashmagic.

My setup consists in a LPCXpresso LPC11C24 board connected to a computer through CAN (with a USB2CAN from 8devices).
The firmware on the board simply uses IAP 57 (Reinvoke ISP) and sets GPIO0_3 low to enter the bootloader.
Then, CANOpen messages are sent from the PC to the board using a python script. The file to be transferred is the .bin from a blink test, with size optimization and debugging disabled. Here are the messages:

'cansend can0 67D#'    ask for ID
'cansend can0 67D#2B.'   unlock
'cansend can0 67D#'    set RAM addr: 0x10001000
'cansend can0 67D#21.50.1F.'    segmented transfer
'cansend can0 67D#2B.'   prepare sector 2
'cansend can0 67D#2B.'   erase sector 2
'cansend can0 67D#2B.'   check sector 2
'cansend can0 67D#2B.'   prepare again

'cansend can0 67D#'   set destination addr: 0x00002000
'cansend can0 67D#'   set source addr: 0x10001000
'cansend can0 67D#2B.'  set number of bytes

'cansend can0 67D#'   set new entry point
'cansend can0 67D#2F.51.1F.'  go

I verified that each message receives its corresponding acknowledgment, including all the chunks of data. I also saw that the new firmware gets successfully uploaded to the device flash. Nevertheless, the new firmware doesn't seem to run, and after the upload the processor gets stuck in the bootloader section ( 0x1FFF 0xxx ) and newer CAN messages get ignored (as expected). Dumping the firmware into sector 0 would be ideal but it seems not to be possible (the "erase" request yields an error code). Changing the location/size of the flash in the blink project settings didn't help either.

I searched through the forum and this is all I could put together with all the suggestions found. Is there something I'm missing? :)