thinkpad-x13s: bump to 6.6-rcX; support trixie/sid/mantis userspace sans PPA

- This requires https://github.com/armbian/firmware/pull/65
- thinkpad-x13s: workaround ubuntu's pd-mapper only starting on "-laptop" kernels
- thinkpad-x13s: add fprintd and pam
- thinkpad-x13s: throws warnings about missing userspace if not trixie/sid/mantic
- thinkpad-x13s: split hooks into functions
- thinkpad-x13s: enable touchscreen hack via udev
- thinkpad-x13s: use override, not separate service, for systemd settage of BT public-addr
- thinkpad-x13s: "handle" alsa-ucm-conf by simply overwriting with fixed version
- thinkpad-x13s: update .config
  - according to 0dbdb29bc4
- thinkpad-x13s: bump to 6.6-rc4; add more cmdline params
  - add a bunch of tricks I learned from jhovold's talk
  - update .config, no changes
- thinkpad-x13s: bump to steev's lenovo-x13s-v6.6.0-rc5 - update .config, no changes
- thinkpad-x13s: bump to steev's lenovo-x13s-v6.6.0-rc5
- thinkpad-x13s: trixie is missing fprintd/libpam-fprintd, skip for now if trixie
- thinkpad-x13s: set `UEFI_MOUNT_POINT_SKIP_FSTAB=yes` (otherwise hangs waiting for it, dunno why)
This commit is contained in:
Ricardo Pardini 2023-10-06 14:06:30 +02:00 committed by Igor
parent bba856bb57
commit 4d9cae0645
2 changed files with 501 additions and 275 deletions

View File

@ -6,53 +6,126 @@ declare -g KERNEL_TARGET="sc8280xp"
declare -g BOOT_LOGO=desktop
# This board boots via EFI/Grub, but requires a DTB to be passed, from Grub, to the Kernel.
declare -g GRUB_CMDLINE_LINUX_DEFAULT="efi=noruntime clk_ignore_unused pd_ignore_unused"
declare -g BOOT_FDT_FILE="qcom/sc8280xp-lenovo-thinkpad-x13s.dtb"
enable_extension "grub-with-dtb" # important, puts the whole DTB handling in place.
###########################################################################################################
# Absolutely watch this video https://www.youtube.com/watch?v=qffWt4o334Y - jhovold explains it all there.
# @TODO list
# - cleanup the .config using jhovold's defconfig.
# - consider dropping steev's kernel in favor of jhovold's.
# - rework the initramfs firmware/modules required, according to jhovold's defconfig-commit-msg instructions
###########################################################################################################
# Userspace TO-DO:
# - (mantic/others?) hangs waiting for the EFI partition via UUID, why? [yeah WHY?!]
# - deploy fprintd/libpam-fprintd (sic) for fingerprint authentication [done]
# - (ubuntu, mantic for sure): protection-domain-mapper's pd-mapper.service has a condition on "-laptop" kernel, use override to get rid of it [done]
# The 6.4 branch is incompatible with x13s Concept's alsa-ucm-conf package, so keep it at 6.3.y for now.
function post_family_config_branch_sc8280xp__steevs_63y_kernel() {
display_alert "Setting up steev's kernel for" "${BOARD}" "warn"
declare -g KERNEL_MAJOR_MINOR="6.3" # Major and minor versions of this kernel.
declare -g KERNELBRANCH='branch:lenovo-x13s-linux-6.3.y'
# This board boots via EFI/Grub, but requires a DTB to be passed, from Grub, to the Kernel.
declare -g GRUB_CMDLINE_LINUX_DEFAULT="efi=noruntime clk_ignore_unused pd_ignore_unused arm64.nopauth iommu.passthrough=0 iommu.strict=0 pcie_aspm.policy=powersupersave"
declare -g BOOT_FDT_FILE="qcom/sc8280xp-lenovo-thinkpad-x13s.dtb"
declare -g UEFI_MOUNT_POINT_SKIP_FSTAB="yes" # If we leave the /boot/efi in fstab, systemd hangs waiting for it. @TODO why?
enable_extension "grub-with-dtb" # important, puts the whole DTB handling in place.
# Use the full firmware, complete linux-firmware plus Armbian's
declare -g BOARD_FIRMWARE_INSTALL="-full"
# The 6.4 branch is incompatible with x13s Concept's alsa-ucm-conf package, so keep it at 6.3.y for now. @TODO what about 6.6
function post_family_config_branch_sc8280xp__steevs_66y_kernel() {
declare -g KERNEL_MAJOR_MINOR="6.6" # Major and minor versions of this kernel.
declare -g KERNELBRANCH='branch:lenovo-x13s-v6.6.0-rc5'
declare -g KERNELSOURCE='https://github.com/steev/linux.git'
display_alert "Set up steev's kernel ${KERNELBRANCH} for" "${BOARD}" "info"
}
function post_family_tweaks_bsp__thinkpad_x13s_bsp_stuff() {
function x13s_is_userspace_supported() {
[[ "${RELEASE}" == "trixie" || "${RELEASE}" == "sid" || "${RELEASE}" == "mantic" ]] && return 0
return 1
}
# https://wiki.debian.org/InstallingDebianOn/Thinkpad/X13s
function post_family_config__debian_now_has_userspace_for_the_x13s() {
if ! x13s_is_userspace_supported; then
if [[ "${RELEASE}" != "" ]]; then
display_alert "Missing userspace for ${BOARD}" "${RELEASE} does not have the userspace necessary to support the ${BOARD}" "warn"
fi
return 0
fi
display_alert "Setting up extra Debian packages for ${BOARD}" "${RELEASE}///${BOARD}" "info"
add_packages_to_image "bluez" "bluetooth" # for bluetooth stuff
add_packages_to_image "protection-domain-mapper" # for charging; see https://packages.ubuntu.com/protection-domain-mapper and https://packages.debian.org/protection-domain-mapper
add_packages_to_image "qrtr-tools" # for charging; see https://packages.ubuntu.com/qrtr-tools and https://packages.debian.org/qrtr-tools
add_packages_to_image "alsa-ucm-conf" # for audio; see https://packages.ubuntu.com/alsa-ucm-conf and https://packages.debian.org/alsa-ucm-conf - we need 1.2.10 + patches, see below
add_packages_to_image "acpi" # general ACPI support
add_packages_to_image "zstd" # for zstd compression of initrd
# Trixie, as of 2023-10-13, is missing fprintd and libpam-fprintd; see https://tracker.debian.org/pkg/fprintd and https://tracker.debian.org/pkg/libpam-fprintd
# @TODO: check again later, and remove this if it's there
if [[ "${RELEASE}" != "trixie" ]]; then
add_packages_to_image "fprintd" # for fingerprint reader; see https://packages.ubuntu.com/fprintd and https://packages.debian.org/fprintd
add_packages_to_image "libpam-fprintd" # for fingerprint reader PAM support; see https://packages.ubuntu.com/libpam-fprintd and https://packages.debian.org/libpam-fprintd
fi
# Also needed, not listed here:
# - mesa > 23.1.5; see https://packages.ubuntu.com/mesa-vulkan-drivers and https://packages.debian.org/mesa-vulkan-drivers
}
# Distros don't carry the necessary alsa-ucm-conf files.
# We need https://github.com/alsa-project/alsa-ucm-conf/pull/335
# Specifically https://github.com/Srinivas-Kandagatla/alsa-ucm-conf.git branch x13s-volume-fixes
# And specifically SHA1 e8c3e7792336e9f68aa560db8ad19ba06ba786bb -- it has been force pushed a few times
# As quick-n-dirty solution, we dump the whole contents of that branch on top of the distro's alsa-ucm-conf.
# This means the fixes will be lost if package is updated, so we apt-mark it to hold.
# Also means that this will break when ucm package is actually updated, so we can remove this when it is upstreamed.
function pre_customize_image__x13s_debian_ucm_hack_via_patch() {
if ! x13s_is_userspace_supported; then
return 0
fi
display_alert "Fixing alsa-ucm-conf for ${BOARD}" "${RELEASE}///${BOARD}" "info"
(
cd "${SDCARD}/usr/share/alsa"
curl -L "https://github.com/Srinivas-Kandagatla/alsa-ucm-conf/archive/refs/heads/x13s-volume-fixes.tar.gz" | tar xzf - --strip-components=1
)
chroot_sdcard "apt-mark hold alsa-ucm-conf"
}
function post_family_tweaks_bsp__thinkpad_x13s_bsp_bluetooth_addr() {
### The bluetooth does not have a public MAC address set in DT, and BT won't start without one.
### Create a systemd service to set it at boot, and enable it; use the same address used by Ubuntu's x13s Concept project.
display_alert "Adding to bsp-cli" "${BOARD}: systemd service for bluetooth public address init" "info"
add_file_from_stdin_to_bsp_destination "/etc/systemd/system/set-bluetooth-address.service" <<- 'EOD'
[Unit]
Description=Set Bluetooth Address for x13s
After=bluetooth.target
### Use a systemd override to hook up setting a public-addr before starting bluetoothd
declare random_mac_address="" # would be much better to rnd mac on board-side though
random_mac_address=$(printf '02:%02X:%02X:%02X:%02X:%02X' $((RANDOM % 256)) $((RANDOM % 256)) $((RANDOM % 256)) $((RANDOM % 256)) $((RANDOM % 256)))
display_alert "Adding systemd override for bluetooth public address init" "${BOARD} :: bt mac ${random_mac_address}" "info"
add_file_from_stdin_to_bsp_destination "/etc/systemd/system/bluetooth.service.d/override.conf" <<- EOD
[Service]
Type=oneshot
ExecStart=/usr/bin/btmgmt public-addr AD:5A:00:F0:FD:8C
[Install]
WantedBy=multi-user.target
ExecStartPre=/bin/bash -c 'sleep 5 && yes | btmgmt public-addr ${random_mac_address}'
EOD
}
display_alert "Adding to bsp-cli" "${BOARD}: postinst for bluetooth service" "info"
# Define a function to be run board-side during postinst of the BSP
postinst_functions+=("board_side_x13s_bsp_cli_enable_set_bluetooth_address_service") # add to the postinst function list
function board_side_x13s_bsp_cli_enable_set_bluetooth_address_service() {
systemctl --no-reload enable set-bluetooth-address.service
}
function post_family_tweaks_bsp__thinkpad_x13s_bsp_always_start_pdmapper() {
### (At least) Ubuntu's version of protection-domain-mapper's pd-mapper.service has a kernel condition.
### On Debian, this does not hurt.
### Remove it using a systemd override.
add_file_from_stdin_to_bsp_destination "/etc/systemd/system/pd-mapper.service.d/override.conf" <<- EOD
[Unit]
Description=Qualcomm PD mapper service (always starts)
ConditionKernelVersion=
EOD
}
## WAIT FOR 6.5.y ## ## Hack in udev so touchscreen can work - from https://github.com/ironrobin/x13s-alarm/tree/trunk/x13s-touchscreen-udev
## WAIT FOR 6.5.y ## display_alert "Adding to bsp-cli" "${BOARD}: udev for touchscreen bind" "info"
## WAIT FOR 6.5.y ## add_file_from_stdin_to_bsp_destination "/usr/lib/udev/rules.d/72-x13s-touchscreen.rules" <<- 'EOD'
## WAIT FOR 6.5.y ## ACTION=="add" \
## WAIT FOR 6.5.y ## , RUN+="/bin/bash -c 'echo 4-0010 > /sys/bus/i2c/drivers/i2c_hid_of/bind'"
## WAIT FOR 6.5.y ## EOD
function post_family_tweaks_bsp__thinkpad_x13s_bsp_touchscreen_udev_unbind_i2c_hid_hack() {
## Hack in udev so touchscreen can work - from https://github.com/ironrobin/x13s-alarm/tree/trunk/x13s-touchscreen-udev
display_alert "Adding to bsp-cli" "${BOARD}: udev for touchscreen bind" "info"
add_file_from_stdin_to_bsp_destination "/usr/lib/udev/rules.d/72-x13s-touchscreen.rules" <<- 'EOD'
ACTION=="add" \
, RUN+="/bin/bash -c 'echo 4-0010 > /sys/bus/i2c/drivers/i2c_hid_of/bind'"
EOD
}
##
## Include certain firmware in the initrd
##
##
## Include certain firmware in the initrd
##
function post_family_tweaks_bsp__thinkpad_x13s_bsp_firmware_in_initrd() {
display_alert "Adding to bsp-cli" "${BOARD}: firmware in initrd" "info"
declare file_added_to_bsp_destination # will be filled in by add_file_from_stdin_to_bsp_destination
add_file_from_stdin_to_bsp_destination "/etc/initramfs-tools/hooks/x13s-firmware" <<- 'FIRMWARE_HOOK'
@ -63,13 +136,17 @@ function post_family_tweaks_bsp__thinkpad_x13s_bsp_stuff() {
add_firmware "${f#/lib/firmware/}"
done
add_firmware "qcom/a660_sqe.fw" # extra one for dpu
add_firmware "qcom/a690_gmu.bin" # extra one for gpu
add_firmware "qcom/a660_gmu.bin" # extra one for gpu
add_firmware "qcom/a690_gmu.bin" # extra one for gpu (is a symlink)
FIRMWARE_HOOK
run_host_command_logged chmod -v +x "${file_added_to_bsp_destination}"
}
## Modules, required to boot, add them to initrd; might need to be done in '.d/x13s-modules' instead
## Modules, required to boot, add them to initrd; might need to be done in '.d/x13s-modules' instead
function post_family_tweaks_bsp__thinkpad_x13s_bsp_modules_in_initrd() {
display_alert "Adding to bsp-cli" "${BOARD}: modules in initrd" "info"
add_file_from_stdin_to_bsp_destination "/etc/initramfs-tools/modules" <<- 'EXTRA_MODULES'
# @TODO this list is outdated, much has changed; check jhovold's defconfig commit msg
pwm_bl
phy_qcom_qmp_pcie
pcie_qcom
@ -84,7 +161,6 @@ function post_family_tweaks_bsp__thinkpad_x13s_bsp_stuff() {
pmic_glink_altmode
leds_qcom_lpg
qcom_q6v5_pas # This module loads a lot of FW blobs
panel_edp
panel-edp
msm
nvme
@ -95,52 +171,27 @@ function post_family_tweaks_bsp__thinkpad_x13s_bsp_stuff() {
}
# armbian-firstrun waits for systemd to be ready, but snapd.seeded might cause it to hang due to wrong clock.
# if the battery runs out, the clock is reset to 1970. This causes snapd.seeded to hang, and armbian-firstrun to hang.
function pre_customize_image__disable_snapd_seeded() {
[[ "${DISTRIBUTION}" != "Ubuntu" ]] && return 0 # only needed for Ubuntu
display_alert "Disabling snapd.seeded" "${BOARD}" "info"
chroot_sdcard systemctl disable snapd.seeded.service "||" true
}
function pre_customize_image__add_ubuntu_concept_x13s_packages_if_ubuntu_lunar() {
# Ubuntu has a "x13s Concept" PPA, with needed userspace packages for Lunar (only).
# https://launchpad.net/~ubuntu-concept/+archive/ubuntu/x13s
# These will enable:
# - battery charging/control
# - audio via ALSA
# - patched 23.0 mesa, for GPU (trixie/sid and mantic already has upstream 23.1 mesa which fully supports it)
# It is only available for Lunar, though, so skip it if we're building for anything else.
# We add the PPA & pin it in apt conf, so regular Ubuntu updates don't get rid of them.
# Utility to get firmware needed; this is used to populate armbian/firmware, and is here for reference only.
function x13s_obtain_firmware() {
display_alert "Getting extra firmware for ${BOARD}" "${RELEASE}///${BOARD}" "info"
declare fw_target="${SDCARD}/lib/firmware"
mkdir -p "${fw_target}/qcom/sc8280xp/LENOVO/21BX"
if [[ "${RELEASE}" != "lunar" ]]; then
display_alert "Skipping Ubuntu Concept PPA for ${BOARD}" "for ${RELEASE} :: only available for lunar" "info"
return 0
fi
# interconnect stuff; get it from ironrobin's repo;
wget --output-document "${fw_target}/qcom/sc8280xp/LENOVO/21BX/qcvss8280.mbn" "https://raw.githubusercontent.com/ironrobin/x13s-alarm/trunk/x13s-firmware/qcvss8280.mbn"
if [[ "${BUILD_MINIMAL}" == "yes" ]]; then
display_alert "Skipping Ubuntu Concept PPA for ${BOARD}" "for ${RELEASE} MINIMAL :: only available for non-minimal" "info"
return 0
fi
# add a link to audio fw
(cd "${fw_target}/qcom/sc8280xp" && ln -s "LENOVO/21BX/audioreach-tplg.bin" "SC8280XP-LENOVO-X13S-tplg.bin")
display_alert "Adding Ubuntu Concept x13s PPA" "${BOARD}" "info"
do_with_retries 3 chroot_sdcard add-apt-repository ppa:ubuntu-concept/x13s --yes --no-update
# Pin all packages from the PPA to a high priority, so they don't get overwritten by Ubuntu updates.
# This is important for alsa-ucm-conf and the mesa packages, which are lagging in x13s but already updated in regular Lunar.
display_alert "Pinning Ubuntu Concept x132 PPA" "${BOARD}" "info"
cat <<- 'EOF' > "${SDCARD}/etc/apt/preferences.d/ubuntu-concept-x13s"
Package: *
Pin: release o=LP-PPA-ubuntu-concept-x13s
Pin-Priority: 1337
EOF
display_alert "Updating sources list, after Ubuntu Concept x13s PPAs" "${BOARD}" "info"
do_with_retries 3 chroot_sdcard_apt_get_update
display_alert "Upgrading/downgrading packages, after Ubuntu Concept x13s PPAs" "${BOARD}" "info"
do_with_retries 3 chroot_sdcard_apt_get full-upgrade --allow-downgrades # allow downgrades, to get the pinned Ubuntu Concept x13s packages
display_alert "Installing new Ubuntu Concept x13s packages" "${BOARD}" "info"
do_with_retries 3 chroot_sdcard_apt_get_install alsa-ucm-conf protection-domain-mapper qrtr-tools
# gpu, link 690 to 660 gmu
(cd "${fw_target}/qcom/" && ln -s a660_gmu.bin a690_gmu.bin)
return 0
}

File diff suppressed because it is too large Load Diff