Invoking CAN bootloader via IAP on LPC11Cxx ?

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

Invoking CAN bootloader via IAP on LPC11Cxx ?

2,528 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by DaveNadler on Sat Oct 08 14:12:08 MST 2011
[FONT=Arial]In LPC11Cxx, In Application Programming (IAP) command 57 invokes In-System Programming (ISP).
Unfortunately there is no command 57 input argument to specify load via serial or CAN, and IAP documentation talks about configuring TX/RX but does not mention CAN.
Does bootloader look at PIO0_3 when invoked by IAP ?
Thanks in advance,
Best Regards, Dave
[/FONT]
0 Kudos
45 Replies

1,637 Views
supercartman
Contributor I

Is it possible to change the C_CAN bit rate from 100 kbits/sec to 125 kbit/sec if an external oscillator is used?

0 Kudos

1,637 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Almaz on Tue Oct 16 01:24:59 MST 2012
I finished completely software bootloader on IAP-commands))
0 Kudos

1,641 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed Oct 10 01:13:17 MST 2012

Quote: Almaz
But on my microcontroller none of this methods does not help.



:confused:

It's working here with LPC11C14 & LPC11C24 since 2011 :)
0 Kudos

1,642 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Almaz on Wed Oct 10 00:16:31 MST 2012
Thanks for the advice, Zero:). But on my microcontroller none of this methods does not help.
So decided not to use the hardware bootloader and write the fully software bootloader by using IAP-commands.
0 Kudos

1,642 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Oct 09 04:56:07 MST 2012

Quote:

1 question.
The function, that copyed from device to device will work? Absolute addressing in assembly will not interfere?

:confused:

Writing to a register is usually done relative :eek:

 void Own_Reset(void)
{
      SCB->AIRCR  = ((0x5FA << SCB_AIRCR_VECTKEY_Pos)      |
 300:   [COLOR=Red] 4a01[/COLOR]          ldr    r2, [pc, [COLOR=DarkOrchid]#4[/COLOR]]    ; (308 <Own_Reset+0x8>)
 302:    [COLOR=Red]4b02[/COLOR]          ldr    r3, [pc, [COLOR=DarkOrchid]#8[/COLOR]]    ; (30c <Own_Reset+0xc>)
 304:   [COLOR=Red] 60da[/COLOR]          str    r2, [r3, #12]
                         SCB_AIRCR_SYSRESETREQ_Msk);
}
 306:   [COLOR=Red] 4770 [/COLOR]         bx    lr
 308:    [COLOR=Red]05fa0004[/COLOR]     .word    0x05fa0004
 30c:    [COLOR=Red]e000ed00[/COLOR]     .word    0xe000ed00
So writing this 16 byte code to target RAM (changed bx to nop) and executing it is working without problems
const char system_reset[]={0x01,0x4a,0x02,0x4b,0xda,0x60,0xc0,0x46,0x04,0x00,0xfa,0x05,0x00,0xed,0x00,0xe0};
0 Kudos

1,642 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Oct 09 02:26:02 MST 2012

Quote: Almaz
That could work.



That [COLOR=Red]is[/COLOR] working :)

Using AIRCR to reset targets isn't unusual ;)


Quote:
[B]Resetting the target[/B]
To reset a Cortex target, the Application Interrupt and Reset Control  Register (AIRCR) can be used. This register exists in the target’s CPU  address space at address 0xE000ED0C. Writing 0x05FA0004 will reset the  LPC controller.   

See: http://lpcware.com/content/blog/introduction-cortex-serial-wire-debugging-part-two
0 Kudos

1,642 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Almaz on Tue Oct 09 02:14:47 MST 2012
1 question.
The function, that copyed from device to device will work? Absolute addressing in assembly will not interfere?

Because fact is that, when i "say" to linker place the function in RAM, - function work.
When copy ram from flash to RAM a&#1090;&#1074; then jump to RAM address of copy of function - it is not work
0 Kudos

1,642 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Oct 09 02:07:34 MST 2012

Quote: Almaz
Now this function placed in RAM but not in word boundary address.



:confused:

Which RAM?

Doctor RAM or patient RAM?

Are we talking about resetting a target after flashing it?

#1 A compiled NVIC_SystemReset should be something like a 20 byte sequence :D

#2 Writing this bytes to target RAM address via 'Write to RAM' C_CAN command  is placing this sequence wherever you want :eek:

#3 Executing this address via GO is resetting target :)
0 Kudos

1,642 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Almaz on Tue Oct 09 01:44:02 MST 2012

Quote: Zero
:confused:

Then change the doctor :p

Look for a doctor which can write a compiled NVIC_SystemReset to patient RAM and start it via GO :eek:

That's a reset, isn't that what you are asking for?



I am store at RAM the comand
Quote:
void restartPacient( )
{
NVIC_SystemReset( );
}


For this i put this function in separate src file. In options to this file is set the memory to store is RAM. Now this function placed in RAM but not in word boundary address. Linker categorically don't place the function by word boundary address!!!
And via GO i can jump only in word boundary address!!!
0 Kudos

1,642 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Oct 09 01:24:16 MST 2012

Quote: Almaz
Doctor can't give to pacient comand NVIC_SystemReset(void)



:confused:

Then change the doctor :p

Look for a doctor which can write a compiled NVIC_SystemReset to patient RAM and start it via GO :eek:

That's a reset, isn't that what you are asking for?
0 Kudos

1,642 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Almaz on Tue Oct 09 01:16:59 MST 2012

Quote: Zero
What's wrong with NVIC_SystemReset(void) :confused:



There are two device in network: doctor and pacient.

Doctor say to pacient go to hardware boot.
Then doctor copy their flash to flash of pacient.
After that pacient need to be restarted.
But the pacient understand once these commands:

Quote:
Unlock
Set Baud
Echo
Write to RAM
Read Memory
Prepare sector(s)
Copy RAM to flash
[B][SIZE=2]Go [/SIZE][/B]
Erase sector(s)
Blank check sector(s)
Read Part ID
Read Boot code
ReadUID
Compare



Doctor can't give to pacient comand NVIC_SystemReset(void)
0 Kudos

1,642 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Oct 09 01:07:32 MST 2012
What's wrong with NVIC_SystemReset(void) :confused:
0 Kudos

1,642 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Almaz on Mon Oct 08 23:17:12 MST 2012
Some questions about using "Go" command.
1)I understand, that this command used to restart device after of finishing the downloading code to flash memory of device?

There is what written about this in manual:

Quote:
Input parameter - Address: Flash or RAM address from which the code execution is to be started. This address should be on a word boundary.
This command is used to execute a program residing in RAM or flash memory. It
may not be possible to return to the ISP command handler once this command is
successfully executed. This command is blocked when code read protection is
enabled. The command must be used with an address of 0x0000 0200 or greater.



2)As input parameter i must set the address of Reset_Handler?
3) How to be if the Reset_Handler address is not word boundary?
0 Kudos

1,642 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Almaz on Mon Sep 17 21:29:23 MST 2012
thanks for the advice:)
How about this solution:

Write to the microcontroller two programs:
1. "Software bootloader mode" stored at 0x0000 0000 - 0x0000 0FFF
2. "Working mode" stored at 0x0000 10000 - 0x0000 3FFF
When power is applied, the microcontroller starts with "Software bootloader mode".
This program control checksum of second program "Working mode". If the checksum is correct, then execution control is transferred to the "Working mode" with "GO command". Else this program put microcontroller in boot mode with "reinvoke command".

Do you think this will work?:)
0 Kudos

1,642 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ex-kayoda on Mon Sep 17 05:37:42 MST 2012

Quote: Almaz
It is possible to put the second node in ISP mode if it have invalid user code without hardware reset (pins 0_1 and 0_3 to LOW)?



No :( Without hardware switch to ISP or software ISP call you  can't switch to ISP :o

Therefore I would strongly recommend to 'Compare' RAM and FLASH after writing  (Table 391. C_CAN ISP and UART ISP command summary) :)
0 Kudos

1,638 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Almaz on Mon Sep 17 05:20:31 MST 2012
So, I wrote a program that allows one device copy their flash-memory to another device  when they are connected to the CAN-network.
The algorithm is as follows:
1. First node write in a specific entry of OD of second node. The writting in this entry call the reinvoke comand, that put this node in the ISP mode.
2. Using the standart comand: "Write to RAM" , "Prepare sector" , "Erase sector" , "Copy RAM to flash", i copy the content of first node's flash-memory to the second node's flash memory.

This is possible when the second node have a valid user code. It is possible to put the second node in ISP mode if it have invalid user code without hardware reset (pins 0_1 and 0_3 to LOW)?

Thanks)
0 Kudos

1,638 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Almaz on Mon Sep 17 04:54:25 MST 2012
damned careless:)
0 Kudos

1,637 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ex-kayoda on Wed Sep 12 02:04:09 MST 2012

Quote: Almaz
The used microcontroller is lpc11c24. This is true, I can not write directly to the flash?
The manual states that it is possible!



Where :confused:

With which command :confused:


Quote:

Table 391. C_CAN ISP and UART ISP command summary

Unlock
Set Baud Rate
Echo
Write to RAM
Read Memory
Prepare sector(s) for write operation
Copy RAM to flash
Go
Erase sector(s)
Blank check sector(s)
Read Part ID
Read Boot code version
ReadUID
Compare

0 Kudos

1,641 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Almaz on Wed Sep 12 01:30:29 MST 2012
in bootloader mode:
When i write to RAM - all goes well.
When i copy RAM to flash - all goes well.
When i write to flash - the memory location in which I write no changes.
I have to first write to RAM, then copy RAM to flash - in this case the memory location in which I write changes.

The used microcontroller is lpc11c24. This is true, I can not write directly to the flash?
The manual states that it is possible!
0 Kudos

1,641 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Almaz on Tue Sep 11 05:44:38 MST 2012
overlooked this page 100 times and did not notice the word "LPC1"
Thanks))
0 Kudos