OTA Upgrade PIC24

Re: OTA Upgrade PIC24

Postby BobAGI » Fri Jul 25, 2014 7:13 am

You might want to read the threads on Microchip Forum regarding the ways to build a PIC24 boot loader.
Here is one such starting thread: PIC24HJ64GP502: Boot Segment Protection
If you are looking for ways to start the boot loader from your application: Better Bootloader re-entry method
There are several other recent boot loader threads on the MC PIC24 forum you may want to look through too.
--
Bo B
Sweden & Texas
User avatar
BobAGI
Verified identity
 
Posts: 49
Joined: Sun May 25, 2014 2:28 pm
Location: Sweden and Texas
PIC experience: Professional 5+ years with MCHP products

Re: OTA Upgrade PIC24

Postby BobAGI » Fri Jul 25, 2014 7:21 am

HallMark wrote:@BobAGi, Vector table is from 000004H to 0000FEH and for my SIM900 bootloader code starts from 000200H and I allocate say up to 001200H and then from 001400 I start my application code. So when I want to change my application I just have to erase part from 001400H and update them with new received code. Isn't this going to work?

Where is your application vectors stored?
You can't erase the first flash block because that will kill the boot loader so the active application vectors cannot live there.
In the AN1157 boot loader and derivatives there is a jump table created with the boot loader that contains all the application vectors and this is located in application flash space.
And the boot loader vector table in low flash contains addresses to this jump table. They never change.

This does not work if you really must use interrupts in the boot loader itself, in which case you need to do something else.
I have never done this though so I cannot advice.
My boot loader does not need interrupts so the jump table solution works just fine.
All of the structure data like these tables are created in the linker scripts (one for the BL and another different one for the application).
--
Bo B
Sweden & Texas
User avatar
BobAGI
Verified identity
 
Posts: 49
Joined: Sun May 25, 2014 2:28 pm
Location: Sweden and Texas
PIC experience: Professional 5+ years with MCHP products

Re: OTA Upgrade PIC24

Postby HallMark » Fri Jul 25, 2014 10:09 am

@BobAGI,

Where is your application vectors stored?


Code: Select all
External Symbols in Program Memory (by address):

                  0x000200                  __resetPRI
                  0x000226                  __psv_init
                  0x000236                  __data_init
                  0x000236                  __data_init_standard
                  0x0002bc                  __T1Interrupt
                  0x000410                  __U1RXInterrupt
                  0x0004aa                  __U2RXInterrupt
                  0x0004ca                  __U3RXInterrupt
                  0x0004ea                  __U4RXInterrupt
                  0x00050a                  __CNInterrupt
                  0x000528                  _main
                  0x001742                  _vBatADCInit
                  0x001760                  _UserInit
                  0x001804                  _Terminal


So this is why I need to remap my vector? __T1Interrupt lies on 0x0002bc which can erase bootloader code when doing change in application firmware and need to change anything on this location correct?
Last edited by HallMark on Sat Jul 26, 2014 5:22 am, edited 1 time in total.
HallMark
 
Posts: 19
Joined: Mon Jun 30, 2014 12:11 pm

Re: OTA Upgrade PIC24

Postby BobAGI » Fri Jul 25, 2014 7:25 pm

HallMark wrote:@BobAGI,
External Symbols in Program Memory (by address):

Code: Select all
                  0x000200                  __resetPRI
...
                  0x0002bc                  __T1Interrupt
                  0x000410                  __U1RXInterrupt
...
                  0x0004ea                  __U4RXInterrupt
                  0x00050a                  __CNInterrupt
                  0x000528                  _main
                  0x001742                  _vBatADCInit
                  0x001760                  _UserInit
                  0x001804                  _Terminal

So this is why I need to remap my vector?
__T1Interrupt lies on 0x0002bc which can erase bootloader code when doing change in application firmware and need to change anything on this location correct?

You have to realize that the boot loader does not know anything at all about the application vectors (how could it? It is compiled before the application).
According to your vector addresses they are all in low memory inside the flash page normally occupied by the boot loader and so they will not change with the application versions since this flash page is protected from erasure in the boot loader code.

That is why I said that the boot loader vector table must point to a jump table in the application flash space (which WILL be updated when a new application is flashed via the boot loader).
But additionally the boot loader itself then cannot use interrupts because it will redirect to the application ISR, which probably is not even there in the middle of a flash update.

In my PIC24FJ256GB206 CPU there is an alternate vector table, which could be used for the application data if it can be relocated outside the boot loader flash page and then on starting the main application the interrupts could presumably be set to use the alternate table.
But I have never used this since I did not need to. I use a serial boot loader and it just loops on the USART flags rather than use any interrupts for sending/receiving data.
So I use the jump table approach successfully.
--
Bo B
Sweden & Texas
User avatar
BobAGI
Verified identity
 
Posts: 49
Joined: Sun May 25, 2014 2:28 pm
Location: Sweden and Texas
PIC experience: Professional 5+ years with MCHP products

Re: OTA Upgrade PIC24

Postby asmallri » Wed Jul 30, 2014 3:13 pm

If your bootloader does not use interrupts then there is no need to remap interrupts - this avoids introducing latency problems associated with remapping interrupts. It is possible for the bootloader to place code in the first page of program memory as long as the bootloader preserves the reset vector. There is a very very very very small chance of the bricking the device in the event that power fails when the bootloader is updating the first page of program memory (containing the reset vector).
http://www.brushelectronics.com/index.php?page=software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
User avatar
asmallri
 
Posts: 1
Joined: Wed Jul 30, 2014 2:53 pm
Location: Perth, Western Australia
PIC experience: Professional 5+ years with MCHP products

Re: OTA Upgrade PIC24

Postby HallMark » Thu Jul 31, 2014 5:59 am

asmallri wrote:If your bootloader does not use interrupts then there is no need to remap interrupts - this avoids introducing latency problems associated with remapping interrupts. It is possible for the bootloader to place code in the first page of program memory as long as the bootloader preserves the reset vector. There is a very very very very small chance of the bricking the device in the event that power fails when the bootloader is updating the first page of program memory (containing the reset vector).

So when I am trying with AN1157 bootloader example IVT .gld is not required? as It is serial bootloader and no interrupt is there in that example. But yes in application example it is there.
HallMark
 
Posts: 19
Joined: Mon Jun 30, 2014 12:11 pm

Re: OTA Upgrade PIC24

Postby GrahamG » Sat Jan 31, 2015 8:28 am

Although this is an old post I hope that you guys are still monitoring it.

I am just about to embark on a project involving a PIC24F, I have not decided on which one yet but might be the PIC24F256GC060, using a SIM900 GSM and require a boot-loader for updating the PIC24's firmware OTA.

I have researched this quite a bit and find that there is a lot of talk about it not working unless a direct RS232 cable is connected. Is this true of can the GSM method work ?

Your input would be greatly appreciated.

Graham
Durban, South Africa
Graham
Westville, Durban
South Africa
GrahamG
 
Posts: 2
Joined: Sat Jan 31, 2015 8:19 am
PIC experience: Professional 5+ years with MCHP products

Previous

Return to PIC24

Who is online

Users browsing this forum: No registered users and 5 guests