Skip to content

Commit d26b574

Browse files
authored
Merge pull request #2688 from HiFiPhile/3511_rtos
LPC55: FreeRTOS fix
2 parents 65b3edb + fbe0251 commit d26b574

File tree

6 files changed

+15
-1
lines changed

6 files changed

+15
-1
lines changed

examples/device/audio_4_channel_mic_freertos/src/FreeRTOSConfig/FreeRTOSConfig.h

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
#define configENABLE_FPU 1
6868
#define configENABLE_TRUSTZONE 0
6969
#define configMINIMAL_SECURE_STACK_SIZE ( 1024 )
70+
#define configRUN_FREERTOS_SECURE_ONLY 1
7071

7172
#define configUSE_PREEMPTION 1
7273
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0

examples/device/audio_test_freertos/src/FreeRTOSConfig/FreeRTOSConfig.h

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
#define configENABLE_FPU 1
6868
#define configENABLE_TRUSTZONE 0
6969
#define configMINIMAL_SECURE_STACK_SIZE ( 1024 )
70+
#define configRUN_FREERTOS_SECURE_ONLY 1
7071

7172
#define configUSE_PREEMPTION 1
7273
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0

examples/device/cdc_msc_freertos/src/FreeRTOSConfig/FreeRTOSConfig.h

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
#define configENABLE_FPU 1
6868
#define configENABLE_TRUSTZONE 0
6969
#define configMINIMAL_SECURE_STACK_SIZE ( 1024 )
70+
#define configRUN_FREERTOS_SECURE_ONLY 1
7071

7172
#define configUSE_PREEMPTION 1
7273
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0

examples/device/hid_composite_freertos/src/FreeRTOSConfig/FreeRTOSConfig.h

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
#define configENABLE_FPU 1
6868
#define configENABLE_TRUSTZONE 0
6969
#define configMINIMAL_SECURE_STACK_SIZE ( 1024 )
70+
#define configRUN_FREERTOS_SECURE_ONLY 1
7071

7172
#define configUSE_PREEMPTION 1
7273
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0

hw/bsp/lpc55/FreeRTOSConfig/FreeRTOSConfig.h

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#define configENABLE_FPU 1
5353
#define configENABLE_TRUSTZONE 0
5454
#define configMINIMAL_SECURE_STACK_SIZE (1024)
55+
#define configRUN_FREERTOS_SECURE_ONLY 1
5556

5657
#define configUSE_PREEMPTION 1
5758
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0

hw/bsp/lpc55/family.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,17 @@ void board_init(void) {
120120
// Init 96 MHz clock
121121
BootClockFROHF96M();
122122

123+
#if CFG_TUSB_OS == OPT_OS_NONE
123124
// 1ms tick timer
124125
SysTick_Config(SystemCoreClock / 1000);
125126

126-
#if CFG_TUSB_OS == OPT_OS_FREERTOS
127+
#elif CFG_TUSB_OS == OPT_OS_FREERTOS
128+
// Explicitly disable systick to prevent its ISR runs before scheduler start
129+
SysTick->CTRL &= ~1U;
130+
127131
// If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
128132
NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
133+
NVIC_SetPriority(USB1_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
129134
#endif
130135

131136
// Init all GPIO ports
@@ -239,6 +244,10 @@ void board_init(void) {
239244
// phytx &= ~(USBPHY_TX_D_CAL_MASK | USBPHY_TX_TXCAL45DM_MASK | USBPHY_TX_TXCAL45DP_MASK);
240245
// phytx |= USBPHY_TX_D_CAL(0x0C) | USBPHY_TX_TXCAL45DP(0x06) | USBPHY_TX_TXCAL45DM(0x06);
241246
// USBPHY->TX = phytx;
247+
248+
ARM_MPU_SetMemAttr(0, 0x44); // Normal memory, non-cacheable (inner and outer)
249+
ARM_MPU_SetRegion(0, ARM_MPU_RBAR(0x40100000, ARM_MPU_SH_NON, 0, 1, 1), ARM_MPU_RLAR(0x40104000, 0));
250+
ARM_MPU_Enable(MPU_CTRL_PRIVDEFENA_Msk | MPU_CTRL_HFNMIENA_Msk);
242251
#endif
243252
}
244253

0 commit comments

Comments
 (0)