This repository demonstrates how to implement a Continuous Integration and Continuous Deployment (CI/CD) pipeline for ESP32-S3 projects using ESP-IDF, with a practical SPIFFS (SPI Flash File System) implementation example.
This project showcases a modern development workflow for ESP32-S3 firmware development, featuring:
- Containerized development environment with Docker
- CI/CD pipeline setup
- ESP-IDF framework integration
- SPIFFS implementation for efficient file storage on the ESP32-S3
- Best practices for ESP32-S3 firmware development
.
├── .gitignore # Git ignore file for ESP-IDF projects
├── Dockerfile # Docker configuration for ESP32-S3 development
├── .github/workflows/ # CI/CD pipeline configurations
├── main/ # Application source code
│ ├── spiffs_main.c # SPIFFS demo implementation main file
│ ├── include/ # Header files
│ └── CMakeLists.txt # Main component build configuration
├── pytest_spiffs.py # Python for testing SPIFFS
├── spiffs_data/ # Files to be included in SPIFFS partition
├── partitions.csv # Custom partition table with SPIFFS partition
├── CMakeLists.txt # Project build configuration
├── sdkconfig.defaults # Default ESP-IDF configuration
└── README.md # Project documentation
-
Clone this repository:
git clone https://github.com/yourusername/esp32-s3-cicd.git cd esp32-s3-cicd -
Build the Docker image:
docker build -t esp32s3-dev . -
Run the development container:
docker run -it --rm \ -v $(pwd):/workspace \ --device=/dev/ttyUSB0 \ esp32s3-devNote: Replace
/dev/ttyUSB0with your device path.
From within the Docker container:
idf.py buildThis will compile the application and package the SPIFFS data files.
From within the Docker container:
idf.py -p /dev/ttyUSB0 flashThis command flashes both the application and the SPIFFS partition.
If you only want to update the files in SPIFFS without reflashing the entire application:
idf.py -p /dev/ttyUSB0 spiffs-flashFrom within the Docker container:
idf.py -p /dev/ttyUSB0 monitorPress Ctrl+] to exit the monitor.
The SPIFFS example demonstrates:
- Mounting the SPIFFS filesystem
- Creating and writing to files
- Reading file contents
- Listing directory contents
- Deleting files
- File system statistics (free/used space)
This repository uses GitHub Actions for CI/CD. The pipeline:
- Builds the project for ESP32-S3
- Runs tests including SPIFFS functionality tests
- Creates firmware artifacts (app binary and SPIFFS image)
- (Optional) Deploys firmware to devices
Pipeline configurations are located in the .github/workflows/ directory.
The CI pipeline includes automated tests for SPIFFS functionality:
- Mounting SPIFFS and verifying it initializes correctly
- Writing test files and validating their contents
- Checking file operations (create, read, write, delete)
- Validating filesystem integrity after operations
- Stress testing with multiple file operations
This project uses ESP-IDF v5.1.1, which provides comprehensive support for ESP32-S3.
Key ESP-IDF settings:
- Target: ESP32-S3
- Flash size: 8MB (configurable in
menuconfig) - PSRAM: Enabled (configurable in
menuconfig) - SPIFFS partition: 1MB (defined in
partitions.csv)
The project includes a SPIFFS partition for file storage:
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, 0x10000, 3M,
spiffs, data, spiffs, , 1M,
SPIFFS is initialized in the application startup and provides:
- File read/write operations
- Directory support
- Wear leveling for flash memory protection
- Create a feature branch from
main - Make your changes and commit
- Push your branch and create a pull request
- CI will automatically build and test your changes
- After review and approval, merge to
main - CI will build the release version
ESP32-S3 uses USB for both programming and serial communication. If you're having trouble:
- Check if the board is in download mode
- Try different USB ports
- Verify USB permissions on Linux:
sudo usermod -a -G dialout $USER
If build fails:
- Update ESP-IDF:
cd $IDF_PATH && git pull && ./install.sh esp32s3 - Clean build:
idf.py fullclean && idf.py build
docker build -t esp32s3-dev .
docker run -it --rm -v {path}/esp32s3_espidf_spiffs_deployment_demo:/workspace esp32s3-dev
The SPIFFS demo showcases how to:
- Initialize and mount a SPIFFS filesystem
- Handle file operations efficiently
- Manage file data on the ESP32-S3's flash memory
- Implement proper error handling for file operations
- Package static files into the SPIFFS partition during build