mcuboot icon indicating copy to clipboard operation
mcuboot copied to clipboard

Add Cortex-R support

Open m-braunschweig opened this issue 7 months ago • 5 comments

This PR adds support for Booting on a Cortex-R core. It has been tested with the following branch which also includes some instructions what Kconfig options need to be set: https://github.com/siemens/zephyr/tree/mika/ti/ti-am2434-native-boot

m-braunschweig avatar Apr 10 '25 13:04 m-braunschweig

Thanks for the review. I addressed the changes in the last force-push and added a comment to the MPU

m-braunschweig avatar Apr 10 '25 15:04 m-braunschweig

@nordicjm can you please take a look again? I changed the MPU code to be more readable via macros but if you insist I can also add a #include <zephyr/../../arch/arm/core/mpu/cortex_a_r/arm_mpu_internal.h> to use the internal Zephyr functions.

Also sorry but I didn't notice that I removed the Copyright notices for the small changes in the release note commit instead of the original commit while rebasing

m-braunschweig avatar Jun 13 '25 13:06 m-braunschweig

First force-push is a capitalize first letter in the comment fix that I previously missed; second force-push are your suggestions.

Do you mean it's ok to add the internal header or the inline ASM to read/write coprocessor registers via the macros?

m-braunschweig avatar Jun 16 '25 07:06 m-braunschweig

First force-push is a capitalize first letter in the comment fix that I previously missed; second force-push are your suggestions.

Do you mean it's ok to add the internal header or the inline ASM to read/write coprocessor registers via the macros?

PR is OK as-is, would be good to move from here to zephyr itself then just call from here but that is optional/nice to have not required

nordicjm avatar Jun 16 '25 07:06 nordicjm

@m-braunschweig seemingly this branch has conflicts that must be resolved? Not sure what those are but can you check and fix?

nordicjm avatar Jun 18 '25 08:06 nordicjm

@m-braunschweig seemingly this branch has conflicts that must be resolved? Not sure what those are but can you check and fix?

Resolved. Was due to the Copyright line in the main.c

Can we have explicate ifdefry #ifdef CONFIG_CPU_CORTEX_R5 for code for supporting Cortex-R in that patch. This would help wit maintenance and improve legibility of Cortex-R relevant code.

Yeah. Are you fine with me splitting the arm_cleanup.c into cleanup/arm_cortex_m.c and cleanup/arm_cortex_r.c with both providing the same functions and only one being compiled via CMake? For the main.c I don't have an idea currently on how to effectivly remove/decrease the #ifdefs

m-braunschweig avatar Jun 23 '25 12:06 m-braunschweig

@m-braunschweig I actually men rather using #ifdef CONFIG_CPU_CORTEX_R for code dedicated for Cortex-R than #ifndef CONFIG_CPU_CORTEX_M. If you want to go with separate files/functions - that will help wit clean code as well.

nvlsianpu avatar Jun 25 '25 14:06 nvlsianpu

Updated it. One problem is that we can't use CONFIG_CPU_CORTEX_R since that Kconfig option doesn't exist in Zephyr. For now I only use CONFIG_CPU_CORTEX_R5 since that's the exact core I'm using to test the code.

Edit: I just saw CONFIG_ARMV7_R exists. I will update it now

m-braunschweig avatar Jul 04 '25 08:07 m-braunschweig

Updated it to use ARMV7_R and also the comment for Cortex-R to be more accurate

m-braunschweig avatar Jul 04 '25 09:07 m-braunschweig

I will try to remember to do the changes when submitting a PR that provides default configs for the AM243x LaunchPad (which isn't supported by upstream Zephyr yet)

m-braunschweig avatar Jul 18 '25 14:07 m-braunschweig