Skip to content
Snippets Groups Projects
  1. Mar 14, 2025
    • Caleb Connolly's avatar
      postmarketos-initramfs: refactor cmdline parsing · 8400fffe
      Caleb Connolly authored
      
      Currently the initramfs is littered with various code snippets which
      read /proc/cmdline. This is error prone and results in more complicated
      code especially as we want to standardise all the pmos specific cmdline
      arguments, and where some arguments have the same behaviour as
      deviceinfo variables.
      
      Let's do the parsing correctly, once, and set global variables to
      enable/disable/configure parts of the initramfs. At the same time
      introduce namespaced and standard versions of the remaining arguments
      which haven't been standardised yet.
      
      Now (for example) to check if the splash is disabled, rather than
      grepping /proc/cmdline for PMOS_NOSPLASH AND checking if
      deviceinfo_no_framebuffer is true, you can just check if "$nosplash" =
      "y".
      
      This will drastically simplify the process of adding additional
      configuration options in the future.
      
      Most of the code here was taken from the Arch Linux initramfs and
      simplified/adjusted to better fix our use case.
      
      Signed-off-by: default avatarCaleb Connolly <caleb@postmarketos.org>
      Part-of: !6172
      Unverified
      8400fffe
  2. Dec 05, 2024
    • Minecrell's avatar
      main/postmarketos-initramfs: start mdev/udev before setting up USB (MR 5852) · 85e0c1f0
      Minecrell authored and Oliver Smith's avatar Oliver Smith committed
      There might be additional kernel modules needed for the USB UDC to show up.
      This used to work fine, but broke when the initramfs was unified with the
      minimal one. We need to load modules/start udev before setting up USB.
      
      Fix this by duplicating the setup calls in both init.sh and init_2nd.sh.
      Both calls already have checks to allow calling them multiple times,
      so we don't need to handle the initramfs-extra case in a special way.
      [ci:skip-build]: already built successfully in CI
      Unverified
      85e0c1f0
  3. Nov 01, 2024
  4. Oct 31, 2024
  5. Jul 24, 2024
  6. Jun 27, 2024
  7. Jun 18, 2024
    • Caleb Connolly's avatar
      postmarketos-initramfs: switch to udev and kmod (MR 5000) · 7c981277
      Caleb Connolly authored and Clayton Craft's avatar Clayton Craft committed
      
      mdev is slow and missing features, it also requires that we load all the
      modules that we include at once making the boot process slower.
      
      udev is required for unl0kr (and buffyboard), it can also load modules
      on demand (and asynchronously). Making the boot process considerably
      faster on devices, especially for generic images where we have lots of
      drivers for different display panels in the initramfs.
      
      Additionally, import full fat modprobe from the kmod package, this is
      required to support compressed modules.
      
      This brings us more in line with other distros and generally improves
      compatibility.
      
      If devices use broken kernel modules which don't correctly define
      modalias', these drivers may not be loaded by udev. This should be fixed
      by defining the missing modalias statements in the driver.
      
      This also runs udev earlier in the init, so that display drivers are
      loaded before the splash in case they are needed.
      
      Signed-off-by: default avatarCaleb Connolly <caleb@postmarketos.org>
      Co-authored-by: default avatarClayton Craft <clayton@craftyguy.net>
      
      [ci:ignore-count]
      [ci:skip-build]: already built successfully in CI
      Verified
      7c981277
    • Caleb Connolly's avatar
      postmarketos-initramfs: debug-shell 3.0 (MR 5000) · dd28314b
      Caleb Connolly authored and Clayton Craft's avatar Clayton Craft committed
      
      This incorprates the debug-shell functionality directly into the
      initramfs, so it's no longer necessary to build and boot a custom
      initramfs in order to debug your device.
      
      Additionally, the behaviour of the debug-shell is entirely reworked, It
      now creates an ACM serial gadget which can be accessed via any normal
      terminal emulator (picocom, minicom, etc; or PuTTY on windows). Rather
      than just invoking sh, the debug-shell now creates a respawning getty on
      both the new virtual console and the active console (this will either be
      the UART console or tty0/1).
      
      It is necessary to spawn these shells via getty since the logging rework
      means we can no longer assume that stdin/out/err reference a TTY.
      
      In addition to the above, it is now possible to trigger a log dump by
      holding volume up during boot. This can be useful for helping users
      debug their devices if the issue doesn't result in a failure that can be
      detected in the initramfs.
      
      With these changes, the console-shell and debug-shell hook packages are
      reduced to only adding the additional tools/features. console-shell is
      still required for fbkeyboard, and debug-shell for the setup_usb_storage
      tool.
      
      Co-Developed-by: default avatarClayton Craft <craftyguy@postmarketos.org>
      Signed-off-by: default avatarCaleb Connolly <caleb@postmarketos.org>
      Verified
      dd28314b
    • Caleb Connolly's avatar
      postmarketos-initramfs: mount subpartitions after hooks (MR 5000) · 118a3093
      Caleb Connolly authored and Clayton Craft's avatar Clayton Craft committed
      
      This step is the most likely to go wrong or have issues, and it has side
      effects which can make it difficult to run multiple times on one boot.
      Move it to after hooks so that e.g. when dropping to a debug shell, we
      land before the first call.
      
      This also makes booting to hooks a faster in many cases.
      
      Signed-off-by: default avatarCaleb Connolly <caleb@postmarketos.org>
      Verified
      118a3093
    • Caleb Connolly's avatar
      postmarketos-initramfs: log to kernel ringbuffer (MR 5000) · 95b22138
      Caleb Connolly authored and Clayton Craft's avatar Clayton Craft committed
      
      Rework logging to always log the initramfs output to the kernel
      ringbuffer and deprecate PMOS_NO_OUTPUT_REDIRECT in favour of following
      the kernel loglevel.
      
      I know it seems silly to use syslogd for this, but it's necessary to
      buffer writes to /dev/kmsg per-line if we want to correctly set the log
      level, and "tee" does not do this (it will write multiple lines at once,
      resulting in "<14>" prints in the ringbuffer). The main advantage to
      this is that we won't have kernel logs cut in half by initramfs logs
      anymore, everything will be nicely line buffered!
      
      The previous logging solution of multiple "tail" commands would actually
      fail to log up to the last few lines before a crash due to how tail
      works (it polls the file and buffers lines).
      
      I attempted something like this before, but I stopped after running into
      ratelimiting issues. These are now resolved by configuring the
      printk_devkmsg sysctl.
      
      Dropping PMOS_NO_OUTPUT_REDIRECT:
      
      The general motivations behind PMOS_NO_OUTPUT_REDIRECT was to avoid
      cluttering up the console with initramfs logs when they aren't wanted;
      this is now handled instead by the kernels logging facility. We log to
      the ringbuffer at LOGLEVEL_INFO, so if "quiet" is specified on the
      cmdline (or the loglevel is otherwise set above info) then initramfs
      logs will also not be shown.
      
      Signed-off-by: default avatarCaleb Connolly <caleb@postmarketos.org>
      Verified
      95b22138
  8. Jun 04, 2024
  9. May 16, 2024
  10. Feb 06, 2024
  11. Jan 05, 2024
    • Caleb Connolly's avatar
      postmarketos-initramfs: export logs on boot failure (MR 4646) · 57744b98
      Caleb Connolly authored
      
      Currently, when postmarketOS fails to boot up, retrieving any
      information necessary to root cause the issue is non-trivial, requiring
      building a custom initramfs with debug-shell enabled and then manually
      copying out data.
      
      Let's improve the situation by exporting logs automatically on boot
      failure. This is safer than just exposing a root shell but still
      provides a whole lot of useful info that should make duplicating and
      triaging issues much easier for developers.
      
      This commit implements the functionality and includes some generally
      useful data. We then generate a README and expose files for each command/log
      as well as an archive that can be easily attached to a GitLab issue.
      
      To help with triaging, also record the version of the postmarketos-initramfs
      package and hash the init.sh and init_functions.sh files.
      
      For testing purposes, you can trigger the log recovery mode on-time by
      creating an empty file named ".pmos_export_logs" in the /boot partition.
      
      Signed-off-by: default avatarCaleb Connolly <caleb@connolly.tech>
      Unverified
      57744b98
  12. Nov 21, 2023
  13. Nov 02, 2023
    • Clayton Craft's avatar
      main/postmarketos-initramfs: show OS version on splash screen (MR 4470) · c9c4b492
      Clayton Craft authored and Oliver Smith's avatar Oliver Smith committed
      This shows the OS version (from /etc/os-release), e.g. "edge", on the splash
      screen. os-release is a tiny text file, adding it to the initramfs doesn't seem
      too bad, and having this information on the splash screen can be helpful.
      
      Note that this uses "VERSION" and not "PRETTY_NAME" from the os-release file,
      since the splash already shows "postmarketOS" (and the pretty name includes
      that too), it seemed redundant and took up valuable display space.
      
      [ci:skip-build]: already built successfully in CI
      Unverified
      c9c4b492
  14. Oct 31, 2023
  15. Sep 07, 2023
    • Caleb Connolly's avatar
      main/postmarketos-initramfs: get to splash faster (MR 4204) · 9fb29079
      Caleb Connolly authored
      
      With full-fat mdev supporting by-partlabel lookups, there is a small
      delay during startup. As mdev and dynamic partitions aren't actually
      needed for the framebuffer device, move show_splash earlier.
      
      Furthermore, slightly rework setup_framebuffer to not dump the verbose
      message about waiting for the framebuffer unless the framebuffer isn't
      found.
      
      Signed-off-by: default avatarCaleb Connolly <caleb@connolly.tech>
      Unverified
      9fb29079
    • Caleb Connolly's avatar
      main/postmarketos-initramfs: use mdev properly (MR 4204) · e0fcfb74
      Caleb Connolly authored
      Drop in mdev.conf and the /lib/mdev/persistent-storage script, these
      cause /dev/disk/by-* to be populated in the ramdisk, making it
      possible to do look up partition by-label and by-partlabel for free,
      compared to findfs which can take some time.
      
      As a first optimisation based on this, check for some partitions using
      these paths and prioritise them when looking for subpartitions. Drop the
      first find_boot_partition call as it doesn't really save time over the
      call in the while loop.
      
      The mdev config also handles setting up /dev/null, /dev/random, etc, so
      these don't have to be done manually.
      Unverified
      e0fcfb74
    • Luca Weiss's avatar
      main/postmarketos-initramfs: switch_root with /dev (MR 3230) (MR 4204) · 5f820dee
      Luca Weiss authored and Caleb Connolly's avatar Caleb Connolly committed
      Mount /dev (and /run) in initramfs so util-linux switch_root can move
      the mounts over to the new sysroot before changing root.
      BusyBox switch_root doesn't even attempt to move anything so use
      util-linux's switch_root for this.
      
      Explicitly disable tests too...
      Unverified
      5f820dee
  16. Aug 23, 2023
  17. Aug 04, 2023
  18. Jul 10, 2023
    • Pablo Correa Gomez's avatar
      main/postmarketos-initramfs: load modules also from /lib/modules/initramfs.load (MR 4193) · 38ce112c
      Pablo Correa Gomez authored and Clayton Craft's avatar Clayton Craft committed
      Make it possible to load modules from the file installed by devicepkg-dev,
      that will be there when extra modules are needed. This is coded in a
      backwards-compatible way, so that it can be independent of the main modules
      MR.
      
      The code changes create a new function which takes a list of modules
      and possibly a file (that should contain a list of modules too). The
      idea is to be able to support also loading modules for initramfs-extra
      in the future, and having a similar file would be more convenient than
      extracting all the modules each time. In addition, the "[ -d /lib/modules]"
      check has been removed. If there's no modules directory, as all
      modules might be built-in, modprobe will fail, but that will not be
      fatal. This will most likely only exclusively happen in some android
      downstream kernel, so it should not be a big concern.
      Verified
      38ce112c
  19. Jun 03, 2023
  20. Apr 26, 2023
  21. Mar 09, 2023
    • Clayton Craft's avatar
      main/postmarketos-initramfs: new aport (MR 3895) · 536264ba
      Clayton Craft authored
      This package contains base file and module lists for the initramfs /
      initramfs-extra archives, along with the init.sh
      
      The primary reason for doing this is so that changes to these
      files/lists can be properly versioned (in pkgver), and (re)building
      mkinitfs itself is no longer required for these changes.
      
      - Add base file list for initramfs. The dirs at path
        /usr/share/postmarketos-mkinitfs/* are "new" in mkinitfs 2.0
      
      - Install default modules to /usr/share
      
      - Install system config to /usr/share/mkinifs
      
      - Add base files for -extra archive
      
      - Create user config dirs
      
      - Update hook dirs in init.sh, change from mkinitfs 2.0
      
      - Remove splash images, obsolete since pbsplash
      
      - Support uncompressed initramfs-extra
      Unverified
      536264ba
  22. Feb 19, 2023
  23. Feb 18, 2023
    • Caleb Connolly's avatar
      main/postmarketos-mkinitfs: switch to pbsplash (MR 2878) · e97b61b0
      Caleb Connolly authored
      This modifies to the postmarketOS ramdisk init to use the new pbsplash
      tool for displaying splash messages, replacing the old fbsplash.
      
      This also moves the show_splash call to run as soon as possible rather
      than waiting for mount_subpartitions to run (which can take a while).
      e97b61b0
  24. Jan 23, 2023
  25. Jan 08, 2023
  26. Jun 06, 2022
  27. May 29, 2022
  28. May 12, 2022
  29. Jan 05, 2022
    • Clayton Craft's avatar
      main/postmarketos-mkinitfs: replace udhcpd with unudhcpd (MR 2698) · d1a6daca
      Clayton Craft authored
      unudhcpd is a lightweight dhcp server that effectively implements static
      assignment of a single IP on an interface regardless of client MAC, with
      no lease. The end result is that a system connected to a pmOS device via
      usb networking should always get an IP, and always get one very quickly.
      
      This adds a new dependency on this dhcp server, and starts it in initfs.
      
      Fixes #1199
      
      [ci:skip-build] already built successfully in CI
      Verified
      d1a6daca
  30. Sep 03, 2021
  31. Aug 16, 2021
Loading