# Hello SD Card Demo This example demonstrates SD card functionality on the CUBE32 board using the SDMMC interface and displaying results on an LVGL-based GUI. ## Features - **SD Card Hot-Swap Support**: Cards can be inserted/removed while the system is running - **Auto-Detection**: Automatic card detection and initialization using software polling - **Card Status Display**: Shows card type (SD/SDHC/SDXC/MMC), speed mode, bus width, and frequency - **Storage Information**: Displays total size, free space, and used space - **Directory Listing**: Shows root directory contents with file sizes - **Speed Test**: Measures read/write speeds with a 256KB test file ## Prerequisites To enable this demo in the CUBE32 Application Selection, you must first enable the following options in the SDK Configuration Menu (`idf.py menuconfig`): ### Required Configuration 1. **Enable Display** - Navigate to: `CUBE32 Board Configuration` → `Display Configuration` - Enable: `Enable Display` - Select your display model (CUBE_TFT_TOUCH_154 or CUBE_TFT_TOUCH_200) 2. **Enable LVGL** - Navigate to: `CUBE32 Board Configuration` → `Display Configuration` - Enable: `Enable LVGL` 3. **Enable SD Card** - Navigate to: `CUBE32 Board Configuration` → `SD Card Configuration` - Enable: `Enable SD Card` 4. **Select the Demo** - Navigate to: `CUBE32 Board Configuration` → `CUBE32 Application Selection` - Select: `Hello SD Card Demo` ## Hardware Requirements - CUBE32 board with SD card slot - FAT32 formatted SD card - TFT display (1.54" or 2.0" touch display) ## SD Card Pins (SDMMC 1-bit Mode) | Signal | GPIO | |--------|------| | CMD | GPIO7 | | CLK | GPIO15 | | D0 | GPIO4 | ## Usage 1. Configure the project using `idf.py menuconfig` as described above 2. Build and flash: `idf.py build flash monitor` 3. The demo will start automatically 4. Insert an SD card to see card information and directory listing 5. Press the "Speed Test" button to run read/write performance test 6. Remove/insert the card to test hot-swap functionality ## Console Output The demo also outputs card information to the serial console: ``` I (xxxx) cube32_sdcard: ======================================== I (xxxx) cube32_sdcard: SD Card Information: I (xxxx) cube32_sdcard: ======================================== I (xxxx) cube32_sdcard: Name: SD I (xxxx) cube32_sdcard: Card Type: SDHC I (xxxx) cube32_sdcard: Speed Mode: Default Speed I (xxxx) cube32_sdcard: Bus Width: 1-bit I (xxxx) cube32_sdcard: Max Frequency: 20000 kHz I (xxxx) cube32_sdcard: Total Size: 7456 MB I (xxxx) cube32_sdcard: Free Space: 7448 MB I (xxxx) cube32_sdcard: Used Space: 8 MB I (xxxx) cube32_sdcard: ======================================== ``` ## Notes - The SD card driver uses software card detection since CUBE32 does not have a hardware card detect pin - Card status is polled every 2 seconds to detect insertion/removal - The speed test creates a temporary file (`spdtest.tmp`) which is automatically deleted after the test
To create a project from this example, run:
idf.py create-project-from-example "cube32esp/cube32_bsp=0.0.17:hello_sdcard"