by bschnei » Mon Jun 10, 2024 9:32 pm
pacman hooks are installed here: /usr/share/libalpm/hooks/ permake_clickable_callback(MAGIC_URL_FULL, ' ', 'https://wiki.archlinux.org/title/pacman#Hooks', '', ' class="postlink"')
The linux-espressobin package is installing it's own custom pacman hooks that trigger mkinitpio to run to generate initramfs-linux.img and then mkimage to generate initramfs-linux.uimg. That is these files:
make_clickable_callback(MAGIC_URL_FULL, '
', 'https://github.com/archlinuxarm/PKGBUILDs/blob/master/core/linux-espressobin/90-linux.hook', '', ' class="postlink"')make_clickable_callback(MAGIC_URL_FULL, '
', 'https://github.com/archlinuxarm/PKGBUILDs/blob/master/core/linux-espressobin/91-linux.hook', '', ' class="postlink"')
In contrast, linux-aarch64 uses the pacman hook that gets installed as part of mkinitcpio per this comment:make_clickable_callback(MAGIC_URL_FULL, '
', 'https://github.com/archlinuxarm/PKGBUILDs/blob/master/core/linux-aarch64/PKGBUILD#L101-L102', '', ' class="postlink"')
You'll find that hook (90-mkinitcpio-install.hook) in the same hooks directory. As you've already discovered, that hook will not build the .uimg file for you so if you want to switch to linux-aarch64 you will have to customize your configuration (e.g. by writing your own hooks). You are basically going down the same rabbit hole I did which is why I ultimately built my own kernel package.
As to what mkinitcpio generates, that is controlled by "presets". In the case of linux-aarch64 that is this file:make_clickable_callback(MAGIC_URL_FULL, ' ', 'https://github.com/archlinuxarm/PKGBUILDs/blob/master/core/linux-aarch64/linux.preset', '', ' class="postlink"')
So when you install linux-aarch64, mkinitcpio should generate *both* /boot/initramfs-linux.img and /boot/initramfs-linux-fallback.img. The fallback image is just a larger initramfs that doesn't try to autodetect which modules you have loaded. As a result it is larger in size. More info on that here:make_clickable_callback(MAGIC_URL_FULL, ' ', 'https://wiki.archlinux.org/title/Mkinitcpio#Automated_generation', '', ' class="postlink"')
But it will not generate the .uimg version of those ramdisks which is the format u-boot is expecting. So regardless of which initramfs you want to use (you are probably safe using the non-fallback version), you will have to always run mkimage to build the version formatted for u-boot on every kernel upgrade and/or upgrade to mkinitcpio.
IMHO, mkinitcpio packaged for ARM is a clunky version of mkinitcpio for x64. The way it's patched, it doesn't elegantly support multiple kernel installs. If you poke around on these forums you'll see quite a few threads reporting issues. If you are wiling to move to EFI booting, you may be able to eliminate the initramfs entirely, unless you need to use features like full disk encryption. This is yet another reason I packaged my own kernel.
So if you used the larger -fallback version of the initramfs then, yes, it's entirely possibly you've loaded the initramfs to a location in memory that would cause it to overwrite other things in memory. The simplest thing may be to use the non-fallback version, but the linux-aarch64 kernel is also a general kernel that is likely compiled to support a larger number of devices which will mean a much larger kernel and initramfs. So yes, you will want to check that your load addresses for the kernel, device tree, and initramfs give them all enough space to not run over each other.
The address values in u-boot configuration are in hexadecimal form so you want to convert them to decimal to interpret where in addressable memory space they are. You can use an online calculator or spreadsheet functions. So if we use the example here:make_clickable_callback(MAGIC_URL_FULL, ' ', 'https://github.com/archlinuxarm/PKGBUILDs/blob/master/alarm/uboot-espressobin/uEnv.txt', '', ' class="postlink"')
kernel_addr=0x2000000
ramdisk_addr=0x1100000
fdt_addr=0x1000000
Those values map to 32MB (33554432 bytes), 17MB (17825792 bytes) and 16MB (16777216 bytes) respectively. This is a terrible layout because it only leaves 32-17 = 15MB for your initramfs. If your initramfs is larger than that (which it almost certainly is if you use the -fallback version) then you will overwrite the spot in memory where the kernel was loaded. Most likely that is what is going on. This headache is yet another issue that is solved by moving to EFI booting.