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 .#flash
to flash the compiled code to a physical device.
And a development shell via:
nix develop
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/default.nix. Please refer to the linked issue for details and please suggest a better/permanent fix if you know of one!