Compare commits
7 Commits
ff8bf82988
...
b7578e175a
Author | SHA1 | Date |
---|---|---|
Florian Agbuya | b7578e175a | |
Florian Agbuya | 3c025e049d | |
Florian Agbuya | 0ff299aa55 | |
Florian Agbuya | c2d38540c0 | |
Florian Agbuya | d9a2d60b50 | |
Florian Agbuya | 26dd210eb6 | |
Florian Agbuya | 251f65f217 |
159
flake.nix
159
flake.nix
|
@ -11,6 +11,7 @@
|
|||
outputs = { self, nixpkgs, not-os, src-migen, src-misoc }:
|
||||
let
|
||||
pkgs = import nixpkgs { system = "x86_64-linux"; overlays = [ crosspkgs-overlay ]; };
|
||||
pkgs-armv7l = pkgs.pkgsCross.zynq-armv7l-linux;
|
||||
fsbl-support = ./fast-servo/fsbl-support;
|
||||
|
||||
patched-not-os = pkgs.applyPatches {
|
||||
|
@ -26,6 +27,19 @@
|
|||
];
|
||||
};
|
||||
|
||||
crossSystem = {
|
||||
system = "armv7l-linux";
|
||||
linux-kernel = {
|
||||
name = "zynq";
|
||||
baseConfig = "multi_v7_defconfig";
|
||||
target = "uImage";
|
||||
installTarget = "uImage";
|
||||
autoModules = false;
|
||||
DTB = true;
|
||||
makeFlags = [ "LOADADDR=0x8000" ];
|
||||
};
|
||||
};
|
||||
|
||||
crosspkgs-overlay = (self: super: {
|
||||
pkgsCross = super.pkgsCross // {
|
||||
zynq-baremetal = import super.path {
|
||||
|
@ -37,6 +51,10 @@
|
|||
gcc.fpu = "vfpv3";
|
||||
};
|
||||
};
|
||||
zynq-armv7l-linux = import super.path {
|
||||
system = "x86_64-linux";
|
||||
inherit crossSystem;
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -82,74 +100,48 @@
|
|||
runScript = "vivado";
|
||||
};
|
||||
|
||||
fast-servo-extrapkg = ({ config, pkgs, ... }: let
|
||||
pyrp3 = pkgs.python3Packages.buildPythonPackage rec {
|
||||
pname = "pyrp3";
|
||||
version = "1.2.0";
|
||||
pyproject = true;
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "linien-org";
|
||||
repo = "pyrp3";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-43TTlpJ5SMAjQM71bNVvrWQyciRXM3zpuA/Dw41AEgU=";
|
||||
};
|
||||
nativeBuildInputs = with pkgs.python3Packages; [ setuptools wheel setuptools-scm ];
|
||||
propagatedBuildInputs = with pkgs.python3Packages; [
|
||||
myhdl
|
||||
rpyc4
|
||||
cached-property
|
||||
numpy
|
||||
];
|
||||
pyrp3 = pkgs-armv7l.python3Packages.buildPythonPackage rec {
|
||||
pname = "pyrp3";
|
||||
version = "1.2.0";
|
||||
pyproject = true;
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "linien-org";
|
||||
repo = "pyrp3";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-43TTlpJ5SMAjQM71bNVvrWQyciRXM3zpuA/Dw41AEgU=";
|
||||
};
|
||||
|
||||
linien-server = pkgs.python3Packages.buildPythonPackage rec {
|
||||
pname = "linien-server";
|
||||
pyproject = true;
|
||||
inherit (pkgs.python3Packages.linien-common) src version;
|
||||
sourceRoot = "source/linien-server";
|
||||
postPatch = ''
|
||||
substituteInPlace linien_server/acquisition.py \
|
||||
--replace " start_nginx()" "" \
|
||||
--replace " stop_nginx()" "" \
|
||||
--replace " flash_fpga()" ""
|
||||
'';
|
||||
nativeBuildInputs = [ pkgs.python3Packages.setuptools ];
|
||||
propagatedBuildInputs = with pkgs.python3Packages; [
|
||||
appdirs
|
||||
certifi
|
||||
click
|
||||
cma
|
||||
pylpsd
|
||||
pyrp3
|
||||
requests
|
||||
linien-common
|
||||
];
|
||||
};
|
||||
in {
|
||||
system.build.linien-server = linien-server;
|
||||
environment.systemPackages = [
|
||||
linien-server
|
||||
(pkgs.python3.withPackages(ps: [ ps.spidev ps.smbus2 ]))
|
||||
nativeBuildInputs = with pkgs-armv7l.python3Packages; [ setuptools wheel setuptools-scm ];
|
||||
propagatedBuildInputs = with pkgs-armv7l.python3Packages; [
|
||||
myhdl
|
||||
rpyc4
|
||||
cached-property
|
||||
numpy
|
||||
];
|
||||
});
|
||||
};
|
||||
|
||||
fast-servo-init = ({ config, pkgs, lib, ... }: {
|
||||
boot.postBootCommands = lib.mkAfter ''
|
||||
|
||||
# Program the FPGA
|
||||
set +x
|
||||
echo Flashing bitstream...
|
||||
echo 0 > /sys/class/fpga_manager/fpga0/flags
|
||||
mkdir -p /lib/firmware
|
||||
cp ${fast-servo-gateware}/gateware.bin /lib/firmware/
|
||||
echo gateware.bin > /sys/class/fpga_manager/fpga0/firmware
|
||||
|
||||
# Run device init scripts
|
||||
mkdir -p /opt/pyfastservo
|
||||
cp ${./fast-servo/pyfastservo}/* /opt/pyfastservo
|
||||
python3 /opt/pyfastservo/initialize.py
|
||||
linien-server = pkgs-armv7l.python3Packages.buildPythonPackage rec {
|
||||
pname = "linien-server";
|
||||
pyproject = true;
|
||||
inherit (pkgs.python3Packages.linien-common) src version;
|
||||
sourceRoot = "source/linien-server";
|
||||
postPatch = ''
|
||||
substituteInPlace linien_server/acquisition.py \
|
||||
--replace " start_nginx()" "" \
|
||||
--replace " stop_nginx()" "" \
|
||||
--replace " flash_fpga()" ""
|
||||
'';
|
||||
});
|
||||
nativeBuildInputs = [ pkgs-armv7l.python3Packages.setuptools ];
|
||||
propagatedBuildInputs = with pkgs-armv7l.python3Packages; [
|
||||
appdirs
|
||||
certifi
|
||||
click
|
||||
cma
|
||||
pylpsd
|
||||
pyrp3
|
||||
requests
|
||||
linien-common
|
||||
];
|
||||
};
|
||||
|
||||
fast-servo-gateware = pkgs.stdenv.mkDerivation rec {
|
||||
name = "fast-servo-gateware";
|
||||
|
@ -216,10 +208,30 @@
|
|||
inherit nixpkgs;
|
||||
extraModules = [
|
||||
"${patched-not-os}/zynq_image.nix"
|
||||
] ++ pkgs.lib.optional (board == "fast-servo") fast-servo-extrapkg
|
||||
++ pkgs.lib.optional (board == "fast-servo") fast-servo-init;
|
||||
] ++ pkgs.lib.optionals (board == "fast-servo") [
|
||||
({ config, pkgs, lib, ... }: {
|
||||
environment.systemPackages = [
|
||||
linien-server
|
||||
(pkgs.python3.withPackages(ps: [ ps.spidev ps.smbus2 ]))
|
||||
];
|
||||
boot.postBootCommands = lib.mkAfter ''
|
||||
|
||||
# Program the FPGA
|
||||
set +x
|
||||
echo Flashing bitstream...
|
||||
echo 0 > /sys/class/fpga_manager/fpga0/flags
|
||||
mkdir -p /lib/firmware
|
||||
cp ${fast-servo-gateware}/gateware.bin /lib/firmware/
|
||||
echo gateware.bin > /sys/class/fpga_manager/fpga0/firmware
|
||||
|
||||
# Run device init scripts
|
||||
mkdir -p /opt/pyfastservo
|
||||
cp ${./fast-servo/pyfastservo}/* /opt/pyfastservo
|
||||
python3 /opt/pyfastservo/initialize.py
|
||||
'';
|
||||
})];
|
||||
system = "x86_64-linux";
|
||||
crossSystem.system = "armv7l-linux";
|
||||
inherit crossSystem;
|
||||
});
|
||||
|
||||
not-os-build = not-os-configured.config.system.build;
|
||||
|
@ -262,9 +274,7 @@
|
|||
dontFixup = true;
|
||||
};
|
||||
|
||||
u-boot = let
|
||||
fast-servo-dts = fast-servo/fast-servo.dts;
|
||||
in (pkgs.pkgsCross.armv7l-hf-multiplatform.buildUBoot {
|
||||
u-boot = (pkgs-armv7l.buildUBoot {
|
||||
defconfig = "xilinx_zynq_virt_defconfig";
|
||||
patches = [] ++ pkgs.lib.optional (board == "fast-servo") ./fast-servo/u-boot.patch;
|
||||
preConfigure = ''
|
||||
|
@ -287,7 +297,7 @@
|
|||
filesToInstall = [ "u-boot.elf" ];
|
||||
}).overrideAttrs (oldAttrs: {
|
||||
postUnpack = ''
|
||||
cp ${fast-servo-dts} $sourceRoot/arch/arm/dts/zynq-fast-servo.dts
|
||||
cp ${fast-servo/fast-servo.dts} $sourceRoot/arch/arm/dts/zynq-fast-servo.dts
|
||||
'';
|
||||
postInstall = ''
|
||||
mkdir -p $out/dts
|
||||
|
@ -393,7 +403,9 @@
|
|||
export PATH=${pkgs.qemu}/bin:$PATH
|
||||
IMGDIR=$(mktemp -d /tmp/not-os-qemu-XXXXXX)
|
||||
BASE=$(realpath $(dirname $0))
|
||||
qemu-img create -F raw -f qcow2 -b $BASE/sd-image.img $IMGDIR/sd-overlay.qcow2 4G
|
||||
|
||||
qemu-img convert -O qcow2 -f raw -o preallocation=metadata $BASE/sd-image.img $IMGDIR/sd-sparse.qcow2
|
||||
qemu-img create -F qcow2 -f qcow2 -b $IMGDIR/sd-sparse.qcow2 $IMGDIR/sd-overlay.qcow2 2G
|
||||
|
||||
# Some command arguments are based from samples in Xilinx QEMU User Documentation
|
||||
# See: https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/821854273/Running+Bare+Metal+Applications+on+QEMU
|
||||
|
@ -429,7 +441,6 @@
|
|||
"${board}-dtb" = dtb;
|
||||
"${board}-sd-image" = sd-image;
|
||||
"${board}-qemu" = not-os-qemu;
|
||||
linien-server = not-os-build.linien-server;
|
||||
};
|
||||
in rec {
|
||||
packages.x86_64-linux = {
|
||||
|
@ -437,7 +448,7 @@
|
|||
inherit migen misoc vivado;
|
||||
};
|
||||
packages.armv7l-linux = {
|
||||
inherit fast-servo-gateware;
|
||||
inherit fast-servo-gateware linien-server;
|
||||
} //
|
||||
(board-package-set { board = "zc706"; }) //
|
||||
(board-package-set { board = "fast-servo"; });
|
||||
|
|
|
@ -151,10 +151,10 @@ index c61f9d6..fbdf0fd 100644
|
|||
};
|
||||
}
|
||||
diff --git a/zynq_image.nix b/zynq_image.nix
|
||||
index 3fa23ab..e2e3871 100644
|
||||
index 3fa23ab..9d1621e 100644
|
||||
--- a/zynq_image.nix
|
||||
+++ b/zynq_image.nix
|
||||
@@ -1,66 +1,102 @@
|
||||
@@ -1,66 +1,89 @@
|
||||
-{ config, pkgs, ... }:
|
||||
+{ lib, config, pkgs, ... }:
|
||||
|
||||
|
@ -163,22 +163,7 @@ index 3fa23ab..e2e3871 100644
|
|||
- # dont use overlays for the qemu, it causes a lot of wasted time on recompiles
|
||||
- x86pkgs = import pkgs.path { system = "x86_64-linux"; };
|
||||
- customKernel = pkgs.linux.override {
|
||||
+ crosspkgs = import pkgs.path {
|
||||
+ system = "x86_64-linux";
|
||||
+ crossSystem = {
|
||||
+ system = "armv7l-linux";
|
||||
+ linux-kernel = {
|
||||
+ name = "zynq";
|
||||
+ baseConfig = "multi_v7_defconfig";
|
||||
+ target = "uImage";
|
||||
+ installTarget = "uImage";
|
||||
+ autoModules = false;
|
||||
+ DTB = true;
|
||||
+ makeFlags = [ "LOADADDR=0x8000" ];
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+ customKernel = (crosspkgs.linux.override {
|
||||
+ customKernel = (pkgs.linux.override {
|
||||
extraConfig = ''
|
||||
OVERLAY_FS y
|
||||
+ MEDIA_SUPPORT n
|
||||
|
@ -195,14 +180,15 @@ index 3fa23ab..e2e3871 100644
|
|||
+ OF_OVERLAY y
|
||||
'';
|
||||
- };
|
||||
- customKernelPackages = pkgs.linuxPackagesFor customKernel;
|
||||
+ }).overrideAttrs (oa: {
|
||||
+ postInstall = ''
|
||||
+ cp arch/arm/boot/uImage $out
|
||||
+ if [ -e arch/arm/boot/uImage ]; then
|
||||
+ cp arch/arm/boot/uImage $out
|
||||
+ fi
|
||||
+ ${oa.postInstall}
|
||||
+ '';
|
||||
+ });
|
||||
+ customKernelPackages = crosspkgs.linuxPackagesFor customKernel;
|
||||
customKernelPackages = pkgs.linuxPackagesFor customKernel;
|
||||
in {
|
||||
imports = [ ./arm32-cross-fixes.nix ];
|
||||
boot.kernelPackages = customKernelPackages;
|
||||
|
@ -253,12 +239,12 @@ index 3fa23ab..e2e3871 100644
|
|||
- chmod +x qemu-script
|
||||
- patchShebangs qemu-script
|
||||
- ls -ltrh
|
||||
'';
|
||||
- '';
|
||||
- system.build.rpi_image_tar = pkgs.runCommand "dist.tar" {} ''
|
||||
- mkdir -p $out/nix-support
|
||||
- tar -cvf $out/dist.tar ${config.system.build.rpi_image}
|
||||
- echo "file binary-dist $out/dist.tar" >> $out/nix-support/hydra-build-products
|
||||
- '';
|
||||
'';
|
||||
- environment.systemPackages = [ pkgs.strace ];
|
||||
- environment.etc."service/getty/run".source = pkgs.writeShellScript "getty" ''
|
||||
- agetty ttyPS0 115200
|
||||
|
|
|
@ -1062,13 +1062,13 @@ index 0000000..59aa585
|
|||
++
|
||||
+ #endif /*_LINUX_FPGA_MGR_H */
|
||||
diff --git a/zynq_image.nix b/zynq_image.nix
|
||||
index e2e3871..2decd54 100644
|
||||
index 9d1621e..012e50c 100644
|
||||
--- a/zynq_image.nix
|
||||
+++ b/zynq_image.nix
|
||||
@@ -18,6 +18,16 @@ let
|
||||
};
|
||||
};
|
||||
customKernel = (crosspkgs.linux.override {
|
||||
@@ -3,6 +3,16 @@
|
||||
with lib;
|
||||
let
|
||||
customKernel = (pkgs.linux.override {
|
||||
+ kernelPatches = [
|
||||
+ ({
|
||||
+ name = "xilinx-configfs-overlays";
|
||||
|
@ -1082,7 +1082,7 @@ index e2e3871..2decd54 100644
|
|||
extraConfig = ''
|
||||
OVERLAY_FS y
|
||||
MEDIA_SUPPORT n
|
||||
@@ -32,6 +42,7 @@ let
|
||||
@@ -17,6 +27,7 @@ let
|
||||
OF_FPGA_REGION y
|
||||
FPGA_MGR_ZYNQ_FPGA y
|
||||
OF_OVERLAY y
|
||||
|
|
Loading…
Reference in New Issue