Merge pull request #75069 from lopsided98/uboot-odroid-c2
uboot: add support for the ODROID-C2
This commit is contained in:
commit
4f67905034
@ -1,16 +1,16 @@
|
|||||||
{ stdenv, fetchFromGitHub, pkgsCross, buildPackages }:
|
{ lib, stdenv, fetchFromGitHub, fetchpatch, openssl, pkgsCross, buildPackages }:
|
||||||
|
|
||||||
let
|
let
|
||||||
buildArmTrustedFirmware = { filesToInstall
|
buildArmTrustedFirmware = { filesToInstall
|
||||||
, installDir ? "$out"
|
, installDir ? "$out"
|
||||||
, platform
|
, platform ? null
|
||||||
, extraMakeFlags ? []
|
, extraMakeFlags ? []
|
||||||
, extraMeta ? {}
|
, extraMeta ? {}
|
||||||
, version ? "2.1"
|
, version ? "2.1"
|
||||||
, ... } @ args:
|
, ... } @ args:
|
||||||
stdenv.mkDerivation ({
|
stdenv.mkDerivation ({
|
||||||
|
|
||||||
name = "arm-trusted-firmware-${platform}-${version}";
|
name = "arm-trusted-firmware${lib.optionalString (platform != null) "-${platform}"}-${version}";
|
||||||
inherit version;
|
inherit version;
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
@ -25,16 +25,18 @@ let
|
|||||||
# For Cortex-M0 firmware in RK3399
|
# For Cortex-M0 firmware in RK3399
|
||||||
nativeBuildInputs = [ pkgsCross.arm-embedded.stdenv.cc ];
|
nativeBuildInputs = [ pkgsCross.arm-embedded.stdenv.cc ];
|
||||||
|
|
||||||
|
buildInputs = [ openssl ];
|
||||||
|
|
||||||
makeFlags = [
|
makeFlags = [
|
||||||
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"
|
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"
|
||||||
"PLAT=${platform}"
|
] ++ (lib.optional (platform != null) "PLAT=${platform}")
|
||||||
] ++ extraMakeFlags;
|
++ extraMakeFlags;
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
|
|
||||||
mkdir -p ${installDir}
|
mkdir -p ${installDir}
|
||||||
cp ${stdenv.lib.concatStringsSep " " filesToInstall} ${installDir}
|
cp ${lib.concatStringsSep " " filesToInstall} ${installDir}
|
||||||
|
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
@ -45,7 +47,7 @@ let
|
|||||||
# Fatal error: can't create build/sun50iw1p1/release/bl31/sunxi_clocks.o: No such file or directory
|
# Fatal error: can't create build/sun50iw1p1/release/bl31/sunxi_clocks.o: No such file or directory
|
||||||
enableParallelBuilding = false;
|
enableParallelBuilding = false;
|
||||||
|
|
||||||
meta = with stdenv.lib; {
|
meta = with lib; {
|
||||||
homepage = https://github.com/ARM-software/arm-trusted-firmware;
|
homepage = https://github.com/ARM-software/arm-trusted-firmware;
|
||||||
description = "A reference implementation of secure world software for ARMv8-A";
|
description = "A reference implementation of secure world software for ARMv8-A";
|
||||||
license = licenses.bsd3;
|
license = licenses.bsd3;
|
||||||
@ -56,6 +58,22 @@ let
|
|||||||
in {
|
in {
|
||||||
inherit buildArmTrustedFirmware;
|
inherit buildArmTrustedFirmware;
|
||||||
|
|
||||||
|
armTrustedFirmwareTools = buildArmTrustedFirmware rec {
|
||||||
|
extraMakeFlags = [
|
||||||
|
"HOSTCC=${stdenv.cc.targetPrefix}gcc"
|
||||||
|
"fiptool" "certtool" "sptool"
|
||||||
|
];
|
||||||
|
filesToInstall = [
|
||||||
|
"tools/fiptool/fiptool"
|
||||||
|
"tools/cert_create/cert_create"
|
||||||
|
"tools/sptool/sptool"
|
||||||
|
];
|
||||||
|
postInstall = ''
|
||||||
|
mkdir -p "$out/bin"
|
||||||
|
find "$out" -type f -executable -exec mv -t "$out/bin" {} +
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
armTrustedFirmwareAllwinner = buildArmTrustedFirmware rec {
|
armTrustedFirmwareAllwinner = buildArmTrustedFirmware rec {
|
||||||
platform = "sun50i_a64";
|
platform = "sun50i_a64";
|
||||||
extraMeta.platforms = ["aarch64-linux"];
|
extraMeta.platforms = ["aarch64-linux"];
|
||||||
@ -85,4 +103,11 @@ in {
|
|||||||
extraMeta.platforms = ["aarch64-linux"];
|
extraMeta.platforms = ["aarch64-linux"];
|
||||||
filesToInstall = [ "build/${platform}/release/bl31/bl31.elf"];
|
filesToInstall = [ "build/${platform}/release/bl31/bl31.elf"];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
armTrustedFirmwareS905 = buildArmTrustedFirmware rec {
|
||||||
|
extraMakeFlags = [ "bl31" ];
|
||||||
|
platform = "gxbb";
|
||||||
|
extraMeta.platforms = ["aarch64-linux"];
|
||||||
|
filesToInstall = [ "build/${platform}/release/bl31.bin"];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
27
pkgs/misc/meson-tools/default.nix
Normal file
27
pkgs/misc/meson-tools/default.nix
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{ lib, stdenv, fetchFromGitHub, openssl }:
|
||||||
|
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
|
pname = "meson-tools";
|
||||||
|
version = "0.1";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "afaerber";
|
||||||
|
repo = pname;
|
||||||
|
rev = "v${version}";
|
||||||
|
sha256 = "1bvshfa9pa012yzdwapi3nalpgcwmfq7d3n3w3mlr357a6kq64qk";
|
||||||
|
};
|
||||||
|
|
||||||
|
buildInputs = [ openssl ];
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p "$out/bin"
|
||||||
|
mv amlbootsig unamlbootsig amlinfo "$out/bin"
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
homepage = "https://github.com/afaerber/meson-tools";
|
||||||
|
description = "Tools for Amlogic Meson ARM platforms";
|
||||||
|
license = licenses.gpl2;
|
||||||
|
maintainers = with maintainers; [ lopsided98 ];
|
||||||
|
};
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
{ stdenv, lib, fetchurl, fetchpatch, fetchFromGitHub, bc, bison, dtc, flex
|
{ stdenv, lib, fetchurl, fetchpatch, fetchFromGitHub, bc, bison, dtc, flex
|
||||||
, openssl, swig, armTrustedFirmwareAllwinner, armTrustedFirmwareRK3328
|
, openssl, swig, meson-tools, armTrustedFirmwareAllwinner
|
||||||
, armTrustedFirmwareRK3399
|
, armTrustedFirmwareRK3328, armTrustedFirmwareRK3399
|
||||||
|
, armTrustedFirmwareS905
|
||||||
, buildPackages
|
, buildPackages
|
||||||
}:
|
}:
|
||||||
|
|
||||||
@ -94,7 +95,7 @@ let
|
|||||||
homepage = http://www.denx.de/wiki/U-Boot/;
|
homepage = http://www.denx.de/wiki/U-Boot/;
|
||||||
description = "Boot loader for embedded systems";
|
description = "Boot loader for embedded systems";
|
||||||
license = licenses.gpl2;
|
license = licenses.gpl2;
|
||||||
maintainers = with maintainers; [ dezgeg samueldr ];
|
maintainers = with maintainers; [ dezgeg samueldr lopsided98 ];
|
||||||
} // extraMeta;
|
} // extraMeta;
|
||||||
} // removeAttrs args [ "extraMeta" ]);
|
} // removeAttrs args [ "extraMeta" ]);
|
||||||
|
|
||||||
@ -178,6 +179,52 @@ in {
|
|||||||
filesToInstall = ["u-boot.bin" "SPL"];
|
filesToInstall = ["u-boot.bin" "SPL"];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Flashing instructions:
|
||||||
|
# dd if=bl1.bin.hardkernel of=<device> conv=fsync bs=1 count=442
|
||||||
|
# dd if=bl1.bin.hardkernel of=<device> conv=fsync bs=512 skip=1 seek=1
|
||||||
|
# dd if=u-boot.gxbb of=<device> conv=fsync bs=512 seek=97
|
||||||
|
ubootOdroidC2 = let
|
||||||
|
firmwareBlobs = fetchFromGitHub {
|
||||||
|
owner = "armbian";
|
||||||
|
repo = "odroidc2-blobs";
|
||||||
|
rev = "47c5aac4bcac6f067cebe76e41fb9924d45b429c";
|
||||||
|
sha256 = "1ns0a130yxnxysia8c3q2fgyjp9k0nkr689dxk88qh2vnibgchnp";
|
||||||
|
meta.license = lib.licenses.unfreeRedistributableFirmware;
|
||||||
|
};
|
||||||
|
in buildUBoot {
|
||||||
|
defconfig = "odroid-c2_defconfig";
|
||||||
|
extraMeta.platforms = ["aarch64-linux"];
|
||||||
|
filesToInstall = ["u-boot.bin" "u-boot.gxbb" "${firmwareBlobs}/bl1.bin.hardkernel"];
|
||||||
|
postBuild = ''
|
||||||
|
# BL301 image needs at least 64 bytes of padding after it to place
|
||||||
|
# signing headers (with amlbootsig)
|
||||||
|
truncate -s 64 bl301.padding.bin
|
||||||
|
cat '${firmwareBlobs}/gxb/bl301.bin' bl301.padding.bin > bl301.padded.bin
|
||||||
|
# The downstream fip_create tool adds a custom TOC entry with UUID
|
||||||
|
# AABBCCDD-ABCD-EFEF-ABCD-12345678ABCD for the BL301 image. It turns out
|
||||||
|
# that the firmware blob does not actually care about UUIDs, only the
|
||||||
|
# order the images appear in the file. Because fiptool does not know
|
||||||
|
# about the BL301 UUID, we would have to use the --blob option, which adds
|
||||||
|
# the image to the end of the file, causing the boot to fail. Instead, we
|
||||||
|
# take advantage of the fact that UUIDs are ignored and just put the
|
||||||
|
# images in the right order with the wrong UUIDs. In the command below,
|
||||||
|
# --tb-fw is really --scp-fw and --scp-fw is the BL301 image.
|
||||||
|
#
|
||||||
|
# See https://github.com/afaerber/meson-tools/issues/3 for more
|
||||||
|
# information.
|
||||||
|
'${buildPackages.armTrustedFirmwareTools}/bin/fiptool' create \
|
||||||
|
--align 0x4000 \
|
||||||
|
--tb-fw '${firmwareBlobs}/gxb/bl30.bin' \
|
||||||
|
--scp-fw bl301.padded.bin \
|
||||||
|
--soc-fw '${armTrustedFirmwareS905}/bl31.bin' \
|
||||||
|
--nt-fw u-boot.bin \
|
||||||
|
fip.bin
|
||||||
|
cat '${firmwareBlobs}/gxb/bl2.package' fip.bin > boot_new.bin
|
||||||
|
'${buildPackages.meson-tools}/bin/amlbootsig' boot_new.bin u-boot.img
|
||||||
|
dd if=u-boot.img of=u-boot.gxbb bs=512 skip=96
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
ubootOdroidXU3 = buildUBoot {
|
ubootOdroidXU3 = buildUBoot {
|
||||||
defconfig = "odroid-xu3_defconfig";
|
defconfig = "odroid-xu3_defconfig";
|
||||||
extraMeta.platforms = ["armv7l-linux"];
|
extraMeta.platforms = ["armv7l-linux"];
|
||||||
|
@ -1916,6 +1916,8 @@ in
|
|||||||
|
|
||||||
meson = callPackage ../development/tools/build-managers/meson { };
|
meson = callPackage ../development/tools/build-managers/meson { };
|
||||||
|
|
||||||
|
meson-tools = callPackage ../misc/meson-tools { };
|
||||||
|
|
||||||
metabase = callPackage ../servers/metabase { };
|
metabase = callPackage ../servers/metabase { };
|
||||||
|
|
||||||
mididings = callPackage ../tools/audio/mididings { };
|
mididings = callPackage ../tools/audio/mididings { };
|
||||||
@ -15898,10 +15900,12 @@ in
|
|||||||
|
|
||||||
inherit (callPackage ../misc/arm-trusted-firmware {})
|
inherit (callPackage ../misc/arm-trusted-firmware {})
|
||||||
buildArmTrustedFirmware
|
buildArmTrustedFirmware
|
||||||
|
armTrustedFirmwareTools
|
||||||
armTrustedFirmwareAllwinner
|
armTrustedFirmwareAllwinner
|
||||||
armTrustedFirmwareQemu
|
armTrustedFirmwareQemu
|
||||||
armTrustedFirmwareRK3328
|
armTrustedFirmwareRK3328
|
||||||
armTrustedFirmwareRK3399
|
armTrustedFirmwareRK3399
|
||||||
|
armTrustedFirmwareS905
|
||||||
;
|
;
|
||||||
|
|
||||||
microcodeAmd = callPackage ../os-specific/linux/microcode/amd.nix { };
|
microcodeAmd = callPackage ../os-specific/linux/microcode/amd.nix { };
|
||||||
@ -17056,6 +17060,7 @@ in
|
|||||||
ubootGuruplug
|
ubootGuruplug
|
||||||
ubootJetsonTK1
|
ubootJetsonTK1
|
||||||
ubootNovena
|
ubootNovena
|
||||||
|
ubootOdroidC2
|
||||||
ubootOdroidXU3
|
ubootOdroidXU3
|
||||||
ubootOrangePiPc
|
ubootOrangePiPc
|
||||||
ubootOrangePiZeroPlus2H5
|
ubootOrangePiZeroPlus2H5
|
||||||
|
Loading…
x
Reference in New Issue
Block a user