Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cores/rp2040/_freertos.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,8 @@ extern "C" {

extern void __freertos_idle_other_core() __attribute__((weak));
extern void __freertos_resume_other_core() __attribute__((weak));

extern void __freertos_task_exit_critical() __attribute__((weak));
extern void __freertos_task_enter_critical() __attribute__((weak));
}
extern SemaphoreHandle_t __get_freertos_mutex_for_ptr(mutex_t *m, bool recursive = false);
31 changes: 20 additions & 11 deletions cores/rp2040/wiring_private.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <hardware/gpio.h>
#include <hardware/sync.h>
#include <map>
#include "_freertos.h"


// Support nested IRQ disable/re-enable
#ifndef maxIRQs
Expand All @@ -32,22 +34,29 @@ static uint32_t _irqStackTop[2] = { 0, 0 };
static uint32_t _irqStack[2][maxIRQs];

extern "C" void interrupts() {
auto core = get_core_num();
if (!_irqStackTop[core]) {
// ERROR
return;
if (__freeRTOSinitted) {
__freertos_task_exit_critical();
} else {
auto core = get_core_num();
if (!_irqStackTop[core]) {
// ERROR
return;
}
restore_interrupts(_irqStack[core][--_irqStackTop[core]]);
}
restore_interrupts(_irqStack[core][--_irqStackTop[core]]);
}

extern "C" void noInterrupts() {
auto core = get_core_num();
if (_irqStackTop[core] == maxIRQs) {
// ERROR
panic("IRQ stack overflow");
if (__freeRTOSinitted) {
__freertos_task_enter_critical();
} else {
auto core = get_core_num();
if (_irqStackTop[core] == maxIRQs) {
// ERROR
panic("IRQ stack overflow");
}
_irqStack[core][_irqStackTop[core]++] = save_and_disable_interrupts();
}

_irqStack[core][_irqStackTop[core]++] = save_and_disable_interrupts();
}

// Only 1 GPIO IRQ callback for all pins, so we need to look at the pin it's for and
Expand Down
2 changes: 1 addition & 1 deletion libraries/FreeRTOS/lib/FreeRTOS-Kernel
Submodule FreeRTOS-Kernel updated 32 files
+2 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/.gitignore
+50 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/CMakeLists.txt
+70 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/FreeRTOS_Kernel_import.cmake
+23 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/LICENSE.md
+67 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/README.md
+73 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/library.cmake
+77 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/freertos_sdk_config.h
+2,055 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/mpu_wrappers_v2_asm.c
+2,743 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/port.c
+526 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/portasm.c
+114 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/portasm.h
+230 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/portmacro.h
+516 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/portmacrocommon.h
+96 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/rp2040_config.h
+66 −0 portable/ThirdParty/GCC/RP2350_ARM_NTZ/pico_sdk_import.cmake
+2 −0 portable/ThirdParty/GCC/RP2350_RISC-V/.gitignore
+50 −0 portable/ThirdParty/GCC/RP2350_RISC-V/CMakeLists.txt
+5 −0 portable/ThirdParty/GCC/RP2350_RISC-V/Documentation.url
+70 −0 portable/ThirdParty/GCC/RP2350_RISC-V/FreeRTOS_Kernel_import.cmake
+23 −0 portable/ThirdParty/GCC/RP2350_RISC-V/LICENSE.md
+65 −0 portable/ThirdParty/GCC/RP2350_RISC-V/README.md
+68 −0 portable/ThirdParty/GCC/RP2350_RISC-V/include/freertos_risc_v_chip_specific_extensions.h
+77 −0 portable/ThirdParty/GCC/RP2350_RISC-V/include/freertos_sdk_config.h
+264 −0 portable/ThirdParty/GCC/RP2350_RISC-V/include/portContext.h
+314 −0 portable/ThirdParty/GCC/RP2350_RISC-V/include/portmacro.h
+96 −0 portable/ThirdParty/GCC/RP2350_RISC-V/include/rp2040_config.h
+74 −0 portable/ThirdParty/GCC/RP2350_RISC-V/library.cmake
+4 −0 portable/ThirdParty/GCC/RP2350_RISC-V/notes.txt
+66 −0 portable/ThirdParty/GCC/RP2350_RISC-V/pico_sdk_import.cmake
+713 −0 portable/ThirdParty/GCC/RP2350_RISC-V/port.c
+461 −0 portable/ThirdParty/GCC/RP2350_RISC-V/portASM.S
+23 −0 portable/ThirdParty/GCC/RP2350_RISC-V/readme.txt
4 changes: 0 additions & 4 deletions libraries/FreeRTOS/src/FreeRTOS.h
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
#ifdef PICO_RP2350
#error Sorry, FreeRTOS is not yet supported on the RP2350 in this core.
#else
#include "../lib/FreeRTOS-Kernel/include/FreeRTOS.h"
#endif
9 changes: 9 additions & 0 deletions libraries/FreeRTOS/src/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ extern unsigned long ulMainGetRunTimeCounterValue(void);
#endif
#endif

#define configENABLE_MPU 0
#define configENABLE_TRUSTZONE 0
#define configRUN_FREERTOS_SECURE_ONLY 1
#define configENABLE_FPU 1
/* The lowest interrupt priority that can be used in a call to a "set priority"
function. */
#ifndef configLIBRARY_LOWEST_INTERRUPT_PRIORITY
Expand All @@ -219,11 +223,16 @@ extern unsigned long ulMainGetRunTimeCounterValue(void);
#ifndef configKERNEL_INTERRUPT_PRIORITY
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
#endif

/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#ifndef configMAX_SYSCALL_INTERRUPT_PRIORITY
#ifdef PICO_RP2350
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 16
#else
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
#endif
#endif

#ifndef configASSERT
#ifdef __cplusplus
Expand Down
1 change: 1 addition & 0 deletions libraries/FreeRTOS/src/mpu_syscall_numbers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../lib/FreeRTOS-Kernel/include/mpu_syscall_numbers.h"
3 changes: 3 additions & 0 deletions libraries/FreeRTOS/src/mpu_wrappers_v2_asm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#ifdef PICO_RP2350
#include "../lib/FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/mpu_wrappers_v2_asm.c"
#endif
4 changes: 4 additions & 0 deletions libraries/FreeRTOS/src/port.c
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
#ifdef PICO_RP2040
#include "../lib/FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2040/port.c"
#else
#include "../lib/FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/port.c"
#endif
3 changes: 3 additions & 0 deletions libraries/FreeRTOS/src/portasm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#ifdef PICO_RP2350
#include "../lib/FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/portasm.c"
#endif
4 changes: 4 additions & 0 deletions libraries/FreeRTOS/src/portmacro.h
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
#ifdef PICO_RP2350
#include "../lib/FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/portmacro.h"
#else
#include "../lib/FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2040/include/portmacro.h"
#endif
4 changes: 4 additions & 0 deletions libraries/FreeRTOS/src/rp2040_config.h
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
#ifdef PICO_RP2350
#include "../lib/FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure//rp2040_config.h"
#else
#include "../lib/FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2040/include/rp2040_config.h"
#endif
8 changes: 8 additions & 0 deletions libraries/FreeRTOS/src/variantHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ extern "C" {
bool __freertos_check_if_in_isr() {
return portCHECK_IF_IN_ISR();
}

void __freertos_task_exit_critical() {
taskEXIT_CRITICAL();
}

void __freertos_task_enter_critical() {
taskENTER_CRITICAL();
}
}


Expand Down
57 changes: 57 additions & 0 deletions libraries/FreeRTOS/tests/switching/switching.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Released to the public domain
#include <FreeRTOS.h>
#include <task.h>
#include <map>
#define STACK_SIZE 512
#define CORE_0 (1 << 0)
#define CORE_1 (1 << 1)

std::map<eTaskState, const char *> eTaskStateName { {eReady, "Ready"}, { eRunning, "Running" }, {eBlocked, "Blocked"}, {eSuspended, "Suspended"}, {eDeleted, "Deleted"} };
void ps() {
int tasks = uxTaskGetNumberOfTasks();
TaskStatus_t *pxTaskStatusArray = new TaskStatus_t[tasks];
unsigned long runtime;
tasks = uxTaskGetSystemState( pxTaskStatusArray, tasks, &runtime );
Serial.printf("# Tasks: %d\n", tasks);
Serial.printf("%-3s %-16s %-10s %s %s\n", "ID", "NAME", "STATE", "PRIO", "CYCLES");
for (int i = 0; i < tasks; i++) {
Serial.printf("%2d: %-16s %-10s %4d %lu\n", i, pxTaskStatusArray[i].pcTaskName, eTaskStateName[pxTaskStatusArray[i].eCurrentState], (int)pxTaskStatusArray[i].uxCurrentPriority, pxTaskStatusArray[i].ulRunTimeCounter);
}
delete[] pxTaskStatusArray;
}

static TaskHandle_t l[16];

void loop() {
ps();
delay(1000);
}

#define LOOP(z) \
void loop##z(void *params) {\
(void) params;\
while (true) {\
srand(z);\
int sum = 0;\
for (int i = 0; i < 500000; i++) sum+= rand();\
Serial.printf("L%d: %08x\n", z, sum);\
delay(1000 + z * 10);\
}\
}

LOOP(0);
LOOP(1);
LOOP(2);
LOOP(3);


void setup() {
xTaskCreate(loop0, "loop0", STACK_SIZE, NULL, 1, &l[0]);
vTaskCoreAffinitySet(l[0], CORE_0);
// xTaskCreate(loop1, "loop1", STACK_SIZE, NULL, 1, &l[1]);
// vTaskCoreAffinitySet(l[1], CORE_0);
// xTaskCreate(loop2, "loop2", STACK_SIZE, NULL, 1, &l[2]);
// vTaskCoreAffinitySet(l[2], CORE_0);
// xTaskCreate(loop3, "loop3", STACK_SIZE, NULL, 1, &l[3]);
// vTaskCoreAffinitySet(l[3], CORE_1);
}
1 change: 0 additions & 1 deletion tests/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ function skip_ino()
local skiplistrp2350=""
if [ "$PICO_BOARD" == "rp2350" ]; then
read -d '' skiplistrp2350 << EOL || true
/FreeRTOS/
/BTstackLib/
/JoystickBT/
/KeyboardBT/
Expand Down
Loading