Scheduler failed to start on CM33 porting

Sai 45 Reputation points
2023-08-08T04:00:31.41+00:00

Hi all!

I am porting Azure RTOS to cm33 using gcc and run only in non-secure mode. There are two question when running the exampe .

1.The HardFault when PendSV_Handler return.

The assembly instruction generates HardFault is "bx lr" in __tx_ts_restore in __tx_ts_handler. The function call flow is as followed:

_tx_thread_schedule() -> PendSV_Handler -> __tx_ts_handler -> __tx_ts_new -> __tx_ts_restore

The instruction causes HardFault is "LDMIA r12!. {LR}". This instruction changes lr value "0xFFFFFFF9" to "0xFFFFFFBC" which triggers HardFault when "bx lr" to exit PendSV_Handler.

/* ports/cortex-m33/gnu/src/tx_thread_schedule.S */     
261	   LDMIA   r12!, {LR}                              // Pickup LR
268    LDMIA   r12!, {r4-r11}                          // Recover thread's registers
269    MSR     PSP, r12                                // Setup the thread's stack pointer
270
  1. The first task fail to run.

After the first step of analysis,using GDB to change lr value to previous "0xFFFFFFF9" avoids HardFault and return to program. But at this time, there is no task to run. I checked the variable “_tx_timer_system_clock”, it incremented rightly. I do not know why scheduler does not work.

I am quite new about Azure RTOS, I hope someone can provide some debugging ideas.

Thank you!

Azure RTOS
Azure RTOS
An Azure embedded development suite including a small but powerful operating system for resource-constrained devices.
331 questions
{count} votes

Accepted answer
  1. LeelaRajeshSayana-MSFT 15,241 Reputation points Microsoft Employee
    2023-08-17T22:11:58.1433333+00:00

    Hi @Sai Apologies for the delayed feedback on this. I would like to know if you have looked into the repo https://github.com/azure-rtos/samples where samples of SMT devices are shared to help you get started with Azure RTOS.

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to accept the answer .

    Issue:

    The assembly instruction generates HardFault is "bx lr" in __tx_ts_restore in __tx_ts_handler. The instruction causes HardFault is "LDMIA r12!. {LR}". This instruction changes lr value "0xFFFFFFF9" to "0xFFFFFFBC" which triggers HardFault when "bx lr" to exit PendSV_Handler.

    Solution:

    Setting the correct macro to the property TX_SINGLE_MODE_SECURE helped resolve the issue.

    If I missed anything please let me know and I'd be happy to add it to my answer, or feel free to comment below with any additional information.

    I hope this helps!

    If you have any other questions, please let me know. Thank you again for your time and patience throughout this issue.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.