2.5 KiB
Building and flashing
- Make sure you've got all of the submodules in this repo correctly initialised:
git submodule update --init --recursive
- If this is your first time setting up the repo, then you will need to install the ESP-IDF tools. You can consult the ESP-IDF docs for more detailed instructions, but the TL;DR is that you'll want to run something like this:
./lib/esp-idf/install.sh esp32
- As a final piece of setup, you will need to source the env file in this repo to correctly set up your environment for building.
. ./.env
There is also a .env.fish
for fish users.
- You can now build the project using
idf.py build
. Or to flash the project onto your board, something like:
idf.py -p /dev/ttyUSB0 -b 115200 flash
(give or take the correct serial port)
Running tests
Tests are implemented as a separate application build, located in the test
directory. We use Catch2 as our test framework.
To run them, navigate to the test directory, then build and flash as normal. Connect to your device via UART, and you will be presented with a terminal prompt that you may run tests from.
To add new tests to a components, you must:
- Create a
test
subcomponent within that component. Seedrivers/test
for an example of this. - Include the component in the test build and list of testable components, in
test/CMakeLists.txt
.
VSCode setup
When using the Espressif IDF extension, you may want to set the following in your settings.json file:
"idf.espIdfPath": "${workspaceFolder}/lib/esp-idf",
"idf.espIdfPathWin": "${workspaceFolder}/lib/esp-idf"
LSP (clangd) setup
A regular build will generate build/compile_commands.json
, which clangd will
automatically pick up. However, there are a couple of additional steps to get
everything to play nicely.
First, create a .clangd
file in the this directory, with contents like:
CompileFlags:
Add: [
-D__XTENSA__,
--target=mipsel-linux-gnu,
]
Remove: [
-fno-tree-switch-conversion,
-mlongcalls,
-fstrict-volatile-bitfields,
]
You may need to tweak the target
flag until clangd
is happy to build.
If you get errors involving missing C++ includes, then you may need to edit
your editor's LSP invocation to include --query-driver=**
.
You should then get proper LSP integration via clangd.