Add FIT multi-DTB selection for Qualcomm platforms
Subsystems (3)
v3 cover Add FIT multi-DTB selection for Qualcomm platforms
This series adds dynamic device tree selection from FIT images for Qualcomm Snapdragon platforms, enabling U-Boot to select the appropriate DTB based on hardware parameters detected from SMEM.
Qualcomm fit based DTB format is documented in [1]
The fit image contains only DTB, while the kernel will be part of UKI image.
The implementation consists of three parts:
1. SMEM cache infrastructure: Provides cached access to commonly used SMEM data (socinfo, RAM partitions) to avoid redundant lookups during boot. Includes socinfo header from Linux kernel for SoC identification.
2. FIT multi-DTB selection: Implements the core selection logic that reads hardware parameters from SMEM, parses metadata DTB, matches FIT configurations, and loads the selected DTB with overlays. Integrates with EFI boot flow by setting fdt_addr.
3. mkimage: add fatfs image type for FAT partition images Added fatimage.c handler that uses mkfs.vfat and mcopy to create FAT images from a directory.
[1] https://github.com/qualcomm-linux/qcom-dtb-metadata/blob/main/Documentation.md
---
Changes in v3:
1. Runtime IMEM address lookup via DT: Removed CONFIG_QCOM_IMEM_SIZE Kconfig option. Added qcom_imem_table[] mapping SoC compatible strings to IMEM addresses.
2. Split SoC version sources: SoC hardware version now read from TCSR register via qcom_read_tcsr_soc_version(). The soc_info->plat_ver from SMEM is stored separately as board_version. Added socver and boardrev metadata node matching for finer-grained DTB selection.
3. qcom_load_fit_image() returns int: Changed return type from efi_status_t to int, returning standard Linux error codes for consistency with the rest of the driver.
4. Code cleanup: strtok() replaced with strsep(); memcpy + manual null-termination replaced with strlcpy(); DDR thresholds use SZ_* macros; compatible matching and FDT loading extracted into dedicated helpers.
5. image: add IH_TYPE_FATFS image type: Added new fatfs image type to represent a raw FAT filesystem partition image, registered in the image type lookup table.
6. mkimage: add fatfs image type for FAT partition images: Added fatimage.c handler that uses mkfs.vfat and mcopy to create FAT images from a directory.
New --fat-extra-space, --fat-type, --fat-volume-id, --fat-mkfs-opts long options added to mkimage.
7. doc: document mkimage fatfs type and Qualcomm multi-DTB: Updated 'doc/mkimage.1' for the new fatfs type and options. Added 'doc/board/qualcomm/multi_dtb.rst' covering FIT ITS configuration, QCOM metadata format, socver/boardrev guidelines, and image creation steps.
Link to v2:
https://lore.kernel.org/u-boot/[email protected]/
Changes in v2:
- In v1, a combined DTB format was used for multi-DTB support. Based on
feedback, v2 implements FIT-based DTB selection instead.
- Link to v1: https://lore.kernel.org/all/[email protected]/
Aswin Murugan (7):
mach-snapdragon: Add generic SMEM cache infrastructure
mach-snapdragon: Add FIT multi-DTB selection support
configs: snapdragon: Enable FIT multi-DTB and configure IMEM
image: add IH_TYPE_FATFS image type
mkimage: add fatfs image type for FAT partition images
doc: document mkimage fatfs type and Qualcomm multi-DTB
mach-snapdragon: Reorder header includes
arch/arm/mach-snapdragon/Kconfig | 8 + arch/arm/mach-snapdragon/Makefile | 1 + arch/arm/mach-snapdragon/board.c | 123 +- arch/arm/mach-snapdragon/qcom-priv.h | 24 + arch/arm/mach-snapdragon/qcom_fit_multidtb.c | 1103 ++++++++++++++++++ arch/arm/mach-snapdragon/qcom_fit_multidtb.h | 189 +++ arch/arm/mach-snapdragon/rampart.h | 225 ++++ boot/image.c | 1 + configs/qcom_defconfig | 2 + doc/board/qualcomm/index.rst | 1 + doc/board/qualcomm/multi_dtb.rst | 352 ++++++ doc/mkimage.1 | 103 ++ include/image.h | 1 + include/soc/qcom/socinfo.h | 114 ++ tools/Makefile | 1 + tools/fatimage.c | 495 ++++++++ tools/fatimage.h | 25 + tools/mkimage.c | 21 + tools/mkimage.h | 15 + 19 files changed, 2793 insertions(+), 11 deletions(-) create mode 100644 arch/arm/mach-snapdragon/qcom_fit_multidtb.c create mode 100644 arch/arm/mach-snapdragon/qcom_fit_multidtb.h create mode 100644 arch/arm/mach-snapdragon/rampart.h create mode 100644 doc/board/qualcomm/multi_dtb.rst create mode 100644 include/soc/qcom/socinfo.h create mode 100644 tools/fatimage.c create mode 100644 tools/fatimage.h
Signature · 1 line
2.34.1
PATCH v3 1/7 mach-snapdragon: Add generic SMEM cache infrastructure
Add cached access functions for commonly used SMEM data to reduce redundant SMEM lookups across the boot process.
This patch introduces three generic caching functions:
- qcom_get_smem_device(): Cached SMEM device access
- qcom_get_socinfo(): Cached socinfo structure access
- qcom_get_ram_partitions(): Cached RAM partition table access
The implementation includes new header files for data structures:
- include/soc/qcom/socinfo.h: Added socinfo header from Linux [1] Provides socinfo structure definitions for SoC identification and hardware parameters
- arch/arm/mach-snapdragon/rampart.h: Provides RAM partition table structures for memory layout information
The caching mechanism initializes SMEM data on first access and returns cached pointers on subsequent calls, avoiding expensive SMEM lookups during boot. This infrastructure is designed to be reusable by other Qualcomm-specific features that require hardware information from SMEM.
The functions provide a clean API for accessing:
- SoC information (chip ID, version, platform details)
- RAM partition layout for memory size calculations
- Hardware parameters needed for device-specific configurations
---
Changes in v3:
1. Addressed the review comments
--- arch/arm/mach-snapdragon/board.c | 95 +++++++++++ arch/arm/mach-snapdragon/qcom-priv.h | 24 +++ arch/arm/mach-snapdragon/rampart.h | 225 +++++++++++++++++++++++++++ include/soc/qcom/socinfo.h | 114 ++++++++++++++ 4 files changed, 458 insertions(+) create mode 100644 arch/arm/mach-snapdragon/rampart.h create mode 100644 include/soc/qcom/socinfo.h
arch/arm/mach-snapdragon/board.c +95 -0
@@ -16,6 +16,7 @@#include <asm/system.h> #include <dm/device.h> #include <dm/pinctrl.h> +#include <dm/uclass.h> #include <dm/uclass-internal.h> #include <dm/read.h> #include <power/regulator.h>
@@ -30,6 +31,7 @@#include <malloc.h> #include <fdt_support.h> #include <usb.h> +#include <smem.h> #include <sort.h> #include <time.h>
@@ -39,6 +41,16 @@ DECLARE_GLOBAL_DATA_PTR; enum qcom_boot_source qcom_boot_source __section(".data") = 0; +/** +* struct smem_cache - Cached SMEM device and data pointers +* @soc_info: Pointer to the SoC info structure +* @ram_part: Pointer to the RAM partition table +*/ +static struct { +struct socinfo *soc_info; +struct usable_ram_partition_table *ram_part; +} smem_cache; +static struct mm_region rbx_mem_map[CONFIG_NR_DRAM_BANKS +2 ] = { {0 } };struct mm_region *mem_map = rbx_mem_map;
@@ -749,3 +761,86 @@ void enable_caches(void) }dcache_enable (); } + +/** +* qcom_get_smem_device() - Get cached SMEM device +* +* This function provides cached access to the SMEM device. +* On first call, it initializes the SMEM device. +* Subsequent calls return the cached pointer. +* +* Return: Pointer to SMEM device on success, NULL on failure +*/ +struct udevice *qcom_get_smem_device (void ) +{ +struct udevice *dev; + +if (uclass_first_device_err (UCLASS_SMEM , &dev)) { +log_err ("Failed to get SMEM device\n" ); +return NULL ; + } + +return dev; +} + +/** +* qcom_get_socinfo() - Get cached socinfo from SMEM +* +* This function provides cached access to the socinfo structure from SMEM. +* On first call, it initializes the SMEM device and retrieves the socinfo. +* Subsequent calls return the cached pointer. +* +* Return: Pointer to socinfo structure on success, NULL on failure +*/ +struct socinfo *qcom_get_socinfo (void ) +{ +size_t size; +struct udevice *dev; + +if (smem_cache.soc_info) +return smem_cache.soc_info; + + dev =qcom_get_smem_device (); +if (!dev) +return NULL ; + + smem_cache.soc_info =smem_get (dev,0 ,SMEM_HW_SW_BUILD_ID , &size); +if (!smem_cache.soc_info) { +log_err ("Failed to get socinfo from SMEM\n" ); +return NULL ; + } + +return smem_cache.soc_info; +} + +/** +* qcom_get_ram_partitions() - Get cached RAM partition table from SMEM +* +* This function provides cached access to the RAM partition table from SMEM. +* On first call, it retrieves the partition table from SMEM. +* Subsequent calls return the cached pointer. +* +* Return: Pointer to RAM partition table on success, NULL on failure +*/ +struct usable_ram_partition_table *qcom_get_ram_partitions (void ) +{ +size_t size; +struct udevice *dev; + +if (smem_cache.ram_part) +return smem_cache.ram_part; + + dev =qcom_get_smem_device (); +if (!dev) +return NULL ; + + smem_cache.ram_part =smem_get (dev,0 , +SMEM_USABLE_RAM_PARTITION_TABLE , + &size); +if (!smem_cache.ram_part) { +log_err ("Failed to get RAM partition table from SMEM\n" ); +return NULL ; + } + +return smem_cache.ram_part; +}
arch/arm/mach-snapdragon/qcom-priv.h +24 -0
@@ -3,6 +3,9 @@#ifndef __QCOM_PRIV_H__#define __QCOM_PRIV_H__ +#include <soc/qcom/socinfo.h> +#include "rampart.h" +/** * enum qcom_boot_source - Track where we got loaded from. * Used for capsule update logic.
@@ -17,6 +20,27 @@ enum qcom_boot_source {extern enum qcom_boot_source qcom_boot_source; +/** +* qcom_get_smem_device() - Get cached SMEM device +* +* Return: Pointer to SMEM device on success, NULL on failure +*/ +struct udevice *qcom_get_smem_device (void ); + +/** +* qcom_get_socinfo() - Get cached socinfo from SMEM +* +* Return: Pointer to socinfo structure on success, NULL on failure +*/ +struct socinfo *qcom_get_socinfo (void ); + +/** +* qcom_get_ram_partitions() - Get cached RAM partition table from SMEM +* +* Return: Pointer to RAM partition table on success, NULL on failure +*/ +struct usable_ram_partition_table *qcom_get_ram_partitions (void ); +#if IS_ENABLED (CONFIG_EFI_HAVE_CAPSULE_SUPPORT )void qcom_configure_capsule_updates (void );#else
arch/arm/mach-snapdragon/rampart.h new file +225 -0
225 lines not on this page · raw message
include/soc/qcom/socinfo.h new file +114 -0
114 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v3 1/7] mach-snapdragon: Add generic SMEM cache infrastructure
Hi Aswin,
Quoted 30 lines · Aswin Murugan
mach-snapdragon: Add generic SMEM cache infrastructure
Add cached access functions for commonly used SMEM data to reduce redundant SMEM lookups across the boot process.
This patch introduces three generic caching functions:
-qcom_get_smem_device(): Cached SMEM device access
-qcom_get_socinfo(): Cached socinfo structure access
-qcom_get_ram_partitions(): Cached RAM partition table accessThe implementation includes new header files for data structures:
-include/soc/qcom/socinfo.h: Added socinfo header from Linux [1] Provides socinfo structure definitions for SoC identification and hardware parameters
-arch/arm/mach-snapdragon/rampart.h: Provides RAM partition table structures for memory layout informationThe caching mechanism initializes SMEM data on first access and returns cached pointers on subsequent calls, avoiding expensive SMEM lookups during boot. This infrastructure is designed to be [...]
arch/arm/mach-snapdragon/board.c| 95 +++++++++++++++arch/arm/mach-snapdragon/qcom-priv.h | 24 ++++ arch/arm/mach-snapdragon/rampart.h | 225 +++++++++++++++++++++++++++++++++++ include/soc/qcom/socinfo.h | 114 ++++++++++++++++++ 4 files changed, 458 insertions(+)
arch/arm/mach-snapdragon/rampart.h line 9
Quoted 9 lines
arch/arm/mach-snapdragon/rampart.h +9
-0@@ -0,0 +1,225 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* RAM partition table definitions +* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* +*/ + +#define SMEM_USABLE_RAM_PARTITION_TABLE 402
This header should have an include guard.
Quoted 12 lines
arch/arm/mach-snapdragon/board.c +10
-0@@ -749,3 +761,86 @@ void enable_caches(void) +/** +* qcom_get_smem_device() - Get cached SMEM device +* +* This function provides cached access to the SMEM device. +* On first call, it initializes the SMEM device. +* Subsequent calls return the cached pointer. +* +* Return: Pointer to SMEM device on success, NULL on failure +*/ +struct udevice *qcom_get_smem_device (void )
arch/arm/mach-snapdragon/board.c void enable_caches(void) · line 780
Quoted 10 lines
arch/arm/mach-snapdragon/board.c +10
-0+{ +struct udevice *dev; + +if (uclass_first_device_err (UCLASS_SMEM , &dev)) { +log_err ("Failed to get SMEM device\n" ); +return NULL ; + } + +return dev; +}
Can you update the commit message and function documentation since this does not cache anything.
Regards,
Simon
PATCH v3 2/7 mach-snapdragon: Add FIT multi-DTB selection support
In reply to Aswin MuruganImplement multi DTB selection from FIT images based on hardware detection via SMEM.
The implementation provides:
1. Hardware Detection: Reads SoC parameters from SMEM including chip ID, version, platform ID, OEM variant, DDR size, and storage type from IMEM.
2. Metadata DTB Processing: Parses a metadata DTB (first image in FIT) to build a "bucket list" of hardware-specific node names that match the detected hardware parameters.
3. FIT Configuration Matching: Uses standard FIT mechanisms to find the configuration with the most matching tokens in its compatible string compared to the hardware-derived bucket list.
4. DTB Loading and Overlays: Loads the base DTB and applies any DTBOs specified in the selected configuration using standard FIT overlay application.
5. EFI Integration: Loads selected dtb from qclinux_fit.img and sets fdt_addr for use by the EFI boot flow.
This enables multi DTB selection across hardware variants.
---
Changes in v3:
1. Runtime IMEM address lookup via DT: Removed CONFIG_QCOM_IMEM_SIZE Kconfig option. Added qcom_imem_table[] mapping SoC compatible strings to IMEM addresses.
2. Split SoC version sources: SoC hardware version now read from TCSR register via qcom_read_tcsr_soc_version(). The soc_info->plat_ver from SMEM is stored separately as board_version. Added socver and boardrev metadata node matching for finer-grained DTB selection.
3. qcom_load_fit_image() returns int: Changed return type from efi_status_t to int, returning standard Linux error codes for consistency with the rest of the driver.
4. Code cleanup: strtok() replaced with strsep(); memcpy + manual null-termination replaced with strlcpy(); DDR thresholds use SZ_* macros; compatible matching and FDT loading extracted into dedicated helpers.
--- arch/arm/mach-snapdragon/Kconfig | 8 + arch/arm/mach-snapdragon/Makefile | 1 + arch/arm/mach-snapdragon/board.c | 7 + arch/arm/mach-snapdragon/qcom_fit_multidtb.c | 1103 ++++++++++++++++++ arch/arm/mach-snapdragon/qcom_fit_multidtb.h | 189 +++ 5 files changed, 1308 insertions(+) create mode 100644 arch/arm/mach-snapdragon/qcom_fit_multidtb.c create mode 100644 arch/arm/mach-snapdragon/qcom_fit_multidtb.h
arch/arm/mach-snapdragon/Kconfig +8 -0
@@ -42,4 +42,12 @@ config SYS_CONFIG_NAME Based on this option include/configs/<CONFIG_SYS_CONFIG_NAME>.h header will be used for board configuration. +config QCOM_FIT_MULTIDTB + bool "Enable FIT multi-DTB selection for Qualcomm platforms" + depends on FIT + help + Enable FIT multi-DTB selection for Qualcomm platforms. + This allows U-Boot to select the appropriate device tree + from a FIT image. + endif
arch/arm/mach-snapdragon/Makefile +1 -0
@@ -5,3 +5,4 @@ obj-y += board.o obj-$(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) += capsule_update.o obj-$(CONFIG_OF_LIVE) += of_fixup.o +obj-$(CONFIG_QCOM_FIT_MULTIDTB) += qcom_fit_multidtb.o
arch/arm/mach-snapdragon/board.c +7 -0
@@ -35,6 +35,7 @@#include <sort.h> #include <time.h> +#include "qcom_fit_multidtb.h" #include "qcom-priv.h" DECLARE_GLOBAL_DATA_PTR ;
@@ -585,6 +586,12 @@ int board_late_init(void)/* Configure the dfu_string for capsule updates */ qcom_configure_capsule_updates (); +/* Try FIT multi-DTB selection if enabled */ +if (IS_ENABLED (CONFIG_QCOM_FIT_MULTIDTB )) { +if (!qcom_fit_multidtb_setup ()) +log_debug ("FIT multi-DTB selection not available or failed\n" ); + } +return 0 ; }
arch/arm/mach-snapdragon/qcom_fit_multidtb.c new file +1103 -0
1,103 lines not on this page · raw message
arch/arm/mach-snapdragon/qcom_fit_multidtb.h new file +189 -0
189 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v3 2/7] mach-snapdragon: Add FIT multi-DTB selection support
Hi Aswin,
Quoted 31 lines · Aswin Murugan
mach-snapdragon: Add FIT multi-DTB selection support
Implement multi DTB selection from FIT images based on hardware detection via SMEM.
The implementation provides:
1. Hardware Detection: Reads SoC parameters from SMEM including chip ID, version, platform ID, OEM variant, DDR size, and storage type from IMEM.
2. Metadata DTB Processing: Parses a metadata DTB (first image in FIT) to build a "bucket list" of hardware-specific node names that match the detected hardware parameters.
3. FIT Configuration Matching: Uses standard FIT mechanisms to find the configuration with the most matching tokens in its compatible string compared to the hardware-derived bucket list.
4. DTB Loading and Overlays: Loads the base DTB and applies any DTBOs specified in the selected configuration using standard FIT overlay
[...]
arch/arm/mach-snapdragon/Kconfig| 8 +arch/arm/mach-snapdragon/Makefile | 1 + arch/arm/mach-snapdragon/board.c | 7 + arch/arm/mach-snapdragon/qcom_fit_multidtb.c | 1103 ++++++++++++++++++++++++++ arch/arm/mach-snapdragon/qcom_fit_multidtb.h | 189 +++++ 5 files changed, 1308 insertions(+)
arch/arm/mach-snapdragon/board.c int board_late_init(void) · line 590
Quoted 5 lines
arch/arm/mach-snapdragon/board.c +5
-0@@ -585,6 +586,12 @@ int board_late_init(void) +/* Try FIT multi-DTB selection if enabled */ +if (IS_ENABLED (CONFIG_QCOM_FIT_MULTIDTB )) { +if (!qcom_fit_multidtb_setup ()) +log_debug ("FIT multi-DTB selection not available or failed\n" ); + }
The logic seems inverted, since qcom_fit_multidtb_setup() returns 0 on success.
arch/arm/mach-snapdragon/qcom_fit_multidtb.c line 1
Quoted 3 lines
arch/arm/mach-snapdragon/qcom_fit_multidtb.c +1
-0@@ -0,0 +1,1103 @@ +#define TCSR_SOC_HW_VERSION 0x01fc8000
This address is hardcoded - does this mean the same TCSR base is used on all SoCs?
Quoted 7 lines
arch/arm/mach-snapdragon/qcom_fit_multidtb.c +5
-0@@ -0,0 +1,1103 @@ + *ddr_type =0 ; +if (total_ddr_size <=DDR_128MB ) + *ddr_type =DDRTYPE_128MB ; +else if (total_ddr_size <=DDR_256MB ) + *ddr_type =DDRTYPE_256MB ;
arch/arm/mach-snapdragon/qcom_fit_multidtb.c line 15
Quoted 10 lines
arch/arm/mach-snapdragon/qcom_fit_multidtb.c +10
-0+else if (total_ddr_size <=DDR_512MB ) + *ddr_type =DDRTYPE_512MB ; +else if (total_ddr_size <=DDR_1024MB ) + *ddr_type =DDRTYPE_1024MB ; +else if (total_ddr_size <=DDR_2048MB ) + *ddr_type =DDRTYPE_2048MB ; +else if (total_ddr_size <=DDR_3072MB ) + *ddr_type =DDRTYPE_3072MB ; +else if (total_ddr_size <=DDR_4096MB ) + *ddr_type =DDRTYPE_4096MB ;
If total_ddr_size > 4 GB, ddr_type remains 0. Is that intentional, or should there be a final else clause for larger memory configurations?
arch/arm/mach-snapdragon/qcom_fit_multidtb.c line 1
Quoted 3 lines
arch/arm/mach-snapdragon/qcom_fit_multidtb.c +1
-0@@ -0,0 +1,1103 @@ +printf ("DTB: %s\n" , fdt_name);
Maybe use log_info() here for consistency with the rest of the file?
Regards,
Simon
PATCH v3 3/7 configs: snapdragon: Enable FIT multi-DTB and configure IMEM
In reply to Aswin MuruganEnable CONFIG_QCOM_FIT_MULTIDTB by default for Qualcomm Snapdragon platforms to provide automatic DTB selection from qclinux_fit.img with overlay support.
This allows U-Boot to automatically select the appropriate device tree based on hardware parameters detected from SMEM, improving boot compatibility across different hardware variants and reducing the need for board-specific DTB selection logic.
--- configs/qcom_defconfig | 2 ++ 1 file changed, 2 insertions(+)
configs/qcom_defconfig +2 -0
@@ -12,6 +12,7 @@ CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y CONFIG_BUTTON_CMD=y CONFIG_FIT=y CONFIG_FIT_VERBOSE=y +CONFIG_QCOM_FIT_MULTIDTB=y CONFIG_BOOTSTD_FULL=y # CONFIG_BOOTMETH_VBE is not set CONFIG_BOOTDELAY=1
@@ -48,6 +49,7 @@ CONFIG_CMD_RNG=y CONFIG_CMD_REGULATOR=y CONFIG_CMD_LOG=y CONFIG_OF_LIVE=y +CONFIG_OF_LIBFDT_OVERLAY=y CONFIG_OF_UPSTREAM_BUILD_VENDOR=y CONFIG_ENV_USE_DEFAULT_ENV_TEXT_FILE=y CONFIG_ENV_DEFAULT_ENV_TEXT_FILE="board/qualcomm/default.env"
Signature · 1 line
2.34.1
Re: [PATCH v3 3/7] configs: snapdragon: Enable FIT multi-DTB and configure IMEM
Hi Aswin,
Quoted 18 lines · Aswin Murugan
configs: snapdragon: Enable FIT multi-DTB and configure IMEM
Enable
CONFIG_QCOM_FIT_MULTIDTBby default for Qualcomm Snapdragon platforms to provide automatic DTB selection from qclinux_fit.img with overlay support.This allows U-Boot to automatically select the appropriate device tree based on hardware parameters detected from SMEM, improving boot compatibility across different hardware variants and reducing the need for board-specific DTB selection logic.
Signed-off-by Aswin Murugan <[email protected]>configs/qcom_defconfig | 2 ++
1 file changed, 2 insertions(+)
configs/qcom_defconfig CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y · line 15
Quoted 4 lines
configs/qcom_defconfig +1
-0@@ -12,6 +12,7 @@ CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y CONFIG_BUTTON_CMD=y CONFIG_FIT=y CONFIG_FIT_VERBOSE=y +CONFIG_QCOM_FIT_MULTIDTB=y
The subject says 'Enable FIT multi-DTB and configure IMEM' but this patch does not configure IMEM
How about 'configs: snapdragon: Enable FIT multi-DTB support' ?
Regards,
Simon
PATCH v3 4/7 image: add IH_TYPE_FATFS image type
In reply to Aswin MuruganAdd a new image type IH_TYPE_FATFS to represent a raw FAT filesystem partition image. Register the type in the image type lookup table with short name "fatfs" and description "FAT Filesystem Image".
--- boot/image.c | 1 + include/image.h | 1 + 2 files changed, 2 insertions(+)
boot/image.c +1 -0
@@ -136,6 +136,7 @@ static const table_entry_t uimage_type[] = { { IH_TYPE_FILESYSTEM, "filesystem", "Filesystem Image", }, { IH_TYPE_FIRMWARE, "firmware", "Firmware", }, { IH_TYPE_FLATDT, "flat_dt", "Flat Device Tree", }, + { IH_TYPE_FATFS, "fatfs", "FAT Filesystem Image", }, { IH_TYPE_GPIMAGE, "gpimage", "TI Keystone SPL Image",}, { IH_TYPE_KERNEL, "kernel", "Kernel Image", }, { IH_TYPE_KERNEL_NOLOAD, "kernel_noload", "Kernel Image (no loading done)", },
include/image.h +1 -0
@@ -235,6 +235,7 @@ enum image_type_t {IH_TYPE_TFA_BL31 ,/* TFA BL31 image */ IH_TYPE_STM32IMAGE_V2 ,/* STMicroelectronics STM32 Image V2.0 */ IH_TYPE_AMLIMAGE ,/* Amlogic Boot Image */ +IH_TYPE_FATFS ,/* FAT Filesystem Image */ IH_TYPE_COUNT, /* Number of image types */ };
Signature · 1 line
2.34.1
Re: [PATCH v3 4/7] image: add IH_TYPE_FATFS image type
Hi Aswin,
Quoted 15 lines · Aswin Murugan
image: add
IH_TYPE_FATFSimage typeAdd a new image type
IH_TYPE_FATFSto represent a raw FAT filesystem partition image. Register the type in the image type lookup table with short name "fatfs" and description "FAT Filesystem Image".Signed-off-by Aswin Murugan <[email protected]>
boot/image.c| 1 +include/image.h | 1 + 2 files changed, 2 insertions(+)
boot/image.c static const table_entry_t uimage_type[] = { · line 139
Quoted 4 lines
boot/image.c +1
-0@@ -136,6 +136,7 @@ static const table_entry_t uimage_type[] = { { IH_TYPE_FILESYSTEM, "filesystem", "Filesystem Image", }, { IH_TYPE_FIRMWARE, "firmware", "Firmware", }, { IH_TYPE_FLATDT, "flat_dt", "Flat Device Tree", }, + { IH_TYPE_FATFS, "fatfs", "FAT Filesystem Image", },
The uimage_type table is sorted alphabetically by short name. The entry fatfs should come before filesystem (f-a-t < f-i-l), not after flat_dt
Regards,
Simon
PATCH v3 5/7 mkimage: add fatfs image type for FAT partition images
In reply to Aswin MuruganAdd a new mkimage image type 'fatfs' that creates a raw FAT filesystem partition image from a directory of files.
The image handler (fatimage.c) uses mkfs.vfat (dosfstools) to format the image and mcopy (mtools) to populate it. The image size is calculated automatically from the input directory size plus FAT metadata overhead.
New long options added to mkimage:
--fat-extra-space <KB> extra padding (default: 512 KB) --fat-type <0|12|16|32> FAT type (0 = auto-detect) --fat-volume-id <label> volume label (default: BOOT) --fat-mkfs-opts <opts> extra mkfs.vfat options
Usage:
mkimage -T fatfs -d <input-dir> \
--fat-extra-space 512 \
--fat-volume-id "MYBOOT" \
--fat-mkfs-opts "-S 512 -a" \
output.img--- tools/Makefile | 1 + tools/fatimage.c | 495 +++++++++++++++++++++++++++++++++++++++++++++++ tools/fatimage.h | 25 +++ tools/mkimage.c | 21 ++ tools/mkimage.h | 15 ++ 5 files changed, 557 insertions(+) create mode 100644 tools/fatimage.c create mode 100644 tools/fatimage.h
tools/Makefile +1 -0
@@ -112,6 +112,7 @@ ROCKCHIP_OBS = generated/lib/rc4.o rkcommon.o rkimage.o rksd.o rkspi.o dumpimage-mkimage-objs := aisimage.o \ amlimage.o \ atmelimage.o \ + fatimage.o \ $(FIT_OBJS-y) \ $(FIT_SIG_OBJS-y) \ $(FIT_CIPHER_OBJS-y) \
tools/fatimage.c new file +495 -0
495 lines not on this page · raw message
tools/fatimage.h new file +25 -0
@@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* FAT Filesystem Image support for mkimage +* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries +*/ + +#ifndef _FATIMAGE_H_ +#define _FATIMAGE_H_ + +#define SECTOR_SIZE 512 +#define DIR_ENTRY_SIZE 32 +#define FAT_ENTRY_SIZE_FAT32 4 +#define FAT_ENTRY_SIZE_FAT16 2 +#define FAT_ENTRY_SIZE_FAT12 2/* Rounded up from 1.5 bytes */ + +struct fatimage_params { +char *input_dir; +int extra_space;/* Extra padding space in KB (default: 512) */ +int fat_type;/* FAT type: 0=auto, 12/16/32 */ +char *volume_id;/* Volume label (default: "BOOT") */ +char *mkfs_opts;/* Extra mkfs.vfat options (default: "-S 512") */ +}; + +#endif /* _FATIMAGE_H_ */
tools/mkimage.c +21 -0
@@ -204,6 +204,10 @@ static const struct option longopts[] = { { "tfa-bl31-addr", no_argument, NULL, 'Y' }, { "tee-file", no_argument, NULL, 'z' }, { "tee-addr", no_argument, NULL, 'Z' }, +{ "fat-extra-space", required_argument, NULL, OPT_FAT_EXTRA }, + { "fat-type", required_argument, NULL, OPT_FAT_TYPE }, + { "fat-volume-id", required_argument, NULL, OPT_FAT_VOLID }, + { "fat-mkfs-opts", required_argument, NULL, OPT_FAT_MKFS }, { /* sentinel */ }, };
@@ -397,6 +401,18 @@ static void process_args(int argc, char **argv)exit (EXIT_FAILURE ); }break ; +case OPT_FAT_EXTRA : +fatimage_set_extra_space (atoi (optarg)); +break ; +case OPT_FAT_TYPE : +fatimage_set_fat_type (atoi (optarg)); +break ; +case OPT_FAT_VOLID : +fatimage_set_volume_id (optarg); +break ; +case OPT_FAT_MKFS : +fatimage_set_mkfs_opts (optarg); +break ;default :usage ("Invalid option" ); }
@@ -433,6 +449,11 @@ static void process_args(int argc, char **argv) params.type = type; } +if (params.type ==IH_TYPE_FATFS && params.datafile) { +fatimage_set_dir (params.datafile); + params.skipcpy =1 ; + } +if (!params.imagefile)usage ("Missing output filename" ); }
tools/mkimage.h +15 -0
@@ -53,4 +53,19 @@ static inline ulong map_to_sysmem(const void *ptr)#define MKIMAGE_DEFAULT_DTC_OPTIONS "-I dts -O dtb -p 500"#define MKIMAGE_MAX_DTC_CMDLINE_LEN 2 * MKIMAGE_MAX_TMPFILE_LEN + 35 +/* Long option values for mkimage */ +enum { +OPT_FAT_EXTRA =512 , +OPT_FAT_TYPE , +OPT_FAT_VOLID , +OPT_FAT_MKFS , +}; + +/* FAT image functions */ +void fatimage_set_dir (const char *dir); +void fatimage_set_extra_space (int space_kb); +void fatimage_set_fat_type (int type); +void fatimage_set_volume_id (const char *volid); +void fatimage_set_mkfs_opts (const char *opts); +#endif /* _MKIIMAGE_H_ */
Signature · 1 line
2.34.1
Re: [PATCH v3 5/7] mkimage: add fatfs image type for FAT partition images
Hi Aswin,
Quoted 31 lines · Aswin Murugan
mkimage: add fatfs image type for FAT partition images
Add a new mkimage image type 'fatfs' that creates a raw FAT filesystem partition image from a directory of files.
The image handler (
fatimage.c) uses mkfs.vfat (dosfstools) to format the image and mcopy (mtools) to populate it. The image size is calculated automatically from the input directory size plus FAT metadata overhead.New long options added to mkimage:
--fat-extra-space <KB> extra padding (default: 512 KB) --fat-type <0|12|16|32> FAT type (0 = auto-detect) --fat-volume-id <label> volume label (default: BOOT) --fat-mkfs-opts <opts> extra mkfs.vfat optionsUsage:
mkimage -T fatfs -d <input-dir> \ --fat-extra-space 512 \ --fat-volume-id "MYBOOT" \[...]
tools/Makefile| 1 +tools/fatimage.c | 495 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ tools/fatimage.h | 25 +++ tools/mkimage.c | 21 +++ tools/mkimage.h | 15 ++ 5 files changed, 557 insertions(+)
tools/mkimage.c static const struct option longopts[] = { · line 205
Quoted 2 lines
tools/mkimage.c +2
-0@@ -204,6 +204,10 @@ static const struct option longopts[] = { +{ "fat-extra-space", required_argument, NULL, OPT_FAT_EXTRA }, + { "fat-type", required_argument, NULL, OPT_FAT_TYPE },
The first line is missing its leading tab.
tools/fatimage.c line 2
Quoted 4 lines
tools/fatimage.c +2
-0@@ -0,0 +1,495 @@ +static int fatimage_set_header (void *ptr,struct stat *sbuf,int ifd, +struct image_tool_params *params)
The set_header callback in struct image_type_params returns void, not int
Assuming you don't want to update that (which you might?), please change the return type to void and call exit() on unrecoverable errors, like the other image handlers.
tools/fatimage.c line 10
Quoted 12 lines
tools/fatimage.c +10
-0@@ -0,0 +1,495 @@ +static int fatimage_check_params (struct image_tool_params *params) +{ +if (!fatparams.input_dir) { +fprintf (stderr,"Error: Input directory not specified\n" ); +fprintf (stderr,"Use -d <directory> to specify input directory\n" ); +return -1 ; + } + +struct stat st; +if (stat (fatparams.input_dir, &st) <0 ) {
Please move the decl to the start to the top of the function.
Quoted 16 lines
tools/fatimage.c +14
-0@@ -0,0 +1,495 @@ +void fatimage_set_dir (const char *dir) +{ + fatparams.input_dir =strdup (dir); +} + +void fatimage_set_extra_space (int space_kb) +{ + fatparams.extra_space = space_kb; +} + +void fatimage_set_fat_type (int type) +{ + fatparams.fat_type = type; +}
tools/fatimage.c line 24
Quoted 10 lines
tools/fatimage.c +10
-0+ +void fatimage_set_volume_id (const char *volid) +{ + fatparams.volume_id =strdup (volid); +} + +void fatimage_set_mkfs_opts (const char *opts) +{ + fatparams.mkfs_opts =strdup (opts); +}
The strdup() calls in fatimage_set_dir(), fatimage_set_volume_id() and fatimage_set_mkfs_opts() can return NULL, but the return value is not checked. Please check for NULL and handle the error.
Regards,
Simon
PATCH v3 6/7 doc: document mkimage fatfs type and Qualcomm multi-DTB
In reply to Aswin MuruganUpdate doc/mkimage.1 to document the new fatfs image type, the --fat-* long options, a fatfs entry in the CONFIGURATION section, and two usage examples.
Add doc/board/qualcomm/multi_dtb.rst describing the Qualcomm FIT-based multi-DTB packaging workflow for Snapdragon platforms. The document covers:
- FIT ITS configuration and compatible string matching
- QCOM metadata binary format and identifier properties
- Guidelines for adding new socver/boardrev entries
- Step-by-step image creation using mkimage -T fatfs
Update doc/board/qualcomm/index.rst to include the new multi_dtb page in the toctree.
--- doc/board/qualcomm/index.rst | 1 + doc/board/qualcomm/multi_dtb.rst | 352 +++++++++++++++++++++++++++++++ doc/mkimage.1 | 103 +++++++++ 3 files changed, 456 insertions(+) create mode 100644 doc/board/qualcomm/multi_dtb.rst
doc/board/qualcomm/index.rst +1 -0
@@ -10,6 +10,7 @@ Qualcomm debugging dragonboard410c dragonwing + multi_dtb rb3gen2 iq8 phones
doc/board/qualcomm/multi_dtb.rst new file +352 -0
352 lines not on this page · raw message
doc/mkimage.1 +103 -0
137 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v3 6/7] doc: document mkimage fatfs type and Qualcomm multi-DTB
Hi Aswin,
Quoted 26 lines · Aswin Murugan
doc: document mkimage fatfs type and Qualcomm multi-DTB
Update doc/mkimage.1 to document the new fatfs image type, the --fat-* long options, a fatfs entry in the CONFIGURATION section, and two usage examples.
Add
doc/board/qualcomm/multi_dtb.rstdescribing the Qualcomm FIT-based multi-DTB packaging workflow for Snapdragon platforms. The document covers:
- FIT ITS configuration and compatible string matching
- QCOM metadata binary format and identifier properties
- Guidelines for adding new socver/boardrev entries
- Step-by-step image creation using mkimage -T fatfsUpdate
doc/board/qualcomm/index.rstto include the newmulti_dtbpage in the toctree.Signed-off-by Aswin Murugan <[email protected]>
doc/board/qualcomm/index.rst| 1 +doc/board/qualcomm/multi_dtb.rst | 352 +++++++++++++++++++++++++++++++++++++++ doc/mkimage.1 | 103 ++++++++++++ 3 files changed, 456 insertions(+)
doc/board/qualcomm/multi_dtb.rst line 2
Quoted 2 lines
doc/board/qualcomm/multi_dtb.rst +2
-0@@ -0,0 +1,352 @@ + cp -rap <u-boot build dir>/dts/upstream/src/arm64/qcom/*.dtb* \ + fit_image/arch/arm64/boot/dts/qcom/
The text above refers to "Qualcomm Linux Kernel Tree" but the placeholder says "u-boot build dir". Please change this to reference the kernel build directory.
doc/board/qualcomm/multi_dtb.rst line 3
Quoted 5 lines
doc/board/qualcomm/multi_dtb.rst +3
-0@@ -0,0 +1,352 @@ +1. **Install required tools**:: + + sudo apt-get install device-tree-compiler u-boot-tools mtools
Step 6 notes that dosfstools is also required for mkfs.vfat - please add dosfstools to this install command.
doc/board/qualcomm/multi_dtb.rst line 6
Quoted 8 lines
doc/board/qualcomm/multi_dtb.rst +6
-0@@ -0,0 +1,352 @@ +6. **Pack the FIT image into a FAT partition image using mkimage** + + The `mkimage tool supports creating FAT filesystem images directly via + the fatfs image type. + + mkimage -T fatfs -d out/ fitimage.bin \
This code block is missing the RST literal-block marker, i.e. the text before it should end with ::
doc/mkimage.1 of data storage. · line 985
Quoted 4 lines
doc/mkimage.1 +2
-0@@ -903,10 +984,32 @@ of data storage. +.BR mkfs.vfat (8), +.BR mcopy (1),
The SEE ALSO entries should be in alphabetical order. Please swap these two lines so mcopy comes before mkfs.vfat
Regards,
Simon
PATCH v3 7/7 mach-snapdragon: Reorder header includes
In reply to Aswin MuruganRearrange the header include order for better readability and consistency. No functional change intended.
--- arch/arm/mach-snapdragon/board.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
arch/arm/mach-snapdragon/board.c +12 -13
@@ -9,6 +9,16 @@#define LOG_CATEGORY LOGC_BOARD#define pr_fmt (fmt) "QCOM: " fmt +#include <env.h> +#include <fdt_support.h> +#include <init.h> +#include <lmb.h> +#include <malloc.h> +#include <power/regulator.h> +#include <smem.h> +#include <sort.h> +#include <time.h> +#include <usb.h> #include <asm/armv8/mmu.h> #include <asm/gpio.h> #include <asm/io.h>
@@ -16,24 +26,13 @@#include <asm/system.h> #include <dm/device.h> #include <dm/pinctrl.h> -#include <dm/uclass.h> -#include <dm/uclass-internal.h> #include <dm/read.h> -#include <power/regulator.h> -#include <env.h> -#include <fdt_support.h> -#include <init.h> +#include <dm/uclass-internal.h> +#include <dm/uclass.h> #include <linux/arm-smccc.h> #include <linux/bug.h> #include <linux/psci.h> #include <linux/sizes.h> -#include <lmb.h> -#include <malloc.h> -#include <fdt_support.h> -#include <usb.h> -#include <smem.h> -#include <sort.h> -#include <time.h> #include "qcom_fit_multidtb.h" #include "qcom-priv.h"
Signature · 1 line
2.34.1
Re: [PATCH v3 7/7] mach-snapdragon: Reorder header includes
Quoted 9 lines · Aswin Murugan
mach-snapdragon: Reorder header includes
Rearrange the header include order for better readability and consistency. No functional change intended.
Signed-off-by Aswin Murugan <[email protected]>
arch/arm/mach-snapdragon/board.c| 25 ++++++++++++-------------1 file changed, 12 insertions(+), 13 deletions(-)
Quoted 7 lines · Aswin Murugan
This series adds dynamic device tree selection from FIT images for Qualcomm Snapdragon platforms, enabling U-Boot to select the appropriate DTB based on hardware parameters detected from SMEM.
Qualcomm fit based DTB format is documented in [1]
The fit image contains only DTB, while the kernel will be part of UKI image.
I suppose you know that UKIs (systemd-boot, EFI Boot Guard) provide DTB selection as well. However, that is a fix-up for the case the firmware does not provide a fitting DTB. This here is supposed to support the firmware DTB delivery, correct?
Jan
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center
Hi Jan,
Quoted 5 lines · Jan Kiszka
Quoted 4 lines · Aswin Murugan
This series adds dynamic device tree selection from FIT images for Qualcomm Snapdragon platforms, enabling U-Boot to select the appropriate DTB based on hardware parameters detected from SMEM.
Quoted 9 lines
Quoted 3 lines
Qualcomm fit based DTB format is documented in [1]
The fit image contains only DTB, while the kernel will be part of UKI image.I suppose you know that UKIs (systemd-boot, EFI Boot Guard) provide DTB selection as well. However, that is a fix-up for the case the firmware does not provide a fitting DTB. This here is supposed to support the firmware DTB delivery, correct?
I would say instead that it's an alternate way to bundle multiple DTBs in a specific DT partition which are used by firmware to select appropriate DTB for the board the firmware is running on.
The source of this DTBs are from kernel only where the OEM has to take care of 1:1 compatibility among kernel and DTB. This approach has been deployed for Yocto and Android based systems but I do agree with general purpose distros bundling DTBs in UKIs is surely an alternative option.
-Sumit
Quoted 18 lines · Sumit Garg
Hi Jan,
Quoted 5 lines · Jan Kiszka
Quoted 4 lines · Aswin Murugan
This series adds dynamic device tree selection from FIT images for Qualcomm Snapdragon platforms, enabling U-Boot to select the appropriate DTB based on hardware parameters detected from SMEM.
Quoted 9 lines
Quoted 3 lines
Qualcomm fit based DTB format is documented in [1]
The fit image contains only DTB, while the kernel will be part of UKI image.I suppose you know that UKIs (systemd-boot, EFI Boot Guard) provide DTB selection as well. However, that is a fix-up for the case the firmware does not provide a fitting DTB. This here is supposed to support the firmware DTB delivery, correct?
Quoted 3 lines
I would say instead that it's an alternate way to bundle multiple DTBs in a specific DT partition which are used by firmware to select appropriate DTB for the board the firmware is running on.
Right. We (and likely not only us) implemented that kind of DTB selection many years ago for the IOT2050 boards with existing U-Boot features here. But we embedded the supported DTBs into the U-Boot FIT image so that they naturally become part of the secure boot chain.
Quoted 5 lines
The source of this DTBs are from kernel only where the OEM has to take care of 1:1 compatibility among kernel and DTB. This approach has been deployed for Yocto and Android based systems but I do agree with general purpose distros bundling DTBs in UKIs is surely an alternative option.
This is just a workaround for broken vendor firmware or vendor kernels. In the ideal world, the firmware delivers an upstream-approved DTB to an upstream kernel. Any update of firmware or kernel only augments bindings and DTBs, adding features or refining them in a compatible way, not breaking them - SystemReady.
In real world, premature vendor code gets shipped first and only cleaned up later on via upstream (if at all). Then you need to fix up the mismatches between in-field firmware and upstreamed kernels. And all that obviously in secure, updatable way, therefore UKI embedding.
Jan
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center
Quoted 19 lines · Jan Kiszka
Quoted 18 lines · Sumit Garg
Hi Jan,
Quoted 14 lines · Jan Kiszka
Quoted 7 lines · Aswin Murugan
This series adds dynamic device tree selection from FIT images for Qualcomm Snapdragon platforms, enabling U-Boot to select the appropriate DTB based on hardware parameters detected from SMEM.
Qualcomm fit based DTB format is documented in [1]
The fit image contains only DTB, while the kernel will be part of UKI image.I suppose you know that UKIs (systemd-boot, EFI Boot Guard) provide DTB selection as well. However, that is a fix-up for the case the firmware does not provide a fitting DTB. This here is supposed to support the firmware DTB delivery, correct?
Quoted 8 lines
Quoted 3 lines
I would say instead that it's an alternate way to bundle multiple DTBs in a specific DT partition which are used by firmware to select appropriate DTB for the board the firmware is running on.
Right. We (and likely not only us) implemented that kind of DTB selection many years ago for the IOT2050 boards with existing U-Boot features here. But we embedded the supported DTBs into the U-Boot FIT image so that they naturally become part of the secure boot chain.
Yeah but this apporach of DTBs only FIT decouples it from how kernel secure boot chain works whether it's based on UEFI secure boot or FIT based or any other approach.
Quoted 7 lines
Quoted 6 lines
The source of this DTBs are from kernel only where the OEM has to take care of 1:1 compatibility among kernel and DTB. This approach has been deployed for Yocto and Android based systems but I do agree with general purpose distros bundling DTBs in UKIs is surely an alternative option.
Quoted 5 lines
This is just a workaround for broken vendor firmware or vendor kernels. In the ideal world, the firmware delivers an upstream-approved DTB to an upstream kernel. Any update of firmware or kernel only augments bindings and DTBs, adding features or refining them in a compatible way, not breaking them - SystemReady.
Here this multi DTB isn't part of the kernel image and nor part of the firmware image but has to get independent updates which surely have to be aligned with the kernel to avoid any breakage. However, this approach tries to acheive SystemReady in that way.
Quoted 6 lines
In real world, premature vendor code gets shipped first and only cleaned up later on via upstream (if at all). Then you need to fix up the mismatches between in-field firmware and upstreamed kernels. And all that obviously in secure, updatable way, therefore UKI embedding.
I do agree the DT incompatibilities are always hard to manage however the vertically integrated stacks like Android or Yocto which Qualcomm SoCs supported don't always want DTBs or overlays to be bundled alongside the kernel image. However, surely we want the general purpose distros to be supported as well which can always over-ride DT as needed.
In summary, from Qualcomm point of view, we will try to support both these multi FIT DTBs approach as well as the UKI bundling. In the end it really depends on the OS vendors to choose whichever approach suits best to their needs when it comes to in field updates.
-Sumit
Quoted 14 lines · Aswin Murugan
This series adds dynamic device tree selection from FIT images for Qualcomm Snapdragon platforms, enabling U-Boot to select the appropriate DTB based on hardware parameters detected from SMEM.
Qualcomm fit based DTB format is documented in [1]
The fit image contains only DTB, while the kernel will be part of UKI image.The implementation consists of three parts:
1. SMEM cache infrastructure: Provides cached access to commonly used SMEM data (socinfo, RAM partitions) to avoid redundant lookups during boot. Includes socinfo header from Linux kernel for SoC identification.
Quoted 8 lines
2. FIT multi-DTB selection: Implements the core selection logic that reads hardware parameters from SMEM, parses metadata DTB, matches FIT configurations, and loads the selected DTB with overlays. Integrates with EFI boot flow by setting
fdt_addr.3. mkimage: add fatfs image type for FAT partition images Added
fatimage.chandler that uses mkfs.vfat and mcopy to create FAT images from a directory.
I'm unsure why part 3 here is appropriate for U-Boot. It's wrapping existing tooling to create a fat image?
Signature · 1 line
Tom
Quoted 20 lines · Tom Rini
Quoted 19 lines · Aswin Murugan
This series adds dynamic device tree selection from FIT images for Qualcomm Snapdragon platforms, enabling U-Boot to select the appropriate DTB based on hardware parameters detected from SMEM.
Qualcomm fit based DTB format is documented in [1]
The fit image contains only DTB, while the kernel will be part of UKI image.The implementation consists of three parts:
1. SMEM cache infrastructure: Provides cached access to commonly used SMEM data (socinfo, RAM partitions) to avoid redundant lookups during boot. Includes socinfo header from Linux kernel for SoC identification.
2. FIT multi-DTB selection: Implements the core selection logic that reads hardware parameters from SMEM, parses metadata DTB, matches FIT configurations, and loads the selected DTB with overlays. Integrates with EFI boot flow by setting
fdt_addr.
Quoted 7 lines
Quoted 3 lines
3. mkimage: add fatfs image type for FAT partition images Added
fatimage.chandler that uses mkfs.vfat and mcopy to create FAT images from a directory.I'm unsure why part 3 here is appropriate for U-Boot. It's wrapping existing tooling to create a fat image?
I concur. Aswin, you need to justify with a usecase because I don't see a benefit for generating a fat image from mkimage for now. Why do you even need a filesystem for just the fitimage? Why not flash the fitimage directly on the partition?
Cheers,
Quentin
Hi Aswin, Sumit,
Sorry it's taken a while, you should have the new version of the SMEM revamp in your inbox now (or here
https://lore.kernel.org/u-boot/[email protected]/)
I used the header from this series with some cleanups. You should be able to rebase on that and we can get this series moving forwards a bit more.
Quoted 7 lines · Aswin Murugan
This series adds dynamic device tree selection from FIT images for Qualcomm Snapdragon platforms, enabling U-Boot to select the appropriate DTB based on hardware parameters detected from SMEM.
Qualcomm fit based DTB format is documented in [1]
The fit image contains only DTB, while the kernel will be part of UKI image.
Quoted 6 lines
The implementation consists of three parts:
1. SMEM cache infrastructure: Provides cached access to commonly used SMEM data (socinfo, RAM partitions) to avoid redundant lookups during boot. Includes socinfo header from Linux kernel for SoC identification.
I think this abstraction is at the wrong layer, you shouldn't be accessing SMEM in a hot path, it seems more like your "cache" here is just the state of the FIT parsing state machine? In which case it would be much better modelled as a state object rather than spreading the state around a bunch of wrapper functions.
Quoted 5 lines
2. FIT multi-DTB selection: Implements the core selection logic that reads hardware parameters from SMEM, parses metadata DTB, matches FIT configurations, and loads the selected DTB with overlays. Integrates with EFI boot flow by setting
fdt_addr.
The way this code is currently laid out generally makes it quite confusing to parse, as with my previous point I think you should rewrite this to first get all the data you need together in one struct and translate it into suitable formats (e.g. if you only need a few things from socinfo then just get those and don't carry around a big socinfo pointer where it isn't clear which properties are actually used).
Stuff like the IMEM cookie should be in it's own abstraction maybe under drivers/soc/qcom that only exposes the properties that actually make sense.
This would then let you bring down the size of this huge file so it's a bit more manageable.
Some properties like the mem_card_type from IMEM would be extremely useful for simplifying the capsule update code for example, so having this as a separate abstraction would greatly improve things.
Thanks and kind regards,
Quoted 79 lines
3. mkimage: add fatfs image type for FAT partition images Added
fatimage.chandler that uses mkfs.vfat and mcopy to create FAT images from a directory.[1] https://github.com/qualcomm-linux/qcom-dtb-metadata/blob/main/Documentation.md
---
Changes in v3:
1. Runtime IMEM address lookup via DT: RemovedCONFIG_QCOM_IMEM_SIZEKconfigoption. Added qcom_imem_table[] mapping SoC compatible strings to IMEM addresses.2. Split SoC version sources: SoC hardware version now read from TCSR register via
qcom_read_tcsr_soc_version(). Thesoc_info->plat_verfrom SMEM is stored separately asboard_version. Added socver and boardrev metadata node matching for finer-grained DTB selection.3.
qcom_load_fit_image()returns int: Changed return type fromefi_status_tto int, returning standard Linux error codes for consistency with the rest of the driver.4. Code cleanup:
strtok()replaced withstrsep(); memcpy + manual null-termination replaced withstrlcpy(); DDR thresholds use SZ_* macros; compatible matching and FDT loading extracted into dedicated helpers.5. image: add
IH_TYPE_FATFSimage type: Added new fatfs image type to represent a raw FAT filesystem partition image, registered in the image type lookup table.6. mkimage: add fatfs image type for FAT partition images: Added
fatimage.chandler that uses mkfs.vfat and mcopy to create FAT images from a directory.
New --fat-extra-space, --fat-type, --fat-volume-id, --fat-mkfs-opts long options added to mkimage.7. doc: document mkimage fatfs type and Qualcomm multi-DTB: Updated 'doc/mkimage.1' for the new fatfs type and options. Added '
doc/board/qualcomm/multi_dtb.rst' covering FIT ITS configuration, QCOM metadata format, socver/boardrev guidelines, and image creation steps.Link to v2:
https://lore.kernel.org/u-boot/[email protected]/Changes in v2:
- In v1, a combined DTB format was used for multi-DTB support. Based on
feedback, v2 implements FIT-based DTB selection instead.
- Link to v1: https://lore.kernel.org/all/[email protected]/Aswin Murugan (7):
mach-snapdragon: Add generic SMEM cache infrastructure
mach-snapdragon: Add FIT multi-DTB selection support
configs: snapdragon: Enable FIT multi-DTB and configure IMEM
image: addIH_TYPE_FATFSimage type
mkimage: add fatfs image type for FAT partition images
doc: document mkimage fatfs type and Qualcomm multi-DTB
mach-snapdragon: Reorder header includesarch/arm/mach-snapdragon/Kconfig | 8 + arch/arm/mach-snapdragon/Makefile | 1 + arch/arm/mach-snapdragon/board.c | 123 +- arch/arm/mach-snapdragon/qcom-priv.h | 24 + arch/arm/mach-snapdragon/qcom_fit_multidtb.c | 1103 ++++++++++++++++++ arch/arm/mach-snapdragon/qcom_fit_multidtb.h | 189 +++ arch/arm/mach-snapdragon/rampart.h | 225 ++++ boot/image.c | 1 + configs/qcom_defconfig | 2 + doc/board/qualcomm/index.rst | 1 + doc/board/qualcomm/multi_dtb.rst | 352 ++++++ doc/mkimage.1 | 103 ++ include/image.h | 1 + include/soc/qcom/socinfo.h | 114 ++ tools/Makefile | 1 + tools/fatimage.c | 495 ++++++++ tools/fatimage.h | 25 + tools/mkimage.c | 21 + tools/mkimage.h | 15 + 19 files changed, 2793 insertions(+), 11 deletions(-) create mode 100644 arch/arm/mach-snapdragon/qcom_fit_multidtb.c create mode 100644 arch/arm/mach-snapdragon/qcom_fit_multidtb.h create mode 100644 arch/arm/mach-snapdragon/rampart.h create mode 100644 doc/board/qualcomm/multi_dtb.rst create mode 100644 include/soc/qcom/socinfo.h create mode 100644 tools/fatimage.c create mode 100644 tools/fatimage.h
Signature · 1 line
// Casey (she/her)