I’m having a strange problem. I have an application that uses FreeRTOS and I’ve been building debug versions on MPLAB-X for a couple of months now. I switched to a release build today and the program builds but stops running after starting the scheduler. I’ve stripped out all of my code except the toggling of an LED when a queue times out in the main loop. There is now only one task running with a single queue. If I switch to a debug build, it works fine. It’s a newer processor from Microchip, the PIC32MX250F128D. I have another application for a different client that does not use FreeRTOS and it builds and deploys a release version with no problems. I have the Dotstack Bluetooth stack in the app that doesn’t work in release mode but I have it commented out for now. I know it’s probably something stupid that I’m missing but… I upgraded to the latest stable build of FreeRTOS, V 7.1.1 and that didn’t fix the problem. I recently upgraded the compiler to the new xC32 compiler and have tried it and the 2.02 version of the C32 compiler and neither one works. Same symptoms, builds fine, stops after starting up the task scheduler.
XC32 is GCC right? How far up did you crank the optimization? I have no direct experience of that particular compiler, but it is not uncommon for GCC to be overly optimistic at the top optimization levels. What happens if you optimize at O2? There will not be much difference between O2 and O3 in performance anyway.
Same linker file. I have not set anything different between the debug and release modes. What do you think the problem is related to? It seems as if the timer isn’t running that is used for the scheduler.
If the debug build works, but the release build does not work, there must be a difference between the two. I’m afraid I cannot guess what that might be - you have both builds in front of you and I don’t. Maybe you could look at the command line generated by two builds (shown as the code builds) to see what the differences are.
Using a bit twiddler to toggle an LED I managed to confirm my suspicion. Timer 1 is used by the FreeRTOS scheduler and is not working properly in the release build. I put the LED toggle in the starting of the timer and the code gets there. If I move it to the T1 interrupt handler, it never gets there. Interrupts are enabled because my timer 2 interrupt will toggle the LED but the timer 1 interrupt never fires. I’ll take a look at the command lines next….
I found the problem. It turned out to be the Bluetooth stack, which required an update to be used with the XC32 compiler. Even though I commented out it’s use in my first testing, it had to be removed entirely from the project. I received an update from the stack vendor and everything is happy now.