Reading the correct reset status from a bootloadble project.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
DaGr_294516
Level 3
Level 3
10 sign-ins 10 questions asked First solution authored

In a bootloadable project, I need to access CyResetStatus but it alwasy says CY_RESET_SW, regardless of how the chip reset.

This is caused by the  the bootloader running on startup, which exits with CySoftwareReset(). This overwrites whatever was in CyResetStatus previously.

Is there a way for the bootloadable project to correctly determine the reset status as seen by the bootloader?

Put another way, is there a way for the bootloader to copy that information somewhere for the bootloadable to read? For instance, how could I create a NOINIT variable in both projects that would share the same memory location?

 

0 Likes
1 Solution
DaGr_294516
Level 3
Level 3
10 sign-ins 10 questions asked First solution authored

HI, thanks for your replies.

In fact, it was necessary for other reasons to make sure I could share a NOLOAD region of memory between bootloadable and bootloader programs as I needed other information to persist between soft resets. In the end we did this by creating a struct to contain the information, putting that into a custom NOLOAD section in both projects, and a new memory region to contain it:

A global in both projects:

 

CY_SECTION(".reset_info") volatile struct t_reset_info reset_info;

 

 

Then in the linker script of each project:

 

MEMORY
{
	rom (rx) : ORIGIN = 0x0, LENGTH = 262144
	ram (rwx) : ORIGIN = 0x20000000 - (65536 / 2), LENGTH = 65536 - 128
    nld (rw) : ORIGIN = 0x20000000 - 128 / 2, LENGTH = 128
}

.reset_info(NOLOAD) : ALIGN(8)
{
    KEEP(*(.reset_info))
} > nld

 

 

That way, it's certain that the two programs will both have access to the same NOLOAD memory, and neither will corrupt it by having the memory used for anything else.

View solution in original post

0 Likes
4 Replies
Alakananda_BG
Moderator
Moderator
Moderator
50 likes received 250 sign-ins 250 replies posted

Hi @DaGr_294516 ,

Please refer to the below KBA and let us know if that helps.

https://community.infineon.com/t5/Knowledge-Base-Articles/Why-reset-status-is-always-set-as-software...

Regards,

Alakananda

The linked article suggests writing the reset reason to EEPROM or FLASH, so that the bootloadable code and read it back.

But it seems a shame to have to write to the EEPROM or FLASH on every reset, and potentially wear it out.

The OP suggested that it might be possible to pass this value through RAM using the NOINIT section. The only piece of this puzzle that's missing is to know how to define a variable to be at a specific address within the NOINIT section.

DaGr_294516
Level 3
Level 3
10 sign-ins 10 questions asked First solution authored

HI, thanks for your replies.

In fact, it was necessary for other reasons to make sure I could share a NOLOAD region of memory between bootloadable and bootloader programs as I needed other information to persist between soft resets. In the end we did this by creating a struct to contain the information, putting that into a custom NOLOAD section in both projects, and a new memory region to contain it:

A global in both projects:

 

CY_SECTION(".reset_info") volatile struct t_reset_info reset_info;

 

 

Then in the linker script of each project:

 

MEMORY
{
	rom (rx) : ORIGIN = 0x0, LENGTH = 262144
	ram (rwx) : ORIGIN = 0x20000000 - (65536 / 2), LENGTH = 65536 - 128
    nld (rw) : ORIGIN = 0x20000000 - 128 / 2, LENGTH = 128
}

.reset_info(NOLOAD) : ALIGN(8)
{
    KEEP(*(.reset_info))
} > nld

 

 

That way, it's certain that the two programs will both have access to the same NOLOAD memory, and neither will corrupt it by having the memory used for anything else.

0 Likes

Great! Thanks for this useful tip.

0 Likes