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

PSoC™ 5, 3 & 1 Forum Discussions

DaGr_294516
Level 2
First solution authored 5 sign-ins 10 replies posted
Level 2

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 2
First solution authored 5 sign-ins 10 replies posted
Level 2

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 50 likes received 250 sign-ins 250 replies posted
Moderator

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
HuEl_264296
Level 5
25 sign-ins First solution authored 100 replies posted
Level 5

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 2
First solution authored 5 sign-ins 10 replies posted
Level 2

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
HuEl_264296
Level 5
25 sign-ins First solution authored 100 replies posted
Level 5

Great! Thanks for this useful tip.

0 Likes