From f645005b45d9ba09ae39cbbab93c7104474a2fde Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 1 Sep 2025 22:25:48 +0000 Subject: [PATCH] pinephone-pro: ship a binary helper to install (or update) u-boot on an existing (or new) device moby is now updated to u-boot 2025.07 --- hosts/common/programs/default.nix | 1 + .../programs/u-boot-pinephone-pro/default.nix | 21 ++++++++++++++++ .../u-boot-pinephone-pro/install-u-boot | 25 +++++++++++++++++++ .../hal/pine64-pinephone-pro/default.nix | 4 +++ 4 files changed, 51 insertions(+) create mode 100644 hosts/common/programs/u-boot-pinephone-pro/default.nix create mode 100644 hosts/common/programs/u-boot-pinephone-pro/install-u-boot diff --git a/hosts/common/programs/default.nix b/hosts/common/programs/default.nix index dfc8ce955..1e7d90179 100644 --- a/hosts/common/programs/default.nix +++ b/hosts/common/programs/default.nix @@ -216,6 +216,7 @@ ./tcpdump.nix ./tor-browser.nix ./tuba.nix + ./u-boot-pinephone-pro ./unl0kr ./uptime.nix ./v4l-utils.nix diff --git a/hosts/common/programs/u-boot-pinephone-pro/default.nix b/hosts/common/programs/u-boot-pinephone-pro/default.nix new file mode 100644 index 000000000..6f5bdcde5 --- /dev/null +++ b/hosts/common/programs/u-boot-pinephone-pro/default.nix @@ -0,0 +1,21 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.sane.programs.u-boot-pinephone-pro; +in +{ + sane.programs.u-boot-pinephone-pro = { + packageUnwrapped = pkgs.runCommandNoCC "u-boot-pinephone-pro-program" { + preferLocalBuild = true; + } '' + install -Dm644 ${pkgs.u-boot-pinephone-pro}/idbloader.img $out/share/boot/idbloader.img + install -Dm644 ${pkgs.u-boot-pinephone-pro}/u-boot.itb $out/share/boot/u-boot.itb + install -Dm755 ${./install-u-boot} $out/bin/install-u-boot + # ln -sv $out/bin/install-u-boot $out/share/boot/install-u-boot + ''; + sandbox.autodetectCliPaths = "existingFile"; + }; + + environment.pathsToLink = lib.mkIf cfg.enabled [ + "/share/boot" + ]; +} diff --git a/hosts/common/programs/u-boot-pinephone-pro/install-u-boot b/hosts/common/programs/u-boot-pinephone-pro/install-u-boot new file mode 100644 index 000000000..e8ed7a06e --- /dev/null +++ b/hosts/common/programs/u-boot-pinephone-pro/install-u-boot @@ -0,0 +1,25 @@ +#!/bin/sh + +set -eu + +drive=$1 + +if ! [[ -e "$drive" ]]; then + echo "usage: install-u-boot /dev/sdX" + exit 1 +fi + +bootfiles_dir= +for d in ${XDG_DATA_DIRS//:/ }; do + if [[ -e "$d/boot/idbloader.img" ]] && [[ -e "$d/boot/u-boot.itb" ]]; then + bootfiles_dir=$d/boot + fi +done +if [[ -z "$bootfiles_dir" ]]; then + echo "boot/{idbloader.img,u-boot.itb} not found on XDG_DATA_DIRS" + exit 1 +fi + +set -x +dd if="$bootfiles_dir/idbloader.img" of="$drive" bs=512 seek=64 conv=notrunc,sync oflag=direct status=progress +dd if="$bootfiles_dir/u-boot.itb" of="$drive" bs=512 seek=16384 conv=notrunc,sync oflag=direct status=progress diff --git a/hosts/modules/hal/pine64-pinephone-pro/default.nix b/hosts/modules/hal/pine64-pinephone-pro/default.nix index f2682d754..c9142ace8 100644 --- a/hosts/modules/hal/pine64-pinephone-pro/default.nix +++ b/hosts/modules/hal/pine64-pinephone-pro/default.nix @@ -61,6 +61,10 @@ in dd if=${pkgs.u-boot-pinephone-pro}/u-boot.itb of=$out bs=512 seek=16384 conv=notrunc ''; + sane.programs.sysadminUtils.suggestedPrograms = [ + "u-boot-pinephone-pro" + ]; + sane.programs.alsa-ucm-conf.suggestedPrograms = [ "pine64-alsa-ucm" # upstreaming: https://github.com/alsa-project/alsa-ucm-conf/pull/375 ];