Lua interpreter for the M5Stack NanoC6 with ESP-IDF
Create project, configure git remote, set target
cd ~/esp/esp-idf
source export.sh
cd ~/esp
idf.py create-project nanoc6-lua
cd nanoc6-lua
git init
git add origin https://github.com/samblenny/nanoc6-lua.git
# copy .gitignore and LICENSE
git add .
git commit -m 'initial commit'
git branch --set-upstream-to=origin/main main
git push
idf.py set-target esp32c6
Configure build with menuconfig
idf.py menuconfig
Then:
- Build type > Enable reproducible build > YES
- Bootloader config > Log > Bootloader log verbosity > Error
- Serial flasher config
- Flash size > 4 MB
- Detect flash size when flashing bootloader > YES
- Compiler options
- Optimization level > Optimize for size
- Assertion level > Disabled
- Component config
- ESP System Settings > CPU frequency > 80 MHz
- Log > Log Level > Default log verbosity > Error
idf.py flash monitor
# Ctrl-] to exit
cd ~/esp/nanoc6-lua
idf.py create-component -C components lua-5.4.8
cd components
tar xzf ~/Downloads/lua-5.4.8.tar.gz
cd lua-5.4.8/src
tar xzf ~/Downloads/one.tar.gz # Lua 5.4 onefile tarball
After this, edit components/lua-5.4.8/CMakeLists.txt to include the right files from lua-5.4.8/src/.
To get unit tests working, you need to combine some of the information from Espressif's Unit Testing documentation page with the methods demonstrated in the examples/system_unit_test example project in the esp-idf repo on GitHub.
Key Points:
- Code to be tested needs to be a component
- Unit tests go in
components/whatever/testsin your project repo - You also need a test runner app in /test next to /main at the top level of
your project. The test app runner should follow the
unit_testexample for CMakeLists.txt setup and code to invoke the Unity test library. - To build and run the test app:
Test runner output will print on the serial console.
cd $REPO_ROOT_DIR/tests # IMPORTANT: cd to tests before running idf.py! idf.py set-target esp32c6 # menuconfig won't work right without this idf.py menuconfig # set STDIO to use USB serial idf.py flash monitor # flash and run as usual
Copyright (c) 2026 Sam Blenny
This nanoc6-lua project is licensed under the MIT license.
Copyright © 1994–2025 Lua.org, PUC-Rio.
Lua is licensed under the MIT license.
See components/lua-5.4.8/doc/readme.html.