This is an example / test for https://github.com/SFrijters/nix-qemu-espressif; it is kept out of that repository to keep it as lean as possible.
As an example we compile a simple 'blinking LED' Rust code based on an example in esp-hal for an ESP32C3 chip and run it on QEMU:
nix flake check -L
This command is also run in the GitHub action.
This flake also provides the following apps:
nix run .#emulate(default app) to run the emulation test script directly.nix run .#flashto flash the compiled code to a physical device.
And a development shell via:
nix develop
Inside the development shell, we can also use cargo directly to build the binary:
$ nix develop
$ cd blinky && cargo build --releaseFinally, there are three package outputs:
nix build .#elf-binarybuilds only the ELF binary file.nix build .#emulate-script(default package) builds a script to run the emulation test.nix build .#flash-scriptbuilds a wrapper script to flash the binary to a physical device using espflash.
The code has been tested on a Seeed Studio XIAO ESP32C3. The GPIO10 pin corresponds to the D10 pin as marked on the board.
This example code works around a linker issue in nixpkgs in blinky/.cargo/config.toml. Please refer to the linked issue for details and please suggest a better/permanent fix if you know of one! We also may need to keep an eye on nixpkgs pull #389204.
- The Nix code, its documentation and supporting files provided in this repository are subject to the MIT license (LICENSE or http://opensource.org/licenses/MIT)
- The example Rust code is also subject to the MIT license, as per the README at the time of removal from the upstream repository.