diff --git a/hosts/modules/hal/samsung/default.nix b/hosts/modules/hal/samsung/default.nix index 72e48758..c5bbdd6b 100644 --- a/hosts/modules/hal/samsung/default.nix +++ b/hosts/modules/hal/samsung/default.nix @@ -54,33 +54,6 @@ { config, lib, pkgs, ... }: let cfg = config.sane.hal.samsung; - # dtbs = "${config.system.build.kernel}/dtbs/exynos"; - # dtbs = "${config.system.build.kernel}/dtbs"; - # initrd = "${config.system.build.initialRamdisk}"; - # kernel_file = "${config.system.build.kernel}/zImage"; #< TODO: `zImage` is specific to the `stdenv` config - # kernel-lzma = pkgs.runCommand "kernel-lzma" { nativeBuildInputs = [ pkgs.xz ]; } '' - # lzma --threads 0 < ${kernel_file} > "$out" - # ''; - # cmdlineText = lib.concatStringsSep " " (config.boot.kernelParams ++ [ - # "init=${config.system.build.toplevel}/init" - # ]); - # cmdlineFile = pkgs.writeTextFile { - # name = "kernel-cmdline"; - # text = cmdlineText; - # }; - u-boot = pkgs.buildUBoot { - defconfig = "snow_defconfig"; - extraMeta.platforms = [ "armv7l-linux" ]; - filesToInstall = [ - "u-boot" #< ELF file - "u-boot.bin" #< raw binary, load it into RAM and jump toit - "u-boot.cfg" #< copy of Kconfig which this u-boot was compiled with - "u-boot.dtb" - "u-boot.map" - "u-boot-nodtb.bin" - "u-boot.sym" - ]; - }; in { options = { @@ -88,35 +61,8 @@ in }; config = lib.mkIf cfg.enable { - # we're limited to 8 MiB: omit the debugging utilities - # boot.initrd.availableKernelModules = lib.mkForce []; boot.initrd.compressor = "gzip"; # boot.initrd.compressorArgs = [ "--ultra" "-22" ]; - # boot.initrd.extraUtilsCommands = lib.mkForce '' - # rm -f $out/bin/{ata_id,cdrom_id,dmsetup,fido_id,lvm,scsi_id,v4l_id} - # ''; - # boot.initrd.supportedFilesystems = lib.mkForce [ "btrfs" ]; #< vfat should technically be optional? - # boot.initrd.availableKernelModules = lib.mkForce [ ]; - # boot.initrd.extraUdevRulesCommands = lib.mkForce ""; - # boot.initrd.extraUtilsCommandsTest = lib.mkForce ""; - # boot.initrd.luks.cryptoModules = lib.mkForce []; - # boot.initrd.services.udev.packages = lib.mkForce []; - # boot.initrd.services.udev.rules = lib.mkForce ""; - # # boot.initrd.systemd.enable = true; - # boot.initrd.systemd.enableTpm2 = false; - # # # build systemd w/o efivarfs support, so it won't complain about that missing module - # boot.initrd.systemd.package = pkgs.systemd.override { withEfi = false; }; - # boot.initrd.systemd.extraBin = lib.mkForce {}; - # boot.initrd.systemd.suppressedUnits = [ - # "ctrl-alt-del.target" - # "debug-shell.service" - # "emergency.service" - # "emergency.target" - # "rpcbind.target" - # # "swap.target" - # "systemd-fsck@.service" - # "systemd-bsod.service" - # ]; boot.initrd.availableKernelModules = [ # boot.initrd.kernelModules = [ @@ -130,7 +76,7 @@ in "uas" "sd-mod" ]; - # TODO: mobile-nixos says these modules break udev, if builtin or run before udev: + # N.B: mobile-nixos says these modules break udev, if builtin or run before udev: # "sbs-battery" # "sbs-charger" # "sbs-manager" @@ -143,57 +89,19 @@ in # }; # }); - # nixpkgs.overlays = [(self: super: { - # # optimize for size, especially to get a initrd which fits within the platform size constraints - # stdenv = super.withCFlags [ "-Os" ] super.stdenv; - # libgcrypt = super.libgcrypt.overrideAttrs (base: { - # postPatch = (base.postPatch or "") + '' - # export NIX_CFLAGS_COMPILE= - # ''; - # }); - # })]; - - system.build.u-boot = u-boot; - - # system.build.kernel-its = pkgs.runCommand "kernel-its-samsung" { - # nativeBuildInputs = with pkgs; [ - # dtc - # ubootTools - # vboot_reference - # xz - # ]; - # meta.description = '' - # ITS file is Image Tree Source: - # DTS is to ITS - # as DTB is to FIT. - # ''; - # } '' - - # ln -s "${kernel-lzma}" kernel.lzma - # ln -s "${dtbs}" dtbs - # ln -s "${initrd}/initrd" initrd - - # bash "${./make-kernel-its}" "$PWD" > $out - # ''; - - # system.build.kernel-lzma = kernel-lzma; - - # system.build.kernel-uimg = pkgs.runCommand "kernel-uimg" { - # nativeBuildInputs = with pkgs; [ - # dtc - # ubootTools - # ]; - # } '' - # ln -s "${config.system.build.kernel-lzma}" kernel.lzma - # ln -s "${dtbs}" dtbs - # ln -s "${initrd}/initrd" initrd - # ln -s "${config.system.build.kernel-its}" kernel.its - - # mkimage \ - # -D "-I dts -O dtb -p 2048" \ - # -f kernel.its \ - # $out - # ''; + system.build.u-boot = pkgs.buildUBoot { + defconfig = "snow_defconfig"; + extraMeta.platforms = [ "armv7l-linux" ]; + filesToInstall = [ + "u-boot" #< ELF file + "u-boot.bin" #< raw binary, load it into RAM and jump toit + "u-boot.cfg" #< copy of Kconfig which this u-boot was compiled with + "u-boot.dtb" + "u-boot.map" + "u-boot-nodtb.bin" + "u-boot.sym" + ]; + }; system.build.platformPartition = pkgs.runCommandLocal "kernel-partition" { nativeBuildInputs = with pkgs; [ @@ -237,85 +145,9 @@ in --pack $out ''; - # system.build.platformPartition = pkgs.runCommandLocal "kernel-partition" { - # nativeBuildInputs = with pkgs; [ - # dtc # for fdtget - # python3Packages.depthcharge-tools - # ubootTools # for mkimage - # vboot_reference # for futility - # ]; - # } '' - # cp -R "${dtbs}" dtbs - # cp ${u-boot}/u-boot . - # depthchargectl build \ - # --verbose \ - # --vboot-keyblock ${pkgs.buildPackages.vboot_reference}/share/vboot/devkeys/kernel.keyblock \ - # --vboot-private-key ${pkgs.buildPackages.vboot_reference}/share/vboot/devkeys/kernel_data_key.vbprivk \ - # --root none \ - # --ignore-initramfs \ - # --board "snow" \ - # --kernel ./u-boot \ - # --fdtdir ./dtbs \ - # --output "$out" - # ''; - - # system.build.platformPartition = pkgs.runCommandLocal "kernel-partition" { - # nativeBuildInputs = with pkgs; [ - # dtc # for fdtget - # python3Packages.depthcharge-tools - # ubootTools # for mkimage - # vboot_reference # for futility - # ]; - # # TODO: try --compress lz4 --compress lzma - # } '' - # # override default board settings (pray that the 8 MiB kpart limit isn't firmware enforced) - # echo '[boards/arm/exynos5/daisy/snow]' > boardcfg - # echo 'image-max-size = 16 MiB' >> boardcfg - - # cp "${kernel_file}" zImage - # cp "${initrd}/initrd" initrd - # cp -R "${dtbs}" dtbs - # # --config ./boardcfg - # # --no-kern-guid - - # depthchargectl build \ - # --verbose \ - # --vboot-keyblock ${pkgs.buildPackages.vboot_reference}/share/vboot/devkeys/kernel.keyblock \ - # --vboot-private-key ${pkgs.buildPackages.vboot_reference}/share/vboot/devkeys/kernel_data_key.vbprivk \ - # --root none \ - # --ignore-initramfs \ - # --board "snow" \ - # --kernel ./zImage \ - # --kernel-cmdline ${lib.escapeShellArg cmdlineText} \ - # --initramfs ./initrd \ - # --fdtdir ./dtbs \ - # --output "$out" - # ''; - - # ArchLinuxArm method: - # system.build.platformPartition = pkgs.runCommandLocal "kernel-partition" { - # nativeBuildInputs = with pkgs; [ - # vboot_reference - # ]; - # } '' - # # according to depthcharge-tools, bootloader.bin is legacy, was used by the earliest - # # chromebooks (H2C) *only*. - # dd if=/dev/zero of=bootloader.bin bs=512 count=1 - - # futility \ - # --debug \ - # vbutil_kernel \ - # --version 1 \ - # --bootloader bootloader.bin \ - # --vmlinuz ${config.system.build.kernel-uimg} \ - # --arch arm7l \ - # --keyblock ${pkgs.buildPackages.vboot_reference}/share/vboot/devkeys/kernel.keyblock \ - # --signprivate ${pkgs.buildPackages.vboot_reference}/share/vboot/devkeys/kernel_data_key.vbprivk \ - # --config ${cmdlineFile} \ - # --pack $out - # ''; - - # nixos kernels + initrd can be hilariously large, so allocate a ton of space + # the platform partition presently only holds u-boot, + # and it seems possibly a limitation of depthcharge that it can't launch anything > 8 MiB (?) + # still, give a little extra room so i'm free to rearrange stuff if i find a way how. sane.image.platformPartSize = 256 * 1024 * 1024; # depthcharge firmware is designed for an A/B partition style, diff --git a/hosts/modules/hal/samsung/make-kernel-its b/hosts/modules/hal/samsung/make-kernel-its deleted file mode 100755 index 9259fa60..00000000 --- a/hosts/modules/hal/samsung/make-kernel-its +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/sh -# source: - -toplevel=$1 - -cd $toplevel - -dtb_files=($(find -L dtbs -type f -name '*.dtb')) - -fdt_definition() { - local idx=$1 - local filename=$2 - local basename=$(basename $filename) - cat <; - entry = <0>; - }; - ramdisk-1 { - description = "ramdisk"; - data = /incbin/("initrd"); - type = "ramdisk"; - arch = "arm64"; - os = "linux"; - compression = "none"; - hash-1 { - algo = "sha1"; - }; - }; -EOF - -for index in "${!dtb_files[@]}"; do - fdt_definition $index ${dtb_files[$index]} -done - -cat <; - - images { - kernel { - description = "U-Boot mainline "; - type = "kernel_noload"; - arch = "arm"; - os = "linux"; - data = /incbin/("u-boot"); - compression = "none"; - load = <0>; - entry = <0>; - hash-2 { - algo = "sha256"; - }; - }; - - fdt-1{ - description = "u-boot.dtb"; - data = /incbin/("u-boot.dtb"); - type = "flat_dt"; - arch = "arm"; - compression = "none"; - hash-1{ - algo = "sha256"; - }; - }; - }; - - configurations { - default = "config-1"; - config-1 { - description = "Boot U-Boot"; - kernel = "kernel"; - fdt = "fdt-1"; - }; - }; -}; -