build/config/boards/thinkpad-x13s.wip

147 lines
6.4 KiB
Plaintext
Raw Permalink Normal View History

# Qualcomm Snapdragon 8cx Gen 3 Adreno 690 Qualcomm WCN685x Wi-Fi 6E Qualcomm Snapdragon X55 5G Bluetooth 5.1
declare -g BOARD_NAME="ThinkPad X13s"
declare -g BOARD_MAINTAINER="rpardini"
declare -g BOARDFAMILY="uefi-arm64"
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.
# 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'
declare -g KERNELSOURCE='https://github.com/steev/linux.git'
}
function post_family_tweaks_bsp__thinkpad_x13s_bsp_stuff() {
### 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
[Service]
Type=oneshot
ExecStart=/usr/bin/btmgmt public-addr AD:5A:00:F0:FD:8C
[Install]
WantedBy=multi-user.target
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
}
## 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
##
## Include certain firmware in the 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'
#!/bin/bash
[[ "$1" == "prereqs" ]] && exit 0
. /usr/share/initramfs-tools/hook-functions
for f in /lib/firmware/qcom/sc8280xp/LENOVO/21BX/* ; do
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
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
display_alert "Adding to bsp-cli" "${BOARD}: modules in initrd" "info"
add_file_from_stdin_to_bsp_destination "/etc/initramfs-tools/modules" <<- 'EXTRA_MODULES'
pwm_bl
phy_qcom_qmp_pcie
pcie_qcom
phy_qcom
qmp_pcie
phy_qcom_qmp_combo
qrtr
phy_qcom_edp
gpio_sbu_mux
i2c_hid_of
i2c_qcom_geni
pmic_glink_altmode
leds_qcom_lpg
qcom_q6v5_pas # This module loads a lot of FW blobs
panel_edp
panel-edp
msm
nvme
usb_storage
uas
EXTRA_MODULES
}
# armbian-firstrun waits for systemd to be ready, but snapd.seeded might cause it to hang due to wrong clock.
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.
if [[ "${RELEASE}" != "lunar" ]]; then
display_alert "Skipping Ubuntu Concept PPA for ${BOARD}" "for ${RELEASE} :: only available for lunar" "info"
return 0
fi
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
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
return 0
}