Add flags to generate .hex files
This commit is contained in:
parent
301496cf0e
commit
7e16faefae
18
flake.nix
18
flake.nix
|
@ -43,8 +43,10 @@
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
mkProgram = { pkgs, gcc, cflags, pname, psrc, pbuildInputs ? [] }:
|
mkProgram = { pkgs, gcc, cflags, pname, psrc, pbuildInputs ? [], avr ? false }:
|
||||||
pkgs.stdenv.mkDerivation rec {
|
let
|
||||||
|
AVR = if avr == true then "1" else "";
|
||||||
|
in pkgs.stdenv.mkDerivation rec {
|
||||||
name = pname;
|
name = pname;
|
||||||
src = psrc;
|
src = psrc;
|
||||||
|
|
||||||
|
@ -63,12 +65,15 @@
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
${gcc} -o ${name} ${cflags} ${object_files} *.o
|
${gcc} -o ${name}.elf ${cflags} ${object_files} *.o
|
||||||
|
if $AVR; then
|
||||||
|
$OBJCOPY -O ihex ${name}.elf ${name}.hex
|
||||||
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
cp ${name} $out/bin
|
cp ${name}.elf ${name}.hex $out/bin
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,7 +88,7 @@
|
||||||
paths = [
|
paths = [
|
||||||
(packages."x86_64-linux"."prime-tx" { gcc = "${avr.gcc}/bin/avr-gcc"; cflags = mcu_cflags atmega32u4; })
|
(packages."x86_64-linux"."prime-tx" { gcc = "${avr.gcc}/bin/avr-gcc"; cflags = mcu_cflags atmega32u4; })
|
||||||
(packages."x86_64-linux"."radio-rx" { gcc = "${avr.gcc}/bin/avr-gcc"; cflags = mcu_cflags atmega32u4; })
|
(packages."x86_64-linux"."radio-rx" { gcc = "${avr.gcc}/bin/avr-gcc"; cflags = mcu_cflags atmega32u4; })
|
||||||
(packages."x86_64-linux"."lantern" { gcc = "${avr.gcc}/bin/avr-gcc"; cflags = mcu_cflags atmega32u4; })
|
(packages."x86_64-linux"."lantern" { gcc = "${avr.gcc}/bin/avr-gcc"; cflags = mcu_cflags atmega32u4; avr = true; })
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -232,7 +237,7 @@
|
||||||
avr = pkgs.pkgsCross.avr.buildPackages;
|
avr = pkgs.pkgsCross.avr.buildPackages;
|
||||||
in packages."x86_64-linux"."lantern" { gcc = "${avr.gcc}/bin/avr-gcc"; cflags = mcu_cflags atmega32u4; };
|
in packages."x86_64-linux"."lantern" { gcc = "${avr.gcc}/bin/avr-gcc"; cflags = mcu_cflags atmega32u4; };
|
||||||
packages."x86_64-linux"."lantern" =
|
packages."x86_64-linux"."lantern" =
|
||||||
{ gcc, cflags }:
|
{ gcc, cflags, avr }:
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
||||||
in mkProgram {
|
in mkProgram {
|
||||||
|
@ -241,6 +246,7 @@
|
||||||
cflags = cflags;
|
cflags = cflags;
|
||||||
pname = "lantern";
|
pname = "lantern";
|
||||||
psrc = ./lantern;
|
psrc = ./lantern;
|
||||||
|
inherit avr;
|
||||||
|
|
||||||
pbuildInputs = [
|
pbuildInputs = [
|
||||||
(packages."x86_64-linux"."animation" { inherit gcc cflags; })
|
(packages."x86_64-linux"."animation" { inherit gcc cflags; })
|
||||||
|
|
Loading…
Reference in New Issue