From 259fb24ff9084c4c9ae9b3e857b0a942be4b56b5 Mon Sep 17 00:00:00 2001 From: rmanach Date: Fri, 21 Feb 2025 12:02:48 +0100 Subject: [PATCH] update doc + enable multicore --- README.md | 12 +++++++----- config/FreeRTOSConfig.h | 17 +++++++++++++++++ simple_led/CMakeLists.txt | 16 ++-------------- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 756d06e..3ae6ba8 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,23 @@ # Picoco -A repository to store Rasbperry Pico C projects. +A repository to store Rasbperry Pico C sample projects. It uses the **Freenove Super Starter Kit For Raspberry Pi Pico**, the tutorial and ressources can be found [here](https://github.com/Freenove/Freenove_Super_Starter_Kit_for_Raspberry_Pi_Pico). -The official documentation to start with the Raspberry Pi Pico: [Getting started with Raspberry Pi Pico-series](https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf). +The official documentation to start with the Raspberry Pi Pico: [Getting started with Raspberry Pi Pico-series](https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf). Some examples can be found here: [github.com/raspberrypi/pico-examples](https://github.com/raspberrypi/pico-examples). + +**NOTE**: the configuration defined in `config/FreeRTOSConfig.h` is specific for the **Raspberry Pi Pico 2 RP2350**. Feel free to update it for your Pico spec. ## Installation -In order to build and deploy the binary in the Raspberry Pi Pico, you have to install the **Pico C SDK** and **Picotool**. +In order to build and deploy the binary in the Raspberry Pi Pico, you have to install the **Pico C SDK**, **Picotool** & **FreeRTOS Raspberry Kernel**. -So, you need to execute the following command that will installed both: +So, you need to execute the following command that will installed all: ```bash make install ``` -**NOTE**: this will install the **SDK** and **Picotool** in the current directory. If you want to set an other intallation path, +**NOTE**: this will install the **SDK**, **Picotool** and **FreeRTOS** in the current directory. If you want to set an other intallation path, set the `INSTALL_PATH` variable. The `INSTALL_PATH` directory must exists, create it before and make sure user have write rights. The **SDK** and **Picotool** version used is: **2.1.0**. diff --git a/config/FreeRTOSConfig.h b/config/FreeRTOSConfig.h index 8db118c..fbee0ef 100644 --- a/config/FreeRTOSConfig.h +++ b/config/FreeRTOSConfig.h @@ -19,6 +19,7 @@ #define configUSE_IDLE_HOOK 0 // 1: Use Idle hook function #define configUSE_TICK_HOOK 0 // 1: Use Tick hook function #define configIDLE_SHOULD_YIELD 1 // 1: Idle task yields to same priority tasks +#define configUSE_PASSIVE_IDLE_HOOK 0 // No passive idle hook (SMP-specific) // System Clock Configuration #define configCPU_CLOCK_HZ ((unsigned long)150000000) // CPU frequency: 150 MHz for RP2350 @@ -58,11 +59,27 @@ // Hardware Specific Configuration #define configENABLE_FPU 1 // 1: Enable Floating Point Unit +#define configUSE_TASK_FPU_SUPPORT 1 // Enable FPU context save/restore #define configENABLE_TRUSTZONE 0 // 1: Enable TrustZone +#define configRUN_FREERTOS_SECURE_ONLY 0 // Non-secure mode to match port #define configENABLE_MPU 0 // 1: Enable Memory Protection Unit (defined twice in original) #define configRUN_FREERTOS_SECURE_ONLY 1 // 1: Run in secure mode only #define configUSE_16_BIT_TICKS 0 // 0: Use 32-bit ticks, 1: Use 16-bit ticks +// SMP Configuration +#define configNUMBER_OF_CORES 2 // RP2350 has 2 cores +#if configNUMBER_OF_CORES > 1 +#define configUSE_SMP 1 // Enable Symmetric Multiprocessing +#define configUSE_CORE_AFFINITY 1 +#define configSMP_SPINLOCK_0 0 // Spinlock 0 for SMP synchronization +#define configSMP_SPINLOCK_1 1 // Spinlock 1 (optional, depending on port) + +/* Fallback for missing portmacro.h definition */ +#ifndef taskDISABLE_INTERRUPTS +#define taskDISABLE_INTERRUPTS() __asm volatile ("cpsid i" ::: "memory") +#endif +#endif + // API Inclusion Configuration #define INCLUDE_vTaskPrioritySet 1 // Include task priority set API #define INCLUDE_uxTaskPriorityGet 1 // Include task priority get API diff --git a/simple_led/CMakeLists.txt b/simple_led/CMakeLists.txt index f50af74..2ea410d 100644 --- a/simple_led/CMakeLists.txt +++ b/simple_led/CMakeLists.txt @@ -17,18 +17,6 @@ set(FREERTOS_CONFIG_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../config) include(${FREERTOS_SRC_DIRECTORY}/portable/ThirdParty/GCC/RP2350_ARM_NTZ/FreeRTOS_Kernel_import.cmake) -# add_library(FreeRTOS STATIC -# ${FREERTOS_SRC_DIRECTORY}/event_groups.c -# ${FREERTOS_SRC_DIRECTORY}/list.c -# ${FREERTOS_SRC_DIRECTORY}/queue.c -# ${FREERTOS_SRC_DIRECTORY}/stream_buffer.c -# ${FREERTOS_SRC_DIRECTORY}/tasks.c -# ${FREERTOS_SRC_DIRECTORY}/timers.c -# ${FREERTOS_SRC_DIRECTORY}/portable/MemMang/heap_3.c -# ${FREERTOS_SRC_DIRECTORY}/portable/GCC/ARM_CM33_NTZ/non_secure/port.c -# ${FREERTOS_SRC_DIRECTORY}/portable/GCC/ARM_CM33_NTZ/non_secure/portasm.c -# ) - # Include FreeRTOS directories include_directories( ${FREERTOS_CONFIG_DIRECTORY} @@ -60,11 +48,11 @@ pico_set_program_version(simple_led "0.1") target_link_libraries( simple_led pico_stdlib + pico_multicore hardware_exception - # FreeRTOS ) -pico_enable_stdio_uart(simple_led 1) +pico_enable_stdio_uart(simple_led 0) pico_enable_stdio_usb(simple_led 1) pico_add_extra_outputs(simple_led)