Merge remote-tracking branch 'origin/master' into adafruit_rp2350
This commit is contained in:
commit
73eab6e224
16 changed files with 118 additions and 20 deletions
|
|
@ -54,5 +54,8 @@ extern "C" {
|
||||||
|
|
||||||
extern void __freertos_idle_other_core() __attribute__((weak));
|
extern void __freertos_idle_other_core() __attribute__((weak));
|
||||||
extern void __freertos_resume_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);
|
extern SemaphoreHandle_t __get_freertos_mutex_for_ptr(mutex_t *m, bool recursive = false);
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@
|
||||||
#include <hardware/gpio.h>
|
#include <hardware/gpio.h>
|
||||||
#include <hardware/sync.h>
|
#include <hardware/sync.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include "_freertos.h"
|
||||||
|
|
||||||
|
|
||||||
// Support nested IRQ disable/re-enable
|
// Support nested IRQ disable/re-enable
|
||||||
#ifndef maxIRQs
|
#ifndef maxIRQs
|
||||||
|
|
@ -32,22 +34,29 @@ static uint32_t _irqStackTop[2] = { 0, 0 };
|
||||||
static uint32_t _irqStack[2][maxIRQs];
|
static uint32_t _irqStack[2][maxIRQs];
|
||||||
|
|
||||||
extern "C" void interrupts() {
|
extern "C" void interrupts() {
|
||||||
auto core = get_core_num();
|
if (__freeRTOSinitted) {
|
||||||
if (!_irqStackTop[core]) {
|
__freertos_task_exit_critical();
|
||||||
// ERROR
|
} else {
|
||||||
return;
|
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() {
|
extern "C" void noInterrupts() {
|
||||||
auto core = get_core_num();
|
if (__freeRTOSinitted) {
|
||||||
if (_irqStackTop[core] == maxIRQs) {
|
__freertos_task_enter_critical();
|
||||||
// ERROR
|
} else {
|
||||||
panic("IRQ stack overflow");
|
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
|
// Only 1 GPIO IRQ callback for all pins, so we need to look at the pin it's for and
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
FreeRTOS SMP
|
FreeRTOS SMP
|
||||||
============
|
============
|
||||||
|
|
||||||
**NOTE:** FreeRTOS is not yet supported on the RP2350. PRs gladly accepted!
|
|
||||||
|
|
||||||
The SMP (multicore) port of FreeRTOS is included with the core. This allows complex
|
The SMP (multicore) port of FreeRTOS is included with the core. This allows complex
|
||||||
task operations and real preemptive multithreading in your sketches. While the
|
task operations and real preemptive multithreading in your sketches. While the
|
||||||
``setup1`` and ``loop1`` way of multitasking is simplest for most folks, FreeRTOS
|
``setup1`` and ``loop1`` way of multitasking is simplest for most folks, FreeRTOS
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ is supported by the core with some minor caveats:
|
||||||
* PSRAM is supported via a new ``pmalloc`` call and ``PSRAM`` variable decorator.
|
* PSRAM is supported via a new ``pmalloc`` call and ``PSRAM`` variable decorator.
|
||||||
* Both RP2350A and RP2350B (48 GPIOs) are supported.
|
* Both RP2350A and RP2350B (48 GPIOs) are supported.
|
||||||
* Only ARM mode is available. For RISC-V (Hazard3), please use the raw SDK.
|
* Only ARM mode is available. For RISC-V (Hazard3), please use the raw SDK.
|
||||||
* FreeRTOS and OTA are not yet supported.
|
* OTA is not yet supported.
|
||||||
|
|
||||||
P2350-E9 Errata ("Increased leakage current on Bank 0 GPIO when pad input is enabled")
|
P2350-E9 Errata ("Increased leakage current on Bank 0 GPIO when pad input is enabled")
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 6a303231eceaec08a26a7e534800ba4010cec58d
|
Subproject commit 2e588af95bad29aef577373512883370c9408c1c
|
||||||
|
|
@ -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"
|
#include "../lib/FreeRTOS-Kernel/include/FreeRTOS.h"
|
||||||
#endif
|
|
||||||
|
|
|
||||||
|
|
@ -200,6 +200,10 @@ extern unsigned long ulMainGetRunTimeCounterValue(void);
|
||||||
#endif
|
#endif
|
||||||
#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"
|
/* The lowest interrupt priority that can be used in a call to a "set priority"
|
||||||
function. */
|
function. */
|
||||||
#ifndef configLIBRARY_LOWEST_INTERRUPT_PRIORITY
|
#ifndef configLIBRARY_LOWEST_INTERRUPT_PRIORITY
|
||||||
|
|
@ -219,11 +223,16 @@ extern unsigned long ulMainGetRunTimeCounterValue(void);
|
||||||
#ifndef configKERNEL_INTERRUPT_PRIORITY
|
#ifndef configKERNEL_INTERRUPT_PRIORITY
|
||||||
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
|
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
|
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
|
||||||
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
|
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
|
||||||
#ifndef configMAX_SYSCALL_INTERRUPT_PRIORITY
|
#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) )
|
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef configASSERT
|
#ifndef configASSERT
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
||||||
1
libraries/FreeRTOS/src/mpu_syscall_numbers.h
Normal file
1
libraries/FreeRTOS/src/mpu_syscall_numbers.h
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
#include "../lib/FreeRTOS-Kernel/include/mpu_syscall_numbers.h"
|
||||||
3
libraries/FreeRTOS/src/mpu_wrappers_v2_asm.c
Normal file
3
libraries/FreeRTOS/src/mpu_wrappers_v2_asm.c
Normal file
|
|
@ -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
|
||||||
|
|
@ -1 +1,5 @@
|
||||||
|
#ifdef PICO_RP2040
|
||||||
#include "../lib/FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2040/port.c"
|
#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
libraries/FreeRTOS/src/portasm.c
Normal file
3
libraries/FreeRTOS/src/portasm.c
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#ifdef PICO_RP2350
|
||||||
|
#include "../lib/FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/portasm.c"
|
||||||
|
#endif
|
||||||
|
|
@ -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"
|
#include "../lib/FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2040/include/portmacro.h"
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -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"
|
#include "../lib/FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2040/include/rp2040_config.h"
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,14 @@ extern "C" {
|
||||||
bool __freertos_check_if_in_isr() {
|
bool __freertos_check_if_in_isr() {
|
||||||
return portCHECK_IF_IN_ISR();
|
return portCHECK_IF_IN_ISR();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void __freertos_task_exit_critical() {
|
||||||
|
taskEXIT_CRITICAL();
|
||||||
|
}
|
||||||
|
|
||||||
|
void __freertos_task_enter_critical() {
|
||||||
|
taskENTER_CRITICAL();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
57
libraries/FreeRTOS/tests/switching/switching.ino
Normal file
57
libraries/FreeRTOS/tests/switching/switching.ino
Normal file
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
@ -8,7 +8,6 @@ function skip_ino()
|
||||||
local skiplistrp2350=""
|
local skiplistrp2350=""
|
||||||
if [ "$PICO_BOARD" == "rp2350" ]; then
|
if [ "$PICO_BOARD" == "rp2350" ]; then
|
||||||
read -d '' skiplistrp2350 << EOL || true
|
read -d '' skiplistrp2350 << EOL || true
|
||||||
/FreeRTOS/
|
|
||||||
/BTstackLib/
|
/BTstackLib/
|
||||||
/JoystickBT/
|
/JoystickBT/
|
||||||
/KeyboardBT/
|
/KeyboardBT/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue