Astralixi Lyra OS Megathread

Pretty sure you need to tell cmake to target the 2350 or clean your build folder.

how can I tell it, I’ve already specified in my CMakeLists.txt file that the target board is the Pico 2W and it still tries to build for the Pico 1 series

Why is it still building for rp2040… And then a stupid CMake debugger notification pops up, and them it says cannot find rp2350.cmake file in … directory and if I try to rebuild again it still goes for the rp2040 because it says not specified.

CMakeLists.txt File:

# Set the Pico SDK path using the environment variable
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})
# == DO NOT EDIT THE FOLLOWING LINES for the Raspberry Pi Pico VS Code Extension to work ==
if(WIN32)
    set(USERHOME $ENV{USERPROFILE})
else()
    set(USERHOME $ENV{HOME})
endif()
set(sdkVersion 2.1.1)
set(toolchainVersion 14_2_Rel1)
set(picotoolVersion 2.1.1)
set(picoVscode ${USERHOME}/.pico-sdk/cmake/pico-vscode.cmake)
if (EXISTS ${picoVscode})
    include(${picoVscode})
endif()
# ====================================================================================
# ================ 1. TOOLCHAIN FILE ================
# ***** MUST be at the absolute top! *****
set(CMAKE_TOOLCHAIN_FILE ${PICO_TOOLCHAIN_FILE})
# ================ 3. CMake MINIMUM VERSION ================
cmake_minimum_required(VERSION 3.3)
# ================ 4. IMPORT PICO SDK (BEFORE project()!) ================
include(${PICO_SDK_PATH}/external/pico_sdk_import.cmake)
# ================ 6. PROJECT DEFINITION ================
project(astralixi-os LANGUAGES C CXX)
# ================ 7. TARGET BOARD & STANDARDS ================
# Specify the platform 
set(PICO_PLATFORM rp2350)
# Specify the target board 
set(PICO_BOARD pico2_w CACHE STRING "Board type")
# C11/C++17 strongly recommended for Pico SDK!
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
# ================ 8. INITIALIZE PICO SDK ================
pico_sdk_init()
# ================ 9. EXECUTABLE & SOURCES ================
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
    # Add any other .c files in this format
)
# ================ 10. LINK LIBRARIES ================
target_link_libraries(astralixi-os
    pico_stdlib
    hardware_spi
    hardware_uart
    hardware_pwm
    hardware_i2c
    hardware_dma
    hardware_gpio
    hardware_adc
    pico_malloc
    pico_cyw43_arch
    cyw43_arch_threadsafe_background
)
# ================ 11. STDIO CONFIGURATION (USB only, no UART) ================
pico_enable_stdio_usb(astralixi-os 1)
pico_enable_stdio_uart(astralixi-os 0)
# ================ 12. GENERATE .uf2 & OTHER OUTPUTS ================
pico_add_extra_outputs(astralixi-os)
# ================ 13. COMPILER WARNINGS ================
target_compile_options(astralixi-os PRIVATE
    -Wall
    -Wextra
    -Wno-unused-parameter
)
# ================ 14. INCLUDE DIRECTORIES ================
target_include_directories(astralixi-os PRIVATE
    ${CMAKE_CURRENT_LIST_DIR}
    drivers/
)
# ================ 15. GLOBAL CONFIG ================
set(CMAKE_EXPORT_COMPILE_COMMANDS YES)

Try this command to verify the sdk sees the pico.
type build\CMakeCache.txt | findstr PICO_PLATFORM
If that doesn’t work try deleting your entire build folder & confirm that cmake.RP2350 exists, if not redownload the sdk or update it. If that doesn’t work try running this script,

# Name as: rebuild-rp2350.ps1


Write-Host "Checking Pico SDK path..."
if (-not $env:PICO_SDK_PATH) {
    Write-Host "ERROR: PICO_SDK_PATH is not set!"
    Write-Host "Please set it, e.g.: `setx PICO_SDK_PATH C:\path\to\pico-sdk`"
    exit 1
}

$PICO_SDK_PATH = $env:PICO_SDK_PATH
Write-Host "PICO_SDK_PATH = $PICO_SDK_PATH"

# Check if rp2350.cmake exists
$cmakeFile = Join-Path $PICO_SDK_PATH "cmake\preload\rp2350.cmake"
if (!(Test-Path $cmakeFile)) {
    Write-Host "    ERROR: $cmakeFile not found!"
    Write-Host "    Your Pico SDK might be outdated. Run:"
    Write-Host "    cd $PICO_SDK_PATH"
    Write-Host "    git fetch --all"
    Write-Host "    git checkout 2.1.1"
    Write-Host "    git submodule update --init"
    exit 1
} else {
    Write-Host "Found rp2350.cmake in SDK."
}

# Delete build folder if it exists
$buildDir = Join-Path $PWD "build"
if (Test-Path $buildDir) {
    Write-Host "Deleting old build folder..."
    Remove-Item -Recurse -Force $buildDir
}
Write-Host "Creating fresh build folder..."
New-Item -ItemType Directory -Path $buildDir | Out-Null

# Run CMake configure
Write-Host " Running CMake for rp2350 (pico2_w)..."
Push-Location $buildDir
cmake .. -DPICO_PLATFORM=rp2350 -DPICO_BOARD=pico2_w
Pop-Location

Write-Host "    Done! Now you can build with:"
Write-Host "    cmake --build build --parallel"

Save this to your rood directory and then run it, via this command

powershell -ExecutionPolicy Bypass -File rebuild-rp2350.ps1

if the script passes try building again.
cmake --build build --parallel

When you first ran cmake was it with the rp2040 or 2350? you need to wipe cmakes cache I believe. OR tell cmake to overwrite the initial Cmakecache.txt or add this to it.
PICO_PLATFORM:STRING=rp2350
PICO_BOARD:STRING=pico2_w

Welcome to software development.

1 Like

Isn’t the best moment in a developer’s life when they set up their workspace?

PICO_PLATFORM and _BOARD must be ā€œenvā€ vars, through the ā€œset PICO_PLATFORM=ā€ command on windows and ā€œexport PICO_PLATFORM=ā€ on bash/linux.
You can set them in CMakeFile using the ā€œENVā€ specifier too.

Take a look on my template project as comparison: https://git.jcsmith.fr/jackcartersmith/RP2xxx_CodePrjTemplate/src/branch/rp2350/

so would this one work in my case?

cmake_minimum_required(VERSION 3.12)

set(ENV{PICO_PLATFORM} "rp2350")

# Pull in SDK (must be before project)
include(pico_sdk_import.cmake)
#include(pico_extras_import_optional.cmake)

project(pico_examples C CXX ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

if (PICO_SDK_VERSION_STRING VERSION_LESS "2.1.0")
    message(FATAL_ERROR "Raspberry Pi Pico SDK version 2.1.0 (or later) required. Your version is ${PICO_SDK_VERSION_STRING}")
endif()

if (NOT DEFINED PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS)
    set(PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS 3000)
endif()

# Initialize the SDK
pico_sdk_init()

add_compile_options(-Wall
        -Wno-format          # int != int32_t as far as the compiler is concerned because gcc has int32_t as long int
        -Wno-unused-function # we have some for the docs that aren't called
        )
		
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
    add_compile_options(-Wno-maybe-uninitialized)
endif()

add_executable(main_prog
        main.c
        )

# pull in common dependencies
target_link_libraries(main_prog pico_stdlib)

# create map/bin/hex/uf2 file etc.
pico_add_extra_outputs(main_prog)
PS C:\Users\piyus\Music\Aayan\Blender_Coding\coding\other\astralixiOS\build> cmake ..
CMake Error at CMakeLists.txt:24 (cmake_minimum_required):
  Compatibility with CMake < 3.5 has been removed from CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.

  Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.


-- Configuring incomplete, errors occurred!

Where can I find the rp2350.cmake file? It didn’t come with my SDK installation according to the errors, I got everything else fixed except this right now.

You still need to adapt the template to your project, but seem ok.

But please use CMake 3, not the new 4. This broke the pico sdk (so much projects haven’t make the migration). I’m using the 3.31.8.

You should use " rp2350-arm-s", because you’ve 2 options between ARM and RISC-V cores.
Here is your new best friend! (You should really take a look on it…)

And when using cmake to generate project use the ā€œā€“freshā€ flag to force use clean variables instead from CMakeCache.txt.

Also btw…

I guess you now understand why having open sources helps both learning and other developers? :upside_down_face:

Your request is a bit cheeky. Be fair and share your github before asking for others links.
Without wishing to be rude, it is highly probable that your code doesn’t make the ā€œnew tech revolutionā€ and github is already a timestamp that proves you made it first.

Honestly, the only person who is currently ā€œstealingā€ code/IP on this topic is none other than you.

9 Likes

I actually hate CMake or VS Code, idk which but I got an older version of CMake, added it to my path, added it to the VSCode setting CMake path thing, and then in the terminal it says CMake is not an operatable batch file, command, …

Buddy, I’m not trying to be a hater but… I think its time to make this open source if you want more help from the community.

9 Likes

Agreed. Asking for help with getting your code to compile, while refusing to show your code except for little snippets, is not how you actually get help.

6 Likes

I’m closer to getting the code compiled, but i’ve found another error message, I kinda understand it, but I need help for clarifying it:

5 Likes

I’m not saying there is any errors, but during build these errors come for your drivers (and lots of them) @BlairLeduc

comparison is always false due to limited range of data type

e.g

C:/Users/.../coding/other/astralixiOS/drivers/display.c:334:36: warning: comparison is always true due to limited range of data type [-Wtype-limits]
  334 |                         if (colour < 256)
      |                                    ^
C:/Users/.../coding/other/astralixiOS/drivers/display.c:360:36: warning: comparison is always true due to limited range of data type [-Wtype-limits]
  360 |                         if (colour < 256)
      |                                    ^
C:/Users/.../coding/other/astralixiOS/drivers/display.c:549:13: warning: comparison is always false due to limited range of data type [-Wtype-limits]
  549 |     if (row < 0) // scroll at top of the screen
      |             ^
C:/Users/.../coding/other/astralixiOS/drivers/display.c:551:20: warning: comparison is always false due to limited range of data type [-Wtype-limits]
  551 |         while (row < 0) // scroll until y is non-negative

Oops, there isn’t lots of them, there is only 4 from what I see from a quick read of the error, it’s all for display.c btw.