This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TDA4VM: SVC handler and stack pointer handling

Part Number: TDA4VM
Other Parts Discussed in Thread: DRA829,

Following are tools and compilers:

  1. Development Board: Jacinto7 J721E/DRA829/TDA4VM Evaluation Module (EVM)
  2. Core: MCU sub system- (MCU1_0 (R5F))
  3. Compiler : ti-cgt-arm_18.12.4.LTS
  4. Debugging setup: Code Composer Studio 9.3.0

Scenario: 

  1. writing a SVC handler where intention is
    1. from the SVC handler (supervisory mode) the control should be passed on to the user mode (system mode) Task.
    2. The stack pointer for the user mode Task should be loaded with predefined stack address (The tasks stack address)

 

Now when we try to do this (using instruction movs pc,lr ,) we are able to jump to the intended task by switching the mode (spsr is correctly loaded in cpsr) but now what happens is that the SP is loaded with the user mode stack address which was saved in the SP_user register (which is absolutely correct as per the r5 behavior) but what we want is that the SP should be loaded with whatever address we provide (the predefined SP for the given task). Now in order to achieve this we tried to change the SP_user register from the SVC mode (using instruction stmia r4, r13 ^ ) however we are not able to change the SP_user.

Can we change the read/write the SP_user register from supervisor mode? If yes, How?

The compiler provides errors for rfe (rfe, sp!)instruction,

also for ldmfd  sp, {r13} the compiler throws error for r13.

Is it like arm v7 does not support this instructions, r5 does not support this instructions and or compiler settings issue ?

 

The implemented workaround:

  1. From the SVC mode, change the cpsr register to change the mode to the system mode
  2. Now set the sp_user to the desired address and perform bx lr (instead of normal exception return)

Is this implementation correct or there is a way to change the sp_user from SVC mode and then perform the standard exception return procedure ?