A minimal kernel for the ESP32 microcontroller. Part of the computer vision project for embedded obstacle detection.
This kernel provides a basic foundation for running the CNN object detection model on ESP32 hardware. It's lightweight and efficient, good for real-time processing with limited resources.
kernel/
├── src/ # Source files
│ ├── boot.S # Assembly boot code
│ ├── kernel.c # Main kernel implementation
│ └── linker.ld # Linker script
├── include/ # Header files
│ └── kernel.h # Kernel interface
├── Makefile # Build system
└── README.md # This file
- Minimal Footprint: Lightweight kernel suitable for ESP32's limited resources
- Bare Metal: Runs without an operating system for maximum performance
- Modular Design: Clean separation between boot code and kernel logic
- Extensible: Designed to be easily extended with additional functionality
- Hardware: ESP32 development board
- Toolchain: ESP32 GCC toolchain (
xtensa-esp32-elf-gcc) - Tools:
esptool.pyfor flashing
-
Install ESP32 toolchain:
# On Ubuntu/Debian sudo apt-get install gcc-xtensa-esp32-elf # Or download from Espressif # https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/
-
Install esptool:
pip install esptool
# Build kernel
make all
# Clean build artifacts
make clean
# Full clean
make fclean
# Rebuild from scratch
make re# Flash to ESP32 (adjust port as needed)
make flash
# Manual flashing with custom port
esptool.py --chip esp32 --port /dev/ttyUSB0 write_flash 0x10000 kernel.bin- Hardware Reset: ESP32 boot ROM initializes basic hardware
- Boot Code (
boot.S): Sets up stack and calls kernel - Kernel Entry (
kernel_main()): Main kernel initialization and loop
The current kernel is minimal and includes:
- Basic hardware initialization
- Stack setup
- Main kernel loop with power management
- Placeholder for future extensions
The kernel is designed to be extended with:
- CNN Integration: Loading and running the trained model
- Camera Interface: Reading from ESP32-CAM or similar
- Communication: WiFi/BLE for data transmission
- Real-time Processing: Optimized inference pipeline
- Power Management: Dynamic frequency scaling and sleep modes
- Header Files: Add function declarations to
include/kernel.h - Implementation: Add code to
src/kernel.c - Build: Update Makefile if new source files are added
- Test: Build and flash to verify functionality
- Use
esptool.pyto monitor serial output - Add debug prints to kernel code
- Use ESP32's built-in debugging capabilities
- Build Errors: Ensure ESP32 toolchain is properly installed
- Flash Errors: Check USB connection and port settings
- Runtime Issues: Verify memory layout and stack setup
- Check ESP32 documentation: https://docs.espressif.com/
- Review linker script for memory layout issues
- Verify toolchain installation and PATH settings
See the main project LICENSE file for details.