Compare commits

...
Author SHA1 Message Date
Caleb Connolly a52fa2edf6 u-boot-sdm845: new aport
Add a u-boot package which produces device-specific u-boot images for
the supported sdm845 devices. This isn't done via boot-deploy right now
because it shouldn't be re-flashed every time the initramfs is changed.
We'll need some kind of mechanism to only re-generate and re-flash
u-boot when u-boot itself changes...

This u-boot build supports the UFS storage found on these devices, hence
it can simply load the kernel via grub from a fat32 partition.

Signed-off-by: Caleb Connolly <caleb@connolly.tech>
2023-08-07 23:24:27 +01:00
Caleb Connolly 7d8d70b4dd device-generic-sdm845: new aport
Add a new generic device package targeting for now the SHIFT6mq, OnePlus
6, PocoPhone F1 and db845c. This device package uses u-boot and Grub to boot
Linux, allowing a common image for all the supported devices.

TODO:
 * Create a unified board-2.bin file for all the devices
 * Test on both beryllium variants

Signed-off-by: Caleb Connolly <caleb@connolly.tech>
2023-08-07 23:24:16 +01:00
Caleb Connolly b5997bbe77 HACK: firmware-shift-sdm845: don't conflict with other sdm845 devices
The bluetooth firmware and board-2.bin file also conflict, for testing
just remove them.

Signed-off-by: Caleb Connolly <caleb@connolly.tech>
2023-08-07 19:29:44 +01:00
Caleb Connolly 6d1ed439f2 firmware-oneplus-sdm845: don't conflict with other sdm845 devices
rename the initfs hook file to avoid conflicts.

Signed-off-by: Caleb Connolly <caleb@connolly.tech>
2023-08-07 19:27:23 +01:00
Caleb Connolly 70e81e9c21 device-oneplus-lemonade: use boot image header v1
Using header v1 and appended dtb simplifies a lot of things. It now
requires flashing dtbo with an empty file of at least 2 bytes, erasing
it might also work. As well as erasing vendor_boot.

It may still be necessary to flash vbmeta.

Signed-off-by: Caleb Connolly <caleb@connolly.tech>
2023-08-06 02:52:04 +01:00
Caleb Connolly 564e1bee73 DONTPUSH: axolotl dev stuff
Signed-off-by: Caleb Connolly <caleb@connolly.tech>
2023-08-06 02:52:02 +01:00
Clayton Craft 38a47aaebc main/postmarketos-initramfs: use only one method to resize the root partition
This removes the possibility that multiple resize root partition methods
could be invoked. I'm not sure how likely this is in practice, but it
seems like we should avoid the possiblity altogether.

This also adds some more helpful printing to stdout when the partition
resize is skipped / not done.
2023-08-06 02:51:11 +01:00
Caleb Connolly 87ac63e6d1 main/postmarketos-initramfs: fixup device-mapper paths
findfs might produce a block device path like /dev/dm-3, these can
change across boots and devices. Make things more readable and
consistent by mapping from the /dev/dm-* path to the equivalent
/dev/mapper/xyz path. Combined with invoking kpartx from a
/dev/disk/by-partlabel/abc symlink, this results in the final block
device having a name like /dev/mapper/userdata2 on an Android device.

Whilst this is just nicer to work with, this will be especially useful for
the upcoming ondev2 postmarketOS installer to make device-specific
configuration and detection easier.
2023-08-06 02:50:54 +01:00
Caleb Connolly 05e7887448 main/postmarketos-initramfs: optimise find_*_partition
Save the root/boot partition paths once found, and optimise a few loops.
2023-08-06 02:50:15 +01:00
Caleb Connolly 8340bbae4d main/postmarketos-initramfs: use mdev properly
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.
2023-08-06 02:50:15 +01:00
Caleb Connolly 3b18bc6a1d main/postmarketos-initramfs: rework logging
Make logs always go to kmsg, so that if you have a console configured
then you'll always be able to see the init script output. The
behaviour of PMOS_NO_OUTPUT_REDIRECT is adjusted so that it just
decides whether or not openrc will log to the console or not.

The original stdout/stderr fds are preserved and later restored, this is
important for debug-shell to run on the TTY.
2023-08-06 02:50:15 +01:00
Caleb Connolly ff6d3ee71e main/postmarketos-initramfs: silence pbsplash 2023-08-06 02:50:14 +01:00
Caleb Connolly 820cdd4ae0 main/postmarketos-mkinitfs-hook-debug-shell: reconfigure logging
It's necessary to reconfigure the stdout/stderr streams before spawning
the debug shell, so that it will correctly launch a getty on the serial
console if available.
2023-08-06 02:50:14 +01:00
Luca Weiss e71bc50b95 main/postmarketos-initramfs: switch_root with /dev (MR 3230)
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...
2023-08-06 02:50:14 +01:00
28 changed files with 423 additions and 96 deletions

No files matched your search

@@ -4,7 +4,7 @@
pkgname=device-shift-axolotl
pkgdesc="SHIFT6mq"
pkgver=11
pkgver=9999
pkgrel=1
url="https://postmarketos.org"
license="MIT"
@@ -47,7 +47,7 @@ nonfree_firmware() {
}
sha512sums="
88e5a1f014e48c811df46e94e09016f4f65cd99eb7e0baff4f7aaf9ee9cec2f8d9d9849aa23b6a28dac9631eeace530c5d914b538f186acbbd1e907d9041cc7e deviceinfo
abbe8c0fa5f847e9431a89c9ad8d6fbc85a406099b4384de22ac1fda8e5f07680677e5f389bab610f39d440d57eef0701831b8a97a7f89d43dc65f1406c855e0 deviceinfo
6bea4c8628853197600db11d11d2ad64f365ad2bdd9d06a05af0f3e96d4dcd2ffb9ddbd8ffc439f3d54baef02ad6eb05a7c16d308eecb24088279e63d7eb514a modules-initfs
2a3cbdad5aa91181d24a4e56e63986af6accf887c64fa4d1b6ddad1926e29050243c4b1e2fd892d38ca7c16e24dff8545a16552e5749ae31b6d01bf428468e51 q6voiced.conf
"
@@ -20,7 +20,8 @@ deviceinfo_screen_height="2160"
# Bootloader related
deviceinfo_flash_method="fastboot"
deviceinfo_kernel_cmdline="console=null"
deviceinfo_kernel_cmdline="console=ttyMSM0,115200 PMOS_NO_OUTPUT_REDIRECT"
deviceinfo_getty="ttyMSM0;115200"
deviceinfo_generate_bootimg="true"
deviceinfo_bootimg_qcdt="false"
deviceinfo_bootimg_dtb_second="false"
@@ -2,7 +2,7 @@
pkgname=firmware-oneplus-sdm845
pkgver=7
pkgrel=1
pkgrel=2
pkgdesc="Firmware for OnePlus 6 / 6T"
url="https://gitlab.com/sdm845-mainline/firmware-oneplus-sdm845"
arch="aarch64"
@@ -14,7 +14,7 @@ _version="895bb1c8dd0695635df354bbd713740af48e47ce"
source="$pkgname.tar.gz::$url/-/archive/$_version/$pkgname-$_version.tar.gz
firmware.files
30-gpu-firmware.files"
30-oneplus-sdm845-firmware.files"
subpackages="
$pkgname-initramfs:firmware_initramfs"
@@ -31,12 +31,12 @@ firmware_initramfs() {
install_if="$pkgname-nonfree-firmware"
mkdir "$subpkgdir"
install -Dm644 "$srcdir/30-gpu-firmware.files" \
"$subpkgdir/usr/share/mkinitfs/files/30-gpu-firmware.files"
install -Dm644 "$srcdir/30-oneplus-sdm845-firmware.files" \
"$subpkgdir/usr/share/mkinitfs/files/30-oneplus-sdm845-firmware.files"
}
sha512sums="
59091452f1d6363fab0474ebc2738ec8fca6903c64837c3b6228eefb2030b0b4d5f0694770ddadf81f59f2ace4fad548459ad7a6604498aaa08a9064fb1dc736 firmware-oneplus-sdm845.tar.gz
d2295ba3346ded12e88bb1b27958418cb14ab6bb8f2c23e73a66168f53eac0cc8a10e4be28181724e92ff75ef8608c4483641e24bfd9f05c4ff7b351179ba784 firmware.files
bc6c329bf6bb9622320ab610f4f5fb944129e276855a4cf5646cb29a553f4c47cd9a4ef4305cbcd94a991471bc109b8f615cefd6871be99bf6a457fe0fa5aa19 30-gpu-firmware.files
bc6c329bf6bb9622320ab610f4f5fb944129e276855a4cf5646cb29a553f4c47cd9a4ef4305cbcd94a991471bc109b8f615cefd6871be99bf6a457fe0fa5aa19 30-oneplus-sdm845-firmware.files
"
@@ -2,7 +2,7 @@
pkgname=firmware-shift-sdm845
pkgver=0.3
pkgrel=1
pkgrel=2
pkgdesc="Firmware for SHIFT sdm845 devices"
url="https://gitlab.com/sdm845-mainline/firmware-shift-sdm845"
arch="aarch64"
@@ -17,7 +17,7 @@ _version="ce9d27bf03624cceeaa8e7466f2e6dc731f2ba5e"
source="$pkgname.tar.gz::$url/-/archive/$_version/$pkgname-$_version.tar.gz
firmware.files
30-gpu-firmware.files"
30-shift-sdm845-firmware.files"
subpackages="
$pkgname-initramfs:firmware_initramfs"
@@ -36,12 +36,12 @@ firmware_initramfs() {
install_if="$pkgname-nonfree-firmware"
mkdir "$subpkgdir"
install -Dm644 "$srcdir/30-gpu-firmware.files" \
"$subpkgdir/usr/share/mkinitfs/files/30-gpu-firmware.files"
install -Dm644 "$srcdir/30-shift-sdm845-firmware.files" \
"$subpkgdir/usr/share/mkinitfs/files/30-shift-sdm845-firmware.files"
}
sha512sums="
86c3813a9f43e8f5f5e0df1215e37090011d6c468aad1a23f944a202e9fa740240869ed7b0b11ad032d35afaee72e903e24ca8d0e1de2f992902692f8c5983f8 firmware-shift-sdm845.tar.gz
0b547cd027a9760cf16d80e63ebfb89282cff260bd07cc0bfea364513be7a5a32202a5f0aedbeb52dc5ca8087595a2842442a59f77dc7c9bcf5f154e905ceb15 firmware.files
8695a37da5578fdae506f373131ce9481be3db1a86f329c19893e7360b9cb0fadd47b0b1318b2e74702c5e76a9be022f58610940ad17becab49788689f6ca3f8 30-gpu-firmware.files
2d74afc5c0b8eaae6efc8dff50a61045b6bf2a3628521b8561824b0f18fe52af8eff62c49b8d48fef965f23316bcb33c7fba7d8738cd068287df5a9e7890a03e firmware.files
8695a37da5578fdae506f373131ce9481be3db1a86f329c19893e7360b9cb0fadd47b0b1318b2e74702c5e76a9be022f58610940ad17becab49788689f6ca3f8 30-shift-sdm845-firmware.files
"
@@ -1,5 +1,3 @@
./lib/firmware/postmarketos/ath10k/WCN3990/hw1.0/board-2.bin
./lib/firmware/postmarketos/qca/crbtfw21.tlv
./lib/firmware/qca/axolotl/crnv21.bin
./lib/firmware/qcom/sdm845/axolotl/a630_zap.mbn
./lib/firmware/qcom/sdm845/axolotl/adsp.mbn
@@ -0,0 +1,86 @@
# Reference: <https://postmarketos.org/devicepkg>
# Maintainer: Caleb Connolly <caleb@connolly.tech>
pkgname=device-generic-sdm845
pkgdesc="SDM845 generic device port (for use with u-boot)"
pkgver=1
pkgrel=0
url="https://postmarketos.org"
license="MIT"
arch="aarch64"
# pmb:strict is required for grub
options="!check !archcheck pmb:strict"
depends="
linux-postmarketos-qcom-sdm845
make-dynpart-mappings
mkbootimg
postmarketos-base
postmarketos-update-kernel
soc-qcom-sdm845
soc-qcom-sdm845-ucm
soc-qcom-sdm845-qbootctl
u-boot-sdm845
fwupd>=1.8.6
"
makedepends="devicepkg-dev grub grub-efi"
source="
deviceinfo
q6voiced.conf
modules-initfs
"
subpackages="$pkgname-nonfree-firmware:nonfree_firmware"
build() {
devicepkg_build $startdir $pkgname
grub-mkimage \
--prefix="/grub" \
--output="bootaa64.efi" \
--format="arm64-efi" \
--compression="xz" \
\
all_video \
cat \
configfile \
disk \
echo \
efi_gop \
fat \
gzio \
help \
iso9660 \
linux \
ls \
normal \
part_gpt \
part_msdos \
search \
search_label \
test \
true
}
package() {
devicepkg_package $startdir $pkgname
install -Dm644 -t "$pkgdir"/boot/EFI/Boot \
"$srcdir"/bootaa64.efi
}
nonfree_firmware() {
pkgdesc="Modem, GPU and WiFi Firmware, also needed for osk-sdl"
depends="firmware-shift-sdm845 firmware-shift-sdm845-initramfs
firmware-oneplus-sdm845 firmware-oneplus-sdm845-initramfs
firmware-xiaomi-beryllium
soc-qcom-sdm845-nonfree-firmware soc-qcom-sdm845-modem"
mkdir "$subpkgdir"
install -Dm644 q6voiced.conf "$subpkgdir"/etc/conf.d/q6voiced
}
sha512sums="
641ded402aa97bb1f9f7e837b2210d9fb9b8edaf98ad464ca2c92a0325694fb2fd456e42298c3a50bee895eafa908b07e46ebc8def391b4291c42ac178dea6a6 deviceinfo
2131a6838a7af24ff91de24064d27b0e43706831701fff5e8d6827d808d3ddaa74cd68f9d6575204df86af237224807aadc014a43f5600f1adc95408da6f273a q6voiced.conf
84ec48c6adf5644d6b8b848d18e35383fe0d5bbf17045112a76f6d285f9938d8874836ceca724d3eb8a61b10395b4b9365888c81c83480e2f26a76afecd702ed modules-initfs
"
@@ -0,0 +1,36 @@
# Reference: <https://postmarketos.org/deviceinfo>
# Please use double quotes only. You can source this file in shell
# scripts.
deviceinfo_format_version="0"
deviceinfo_name="Qualcomm SDM845"
deviceinfo_manufacturer="Qualcomm"
deviceinfo_codename="generic-sdm845"
deviceinfo_uboot_boardname="sdm845"
deviceinfo_year="2020"
deviceinfo_arch="aarch64"
# Device related
deviceinfo_gpu_accelerated="true"
deviceinfo_mesa_driver="msm"
deviceinfo_chassis="handset"
deviceinfo_keyboard="false"
deviceinfo_external_storage="true"
# Bootloader related
deviceinfo_flash_method="fastboot"
deviceinfo_kernel_cmdline="quiet"
# uncomment to enable a getty on the serial port
# deviceinfo_getty="ttyMSM0;115200"
deviceinfo_generate_grub_config="true"
deviceinfo_boot_filesystem="fat32"
# Look ma! no hands!
# u-boot picks the right DTB for us, no need to specify it in grub.
# deviceinfo_dtb=""
deviceinfo_initfs_compression="zstd:fast"
deviceinfo_bootimg_override_payload="u-boot.bin"
deviceinfo_bootimg_override_payload_compression="gzip"
# Required for devices using UFS as storage (instead of e.g. eMMC)
deviceinfo_rootfs_image_sector_size="4096"
@@ -0,0 +1,8 @@
focaltech_fts
gpi
i2c_qcom_geni
qcom_spmi_haptics
lontium-lt9611
rmi_core
rmi_i2c
nt36xxx
@@ -0,0 +1,22 @@
_dt_compatible="$(cat /sys/firmware/devicetree/base/compatible | \
tr '\0' '|' | cut -d'|' -f1)"
# Set q6voice_card and q6voice_device based on compatible string
# shift,axolotl: q6voice_card=0, q6voice_device=12
# oneplus,enchilada: q6voice_card=0, q6voice_device=6
# oneplus,fajita: q6voice_card=0, q6voice_device=6
# xiaomi,beryllium: q6voice_card=0, q6voice_device=4
case "$_dt_compatible" in
"shift,axolotl")
q6voice_card=0
q6voice_device=12
;;
"oneplus,enchilada"|"oneplus,fajita")
q6voice_card=0
q6voice_device=6
;;
"xiaomi,beryllium")
q6voice_card=0
q6voice_device=4
;;
esac
@@ -1,7 +1,7 @@
# Reference: <https://postmarketos.org/devicepkg>
pkgname=device-oneplus-lemonade
pkgdesc="OnePlus 9 & 9 Pro"
pkgver=0.2
pkgver=0.3
pkgrel=2
url="https://postmarketos.org"
license="MIT"
@@ -49,7 +49,7 @@ nonfree_firmware() {
}
sha512sums="
69666f895a4e8f0d9d87d0f1e37a7bdb62f08880151deb7450d3f774ec7fb61a1b1b263588e90bd403c3961d74d57e2c256ee02e3ef07e771700b57b94292f8a deviceinfo
587bc143fe18bf993d9ca4668d9f5c1b25eb7fe1d693f8f6051de4bb0454545e3e5c29ae89bef5d4b113e33e6ea508659f5f2019a500848f4e0cb41ddd6c2eb6 deviceinfo
cf3bde87540de9a94d253ab211ca9d6ca426e062237db3ab6ec5dfcdb35c161fdfc22837ca696dd27ee5a371157186a5e65b8de33dcc69ce49b7a9584fdce51c empty-oneplus-lemonade.dts
cd5d0daff0f156c6f8e2b987a84199cf6d6cd4190b4e91f81465230d9a39f8dba6e25b1aa995b9da829ba940fcf25c43f5c32ae0c041f16901e343dabcf332b8 empty-oneplus-lemonadep.dts
b79456fa9dbfe5d8ac0564bcfea9a0242a452fde5e0034e471843aa078f71ca4962052a59fc52ca89b0c13fd16b203c8365a81e0295705c048abeca5e183ddc0 empty-oneplus-lemonadep.dts
"
@@ -29,7 +29,7 @@ deviceinfo_flash_sparse="true"
deviceinfo_flash_fastboot_partition_vbmeta="vbmeta"
deviceinfo_flash_fastboot_partition_dtbo="dtbo"
deviceinfo_flash_fastboot_partition_system="super"
deviceinfo_header_version="2"
deviceinfo_header_version="1"
deviceinfo_flash_offset_base="0x00000000"
deviceinfo_flash_offset_dtb="0x01f00000"
deviceinfo_flash_offset_kernel="0x00008000"
@@ -37,4 +37,5 @@ deviceinfo_flash_offset_ramdisk="0x01000000"
deviceinfo_flash_offset_second="0x00000000"
deviceinfo_flash_offset_tags="0x00000100"
deviceinfo_rootfs_image_sector_size="4096"
deviceinfo_append_dtb="false"
deviceinfo_append_dtb="true"
@@ -13,3 +13,4 @@
&apps_rsc {
compatible = "qcom,rpmh-rsc";
};
+85
View File
@@ -0,0 +1,85 @@
# U-boot with patches to make the Samsung S9 boot
pkgname=u-boot-sdm845
pkgver=2023.04_rc4
pkgrel=0
pkgdesc="U-Boot bootloader for sdm845 devices"
url="https://source.denx.de/u-boot"
arch="aarch64"
license="GPL-2.0-or-later OFL-1.1 BSD-2-Clause BSD-3-Clause eCos-2.0 IBM-pibs
ISC LGPL-2.0-only LGPL-2.1-only X11"
makedepends="
mkbootimg-osm0sis
bc
bison
dtc
flex
openssl-dev
py3-setuptools
python3-dev
swig
"
options="!archcheck !check !tracedeps !strip pmb:cross-native"
_ubootver="75558f95a2c24d6a99209e421c20e96ae21f3dec"
source="
u-boot-$_ubootver.tar.gz::https://github.com/calebccff/u-boot/archive/$_ubootver.tar.gz
dummy_axolotl.dts
dummy_beryllium.dts
dummy_db845c.dts
dummy_enchilada.dts
dummy_fajita.dts
"
builddir="$srcdir/u-boot-$_ubootver"
# XXX: add beryllium DTS to u-boot
# fajita shares the enchilada DTS in u-boot
_boards_to_build="axolotl enchilada db845c"
_boards="$_boards_to_build fajita"
_build_board() {
board="$1"
echo "Building for $board"
make DEVICE_TREE="$board"
cp u-boot.bin u-boot-"$board".bin
gzip u-boot-"$board".bin
}
build() {
unset LDFLAGS
make HOSTCC=gcc ARCH=arm sdm845_defconfig
make
for board in $_boards_to_build; do
_build_board "$board"
done
cp u-boot-enchilada.bin.gz u-boot-fajita.bin.gz
for board in $_boards; do
echo "Generating image for $board"
dtc -I dts -O dtb -o dummy_"$board".dtb "$srcdir"/dummy_"$board".dts
cat u-boot-"$board".bin.gz dummy_"$board".dtb > u-boot-"$board".bin.gz-dtb
mkbootimg-osm0sis --base '0x00000000' \
--kernel_offset '0x00008000' \
--ramdisk_offset '0x01000000' \
--tags_offset '0x00000100' \
--pagesize '4096' \
--second_offset '0x00f00000' \
--kernel u-boot-"$board".bin.gz-dtb \
-o u-boot-"$board".img
done
}
package() {
for board in $_boards; do
install -D -m644 $builddir/"u-boot-$board.img" \
"$pkgdir/boot/u-boot-$board.img";
done
}
sha512sums="
1ca69b4c4bc6a71872dca3633642e0211d7d7923731c03583f950f51ce63334b0dd1dbe8c6715a51627ed2c5c949d3ec6bc1d8c53add0561eb11badf0d096227 u-boot-75558f95a2c24d6a99209e421c20e96ae21f3dec.tar.gz
65b8ab99a1cfd4fa2648018b4b9ad0e8aeeb526a8e50a098265872fd7dde08d99b3f91f0327bbc4fd5225a9760122306da48740f6c6f995b322fef162f4cf691 dummy_axolotl.dts
82b18bd546f5f8eeef0bb228a52d9f6f9dd9642e6aff8c381ff0fe767eb21cab082498268228f19a948c0a96f84299ce833bb8d9ebd547eb8889a7ef58fe14eb dummy_beryllium.dts
65b8ab99a1cfd4fa2648018b4b9ad0e8aeeb526a8e50a098265872fd7dde08d99b3f91f0327bbc4fd5225a9760122306da48740f6c6f995b322fef162f4cf691 dummy_db845c.dts
65b8ab99a1cfd4fa2648018b4b9ad0e8aeeb526a8e50a098265872fd7dde08d99b3f91f0327bbc4fd5225a9760122306da48740f6c6f995b322fef162f4cf691 dummy_enchilada.dts
83bb511dc96b39c3b846b70a6cd975b15c03bb1b9856a3c02438d4b2073abae64f863b529705936de8c2f352c52aaf04aae268f3602a802ff1a03c838ea7081e dummy_fajita.dts
"
+1
View File
@@ -0,0 +1 @@
dummy_enchilada.dts
@@ -0,0 +1,13 @@
/dts-v1/;
/ {
#address-cells = <2>;
#size-cells = <2>;
qcom,msm-id = <321 0x20001>;
qcom,board-id = <69 0>;
memory {
/* We expect the bootloader to fill in the size */
reg = <0 0 0 0>;
};
chosen { };
};
+1
View File
@@ -0,0 +1 @@
dummy_enchilada.dts
@@ -0,0 +1,14 @@
/* Used for enchilada, fajita, axolotl, and db845c */
/dts-v1/;
/ {
#address-cells = <2>;
#size-cells = <2>;
qcom,msm-id = <0x141 0x20001>;
qcom,board-id = <8 0 17819 22>;
memory {
/* We expect the bootloader to fill in the size */
reg = <0 0 0 0>;
};
chosen { };
};
@@ -0,0 +1,14 @@
/* Used for enchilada, fajita, axolotl, and db845c */
/dts-v1/;
/ {
#address-cells = <2>;
#size-cells = <2>;
qcom,msm-id = <0x141 0x20001>;
qcom,board-id = <8 0 18801 41>;
memory {
/* We expect the bootloader to fill in the size */
reg = <0 0 0 0>;
};
chosen { };
};
@@ -4,6 +4,7 @@
/etc
/lib
/proc
/run
/sbin
/sys
/sysroot
@@ -2,6 +2,11 @@
/bin/busybox-extras
/bin/sh
/etc/deviceinfo
/etc/mdev.conf
/etc/group
/etc/passwd
/lib/mdev/persistent-storage
/sbin/blkid
/usr/share/misc/source_deviceinfo
/usr/bin/unudhcpd
/usr/sbin/kpartx
@@ -2,6 +2,7 @@
/sbin/btrfs
/sbin/dmsetup
/sbin/e2fsck
/sbin/switch_root
/usr/sbin/parted
/usr/sbin/resize2fs
/usr/sbin/resize.f2fs
+8 -6
View File
@@ -1,10 +1,11 @@
# Maintainer: Oliver Smith <ollieparanoid@postmarketos.org>
# Co-Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=postmarketos-initramfs
pkgver=1.3.0
pkgver=1.4.1
pkgrel=0
pkgdesc="Base files for the postmarketOS initramfs / initramfs-extra"
url="https://postmarketos.org"
options="!check" # no tests
depends="
btrfs-progs
busybox-extras
@@ -21,6 +22,7 @@ depends="
postmarketos-fde-unlocker
postmarketos-mkinitfs
unudhcpd
util-linux-misc
xz
"
source="
@@ -65,9 +67,9 @@ package() {
sha512sums="
bed319179bcd0b894d6267c7e73f2890db07bc07df71542936947dfb3bdb17fade8a7b4e7b577f278af4472464427bba07f75aff0a1e454a4167052c088f3b6a 00-default.modules
399da6e61993f48c8a62c956bb15d294cac10bf003d84257efdf4a213ebc87bb51cdcd75c4675f51c3be832146b8f21a7c769bf3e94f574a5067f001662632a1 00-initramfs-base.dirs
3bc73f3a0d1de210444d9c45fab51fd4520e38b43ffbb76368f8ff854b990aa2f21c6356840c5a48eb9808e834eb885a6d581639a60707c26abf66fc20b70db9 00-initramfs-base.files
e984cd3033ce8752ebc71127828b964b46259a5263c2ebfab32c1394b674bcff464862ff00b8e920d3d31386c54ca0b94f84bc77580d275ecfeea33e76c07ef4 00-initramfs-extra-base.files
4e6f5b79b0bd6188bab9a96526f727780dda6be1c1e5fe04c3ce5a892bf0f92b7c7d0fc5809ac3eacc8121096a4815c6177a573f1b968752972f20460cc04ac6 init.sh
d5570ce96f501d3a1cb39d803d81770abaa27b4692c455034a7d69e14ae226ee07f8bd61fdd0a738c8a10528e0a984c9e8ebe47427c4cb3a801097381d8adc36 init_functions.sh
5b364300f31c91fd0591eb0715f67cbf5383f45246a5fb9f34b79f7cb2e3b15768b2130e5f32f816cc169950f988c1beabc879ba31645c58ce131a288dbc071d 00-initramfs-base.dirs
77ee384c6b4a74f5c8cc901cebcfca1a60c98885354582ad18d932ae2736376ccd408a0e711f6ac5f043f63194d17b01119e736b8dddec96034cf4ec9e93c341 00-initramfs-base.files
8a4adad3785af474b36a09a05f6a3b2c4b4f43aac331a53b903abfa51ea12be1e3d1d807b7a6e66a1346815f3b0044daf8cd62e21e2dc75d2db13ee265a72985 00-initramfs-extra-base.files
2d28baac7b8c33dadd10fbe8e328fde6aefdb86f19d0fb59856c61bc2214ccaf26d3a8629ad97469ecc064f7daab71e01fbe1a9361591d2f777e5258fe09c60f init.sh
c5306c1b45db0c9107daae705b02ba163bcec2d7e7886d1a71003394a2e569b28a359bbce137f3d5772f0a10d632db56768a436ee119a9723014128a772f141e init_functions.sh
"
+1 -5
View File
@@ -12,7 +12,6 @@ export PATH=/usr/bin:/bin:/usr/sbin:/sbin
# Mount everything, set up logging, modules, mdev
mount_proc_sys_dev
create_device_nodes
setup_log
setup_firmware_path
# shellcheck disable=SC2154
@@ -52,10 +51,7 @@ setup_bootchart2
# Switch root
killall telnetd mdev udevd msm-fb-refresher 2>/dev/null
umount /proc
umount /sys
umount /dev/pts
umount /dev
reconfigure_logging ""
# shellcheck disable=SC2093
exec switch_root /sysroot "$init"
+101 -62
View File
@@ -3,29 +3,45 @@
IP=172.16.42.1
ROOT_PARTITION_UNLOCKED=0
ROOT_PARTITION_RESIZED=0
PMOS_BOOT=""
PMOS_ROOT=""
# Redirect stdout and stderr to logfile
setup_log() {
# Bail out if PMOS_NO_OUTPUT_REDIRECT is set
echo "### postmarketOS initramfs ###"
grep -q PMOS_NO_OUTPUT_REDIRECT /proc/cmdline && return
# Save stdout/stderr for later
exec 6>&1
exec 7>&2
# Redirects all output to a subshell which prepends "PMOS: " to each line
# and then pipes to the logfile and the kernel logbuffer.
# shellcheck disable=SC3001
exec > >(awk '$0="PMOS: "$0' - | tee -a /pmOS_init.log /dev/kmsg >/dev/null)
exec 2>&1
# Print a message about what is going on to the normal output
echo "NOTE: All output from the initramfs gets redirected to:"
echo "/pmOS_init.log"
echo "If you want to disable this behavior (e.g. because you're"
echo "debugging over serial), please add this to your kernel"
echo "command line: PMOS_NO_OUTPUT_REDIRECT"
# Start redirect, print the first line again
exec >/pmOS_init.log 2>&1
echo "### postmarketOS initramfs ###"
echo "NOTE: All output from the initramfs gets redirected to"
echo "the kernel log buffer (dmesg) and /pmOS_init.log in the ramdisk"
}
# Reconfigure logging before switch_root
reconfigure_logging() {
echo "Reconfiguring stdout/stderr $1"
# For debugging, allow logging to the console
if [ -n "$1" ] || grep -q PMOS_NO_OUTPUT_REDIRECT /proc/cmdline; then
exec 1>&6 6>&-
exec 2>&7 7>&-
return
fi
# Pipe to /dev/null and delete the original stdout/stderr
exec >/dev/null 6>&-
exec 2>/dev/null 7>&-
}
mount_proc_sys_dev() {
# mdev
mount -t proc -o nodev,noexec,nosuid proc /proc || echo "Couldn't mount /proc"
mount -t sysfs -o nodev,noexec,nosuid sysfs /sys || echo "Couldn't mount /sys"
mount -t devtmpfs -o mode=0755,nosuid dev /dev || echo "Couldn't mount /dev"
mount -t tmpfs -o nosuid,nodev,mode=0755 run /run || echo "Couldn't mount /run"
mkdir /config
mount -t configfs -o nodev,noexec,nosuid configfs /config
@@ -34,14 +50,11 @@ mount_proc_sys_dev() {
mkdir -p /dev/pts
mount -t devpts devpts /dev/pts
# /run (needed for cryptsetup)
mkdir /run
}
create_device_nodes() {
mknod -m 666 /dev/null c 1 3
mknod -m 644 /dev/random c 1 8
mknod -m 644 /dev/urandom c 1 9
# Set up fd symlinks for I/O redirects
ln -s /proc/self/fd /dev/fd
ln -sf /proc/self/fd/0 /dev/stdin
ln -sf /proc/self/fd/1 /dev/stdout
ln -sf /proc/self/fd/2 /dev/stderr
}
setup_firmware_path() {
@@ -112,16 +125,19 @@ setup_dynamic_partitions() {
}
mount_subpartitions() {
# Do not create subpartition mappings if pmOS_boot
# already exists (e.g. installed on an sdcard)
[ -n "$(find_boot_partition)" ] && return
try_parts="/dev/disk/by-partlabel/userdata /dev/disk/by-partlabel/system* /dev/mapper/system*"
android_parts=""
for x in $try_parts; do
[ -e "$x" ] && android_parts="$android_parts $x"
done
attempt_start=$(get_uptime_seconds)
wait_seconds=10
echo "Trying to mount subpartitions for $wait_seconds seconds..."
while [ -z "$(find_boot_partition)" ]; do
partitions="$(grep -v "loop\|ram" < /proc/diskstats |\
partitions="$android_parts $(grep -v "loop\|ram" < /proc/diskstats |\
sed 's/\(\s\+[0-9]\+\)\+\s\+//;s/ .*//;s/^/\/dev\//')"
echo "$partitions" | while read -r partition; do
for partition in $partitions; do
case "$(kpartx -l "$partition" 2>/dev/null | wc -l)" in
2)
echo "Mount subpartitions of $partition"
@@ -148,7 +164,22 @@ mount_subpartitions() {
done
}
# Rewrite /dev/dm-X paths to /dev/mapper/...
pretty_dm_path() {
dm="$1"
n="${dm#/dev/dm-}"
# If the substitution didn't do anything, then we're done
[ "$n" = "$dm" ] && echo "$dm" && return
# Get the name of the device mapper device
name="/dev/mapper/$(cat "/sys/class/block/dm-${n}/dm/name")"
echo "$name"
}
find_root_partition() {
[ -n "$PMOS_ROOT" ] && echo "$PMOS_ROOT" && return
# The partition layout is one of the following:
# a) boot, root partitions on sdcard
# b) boot, root partition on the "system" partition (which has its
@@ -162,13 +193,14 @@ find_root_partition() {
# shellcheck disable=SC2013
if [ "$ROOT_PARTITION_UNLOCKED" = 0 ]; then
for x in $(cat /proc/cmdline); do
[ "$x" = "${x#pmos_root_uuid=}" ] && continue
DEVICE="$(findfs UUID="${x#pmos_root_uuid=}")"
done
for x in $(cat /proc/cmdline); do
[ "$x" = "${x#pmos_root=}" ] && continue
DEVICE="${x#pmos_root=}"
if ! [ "$x" = "${x#pmos_root_uuid=}" ]; then
PMOS_ROOT="$(findfs UUID="${x#pmos_root_uuid=}")"
break
fi
if ! [ "$x" = "${x#pmos_root=}" ]; then
PMOS_ROOT="${x#pmos_root=}"
break
fi
done
# On-device installer: before postmarketOS is installed,
@@ -179,61 +211,61 @@ find_root_partition() {
# p2: (reserved space) <--- pmos_root
# p3: pmOS_install
# Details: https://postmarketos.org/on-device-installer
if [ -n "$DEVICE" ]; then
next="$(echo "$DEVICE" | sed 's/2$/3/')"
if [ -n "$PMOS_ROOT" ]; then
next="$(echo "$PMOS_ROOT" | sed 's/2$/3/')"
# If the next partition is labeled pmOS_install (and
# not pmOS_deleteme), then postmarketOS is not
# installed yet.
if blkid | grep "$next" | grep -q pmOS_install; then
DEVICE="$next"
PMOS_ROOT="$next"
fi
fi
fi
# Try partitions in /dev/mapper and /dev/dm-* first
if [ -z "$DEVICE" ]; then
if [ -z "$PMOS_ROOT" ]; then
for id in pmOS_install pmOS_root crypto_LUKS; do
for path in /dev/mapper /dev/dm; do
DEVICE="$(blkid | grep "$path" | grep "$id" \
| cut -d ":" -f 1 | head -n 1)"
[ -z "$DEVICE" ] || break 2
done
PMOS_ROOT="$(findfs LABEL="$id")"
[ -n "$PMOS_ROOT" ] && break
done
fi
# Then try all devices
if [ -z "$DEVICE" ]; then
for id in pmOS_install pmOS_root crypto_LUKS; do
DEVICE="$(blkid | grep "$id" | cut -d ":" -f 1 \
| head -n 1)"
[ -z "$DEVICE" ] || break
done
fi
echo "$DEVICE"
PMOS_ROOT=$(pretty_dm_path "$PMOS_ROOT")
echo "$PMOS_ROOT"
}
find_boot_partition() {
[ -n "$PMOS_BOOT" ] && echo "$PMOS_BOOT" && return
# shellcheck disable=SC2013
for x in $(cat /proc/cmdline); do
[ "$x" = "${x#pmos_boot_uuid=}" ] && continue
findfs UUID="${x#pmos_boot_uuid=}"
path="$(findfs UUID="${x#pmos_boot_uuid=}")"
[ -e "$path" ] && PMOS_BOOT="$path" && echo "$path"
return
done
# shellcheck disable=SC2013
for x in $(cat /proc/cmdline); do
[ "$x" = "${x#pmos_boot=}" ] && continue
echo "${x#pmos_boot=}"
path="${x#pmos_boot=}"
[ -e "$path" ] && PMOS_BOOT="$path" && echo "$path"
return
done
# * "pmOS_i_boot" installer boot partition (fits 11 chars for fat32)
# * "pmOS_inst_boot" old installer boot partition (backwards compat)
# * "pmOS_boot" boot partition after installation
findfs LABEL="pmOS_i_boot" \
|| findfs LABEL="pmOS_inst_boot" \
|| findfs LABEL="pmOS_boot"
for p in pmOS_i_boot pmOS_inst_boot pmOS_boot; do
PMOS_BOOT="$(findfs LABEL="$p")"
[ -n "$PMOS_BOOT" ] && break
done
# If we didn't find it, then we're done
[ -z "$PMOS_BOOT" ] && return
PMOS_BOOT=$(pretty_dm_path "$PMOS_BOOT")
echo "$PMOS_BOOT"
}
get_partition_type() {
@@ -352,22 +384,24 @@ resize_root_partition() {
parted -f -s "$partition_dev" resizepart 2 100%
kpartx -afs "$partition_dev"
ROOT_PARTITION_RESIZED=1
else
echo "Not resizing root partition ($partition): no free space left"
fi
fi
# Resize the root partition (non-subpartitions). Usually we do not want
# this, except for QEMU devices and non-android devices (e.g.
# PinePhone). For them, it is fine to use the whole storage device and
# so we pass PMOS_FORCE_PARTITION_RESIZE as kernel parameter.
if grep -q PMOS_FORCE_PARTITION_RESIZE /proc/cmdline; then
elif grep -q PMOS_FORCE_PARTITION_RESIZE /proc/cmdline; then
partition_dev="$(echo "$partition" | sed -E 's/p?2$//')"
if has_unallocated_space "$partition_dev"; then
echo "Resize root partition ($partition)"
parted -f -s "$partition_dev" resizepart 2 100%
partprobe
ROOT_PARTITION_RESIZED=1
else
echo "Not resizing root partition ($partition): no free space left"
fi
fi
# Resize the root partition (non-subpartitions) on Chrome OS devices.
# Match $deviceinfo_cgpt_kpart not being empty instead of cmdline
@@ -375,14 +409,19 @@ resize_root_partition() {
# partitioning methods. This also resizes third partition instead of
# second, because these devices have an additional kernel partition
# at the start.
if [ -n "$deviceinfo_cgpt_kpart" ]; then
elif [ -n "$deviceinfo_cgpt_kpart" ]; then
partition_dev="$(echo "$partition" | sed -E 's/p?3$//')"
if has_unallocated_space "$partition_dev"; then
echo "Resize root partition ($partition)"
parted -f -s "$partition_dev" resizepart 3 100%
partprobe
ROOT_PARTITION_RESIZED=1
else
echo "Not resizing root partition ($partition): no free space left"
fi
else
echo "Unable to resize root partition: failed to find qualifying partition"
fi
}
@@ -634,7 +673,7 @@ show_splash() {
# shellcheck disable=SC2154,SC2059
/usr/bin/pbsplash -s /usr/share/pbsplash/pmos-logo-text.svg \
-b "Linux $(uname -r) | $deviceinfo_codename" \
-m "$(printf "$1")" &
-m "$(printf "$1")" >/dev/null &
}
set_framebuffer_mode() {
@@ -57,6 +57,8 @@ echo "This is a security hole! Only use it for debugging, and"
echo "uninstall the debug-shell hook afterwards!"
echo "---"
reconfigure_logging "for debug-shell"
if tty -s; then
echo "Exit the shell to continue booting:"
pmos_shell
@@ -1,5 +1,5 @@
pkgname=postmarketos-mkinitfs-hook-debug-shell
pkgver=0.4.5
pkgver=0.4.6
pkgrel=0
pkgdesc="Root shell in the initramfs (security hole, for debugging only)"
url="https://postmarketos.org"
@@ -17,6 +17,6 @@ package() {
}
sha512sums="
90829cc17d62932730720d6a4d205c9e0093303f6d09865a4d4e83e08677cf4005cf38b02cde546082d60cf97264ddf60b4d76893d0f87e3bda4729bc04a171a 20-debug-shell.sh
c4042dd9d9f9d7d604bfd39016e626e22af898e3ba48beed9d5a50aa62571412c510aec90b16b218938f85df1f09caf7d955c6b9c8e893959242fd9007c9264b 20-debug-shell.sh
845d2eb6ab72c5c1472d65305241ca21dbc26784684e9ae99a180a255f8f7f62123b363d73c642df1f9687106340078311a68a76c123f16829b941bff9151735 20-debug-shell.files
"