From 2835575ee48d4b9c9db81853dedace4caf85e3aa Mon Sep 17 00:00:00 2001 From: Harry Ho Date: Mon, 28 Jun 2021 15:11:06 +0800 Subject: [PATCH 1/5] mcu: disable by-default `cargo test` checkPhase for Stabilizer --- mcu/default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mcu/default.nix b/mcu/default.nix index cc58861..388fb97 100644 --- a/mcu/default.nix +++ b/mcu/default.nix @@ -8,7 +8,7 @@ let rustPlatform = pkgs.recurseIntoAttrs (pkgs.callPackage ./rustPlatform.nix { inherit rustManifest; }); - buildStm32Firmware = { name, src, patchPhase ? "", extraNativeBuildInputs ? [], checkPhase ? "", ... } @ args: + buildStm32Firmware = { name, src, patchPhase ? "", extraNativeBuildInputs ? [], checkPhase ? "", doCheck ? true, ... } @ args: let # If binaryName is specified as an arg of buildStm32Firmware, # then the .nix containing the cargoSha256 must be named "cargosha256-${binaryName}.nix"; @@ -37,7 +37,7 @@ let cargo build --release ''; - inherit checkPhase; + inherit checkPhase doCheck; installPhase = '' mkdir -p $out $out/nix-support cp target/thumbv7em-none-eabihf/release/${binaryName} $out/${name}.elf @@ -62,6 +62,7 @@ in --replace "Ipv4Address::new(10, 34, 16, 1)" \ "Ipv4Address::new(192, 168, 1, 1)" ''; + doCheck = false; }; thermostat = buildStm32Firmware { name = "thermostat"; -- 2.42.0 From e43223532c672febfa0f93a6fcb900dd2a7e6cd8 Mon Sep 17 00:00:00 2001 From: Harry Ho Date: Fri, 2 Jul 2021 15:57:04 +0800 Subject: [PATCH 2/5] mcu: fix cargo not building only the specified binary per job --- mcu/default.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mcu/default.nix b/mcu/default.nix index 388fb97..98c16a5 100644 --- a/mcu/default.nix +++ b/mcu/default.nix @@ -19,6 +19,12 @@ let }.nix" $out ''; # If binaryName is specified as an arg of buildStm32Firmware, + # then pass it as an argument for `cargo build`; otherwise, do not add such argument. + extraCargoBuildArgs = ( + (if (args ? extraCargoBuildArgs) then (args.extraCargoBuildArgs + " ") else "") + + (if (args ? binaryName) then ("--bin " + binaryName) else "") + ); + # If binaryName is specified, # then use it as the filename of the ELF generated from `cargo build`; # otherwise, use the `name` arg (i.e. the Rust package name) as the ELF filename. binaryName = if (args ? binaryName) then args.binaryName else name; @@ -34,7 +40,7 @@ let nativeBuildInputs = [ pkgs.llvm ] ++ extraNativeBuildInputs; buildPhase = '' export CARGO_HOME=$(mktemp -d cargo-home.XXX) - cargo build --release + cargo build --release ${extraCargoBuildArgs} ''; inherit checkPhase doCheck; -- 2.42.0 From 868216eb2d29508796172e0c8364d29cc666e708 Mon Sep 17 00:00:00 2001 From: Harry Ho Date: Tue, 29 Jun 2021 17:14:34 +0800 Subject: [PATCH 3/5] mcu: keep cargo tarball name the same for different variants * This partially reverts 726ee7aa82f812f40f631b7c4e7040d84a1b627a, and keeps allowing the generated binary to have a name different from the derivation. --- mcu/default.nix | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/mcu/default.nix b/mcu/default.nix index 98c16a5..ec16425 100644 --- a/mcu/default.nix +++ b/mcu/default.nix @@ -8,17 +8,12 @@ let rustPlatform = pkgs.recurseIntoAttrs (pkgs.callPackage ./rustPlatform.nix { inherit rustManifest; }); - buildStm32Firmware = { name, src, patchPhase ? "", extraNativeBuildInputs ? [], checkPhase ? "", doCheck ? true, ... } @ args: + buildStm32Firmware = { name, src, cargoDepsName ? name, patchPhase ? "", extraNativeBuildInputs ? [], checkPhase ? "", doCheck ? true, ... } @ args: let - # If binaryName is specified as an arg of buildStm32Firmware, - # then the .nix containing the cargoSha256 must be named "cargosha256-${binaryName}.nix"; - # otherwise, the .nix must be named "cargosha256.nix". cargoSha256Drv = pkgs.runCommand "${name}-cargosha256" { } '' - cp "${src}/cargosha256${ - if (args ? binaryName) then "-" + args.binaryName else "" - }.nix" $out + cp "${src}/cargosha256.nix" $out ''; - # If binaryName is specified as an arg of buildStm32Firmware, + # If binaryName is specified, # then pass it as an argument for `cargo build`; otherwise, do not add such argument. extraCargoBuildArgs = ( (if (args ? extraCargoBuildArgs) then (args.extraCargoBuildArgs + " ") else "") + @@ -30,7 +25,7 @@ let binaryName = if (args ? binaryName) then args.binaryName else name; in rustPlatform.buildRustPackage rec { - inherit name; + inherit name cargoDepsName; version = "0.0.0"; inherit src; @@ -60,6 +55,7 @@ in stabilizer-dual-iir = buildStm32Firmware { name = "stabilizer-dual-iir"; binaryName = "dual-iir"; + cargoDepsName = "stabilizer"; src = ; patchPhase = '' substituteInPlace src/hardware/configuration.rs \ -- 2.42.0 From 45181c5c5691c81917211238ebfd101dbafe76f3 Mon Sep 17 00:00:00 2001 From: Harry Ho Date: Wed, 30 Jun 2021 12:11:42 +0800 Subject: [PATCH 4/5] mcu: add multiple variants of stabilizer using lib functions --- mcu/default.nix | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/mcu/default.nix b/mcu/default.nix index ec16425..44b05ae 100644 --- a/mcu/default.nix +++ b/mcu/default.nix @@ -51,10 +51,12 @@ let }; migen = (import ../artiq-fast/pkgs/python-deps.nix { inherit (pkgs) lib fetchgit fetchFromGitHub python3Packages; misoc-new = true; }).migen; in - { - stabilizer-dual-iir = buildStm32Firmware { - name = "stabilizer-dual-iir"; - binaryName = "dual-iir"; + pkgs.lib.attrsets.mapAttrs' + (name: value: pkgs.lib.attrsets.nameValuePair ("stabilizer-" + name) + (buildStm32Firmware { + name = "stabilizer-" + name; + # If binaryName is not specified, use the attribute name as binaryName by default. + binaryName = if (value ? binaryName) then value.binaryName else name; cargoDepsName = "stabilizer"; src = ; patchPhase = '' @@ -65,7 +67,24 @@ in "Ipv4Address::new(192, 168, 1, 1)" ''; doCheck = false; - }; + })) { + dual-iir = {}; + dual-iir-pounder_v1_1 = { + binaryName = "dual-iir"; + extraCargoBuildArgs = "--features pounder_v1_1"; + }; + lockin-external = {}; + lockin-external-pounder_v1_1 = { + binaryName = "lockin-external"; + extraCargoBuildArgs = "--features pounder_v1_1"; + }; + lockin-internal = {}; + lockin-internal-pounder_v1_1 = { + binaryName = "lockin-internal"; + extraCargoBuildArgs = "--features pounder_v1_1"; + }; + } // + { thermostat = buildStm32Firmware { name = "thermostat"; src = ; -- 2.42.0 From a00537688cc505a6671ed3239a81629e4c480529 Mon Sep 17 00:00:00 2001 From: Harry Ho Date: Wed, 30 Jun 2021 10:25:40 +0800 Subject: [PATCH 5/5] mcu: temporarily switch to pre-mqtt branch on harry's fork --- hydra/mcu.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hydra/mcu.json b/hydra/mcu.json index ec3df67..80dffff 100644 --- a/hydra/mcu.json +++ b/hydra/mcu.json @@ -14,7 +14,7 @@ "nixpkgs": { "type": "git", "value": "git://github.com/NixOS/nixpkgs nixos-21.05", "emailresponsible": false }, "mozillaOverlay": { "type": "git", "value": "git://github.com/mozilla/nixpkgs-mozilla.git", "emailresponsible": false }, "nixScripts": { "type": "git", "value": "https://git.m-labs.hk/M-Labs/nix-scripts.git", "emailresponsible": false }, - "stabilizerSrc": { "type": "git", "value": "git://github.com/quartiq/stabilizer.git", "emailresponsible": false }, + "stabilizerSrc": { "type": "git", "value": "git://github.com/HarryMakes/stabilizer.git pre-mqtt 1", "emailresponsible": false }, "thermostatSrc": { "type": "git", "value": "https://git.m-labs.hk/M-Labs/thermostat.git", "emailresponsible": false }, "humpbackDdsSrc": { "type": "git", "value": "https://git.m-labs.hk/M-Labs/humpback-dds.git", "emailresponsible": false }, "saymaMmcSrc": { "type": "git", "value": "git://github.com/sinara-hw/openMMC sayma-devel", "emailresponsible": false } -- 2.42.0