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_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 ?