View previous topic :: View next topic |
Author |
Message |
SergioMForster
Joined: 23 Jan 2019 Posts: 29 Location: Argentina
|
How to share some ram bytes between bootloader and user app |
Posted: Fri Aug 16, 2019 7:34 am |
|
|
I have developed a user App(in general segment flash) and a bootloader (in auxiliary flash memory) that works well
Compiler PCD v5.085 Processor PIC24EP512GP806
After a reset, the first one that runs is the bootloader (#fuses RESET_AUX), which according to the conditions, passes the control to the user APP, using the
Code: | Goto_Address(APPLICATION_START); | instruction to jump.
I would need to pass the result of the restart_cause () function that only the bootloader can know, to the user APP
Will it be possible to share a RAM byte between the bootloader and the user APP for this?
Will anyone have any example of how to achieve it?
Thanks in advance |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
Re: How to share some ram bytes between bootloader and user |
Posted: Fri Aug 16, 2019 10:55 am |
|
|
SergioMForster wrote: | I have developed a user App(in general segment flash) and a bootloader (in auxiliary flash memory) that works well
Compiler PCD v5.085 Processor PIC24EP512GP806
After a reset, the first one that runs is the bootloader (#fuses RESET_AUX), which according to the conditions, passes the control to the user APP, using the
Code: | Goto_Address(APPLICATION_START); | instruction to jump.
I would need to pass the result of the restart_cause () function that only the bootloader can know, to the user APP
Will it be possible to share a RAM byte between the bootloader and the user APP for this?
Will anyone have any example of how to achieve it?
Thanks in advance |
The restart cause is not cleared by the bootloader. Your application can read the restart cause itself. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
SergioMForster
Joined: 23 Jan 2019 Posts: 29 Location: Argentina
|
|
Posted: Fri Aug 16, 2019 2:06 pm |
|
|
Thanks for your answer.
Unfortunately, in my user app, restart_cause always responds 16 (unknown).
CCS recommends using restart_cause immediately at the beginning of the main:
value = restart_cause()
Function:
Returns the cause of the last processor reset.
[PCD] In order for the result to be accurate, it should be called immediately in main().
After going through all the bootloader logic, the cause of the reset is lost, it does not reach the user app.
For this reason, I want to pass it from the bootloader to the user App, using a shared RAM byte. |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Fri Aug 16, 2019 2:26 pm |
|
|
I was suggesting you interrogate the PIC register directly, not use the CCS function. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Fri Aug 16, 2019 4:24 pm |
|
|
OK, maybe I'm totally wrong, but wouldn't a 'global' variable work ??
My mind's in a fog cause I'm fighting TWO levels of goverment... |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Fri Aug 16, 2019 4:45 pm |
|
|
temtronic wrote: | OK, maybe I'm totally wrong, but wouldn't a 'global' variable work ??
My mind's in a fog cause I'm fighting TWO levels of goverment... |
Once you introduce a global you made the application dependent on the presence of the bootloader. When the application accesses the PICs registers directly this dependency does not exist and there the application will run the same irrespective of the presence of the bootloader.
I may be being too much of a purist here but I am a bit of a bootloader nut. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
|