lpcware

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#40.18.10.02.00.00.00.00.'    ask for ID
'cansend can0 67D#2B.00.50.00.5A.5A.00.00.'   unlock
'cansend can0 67D#23.15.50.00.00.10.00.10.'    set RAM addr: 0x10001000
'cansend can0 67D#21.50.1F.01.00.00.00.00.'    segmented transfer
[...]
'cansend can0 67D#2B.20.50.00.02.02.00.00.'   prepare sector 2
'cansend can0 67D#2B.30.50.00.02.02.00.00.'   erase sector 2
'cansend can0 67D#2B.40.50.01.02.02.00.00.'   check sector 2
'cansend can0 67D#2B.20.50.00.02.02.00.00.'   prepare again

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

'cansend can0 67D#23.70.50.01.00.20.00.00.'   set new entry point
'cansend can0 67D#2F.51.1F.01.01.00.00.00.'  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? :)

Outcomes