meta: rework storage layout XML file handling

1. Move the staging of storage layout XML files from the L4T kit out
   of the tegra-bootfiles recipe to a new pair of recipes, one to
   fetch the base files out of the L4T kit, and a second one to
   process the base files for use in BUP generation and tegraflash
   packages.

2. Move the SoC-specific sed expressions from the tegraflash_create_flash_config
   functions in image_types_tegra.bbclass to a function in the new
   tegra-storage-layout recipe. These rewrites are for static boot firmware
   filenames that are not affected by the build itself, so they can
   be applied early.

3. Use fixed names for the staged layout files - internal, bup-internal,
   and (optionally) external, to reduce the exposure of the variable, since
   only one of each will be used for any build.

This reduces the code size in the bbclass and should make it easier for
users to provide custom layouts in place of the L4T originals.

Signed-off-by: Matt Madison <matt@madison.systems>
This commit is contained in:
Matt Madison
2023-10-02 10:16:18 -07:00
committed by Matt Madison
parent 2149ba3ad0
commit b3195bdb50
4 changed files with 144 additions and 134 deletions

View File

@@ -188,83 +188,26 @@ tegraflash_finalize_pkg() {
}
tegraflash_create_flash_config() {
:
}
tegraflash_create_flash_config:tegra194() {
local destdir="$1"
local destfile="$1"
local lnxfile="$2"
local infile="$3"
[ -n "$infile" ] || infile="${STAGING_DATADIR}/tegraflash/${PARTITION_LAYOUT_TEMPLATE}"
sed -e"s,MB1FILE,mb1_b_t194_prod.bin,2" "$infile" | \
sed \
-e"s,LNXFILE_b,$lnxfile," \
-e"s,LNXFILE,$lnxfile," -e"s,LNXSIZE,${LNXSIZE}," \
-e"s,TEGRABOOT,nvtboot_t194.bin," \
-e"s,MTSPREBOOT,preboot_c10_prod_cr.bin," \
-e"s,MTS_MCE,mce_c10_prod_cr.bin," \
-e"s,MTSPROPER,mts_c10_prod_cr.bin," \
-e"s,SCEFILE,sce_t194.bin," \
-e"s,MB1FILE,mb1_t194_prod.bin," \
-e"s,BPFFILE,bpmp-2_t194.bin," \
-e"s,TBCFILE,uefi_jetson.bin," \
-e"s,CAMERAFW,camera-rtcpu-t194-rce.img," \
-e"s,DRAMECCTYPE,dram_ecc," -e"s,DRAMECCFILE,dram-ecc-t194.bin," -e"s,DRAMECCNAME,dram-ecc-fw," \
-e"s,BADPAGETYPE,black_list_info," -e"s,BADPAGEFILE,badpage.bin," -e"s,BADPAGENAME,badpage-fw," \
-e"s,SPEFILE,spe_t194.bin," \
-e"s,WB0BOOT,warmboot_t194_prod.bin," \
-e"s,TOSFILE,${TOSIMGFILENAME}," \
-e"s,EKSFILE,eks.img," \
-e"s,RECNAME,recovery," -e"s,RECSIZE,${TEGRA_RECOVERY_KERNEL_PART_SIZE}," -e"s,RECDTB-NAME,recovery-dtb," -e"s,BOOTCTRLNAME,kernel-bootctrl," \
-e"/RECFILE/d" -e"/RECDTB-FILE/d" -e"/BOOTCTRL-FILE/d" \
-e"s,APPSIZE,${ROOTFSPART_SIZE}," \
-e"s,RECROOTFSSIZE,${RECROOTFSSIZE}," \
-e"s,APPUUID_b,," -e"s,APPUUID,," \
-e"s,ESP_FILE,esp.img," -e"/VARSTORE_FILE/d" \
-e"s,NUM_SECTORS,${TEGRA_EXTERNAL_DEVICE_SECTORS}," \
> $destdir/flash.xml.in
}
tegraflash_create_flash_config:tegra234() {
local destdir="$1"
local lnxfile="$2"
local infile="$3"
[ -n "$infile" ] || infile="${STAGING_DATADIR}/tegraflash/${PARTITION_LAYOUT_TEMPLATE}"
[ -n "$infile" ] || infile="${STAGING_DATADIR}/tegraflash/internal-flash.xml"
sed \
-e"s,LNXFILE_b,$lnxfile," \
-e"s,LNXFILE,$lnxfile," -e"s,LNXSIZE,${LNXSIZE}," \
-e"s,MB1FILE,mb1_t234_prod.bin," \
-e"s,CAMERAFW,camera-rtcpu-t234-rce.img," \
-e"s,SPEFILE,spe_t234.bin," \
-e"s,TOSFILE,${TOSIMGFILENAME}," \
-e"s,EKSFILE,eks.img," \
-e"s,RECNAME,recovery," -e"s,RECSIZE,${TEGRA_RECOVERY_KERNEL_PART_SIZE}," -e"s,RECDTB-NAME,recovery-dtb," \
-e"/RECFILE/d" -e"/RECDTB-FILE/d" -e"/BOOTCTRL-FILE/d" \
-e"s,APPSIZE,${ROOTFSPART_SIZE}," \
-e"s,RECROOTFSSIZE,${RECROOTFSSIZE}," \
-e"s,BADPAGETYPE,black_list_info," -e"s,BADPAGEFILE,badpage.bin," -e"s,BADPAGENAME,bad-page," \
-e"s,FSIFW,fsi-fw-ecc.bin," \
-e"s,PSCBL1FILE,psc_bl1_t234_prod.bin," \
-e"s,TSECFW,," \
-e"s,NVHOSTNVDEC,nvdec_t234_prod.fw," \
-e"s,MB2BLFILE,mb2_t234.bin," \
-e"s,XUSB_FW,xusb_t234_prod.bin," \
-e"s,PSCFW,pscfw_t234_prod.bin," \
-e"s,MCE_IMAGE,mce_flash_o10_cr_prod.bin," \
-e"s,WB0FILE,sc7_t234_prod.bin," \
-e"s,PSCRF_IMAGE,psc_rf_t234_prod.bin," \
-e"s,MB2RF_IMAGE,mb2rf_t234.bin," \
-e"s,TBCDTB-FILE,uefi_jetson_with_dtb.bin," \
-e"s,DCE,display-t234-dce.bin," \
-e"s,APPUUID_b,," -e"s,APPUUID,," \
-e"s,ESP_FILE,esp.img," -e"/VARSTORE_FILE/d" \
-e"s,NUM_SECTORS,${TEGRA_EXTERNAL_DEVICE_SECTORS}," \
"$infile" \
> $destdir/flash.xml.in
> "$destfile"
}
copy_dtbs() {
@@ -384,12 +327,9 @@ EOF
fi
tegraflash_custom_pre
cp "${IMAGE_TEGRAFLASH_ROOTFS}" ./${IMAGE_BASENAME}.${IMAGE_TEGRAFLASH_FS_TYPE}
tegraflash_create_flash_config "${WORKDIR}/tegraflash" ${LNXFILE}
tegraflash_create_flash_config flash.xml.in ${LNXFILE}
if [ "${TEGRAFLASH_ROOTFS_EXTERNAL}" = "1" ]; then
rm -rf "${WORKDIR}/tegraflash/external" external-flash.xml.in
mkdir "${WORKDIR}/tegraflash/external"
tegraflash_create_flash_config "${WORKDIR}/tegraflash/external" ${LNXFILE} ${STAGING_DATADIR}/tegraflash/${PARTITION_LAYOUT_EXTERNAL}
mv external/flash.xml.in ./external-flash.xml.in
tegraflash_create_flash_config external-flash.xml.in ${LNXFILE} ${STAGING_DATADIR}/tegraflash/external-flash.xml
fi
rm -f doflash.sh
cat > doflash.sh <<END
@@ -516,12 +456,9 @@ EOF
fi
tegraflash_custom_pre
cp "${IMAGE_TEGRAFLASH_ROOTFS}" ./${IMAGE_BASENAME}.${IMAGE_TEGRAFLASH_FS_TYPE}
tegraflash_create_flash_config "${WORKDIR}/tegraflash" ${LNXFILE}
tegraflash_create_flash_config flash.xml.in ${LNXFILE}
if [ "${TEGRAFLASH_ROOTFS_EXTERNAL}" = "1" ]; then
rm -rf "${WORKDIR}/tegraflash/external" external-flash.xml.in
mkdir "${WORKDIR}/tegraflash/external"
tegraflash_create_flash_config "${WORKDIR}/tegraflash/external" ${LNXFILE} ${STAGING_DATADIR}/tegraflash/${PARTITION_LAYOUT_EXTERNAL}
mv external/flash.xml.in ./external-flash.xml.in
tegraflash_create_flash_config external-flash.xml.in ${LNXFILE} ${STAGING_DATADIR}/tegraflash/external-flash.xml
fi
rm -f doflash.sh
cat > doflash.sh <<END
@@ -641,15 +578,7 @@ oe_make_bup_payload() {
# BUP generator really wants to use 'boot.img' for the LNX
# partition contents
cp $1 ./boot.img
# BUP generator must have a layout that includes kernel/DTB/etc.
# When those partitions are stripped from the main layout, we
# create a copy of the original with 'bupgen-' prefix, so use
# that if present.
local layoutsrc
if [ -e "${STAGING_DATADIR}/tegraflash/bupgen-${PARTITION_LAYOUT_TEMPLATE}" ]; then
layoutsrc="${STAGING_DATADIR}/tegraflash/bupgen-${PARTITION_LAYOUT_TEMPLATE}"
fi
tegraflash_create_flash_config "${WORKDIR}/bup-payload" boot.img "$layoutsrc"
tegraflash_create_flash_config flash.xml.in boot.img ${STAGING_DATADIR}/tegraflash/bupgen-internal-flash.xml
cp "${STAGING_DATADIR}/tegraflash/bsp_version" .
cp "${STAGING_DATADIR}/tegraflash/${EMMC_BCT}" .
if [ "${SOC_FAMILY}" = "tegra194" ]; then

View File

@@ -3,15 +3,11 @@ require tegra-shared-binaries.inc
COMPATIBLE_MACHINE = "(tegra)"
INHIBIT_DEFAULT_DEPS = "1"
DEPENDS = "tegra-flashtools-native dtc-native tegra-flashvars lz4-native coreutils-native"
DEPENDS = "tegra-flashvars tegra-storage-layout dtc-native coreutils-native lz4-native"
BCT_TEMPLATE ?= "${S}/bootloader/${NVIDIA_BOARD}/BCT/${EMMC_BCT}"
BCT_OVERRIDE_TEMPLATE ?= "${S}/bootloader/${NVIDIA_BOARD}/BCT/${EMMC_BCT_OVERRIDE}"
PARTITION_FILE ?= "${S}/bootloader/${NVIDIA_BOARD}/cfg/${PARTITION_LAYOUT_TEMPLATE}"
PARTITION_FILE_EXTERNAL ?= "${S}/tools/kernel_flash/${PARTITION_LAYOUT_EXTERNAL}"
EXTRA_XML_SPLIT_ARGS = "--change-device-type=sdcard"
ODMFUSE_FILE ?= ""
PATH =. "${STAGING_BINDIR_NATIVE}/tegra-flash:"
TEGRA_SOCNAME_SHORT = "${@d.getVar('SOC_FAMILY')[0:1] + d.getVar('SOC_FAMILY')[-3:]}"
# Work around bitbake parsing quirk with shell-style escapes
BACKSLASH_X_01 = "${@'\\' + 'x01'}"
@@ -28,7 +24,6 @@ do_compile() {
truncate --size=393216 ${B}/nvdisp-init.bin
fi
prepare_badpage_mapfile
prepare_external_flash_layout
}
prepare_badpage_mapfile() {
@@ -57,30 +52,6 @@ prepare_badpage_mapfile() {
esac
}
prepare_external_flash_layout() {
[ -n "${PARTITION_LAYOUT_EXTERNAL}" ] || return
case "${SOC_FAMILY}" in
tegra194)
cp ${PARTITION_FILE_EXTERNAL} ${PARTITION_LAYOUT_EXTERNAL}
;;
tegra234)
nvflashxmlparse -v --switch-to-prefixed-kernel-partitions --output=${PARTITION_LAYOUT_EXTERNAL} ${PARTITION_FILE_EXTERNAL}
;;
*)
bberror "Unrecognized SOC_FAMILY: ${SOC_FAMILY}"
;;
esac
}
install_external_layout:tegra194() {
}
install_external_layout:tegra234() {
nvflashxmlparse -v --switch-to-prefixed-kernel-partitions --output=${D}${datadir}/tegraflash/${PARTITION_LAYOUT_EXTERNAL} ${PARTITION_FILE_EXTERNAL}
chmod 0644 ${D}${datadir}/tegraflash/${PARTITION_LAYOUT_EXTERNAL}
}
do_install() {
install -d ${D}${datadir}/tegraflash
install -m 0644 ${S}/nv_tegra/bsp_version ${D}${datadir}/tegraflash/
@@ -89,31 +60,6 @@ do_install() {
done
install_other_boot_firmware_files
# For flashing to an external (USB/NVMe) device on targets where
# some of the boot partitions spill into the eMMC, preprocess the
# the XML files so the layout for the internal storage retains the
# those boot partitions, and remove the names of those partitions
# from the layout for the external storage.
if [ "${TNSPEC_BOOTDEV}" != "mmcblk0p1" -a "${BOOT_PARTITIONS_ON_EMMC}" = "1" ]; then
nvflashxmlparse -v --split=/dev/null --output=${D}${datadir}/tegraflash/${PARTITION_LAYOUT_TEMPLATE} ${EXTRA_XML_SPLIT_ARGS} ${PARTITION_FILE}
chmod 0644 ${D}${datadir}/tegraflash/${PARTITION_LAYOUT_TEMPLATE}
# BUP generation will fail if the main XML file does not
# contain the kernel/DTB/etc, so save a copy of the
# original for that purpose, stripping out the APP
# partition so that the offsets of the partitions
# referenced during early boot match the split layout above.
nvflashxmlparse -v --remove --partitions-to-remove=APP --output=${D}${datadir}/tegraflash/bupgen-${PARTITION_LAYOUT_TEMPLATE} ${PARTITION_FILE}
chmod 0644 ${D}${datadir}/tegraflash/bupgen-${PARTITION_LAYOUT_TEMPLATE}
else
if [ "${TEGRAFLASH_NO_INTERNAL_STORAGE}" = "1" ]; then
install -m 0644 ${PARTITION_FILE} ${D}${datadir}/tegraflash/bupgen-${PARTITION_LAYOUT_TEMPLATE}
nvflashxmlparse --extract -t boot --output=${D}${datadir}/tegraflash/${PARTITION_LAYOUT_TEMPLATE} ${PARTITION_FILE}
chmod 0644 ${D}${datadir}/tegraflash/${PARTITION_LAYOUT_TEMPLATE}
else
install -m 0644 ${PARTITION_FILE} ${D}${datadir}/tegraflash/${PARTITION_LAYOUT_TEMPLATE}
fi
fi
[ -z "${PARTITION_LAYOUT_EXTERNAL}" ] || install -m 0644 ${B}/${PARTITION_LAYOUT_EXTERNAL} ${D}${datadir}/tegraflash/
[ -z "${ODMFUSE_FILE}" ] || install -m 0644 ${ODMFUSE_FILE} ${D}${datadir}/tegraflash/odmfuse_pkc_${MACHINE}.xml
install -m 0644 ${BCT_TEMPLATE} ${D}${datadir}/tegraflash/${EMMC_BCT}
}

View File

@@ -0,0 +1,19 @@
require tegra-binaries-${PV}.inc
require tegra-shared-binaries.inc
COMPATIBLE_MACHINE = "(tegra)"
INHIBIT_DEFAULT_DEPS = "1"
PARTITION_FILE ?= "${S}/bootloader/${NVIDIA_BOARD}/cfg/${PARTITION_LAYOUT_TEMPLATE}"
PARTITION_FILE_EXTERNAL ?= "${S}/tools/kernel_flash/${PARTITION_LAYOUT_EXTERNAL}"
do_install() {
install -d ${D}${datadir}/l4t-storage-layout
install -m 0644 ${PARTITION_FILE} ${D}${datadir}/l4t-storage-layout/${PARTITION_LAYOUT_TEMPLATE}
[ -z "${PARTITION_LAYOUT_EXTERNAL}" ] || install -m 0644 ${PARTITION_FILE_EXTERNAL} ${D}${datadir}/l4t-storage-layout/${PARTITION_LAYOUT_EXERNAL}
}
PACKAGES = "${PN}-dev"
FILES:${PN}-dev = "${datadir}"
RRECOMMENDS:${PN}-dev = ""
PACKAGE_ARCH = "${MACHINE_ARCH}"

View File

@@ -0,0 +1,116 @@
DESCRIPTION = "Storage layout XML definitions"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
COMPATIBLE_MACHINE = "(tegra)"
INHIBIT_DEFAULT_DEPS = "1"
DEPENDS = "tegra-helper-scripts-native tegra-storage-layout-base"
PARTITION_FILE ?= "${STAGING_DATADIR}/l4t-storage-layout/${PARTITION_LAYOUT_TEMPLATE}"
PARTITION_FILE_EXTERNAL ?= "${STAGING_DATADIR}/l4t-storage-layout/${PARTITION_LAYOUT_EXTERNAL}"
EXTRA_XML_SPLIT_ARGS = "--change-device-type=sdcard"
PATH =. "${STAGING_BINDIR_NATIVE}/tegra-flash:"
# Applies any fixed, per-SoC rewrites. Consult the flash.sh script
# and conf files in the L4T kit for how these are derived.
copy_in_flash_layout() {
local srcfile="$1"
local dstfile="$2"
case "${SOC_FAMILY}" in
tegra194)
# Multiple seds here since the 2nd occurrence of MB1FILE
# gets a different rewrite than the first
sed -e"s,MB1FILE,mb1_b_t194_prod.bin,2" "$srcfile" | \
sed -e"s,TEGRABOOT,nvtboot_t194.bin," \
-e"s,MTSPREBOOT,preboot_c10_prod_cr.bin," \
-e"s,MTS_MCE,mce_c10_prod_cr.bin," \
-e"s,MTSPROPER,mts_c10_prod_cr.bin," \
-e"s,SCEFILE,sce_t194.bin," \
-e"s,MB1FILE,mb1_t194_prod.bin," \
-e"s,BPFFILE,bpmp-2_t194.bin," \
-e"s,TBCFILE,uefi_jetson.bin," \
-e"s,CAMERAFW,camera-rtcpu-t194-rce.img," \
-e"s,DRAMECCTYPE,dram_ecc," -e"s,DRAMECCFILE,dram-ecc-t194.bin," -e"s,DRAMECCNAME,dram-ecc-fw," \
-e"s,BADPAGETYPE,black_list_info," -e"s,BADPAGEFILE,badpage.bin," -e"s,BADPAGENAME,badpage-fw," \
-e"s,SPEFILE,spe_t194.bin," \
-e"s,WB0BOOT,warmboot_t194_prod.bin," \
> "$dstfile"
;;
tegra234)
nvflashxmlparse -v --switch-to-prefixed-kernel-partitions --output="$dstfile" "$srcfile"
sed -i -e"s,MB1FILE,mb1_t234_prod.bin," \
-e"s,CAMERAFW,camera-rtcpu-t234-rce.img," \
-e"s,SPEFILE,spe_t234.bin," \
-e"s,BADPAGETYPE,black_list_info," -e"s,BADPAGEFILE,badpage.bin," -e"s,BADPAGENAME,bad-page," \
-e"s,FSIFW,fsi-fw-ecc.bin," \
-e"s,PSCBL1FILE,psc_bl1_t234_prod.bin," \
-e"s,TSECFW,," \
-e"s,NVHOSTNVDEC,nvdec_t234_prod.fw," \
-e"s,MB2BLFILE,mb2_t234.bin," \
-e"s,XUSB_FW,xusb_t234_prod.bin," \
-e"s,PSCFW,pscfw_t234_prod.bin," \
-e"s,MCE_IMAGE,mce_flash_o10_cr_prod.bin," \
-e"s,WB0FILE,sc7_t234_prod.bin," \
-e"s,PSCRF_IMAGE,psc_rf_t234_prod.bin," \
-e"s,MB2RF_IMAGE,mb2rf_t234.bin," \
-e"s,TBCDTB-FILE,uefi_jetson_with_dtb.bin," \
-e"s,DCE,display-t234-dce.bin," \
"$dstfile"
;;
*)
bberror "Unrecognized SOC_FAMILY: ${SOC_FAMILY}"
;;
esac
}
do_compile() {
copy_in_flash_layout ${PARTITION_FILE} internal-flash.xml.orig
# For flashing to an external (USB/NVMe) device on targets where
# some of the boot partitions spill into the eMMC, preprocess the
# the XML files so the layout for the internal storage retains the
# those boot partitions, and remove the names of those partitions
# from the layout for the external storage.
if [ "${TNSPEC_BOOTDEV}" != "mmcblk0p1" -a "${BOOT_PARTITIONS_ON_EMMC}" = "1" ]; then
nvflashxmlparse -v --split=/dev/null --output=internal-flash.xml ${EXTRA_XML_SPLIT_ARGS} internal-flash.xml.orig
# BUP generation will fail if the main XML file does not
# contain the kernel/DTB/etc, so save a copy of the
# original for that purpose, stripping out the APP
# partition so that the offsets of the partitions
# referenced during early boot match the split layout above.
nvflashxmlparse -v --remove --partitions-to-remove=APP --output=bupgen-internal-flash.xml internal-flash.xml.orig
else
if [ "${TEGRAFLASH_NO_INTERNAL_STORAGE}" = "1" ]; then
# For modules with *only* SPI flash (or other boot device) and no
# internal storage for rootfs, use a full copy for BUP (see note above)
# and make sure the internal layout used for flashing only
# covers the boot device.
cp internal-flash.xml.orig bupgen-internal-flash.xml
nvflashxmlparse --extract -t boot --output=internal-flash.xml internal-flash.xml.orig
else
cp internal-flash.xml.orig internal-flash.xml
fi
fi
if [ -n "${PARTITION_LAYOUT_EXTERNAL}" ]; then
copy_in_flash_layout ${PARTITION_FILE_EXTERNAL} external-flash.xml
fi
}
do_install() {
install -D -m 0644 -t ${D}${datadir}/tegraflash ${B}/internal-flash.xml
if [ -e ${B}/bupgen-internal-flash.xml ]; then
install -m 0644 ${B}/bupgen-internal-flash.xml ${D}${datadir}/tegraflash/bupgen-internal-flash.xml
else
ln -sf internal-flash.xml ${D}${datadir}/tegraflash/bupgen-internal-flash.xml
fi
if [ -e ${B}/external-flash.xml ]; then
install -m 0644 ${B}/external-flash.xml ${D}${datadir}/tegraflash/
fi
}
PACKAGES = "${PN}-dev"
FILES:${PN}-dev = "${datadir}"
RRECOMMENDS:${PN}-dev = ""
PACKAGE_ARCH = "${MACHINE_ARCH}"