forked from M-Labs/thermostat
nix: add openocd flashing
This commit is contained in:
parent
51ee455fe7
commit
092ea7f824
30
default.nix
30
default.nix
|
@ -4,5 +4,33 @@ in
|
||||||
with import <nixpkgs> { overlays = [ mozillaOverlay ]; };
|
with import <nixpkgs> { overlays = [ mozillaOverlay ]; };
|
||||||
let
|
let
|
||||||
rustPlatform = recurseIntoAttrs (callPackage (import ./nix/rustPlatform.nix) {});
|
rustPlatform = recurseIntoAttrs (callPackage (import ./nix/rustPlatform.nix) {});
|
||||||
|
adc2tcp = callPackage (import ./nix/adc2tcp.nix) { inherit rustPlatform; };
|
||||||
|
openocd = callPackage (import ./nix/openocd.nix) {};
|
||||||
in
|
in
|
||||||
callPackage (import ./nix/adc2tcp.nix) { inherit rustPlatform; }
|
stdenv.mkDerivation {
|
||||||
|
name = "adc2tcp-dist";
|
||||||
|
buildInputs = [
|
||||||
|
adc2tcp
|
||||||
|
openocd
|
||||||
|
gdb
|
||||||
|
];
|
||||||
|
src = ./.;
|
||||||
|
dontBuild = true;
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/bin $out/lib
|
||||||
|
|
||||||
|
BIN=$out/lib/adc2tcp
|
||||||
|
ln -s ${adc2tcp}/lib/adc2tcp $BIN
|
||||||
|
cat >> $out/bin/flash-adc2tcp <<EOF
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
${openocd}/bin/openocd-nucleo-f429zi \
|
||||||
|
-c "reset halt" \
|
||||||
|
-c "flash write_image erase $BIN" \
|
||||||
|
-c "verify_image $BIN" \
|
||||||
|
-c "reset run" \
|
||||||
|
-c "shutdown"
|
||||||
|
EOF
|
||||||
|
chmod +x $out/bin/flash-adc2tcp
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
|
@ -10,4 +10,8 @@ buildRustPackage rec {
|
||||||
cargoSha256 = "0q3cn3jzgmrqiymisxymn19vbnnpsj7if052w5zh25x9ikin6lpl";
|
cargoSha256 = "0q3cn3jzgmrqiymisxymn19vbnnpsj7if052w5zh25x9ikin6lpl";
|
||||||
|
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/lib
|
||||||
|
cp target/thumbv7em-none-eabihf/release/adc2tcp $out/lib/
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
{ stdenv, callPackage }:
|
|
||||||
|
|
||||||
let
|
|
||||||
adc2tcp = callPackage (import ./adc2tcp.nix) {};
|
|
||||||
in
|
|
||||||
stdenv.mkDerivation {
|
|
||||||
name = "adc2tcp";
|
|
||||||
buildInputs = [
|
|
||||||
adc2tcp
|
|
||||||
];
|
|
||||||
src = ./.;
|
|
||||||
noBuild = true;
|
|
||||||
installPhase = ''
|
|
||||||
find ${adc2tcp} -type f
|
|
||||||
'';
|
|
||||||
}
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
{ stdenv, openocd }:
|
||||||
|
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
name = "openocd-nucleo-f429zi";
|
||||||
|
buildInputs = [
|
||||||
|
openocd
|
||||||
|
];
|
||||||
|
src = ./.;
|
||||||
|
noBuild = true;
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
cat >> $out/bin/openocd-nucleo-f429zi <<EOF
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
${openocd}/bin/openocd \
|
||||||
|
-f ${openocd}/share/openocd/scripts/interface/stlink-v2-1.cfg \
|
||||||
|
-f ${openocd}/share/openocd/scripts/target/stm32f4x.cfg \
|
||||||
|
-c "init" \
|
||||||
|
"\$@"
|
||||||
|
EOF
|
||||||
|
chmod +x $out/bin/openocd-nucleo-f429zi
|
||||||
|
'';
|
||||||
|
}
|
|
@ -7,7 +7,7 @@ let
|
||||||
# "thumbv7em-none-eabi"
|
# "thumbv7em-none-eabi"
|
||||||
"thumbv7em-none-eabihf"
|
"thumbv7em-none-eabihf"
|
||||||
];
|
];
|
||||||
rust = builtins.trace "Selected channel ${rustChannel}"
|
rust = builtins.trace "rustChannel: selected channel ${rustChannel}"
|
||||||
rustChannelOfTargets rustChannel null targets;
|
rustChannelOfTargets rustChannel null targets;
|
||||||
in
|
in
|
||||||
makeRustPlatform {
|
makeRustPlatform {
|
||||||
|
|
21
shell.nix
21
shell.nix
|
@ -5,15 +5,9 @@ let
|
||||||
in
|
in
|
||||||
with import <nixpkgs> { overlays = [ mozillaOverlay ]; };
|
with import <nixpkgs> { overlays = [ mozillaOverlay ]; };
|
||||||
let
|
let
|
||||||
rustPlatform = recurseIntoAttrs (
|
rustPlatform = callPackage (import ./nix/rustPlatform.nix) { inherit rustChannel; };
|
||||||
callPackage (import ./nix/rustPlatform.nix) { inherit rustChannel; }
|
openocd = callPackage (import ./nix/openocd.nix) {};
|
||||||
);
|
|
||||||
in
|
in
|
||||||
# mkShell {
|
|
||||||
# inputsFrom = with rustPlatform.rust; [
|
|
||||||
# rustc cargo
|
|
||||||
# ];
|
|
||||||
# }
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "adc2tcp-env";
|
name = "adc2tcp-env";
|
||||||
buildInputs = with rustPlatform.rust; [
|
buildInputs = with rustPlatform.rust; [
|
||||||
|
@ -22,4 +16,15 @@ stdenv.mkDerivation {
|
||||||
|
|
||||||
# Set Environment Variables
|
# Set Environment Variables
|
||||||
RUST_BACKTRACE = 1;
|
RUST_BACKTRACE = 1;
|
||||||
|
|
||||||
|
shellHook = ''
|
||||||
|
echo "Starting openocd…"
|
||||||
|
${openocd}/bin/openocd-nucleo-f429zi &
|
||||||
|
|
||||||
|
# Let openocd output scroll by
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
echo "Run 'cargo build --release'"
|
||||||
|
echo "Then 'gdb target/thumbv7em-none-eabihf/release/adc2tcp'"
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue