Use grub instead of flash-kernel on pinephone-pro. This should also make this image...
authorDaniel Abrecht <public@danielabrecht.ch>
Thu, 26 May 2022 20:17:17 +0000 (20:17 +0000)
committerDaniel Abrecht <public@danielabrecht.ch>
Thu, 26 May 2022 20:17:23 +0000 (20:17 +0000)
17 files changed:
config/default/b-librem5-devkit/install_early
config/default/b-librem5-phone/install_early
config/default/b-pinephone-pro/config
config/default/b-pinephone-pro/install_early
config/default/b-pinephone-pro/post_early_install
config/default/b-pinephone-pro/post_target_install [new file with mode: 0755]
config/default/b-pinephone-pro/rootfs/boot/efi/EFI/boot/grub.cfg [new file with mode: 0644]
config/default/b-pinephone-pro/rootfs/etc/default/grub [new file with mode: 0644]
config/default/b-pinephone-pro/rootfs/etc/fstab [new file with mode: 0644]
config/default/b-pinephone-pro/rootfs/etc/kernel/postinst.d/install-dtbs [new file with mode: 0755]
config/default/b-raspberry-pi-3-b+/install_early
config/default/config
config/default/install_debootstrap
config/default/install_early
config/default/rootfs/etc/fstab
platform/pinephone-pro/part.sfdisk
script/assemble_image.sh

index b2f3d9d485c310149de4102629f49bc94b808ee0..6365b3805b27098104bf6124c1225cc854e93d8a 100644 (file)
@@ -1 +1,5 @@
+# Needed for booting, creates uboot scripts and so on
+flash-kernel
+
+# TODO: Is the following still needed? Is the new mesa nir default already in debian?
 libenvpreload
index 8cc1c8f2dc4a2c6a42529090144fd75210a5a86b..0d67ec07a353f24497d2dd68c5b503de0a4ad62e 100644 (file)
@@ -1,3 +1,7 @@
+# Needed for booting, creates uboot scripts and so on
+flash-kernel
+
+# TODO: Is the following still needed? Is the new mesa nir default already in debian?
 libenvpreload
 
 # For forwarding modem audio
index 93a9e10580f0804d5982b22fe3800b9426f0254c..6e85969843c5ce1acdc27310db6564bb754c6e6b 100644 (file)
@@ -2,8 +2,13 @@ BUILDER_PLATFORM = pinephone-pro
 KERNEL_CONFIG_TARGET = pinephonepro
 FK_MACHINE = Pine64 PinePhonePro
 
+BOOT_FSTYPE = vfat
+BOOT_DIR = boot/efi
+
 S_COMPONENTS += contrib non-free
 
+PATCH_DEV_FILES += boot/efi/EFI/boot/grub.cfg
+
 repo-branch@linux = pine64-kernel-ppp-5.16.y-release
 repo-source@linux = https://gitlab.com/pine64-org/linux.git
 
index af0e3a3666821b581c7e9641b6bd43de507f1e4a..97e2a0077dfd5a2e7bbae7cbffc0d4c90dacc1aa 100644 (file)
@@ -1,3 +1,4 @@
 firmware-misc-nonfree
 firmware-brcm80211
 eg25-manager
+grub-efi
index cbcd1913d157a7c7329ed99b2036df88e52ab7d8..33807bbd4ea43a7251f94031f7b2a2654ce4b06e 100755 (executable)
@@ -6,6 +6,7 @@ trap cleanup EXIT TERM INT
 
 cd "$tmp"
 
+# TODO: Does any of the /lib/firmware/brcm/brcmfmac43455-sdio.* files from firmware-brcm80211 / linux-firmware, which is installed, work?
 if apt-get download raspi-firmware
 then
   dpkg-deb -xv raspi-firmware*.deb .
@@ -15,3 +16,15 @@ else
   dpkg-deb -xv linux-firmware-raspi*.deb .
   cp ./lib/firmware/brcm/brcmfmac43455-sdio.raspberrypi,400.txt /lib/firmware/brcm/brcmfmac43455-sdio.pine64,pinephone-pro.txt
 fi
+
+# Create an initial grub config. It's not possible to get grub-install
+# working properly in the chroot, but grub-mkimage will work for the first boot,
+# we can do grub-instal and grub-update un the first boot after that.
+MODULES='
+  all_video boot cat configfile disk echo efi_gop ext2 fat fdt gzio help iso9660
+  linux ls normal part_gpt part_msdos reboot search search_fs_file search_fs_uuid
+  search_label test true probe
+'
+
+mkdir -p /boot/efi/EFI/boot/
+grub-mkimage -p /EFI/boot/ -O arm64-efi -o /boot/efi/EFI/boot/bootaa64.efi $MODULES
diff --git a/config/default/b-pinephone-pro/post_target_install b/config/default/b-pinephone-pro/post_target_install
new file mode 100755 (executable)
index 0000000..44b6b72
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+set +e
+
+# Properly install grub. Can't be done when bootstrapping.
+
+# Apparently, the modules needed for fat32 aren't in the initramfs
+modprobe fat
+modprobe vfat
+modprobe msdos
+modprobe nls_cp437
+modprobe nls_ascii
+
+# grub will be reinstalled here
+mount /boot/efi
+mount -o remount,rw /boot/efi
+
+# The following will fail, but maybe someone fixes EFI Varaiables un uboot some day?
+grub-install
+# EFI Varaiables aren't supported yet, skip just that step. That should work.
+grub-install --no-nvram
+# Without EFI variables, we need the fallback. It doesn't work without the above though. Probably a bug?
+grub-install --removable
+# Let's make sure the config and so one is present, too
+update-grub
+
+# Unmount it again, the system will mount it later, but may want to do an fsck first.
+umount /boot/efi
diff --git a/config/default/b-pinephone-pro/rootfs/boot/efi/EFI/boot/grub.cfg b/config/default/b-pinephone-pro/rootfs/boot/efi/EFI/boot/grub.cfg
new file mode 100644 (file)
index 0000000..959fb86
--- /dev/null
@@ -0,0 +1,10 @@
+# Apparently, this grubs probe command doesn't support --part-uuid
+#if [ x{PARTUUID_root} != x ]
+#  then probe --set=root --part-uuid {PARTUUID_root}
+#  else
+search --no-floppy --fs-uuid --set=root {UUID_root}
+#fi
+
+linux /boot/vmlinuz-5.16.7-00003-gd31aea033841 root={FSTAB_root} console=tty1 ro
+initrd /boot/initrd.img-5.16.7-00003-gd31aea033841
+boot
diff --git a/config/default/b-pinephone-pro/rootfs/etc/default/grub b/config/default/b-pinephone-pro/rootfs/etc/default/grub
new file mode 100644 (file)
index 0000000..29174a7
--- /dev/null
@@ -0,0 +1,32 @@
+# If you change this file, run 'update-grub' afterwards to update
+# /boot/grub/grub.cfg.
+# For full documentation of the options in this file, see:
+#   info -f grub -n 'Simple configuration'
+
+GRUB_DEFAULT=0
+GRUB_TIMEOUT=5
+GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
+GRUB_CMDLINE_LINUX_DEFAULT=""
+GRUB_CMDLINE_LINUX="console=tty1 ro"
+
+# Uncomment to enable BadRAM filtering, modify to suit your needs
+# This works with Linux (no patch required) and with any kernel that obtains
+# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
+#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
+
+# Uncomment to disable graphical terminal (grub-pc only)
+GRUB_TERMINAL=console
+
+# The resolution used on graphical terminal
+# note that you can use only modes which your graphic card supports via VBE
+# you can see them in real GRUB with the command `vbeinfo'
+#GRUB_GFXMODE=640x480
+
+# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
+#GRUB_DISABLE_LINUX_UUID=true
+
+# Uncomment to disable generation of recovery mode menu entries
+#GRUB_DISABLE_RECOVERY="true"
+
+# Uncomment to get a beep at grub start
+#GRUB_INIT_TUNE="480 440 1"
diff --git a/config/default/b-pinephone-pro/rootfs/etc/fstab b/config/default/b-pinephone-pro/rootfs/etc/fstab
new file mode 100644 (file)
index 0000000..6830ae4
--- /dev/null
@@ -0,0 +1,6 @@
+# <file system>                <mount point>   <type>  <options>                               <dump>  <pass>
+
+proc                   /proc           proc    nosuid,noexec,nodev,hidepid=2           0       0
+{FSTAB_root}           /               auto    defaults,discard,relatime               0       1
+{FSTAB_boot}           /boot/efi       vfat    defaults,ro,relatime                    0       1
+tmpfs                  /tmp            tmpfs   defaults,noexec,nosuid,nodev            0       0
diff --git a/config/default/b-pinephone-pro/rootfs/etc/kernel/postinst.d/install-dtbs b/config/default/b-pinephone-pro/rootfs/etc/kernel/postinst.d/install-dtbs
new file mode 100755 (executable)
index 0000000..b544b2a
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+set -ex
+
+libdir="/usr/lib/$DPKG_MAINTSCRIPT_PACKAGE/"
+[ -d "$libdir" ] || exit 0
+
+cd "$libdir"
+mkdir -p /boot/efi/dtb/
+find -iname '*.dtb' -exec cp --parents {} /boot/efi/dtb/ \;
index f74bf6abc6429e9f7b82843379da9fff0f0434ae..05a2bb3ff941b2f3074b46195a15e1162f9647f0 100644 (file)
@@ -1,2 +1,4 @@
+# Needed for booting, creates uboot scripts and so on
+flash-kernel
 linux-image-arm64
 raspi-firmware
index 74870d15c57cb36e28d7220e04713c0d3ab9f81d..9eb6886dcbb1beda6a3f8b73e16d3c6b14b549a9 100644 (file)
@@ -8,6 +8,7 @@ S_COMPONENTS=main
 FSTYPE = ext4
 
 USE_EFI = y
+PATCH_DEV_FILES = etc/fstab
 
 BUILD_PACKAGES = no
 USE_IMAGE_BUILDER_REPO = yes
index e95f1b72c29afe90313babdb5e682d56959653b1..fd6b2faa2db5cfaac61507433c54c9366fad102c 100644 (file)
@@ -1,10 +1,8 @@
 # Needed to install the kernel & bootloader
 u-boot-tools
-# flash-kernel # Uncomment once librem 5 support is in the official repos
 
 # Required by rootfs_setup.sh and first_boot_setup.sh
 dpkg-dev
 initramfs-tools
 
-# Needed by current flash-kernel version, remove once everything is mainline
 file
index 5e7b1c63c3097cb1c122058aa524f95408c8fec4..fd7bc4378ca45302c503d655ae5c0b214021a190 100644 (file)
@@ -1,6 +1,3 @@
-# Needed for booting, creates uboot scripts and so on
-flash-kernel
-
 locales # Has to be installed before console keyboard, because it needs locale C.UTF-8
 
 # Do make the text readable
index f2d7cd52ae62b7078b25fb4dbca5f6d98f682ce9..f9f93800225ffae68ca59e931127436595d7ec21 100644 (file)
@@ -1,6 +1,6 @@
 # <file system>                <mount point>   <type>  <options>                               <dump>  <pass>
 
 proc                   /proc           proc    nosuid,noexec,nodev,hidepid=2           0       0
-{UUID_root}            /               auto    defaults,discard,relatime               0       1
-{UUID_boot}            /boot           ext2    defaults,ro,relatime                    0       1
+{FSTAB_root}           /               auto    defaults,discard,relatime               0       1
+{FSTAB_boot}           /boot           ext2    defaults,ro,relatime                    0       1
 tmpfs                  /tmp            tmpfs   defaults,noexec,nosuid,nodev            0       0
index 79a3201d09481945d829b3748173cf4ed34ff488..e4f3d10863b86fcc3b08450fccea39605aeb39cc 100644 (file)
@@ -5,7 +5,7 @@ grain: 4MiB
 
 # Protective partition for firmware (The type / guid here was chowsen randomly)
 start=64, size=31MiB, type=59EB2C4A-6F39-4E7E-8A7A-2C32F189FA8F, name=loader, attrs="RequiredPartition,62,63"
-# /boot/ partition
-size=224MiB, type=BC13C2FF-59E6-4262-A352-B275FD6F7172, name=boot, attrs=LegacyBIOSBootable
+# /boot/efi partition
+size=224MiB, type=C12A7328-F81F-11d2-BA4B-00A0C93EC93B, name=boot
 # / partition, use remaining space
 type=B921B045-1DF0-41C3-AF44-4C6F280D3FAE, name=root
index 8712088174c0aa0b1c64b3975052d66b286f20ba..2f3a71c6277cf2d7694fabaf82d7ef3c7b2bfc1b 100755 (executable)
@@ -125,13 +125,18 @@ imgdir="$tmp" OLDPATH="$PATH" CHNS_EXTRA='(
     . "$part_info"
     eval "$(blkid -p "$part" | sed "s/^[^:]*: //")"
     FSTAB_ID=
+    if [ -n "$UUID" ]
+    then
+      FSTAB_ID="UUID=$UUID"
+      sed -i "s/{UUID_$part_name}/$UUID/" $PATCH_DEV_FILES
+    fi
     if [ -n "$PARTUUID" ]
-      then FSTAB_ID="PARTUUID=$PARTUUID"
-    elif [ -n "$UUID" ]
-      then FSTAB_ID="UUID=$UUID"
+    then
+      FSTAB_ID="PARTUUID=$PARTUUID"
+      sed -i "s/{PARTUUID_$part_name}/$PARTUUID/" $PATCH_DEV_FILES
     fi
     if [ -n "$FSTAB_ID" ]
-      then sed -i "s/{UUID_$part_name}/$FSTAB_ID/" etc/fstab
+      then sed -i "s/{FSTAB_$part_name}/$FSTAB_ID/" $PATCH_DEV_FILES
     fi
   ); done
 )' CHNS_OVERLAY=1 CHNS_EXTRA_POST='(