Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zephyr: Add CONFIG_MCUBOOT_CLEANUP_RAM #2127

Merged
merged 1 commit into from
Nov 26, 2024

Conversation

de-nordic
Copy link
Collaborator

Add Kconfig option to cleanup RAM in MCUboot before passing control to an application.

@de-nordic de-nordic added the area: zephyr Affects the Zephyr port label Nov 20, 2024
@de-nordic de-nordic force-pushed the cleanup-ram branch 2 times, most recently from 75c44f6 to 6373888 Compare November 21, 2024 12:01
@de-nordic de-nordic self-assigned this Nov 21, 2024
@@ -236,7 +236,34 @@ static void do_boot(struct boot_rsp *rsp)
__set_CONTROL(0x00); /* application will configures core on its own */
__ISB();
#endif
#if CONFIG_MCUBOOT_CLEANUP_RAM
__asm__ volatile (
/* rt->reset -> r0 */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* rt->reset -> r0 */
/* vt->reset -> r0 */

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

" bx r0\n"
:
: "r" (vt->reset), "i" (CONFIG_SRAM_BASE_ADDRESS),
"i" (CONFIG_SRAM_SIZE * 1024), "i" (0), "i" (sizeof(uint32_t))
Copy link
Collaborator

@nvlsianpu nvlsianpu Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"i" (sizeof(uint32_t)) operand is not used, assembly above used immediate value - which is just perfect.
%4, it is used

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, so I have hardcoded this to #4 and remove the parameter.

Copy link
Collaborator

@nordicjm nordicjm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not work with ARMv6:

/tmp/ccmsO9XM.s: Assembler messages:
/tmp/ccmsO9XM.s:495: Error: selected processor does not support `cbz r2,out' in Thumb mode
/tmp/ccmsO9XM.s:488: Error: invalid immediate: 536870912 is out of range
/tmp/ccmsO9XM.s:488: Error: value of 20000000 too large for field of 2 bytes at 000000c2
/tmp/ccmsO9XM.s:489: Error: invalid immediate: 32768 is out of range

Copy link
Collaborator

@nordicjm nordicjm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit confused here, different symbol has been changed and depends on m7, we don't have any cortex m7's

@de-nordic
Copy link
Collaborator Author

Bit confused here, different symbol has been changed and depends on m7, we don't have any cortex m7's

I am now confused too, because it compiled and worked and the code is actually picked up.

@de-nordic
Copy link
Collaborator Author

Bit confused here, different symbol has been changed and depends on m7, we don't have any cortex m7's

I am now confused too, because it compiled and worked and the code is actually picked up.

Yeah, sure, because I did the change to wrong Kconfig.

boot/zephyr/Kconfig Outdated Show resolved Hide resolved
Add Kconfig option to cleanup RAM in MCUboot before passing control
to an application.

Signed-off-by: Dominik Ermel <[email protected]>
@de-nordic de-nordic merged commit 39aab3d into mcu-tools:main Nov 26, 2024
58 checks passed
@de-nordic de-nordic deleted the cleanup-ram branch November 26, 2024 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: zephyr Affects the Zephyr port
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants