Eagerly anticipating the port for PIC32MZ EF Family (with hardware floating point)

nathanwiebe wrote on Monday, August 31, 2015:

Now that the PIC32MZ EF family micros and dev boards are readily available, does anyone have any idea when a FreeRTOS port and demo project might be available for them?

I’ve been trying to use the existing PIC32MZ port (for the EC family), which works great, except that any operation that uses a float type inside a FreeRTOS thread throws an exception.

rtel wrote on Monday, August 31, 2015:

EF support is on the way! Sorry I don’t have a time estimate yet.

bigbillclark wrote on Tuesday, April 19, 2016:

Where is vPortTaskUsesFPU()

I’m using a PIC32MZ2048EFG100
compiler xc32 v1.40 with MPLABX 3.05
I had to upgrade because to v8.2.3 because older FreeRTOS versions die at the general_exception with 0x0B

I cannot compile FreeRTOS v8.2.3 because vPortTaskUsesFPU() is missing, also I cannot find where __mips_hard_float is defined, see error msg from compiler:

build/default/debug/_ext/843873356/port.o: In function vPortTaskUsesFPU': c:/projects/svn_i3c/trunk/firmware/src/freertos/source/portable/mplab/pic32mz/port.c:393: undefined reference to vPortInitialiseFPSCR

I’ve searched both v8.2.3 and v9.0.0rc2 for that function but cannot find it. I also used ctags+cscope to do the search. mplabx can’t find it. I’m stuck :frowning:

Should this function part of the released code or should I be looking else where? - thanks,

bowerymarc wrote on Tuesday, April 19, 2016:

I’ve been trying to take the PIC18F port from the most current FreeRTOS release (V8.2.3) and import it to the latest microchip tool chain - MPLABX. Tried both the XC8 and C18 compilers, neither give me properly running code (XC8 won’t even compile). I’m wondering if this is just hopeless…

bowerymarc wrote on Tuesday, April 19, 2016:

apologies for hijacking the thread I thought I was creating a new one. please ignore

edward-su wrote on Tuesday, April 19, 2016:

Hi Bill,

I am having the same problem with v8.2.1 using PIC32MZ512EFE64.
Then, the problem seems solved by upgrade to MPLAB Harmony V1.07.01.
The FreeRTOS V8.2.3 is integrated with new MPLAB Harmony.
FYI, vPortTaskUsesFPU() is in port.c
Hope this help.

Regards,

bigbillclark wrote on Tuesday, April 19, 2016:

I’m sorry I mistipped

I meant to say where is vPortInitialiseFPSCR() ?
I see this being called in port.c but the xc32 v1.40 compiler cannot find
the function and neither can I.

Bad news if FreeRTOS is moving to harmony :frowning:

edward-su wrote on Tuesday, April 19, 2016:

vPortInitialiseFPSCR() is at port_asm.S , the sam file directory where port.c located.

bigbillclark wrote on Tuesday, April 19, 2016:

Thanks for that pointer to port_asm.S

Now My problem is back to square one where the compiler xc32 v1.40 still
cannot link vPortInitialiseFPSCR() and if I simply // that line away it
will compile but then I get the portRESTORE_CONTEXT general_exception again.

Does any one know how to expand a macro so I can single
step portRESTORE_CONTEXT ??? this may be of no use since I believe the
problem in not being able to link in vPortInitialiseFPSCR().
Linker file ???

bigbillclark wrote on Wednesday, April 20, 2016:

I hope someone knows the answer to this FreeRTOS/xc32 linker problem with a
PIC32MZ EF

I’m not a MIPS assembler guru so can’t understand why this released stable
code does not link.
It compiles ok except if I take away the C extern then the compiler cannot
find the asm .global

There’s an assembler function vPortInitialiseFPSCR called by a C
function vPortTaskUsesFPU()
that does not link.
Apparently calling an assembler label .global is not enough for the linker
to find it.

---------------------

assembler file port_asm.S
++++++++++++++++++++++++++++
  .global vPortInitialiseFPSCR
  .ent  vPortInitialiseFPSCR

vPortInitialiseFPSCR:

/* Initialize the floating point status register in CP1. The initial
value is passed in a0. */
ctc1 a0, $f31
-------------------------------

C file port.c
+++++++++++++++++++++++
#if ( __mips_hard_float == 1 ) && ( configUSE_TASK_FPU_SUPPORT == 1 )

void vPortTaskUsesFPU(void)
{
            extern void vPortInitialiseFPSCR( uint32_t uxFPSCRInit );

portENTER_CRITICAL();

/* Initialise the floating point status register. */
vPortInitialiseFPSCR(portINITIAL_FPSCR);

/* A task is registering the fact that it needs a FPU context. Set the
FPU flag (saved as part of the task context). */
ulTaskHasFPUContext = pdTRUE;

portEXIT_CRITICAL();
}

#endif /* __mips_hard_float == 1 */
--------------------------------------------
linker output:
+++++++++++++++++++++
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
build/default/debug/_ext/843873356/port.o: In function `vPortTaskUsesFPU':
c:/projects/svn_i3c/trunk/firmware/src/freertos/source/portable/mplab/pic32mz/port.c:393:
undefined reference to `vPortInitialiseFPSCR'
-------------------------

I hope you all are having way better luck than me with the PIC32MZ EF and
FreeRTOS :slight_smile:
Thx,
Bill

rtel wrote on Wednesday, April 20, 2016:

Note the line in the code you pasted:

#if ( __mips_hard_float == 1 ) && ( configUSE_TASK_FPU_SUPPORT == 1 )

What is configUSE_TASK_FPU_SUPPORT set to in your project?

The FreeRTOS download contains a configuration with configUSE_TASK_FPU_SUPPORT set to 1, and another with configUSE_TASK_FPU_SUPPORT set to 0 - I just tired building both with XC1.40 and both built successfully.