- Mar 14, 2025
-
-
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:
Caleb Connolly <caleb@postmarketos.org> Part-of: !6172
-
- Dec 05, 2024
-
-
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
-
- Nov 01, 2024
-
-
Clayton Craft authored
Fixes a bug where the kernel thinks the boot partition is still mounted and it's unavailable for mounting in the rootfs If you look at what the initramfs was doing before !5635, it was explicitly umounting the boot partition from /boot in the initramfs and then mounting it under /boot in the rootfs: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/blob/c45d7ec0a5f7ac814b50087402bb11825120f42b/main/postmarketos-initramfs/init.sh#L87 With this patch, we're now back to umounting /boot in the initramfs. The second part of that original logic is now handled elsewhere now, and that seems to be working OK. The bug was reported here: postmarketOS/pmaports#3279 (comment 454346) [ci:skip-build]: already built successfully in CI
-
- Oct 31, 2024
-
-
make the logging nicer and remove some irrelevant errors. Signed-off-by:
Caleb Connolly <caleb@postmarketos.org> Co-authored-by:
Clayton Craft <clayton@craftyguy.net>
-
We previously forked the initramfs into a minimal variant for highly space constrained devices, to allow the normal variant to gain additional functionality like the debug-shell (With OSK). Initially the hope was that only a handful of devices would need the minimal variant, but in practise this has not been the case. Trying to maintain two diverging forks of the initramfs is absoutely unsustainable and (to be frank) a bit silly. Based on discussion with craftyguy and newbyte, let's re-architect the initramfs to run in two stages, with the second stage being part of initramfs-extra. By itself this doesn't make a lot of sense, since requiring the boot partition be mounted for the debug-shell to be useful is a major downgrade. However this can be used in tandem with pending support for a new deviceinfo_create_initfs_extra variable, this is default false in mkinitfs which finally gets rid of initramfs-extra entirely for devices that don't need it. Signed-off-by:
Caleb Connolly <caleb@postmarketos.org> Co-authored-by:
Clayton Craft <clayton@craftyguy.net>
-
This was only added recently, is likely not used by anyone, and introduces hard to resolve dependencies on /boot being mounted which we may not want in the future. Remove it to drop some complexity. Signed-off-by:
Caleb Connolly <caleb@postmarketos.org>
-
- Jul 24, 2024
-
-
This won't be loaded automatically, so let's modprobe it. Additionally, make myself maintainer to reflect CODEOWNERS Signed-off-by:
Caleb Connolly <caleb@postmarketos.org> [ci:skip-build] already built successfully in CI
-
- Jun 27, 2024
-
-
Rework the messages and avoid re-spawning the splash on every check. Additionally, add a call to check_keys, this lets users drop to a debug shell or export logs to triage this failure (particularly useful for hard-to-reproduce issues). Finally, add a (liberal) 30 second timeout and dump logs at the end. If we're just waiting for a device to show up and it doesn't after 30 seconds then it's probably never going to... Signed-off-by:
Caleb Connolly <caleb@postmarketos.org>
-
- Jun 18, 2024
-
-
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:
Caleb Connolly <caleb@postmarketos.org> Co-authored-by:
Clayton Craft <clayton@craftyguy.net> [ci:ignore-count] [ci:skip-build]: already built successfully in CI
-
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:
Clayton Craft <craftyguy@postmarketos.org> Signed-off-by:
Caleb Connolly <caleb@postmarketos.org>
-
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:
Caleb Connolly <caleb@postmarketos.org>
-
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:
Caleb Connolly <caleb@postmarketos.org>
-
- Jun 04, 2024
- May 16, 2024
-
-
Pablo Correa Gomez authored
-
- Feb 06, 2024
-
-
Some devices take time to initialize storage, e.g. Qualcomm laptops using ADSP need to load firmware firstly, and initramfs script does not always manage to mount boot partition in time. Unfortunately, there is no reliable way to reproduce the issue, but this patch should fix cases like this.
-
- Jan 05, 2024
-
-
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:
Caleb Connolly <caleb@connolly.tech>
-
- Nov 21, 2023
-
-
As described in [0] let's switch away from RNDIS and use NCM instead. Since we cannot force all kernels to switch at the same time, let's keep a fallback to RNDIS in the setup function. We can also remove usb_f_rndis from modprobe as the module gets loaded automatically when needed, but instead we need to load libcomposite manually so that $configfs/usb_gadget gets created. [0] https://gitlab.com/postmarketOS/pmaports/-/issues/1797 [ci:skip-build] already built successfully in CI
-
- Nov 02, 2023
-
-
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
-
- Oct 31, 2023
-
-
Caleb Connolly authored
Enable using the postmarketOS initramfs for boot-testing devices, in this scenario we don't care about some components like the splash, mdev, or subpartitions, instead we want to run full udev (to load all devices) and then run hooks. The ci hook will deadloop after running tests. Signed-off-by:
Caleb Connolly <caleb@connolly.tech>
-
- Sep 07, 2023
-
-
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:
Caleb Connolly <caleb@connolly.tech>
-
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.
-
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...
-
- Aug 23, 2023
-
-
[ci:skip-build] already built successfully in CI
-
- Aug 04, 2023
-
-
The modules are now managed exclusively through the /lib/modules/initramfs.load files
-
- Jul 10, 2023
-
-
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.
-
- Jun 03, 2023
-
- Apr 26, 2023
-
-
Pablo Correa Gomez authored
As a preparation for #1836, move the sourcing of deviceinfo to its own function. This should allow to have a single point in the whole of the initramfs for the sourcing of the deviceinfo, instead of every script that needs it sourcing it. This allows to change the way deviceinfo is sourced in the future with a lot less effort.
-
- Mar 09, 2023
-
-
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
-
- Feb 19, 2023
-
-
As it was dropped in the previous commit. [ci:skip-build]: already built successfully in CI
-
- Feb 18, 2023
-
-
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).
-
- Jan 23, 2023
-
-
Oliver Smith authored
Add support for hook scripts in initramfs-extra to the shell scripts. Related: https://gitlab.com/postmarketOS/postmarketos-mkinitfs/-/merge_requests/27
-
- Jan 08, 2023
-
-
Clayton Craft authored
By positioning this after extracting the initramfs-extra archive, we can allow udev to exist in the -extra archive and not have any size impact on the base initramfs archive. Any hook that needs udev in the initramfs can get that support, provided that the hook lists udev requirements in the .files config for it.
-
- Jun 06, 2022
-
-
At the moment, mkinitfs loads some file system modules always (ext4), some dynamically (brtfs) and some not at all (f2fs, vfat), expecting them to be built-in. To support generic kernels (e.g. from Alpine) properly, use the partition type detection for both boot and root partition and always load the necessary modules before mounting.
-
- May 29, 2022
-
-
This replaces the previous `udevadm test` hack with a combination of `udevd`, `udevadm trigger` and `udevadm settle` in order to coldplug all available devices and make them available for use via libinput / unl0kr. Relates to: #1411 [ci:skip-build] already built successfully in CI
-
- May 12, 2022
-
-
- Jan 05, 2022
-
-
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
-
- Sep 03, 2021
-
-
Clayton Craft authored
This replaces the mkinitfs script with a re-write (in Go). The re-written mkinitfs will atomically replace the initfs in /boot, check for free space before doing so, and try to do whatever it can to not leave the system in an unbootable state by botching the initfs creation/installation. pmb:cross-native with go cross compiling doesn't work exactly, it makes the correct binary, but on Alpine go uses -buildmode=pie which creates a dynamic thing, and the interpreter is wrong (e.g. it it set to use the host arch's interpreter, like /lib/ld-musl-x86_64 even though GOARCH=arm64) The init.sh script is no longer a template, "initramfs-extra" is used. Fixes https://gitlab.com/postmarketOS/pmaports/-/issues/1019 fixes https://gitlab.com/postmarketOS/pmaports/-/issues/660
-
- Aug 16, 2021
-
-
There should be no reason that this has to be done by mkinitfs, and moving it to initfs simplifies mkinitfs (and the creation of a replacement)
-