Skip to content

Instantly share code, notes, and snippets.

@gtgteq
Last active January 23, 2022 00:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gtgteq/30cb73c344477d26f8c69768e010331a to your computer and use it in GitHub Desktop.
Save gtgteq/30cb73c344477d26f8c69768e010331a to your computer and use it in GitHub Desktop.
px4_drv.nix
{ stdenv, fetchFromGitHub, fetchzip }:
stdenv.mkDerivation rec {
pname = "it930x-firmware";
version = "1";
src = fetchFromGitHub {
owner = "nns779";
repo = "px4_drv";
rev = "90e0a4b30b812e7e5fff4483144f165de8914157";
sha256 = "1s9y5szv9i8dj6pnbkph48nikzf1bhkj592pczbq7hy31xr60hmw";
};
plexSrc = fetchzip {
url = "http://plex-net.co.jp/plex/pxw3u4/pxw3u4_BDA_ver1x64.zip";
sha256 = "1ky28m8hv86vivk2clps5qpmlrmlvfya8qcfmcvpd3n2kisbqsrl";
};
sourceRoot = "source/fwtool";
postUnpack = ''
cp "$plexSrc/PXW3U4.sys" source/fwtool/
'';
installPhase = ''
mkdir -p $out/lib/firmware/
./fwtool PXW3U4.sys $out/lib/firmware/it930x-firmware.bin
'';
meta = with stdenv.lib; {
description = "it930x-firmware for px4_drv";
homepage = https://github.com/nns779/px4_drv;
license = licenses.gpl2;
};
}
{ stdenv, fetchFromGitHub, kernel }:
stdenv.mkDerivation rec {
pname = "px4_drv";
version = "1";
src = fetchFromGitHub {
owner = "nns779";
repo = "px4_drv";
rev = "90e0a4b30b812e7e5fff4483144f165de8914157";
sha256 = "1s9y5szv9i8dj6pnbkph48nikzf1bhkj592pczbq7hy31xr60hmw";
};
sourceRoot = "source/driver";
patches = [ ./px4_drv.patch ];
hardeningDisable = [ "pic" ];
KVER = "${kernel.modDirVersion}";
KBUILD_DIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";
makeFlags = [
''KVER="${KVER}"''
''KBUILD_DIR="${KBUILD_DIR}"''
];
NIX_CFLAGS = ["-Wno-error=cpp"];
nativeBuildInputs = kernel.moduleBuildDependencies;
installPhase = ''
mkdir -p $out/lib/modules/${KVER}/misc
mkdir -p $out/lib/udev/rules.d
cp px4_drv.ko $out/lib/modules/${KVER}/misc/
cp ../etc/99-px4video.rules $out/lib/udev/rules.d/
'';
meta = with stdenv.lib; {
description = "Kernel module px4_drv";
homepage = https://github.com/nns779/px4_drv;
license = licenses.gpl2;
platforms = platforms.linux;
};
}
diff --git driver/Makefile driver/Makefile
index f59118b..58524b8 100644
--- driver/Makefile
+++ driver/Makefile
@@ -33,9 +33,9 @@ px4_drv.ko: FORCE revision.h
$(cmd_prefix)$(MAKE) -C $(KBUILD_DIR) M=$(CURRENT_DIR) KBUILD_VERBOSE=$(VERBOSE) modules
revision.h: FORCE
- $(cmd_prefix)rev=`git rev-list --count HEAD` 2>/dev/null; \
- rev_name=`git name-rev --name-only HEAD` 2>/dev/null; \
- commit=`git rev-list --max-count=1 HEAD` 2>/dev/null; \
+ $(cmd_prefix)rev=200 2>/dev/null; \
+ rev_name=develop 2>/dev/null; \
+ commit=90e0a4b30b812e7e5fff4483144f165de8914157 2>/dev/null; \
if [ ! -s $@ ] || [ \"`grep -soE '^#define REVISION_NUMBER[[:blank:]]+"[0-9]+"$$' $@ | sed -E 's/^.+"(.*)"$$/\1/g'`.`grep -soE '^#define REVISION_NAME[[:blank:]]+"[[:print:]]+"$$' $@ | sed -E 's/^.+"(.*)"$$/\1/g'`.`grep -soE '^#define COMMIT_HASH[[:blank:]]+"[0-9A-Fa-f]+"$$' $@ | sed -E 's/^.+"(.*)"$$/\1/g'`\" != \"$${rev}.$${rev_name}.$${commit}\" ]; then \
echo "// revision.h" > $@; \
echo "" >> $@; \

configuration.nix:

let px4_drv = pkgs.callPackage ./px4_drv.nix {
      kernel = pkgs.linux_4_19;
    };
    it930x = pkgs.callPackage ./it930x.nix {};
in
{
  boot.kernelPackages = pkgs.linuxPackages_4_19;
  boot.extraModulePackages = [ px4_drv ];
  hardware.firmware = [ it930x ];
  services.udev.packages = [ px4_drv ];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment