AnsweredAssumed Answered

Confusion regarding thread mode

Question asked by Reuben Noronha on May 25, 2015
Latest reply on Jun 8, 2015 by soledad

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() );



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 ?