cmake_minimum_required(VERSION 3.13)
cmake_policy(SET CMP0057 NEW)
# Check for PICO_SDK_PATH
if(NOT DEFINED ENV{PICO_SDK_PATH})
message(FATAL_ERROR "PICO_SDK_PATH environment variable is not set. Please set it to the path of your Pico SDK installation.")
endif()
set(PICO_SDK_PATH $ENV{PICO_SDK_PATH})
# Set user home directory
if(WIN32)
set(USERHOME $ENV{USERPROFILE})
else()
set(USERHOME $ENV{HOME})
endif()
# SDK and toolchain versions
set(sdkVersion 2.1.1)
set(toolchainVersion 14_2_Rel1)
set(picotoolVersion 2.1.1)
# Include Pico VS Code integration if available
set(picoVscode ${USERHOME}/.pico-sdk/cmake/pico-vscode.cmake)
if (EXISTS ${picoVscode})
include(${picoVscode})
endif()
# Set toolchain and import SDK
set(CMAKE_TOOLCHAIN_FILE ${PICO_TOOLCHAIN_FILE})
include(${PICO_SDK_PATH}/external/pico_sdk_import.cmake)
# Set board type to Pico 2 W
set(PICO_BOARD pico2_w CACHE STRING "Board type" FORCE)
# Project definition
project(astralixi-os LANGUAGES C CXX ASM)
# Set C and C++ standards
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
# Initialize the Pico SDK
pico_sdk_init()
# Add executable with all source files
add_executable(astralixi-os
astralixi-os.c
drivers/display.c
drivers/lcd.c
drivers/keyboard.c
drivers/sdcard.c
drivers/audio.c
drivers/fat32.c
drivers/picocalc.c
drivers/southbridge.c
drivers/font_8x10.c
)
# Generate PIO headers for audio
pico_generate_pio_header(astralixi-os ${CMAKE_CURRENT_LIST_DIR}/drivers/audio.pio)
# Link required libraries
target_link_libraries(astralixi-os
pico_stdlib
hardware_spi
hardware_uart
hardware_pwm
hardware_i2c
hardware_dma
hardware_gpio
hardware_adc
hardware_pio
pico_malloc
pico_cyw43_arch_lwip_threadsafe_background # Wi-Fi + lwIP support
pico_mbedtls # TLS/SSL support if needed
)
# Enable stdio over USB and disable UART stdio
pico_enable_stdio_usb(astralixi-os 1)
pico_enable_stdio_uart(astralixi-os 0)
# Add extra outputs (UF2, hex, bin files)
pico_add_extra_outputs(astralixi-os)
# Compiler options
target_compile_options(astralixi-os PRIVATE
-Wall
-Wextra
-Wno-unused-parameter
-Wno-unused-function
-Wno-sign-compare
-Wno-enum-conversion
)
# Include directories
target_include_directories(astralixi-os PRIVATE
${CMAKE_CURRENT_LIST_DIR}
drivers/
)
# Ensure mbedtls_config.h exists in the project root
configure_file(
${CMAKE_CURRENT_LIST_DIR}/mbedtls_config.h.in
${CMAKE_CURRENT_LIST_DIR}/mbedtls_config.h
COPYONLY
)
# Add project root to include directories for mbedtls_config.h
target_include_directories(astralixi-os PRIVATE
${CMAKE_CURRENT_LIST_DIR}
drivers/
)
# Ensure MBEDTLS_CONFIG_FILE is set for the build
target_compile_definitions(astralixi-os PRIVATE
CYW43_USE_SPI
PICO_CYW43_ARCH_LWIP=1
LWIP_IPV4=1
LWIP_DHCP=1
LWIP_TCP=1
LWIP_UDP=1
MBEDTLS_CONFIG_FILE="mbedtls_config.h"
)
# Enable compile commands export for IDE support
set(CMAKE_EXPORT_COMPILE_COMMANDS YES)
# Add preprocessor definitions for WiFi and networking
target_compile_definitions(astralixi-os PRIVATE
CYW43_USE_SPI
PICO_CYW43_ARCH_LWIP=1
LWIP_IPV4=1
LWIP_DHCP=1
LWIP_TCP=1
LWIP_UDP=1
)
I added picocalc_init() to my OS code and this happened during build:
PS C:\Users\...\coding\other\astralixiOS> cd build
PS C:\Users\...\coding\other\astralixiOS\build> cmake -G "Ninja" ..
PICO_SDK_PATH is C:/Users/.../.pico-sdk/sdk/2.1.1
Defaulting platform (PICO_PLATFORM) to 'rp2350' since not specified.
Defaulting target board (PICO_BOARD) to 'pico2_w' since not specified.
Using board configuration from C:/Users/.../.pico-sdk/sdk/2.1.1/src/boards/include/boards/pico2_w.h
Pico Platform (PICO_PLATFORM) is 'rp2350-arm-s'.
-- Defaulting build type to 'Release' since not specified.
Defaulting compiler (PICO_COMPILER) to 'pico_arm_cortex_m33_gcc' since not specified.
Configuring toolchain based on PICO_COMPILER 'pico_arm_cortex_m33_gcc'
Defaulting PICO_GCC_TRIPLE to 'arm-none-eabi'
CMake Warning at C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/find_compiler.cmake:22 (message):
PICO_TOOLCHAIN_PATH specified
(C:\Users\.../.pico-sdk/toolchain/14_2_Rel1), but not found there
Call Stack (most recent call first):
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/find_compiler.cmake:39 (pico_find_compiler)
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/pico_arm_gcc_common.cmake:25 (pico_find_compiler_with_triples)
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/pico_arm_cortex_m33_gcc.cmake:10 (include)
out sourced stuff/cmake-3.31.8-windows-x86_64/share/cmake-3.31/Modules/CMakeDetermineSystem.cmake:146 (include)
CMakeLists.txt:37 (project)
CMake Warning at C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/find_compiler.cmake:22 (message):
PICO_TOOLCHAIN_PATH specified
(C:\Users\.../.pico-sdk/toolchain/14_2_Rel1), but not found there
Call Stack (most recent call first):
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/find_compiler.cmake:39 (pico_find_compiler)
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/pico_arm_gcc_common.cmake:26 (pico_find_compiler_with_triples)
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/pico_arm_cortex_m33_gcc.cmake:10 (include)
out sourced stuff/cmake-3.31.8-windows-x86_64/share/cmake-3.31/Modules/CMakeDetermineSystem.cmake:146 (include)
CMakeLists.txt:37 (project)
CMake Warning at C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/find_compiler.cmake:22 (message):
PICO_TOOLCHAIN_PATH specified
(C:\Users\.../.pico-sdk/toolchain/14_2_Rel1), but not found there
Call Stack (most recent call first):
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/find_compiler.cmake:39 (pico_find_compiler)
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/pico_arm_gcc_common.cmake:28 (pico_find_compiler_with_triples)
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/pico_arm_cortex_m33_gcc.cmake:10 (include)
out sourced stuff/cmake-3.31.8-windows-x86_64/share/cmake-3.31/Modules/CMakeDetermineSystem.cmake:146 (include)
CMakeLists.txt:37 (project)
CMake Warning at C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/find_compiler.cmake:22 (message):
PICO_TOOLCHAIN_PATH specified
(C:\Users\.../.pico-sdk/toolchain/14_2_Rel1), but not found there
Call Stack (most recent call first):
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/find_compiler.cmake:39 (pico_find_compiler)
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/pico_arm_gcc_common.cmake:29 (pico_find_compiler_with_triples)
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/pico_arm_cortex_m33_gcc.cmake:10 (include)
out sourced stuff/cmake-3.31.8-windows-x86_64/share/cmake-3.31/Modules/CMakeDetermineSystem.cmake:146 (include)
CMakeLists.txt:37 (project)
-- The C compiler identification is GNU 13.3.0
-- The CXX compiler identification is GNU 13.3.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/msys64/mingw64/bin/arm-none-eabi-gcc.exe
-- Detecting C compiler ABI info
CMake Warning at C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/find_compiler.cmake:22 (message):
PICO_TOOLCHAIN_PATH specified
(C:\Users\.../.pico-sdk/toolchain/14_2_Rel1), but not found there
Call Stack (most recent call first):
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/find_compiler.cmake:39 (pico_find_compiler)
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/pico_arm_gcc_common.cmake:25 (pico_find_compiler_with_triples)
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/pico_arm_cortex_m33_gcc.cmake:10 (include)
C:/Users/.../Music/Aayan/Blender_Coding/coding/other/astralixiOS/build/CMakeFiles/3.31.8/CMakeSystem.cmake:6 (include)
C:/Users/.../Music/Aayan/Blender_Coding/coding/other/astralixiOS/build/CMakeFiles/CMakeScratch/TryCompile-12qp3s/CMakeLists.txt:5 (project)
CMake Warning at C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/find_compiler.cmake:22 (message):
PICO_TOOLCHAIN_PATH specified
(C:\Users\.../.pico-sdk/toolchain/14_2_Rel1), but not found there
Call Stack (most recent call first):
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/find_compiler.cmake:39 (pico_find_compiler)
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/pico_arm_gcc_common.cmake:26 (pico_find_compiler_with_triples)
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/pico_arm_cortex_m33_gcc.cmake:10 (include)
C:/Users/.../Music/Aayan/Blender_Coding/coding/other/astralixiOS/build/CMakeFiles/3.31.8/CMakeSystem.cmake:6 (include)
C:/Users/.../Music/Aayan/Blender_Coding/coding/other/astralixiOS/build/CMakeFiles/CMakeScratch/TryCompile-12qp3s/CMakeLists.txt:5 (project)
CMake Warning at C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/find_compiler.cmake:22 (message):
PICO_TOOLCHAIN_PATH specified
(C:\Users\.../.pico-sdk/toolchain/14_2_Rel1), but not found there
Call Stack (most recent call first):
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/find_compiler.cmake:39 (pico_find_compiler)
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/pico_arm_gcc_common.cmake:28 (pico_find_compiler_with_triples)
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/pico_arm_cortex_m33_gcc.cmake:10 (include)
C:/Users/.../Music/Aayan/Blender_Coding/coding/other/astralixiOS/build/CMakeFiles/3.31.8/CMakeSystem.cmake:6 (include)
C:/Users/.../Music/Aayan/Blender_Coding/coding/other/astralixiOS/build/CMakeFiles/CMakeScratch/TryCompile-12qp3s/CMakeLists.txt:5 (project)
CMake Warning at C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/find_compiler.cmake:22 (message):
PICO_TOOLCHAIN_PATH specified
(C:\Users\.../.pico-sdk/toolchain/14_2_Rel1), but not found there
Call Stack (most recent call first):
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/find_compiler.cmake:39 (pico_find_compiler)
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/pico_arm_gcc_common.cmake:29 (pico_find_compiler_with_triples)
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/pico_arm_cortex_m33_gcc.cmake:10 (include)
C:/Users/.../Music/Aayan/Blender_Coding/coding/other/astralixiOS/build/CMakeFiles/3.31.8/CMakeSystem.cmake:6 (include)
C:/Users/.../Music/Aayan/Blender_Coding/coding/other/astralixiOS/build/CMakeFiles/CMakeScratch/TryCompile-12qp3s/CMakeLists.txt:5 (project)
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/msys64/mingw64/bin/arm-none-eabi-gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
CMake Warning at C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/find_compiler.cmake:22 (message):
PICO_TOOLCHAIN_PATH specified
(C:\Users\.../.pico-sdk/toolchain/14_2_Rel1), but not found there
Call Stack (most recent call first):
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/find_compiler.cmake:39 (pico_find_compiler)
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/pico_arm_gcc_common.cmake:25 (pico_find_compiler_with_triples)
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/pico_arm_cortex_m33_gcc.cmake:10 (include)
C:/Users/.../Music/Aayan/Blender_Coding/coding/other/astralixiOS/build/CMakeFiles/3.31.8/CMakeSystem.cmake:6 (include)
C:/Users/.../Music/Aayan/Blender_Coding/coding/other/astralixiOS/build/CMakeFiles/CMakeScratch/TryCompile-3mq2py/CMakeLists.txt:5 (project)
CMake Warning at C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/find_compiler.cmake:22 (message):
PICO_TOOLCHAIN_PATH specified
(C:\Users\.../.pico-sdk/toolchain/14_2_Rel1), but not found there
Call Stack (most recent call first):
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/find_compiler.cmake:39 (pico_find_compiler)
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/pico_arm_gcc_common.cmake:26 (pico_find_compiler_with_triples)
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/pico_arm_cortex_m33_gcc.cmake:10 (include)
C:/Users/.../Music/Aayan/Blender_Coding/coding/other/astralixiOS/build/CMakeFiles/3.31.8/CMakeSystem.cmake:6 (include)
C:/Users/.../Music/Aayan/Blender_Coding/coding/other/astralixiOS/build/CMakeFiles/CMakeScratch/TryCompile-3mq2py/CMakeLists.txt:5 (project)
CMake Warning at C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/find_compiler.cmake:22 (message):
PICO_TOOLCHAIN_PATH specified
(C:\Users\.../.pico-sdk/toolchain/14_2_Rel1), but not found there
Call Stack (most recent call first):
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/find_compiler.cmake:39 (pico_find_compiler)
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/pico_arm_gcc_common.cmake:28 (pico_find_compiler_with_triples)
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/pico_arm_cortex_m33_gcc.cmake:10 (include)
C:/Users/.../Music/Aayan/Blender_Coding/coding/other/astralixiOS/build/CMakeFiles/3.31.8/CMakeSystem.cmake:6 (include)
C:/Users/.../Music/Aayan/Blender_Coding/coding/other/astralixiOS/build/CMakeFiles/CMakeScratch/TryCompile-3mq2py/CMakeLists.txt:5 (project)
CMake Warning at C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/find_compiler.cmake:22 (message):
PICO_TOOLCHAIN_PATH specified
(C:\Users\.../.pico-sdk/toolchain/14_2_Rel1), but not found there
Call Stack (most recent call first):
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/find_compiler.cmake:39 (pico_find_compiler)
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/util/pico_arm_gcc_common.cmake:29 (pico_find_compiler_with_triples)
C:/Users/.../.pico-sdk/sdk/2.1.1/cmake/preload/toolchains/pico_arm_cortex_m33_gcc.cmake:10 (include)
C:/Users/.../Music/Aayan/Blender_Coding/coding/other/astralixiOS/build/CMakeFiles/3.31.8/CMakeSystem.cmake:6 (include)
C:/Users/.../Music/Aayan/Blender_Coding/coding/other/astralixiOS/build/CMakeFiles/CMakeScratch/TryCompile-3mq2py/CMakeLists.txt:5 (project)
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/msys64/mingw64/bin/arm-none-eabi-g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Build type is Release
-- Found Python3: C:/Users/.../AppData/Local/Programs/Python/Python313/python.exe (found version "3.13.0") found components: Interpreter
TinyUSB available at C:/Users/.../.pico-sdk/sdk/2.1.1/lib/tinyusb/src/portable/raspberrypi/rp2040; enabling build support for USB.
BTstack available at C:/Users/.../.pico-sdk/sdk/2.1.1/lib/btstack
cyw43-driver available at C:/Users/.../.pico-sdk/sdk/2.1.1/lib/cyw43-driver
Pico W Bluetooth build support available.
lwIP available at C:/Users/.../.pico-sdk/sdk/2.1.1/lib/lwip
Pico W Wi-Fi build support available.
mbedtls available at C:/Users/.../.pico-sdk/sdk/2.1.1/lib/mbedtls
-- Configuring done (4.0s)
CMake Error at CMakeLists.txt:47 (add_executable):
Cannot find source file:
drivers/font_8x10.c
Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm
.ccm .cxxm .c++m .h .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90
.f95 .f03 .hip .ispc
-- Generating done (0.8s)
CMake Generate step failed. Build files cannot be regenerated correctly.
I found the fix to the error.
I mistakenly out the fileâs name in my CMakeLists.txt as font_8x10.c or something, but instead of underscore it was a dash.
now I just got to make ALL the file management related commands work, then I can fix alignment issues, maybe add a few new feature, final error fixing, and then release!
Yeah because I have made commands for create/delete file/directory and none of them work and neither does change directory because it comes up with file/directory not found. Blair told me that his drivers donât accept drive letters, so I donât know how I can have the base B: as default.
Take a look at Blairâs examples. In my experience, you donât need to use fat32_set_current_dir unless youâre trying to read multiple unknown named files from a directory, otherwise you can just open and read/write to the file directly.
I donât think the error is with the current working directory being set. The cd, ls, pwd and open file commands all work. When I try to do any of the create/delete file/directory commands, it always comes up with an error. e.g when I do âcreate fileâ it comes up with something similar to âError creating file: Read operation failedâ