XC32 v4.00 error with building FreeRTOS' portasm.c

I am trying to build my code using the v4.00 xc32 compiler. I am integrating the source files required to have FreeRTOS scheduler running with my code but I am experiencing the following error when building portasm.c

"/opt/microchip/xc32/v4.00/bin/xc32-gcc" -g -x c -c -mprocessor=ATSAML10E16A -fno-common -MP -MMD -MF "build/default/production/rtos/portable/GCC/ARM_CM23_NTZ/non_secure/portasm.o.d" -o build/default/production/rtos/portable/GCC/ARM_CM23_NTZ/non_secure/portasm.o rtos/portable/GCC/ARM_CM23_NTZ/non_secure/portasm.c -DXPRJ_default=default -mdfp="/home/user/.packs/mhcp/Microchip.SAML10_DFP.3.6.95" -I "/home/user/.packs/arm/CMSIS/5.4.0/CMSIS/Core/Include" -I "rtos/include" -I "rtos/portable" -I "rtos/portable/GCC/ARM_CM23_NTZ/non_secure" -I.
/tmp/cc9CNPey.s: Assembler messages:
/tmp/cc9CNPey.s:118: Error: instruction not supported in Thumb16 mode -- `bics r0,r1'
/tmp/cc9CNPey.s:149: Error: instruction not supported in Thumb16 mode -- `orrs r0,r1'
make[1]: *** [Makefile-local.mk:149: build/default/production/rtos/portable/GCC/ARM_CM23_NTZ/non_secure/portasm.o] Error 255

This is incorporated in my Makefile as follows (I don’t think there is any problem here):

${OBJECTDIR}/rtos/portable/GCC/ARM_CM23_NTZ/non_secure/portasm.o: rtos/portable/GCC/ARM_CM23_NTZ/non_secure/portasm.c
@${MKDIR} "${OBJECTDIR}/rtos/portable/GCC/ARM_CM23_NTZ/non_secure"
@${RM} ${OBJECTDIR}/rtos/portable/GCC/ARM_CM23_NTZ/non_secure/portasm.o.d
@${RM} ${OBJECTDIR}/rtos/portable/GCC/ARM_CM23_NTZ/non_secure/portasm.o
${MP_CC} $(MP_EXTRA_CC_PRE) -g -x c -c -mprocessor=$(MP_PROCESSOR_OPTION) -fno-common -MP -MMD -MF "${OBJECTDIR}/rtos/portable/GCC/ARM_CM23_NTZ/non_secure/portasm.o.d" -o ${OBJECTDIR}/rtos/portable/GCC/ARM_CM23_NTZ/non_secure/portasm.o rtos/portable/GCC/ARM_CM23_NTZ/non_secure/portasm.c -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -mdfp="${DFP_DIR}" ${PACK_COMMON_OPTIONS} ${PACK_FREERTOS} -I.

Any ideas what I am doing wrong? I have tried both v3.01 and v4.00 xc32 compilers and the same problem exists. Does anyone have an example Makefile for an application using FreeRTOS?

The version of FreeRTOS that I am using is: FreeRTOS 202112.00

I’m not familiar with the XC32 version of GCC, other than for the PIC32, but normally when using GCC for a Cortex-M you would use the -mmcu, -march and -mtune command line options to tell the compiler exactly what you are building for. As a minimum I think either the -mmcu or -march is needed. In this case it is using -mprocessor, which probably does the same thing, but I’m not sure.

Hi @rtel thanks for your input. I will look into those options later but for now this is how I got around the problem (wrapping the relevant asm in #if directive):

void vRaisePrivilege( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */

{

    #if ( configENABLE_MPU == 1 )

    __asm volatile

    (

        "	mrs  r0, control								\n"/* Read the CONTROL register. */

        "	movs r1, #1										\n"/* r1 = 1. */

        "	bics r0, r1										\n"/* Clear the bit 0. */

        "	msr  control, r0								\n"/* Write back the new CONTROL value. */

        "	bx lr											\n"/* Return to the caller. */

        ::: "r0", "r1", "memory"

    );

    #endif /* configENABLE_MPU */

}

/*-----------------------------------------------------------*/



void vResetPrivilege( void ) /* __attribute__ (( naked )) */

{

    #if ( configENABLE_MPU == 1 )

    __asm volatile

    (

        "	mrs r0, control									\n"/* r0 = CONTROL. */

        "	movs r1, #1										\n"/* r1 = 1. */

        "	orrs r0, r1										\n"/* r0 = r0 | r1. */

        "	msr control, r0									\n"/* CONTROL = r0. */

        "	bx lr											\n"/* Return to the caller. */

        ::: "r0", "r1", "memory"

    );

    #endif /* configENABLE_MPU */
}

Not 100% sure but you may be able to remove the ‘s’ from movs and bics too.

To get this to build, I had to add this line to the instructions: " .syntax unified \n". So my vRaisePrivilege(void) looks like this:

void vRaisePrivilege( void ) /* __attribute__ (( naked )) PRIVILEGED_FUNCTION */

{

    __asm volatile
    (
        "	.syntax unified									\n"
        "	mrs  r0, control								\n"/* Read the CONTROL register. */
        "	movs r1, #1										\n"/* r1 = 1. */
        "	bics r0, r1										\n"/* Clear the bit 0. */
        "	msr  control, r0								\n"/* Write back the new CONTROL value. */
        "	bx lr											\n"/* Return to the caller. */
        ::: "r0", "r1", "memory"
    );
}

Thank you for taking time to report back your solution. I have added it in this PR - Add .syntax unified to GCC assembly functions by aggarg · Pull Request #538 · FreeRTOS/FreeRTOS-Kernel · GitHub