mirror of
https://github.com/kittywitch/esp32-c3-meepy.git
synced 2026-02-08 23:49:18 -08:00
feat: initial commit
This commit is contained in:
commit
7888da2541
10 changed files with 1515 additions and 0 deletions
15
.cargo/config.toml
Normal file
15
.cargo/config.toml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
[target.riscv32imc-unknown-none-elf]
|
||||
runner = "espflash flash --monitor"
|
||||
|
||||
[build]
|
||||
rustflags = [
|
||||
"-C", "link-arg=-Tlinkall.x",
|
||||
# Required to obtain backtraces (e.g. when using the "esp-backtrace" crate.)
|
||||
# NOTE: May negatively impact performance of produced code
|
||||
"-C", "force-frame-pointers",
|
||||
]
|
||||
|
||||
target = "riscv32imc-unknown-none-elf"
|
||||
|
||||
[unstable]
|
||||
build-std = ["core"]
|
||||
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
target/
|
||||
1203
Cargo.lock
generated
Normal file
1203
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
19
Cargo.toml
Normal file
19
Cargo.toml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
[package]
|
||||
name = "blinky"
|
||||
version = "0.1.0"
|
||||
authors = ["Sergio Gasquez <sergio.gasquez@gmail.com>"]
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
esp-backtrace = { version = "0.18.0", features = [
|
||||
"esp32c3",
|
||||
"panic-handler",
|
||||
"println",
|
||||
]}
|
||||
esp-bootloader-esp-idf = { version = "0.3.0", features = ["esp32c3"]}
|
||||
esp-hal = { version = "1.0.0-rc.1",features = [
|
||||
"esp32c3",
|
||||
"unstable",
|
||||
] }
|
||||
esp-println = { version = "0.16.0", features = ["esp32c3", "log-04"] }
|
||||
33
diagram.json
Normal file
33
diagram.json
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"version": 1,
|
||||
"author": "Sergio Gasquez Arcos",
|
||||
"editor": "wokwi",
|
||||
"parts": [
|
||||
{
|
||||
"type": "board-esp32-c3-rust-1",
|
||||
"id": "esp",
|
||||
"top": -126.57,
|
||||
"left": 46.35,
|
||||
"attrs": {
|
||||
"builder": "rust-nostd-esp"
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": [
|
||||
[
|
||||
"esp:21",
|
||||
"$serialMonitor:RX",
|
||||
"",
|
||||
[]
|
||||
],
|
||||
[
|
||||
"esp:20",
|
||||
"$serialMonitor:TX",
|
||||
"",
|
||||
[]
|
||||
]
|
||||
],
|
||||
"serialMonitor": {
|
||||
"display": "auto"
|
||||
}
|
||||
}
|
||||
130
flake.lock
generated
Normal file
130
flake.lock
generated
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
{
|
||||
"nodes": {
|
||||
"esp-rs-nix": {
|
||||
"inputs": {
|
||||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1760265400,
|
||||
"narHash": "sha256-6Vr5tspB7c7U/pxWNPikc+XvFnq0PnD1pPtQMkhaXzA=",
|
||||
"owner": "leighleighleigh",
|
||||
"repo": "esp-rs-nix",
|
||||
"rev": "d82a564a65cf91f8018bfc18a55d5cc23be4f86c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "leighleighleigh",
|
||||
"repo": "esp-rs-nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1759362264,
|
||||
"narHash": "sha256-wfG0S7pltlYyZTM+qqlhJ7GMw2fTF4mLKCIVhLii/4M=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "758cf7296bee11f1706a574c77d072b8a7baa881",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1760038930,
|
||||
"narHash": "sha256-Oncbh0UmHjSlxO7ErQDM3KM0A5/Znfofj2BSzlHLeVw=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "0b4defa2584313f3b781240b29d61f6f9f7e0df3",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"lastModified": 1754788789,
|
||||
"narHash": "sha256-x2rJ+Ovzq0sCMpgfgGaaqgBSwY+LST+WbZ6TytnT9Rk=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"rev": "a73b9c743612e4244d865a2fdee11865283c04e6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1760596604,
|
||||
"narHash": "sha256-J/i5K6AAz/y5dBePHQOuzC7MbhyTOKsd/GLezSbEFiM=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "3cbe716e2346710d6e1f7c559363d14e11c32a43",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"esp-rs-nix": "esp-rs-nix",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
68
flake.nix
Normal file
68
flake.nix
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
inputs = {
|
||||
esp-rs-nix = {
|
||||
url = "github:leighleighleigh/esp-rs-nix";
|
||||
};
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
};
|
||||
outputs = { nixpkgs, flake-utils, esp-rs-nix, ... }@inputs: let
|
||||
mkPkgs = system: (import nixpkgs) {
|
||||
inherit system;
|
||||
};
|
||||
eachSystemOutputs = flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = mkPkgs system;
|
||||
inherit (esp-rs-nix.packages.${system}) esp-rs;
|
||||
esp-shell = pkgs.mkShell rec {
|
||||
name = "esp-shell";
|
||||
|
||||
buildInputs = [
|
||||
esp-rs
|
||||
pkgs.rustup
|
||||
pkgs.espflash
|
||||
#pkgs.rust-analyzer
|
||||
pkgs.pkg-config
|
||||
pkgs.stdenv.cc
|
||||
#pkgs.bacon
|
||||
#pkgs.systemdMinimal
|
||||
#pkgs.lunarvim
|
||||
#pkgs.inotify-tools
|
||||
#pkgs.picocom
|
||||
#pkgs.vscode-fhs
|
||||
pkgs.libusb1
|
||||
pkgs.python3
|
||||
# Workspace command runners
|
||||
pkgs.just
|
||||
pkgs.mprocs
|
||||
# This is for parameterising the justfile
|
||||
pkgs.toml-cli
|
||||
pkgs.moreutils
|
||||
pkgs.gdb
|
||||
];
|
||||
|
||||
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath buildInputs}";
|
||||
|
||||
shellHook = ''
|
||||
# custom bashrc stuff
|
||||
export PS1_PREFIX="(esp-rs)"
|
||||
. ~/.bashrc
|
||||
|
||||
export LD_LIBRARY_PATH="''${LD_LIBRARY_PATH}:${LD_LIBRARY_PATH}"
|
||||
# this is important - it tells rustup where to find the esp toolchain,
|
||||
# without needing to copy it into your local ~/.rustup/ folder.
|
||||
export RUSTUP_TOOLCHAIN=${esp-rs}
|
||||
|
||||
# Load shell completions for espflash
|
||||
if (which espflash >/dev/null 2>&1); then
|
||||
. <(espflash completions $(basename $SHELL))
|
||||
fi
|
||||
'';
|
||||
};
|
||||
in {
|
||||
devShells = {
|
||||
inherit esp-shell;
|
||||
default = esp-shell;
|
||||
};
|
||||
});
|
||||
in eachSystemOutputs;
|
||||
}
|
||||
4
rust-toolchain.toml
Normal file
4
rust-toolchain.toml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
[toolchain]
|
||||
channel = "stable"
|
||||
components = ["rust-src"]
|
||||
targets = ["riscv32imc-unknown-none-elf"]
|
||||
33
src/main.rs
Normal file
33
src/main.rs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use esp_backtrace as _;
|
||||
use esp_hal::{
|
||||
delay::Delay,
|
||||
gpio::{Level, Output, OutputConfig},
|
||||
main,
|
||||
};
|
||||
use esp_println::println;
|
||||
|
||||
esp_bootloader_esp_idf::esp_app_desc!();
|
||||
|
||||
#[main]
|
||||
fn main() -> ! {
|
||||
let peripherals = esp_hal::init(esp_hal::Config::default());
|
||||
|
||||
println!("Hello world!");
|
||||
|
||||
// Set GPIO7 as an output, and set its state high initially.
|
||||
let mut led = Output::new(peripherals.GPIO8, Level::Low, OutputConfig::default());
|
||||
|
||||
led.set_high();
|
||||
|
||||
// Initialize the Delay peripheral, and use it to toggle the LED state in a
|
||||
// loop.
|
||||
let delay = Delay::new();
|
||||
|
||||
loop {
|
||||
led.toggle();
|
||||
delay.delay_millis(500);
|
||||
}
|
||||
}
|
||||
9
wokwi.toml
Normal file
9
wokwi.toml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
[wokwi]
|
||||
version = 1
|
||||
# Exercise
|
||||
# firmware = "target/riscv32imc-unknown-none-elf/release/blinky"
|
||||
# elf = "target/riscv32imc-unknown-none-elf/release/blinky"
|
||||
|
||||
# Solution
|
||||
firmware = 'target/riscv32imc-unknown-none-elf/release/examples/blinky'
|
||||
elf = 'target/riscv32imc-unknown-none-elf/release/examples/blinky'
|
||||
Loading…
Add table
Add a link
Reference in a new issue