FreeRTOS on Pi Pico 2040

Hello,
I have ported FreeRTOS on Raspberry Pi Pico based on RP2040. It is a basic port that is able to blink the onboard LED. Most of the files are based on the Pico SDK. Where do I submit a pull request?

Build output:

*make -C boot2*
*make[1]: Entering directory '/home/romit/code/FreeRTOS/FreeRTOS/Demo/CORTEX_M0+_RaspberryPiPico_GCC/boot2'*
*mkdir -p build/boot2*
*arm-none-eabi-gcc -march=armv6-m -mcpu=cortex-m0plus -mthumb -O3 -I ../includes -c boot2_w25q080.S -o build/boot2/boot2.o*
*mkdir -p build/boot2*
*arm-none-eabi-gcc -march=armv6-m -mcpu=cortex-m0plus -mthumb -O3 -I ../includes -T ../linker_scripts/boot_stage2.ld --specs=nosys.specs  -*
*Xlinker -Map=build/output.map -nostartfiles build/boot2/boot2.o -o build/boot2/boot2.elf*
*arm-none-eabi-objcopy -Obinary build/boot2/boot2.elf build/boot2/boot2.bin*
*python3 pad_checksum -s 0xffffffff build/boot2/boot2.bin build/boot2/boot2_checksummed.S*
*make[1]: Leaving directory '/home/romit/code/FreeRTOS/FreeRTOS/Demo/CORTEX_M0+_RaspberryPiPico_GCC/boot2'*
*mkdir -p build//home/romit/code/FreeRTOS/FreeRTOS/Source/portable/GCC/ARM_CM0*
*arm-none-eabi-gcc -march=armv6-m -mcpu=cortex-m0plus -mthumb -O3 -I/home/romit/code/FreeRTOS/FreeRTOS/Demo/CORTEX_M0+_RaspberryPiPico_GCC*
*-I/home/romit/code/FreeRTOS/FreeRTOS/Source/include -I/home/romit/code/FreeRTOS/FreeRTOS/Source/portable/GCC/ARM_CM0 -I includes -DHEAP3 -*
*MMD -c /home/romit/code/FreeRTOS/FreeRTOS/Source/portable/GCC/ARM_CM0/port.c -o build//home/romit/code/FreeRTOS/FreeRTOS/Source/portable/G*
*CC/ARM_CM0/port.o*
*mkdir -p build//home/romit/code/FreeRTOS/FreeRTOS/Source*
*arm-none-eabi-gcc -march=armv6-m -mcpu=cortex-m0plus -mthumb -O3 -I/home/romit/code/FreeRTOS/FreeRTOS/Demo/CORTEX_M0+_RaspberryPiPico_GCC*
*-I/home/romit/code/FreeRTOS/FreeRTOS/Source/include -I/home/romit/code/FreeRTOS/FreeRTOS/Source/portable/GCC/ARM_CM0 -I includes -DHEAP3 -*
*MMD -c /home/romit/code/FreeRTOS/FreeRTOS/Source/tasks.c -o build//home/romit/code/FreeRTOS/FreeRTOS/Source/tasks.o*
*mkdir -p build//home/romit/code/FreeRTOS/FreeRTOS/Source*
*arm-none-eabi-gcc -march=armv6-m -mcpu=cortex-m0plus -mthumb -O3 -I/home/romit/code/FreeRTOS/FreeRTOS/Demo/CORTEX_M0+_RaspberryPiPico_GCC*
*-I/home/romit/code/FreeRTOS/FreeRTOS/Source/include -I/home/romit/code/FreeRTOS/FreeRTOS/Source/portable/GCC/ARM_CM0 -I includes -DHEAP3 -*
*MMD -c /home/romit/code/FreeRTOS/FreeRTOS/Source/list.c -o build//home/romit/code/FreeRTOS/FreeRTOS/Source/list.o*
*mkdir -p build//home/romit/code/FreeRTOS/FreeRTOS/Source*
*arm-none-eabi-gcc -march=armv6-m -mcpu=cortex-m0plus -mthumb -O3 -I/home/romit/code/FreeRTOS/FreeRTOS/Demo/CORTEX_M0+_RaspberryPiPico_GCC*
*-I/home/romit/code/FreeRTOS/FreeRTOS/Source/include -I/home/romit/code/FreeRTOS/FreeRTOS/Source/portable/GCC/ARM_CM0 -I includes -DHEAP3 -*
*MMD -c /home/romit/code/FreeRTOS/FreeRTOS/Source/queue.c -o build//home/romit/code/FreeRTOS/FreeRTOS/Source/queue.o*
*mkdir -p build//home/romit/code/FreeRTOS/FreeRTOS/Source*
*arm-none-eabi-gcc -march=armv6-m -mcpu=cortex-m0plus -mthumb -O3 -I/home/romit/code/FreeRTOS/FreeRTOS/Demo/CORTEX_M0+_RaspberryPiPico_GCC*
*-I/home/romit/code/FreeRTOS/FreeRTOS/Source/include -I/home/romit/code/FreeRTOS/FreeRTOS/Source/portable/GCC/ARM_CM0 -I includes -DHEAP3 -*
*MMD -c /home/romit/code/FreeRTOS/FreeRTOS/Source/timers.c -o build//home/romit/code/FreeRTOS/FreeRTOS/Source/timers.o*
*mkdir -p build//home/romit/code/FreeRTOS/FreeRTOS/Source*
*arm-none-eabi-gcc -march=armv6-m -mcpu=cortex-m0plus -mthumb -O3 -I/home/romit/code/FreeRTOS/FreeRTOS/Demo/CORTEX_M0+_RaspberryPiPico_GCC*
*-I/home/romit/code/FreeRTOS/FreeRTOS/Source/include -I/home/romit/code/FreeRTOS/FreeRTOS/Source/portable/GCC/ARM_CM0 -I includes -DHEAP3 -*
*MMD -c /home/romit/code/FreeRTOS/FreeRTOS/Source/event_groups.c -o build//home/romit/code/FreeRTOS/FreeRTOS/Source/event_groups.o*
*mkdir -p build//home/romit/code/FreeRTOS/FreeRTOS/Source/portable/MemMang*
*arm-none-eabi-gcc -march=armv6-m -mcpu=cortex-m0plus -mthumb -O3 -I/home/romit/code/FreeRTOS/FreeRTOS/Demo/CORTEX_M0+_RaspberryPiPico_GCC*
*-I/home/romit/code/FreeRTOS/FreeRTOS/Source/include -I/home/romit/code/FreeRTOS/FreeRTOS/Source/portable/GCC/ARM_CM0 -I includes -DHEAP3 -*
*MMD -c /home/romit/code/FreeRTOS/FreeRTOS/Source/portable/MemMang/heap_3.c -o build//home/romit/code/FreeRTOS/FreeRTOS/Source/portable/Mem*
*Mang/heap_3.o*
*mkdir -p build*
*arm-none-eabi-gcc -march=armv6-m -mcpu=cortex-m0plus -mthumb -O3 -I/home/romit/code/FreeRTOS/FreeRTOS/Demo/CORTEX_M0+_RaspberryPiPico_GCC*
*-I/home/romit/code/FreeRTOS/FreeRTOS/Source/include -I/home/romit/code/FreeRTOS/FreeRTOS/Source/portable/GCC/ARM_CM0 -I includes -DHEAP3 -*
*MMD -c bootrom.c -o build/bootrom.o*
*mkdir -p build*
*arm-none-eabi-gcc -march=armv6-m -mcpu=cortex-m0plus -mthumb -O3 -I/home/romit/code/FreeRTOS/FreeRTOS/Demo/CORTEX_M0+_RaspberryPiPico_GCC*
*-I/home/romit/code/FreeRTOS/FreeRTOS/Source/include -I/home/romit/code/FreeRTOS/FreeRTOS/Source/portable/GCC/ARM_CM0 -I includes -DHEAP3 -*
*MMD -c clocks.c -o build/clocks.o*
*mkdir -p build*
*arm-none-eabi-gcc -march=armv6-m -mcpu=cortex-m0plus -mthumb -O3 -I/home/romit/code/FreeRTOS/FreeRTOS/Demo/CORTEX_M0+_RaspberryPiPico_GCC*
*-I/home/romit/code/FreeRTOS/FreeRTOS/Source/include -I/home/romit/code/FreeRTOS/FreeRTOS/Source/portable/GCC/ARM_CM0 -I includes -DHEAP3 -*
*MMD -c gpio.c -o build/gpio.o*
*mkdir -p build*
*arm-none-eabi-gcc -march=armv6-m -mcpu=cortex-m0plus -mthumb -O3 -I/home/romit/code/FreeRTOS/FreeRTOS/Demo/CORTEX_M0+_RaspberryPiPico_GCC*
*-I/home/romit/code/FreeRTOS/FreeRTOS/Source/include -I/home/romit/code/FreeRTOS/FreeRTOS/Source/portable/GCC/ARM_CM0 -I includes -DHEAP3 -*
*MMD -c pll.c -o build/pll.o*
*mkdir -p build*
*arm-none-eabi-gcc -march=armv6-m -mcpu=cortex-m0plus -mthumb -O3 -I/home/romit/code/FreeRTOS/FreeRTOS/Demo/CORTEX_M0+_RaspberryPiPico_GCC*
*-I/home/romit/code/FreeRTOS/FreeRTOS/Source/include -I/home/romit/code/FreeRTOS/FreeRTOS/Source/portable/GCC/ARM_CM0 -I includes -DHEAP3 -*
*MMD -c startup.c -o build/startup.o*
*mkdir -p build*
*arm-none-eabi-gcc -march=armv6-m -mcpu=cortex-m0plus -mthumb -O3 -I/home/romit/code/FreeRTOS/FreeRTOS/Demo/CORTEX_M0+_RaspberryPiPico_GCC*
*-I/home/romit/code/FreeRTOS/FreeRTOS/Source/include -I/home/romit/code/FreeRTOS/FreeRTOS/Source/portable/GCC/ARM_CM0 -I includes -DHEAP3 -*
*MMD -c xosc.c -o build/xosc.o*
*mkdir -p build*
*arm-none-eabi-gcc -march=armv6-m -mcpu=cortex-m0plus -mthumb -O3 -I/home/romit/code/FreeRTOS/FreeRTOS/Demo/CORTEX_M0+_RaspberryPiPico_GCC*
*-I/home/romit/code/FreeRTOS/FreeRTOS/Source/include -I/home/romit/code/FreeRTOS/FreeRTOS/Source/portable/GCC/ARM_CM0 -I includes -DHEAP3 -*
*MMD -c blinky.c -o build/blinky.o*
*arm-none-eabi-gcc -march=armv6-m -mcpu=cortex-m0plus -mthumb -O3 -I/home/romit/code/FreeRTOS/FreeRTOS/Demo/CORTEX_M0+_RaspberryPiPico_GCC*
*-I/home/romit/code/FreeRTOS/FreeRTOS/Source/include -I/home/romit/code/FreeRTOS/FreeRTOS/Source/portable/GCC/ARM_CM0 -I includes -T linker*
*_scripts/memmap_default.ld --specs=nosys.specs  -Xlinker -Map=build/output.map -c crt0.S -o build/crt0.o*
*make -C elf2uf2*
*make[1]: Entering directory '/home/romit/code/FreeRTOS/FreeRTOS/Demo/CORTEX_M0+_RaspberryPiPico_GCC/elf2uf2'*
*mkdir -p build/elf2uf2*
*g++ -std=c++14  main.cpp -o build/elf2uf2/elf2uf2*
*make[1]: Leaving directory '/home/romit/code/FreeRTOS/FreeRTOS/Demo/CORTEX_M0+_RaspberryPiPico_GCC/elf2uf2'*
*arm-none-eabi-gcc -march=armv6-m -mcpu=cortex-m0plus -mthumb -O3 -I/home/romit/code/FreeRTOS/FreeRTOS/Demo/CORTEX_M0+_RaspberryPiPico_GCC*
*-I/home/romit/code/FreeRTOS/FreeRTOS/Source/include -I/home/romit/code/FreeRTOS/FreeRTOS/Source/portable/GCC/ARM_CM0 -I includes -T linker*
*_scripts/memmap_default.ld --specs=nosys.specs  -Xlinker -Map=build/output.map -Wl,--build-id=none -Wl,--gc-sections build//home/romit/cod*
*e/FreeRTOS/FreeRTOS/Source/portable/GCC/ARM_CM0/port.o build//home/romit/code/FreeRTOS/FreeRTOS/Source/tasks.o build//home/romit/code/Free*
*RTOS/FreeRTOS/Source/list.o build//home/romit/code/FreeRTOS/FreeRTOS/Source/queue.o build//home/romit/code/FreeRTOS/FreeRTOS/Source/timers*
*.o build//home/romit/code/FreeRTOS/FreeRTOS/Source/event_groups.o build//home/romit/code/FreeRTOS/FreeRTOS/Source/portable/MemMang/heap_3.*
*o build/bootrom.o build/clocks.o build/gpio.o build/pll.o build/startup.o build/xosc.o build/blinky.o build/crt0.o -o build/blinky.elf boo*
*t2/build/boot2/boot2_checksummed.S*
*elf2uf2/build/elf2uf2/elf2uf2 build/blinky.elf build/blinky.uf2*

Thanks
-Romit

1 Like

This is great - thanks. Did you make any changes to the kernel itself? If so you can create a pull request in the kernel’s git repo here: https://github.com/FreeRTOS/FreeRTOS-Kernel. For the project that builds the code you can create a pull request in the ‘hub’ repo which contains build projects and sub-modules in the kernel code here: https://github.com/FreeRTOS/FreeRTOS

For expectation management - there are a few projects working on bringing official FreeRTOS support to the Pico - including this interesting project in the SMP labs repo. We will gladly take all inputs :slight_smile: but will necessarily need to consolidate before finally upstreaming a single supported version.

I am curious to know if you needed to make any changes to the FreeRTOS kernel? I am able to run our GCC Cortex M0 port on pico without any changes.

Thanks.

Thanks for the reply. This is purely a hobby project.
No, I didn’t have to make any changes to the kernel. The changes are confined to ‘Demo’ only. I have used the M0+ cpu port and it works without any changes. Currently the port uses only Core0. Core1 is idle. Bulk of the code changes are based on the pico-sdk (though I have made changes to them).
As next steps, I aim to bring in more peripheral support for the 2040 and also multi-core and optimal power management support.
I will try to send a pull request soon.

Thank you.
-Romit

1 Like

No, I didn’t have to make any changes to the Kernel. The changes are in Demo.
Thanks
-Romit

Hi,
I have sent a pull request few days back. I see it is blocked on a FreeRTOS core check failure perhaps owing to license header. Most of the code is based on the PICO SDK which is BSD-3 Clause. I think if the code is accepted the BSD-3 clause should be present as well.

/*
 - * Copyright (c) 2021 Raspberry Pi (Trading) Ltd.
 + * FreeRTOS V202012.00
 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
   *
 - * SPDX-License-Identifier: BSD-3-Clause
 + * Permission is hereby granted, free of charge, to any person obtaining a copy of
 + * this software and associated documentation files (the "Software"), to deal in
 + * the Software without restriction, including without limitation the rights to
 + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 + * the Software, and to permit persons to whom the Software is furnished to do so,
 + * subject to the following conditions:

Any suggestions? If the changes are in the right direction then I can work on additional changes.

Thanks.

Hi - I don’t think this should a problem outside the kernel files so will need to check. Also want to ensure you saw my comment here FreeRTOS on Pi Pico 2040 - #2 by rtel regarding the need to consolidate the Pi Pico work before bringing examples into the upstream.

Sounds good. If there is anything that I can do to speed up the integration please let me know.