default.nix, nix/openocd: replace shell script with makeWrapper
This commit is contained in:
parent
462c5e2668
commit
cbfe3a177b
28
default.nix
28
default.nix
@ -19,26 +19,30 @@ stdenv.mkDerivation {
|
|||||||
buildInputs = [
|
buildInputs = [
|
||||||
adc2tcp
|
adc2tcp
|
||||||
openocd
|
openocd
|
||||||
|
makeWrapper
|
||||||
];
|
];
|
||||||
src = ./.;
|
src = ./.;
|
||||||
dontBuild = true;
|
dontBuild = true;
|
||||||
|
|
||||||
installPhase = ''
|
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
|
mkdir -p $out/bin $out/lib $out/nix-support
|
||||||
|
|
||||||
BIN=$out/lib/adc2tcp
|
BIN=$out/lib/adc2tcp
|
||||||
ln -s ${adc2tcp}/lib/adc2tcp $BIN
|
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
|
|
||||||
|
|
||||||
echo file binary-dist $BIN >> $out/nix-support/hydra-build-products
|
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
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,24 @@
|
|||||||
{ stdenv, openocd }:
|
{ stdenv, lib, openocd, makeWrapper }:
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "openocd-nucleo-f429zi";
|
name = "openocd-nucleo-f429zi";
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
openocd
|
openocd
|
||||||
|
makeWrapper
|
||||||
];
|
];
|
||||||
src = ./.;
|
src = ./.;
|
||||||
noBuild = true;
|
noBuild = true;
|
||||||
installPhase = ''
|
installPhase =
|
||||||
|
let
|
||||||
|
openOcdFlags = [
|
||||||
|
"-f" "${openocd}/share/openocd/scripts/interface/stlink-v2-1.cfg"
|
||||||
|
"-f" "${openocd}/share/openocd/scripts/target/stm32f4x.cfg"
|
||||||
|
"-c" "init"
|
||||||
|
];
|
||||||
|
in ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
cat >> $out/bin/openocd-nucleo-f429zi <<EOF
|
|
||||||
#!/usr/bin/env bash
|
makeWrapper ${openocd}/bin/openocd $out/bin/openocd-nucleo-f429zi \
|
||||||
${openocd}/bin/openocd \
|
--add-flags "${lib.escapeShellArgs openOcdFlags}"
|
||||||
-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
|
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user