The PIC18F port in FreeRTOS has long had two bugs that make it unfit for reliable production use. One is a linker script which permits sections containing C variables to cross bank boundaries. The other is the built-in assumption that the .tmpdata and MATH_DATA sections won’t change size, which they do often both as a project evolves and between compiler versions.
This patch, made against FreeRTOSV7.1.0, contains both of my fixes.
A complete write-up of the issues involved and how my patch fixes them can be read here:
This patch also contains a small fix for the PIC18F demo projects because they do not compile cleanly since V7.0.0.
Since V7, FreeRTOS and C18 both define a header named “timers.h”. The PIC18F ports.c includes “timers.h” from the Microchip libraries for the OpenTimer1 function and associated definitions. Because of this, the FreeRTOS PIC18F demos don’t compile in FreeRTOS V7 as the Microchip “timers.h” is shadowed by the FreeRTOS header.
In order to make sure the demos compile, I have changed the order of the include paths in their Project Build Options to prioritize Microchip’s headers above FreeRTOS’s. This is sufficient to compile the demos, but in order to compile projects that use the FreeRTOS timers module a more complete solution will have to be devised.