17 files changed, 55 insertions, 369 deletions
diff --git a/Jenkinsfile b/Jenkinsfile index 1732307..5b7cf51 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,7 +17,7 @@ pipeline { ISO_BUCKET = 'dist-sayagit-fedora-iso' // Must match the <source path="..."/> in - // repositories/kernel-sp12in.xml. + // repositories/kernel-surface.xml. KERNEL_SURFACE_REPO_URL = 'https://rpm.sayag.it/kernel-sp12in/fedora/45/aarch64' // awscli2 sends CRC32 checksums by default, which B2 rejects. Ask for @@ -68,7 +68,7 @@ spec: // something this repository can produce: the image // installs kernel-surface by name and <ignore>s // Fedora's kernel packages. Its pipeline publishes - // it to rpm.sayag.it, which repositories/kernel-sp12in.xml + // it to rpm.sayag.it, which repositories/kernel-surface.xml // points at directly, so there is nothing to stage // here. Fail now rather than several minutes into // kiwi on an unresolvable package name. @@ -150,8 +150,7 @@ spec: mv "${src}" "${dst}" ls -lh - /s5cmd --endpoint-url "${B2_ENDPOINT}" cp \\ - --content-type "application/x-iso9660-image" \\ + s5cmd --endpoint-url "${B2_ENDPOINT}" cp \\ "${dst}" \\ "s3://${ISO_BUCKET}/fedora/${IMAGE_VERSION}/aarch64/${dst}" ''' @@ -1,13 +1,9 @@ # Fedora KIWI image descriptions, modified to build & launch for Surface Pro 12" Gen 1 - - -**UPD Sep 10 2026:** There has been huge progress made in this project since August! Thanks to kernel patches, pushed onto Linux 7.2 mainstream and [Gentoo overlay](https://github.com/miasvanklei/Gentoo-overlay), most of the previous features which this release lacked (stable suspend on GNOME, accelerometer sensor, dedicated video output, cameras) are now implemented. The project has diverged into [patched kernel](https://sayag.it/fedora-linux-surface-pro-12in/kernel-surface.git) + [libcamera](https://sayag.it/fedora-linux-surface-pro-12in/libcamera.git) builds with an [RPM repo](https://rpm.sayag.it/kernel-sp12in/) publicly available. You can see current state of things in a [feature matrix](#feature-matrix) down below. -  -It is the fork of the original [KIWI image descriptions](https://forge.fedoraproject.org/releng/kiwi-descriptions), modified for launching Fedora Linux 45 Live ISO on Surface Pro 12" Gen 1 (and further installing it on the device). +It is the fork of the original [KIWI image descriptions](https://forge.fedoraproject.org/releng/kiwi-descriptions), modified for launching Fedora Linux Rawhide Live ISO on Surface Pro 12" Gen 1 (and further installing it on the device). I bought this device as I viewed it as a great Linux GNOME tablet, but after several days, many hours of work of trying to do so, I must say that installing a distribution here (and then having it work fine) is a huge pain in the ass. @@ -15,9 +11,9 @@ I bought this device as I viewed it as a great Linux GNOME tablet, but after sev ## How to run -**The compiled ISOs can be downloaded [here](https://dist.sayag.it/fedora/45/aarch64).** +**The compiled ISOs can be downloaded [here](https://dist.sayag.it/surface-pro-12in-ports/fedora/rawhide).** -This KIWI project is built mainly on the base of Fedora Workstation 45 (Pre-release) LiveCD ISO. Trying a stable version (the latest is Fedora 44 at the time of writing this) is possible, but not tested for now. +This KIWI project is built mainly on the base of Fedora Workstation Rawhide LiveCD ISO. Trying a stable version (the latest is Fedora 44 at the time of writing this) is possible, but not tested for now. If you want to compile this image manually, **the build arch must be `aarch64`**. It means that if you are on an `amd64` machine, you would have to use aarch64 instructions emulation tools like `binfmt`. Unfortunately, such a tool will drastically increase the compilation time. @@ -34,47 +30,25 @@ To build this on Fedora Linux: []$ sudo ./kiwi-build --kiwi-file=Fedora.kiwi --image-type=iso --image-profile=Workstation-Live --output-dir ./outdir ``` -## Feature matrix - -| Hardware | State | Nuances | -| --- | --- | --- | -| Keyboard | ✓ | | -| Touchpad | ✓ | | -| Tablet Mode | ✓ | | -| Touchscreen | ✓ | | -| Pen | ✓ | Tested with Surface Slim Pen | -| WiFi | ✓ | 2.4/5 GHz networks | -| Bluetooth | ✓ | | -| Speakers | ✓ | | -| Buttons | ✓ | | -| Suspend | ✓ | `s2idle` tested | -| Hibernate | ? | | -| Sensors | ✓ | Accelerometer works, but light sensor outputs garbage, so adaptive brightness is disabled | -| Battery Status | ✓ | | -| Cameras | ✓ | Front camera -- overexposured areas tend to get green; back camera -- uncalibrated | -| GPU acceleration | ✓ | Video encoding/decoding driver is taken dynamically from a Windows partition | -| USB 3 | ✓ | Video passthrough on hubs (via HDMI) also tested and works | -| DisplayPort out | ✓ | Found issues with suspending while an external monitor is active, where the system freezes | - -## Compromises +## What is left out (for now) * Live CD has to run in RAM, so `rd.live.ram=1` is set for cmdline. Otherwise, at least on my ancient flash drive, it fails to load multiple necessary services, including `polkit`. So, ~5 minutes of loading on USB 2 drive, while screen is not backlit, is to be expected. * No rescue vmlinuz. * No secure boot possible for this ISO for now, as the platform used is `efi` and not `uefi`. * No GRUB auto hidden menu. Trying to have the menu hidden results in system restarting after trying to boot it. -* Hardware video encoding/decoding needs a firmware blob the image is not allowed to ship. The `qcom/vpu/vpu30_p1_s7.mbn` that `linux-firmware` provides is the same codec signed with Qualcomm's SecTools *test* key chain, which a retail Surface's TrustZone rejects -- `qcom_scm_pas_init_image()` fails and the kernel logs `qcom-iris aa00000.video-codec: error -22 initializing firmware`. The production-signed build exists only inside Microsoft's Surface driver package, which grants no redistribution right, so what ships here is the means and not the blob: - * If you kept the Windows ARM64 partition, `surface-video-firmware.service` finds it on the first boot after install and copies `qcvss8380_pa.mbn` out of its DriverStore. Nothing to do. - * If Windows is gone, download the [Surface Pro 12-inch driver pack](https://www.microsoft.com/en-us/download/details.aspx?id=108199) (~500 MB MSI) and run `sudo surface-video-firmware.sh -m /path/to/SurfacePro_12in_*.msi`. - - The kernel's device tree already points `iris` at `/lib/firmware/qcom/x1p42100/Microsoft/Surface12/qcvss8380_pa.mbn`, so the driver picks it up as soon as it is there. -* Explicitly set `s2idle` suspend mode, as `deep` mode did not work properly as of August (when the iso was built without kernel patches). Currently untested if `deep` mode works now. -* No 6 GHz network support (at least my device does not detect mine). -* Adaptive brightness is disabled, as of now the light sensor outputs garbage. +* Hardware video encoding/decoding needs a firmware blob the image cannot ship. The `qcom/vpu/vpu30_p1_s7.mbn` that `linux-firmware` provides is signed with Qualcomm's SecTools *test* key chain, which a retail Surface's TrustZone rejects -- `qcom_scm_pas_init_image()` fails and the kernel logs `qcom-iris aa00000.video-codec: error -22 initializing firmware`. The production-signed build of the same firmware ships with Windows, so if you kept the Windows ARM64 partition, copy `qcvss8380_pa.mbn` out of `/path/to/mounted/windows/drive/Windows/System32/DriverStore/FileRepository/qcdx8380.inf_arm64_*/` into `/lib/firmware/qcom/x1p42100/Microsoft/Surface12/`. The kernel's device tree already points `iris` at that path. +* Suspend on Snapdragon X is still very unstable. No deep sleep is available, so `mem_sleep_default=s2idle` was set. Even that leads to compromises as suspending via GNOME results in hard freeze, so the default power button behavior was changed to `interactive` and should not be changed back to `suspend`. ## Image variants Please look at [`VARIANTS`](VARIANTS.md) for details on the available configurations that can be built. +## CI information + +This project is yet to adapt CI, but it is coming. + +For now the images are being built and tested manually on my personal Surface Pro 12" Gen 1 (16 GB RAM, 512 GB storage). + ## Licensing This is free software: you can redistribute it and/or modify diff --git a/components/boot.xml b/components/boot.xml index 11b48a5..36d8ffa 100644 --- a/components/boot.xml +++ b/components/boot.xml @@ -50,7 +50,7 @@ set for this board (device tree, SAM RTC, SAM suspend workaround, CAMSS/CSI-2, remoteproc attach, clk/PCI/irqchip fixes). It is built from the sibling ../kernel-surface checkout and comes from the repository - repositories/kernel-sp12in.xml adds. + repositories/kernel-surface.xml adds. It is a single package (kernel image, every module, device trees) and Provides kernel, kernel-core, kernel-modules, kernel-modules-core and @@ -436,13 +436,10 @@ fi # Surface Pro 12" customizations #-------------------------------------- -install -Dm644 /tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/yum.repos.d/kernel-sp12in.repo \ - /etc/yum.repos.d/kernel-sp12in.repo - # Device tree. kernel-surface compiles the patched dts in-tree and installs the -# result twice: into its own module tree (dtb/qcom, from dtbs_install) and into -# /usr/lib/surface-dtb/<kver>/. The latter is the master copy -# 60-surface-dtb.install re-stages into a kernel that shipped without one, +# result twice: into its own module tree (dtb/qcom, from dtbs_install) and +# version-independently into /usr/lib/surface-dtb. The latter is the master copy +# 60-surface-dtb.install re-stages into each new kernel's module tree on update, # which is the only reason the image no longer carries a prebuilt blob of its # own -- the description installs kernel-surface by name and <ignore>s Fedora's # kernel packages, so the package is always there. @@ -456,12 +453,9 @@ install -Dm644 /tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/yum.repos.d/ke # module-tree copy, anything keyed off /usr/lib/modules/$kver/dtb (including the # anaconda post-script) finds nothing and silently does nothing. dtb_name=x1p42100-microsoft-sp12in.dtb -# One directory per kernel version under /usr/lib/surface-dtb: kernel-surface is -# installonly, so nothing it owns can be version-unqualified. Only one release is -# ever installed at this point in the build, but glob anyway rather than assume. -dtb_src=$(ls -1 /usr/lib/surface-dtb/*/"$dtb_name" 2>/dev/null | sort -V | tail -n1) -if [[ -z "$dtb_src" ]]; then - printf 'Error: no %s under /usr/lib/surface-dtb/, so kernel-surface (built from ../kernel-surface) is not installed.\n' "$dtb_name" >&2 +dtb_src="/usr/lib/surface-dtb/$dtb_name" +if [[ ! -f "$dtb_src" ]]; then + printf 'Error: %s is missing, so kernel-surface (built from ../kernel-surface) is not installed.\n' "$dtb_src" >&2 exit 1 fi install -Dm644 "$dtb_src" "/usr/lib/modules/$kver/dtb/qcom/$dtb_name" @@ -644,22 +638,6 @@ install -Dm644 /tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/systemd/system # hexagonrpc.service in through the drop-in above. systemctl enable hexagonrpc.service -# Fedora's SELinux policy has no qipcrtr_socket permissions for -# iiosensorproxy_t; the libssc backend needs them to probe the QRTR bus, and -# without them the daemon exits with "No sensors or missing kernel drivers". -# Compile and install the local module that grants them (see the .te for -# details). checkmodule/semodule_package come from checkpolicy; it stays -# installed because removing it takes policycoreutils-python-utils -# (semanage, audit2allow) with it. -dnf install -y checkpolicy -install -Dm644 /tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/local/share/selinux/iio-qipcrtr.te \ - /usr/local/share/selinux/iio-qipcrtr.te -checkmodule -M -m -o /usr/local/share/selinux/iio-qipcrtr.mod \ - /usr/local/share/selinux/iio-qipcrtr.te -semodule_package -o /usr/local/share/selinux/iio-qipcrtr.pp \ - -m /usr/local/share/selinux/iio-qipcrtr.mod -semodule -i /usr/local/share/selinux/iio-qipcrtr.pp - # Cameras (msm/camss). Nothing has to be wired up at boot. libcamera's "simple" # pipeline handler claims qcom-camss and builds the media graph itself in # configure(), including flipping the csiphy -> msm_csid0 link between the rear @@ -692,36 +670,23 @@ case "${libcamera_nevra}" in ;; esac -# Hardware video decode needs firmware this image is not allowed to carry. The -# qcom/vpu/vpu30_p1_s7.mbn in linux-firmware is the same codec signed with -# Qualcomm's SecTools test keys, which a retail Surface's TrustZone rejects, and -# the production-signed build exists only inside Microsoft's Surface driver -# package, under terms that grant no redistribution right. -# -# So the image ships the means rather than the blob: a script that copies it out -# of a Windows install the owner already has a licence for, and a unit that runs -# that once on a dual-boot machine. Where Windows is gone, the script says which -# driver pack to download and how to point it at one. -dnf install -y msitools -install -Dm755 /tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/local/bin/surface-video-firmware.sh \ - /usr/local/bin/surface-video-firmware.sh -install -Dm644 /tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/systemd/system/surface-video-firmware.service \ - /etc/systemd/system/surface-video-firmware.service -systemctl enable surface-video-firmware.service - +# Suspend on Snapdragon is still very unstable. This is the reason why +# 'mem_sleep_default=s2idle' is set explicitly in the cmdline as 'deep' mode +# does not function at all. +# Even then, suspending via gnome settings daemon results in hard freeze. +# This is why: +# logind behavior is kept intact with suspend behavior. +# gnome default power button behavior was replaced with 'interactive'. install -Dm644 /tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/systemd/logind.conf.d/60-surface-power-key.conf \ /etc/systemd/logind.conf.d/60-surface-power-key.conf - -# Ambient light sensor seems to go nuts after I fixed iio-sensor-proxy. Turning -# it off for now. -install -Dm644 /tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/dconf/db/local.d/00-als \ - /etc/dconf/db/local.d/00-als +install -Dm644 /tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/dconf/db/local.d/00-power-button \ + /etc/dconf/db/local.d/00-power-button install -Dm644 /tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/dconf/profile/user \ /etc/dconf/profile/user dconf update -restorecon -Rv /usr /lib /etc/systemd /etc/dconf /etc/udev/rules.d /etc/yum.repos.d +restorecon -Rv /usr /lib /etc/systemd /etc/dconf /etc/udev/rules.d #====================================== # Set the WSL name for ELN diff --git a/docs/Fedora45Progress.jpg b/docs/Fedora45Progress.jpg Binary files differdeleted file mode 100644 index 0f4a22b..0000000 --- a/docs/Fedora45Progress.jpg +++ /dev/null diff --git a/iio-qipcrtr.pp b/iio-qipcrtr.pp Binary files differdeleted file mode 100644 index 9eedadb..0000000 --- a/iio-qipcrtr.pp +++ /dev/null diff --git a/iio-qipcrtr.te b/iio-qipcrtr.te deleted file mode 100644 index 5ea7434..0000000 --- a/iio-qipcrtr.te +++ /dev/null @@ -1,20 +0,0 @@ - -module iio-qipcrtr 1.0; - -require { - type iiosensorproxy_t; - type systemd_userdbd_t; - type xdm_var_run_t; - class sock_file read; - class qipcrtr_socket { create getattr getopt setopt }; -} - -#============= iiosensorproxy_t ============== - -#!!!! This avc is allowed in the current policy -allow iiosensorproxy_t self:qipcrtr_socket { create getattr getopt setopt }; - -#============= systemd_userdbd_t ============== - -#!!!! This avc is allowed in the current policy -allow systemd_userdbd_t xdm_var_run_t:sock_file read; diff --git a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/dconf/db/local.d/00-als b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/dconf/db/local.d/00-power-button index ae14928..1b69eab 100644 --- a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/dconf/db/local.d/00-als +++ b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/dconf/db/local.d/00-power-button @@ -1,2 +1,2 @@ [org/gnome/settings-daemon/plugins/power] -ambient-enabled=false +power-button-action='interactive' diff --git a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/systemd/system/hexagonrpc.service b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/systemd/system/hexagonrpc.service index 4ec7250..2e3cf82 100644 --- a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/systemd/system/hexagonrpc.service +++ b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/systemd/system/hexagonrpc.service @@ -1,9 +1,8 @@ [Unit] Description=HexagonRPC Service -ConditionPathExists=/dev/fastrpc-adsp [Service] -ExecStart=/usr/local/bin/hexagonrpcd -f /dev/fastrpc-adsp -d adsp -s +ExecStart=/usr/local/bin/hexagonrpcd -f /dev/fastrpc-adsp-secure -s Restart=on-failure [Install] diff --git a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/systemd/system/surface-video-firmware.service b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/systemd/system/surface-video-firmware.service deleted file mode 100644 index 5c83962..0000000 --- a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/systemd/system/surface-video-firmware.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Install Surface Pro 12in video codec firmware from a Windows partition -ConditionPathExists=!/lib/firmware/qcom/x1p42100/Microsoft/Surface12/qcvss8380_pa.mbn -After=local-fs.target - -[Service] -Type=oneshot -RemainAfterExit=yes -ExecStart=/usr/local/bin/surface-video-firmware.sh - -[Install] -WantedBy=multi-user.target diff --git a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/udev/rules.d/61-sensors-surface-pro-12-inch.rules b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/udev/rules.d/61-sensors-surface-pro-12-inch.rules index 82051c5..e6ddb1f 100644 --- a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/udev/rules.d/61-sensors-surface-pro-12-inch.rules +++ b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/udev/rules.d/61-sensors-surface-pro-12-inch.rules @@ -1,3 +1 @@ -ACTION=="add|change", SUBSYSTEM=="misc", KERNEL=="fastrpc-adsp*", ENV{ACCEL_MOUNT_MATRIX}="-1, 0, 0; 0, -1, 0; 0, 0, 1" -SUBSYSTEM=="misc", KERNEL=="fastrpc-adsp*", ENV{IIO_SENSOR_PROXY_TYPE}+="ssc-accel" -ACTION=="add", SUBSYSTEM=="misc", KERNEL=="fastrpc-adsp", TAG+="systemd", ENV{SYSTEMD_WANTS}+="hexagonrpc.service" +ACTION=="add|change", SUBSYSTEM=="misc", KERNEL=="fastrpc-adsp-secure", ENV{ACCEL_MOUNT_MATRIX}="-1, 0, 0; 0, -1, 0; 0, 0, 1" diff --git a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/yum.repos.d/kernel-sp12in.repo b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/yum.repos.d/kernel-sp12in.repo deleted file mode 100644 index 24fe9f3..0000000 --- a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/etc/yum.repos.d/kernel-sp12in.repo +++ /dev/null @@ -1,7 +0,0 @@ -[kernel-sp12in] -name=kernel-sp12in for Fedora $releasever - $basearch -baseurl=https://rpm.sayag.it/kernel-sp12in/fedora/$releasever/$basearch/ -enabled=1 -priority=1 -gpgcheck=0 -metadata_expire=6h diff --git a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/lib/kernel/install.d/60-surface-dtb.install b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/lib/kernel/install.d/60-surface-dtb.install index 7622406..2dadac5 100644 --- a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/lib/kernel/install.d/60-surface-dtb.install +++ b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/lib/kernel/install.d/60-surface-dtb.install @@ -8,30 +8,23 @@ KVER="$2" DTB_NAME=x1p42100-microsoft-sp12in.dtb DEST="/usr/lib/modules/${KVER}/dtb/qcom/${DTB_NAME}" -# The master copies come from kernel-surface: it builds the dtb in-tree from the +# The master copy comes from kernel-surface: it builds the dtb in-tree from the # patched dts and installs it under /usr/lib/surface-dtb, deliberately outside -# any /usr/lib/modules/<kver>, so it can be re-staged into a kernel that ships -# no device tree of its own -- a stock Fedora one. -# -# One directory per kernel version, because kernel-surface is installonly and -# rpm will not let two installed releases own one unqualified path once the file -# differs. They are all the same board, so the highest version is as good a -# choice as any, and is the one most likely to carry recent fixes. -SRC=$(ls -1 /usr/lib/surface-dtb/*/"${DTB_NAME}" 2>/dev/null | sort -V | tail -n1) +# any /usr/lib/modules/<kver>, so it can be re-staged into any kernel installed +# alongside it. +SRC="/usr/lib/surface-dtb/${DTB_NAME}" +[ -f "${SRC}" ] || SRC="" case "${COMMAND}" in add) - # kernel-surface ships its own dtb through dtbs_install, and that - # one is the release-matched copy. Leave it alone; the master is - # only for kernels that arrived without one. - if [ -f "${DEST}" ]; then - exit 0 - fi - # Neither means there is nothing this board can boot with, so say - # so rather than failing silently three steps later in the boot - # loader. + # No master and no dtb already in this kernel's tree means there is + # nothing this board can boot with, so say so rather than failing + # silently three steps later in the boot loader. if [ -z "${SRC}" ]; then - echo "60-surface-dtb: no ${DTB_NAME} under /usr/lib/surface-dtb" >&2 + if [ -f "${DEST}" ]; then + exit 0 + fi + echo "60-surface-dtb: no ${DTB_NAME} in /usr/lib/surface-dtb" >&2 exit 1 fi mkdir -p "$(dirname ${DEST})" diff --git a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/lib/kernel/install.d/95-surface-dtb-patch.install b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/lib/kernel/install.d/95-surface-dtb-patch.install index 65b8745..f0314b0 100644 --- a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/lib/kernel/install.d/95-surface-dtb-patch.install +++ b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/lib/kernel/install.d/95-surface-dtb-patch.install @@ -38,10 +38,9 @@ BOOT_ROOT="${KERNEL_INSTALL_BOOT_ROOT:-/boot}" # (or was removed). DTB_SRC="/usr/lib/modules/${KVER}/dtb/${DTB_REL}" if [ ! -f "$DTB_SRC" ]; then - # One directory per kernel version under here; see 60-surface-dtb.install. - DTB_SRC=$(ls -1 /usr/lib/surface-dtb/*/"$DTB_NAME" 2>/dev/null | sort -V | tail -n1) + DTB_SRC="/usr/lib/surface-dtb/$DTB_NAME" fi -[ -n "$DTB_SRC" ] && [ -f "$DTB_SRC" ] || exit 0 +[ -f "$DTB_SRC" ] || exit 0 # The boot loader reads the dtb from the boot filesystem, not the module tree install -Dm644 "$DTB_SRC" "${BOOT_ROOT}/dtb-${KVER}/${DTB_REL}" diff --git a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/local/bin/surface-video-firmware.sh b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/local/bin/surface-video-firmware.sh deleted file mode 100755 index 35dfdf1..0000000 --- a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/local/bin/surface-video-firmware.sh +++ /dev/null @@ -1,183 +0,0 @@ -#!/bin/bash -# Surface Pro 12" (Snapdragon X1P-42-100): install the video codec firmware. -# -# The iris video codec needs firmware TrustZone will accept. linux-firmware's -# qcom/vpu/vpu30_p1_s7.mbn is the same codec signed with Qualcomm's SecTools -# *test* key chain, which a retail Surface rejects: -# -# qcom-iris aa00000.video-codec: error -22 initializing firmware qcom/vpu/vpu30_p1_s7.mbn -# -# The production-signed build ships only inside Microsoft's Surface driver -# package, which grants no redistribution right, so the image cannot carry it. -# What it can do is copy it out of a Windows install the owner already has a -# licence for, or out of a driver pack they downloaded themselves. This script -# does the copying; it never fetches anything the caller did not ask for. -# -# Usage: surface-video-firmware.sh [-m MSI] [-u URL] [-n] -# -# (no options) look for a Windows partition on this machine and copy the -# firmware out of its DriverStore. No network access. -# -m MSI extract from a Surface driver pack already on disk -# -u URL download a driver pack and extract from that -# -n say what would happen, change nothing -# -# The driver pack is a ~500 MB MSI from -# -# https://www.microsoft.com/en-us/download/details.aspx?id=108199 -# -# There is no stable direct link to hardcode: the Download Center hands out -# per-session URLs and the file name carries the driver release, so -u takes -# the URL the browser was given rather than guessing one that would rot. - -set -euo pipefail - -FW_DIR=/lib/firmware/qcom/x1p42100/Microsoft/Surface12 -BLOB=qcvss8380_pa.mbn -DRIVERSTORE=Windows/System32/DriverStore/FileRepository -PAGE=https://www.microsoft.com/en-us/download/details.aspx?id=108199 - -msi="" -url="" -dry_run=false - -while getopts ':m:u:nh' opt; do - case "${opt}" in - m) msi=${OPTARG} ;; - u) url=${OPTARG} ;; - n) dry_run=true ;; - h) sed -n '2,31p' "${BASH_SOURCE[0]}"; exit 0 ;; - *) echo "unknown option -${OPTARG}" >&2; exit 2 ;; - esac -done - -log() { printf 'surface-video-firmware: %s\n' "$*"; } -die() { printf 'surface-video-firmware: %s\n' "$*" >&2; exit 1; } - -if [[ -f "${FW_DIR}/${BLOB}" ]]; then - log "${FW_DIR}/${BLOB} is already installed" - exit 0 -fi - -[[ ${EUID} -eq 0 ]] || die "must run as root" - -cleanup_dirs=() -cleanup_mounts=() -cleanup() { - local m d - for m in ${cleanup_mounts[@]+"${cleanup_mounts[@]}"}; do - mountpoint -q "${m}" && umount "${m}" || true - done - for d in ${cleanup_dirs[@]+"${cleanup_dirs[@]}"}; do - rm -rf "${d}" || true - done -} -trap cleanup EXIT - -install_blob() { - local src=$1 - if [[ ${dry_run} == true ]]; then - log "would install ${src} as ${FW_DIR}/${BLOB}" - return 0 - fi - - install -Dm644 "${src}" "${FW_DIR}/${BLOB}" - log "installed ${FW_DIR}/${BLOB}" - - # The driver only asks for its firmware while probing, so it has to be - # reloaded to pick this up. It refuses while a decode session holds it, - # which is why a failure here is only worth a note. - if lsmod | grep -q '^qcom_iris'; then - if modprobe -r qcom_iris 2>/dev/null && modprobe qcom_iris 2>/dev/null; then - log "reloaded qcom_iris" - else - log "could not reload qcom_iris; reboot to start using the firmware" - fi - fi -} - -# Everything below hands find(1) the bare file name rather than a full path: -# the DriverStore directory carries a per-build hash, and the layout inside an -# extracted MSI is not documented anywhere worth trusting. -find_blob() { - find "$1" -type f -name "${BLOB}" -print -quit 2>/dev/null -} - -from_windows() { - local dev fstype part_mnt mnt found - - while read -r dev fstype part_mnt; do - [[ ${fstype} == ntfs* ]] || continue - - if [[ -n ${part_mnt} ]]; then - mnt=${part_mnt} - else - mnt=$(mktemp -d) - cleanup_dirs+=("${mnt}") - if ! mount -t ntfs3 -o ro,noatime "/dev/${dev}" "${mnt}" 2>/dev/null && - ! mount -o ro,noatime "/dev/${dev}" "${mnt}" 2>/dev/null; then - log "/dev/${dev}: could not mount read-only, skipping" - log "/dev/${dev}: if Windows is hibernated, shut it down fully and retry" - continue - fi - cleanup_mounts+=("${mnt}") - fi - - [[ -d "${mnt}/${DRIVERSTORE}" ]] || continue - - found=$(find_blob "${mnt}/${DRIVERSTORE}") - if [[ -n ${found} ]]; then - log "found ${BLOB} on /dev/${dev}" - install_blob "${found}" - return 0 - fi - log "/dev/${dev}: a Windows install, but no ${BLOB} in its DriverStore" - done < <(lsblk -rno NAME,FSTYPE,MOUNTPOINT) - - return 1 -} - -from_msi() { - local pack=$1 work found - - command -v msiextract >/dev/null || die "msiextract is missing; install msitools" - - work=$(mktemp -d) - cleanup_dirs+=("${work}") - - log "extracting ${pack}" - ( cd "${work}" && msiextract "${pack}" >/dev/null ) - - found=$(find_blob "${work}") - [[ -n ${found} ]] || die "no ${BLOB} inside ${pack}; is it the Surface Pro 12in driver pack?" - - log "found ${BLOB} in the driver pack" - install_blob "${found}" -} - -if [[ -n ${url} ]]; then - dl=$(mktemp -d) - cleanup_dirs+=("${dl}") - msi="${dl}/driverpack.msi" - log "downloading ${url}" - curl -fL --retry 3 --progress-bar -o "${msi}" "${url}" -fi - -if [[ -n ${msi} ]]; then - [[ -f ${msi} ]] || die "${msi} does not exist" - from_msi "${msi}" - exit 0 -fi - -if from_windows; then - exit 0 -fi - -# Nothing found, and nothing was asked for. Not an error: most of the time this -# is a machine with no Windows left on it, and the only thing left to do is say -# how to finish the job by hand. -log "no Windows install on this machine carries ${BLOB}" -log "hardware video decode stays off until it is installed. To finish by hand:" -log " 1. download the Surface Pro 12in driver pack (~500 MB) from" -log " ${PAGE}" -log " 2. sudo surface-video-firmware.sh -m /path/to/SurfacePro_12in_*.msi" -exit 0 diff --git a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/local/share/selinux/iio-qipcrtr.te b/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/local/share/selinux/iio-qipcrtr.te deleted file mode 100644 index b3be8fb..0000000 --- a/root/tmp/SayaAndy/surface-pro-12-inch-linux-fedora/usr/local/share/selinux/iio-qipcrtr.te +++ /dev/null @@ -1,19 +0,0 @@ -module iio-qipcrtr 1.0; - -# Fedora's policy grants iiosensorproxy_t no qipcrtr_socket permissions at -# all: the class exists but nothing allows it, because upstream -# iio-sensor-proxy talks to sensors over IIO and never needed QRTR. The SSC -# backend libssc brings in here reaches the Qualcomm Sensor Core over the -# QRTR bus (libssc probes AF_QIPCRTR first; the fastrpc/hexagonrpcd path is -# what actually serves this board, but the probe alone gets the daemon -# killed by "QRTR bus unavailable" + "No sensors" without these perms). -# -# Hand-written rather than audit2allow'd per-incident: create/bind/... is -# the full client lifecycle, so a policy reload or libssc update cannot -# surface a new denied perm one at a time. -require { - type iiosensorproxy_t; - class qipcrtr_socket { create bind connect read write getattr setattr getopt setopt shutdown }; -} - -allow iiosensorproxy_t self:qipcrtr_socket { create bind connect read write getattr setattr getopt setopt shutdown }; diff --git a/surface-editbootconfig.sh b/surface-editbootconfig.sh index e6cc67c..a426645 100755 --- a/surface-editbootconfig.sh +++ b/surface-editbootconfig.sh @@ -27,12 +27,12 @@ esac dtb_name=x1p42100-microsoft-sp12in.dtb -# The working directory is the image root, so this is kernel-surface's own copy, -# under a directory named for the kernel version because that package is -# installonly. config.sh has already failed the build if it is not there. -dtb_src=$(ls -1 usr/lib/surface-dtb/*/"${dtb_name}" 2>/dev/null | sort -V | tail -n1) -if [[ -z "${dtb_src}" ]]; then - echo "surface-editbootconfig: no ${dtb_name} under usr/lib/surface-dtb/ in the image root" >&2 +# The working directory is the image root, so this is kernel-surface's own +# version-independent copy. config.sh has already failed the build if the +# package did not provide it. +dtb_src="usr/lib/surface-dtb/${dtb_name}" +if [[ ! -f "${dtb_src}" ]]; then + echo "surface-editbootconfig: ${dtb_src} not found in the image root" >&2 exit 1 fi |