- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Solved! Go to Solution.
- Labels:
-
PSOC5 LP MCU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Great! Thanks for this useful tip.