CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

How to share some ram bytes between bootloader and user app

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
SergioMForster



Joined: 23 Jan 2019
Posts: 29
Location: Argentina

View user's profile Send private message

How to share some ram bytes between bootloader and user app
PostPosted: Fri Aug 16, 2019 7:34 am     Reply with quote

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

View user's profile Send private message Send e-mail Visit poster's website

Re: How to share some ram bytes between bootloader and user
PostPosted: Fri Aug 16, 2019 10:55 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Aug 16, 2019 2:06 pm     Reply with quote

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

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Aug 16, 2019 2:26 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Aug 16, 2019 4:24 pm     Reply with quote

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

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Aug 16, 2019 4:45 pm     Reply with quote

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!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group