From ecd0a9bc877af10121240dbe9558166bbdbcad3b Mon Sep 17 00:00:00 2001 From: oddlama Date: Sun, 23 Jul 2023 22:54:04 +0200 Subject: [PATCH] ubootOdroidN2: init --- pkgs/misc/meson64-tools/default.nix | 6 +-- pkgs/misc/uboot/default.nix | 60 +++++++++++++++++++++++------ pkgs/top-level/all-packages.nix | 2 + 3 files changed, 54 insertions(+), 14 deletions(-) diff --git a/pkgs/misc/meson64-tools/default.nix b/pkgs/misc/meson64-tools/default.nix index c5ce2d998ecd12..5d0c11d218f709 100644 --- a/pkgs/misc/meson64-tools/default.nix +++ b/pkgs/misc/meson64-tools/default.nix @@ -15,7 +15,7 @@ stdenv.mkDerivation rec { hash = "sha256-/koIsslDNpaFHf1TV/0Xt0TiyhjL6tCz2oHQraYNhPA="; }; - nativeBuildInputs = with buildPackages; [ openssl bison yacc flex bc python3 ]; + nativeBuildInputs = with buildPackages; [ openssl bison flex bc python3 ]; preBuild = '' patchShebangs --build . @@ -29,7 +29,7 @@ stdenv.mkDerivation rec { postInstall = '' (cd $out/bin for bin in *; do - ln -s $bin meson64-$bin + ln -s $bin meson64-g12-$bin done ) ''; @@ -38,7 +38,7 @@ stdenv.mkDerivation rec { meta = with lib; { homepage = "https://github.com/angerman/meson64-tools"; - description = "Tools for Amlogic Meson ARM64 platforms"; + description = "Tools for Amlogic G12 platforms"; license = licenses.mit; maintainers = with maintainers; [ oddlama ]; }; diff --git a/pkgs/misc/uboot/default.nix b/pkgs/misc/uboot/default.nix index 517f9e784a616e..40d351bc2afd33 100644 --- a/pkgs/misc/uboot/default.nix +++ b/pkgs/misc/uboot/default.nix @@ -9,6 +9,7 @@ , flex , gnutls , libuuid +, meson64-tools , meson-tools , ncurses , openssl @@ -126,6 +127,48 @@ let maintainers = with maintainers; [ bartsch dezgeg samueldr lopsided98 ]; } // extraMeta; } // removeAttrs args [ "extraMeta" ])); + + amlogic-boot-fip = fetchFromGitHub { + owner = "LibreELEC"; + repo = "amlogic-boot-fip"; + rev = "4369a138ca24c5ab932b8cbd1af4504570b709df"; + sha256 = "sha256-mGRUwdh3nW4gBwWIYHJGjzkezHxABwcwk/1gVRis7Tc="; + meta.license = lib.licenses.unfreeRedistributableFirmware; + }; + + # Flashing instructions: + # dd if=${drv}/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1 + # dd if=${drv}/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=1 count=440 + buildUBootOdroidN2 = fipDirectory: buildUBoot { + defconfig = "odroid-n2_defconfig"; + extraMeta.platforms = ["aarch64-linux"]; + filesToInstall = ["u-boot.bin"]; + postBuild = '' + mkdir $out + + FIPDIR=${amlogic-boot-fip}/${fipDirectory} + ${buildPackages.meson64-tools}/bin/meson64-g12-pkg --type bl30 --output bl30.pkg $FIPDIR/bl30.bin $FIPDIR/bl301.bin + ${buildPackages.meson64-tools}/bin/meson64-g12-pkg --type bl2 --output bl2.pkg $FIPDIR/bl2.bin $FIPDIR/acs.bin + ${buildPackages.meson64-tools}/bin/meson64-g12-bl30sig --input bl30.pkg --output bl30.30sig + ${buildPackages.meson64-tools}/bin/meson64-g12-bl3sig --input bl30.30sig --output bl30.3sig + ${buildPackages.meson64-tools}/bin/meson64-g12-bl3sig --input $FIPDIR/bl31.img --output bl31.3sig + ${buildPackages.meson64-tools}/bin/meson64-g12-bl3sig --input u-boot.bin --output bl33.3sig + ${buildPackages.meson64-tools}/bin/meson64-g12-bl2sig --input bl2.pkg --output bl2.2sig + ${buildPackages.meson64-tools}/bin/meson64-g12-bootmk --output $out/u-boot.bin \ + --bl2 bl2.2sig \ + --bl30 bl30.3sig \ + --bl31 bl31.3sig \ + --bl33 bl33.3sig \ + --ddrfw1 $FIPDIR/ddr4_1d.fw \ + --ddrfw2 $FIPDIR/ddr4_2d.fw \ + --ddrfw3 $FIPDIR/ddr3_1d.fw \ + --ddrfw4 $FIPDIR/piei.fw \ + --ddrfw5 $FIPDIR/lpddr4_1d.fw \ + --ddrfw6 $FIPDIR/lpddr4_2d.fw \ + --ddrfw7 $FIPDIR/diag_lpddr4.fw \ + --ddrfw8 $FIPDIR/aml_ddr.fw + ''; + }; in { inherit buildUBoot; @@ -215,15 +258,7 @@ in { # Flashing instructions: # dd if=u-boot.gxl.sd.bin of= conv=fsync,notrunc bs=512 skip=1 seek=1 # dd if=u-boot.gxl.sd.bin of= conv=fsync,notrunc bs=1 count=444 - ubootLibreTechCC = let - firmwareImagePkg = fetchFromGitHub { - owner = "LibreELEC"; - repo = "amlogic-boot-fip"; - rev = "4369a138ca24c5ab932b8cbd1af4504570b709df"; - sha256 = "sha256-mGRUwdh3nW4gBwWIYHJGjzkezHxABwcwk/1gVRis7Tc="; - meta.license = lib.licenses.unfreeRedistributableFirmware; - }; - in + ubootLibreTechCC = assert stdenv.buildPlatform.system == "x86_64-linux"; # aml_encrypt_gxl is a x86_64 binary buildUBoot { defconfig = "libretech-cc_defconfig"; @@ -232,8 +267,8 @@ in { postBuild = '' # Copy binary files & tools from LibreELEC/amlogic-boot-fip, and u-boot build to working dir mkdir $out tmp - cp ${firmwareImagePkg}/lepotato/{acs.bin,bl2.bin,bl21.bin,bl30.bin,bl301.bin,bl31.img} \ - ${firmwareImagePkg}/lepotato/{acs_tool.py,aml_encrypt_gxl,blx_fix.sh} \ + cp ${amlogic-boot-fip}/lepotato/{acs.bin,bl2.bin,bl21.bin,bl30.bin,bl301.bin,bl31.img} \ + ${amlogic-boot-fip}/lepotato/{acs_tool.py,aml_encrypt_gxl,blx_fix.sh} \ u-boot.bin tmp/ cd tmp python3 acs_tool.py bl2.bin bl2_acs.bin acs.bin 0 @@ -327,6 +362,9 @@ in { ''; }; + ubootOdroidN2 = buildUBootOdroidN2 "odroid-n2"; + ubootOdroidN2Plus = buildUBootOdroidN2 "odroid-n2-plus"; + ubootOdroidXU3 = buildUBoot { defconfig = "odroid-xu3_defconfig"; extraMeta.platforms = ["armv7l-linux"]; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 4d44406874624b..ae5951b6f2fad3 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -28581,6 +28581,8 @@ with pkgs; ubootNanoPCT4 ubootNovena ubootOdroidC2 + ubootOdroidN2 + ubootOdroidN2Plus ubootOdroidXU3 ubootOlimexA64Olinuxino ubootOrangePi3