From ba3f6a5e765651f0401839a5fdf4db74e481db30 Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Wed, 12 Jun 2024 17:00:10 -0300 Subject: [PATCH] Update MCXN947 FreeRTOS to CM33 port --- .../FreeRTOSConfig.h | 16 +++++++++++----- .../frdm-mcxn947-make-freertos-builtin/Makefile | 5 +++-- .../nxp/frdm-mcxn947-make-freertos-builtin/hal.c | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/examples/nxp/frdm-mcxn947-make-freertos-builtin/FreeRTOSConfig.h b/examples/nxp/frdm-mcxn947-make-freertos-builtin/FreeRTOSConfig.h index 887631ff..a3057744 100644 --- a/examples/nxp/frdm-mcxn947-make-freertos-builtin/FreeRTOSConfig.h +++ b/examples/nxp/frdm-mcxn947-make-freertos-builtin/FreeRTOSConfig.h @@ -22,8 +22,8 @@ #else #define configPRIO_BITS 3 #endif -#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 -#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 +#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY ((1U << (configPRIO_BITS)) - 1) +#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 3 #define configKERNEL_INTERRUPT_PRIORITY \ (configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS)) @@ -33,6 +33,12 @@ #define configASSERT(expr) \ if (!(expr)) printf("FAILURE %s:%d: %s\n", __FILE__, __LINE__, #expr) -#define vPortSVCHandler SVC_Handler -#define xPortPendSVHandler PendSV_Handler -#define xPortSysTickHandler SysTick_Handler +// https://www.freertos.org/2020/04/using-freertos-on-armv8-m-microcontrollers.html +#define configENABLE_FPU 1 +#define configENABLE_MPU 0 +#define configENABLE_TRUSTZONE 0 +#define configRUN_FREERTOS_SECURE_ONLY 1 + +//#define vPortSVCHandler SVC_Handler +//#define xPortPendSVHandler PendSV_Handler +//#define xPortSysTickHandler SysTick_Handler diff --git a/examples/nxp/frdm-mcxn947-make-freertos-builtin/Makefile b/examples/nxp/frdm-mcxn947-make-freertos-builtin/Makefile index 85aba78a..594de557 100644 --- a/examples/nxp/frdm-mcxn947-make-freertos-builtin/Makefile +++ b/examples/nxp/frdm-mcxn947-make-freertos-builtin/Makefile @@ -16,9 +16,10 @@ SOURCES += cmsis_mcu/devices/MCXN947/drivers/fsl_clock.c cmsis_mcu/devices/MCXN9 # FreeRTOS. MCXN947 has a Cortex-M33 (ARMv8) core, the CM4F port can be used if TrustZone and the MPU are not to be used SOURCES += FreeRTOS-Kernel/portable/MemMang/heap_4.c -SOURCES += FreeRTOS-Kernel/portable/GCC/ARM_CM4F/port.c +SOURCES += FreeRTOS-Kernel/portable/GCC/ARM_CM33_NTZ/non_secure/port.c +SOURCES += FreeRTOS-Kernel/portable/GCC/ARM_CM33_NTZ/non_secure/portasm.c CFLAGS += -IFreeRTOS-Kernel/include -CFLAGS += -IFreeRTOS-Kernel/portable/GCC/ARM_CM4F -Wno-conversion +CFLAGS += -IFreeRTOS-Kernel/portable/GCC/ARM_CM33_NTZ/non_secure -Wno-conversion -Wno-unused-parameter # Mongoose options are defined in mongoose_config.h SOURCES += mongoose.c net.c packed_fs.c diff --git a/examples/nxp/frdm-mcxn947-make-freertos-builtin/hal.c b/examples/nxp/frdm-mcxn947-make-freertos-builtin/hal.c index c6a4271f..3c32b0a3 100644 --- a/examples/nxp/frdm-mcxn947-make-freertos-builtin/hal.c +++ b/examples/nxp/frdm-mcxn947-make-freertos-builtin/hal.c @@ -24,7 +24,7 @@ uint64_t mg_millis(void) { // Let Mongoose use our uptime function void hal_init(void) { clock_init(); // Set system clock to SYS_FREQUENCY SystemCoreClock = SYS_FREQUENCY; // Update SystemCoreClock global var - SysTick_Config(SystemCoreClock / 1000); // Sys tick every 1ms +// SysTick_Config(SystemCoreClock / 1000); // Sys tick every 1ms // rng_init(); // TRNG is part of ELS and there is no info on that uart_init(UART_DEBUG, 115200); // Initialise UART