diff --git a/README.md b/README.md deleted file mode 100644 index 3b63f18..0000000 --- a/README.md +++ /dev/null @@ -1,67 +0,0 @@ -# Synopsis - -Exposes readings from an ADC pin (currently: *PA3*) of the board via a -TCP service on the Ethernet port. - - -# Network Protocol - -Sensor readings produce lines of `key=value` pairs, joined by `,`, -terminated by `"\r\n"`. - -``` -t=21000,pa3=685 -t=22000,pa3=684 -t=23000,pa3=681 -t=24000,pa3=696 -t=25000,pa3=673 -t=26000,pa3=689 -t=27000,pa3=657 -t=28000,pa3=654 -t=29000,pa3=652 -t=30000,pa3=662 -t=31000,pa3=663 -``` - -| Key | Value | Unit | -|:---:|-------------|------| -| t | Time | ms | -| pa3 | ADC reading | mV | - - -# LEDs - -Colors indicate what the MCU is occupied with. - -| Color | Indication | -|:-------:|-------------------| -| Green | WFI (idle) | -| Blue | Network poll | -| Red | Message broadcast | - - -# Crate features - -* `semihosting` enables log output via the **cortex-m-semihosting** - crate. Use only in development! MCU will hang when no OpenOCD is - running. - -* `generate-hwaddr` generates an Ethernet MAC address by hashing the - unique device ID from flash memory. - - -# Instructions - -![Made for NixOS](https://nixos.org/logo/nixos-lores.png) - -## Build the firmware with `default.nix` - -* `nix-build` -* This uses **cargo-vendor** to bundle dependencies, so that unstable versions from git can be used. -* Run `result/bin/flash-adc2tcp` to flash a devboard with OpenOCD and quit. - -## Development environment with `shell.nix` - -* `nix-shell` -* Spawning `openocd`, the devboard should be connected already. -* Instructions (`cargo run --release`) are printed. diff --git a/default.nix b/default.nix deleted file mode 100644 index 5af048d..0000000 --- a/default.nix +++ /dev/null @@ -1,47 +0,0 @@ -{ # Use master branch of the overlay by default - mozillaOverlay ? import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz), - rustManifest ? builtins.fetchurl "https://static.rust-lang.org/dist/channel-rust-nightly.toml" -}: - -let - pkgs = import { overlays = [ mozillaOverlay ]; }; -in -with pkgs; -let - rustPlatform = recurseIntoAttrs (callPackage ./nix/rustPlatform.nix { - inherit rustManifest; - }); - adc2tcp = callPackage ./nix/adc2tcp.nix { inherit rustPlatform; }; - openocd = callPackage ./nix/openocd.nix {}; -in -stdenv.mkDerivation { - name = "adc2tcp-dist"; - buildInputs = [ - adc2tcp - openocd - makeWrapper - ]; - src = ./.; - dontBuild = true; - - installPhase = - let - firmwareBinary = "$out/lib/adc2tcp.elf"; - openOcdFlags = [ - "-c" "reset halt" - "-c" "flash write_image erase ${firmwareBinary}" - "-c" "verify_image ${firmwareBinary}" - "-c" "reset run" - "-c" "shutdown" - ]; - in '' - mkdir -p $out/bin $out/lib $out/nix-support - - ln -s ${adc2tcp}/lib/adc2tcp ${firmwareBinary} - - makeWrapper ${openocd}/bin/openocd-nucleo-f429zi $out/bin/flash-adc2tcp \ - --add-flags "${lib.escapeShellArgs openOcdFlags}" - - echo file binary-dist ${firmwareBinary} >> $out/nix-support/hydra-build-products - ''; -} diff --git a/nix/adc2tcp.nix b/nix/adc2tcp.nix deleted file mode 100644 index 1eeaf6b..0000000 --- a/nix/adc2tcp.nix +++ /dev/null @@ -1,45 +0,0 @@ -{ stdenv, rustPlatform, cacert, git, cargo-vendor }: - -with rustPlatform; -let - sha256 = "1i9p5d5n01ajbp8lmavyway6vr1mmy107qnccff9glvr91rqx352"; - fetchcargo = import ./fetchcargo.nix { - inherit stdenv cacert git cargo-vendor; - inherit (rust) cargo; - }; - adc2tcpDeps = fetchcargo { - name = "adc2tcp"; - src = ../.; - inherit sha256; - }; -in - -buildRustPackage rec { - name = "adc2tcp"; - version = "0.0.0"; - - src = ../.; - cargoSha256 = sha256; - - buildInputs = [ adc2tcpDeps ]; - patchPhase = '' - cat >> .cargo/config < {}, - rustManifest ? ./nix/channel-rust-nightly.toml -}: - -with pkgs; -let - adc2tcp = callPackage ./default.nix { - inherit rustManifest; - mozillaOverlay = import ; - }; -in -{ - build = lib.hydraJob adc2tcp; -} diff --git a/shell.nix b/shell.nix deleted file mode 100644 index b6b38a0..0000000 --- a/shell.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ rustChannel ? "nightly" }: - -let - mozillaOverlay = import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz); - pkgs = import { overlays = [ mozillaOverlay ]; }; -in -with pkgs; -let - rustPlatform = callPackage ./nix/rustPlatform.nix {}; - openocd = callPackage ./nix/openocd.nix {}; -in -stdenv.mkDerivation { - name = "adc2tcp-env"; - buildInputs = with rustPlatform.rust; [ - rustc cargo pkgs.gdb - ]; - - # Set Environment Variables - RUST_BACKTRACE = 1; - - shellHook = '' - echo "Starting openocd…" - ${openocd}/bin/openocd-nucleo-f429zi & - - # Let openocd output scroll by - sleep 1 - - echo "Run 'cargo run --release --features=semihosting'" - ''; -}