Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tegra: support creating wic images along with tegraflash #1083

Merged
merged 14 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fi
# get the partition number and type
INFO=$(udevadm info --query=property --name=${ROOT_DEVICE})
PART_ENTRY_NUMBER=$(echo "${INFO}" | grep '^ID_PART_ENTRY_NUMBER=' | cut -d'=' -f2)
PART_ENTRY_NAME=$(echo "${INFO}" | grep '^ID_PART_ENTRY_NAME=' || true | cut -d'=' -f2)
PART_ENTRY_NAME=$(echo "${INFO}" | { grep '^ID_PART_ENTRY_NAME=' || true; } | cut -d'=' -f2)

# in case the root device is not on a partitioned media
if [ "x$PART_ENTRY_NUMBER" = "x" ]; then
Expand All @@ -64,28 +64,32 @@ PART_TABLE_TYPE=$(echo "${INFO}" | grep '^ID_PART_TABLE_TYPE=' | cut -d'=' -f2)
DEVICE=$(udevadm info --query=path --name=${ROOT_DEVICE} | awk -F'/' '{print $(NF-1)}')
DEVICE="/dev/${DEVICE}"

SIZE=$(blockdev --getsz ${DEVICE})
TYPE="p\n"
if [ "$PART_TABLE_TYPE" = "gpt" ]; then
${SGDISK} -e ${DEVICE}
SIZE=$(($SIZE - 33)) # the GPT end of disk is 34 sectors
TYPE=""
fi
# only manipulate partition table if rootfs is the last partition
LAST_PART=$(partx -s -o nr ${DEVICE} | tail -n1)
if [ ${PART_ENTRY_NUMBER} -eq ${LAST_PART} ]; then
SIZE=$(blockdev --getsz ${DEVICE})
TYPE="p\n"
if [ "$PART_TABLE_TYPE" = "gpt" ]; then
${SGDISK} -e ${DEVICE}
SIZE=$(($SIZE - 33)) # the GPT end of disk is 34 sectors
TYPE=""
fi

# Use fdisk to repartition
# fdisk uses a ram image of the parition table until a write is performed
# so the sequence is to delete the partition and recreate it at the same
# starting point but making it the size of the available disk.
#
END=$((${SIZE} - 1))
PARTOF=$(echo "${INFO}" | grep '^ID_PART_ENTRY_OFFSET=' | cut -d'=' -f2)
echo -e "d\n${PART_ENTRY_NUMBER}\nn\n${TYPE}${PART_ENTRY_NUMBER}\n${PARTOF}\n${END}\nw\n" | ${FDISK} ${DEVICE}
# Use fdisk to repartition
# fdisk uses a ram image of the parition table until a write is performed
# so the sequence is to delete the partition and recreate it at the same
# starting point but making it the size of the available disk.
#
END=$((${SIZE} - 1))
PARTOF=$(echo "${INFO}" | grep '^ID_PART_ENTRY_OFFSET=' | cut -d'=' -f2)
echo -e "d\n${PART_ENTRY_NUMBER}\nn\n${TYPE}${PART_ENTRY_NUMBER}\n${PARTOF}\n${END}\nw\n" | ${FDISK} ${DEVICE}

if [ -n "${PART_ENTRY_NAME}" ]; then
${SGDISK} --change-name=${PART_ENTRY_NUMBER}:"${PART_ENTRY_NAME}" ${DEVICE}
if [ -n "${PART_ENTRY_NAME}" ]; then
${SGDISK} --change-name=${PART_ENTRY_NUMBER}:"${PART_ENTRY_NAME}" ${DEVICE}
fi
${PARTX} -u ${DEVICE}
fi

${PARTX} -u ${DEVICE}
if [ -n "${DM_NAME}" ] && cryptsetup isLuks ${ROOT_DEVICE}; then
# OP-TEE: use TEE Identity for pkcs11 authentication
export CKTEEC_LOGIN_TYPE=user
Expand Down
2 changes: 1 addition & 1 deletion meta-lmp-base/wic/efidisk-sota.wks.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# can directly dd to boot media.

part /boot --source bootimg-sota-efi --sourceparams="loader=${EFI_PROVIDER}" --rootfs-dir=${WORKDIR}/ota-boot --ondisk sda --active --align 1024 --use-uuid ${OSTREE_WKS_EFI_SIZE}
part / --source otaimage --ondisk sda --fstype=ext4 --align 1024 --use-uuid
part / --source otaimage --ondisk sda --part-name=otaroot --fstype=ext4 --align 1024 --use-uuid

bootloader --source bootimg-sota-efi --timeout=1 --ptable gpt
14 changes: 10 additions & 4 deletions meta-lmp-bsp/conf/machine/include/lmp-machine-custom.inc
Original file line number Diff line number Diff line change
Expand Up @@ -632,21 +632,21 @@ LMP_BOOT_FIRMWARE_FILES:append:sota:am64xx-evm = " boot.itb"
DISTRO_FEATURES:append:tegra = " opengl"
DISTRO_FEATURES_DEFAULT:remove:tegra = "modsign"
PREFERRED_PROVIDER_virtual/kernel:tegra ?= "linux-tegra"
IMAGE_TEGRAFLASH_FS_TYPE:sota:tegra = "ota-ext4"
IMAGE_TEGRAFLASH_FS_TYPE:sota:tegra = "${@bb.utils.contains('TEGRA_EXTERNAL_ROOTFS_WIC', '1', 'wic.gz', 'ota-ext4', d)}"
TEGRA_INITRAMFS_FSTYPES:tegra = ""
INITRD_IMAGE:tegra = ""
IMAGE_TEGRAFLASH_KERNEL:tegra = "${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}"
IMAGE_FSTYPES:remove:tegra = "wic wic.gz wic.bmap"
WKS_FILE:tegra:sota ?= "efidisk-sota.wks.in"
IMAGE_ROOTFS_SIZE:tegra = "65536"
PREFERRED_PROVIDER_virtual/bootloader:tegra ?= "edk2-firmware-tegra"
OSTREE_LOADER_LINK:tegra = "0"
OSTREE_BOOTLOADER:tegra ?= "syslinux"
CORE_IMAGE_BASE_INSTALL:remove:tegra = "resize-helper"
OSTREE_DEPLOY_DEVICETREE:tegra = "1"
PREFERRED_PROVIDER_virtual/optee-os:tegra = "optee-os"
MACHINE_EXTRA_RDEPENDS:remove:tegra = "tegra-redundant-boot"
MACHINE_FEATURES:append:tegra = " optee"
## jetson-agx-xavier-devkit (tegra194)
OSTREE_KERNEL_ARGS:tegra194 ?= "\${cbootargs} root=/dev/mmcblk0p1 rootwait rootfstype=ext4 mminit_loglevel=4 console=tty0 console=ttyTCU0,115200 fbcon=map:0 sdhci_tegra.en_boot_part_access=1"
OSTREE_KERNEL_ARGS:tegra194 ?= "\${cbootargs} root=LABEL=otaroot rootwait rootfstype=ext4 mminit_loglevel=4 console=tty0 console=ttyTCU0,115200 fbcon=map:0 sdhci_tegra.en_boot_part_access=1"
## jetson-agx-orin-devkit (tegra234)
OSTREE_KERNEL_ARGS:tegra234 ?= "root=/dev/mmcblk0p1 rootwait rootfstype=ext4 mminit_loglevel=4 console=tty0 console=ttyTCU0,115200 fbcon=map:0"

Expand Down Expand Up @@ -682,3 +682,9 @@ MACHINE_FIRMWARE:remove:mx6-nxp-bsp = "linux-firmware-imx-sdma-imx6q"
MACHINE_FIRMWARE:remove:mx8-nxp-bsp = "linux-firmware-imx-sdma-imx7d"
MACHINE_FIRMWARE:append:mx6-nxp-bsp = " firmware-imx-sdma-imx6q firmwared"
MACHINE_FIRMWARE:append:mx8-nxp-bsp = " firmware-imx-sdma-imx7d firmwared"

### Tegra custom LmP hook
TEGRA_EXTERNAL_ROOTFS_WIC ??= "0"
tegraflash_custom_post:append:tegra() {
echo EXTERNAL_ROOTFS_WIC_FLASH=\"${TEGRA_EXTERNAL_ROOTFS_WIC}\" >> .env.initrd-flash
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FILESEXTRAPATHS:prepend := "${THISDIR}/tegra-helper-scripts:"
Loading