From e7822222bd954b967e4fe5d0131c6d982f2a06b9 Mon Sep 17 00:00:00 2001
From: Anders Roxell <anders.roxell@linaro.org>
Date: Wed, 7 May 2025 13:14:02 +0200
Subject: [PATCH] board_setup: add pixel6 device

Signed-off-by: Benjamin Copeland <ben.copeland@linaro.org>
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
---
 lava/board_setup.sh | 22 +++++++++++++++++++---
 repack_boot.sh      | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/lava/board_setup.sh b/lava/board_setup.sh
index d83b014319ff..7c16902f6eec 100755
--- a/lava/board_setup.sh
+++ b/lava/board_setup.sh
@@ -1,8 +1,8 @@
 #!/bin/bash
 # SPDX-License-Identifier: MIT
 
-set -e
-#set -xe
+#set -e
+set -xe
 
 DEVICE_TYPE=${1}
 ROOTFS_STRING=${2:-"image-"}
@@ -26,6 +26,23 @@ echo "PRINTOUT ROOTFS: ${local_rootfs}"
 file ${local_rootfs}
 
 case ${DEVICE_TYPE} in
+
+	pixel6)
+		machine=${DEVICE_TYPE}
+		local_dtb=$(find . -type f -name '*.dtb')
+		echo "PRINTOUT DTB: ${local_dtb}"
+		${kir}/repack_boot.sh \
+		    -t "${machine}" \
+		    -d "${local_dtb}" \
+		    -k "${local_kernel}" \
+		    -m "${local_modules}" \
+		    -i "${local_initrd}"
+
+		${kir}/resize_rootfs.sh -s \
+		    -f "${local_rootfs}" \
+		    -o "${local_modules}" \
+		    -p "${MODULES_PATH}"
+		;;
 	x15)
 		local_dtb=$(find . -type f -name '*.dtb')
 		echo "PRINTOUT DTB: ${local_dtb}"
@@ -49,7 +66,6 @@ case ${DEVICE_TYPE} in
 		${kir}/resize_rootfs.sh -s -f "${local_rootfs}" -o "${local_modules}" -p "${MODULES_PATH}"
 		;;
 	nfs-dragonboard-845c)
-
 		local_dtb=$(find . -type f -name '*.dtb')
 		echo "PRINTOUT DTB: ${local_dtb}"
 		file ${local_dtb}
diff --git a/repack_boot.sh b/repack_boot.sh
index dbae20a2c85b..f574cb1c8027 100755
--- a/repack_boot.sh
+++ b/repack_boot.sh
@@ -199,6 +199,40 @@ case ${TARGET} in
 		img_file="$(basename "${new_file_name}" .ext4).img"
 		create_a_sparse_img "${img_file}" "${new_file_name}"
 		;;
+	pixel6)
+		echo "androidboot.boot_devices=14700000.ufs" | tee vendor-bootconfig.img
+		mkdir -p modules_dir/usr dlkm-root/usr/lib/modules/
+		unpack_tar_file "${MODULES_FILE}" modules_dir/usr
+		cd modules_dir
+		find . | cpio -o -H newc -R +0:+0 | gzip -9 > ../modules.cpio.gz
+		cd -
+		cat "${INITRD_FILE}" modules.cpio.gz > initramfs.platform.cpio.gz
+		initrd_filename="initramfs.platform.cpio.gz"
+		cp -a modules_dir/usr/lib/modules/* dlkm-root/usr/lib/modules/
+		( cd dlkm-root && find . | cpio -o -H newc | gzip -9 ) > initramfs.dlkm.cpio.gz
+		cmdline="console=ttySAC0,3000000n8 clk_ignore_unused root=PARTLABEL=userdata rw rootwait debug no_console_suspend earlycon"
+		vendor_bootconfig=vendor-bootconfig.img
+		vendor_boot_out=${vendor_boot_out:-vendor_boot.img}
+		boot_out=${boot_out:-boot.img}
+		mkbootimg \
+		    --header_version 4 \
+		    --dtb "$DTB_FILE" \
+		    --kernel "$KERNEL_FILE" \
+		    --vendor_bootconfig "$vendor_bootconfig" \
+		    --vendor_cmdline "$cmdline" \
+		    --ramdisk_type platform \
+		    --ramdisk_name PLAT \
+		    --vendor_ramdisk_fragment "${initrd_filename}" \
+		    --ramdisk_type dlkm \
+		    --ramdisk_name DLKM \
+		    --vendor_ramdisk_fragment initramfs.dlkm.cpio.gz \
+		    \
+		    --vendor_boot "$vendor_boot_out" \
+		    --output "$boot_out"
+
+		file "$vendor_boot_out"
+		file "$boot_out"
+		;;
 	*)
 		usage
 		exit 1
-- 
2.47.2

