use fenix to build package, have runner script; nix run works now!
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
[target.riscv32imac-unknown-none-elf]
|
[target.riscv32imac-unknown-none-elf]
|
||||||
runner = "sudo espflash flash --monitor --chip esp32c6"
|
# UPDATE flake.nix to reflect any changes here in the wrapper script
|
||||||
|
runner = "espflash flash --monitor --chip esp32c6"
|
||||||
|
|
||||||
[env]
|
[env]
|
||||||
ESP_LOG="info"
|
ESP_LOG="info"
|
||||||
|
|||||||
109
flake.lock
generated
109
flake.lock
generated
@@ -1,5 +1,69 @@
|
|||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
"fenix": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
|
"rust-analyzer-src": "rust-analyzer-src"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1775462255,
|
||||||
|
"narHash": "sha256-YRzdvh6nvMebcgO2nDpr8dqVwKHpp1BBRUHeMxX9UAY=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "fenix",
|
||||||
|
"rev": "f90343f1ed330243d4bbdbce51acbd93b776a797",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "fenix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"fenix_2": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"naersk",
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
|
"rust-analyzer-src": "rust-analyzer-src_2"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1752475459,
|
||||||
|
"narHash": "sha256-z6QEu4ZFuHiqdOPbYss4/Q8B0BFhacR8ts6jO/F/aOU=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "fenix",
|
||||||
|
"rev": "bf0d6f70f4c9a9cf8845f992105652173f4b617f",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "fenix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"naersk": {
|
||||||
|
"inputs": {
|
||||||
|
"fenix": "fenix_2",
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1769799857,
|
||||||
|
"narHash": "sha256-88IFXZ7Sa1vxbz5pty0Io5qEaMQMMUPMonLa3Ls/ss4=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "naersk",
|
||||||
|
"rev": "9d4ed44d8b8cecdceb1d6fd76e74123d90ae6339",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "naersk",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1775403759,
|
"lastModified": 1775403759,
|
||||||
@@ -18,27 +82,42 @@
|
|||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": "nixpkgs",
|
"fenix": "fenix",
|
||||||
"rust-overlay": "rust-overlay"
|
"naersk": "naersk",
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rust-overlay": {
|
"rust-analyzer-src": {
|
||||||
"inputs": {
|
"flake": false,
|
||||||
"nixpkgs": [
|
|
||||||
"nixpkgs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1775445266,
|
"lastModified": 1775429583,
|
||||||
"narHash": "sha256-3fgIj85WHQbOamrpIw9WY3ZL1PoEvjPOjmzMYNsEQJo=",
|
"narHash": "sha256-bFC/p7Ywyd9QIr9DbU3Q75c7AcaCm9wVmEvcI3702cY=",
|
||||||
"owner": "oxalica",
|
"owner": "rust-lang",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-analyzer",
|
||||||
"rev": "61747bc3cf2da179b9af356ae9e70f3b895b0c24",
|
"rev": "38fb8f92ac15853d7fa9fb47fc2d81fdd5cd6c7e",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "oxalica",
|
"owner": "rust-lang",
|
||||||
"repo": "rust-overlay",
|
"ref": "nightly",
|
||||||
|
"repo": "rust-analyzer",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rust-analyzer-src_2": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1752428706,
|
||||||
|
"narHash": "sha256-EJcdxw3aXfP8Ex1Nm3s0awyH9egQvB2Gu+QEnJn2Sfg=",
|
||||||
|
"owner": "rust-lang",
|
||||||
|
"repo": "rust-analyzer",
|
||||||
|
"rev": "591e3b7624be97e4443ea7b5542c191311aa141d",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "rust-lang",
|
||||||
|
"ref": "nightly",
|
||||||
|
"repo": "rust-analyzer",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
39
flake.nix
39
flake.nix
@@ -1,32 +1,53 @@
|
|||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
||||||
rust-overlay = {
|
fenix = {
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
url = "github:oxalica/rust-overlay";
|
url = "github:nix-community/fenix";
|
||||||
|
};
|
||||||
|
naersk = {
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
url = "github:nix-community/naersk";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
outputs = {
|
outputs = {
|
||||||
|
fenix,
|
||||||
|
naersk,
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
rust-overlay,
|
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
pkgs = import nixpkgs {
|
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||||
system = "x86_64-linux";
|
toolchain = fenix.packages.x86_64-linux.fromToolchainFile {
|
||||||
overlays = [(import rust-overlay)];
|
file = ./rust-toolchain.toml;
|
||||||
|
sha256 = "sha256-zC8E38iDVJ1oPIzCqTk/Ujo9+9kx9dXq7wAwPMpkpg0=";
|
||||||
};
|
};
|
||||||
rust-bin = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
|
||||||
in {
|
in {
|
||||||
devShells.x86_64-linux.default = pkgs.mkShell {
|
devShells.x86_64-linux.default = pkgs.mkShell {
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
pkgs.espflash
|
pkgs.espflash
|
||||||
pkgs.esp-generate
|
pkgs.esp-generate
|
||||||
pkgs.rust-analyzer
|
pkgs.rust-analyzer
|
||||||
rust-bin
|
toolchain
|
||||||
];
|
];
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
export RUSTUP_TOOLCHAIN=${rust-bin}
|
export RUSTUP_TOOLCHAIN=${toolchain}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
packages.x86_64-linux.default =
|
||||||
|
(naersk.lib.x86_64-linux.override {
|
||||||
|
cargo = toolchain;
|
||||||
|
rustc = toolchain;
|
||||||
|
}).buildPackage {
|
||||||
|
src = ./.;
|
||||||
|
# UPDATE .cargo/config.toml to reflect changes here in the runner
|
||||||
|
postInstall = ''
|
||||||
|
mv $out/bin/esp32c6-play $out/bin/.esp32c6-play
|
||||||
|
cat<<EOF>$out/bin/esp32c6-play
|
||||||
|
#!/usr/bin/bash
|
||||||
|
${pkgs.lib.getExe pkgs.espflash} flash --monitor --chip esp32c6 $(echo $out)/bin/.esp32c6-play
|
||||||
|
EOF
|
||||||
|
chmod +x $out/bin/esp32c6-play
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ esp_bootloader_esp_idf::esp_app_desc!();
|
|||||||
fn main() -> ! {
|
fn main() -> ! {
|
||||||
let peripherals = init();
|
let peripherals = init();
|
||||||
|
|
||||||
let mut led_buffer = smart_led_buffer!(1);
|
let mut led_buffer = smart_led_buffer!(1 /* # of leds */);
|
||||||
let mut rgb_led = {
|
let mut rgb_led = {
|
||||||
let frequency = Rate::from_mhz(80);
|
let frequency = Rate::from_mhz(80); // max frequency of RMT
|
||||||
let rmt = Rmt::new(peripherals.RMT, frequency).expect("failed to initialize RMT0");
|
let rmt = Rmt::new(peripherals.RMT, frequency).expect("failed to initialize RMT0");
|
||||||
SmartLedsAdapter::new(rmt.channel0, peripherals.GPIO8, &mut led_buffer)
|
SmartLedsAdapter::new(rmt.channel0, peripherals.GPIO8, &mut led_buffer)
|
||||||
};
|
};
|
||||||
@@ -28,6 +28,7 @@ fn main() -> ! {
|
|||||||
let r: u8 = i;
|
let r: u8 = i;
|
||||||
let g: u8 = i + 255 / 3; // phase shifted a third
|
let g: u8 = i + 255 / 3; // phase shifted a third
|
||||||
let b: u8 = i + 2 * (255 / 3); // phase shifted two thirds
|
let b: u8 = i + 2 * (255 / 3); // phase shifted two thirds
|
||||||
|
|
||||||
write_rgb(&mut rgb_led, RGB::new(sin(r), sin(g), sin(b)));
|
write_rgb(&mut rgb_led, RGB::new(sin(r), sin(g), sin(b)));
|
||||||
|
|
||||||
wait_ms(8);
|
wait_ms(8);
|
||||||
|
|||||||
Reference in New Issue
Block a user