mirror of
https://github.com/icewind1991/cynthion-flake.git
synced 2026-06-03 14:24:07 +02:00
add apollo firmware to cynthion package
This commit is contained in:
parent
19838d3e06
commit
10c149f513
7 changed files with 196 additions and 97 deletions
50
pkgs/cynthion/apollo-firmware.nix
Normal file
50
pkgs/cynthion/apollo-firmware.nix
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
fetchFromGitHub,
|
||||
stdenv,
|
||||
board,
|
||||
gcc-arm-embedded,
|
||||
...
|
||||
}: let
|
||||
uf2 = fetchFromGitHub {
|
||||
owner = "microsoft";
|
||||
repo = "uf2";
|
||||
rev = "c594542b2faa01cc33a2b97c9fbebc38549df80a";
|
||||
hash = "sha256-s+hVAXGqeEA2ZLYdTQ/JBci37FpmfxEKFkYwnXSWAzU=";
|
||||
};
|
||||
microchip-driver = fetchFromGitHub {
|
||||
owner = "hathach";
|
||||
repo = "microchip_driver";
|
||||
rev = "9e8b37e307d8404033bb881623a113931e1edf27";
|
||||
hash = "sha256-VfUeuiJXXJa59yLVMD5pi7j1YE7CyDrxvIuGqmiyoHY=";
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "apollo-${board}";
|
||||
version = "1.0.6";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "greatscottgadgets";
|
||||
repo = "apollo";
|
||||
rev = "v1.0.6";
|
||||
hash = "sha256-QinJzMZGZo1a1glj1r9NZIoUlQn2gb+rOc7uojBENR4=";
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
|
||||
APOLLO_BOARD = board;
|
||||
|
||||
nativeBuildInputs = [gcc-arm-embedded];
|
||||
|
||||
postPatch = ''
|
||||
ln -s ${microchip-driver} lib/tinyusb/hw/mcu/microchip
|
||||
ln -s ${uf2} lib/tinyusb/tools/uf2
|
||||
'';
|
||||
|
||||
preConfigure = ''
|
||||
cd firmware
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/share/assets
|
||||
cp _build/cynthion_d11/firmware.bin $out/share/assets/apollo.bin
|
||||
'';
|
||||
}
|
||||
80
pkgs/cynthion/cynthion.nix
Normal file
80
pkgs/cynthion/cynthion.nix
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
{
|
||||
lib,
|
||||
fetchFromGitHub,
|
||||
buildPythonPackage,
|
||||
python3Packages,
|
||||
pkgs,
|
||||
setuptools,
|
||||
setuptools-git-versioning,
|
||||
libusb1,
|
||||
pyusb,
|
||||
tomli,
|
||||
future,
|
||||
prompt-toolkit,
|
||||
tabulate,
|
||||
tqdm,
|
||||
pyserial,
|
||||
amaranth-041,
|
||||
luna-usb,
|
||||
luna-soc,
|
||||
apollo-fpga,
|
||||
pyfwup,
|
||||
pygreat-2024,
|
||||
yosys,
|
||||
nextpnr,
|
||||
trellis,
|
||||
}: let
|
||||
in
|
||||
buildPythonPackage rec {
|
||||
pname = "cynthion-unwrapped";
|
||||
version = "0.1.0";
|
||||
|
||||
outputs = ["out" "udev"];
|
||||
pyproject = true;
|
||||
|
||||
src = import ./src.nix fetchFromGitHub;
|
||||
|
||||
nativeBuildInputs = [
|
||||
setuptools
|
||||
setuptools-git-versioning
|
||||
];
|
||||
|
||||
propagatedBuildInputs = [
|
||||
libusb1
|
||||
pyusb
|
||||
tomli
|
||||
future
|
||||
prompt-toolkit
|
||||
tabulate
|
||||
tqdm
|
||||
pyserial
|
||||
amaranth-041
|
||||
luna-usb
|
||||
luna-soc
|
||||
apollo-fpga
|
||||
pyfwup
|
||||
pygreat-2024
|
||||
trellis
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace cynthion/python/src/commands/util.py \
|
||||
--replace-fail "module_path, '../../assets/'" "\"$out/share/assets\"" \
|
||||
--replace-fail "module_path, '../../assets'" "\"$out/share/assets\""
|
||||
'';
|
||||
|
||||
preBuild = ''
|
||||
cd cynthion/python
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
mkdir -p $udev/lib/udev/rules.d
|
||||
cp assets/54-cynthion.rules $udev/lib/udev/rules.d/54-cynthion.rules
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Cynthion is an all-in-one tool for building, testing, monitoring, and experimenting with USB device";
|
||||
homepage = "https://github.com/greatscottgadgets/cynthion";
|
||||
license = lib.licenses.bsd3;
|
||||
};
|
||||
}
|
||||
|
|
@ -1,91 +1,17 @@
|
|||
{
|
||||
lib,
|
||||
fetchFromGitHub,
|
||||
buildPythonPackage,
|
||||
python3Packages,
|
||||
pkgs,
|
||||
setuptools,
|
||||
setuptools-git-versioning,
|
||||
libusb1,
|
||||
pyusb,
|
||||
tomli,
|
||||
future,
|
||||
prompt-toolkit,
|
||||
tabulate,
|
||||
tqdm,
|
||||
pyserial,
|
||||
amaranth-041,
|
||||
luna-usb,
|
||||
luna-soc,
|
||||
apollo-fpga,
|
||||
pyfwup,
|
||||
pygreat-2024,
|
||||
zsh,
|
||||
yosys,
|
||||
nextpnr,
|
||||
trellis,
|
||||
}: let
|
||||
in
|
||||
buildPythonPackage rec {
|
||||
pname = "cynthion";
|
||||
version = "0.1.0";
|
||||
cynthion-unwrapped,
|
||||
cynthion-gateware,
|
||||
apollo-cynthion,
|
||||
...
|
||||
}:
|
||||
# because the gateware needs the python module, we do a weird 2-stage build
|
||||
# where we build the cynthion package twice, once without gateware then again where we copy over the gateware
|
||||
cynthion-unwrapped.overrideAttrs (oldAttrs: {
|
||||
pname = "cynthion";
|
||||
|
||||
outputs = ["out" "udev"];
|
||||
pyproject = true;
|
||||
|
||||
src = import ./src.nix fetchFromGitHub;
|
||||
|
||||
nativeBuildInputs = [
|
||||
setuptools
|
||||
setuptools-git-versioning
|
||||
zsh
|
||||
yosys
|
||||
nextpnr
|
||||
trellis
|
||||
];
|
||||
|
||||
propagatedBuildInputs = [
|
||||
libusb1
|
||||
pyusb
|
||||
tomli
|
||||
future
|
||||
prompt-toolkit
|
||||
tabulate
|
||||
tqdm
|
||||
pyserial
|
||||
amaranth-041
|
||||
luna-usb
|
||||
luna-soc
|
||||
apollo-fpga
|
||||
pyfwup
|
||||
pygreat-2024
|
||||
trellis
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace cynthion/python/Makefile \
|
||||
--replace-fail 'SHELL := /bin/zsh' "SHELL := ${zsh}/bin/zsh"
|
||||
substituteInPlace cynthion/python/src/commands/util.py \
|
||||
--replace-fail "module_path, '../../assets/'" "\"$out/share/assets/\""
|
||||
'';
|
||||
|
||||
preBuild = ''
|
||||
cd cynthion/python
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
mkdir -p $udev/lib/udev/rules.d
|
||||
cp assets/54-cynthion.rules $udev/lib/udev/rules.d/54-cynthion.rules
|
||||
|
||||
make bitstreams
|
||||
mkdir -p $out/share
|
||||
ls -l
|
||||
cp -r assets $out/share
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Cynthion is an all-in-one tool for building, testing, monitoring, and experimenting with USB device";
|
||||
homepage = "https://github.com/greatscottgadgets/cynthion";
|
||||
license = lib.licenses.bsd3;
|
||||
};
|
||||
}
|
||||
postInstall = oldAttrs.postInstall + ''
|
||||
mkdir -p $out/share/assets
|
||||
cp ${apollo-cynthion}/share/assets/apollo.bin $out/share/assets/apollo.bin
|
||||
cp -r ${cynthion-gateware}/share/assets/* $out/share/assets
|
||||
'';
|
||||
})
|
||||
|
|
|
|||
39
pkgs/cynthion/gateware.nix
Normal file
39
pkgs/cynthion/gateware.nix
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
stdenvNoCC,
|
||||
cynthion-unwrapped,
|
||||
zsh,
|
||||
yosys,
|
||||
nextpnr,
|
||||
trellis,
|
||||
...
|
||||
}:
|
||||
stdenvNoCC.mkDerivation {
|
||||
pname = "cynthion-gateware";
|
||||
inherit (cynthion-unwrapped) version src;
|
||||
dontFixup = true;
|
||||
|
||||
nativeBuildInputs = [
|
||||
cynthion-unwrapped
|
||||
yosys
|
||||
nextpnr
|
||||
trellis
|
||||
zsh
|
||||
];
|
||||
|
||||
preBuild = ''
|
||||
cd cynthion/python
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
make -j $NIX_BUILD_CORES SHELL=zsh bitstreams
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/share
|
||||
cp -r assets $out/share
|
||||
'';
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
fetchFromGitHub: fetchFromGitHub {
|
||||
fetchFromGitHub:
|
||||
fetchFromGitHub {
|
||||
owner = "greatscottgadgets";
|
||||
repo = "cynthion";
|
||||
rev = "db0fb8ecfee1c153219f029c0db627c6805e3d59";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue