Skip to content

Commit

Permalink
ubootOdroidN2: init
Browse files Browse the repository at this point in the history
  • Loading branch information
oddlama committed Jul 27, 2023
1 parent 6efca77 commit ecd0a9b
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 14 deletions.
6 changes: 3 additions & 3 deletions pkgs/misc/meson64-tools/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand All @@ -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
)
'';
Expand All @@ -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 ];
};
Expand Down
60 changes: 49 additions & 11 deletions pkgs/misc/uboot/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
, flex
, gnutls
, libuuid
, meson64-tools
, meson-tools
, ncurses
, openssl
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -215,15 +258,7 @@ in {
# Flashing instructions:
# dd if=u-boot.gxl.sd.bin of=<sdcard> conv=fsync,notrunc bs=512 skip=1 seek=1
# dd if=u-boot.gxl.sd.bin of=<sdcard> 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";
Expand All @@ -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
Expand Down Expand Up @@ -327,6 +362,9 @@ in {
'';
};

ubootOdroidN2 = buildUBootOdroidN2 "odroid-n2";
ubootOdroidN2Plus = buildUBootOdroidN2 "odroid-n2-plus";

ubootOdroidXU3 = buildUBoot {
defconfig = "odroid-xu3_defconfig";
extraMeta.platforms = ["armv7l-linux"];
Expand Down
2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28581,6 +28581,8 @@ with pkgs;
ubootNanoPCT4
ubootNovena
ubootOdroidC2
ubootOdroidN2
ubootOdroidN2Plus
ubootOdroidXU3
ubootOlimexA64Olinuxino
ubootOrangePi3
Expand Down

0 comments on commit ecd0a9b

Please sign in to comment.