{ lib, stdenvNoCC, namespace, pkgs, }: let inherit (lib.trivial) importJSON; inherit (lib.${namespace}) selectVariant mkAllSources; versionSpec = importJSON ./version.json; selected = selectVariant versionSpec null null; vars = selected.variables or { }; sources = mkAllSources pkgs selected; defaultConfig = '' EOF armstub=RPI_EFI.fd # device_tree_address=0x3e0000 # device_tree_end=0x400000 device_tree_address=0x1f0000 device_tree_end=0x210000 # Force 32 bpp framebuffer allocation. framebuffer_depth=32 # Disable compensation for displays with overscan. disable_overscan=1 # Force maximum USB power regardless of the power supply. usb_max_current_enable=1 # Force maximum CPU speed. force_turbo=1 dtoverlay=vc4-kms-v3d-pi5.dtbo dtoverlay=i2c0-pi5.dtbo dtoverlay=i2c1-pi5.dtbo dtoverlay=i2c2-pi5.dtbo dtoverlay=i2c3-pi5.dtbo dtoverlay=pisound-pi5.dtbo dtoverlay=sdio-pi5.dtbo dtoverlay=disable-wifi-pi5.dtbo EOF ''; nvram = ./nvram-block.bin; in stdenvNoCC.mkDerivation rec { pname = "uefi-rpi5"; version = vars.version; src = sources.firmware; sourceRoot = "."; dontUnpack = true; dontBuild = true; # Firmware blobs do not need fixing and should not be modified dontFixup = true; # fixupPhase = '' # runHook preFixup # dd if=${nvram} of="$src/RPI_EFI.fd" \ # bs=1 seek=$((0x1d0060)) count=$((0x11c0)) conv=notrunc # runHook postFixup # ''; installPhase = '' runHook preInstall mkdir -p "$out" cp ${src} . dd if=${nvram} of=./RPI_EFI.fd \ bs=1 seek=$((0x1d0060)) count=$((0x11c0)) conv=notrunc cp -v ./RPI_EFI.fd "$out/RPI_EFI.fd" # cp ${src} "$out/RPI_EFI.fd" cat > "$out/config.txt" << ${defaultConfig} runHook postInstall ''; meta = with lib; { description = "RPI5 UEFI firmware"; homepage = "https://github.com/NumberOneGit/rpi5-uefi"; platforms = platforms.linux; maintainers = [ ]; }; }