2022-04-17 04:43:50 +00:00
|
|
|
{
|
2022-05-11 23:25:19 +00:00
|
|
|
description = "AVR";
|
2022-04-17 04:43:50 +00:00
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "nixpkgs/nixos-21.11";
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs = { self, nixpkgs }:
|
|
|
|
let
|
|
|
|
version = builtins.string 0 8 self.lastModifiedDate;
|
|
|
|
supportedSystems = [ "x86_64-linux" "avr-none" ];
|
|
|
|
in
|
|
|
|
{
|
2022-05-11 23:25:19 +00:00
|
|
|
packages."x86_64-linux"."flame" =
|
2022-04-17 04:43:50 +00:00
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
|
|
|
avr = pkgs.pkgsCross.avr.buildPackages;
|
|
|
|
in pkgs.stdenv.mkDerivation rec {
|
2022-05-11 23:25:19 +00:00
|
|
|
name = "flame";
|
2022-04-17 04:43:50 +00:00
|
|
|
src = ./.;
|
|
|
|
|
|
|
|
MCU = "attiny85";
|
|
|
|
CHIP_SELECT = "AVR_ATtiny85";
|
|
|
|
F_CPU = "8000000";
|
2022-06-28 00:05:01 +00:00
|
|
|
CFLAGS = ''-O -finline-functions -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Werror -Wstrict-prototypes -DF_CPU=${F_CPU} -std=gnu99 -D__${CHIP_SELECT}__=1 -mmcu=${MCU}'';
|
2022-04-17 04:43:50 +00:00
|
|
|
|
|
|
|
buildPhase = ''
|
2022-05-08 00:16:20 +00:00
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} -I${src}/base -o base.o -c ${src}/base/base.c
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} -I${src}/base -o sk9822.o -c ${src}/sk9822/sk9822.c
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} -I${src}/base -I${src}/sk9822 -o main.o -c ${src}/flame/main.c
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} -o main.elf main.o sk9822.o base.o
|
2022-04-17 04:43:50 +00:00
|
|
|
$OBJCOPY -O ihex main.elf main.hex
|
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
mkdir $out
|
|
|
|
cp main.elf main.hex $out
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-07-02 21:54:19 +00:00
|
|
|
packages."x86_64-linux"."prime-tx" =
|
2022-06-18 03:06:10 +00:00
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
|
|
|
lib = pkgs.lib;
|
|
|
|
avr = pkgs.pkgsCross.avr.buildPackages;
|
|
|
|
in pkgs.stdenv.mkDerivation rec {
|
2022-07-02 21:54:19 +00:00
|
|
|
name = "prime-tx";
|
2022-06-18 03:06:10 +00:00
|
|
|
src = ./.;
|
|
|
|
|
2022-07-02 21:54:19 +00:00
|
|
|
includes = [ "base" "spi" "shift_register" "rfm69hcw" "display" ];
|
2022-06-18 03:06:10 +00:00
|
|
|
|
|
|
|
MCU = "atmega32u4";
|
2022-06-20 15:40:55 +00:00
|
|
|
CHIP_SELECT = "AVR_ATmega32u4";
|
2022-06-18 03:06:10 +00:00
|
|
|
F_CPU = "8000000";
|
2022-06-28 00:05:01 +00:00
|
|
|
CFLAGS = ''-O -finline-functions -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Werror -Wstrict-prototypes -DF_CPU=${F_CPU} -std=gnu99 -D__${CHIP_SELECT}__=1 -mmcu=${MCU} -DAVR=1'';
|
2022-06-18 03:06:10 +00:00
|
|
|
INCLUDE_DIRS = lib.concatStringsSep " " (map (dir: "-I${src}/${dir}") includes);
|
|
|
|
|
|
|
|
buildPhase = ''
|
2022-06-26 15:51:40 +00:00
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o rfm.o -c ${src}/rfm69hcw/rfm.c
|
2022-06-20 18:52:29 +00:00
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o spi.o -c ${src}/spi/spi.c
|
2022-07-02 21:54:19 +00:00
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o reg.o -c ${src}/shift_register/shift_register.c
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o display.o -c ${src}/display/display.c
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o main.o -c ${src}/prime-tx/main.c
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} -o main.elf main.o display.o spi.o rfm.o reg.o
|
2022-07-07 17:16:36 +00:00
|
|
|
$OBJCOPY -O ihex main.elf main.hex
|
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
mkdir $out
|
|
|
|
cp main.elf main.hex $out
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
packages."x86_64-linux"."radio-rx" =
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
|
|
|
lib = pkgs.lib;
|
|
|
|
avr = pkgs.pkgsCross.avr.buildPackages;
|
|
|
|
in pkgs.stdenv.mkDerivation rec {
|
|
|
|
name = "prime-tx";
|
|
|
|
src = ./.;
|
|
|
|
|
|
|
|
includes = [ "base" "spi" "shift_register" "rfm69hcw" "display" ];
|
|
|
|
|
|
|
|
MCU = "atmega32u4";
|
|
|
|
CHIP_SELECT = "AVR_ATmega32u4";
|
|
|
|
F_CPU = "8000000";
|
|
|
|
CFLAGS = ''-O -finline-functions -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Werror -Wstrict-prototypes -DF_CPU=${F_CPU} -std=gnu99 -D__${CHIP_SELECT}__=1 -mmcu=${MCU} -DAVR=1'';
|
|
|
|
INCLUDE_DIRS = lib.concatStringsSep " " (map (dir: "-I${src}/${dir}") includes);
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o rfm.o -c ${src}/rfm69hcw/rfm.c
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o spi.o -c ${src}/spi/spi.c
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o reg.o -c ${src}/shift_register/shift_register.c
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o display.o -c ${src}/display/display.c
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o main.o -c ${src}/radio-rx/main.c
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} -o main.elf main.o display.o spi.o rfm.o reg.o
|
2022-06-18 03:06:10 +00:00
|
|
|
$OBJCOPY -O ihex main.elf main.hex
|
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
mkdir $out
|
|
|
|
cp main.elf main.hex $out
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-06-20 15:40:55 +00:00
|
|
|
packages."x86_64-linux"."spi_test" =
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
|
|
|
lib = pkgs.lib;
|
|
|
|
avr = pkgs.pkgsCross.avr.buildPackages;
|
|
|
|
in pkgs.stdenv.mkDerivation rec {
|
2022-06-26 15:51:40 +00:00
|
|
|
name = "spi-test";
|
2022-06-20 15:40:55 +00:00
|
|
|
src = ./.;
|
|
|
|
|
|
|
|
includes = [ "base" "spi" ];
|
|
|
|
|
|
|
|
MCU = "atmega32u4";
|
|
|
|
CHIP_SELECT = "AVR_ATmega32u4";
|
|
|
|
F_CPU = "8000000";
|
2022-06-28 00:05:01 +00:00
|
|
|
CFLAGS = ''-O -finline-functions -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Werror -Wstrict-prototypes -DF_CPU=${F_CPU} -std=gnu99 -D__${CHIP_SELECT}__=1 -mmcu=${MCU} -DAVR=1'';
|
2022-06-20 15:40:55 +00:00
|
|
|
INCLUDE_DIRS = lib.concatStringsSep " " (map (dir: "-I${src}/${dir}") includes);
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o spi.o -c ${src}/spi/spi.c
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o main.o -c ${src}/spi_test/main.c
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} -o main.elf main.o spi.o
|
|
|
|
$OBJCOPY -O ihex main.elf main.hex
|
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
mkdir $out
|
|
|
|
cp main.elf main.hex $out
|
|
|
|
'';
|
|
|
|
};
|
2022-06-18 03:06:10 +00:00
|
|
|
|
2022-06-26 15:51:40 +00:00
|
|
|
packages."x86_64-linux"."lcd" =
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
|
|
|
lib = pkgs.lib;
|
|
|
|
avr = pkgs.pkgsCross.avr.buildPackages;
|
|
|
|
in pkgs.stdenv.mkDerivation rec {
|
|
|
|
name = "lcd";
|
|
|
|
src = ./.;
|
|
|
|
|
2022-06-26 16:40:04 +00:00
|
|
|
includes = [ "base" "display" "shift_register" "spi" ];
|
2022-06-26 15:51:40 +00:00
|
|
|
|
|
|
|
MCU = "atmega32u4";
|
|
|
|
CHIP_SELECT = "AVR_ATmega32u4";
|
|
|
|
F_CPU = "8000000";
|
2022-06-28 00:05:01 +00:00
|
|
|
CFLAGS = ''-O -finline-functions -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Werror -Wstrict-prototypes -DF_CPU=${F_CPU} -std=gnu99 -D__${CHIP_SELECT}__=1 -mmcu=${MCU} -DAVR=1'';
|
2022-06-26 15:51:40 +00:00
|
|
|
INCLUDE_DIRS = lib.concatStringsSep " " (map (dir: "-I${src}/${dir}") includes);
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o base.o -c ${src}/base/base.c
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o spi.o -c ${src}/spi/spi.c
|
2022-06-26 16:40:04 +00:00
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o reg.o -c ${src}/shift_register/shift_register.c
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o display.o -c ${src}/display/display.c
|
2022-06-26 15:51:40 +00:00
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o main.o -c ${src}/lcd/main.c
|
2022-06-26 16:40:04 +00:00
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} -o main.elf main.o display.o reg.o spi.o base.o
|
2022-06-26 15:51:40 +00:00
|
|
|
$OBJCOPY -O ihex main.elf main.hex
|
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
mkdir $out
|
|
|
|
cp main.elf main.hex $out
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-06-28 00:05:01 +00:00
|
|
|
packages."x86_64-linux"."rfm_diagnostic" =
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
|
|
|
lib = pkgs.lib;
|
|
|
|
avr = pkgs.pkgsCross.avr.buildPackages;
|
|
|
|
in pkgs.stdenv.mkDerivation rec {
|
|
|
|
name = "lcd";
|
|
|
|
src = ./.;
|
|
|
|
|
|
|
|
includes = [ "base" "display" "shift_register" "spi" "rfm69hcw" ];
|
|
|
|
|
|
|
|
MCU = "atmega32u4";
|
|
|
|
CHIP_SELECT = "AVR_ATmega32u4";
|
|
|
|
F_CPU = "8000000";
|
|
|
|
CFLAGS = ''-O -finline-functions -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Werror -Wstrict-prototypes -DF_CPU=${F_CPU} -std=gnu99 -D__${CHIP_SELECT}__=1 -mmcu=${MCU} -DAVR=1'';
|
|
|
|
INCLUDE_DIRS = lib.concatStringsSep " " (map (dir: "-I${src}/${dir}") includes);
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o base.o -c ${src}/base/base.c
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o spi.o -c ${src}/spi/spi.c
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o reg.o -c ${src}/shift_register/shift_register.c
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o display.o -c ${src}/display/display.c
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o rfm.o -c ${src}/rfm69hcw/rfm.c
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} ${INCLUDE_DIRS} -o main.o -c ${src}/rfm_diagnostic/main.c
|
|
|
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} -o main.elf main.o display.o rfm.o reg.o spi.o base.o
|
|
|
|
$OBJCOPY -O ihex main.elf main.hex
|
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
mkdir $out
|
|
|
|
cp main.elf main.hex $out
|
|
|
|
'';
|
|
|
|
};
|
2022-04-17 04:43:50 +00:00
|
|
|
devShell."x86_64-linux" =
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
|
|
|
avr = with pkgs.pkgsCross.avr.buildPackages; [
|
|
|
|
binutils
|
|
|
|
gcc
|
2022-05-07 23:49:54 +00:00
|
|
|
gdb
|
2022-04-17 04:43:50 +00:00
|
|
|
avrdude
|
2022-05-07 23:49:54 +00:00
|
|
|
simavr
|
|
|
|
gtkwave
|
2022-04-17 04:43:50 +00:00
|
|
|
];
|
|
|
|
in
|
|
|
|
pkgs.mkShell {
|
2022-05-11 23:25:19 +00:00
|
|
|
name = "avr-shell";
|
2022-04-17 04:43:50 +00:00
|
|
|
buildInputs = avr;
|
2022-05-07 23:49:54 +00:00
|
|
|
|
2022-05-08 00:16:20 +00:00
|
|
|
GCC = pkgs.pkgsCross.avr.buildPackages.gcc;
|
|
|
|
SIMAVR = pkgs.pkgsCross.avr.buildPackages.simavr;
|
2022-04-17 04:43:50 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|