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

ThreadX modules support on Cortex-M33 #431

Open
Jasinsky opened this issue Jan 24, 2025 · 1 comment
Open

ThreadX modules support on Cortex-M33 #431

Jasinsky opened this issue Jan 24, 2025 · 1 comment

Comments

@Jasinsky
Copy link

I am running ThreadX from tag v6.4.1_rel with modules-enabled kernel.

When compiled with TX_SINGLE_MODE_SECURE - it hard faults after first enter to the scheduler and PendSV interrupt.
PendSV interrupt executes until returning from exception.
EXC_RETURN was set to 0xFFFFFFBC and that was causing aforementioned hardfault.

After applying patch below - scheduler runs successfully.

diff --git a/ports_module/cortex_m33/gnu/module_manager/src/tx_thread_schedule.S b/ports_module/cortex_m33/gnu/module_manager/src/tx_thread_schedule.S
index e392380b..ba8c5fea 100644
--- a/ports_module/cortex_m33/gnu/module_manager/src/tx_thread_schedule.S
+++ b/ports_module/cortex_m33/gnu/module_manager/src/tx_thread_schedule.S
@@ -471,6 +471,12 @@ _skip_vfp_restore:
     LDMIA   r12!, {r4-r11}                          // Recover thread's registers
     MSR     PSP, r12                                // Setup the thread's stack pointer
 
+#ifdef TX_SINGLE_MODE_SECURE
+    LDR     r0, =0xFFFFFFFD                         // Exception return to secure
+#else
+    LDR     r0, =0xFFFFFFBC                         // Exception return to non-secure
+#endif
+    MOV     lr, r0
     BX      lr                                      // Return to thread!

It might be that I am not understanding Trustzone secure/non-secure implications.

Following addition was present in MemManage handler e.g. - other interrupts do not have it.

Could someone suggest if this is a scheduler bug for CM33/CM23 and other CMSE architectures or I am configuring my microcontroller wrongly?

@fdesbiens
Copy link
Contributor

Thank you for this question, @Jasinsky.

@eclipse-threadx/iot-threadx-committers and @eclipse-threadx/iot-threadx-contributors: can one of you please comment on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants