Xtensa Port and the MPU settings

Hello Community,

I’m trying to port the demo application to an actual hardware instance of the Xtensa LX-6 processor, with the hifi3 coprocessor. I’m using the “ThirdParty/XCC/Xtensa” port. I have also checked the kernel out from the foss-xtensa site, and I see that they are identical.

First issue, my build configuration sets XCHAL_CP_NUM to 1, which will bring in the MPU support. When I try to build port.c, I get an error with a mismatched prototype:

/*

  • Stack initialization
    */
    #if portUSING_MPU_WRAPPERS
    StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void
    *pvParameters,BaseType_t xRunPrivileged)
    #else
    StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void
    *pvParameters )
    #endif

The prototype in portable.h has an additional parameter:

#if ( portUSING_MPU_WRAPPERS == 1 )
#if ( portHAS_STACK_OVERFLOW_CHECKING == 1 )
StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
StackType_t * pxEndOfStack,
TaskFunction_t pxCode,
void * pvParameters,
BaseType_t xRunPrivileged,
xMPU_SETTINGS * xMPUSettings ) PRIVILEGED_FUNCTION;
#else
StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
TaskFunction_t pxCode,
void * pvParameters,
BaseType_t xRunPrivileged,
xMPU_SETTINGS * xMPUSettings ) PRIVILEGED_FUNCTION;
#endif /* if ( portHAS_STACK_OVERFLOW_CHECKING == 1 ) /
#else /
if ( portUSING_MPU_WRAPPERS == 1 ) /
#if ( portHAS_STACK_OVERFLOW_CHECKING == 1 )
StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
StackType_t * pxEndOfStack,
TaskFunction_t pxCode,
void * pvParameters ) PRIVILEGED_FUNCTION;
#else
StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
TaskFunction_t pxCode,
void * pvParameters ) PRIVILEGED_FUNCTION;
#endif
#endif /
if ( portUSING_MPU_WRAPPERS == 1 ) */

Is there some configuration to set? I think having a coprocessor will cause the MPU subsystem to be included (and this may not be the case in the sim). Further, I’m using the RI-2022.10 toolset, which ONLY supports the clang compiler (XCC has been deprecated). I’m looking for any suggestions here.

Thanks!!

Can you try this version maintained by Cadence - GitHub - foss-xtensa/amazon-freertos: Cloud-native IoT operating system for microcontrollers. With Xtensa architecture support.?

Hi Gaurav,
Thanks for the response. I did try building with the above repository, and I get the following errors:

  1. Cannot find asm-offsets.h, I cannot find this in any of my XtDevTools directories or in the build directories for any configuration. It is not in the repository.
  2. Having problem with MPU, getting the error “requested alignment is not a power of 2” in mpu_basic.c

Processor configuration for MPU

$ grep -r XCHAL_MPU_ALIGN *
src/config/core.h:#define XCHAL_MPU_ALIGN_REQ 1 /* MPU requires alignment of entries to background map /
src/config/core.h:#define XCHAL_MPU_ALIGN_BITS 0
src/config/core.h:#define XCHAL_MPU_ALIGN 0
src/cstub/xtensa/config/core-isa.h:#define XCHAL_MPU_ALIGN_REQ 1 /
MPU requires alignment of entries to background map /
src/cstub/xtensa/config/core-isa.h:#define XCHAL_MPU_ALIGN_BITS 0
src/cstub/xtensa/config/core-isa.h:#define XCHAL_MPU_ALIGN 0
src/cstub64/xtensa/config/core-isa.h:#define XCHAL_MPU_ALIGN_REQ 1 /
MPU requires alignment of entries to background map /
src/cstub64/xtensa/config/core-isa.h:#define XCHAL_MPU_ALIGN_BITS 0
src/cstub64/xtensa/config/core-isa.h:#define XCHAL_MPU_ALIGN 0
xtensa-elf/arch/include/xtensa/config/core-isa.h:#define XCHAL_MPU_ALIGN_REQ 1 /
MPU requires alignment of entries to background map /
xtensa-elf/arch/include/xtensa/config/core-isa.h:#define XCHAL_MPU_ALIGN_BITS 0
xtensa-elf/arch/include/xtensa/config/core-isa.h:#define XCHAL_MPU_ALIGN 0xtensa-elf/src/linux/misc/core.h:#define XCHAL_MPU_ALIGN_REQ 1 /
MPU requires alignment of entries to background map */
xtensa-elf/src/linux/misc/core.h:#define XCHAL_MPU_ALIGN_BITS 0
xtensa-elf/src/linux/misc/core.h:#define XCHAL_MPU_ALIGN 0

This seems closer, but still it seems that having the MPU turned on is problematic.

Please send me a DM.

I don’t know how to do that in this tool. Can you give me a hint? I only found a way to message your group.

If you click on Gaurav’s profile picture you should be the option to message him. It looks like this on my side

Also - I did take a look at the code base that Guarav pointed you to. For…

  1. Cannot find asm-offsets.h, I cannot find this in any of my XtDevTools directories or in the build directories for any configuration. It is not in the repository.

It looks like it’s being generated by the Xtensa Makefile. This should generate the asm-offsets.h file in the build directory. Can you try building and seeing if this file appears?

@kstribrn We connected and I redirected the user to Cadence (author of Xtensa port) as recommend by them.

1 Like