Skip to content

Commit 73eab6e

Browse files
committed
Merge remote-tracking branch 'origin/master' into adafruit_rp2350
2 parents 28c3505 + ccdc76c commit 73eab6e

File tree

16 files changed

+118
-20
lines changed

16 files changed

+118
-20
lines changed

cores/rp2040/_freertos.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,8 @@ extern "C" {
5454

5555
extern void __freertos_idle_other_core() __attribute__((weak));
5656
extern void __freertos_resume_other_core() __attribute__((weak));
57+
58+
extern void __freertos_task_exit_critical() __attribute__((weak));
59+
extern void __freertos_task_enter_critical() __attribute__((weak));
5760
}
5861
extern SemaphoreHandle_t __get_freertos_mutex_for_ptr(mutex_t *m, bool recursive = false);

cores/rp2040/wiring_private.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include <hardware/gpio.h>
2424
#include <hardware/sync.h>
2525
#include <map>
26+
#include "_freertos.h"
27+
2628

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

3436
extern "C" void interrupts() {
35-
auto core = get_core_num();
36-
if (!_irqStackTop[core]) {
37-
// ERROR
38-
return;
37+
if (__freeRTOSinitted) {
38+
__freertos_task_exit_critical();
39+
} else {
40+
auto core = get_core_num();
41+
if (!_irqStackTop[core]) {
42+
// ERROR
43+
return;
44+
}
45+
restore_interrupts(_irqStack[core][--_irqStackTop[core]]);
3946
}
40-
restore_interrupts(_irqStack[core][--_irqStackTop[core]]);
4147
}
4248

4349
extern "C" void noInterrupts() {
44-
auto core = get_core_num();
45-
if (_irqStackTop[core] == maxIRQs) {
46-
// ERROR
47-
panic("IRQ stack overflow");
50+
if (__freeRTOSinitted) {
51+
__freertos_task_enter_critical();
52+
} else {
53+
auto core = get_core_num();
54+
if (_irqStackTop[core] == maxIRQs) {
55+
// ERROR
56+
panic("IRQ stack overflow");
57+
}
58+
_irqStack[core][_irqStackTop[core]++] = save_and_disable_interrupts();
4859
}
49-
50-
_irqStack[core][_irqStackTop[core]++] = save_and_disable_interrupts();
5160
}
5261

5362
// Only 1 GPIO IRQ callback for all pins, so we need to look at the pin it's for and

docs/freertos.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
FreeRTOS SMP
22
============
33

4-
**NOTE:** FreeRTOS is not yet supported on the RP2350. PRs gladly accepted!
5-
64
The SMP (multicore) port of FreeRTOS is included with the core. This allows complex
75
task operations and real preemptive multithreading in your sketches. While the
86
``setup1`` and ``loop1`` way of multitasking is simplest for most folks, FreeRTOS

docs/rp2350.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ is supported by the core with some minor caveats:
77
* PSRAM is supported via a new ``pmalloc`` call and ``PSRAM`` variable decorator.
88
* Both RP2350A and RP2350B (48 GPIOs) are supported.
99
* Only ARM mode is available. For RISC-V (Hazard3), please use the raw SDK.
10-
* FreeRTOS and OTA are not yet supported.
10+
* OTA is not yet supported.
1111

1212
P2350-E9 Errata ("Increased leakage current on Bank 0 GPIO when pad input is enabled")
1313
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Submodule FreeRTOS-Kernel updated 32 files

libraries/FreeRTOS/src/FreeRTOS.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
#ifdef PICO_RP2350
2-
#error Sorry, FreeRTOS is not yet supported on the RP2350 in this core.
3-
#else
41
#include "../lib/FreeRTOS-Kernel/include/FreeRTOS.h"
5-
#endif

libraries/FreeRTOS/src/FreeRTOSConfig.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ extern unsigned long ulMainGetRunTimeCounterValue(void);
200200
#endif
201201
#endif
202202

203+
#define configENABLE_MPU 0
204+
#define configENABLE_TRUSTZONE 0
205+
#define configRUN_FREERTOS_SECURE_ONLY 1
206+
#define configENABLE_FPU 1
203207
/* The lowest interrupt priority that can be used in a call to a "set priority"
204208
function. */
205209
#ifndef configLIBRARY_LOWEST_INTERRUPT_PRIORITY
@@ -219,11 +223,16 @@ extern unsigned long ulMainGetRunTimeCounterValue(void);
219223
#ifndef configKERNEL_INTERRUPT_PRIORITY
220224
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
221225
#endif
226+
222227
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
223228
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
224229
#ifndef configMAX_SYSCALL_INTERRUPT_PRIORITY
230+
#ifdef PICO_RP2350
231+
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 16
232+
#else
225233
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
226234
#endif
235+
#endif
227236

228237
#ifndef configASSERT
229238
#ifdef __cplusplus
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "../lib/FreeRTOS-Kernel/include/mpu_syscall_numbers.h"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#ifdef PICO_RP2350
2+
#include "../lib/FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/mpu_wrappers_v2_asm.c"
3+
#endif

libraries/FreeRTOS/src/port.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
#ifdef PICO_RP2040
12
#include "../lib/FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2040/port.c"
3+
#else
4+
#include "../lib/FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2350_ARM_NTZ/non_secure/port.c"
5+
#endif

0 commit comments

Comments
 (0)