In order to get our application with MQX 4.2 working on our board I had to set the OSC0 clock source (EXTAL0) to a 50 MHz clock instead of a crystal and to change the PRDIV value to divide by 5 to make the clock between 8 and 16 MHz at the PLL entrance and than set the VDIV to 24/36 for RUN/HSRUN modes.

Like in the MQX SPI example, we have a NOR Flash connected to SPI2 and after a few reading and writing cycles it gets stuck at the following code segment where the semaphore is never released:

As I wrote in the service request the fact that you used MQX 4.2.0.1 may be the reason the you did not see the bug indeed, but not because it was resolved.

The patch does not change any code in the SPI driver.

As I wrote in my original post the problem disappears, if the code is changed by even a single line of code such as the print.

This indicates a memory leak problem or a timing problem which may appear later on in a larger application and is simply not being reproduced with the current application because you made a change to the code.