From 35c98d44a865ff4aef8e6d121baac655616cf703 Mon Sep 17 00:00:00 2001 From: Stephan Gerhold Date: Mon, 25 Nov 2024 20:29:31 +0100 Subject: [PATCH] main/postmarketos-initramfs: add cmdline to expose specific USB storage (MR 5912) In addition to the pmos.debug-shell cmdline argument, add pmos.usb-storage= to set up the USB mass storage gadget by default when going into debug shell. This allows building a special boot image/option that directly exposes the storage for flashing, without having to type in extra debug-shell commands. --- main/postmarketos-initramfs/APKBUILD | 4 ++-- main/postmarketos-initramfs/init_functions.sh | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/main/postmarketos-initramfs/APKBUILD b/main/postmarketos-initramfs/APKBUILD index 5fdc687bb..7ce019510 100644 --- a/main/postmarketos-initramfs/APKBUILD +++ b/main/postmarketos-initramfs/APKBUILD @@ -1,7 +1,7 @@ # Maintainer: Caleb Connolly # Co-Maintainer: Clayton Craft pkgname=postmarketos-initramfs -pkgver=3.5.0 +pkgver=3.6.0 pkgrel=0 pkgdesc="Base files for the postmarketOS initramfs / initramfs-extra" url="https://postmarketos.org" @@ -109,7 +109,7 @@ sha512sums=" c0233d22858a5901db64e1d2fe1f6d39a2e2cfd1b94a10932483f55fed9461e9b8aa2d73b154b9d99a7a8b49ee02abfbddfe917ce0c6d7576601ba2668589c01 00-initramfs-base.files d0f35562365756d93066ce45924d17fb347b54095179c3262daa2f073e12743505cd5d9372ad30485915ca754d95a8edba9a74314e7949e0b3cf6978a87d03a5 00-initramfs-extra-base.files c497ace6f3d183c48722b9e4fd2b6fed21338d68a9e729c1423d3c3de3eaae7366d8dd75a11f78b7072a6795dcc5380c10d8b390738372ede6dc78074ae87a76 init.sh -cf53e30e6b221adc9e76ac9ebe1f86cf08b865fc999195ccef2f0565d5383553b9415fc274bc82f13721da896fa0a448074c3734e6c54146f637236477da4c3a init_functions.sh +6f2f4245b0cbda4ee5c0966e07ffa7ad6bd4432e382bc41c4c91d463ab325226f6a7be99ff1f83d3c0c46259b189886bd27b902c87cb90f0c55b4dc61960d3d6 init_functions.sh 74681044d10e0e1d5fee94451ee7fa67a1a0b093ae0e54860ed12e2bb98db98b01f0633663d06081753f210dd946752c3d291062faaf410a88501eb5ba12d904 init_2nd.sh 5ed5d96c45db0b32b6ff5f5e63b2821e442baf57c3ba587555e2cd92986c65aa13bc73ae591a8b35845e5d30384daf13b76e83961bd7cfe674a81320b34748d9 init_functions_2nd.sh 675e7d5bee39b2df7d322117f8dcaccc274d61beaf4d50ead19bbf2109446d64b1c0aa0c5b4f9846eb6c1c403418f28f6364eff4537ba41120fbfcbc484b7da7 mdev.conf diff --git a/main/postmarketos-initramfs/init_functions.sh b/main/postmarketos-initramfs/init_functions.sh index 4d1648ca5..da0070e66 100644 --- a/main/postmarketos-initramfs/init_functions.sh +++ b/main/postmarketos-initramfs/init_functions.sh @@ -890,6 +890,13 @@ debug_shell() { Read the initramfs log with 'cat /pmOS_init.log'. EOF + # Expose storage specified on cmdline on USB + local storage_dev="" + # shellcheck disable=SC2013 + for x in $(cat /proc/cmdline); do + [ "$x" = "${x#pmos.usb-storage=}" ] || storage_dev="${x#pmos.usb-storage=}" + done + # Add pmos_logdump message only if relevant if [ -n "$have_udc" ]; then echo "Run 'pmos_logdump' to generate a log dump and expose it over USB." >> /README @@ -898,6 +905,10 @@ debug_shell() { You can expose storage devices over USB with 'setup_usb_storage_configfs /dev/DEVICE' EOF + + if [ -n "$storage_dev" ]; then + echo "pmos.usb-storage=$storage_dev is exposed over USB by default" >> /README + fi fi # Display some info @@ -983,6 +994,9 @@ debug_shell() { # supported on some old kernels so this exists as a fallback. telnetd -b "${HOST_IP}:23" -l /sbin/pmos_getty & + # Set up USB mass storage if pmos.usb-storage= was specified on cmdline + [ -z "$storage_dev" ] || setup_usb_storage_configfs "$storage_dev" + # wait until we get the signal to continue boot while ! [ -e /tmp/continue_boot ]; do sleep 0.2