Confusion regarding thread mode

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Confusion regarding thread mode

549 Views
reubennoronha
Contributor I

Hello All,

I've written a bootloader for my custom board with a Kinetis K61.

The bootloader runs on MQX and has USB + MFS functionality(I extended the mfs_usb example to include more code)

The application(formware to be upgraded) too has an OS(RTXC)

The bootloader writes the Application to DDR, then jumps to a specific location in the DDR and starts executing from there.

The problem I'm facing is that the application code contains the following 2 lines of code in a function called Init_OS() :

#define THREAD_PRIVELEGED (0ul << 0)

#define TSTACK_PROCESS      (1ul << 1)

Q__set_PSP(Q__get_MSP() );

Q__set_CONTROL(THREAD_PRIVILEGED | TSTACK_PROCESS);

On exiting the function that contains the above code, I get an exception(either undefined instruction or usage fault)

If I comment out these 2 lines, there are no issues faced.

1) What could be the issue ?

2) Is it possible that MQX(which is in the bootloader) has already initialized the thread mode and hence wont allow the application OS to make changes ?

3) Is there a work around ?

0 Kudos
3 Replies

363 Views
soledad
NXP Employee
NXP Employee

Hello Reuben ,

Which MQX version are you using??

Regards

Soledad

0 Kudos

363 Views
reubennoronha
Contributor I

We're using MQX 4.1

Would you be kind enough to answer my doubts above ?

0 Kudos

363 Views
soledad
NXP Employee
NXP Employee

Hello Reuben,

Please check the below thread

In MQX are all the threads in privileged mode ? or do we need to enable them in privilege mode


Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos