Astralixi Pico OS Megathread

This is my CMakeLists.txt file:

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.

Devlog

Great News Everyone, When I flashed the OS to my PicoCalc, the OS works almost as intended.

Most commands are working, but I still have a few to tweak, especially the ones in relation to file management.

I appreciate the help of the people along the way, especially Blair.

Thanks, Astrox.

I plan on making a devlog short this Sunday, and maybe release version alpha, next saturday.

:slight_smile:

Why doesn’t this work? It just shows 0 for both values

void command_memory(void) {
    struct mallinfo info = mallinfo();
    printf("Total allocated: %d bytes\n", info.uordblks);
    printf("Total free: %d bytes\n", info.fordblks);
}

error fixed!

I just used a bunch of linker stuff :slight_smile:

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!

How annoyed would everyone be, if my Operating System used 2 out of 4 megabytes of flash, leaving 2 for the user?

Can someone explain this error message to me?

Also, NEW DEVLOG SHORT COMING OUT IN A FEW HOURS

New Devlog!!!

New API for Astralixi OS Version just Released!

@jblanked have you been getting issues with file management with Blair’s drivers?

No I don’t. I haven’t had any issues with any of Blair’s drivers. I actually just implemented the fat32_dir_create method today

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.

what did you set the defualt current working directory as, and how did you set it?

@jblanked do you have an answer to the above question, or do you know someone who might?

All I can suggest is to compare what you have with the working example that comes with PicoCalc Text Starter.

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”

This is my code for create/delete file/directory:
@jblanked @BlairLeduc

// Command to create a file
void command_createfile(const char *fullCommand) {
    fat32_file_t file;
    const char *filename = fullCommand + 11;  // Skip "create file"
    while (*filename == ' ') filename++;      // Skip spaces
    
    // Construct full path
    char filepath[FAT32_MAX_PATH_LEN];
    snprintf(filepath, sizeof(filepath), "%s%s", currentWorkingDirectory, filename);
    
    fat32_error_t result = fat32_create(&file, filepath);
    if (result == FAT32_OK) {
        printf("File '%s' created successfully.\n", filename);
        fat32_close(&file);
    } else {
        printf("Error creating file: %s\n", fat32_error_string(result));
    }
}

// Command to delete a file 
void command_deletefile(const char *fullCommand) {
    const char *filename = fullCommand + 11;  // Skip "delete file"
    while (*filename == ' ') filename++;      // Skip spaces
    
    // Construct full path
    char filepath[FAT32_MAX_PATH_LEN];
    snprintf(filepath, sizeof(filepath), "%s%s", currentWorkingDirectory, filename);
    
    fat32_error_t result = fat32_delete(filepath);
    if (result == FAT32_OK) {
        printf("File '%s' deleted successfully.\n", filename);
    } else {
        printf("Error deleting file: %s\n", fat32_error_string(result));
    }
}

// Command to create directory
void command_createdir(const char *fullCommand) {
    fat32_file_t dir;
    const char *dirname = fullCommand + 16;  // Skip "create directory"
    while (*dirname == ' ') dirname++;       // Skip spaces
    
    // Construct full path
    char dirpath[FAT32_MAX_PATH_LEN];
    snprintf(dirpath, sizeof(dirpath), "%s%s", currentWorkingDirectory, dirname);
    
    fat32_error_t result = fat32_dir_create(&dir, dirpath);
    if (result == FAT32_OK) {
        printf("Directory '%s' created successfully.\n", dirname);
        fat32_close(&dir);
    } else {
        printf("Error creating directory: %s\n", fat32_error_string(result));
    }
}

// Command to delete directory
void command_deletedir(const char *fullCommand) {
    const char *dirname = fullCommand + 16;  // Skip "delete directory"
    while (*dirname == ' ') dirname++;       // Skip spaces
    
    // Construct full path
    char dirpath[FAT32_MAX_PATH_LEN];
    snprintf(dirpath, sizeof(dirpath), "%s%s", currentWorkingDirectory, dirname);
    
    fat32_error_t result = fat32_delete(dirpath);
    if (result == FAT32_OK) {
        printf("Directory '%s' deleted successfully.\n", dirname);
    } else {
        printf("Error deleting directory: %s\n", fat32_error_string(result));
    }
}

Please don’t copy my code :slight_smile: