很早就听说过board-id能用来区分项目,没负责过这个,也一直没有时间去了解。board-id的可以通过gpio或者eeprom来存放,board-id也就是CDT中的部分内容,如果时gpio的方式,可配置的项目有些而且在主板上的都是hardcode,这样不利于维护。
XBL-CDT
default:
BOOT.XF.4.1/boot_images/QcomPkg/Library/PlatformInfoLib/PlatformInfoLoader.c typedef struct PACK(PlatformInfoCDTType){uint8 nVersion;uint8 nPlatform;uint8 nHWVersionMajor;uint8 nHWVersionMinor;uint8 nSubtype;uint8 nNumKVPS;PlatformInfoKVPSCDTType aKVPS[];} PlatformInfoCDTType;CDT中存放 Platform ID和DDR参数 ■ The CDT header consists of
□ A magic number
□ A version number
□ Two reserved fields
■ The block metadata section
■ Individual CDBs
□ CDB0 – Platform ID
□ CDB1 – DDR parameters
□ Additional CDBs – user-defined databoot_config_data_table_initboot_update_config_data_table default table boot_cdt_array_a/b.cboot_flash_configure_target_image for loading CDT bin image BOOT.XF.4.1/boot_images/QcomPkg/Tools 生成boot_cdt_array.c可以覆盖defaultpython cdt_generator.py cdp_1.0_jedec_lpddr4.xml custom_cdt.binBOOT.XF.4.1/boot_images/QcomPkg/Tools/cdp_1.0_jedec_lpddr4.xml<device id="cdb0"><props name="platform_id" type="DALPROP_ATTR_TYPE_BYTE_SEQ"> 0x03, 0x44, 0x00, 0x00, 0x01, 0x00, end </props>cdt platform_id 具体要看平台定义
Version number Platform type HW MajorVersion HW MinVersion platform subtype fusion false(KVP)0x03 0x44 0x00 0x00 0x01 0x00devicetree borad_id
Platform subtype Platform MajorVersion Platform MinVersion Platform typeId0x01 0x00 0x00 0x44
devicetree qcom,board-id = <0x01000044 0x0>;
ABL-LinuxLoader
abl/tianocore/edk2/QcomModulePkg/Application/LinuxLoader/LinuxLoader.inf
abl/tianocore/edk2/QcomModulePkg/Application/LinuxLoader/LinuxLoader.c
LinuxLoaderEntryabl/bootloader/edk2/QcomModulePkg/Library/BootLib/BootLinux.c
BootLinuxGetImage IsBuildUseRecoveryAsBoot boot or recovery 获取image buffer and sizeGZipPkgCheck depress gzip(kernel)DTBImgCheckAndAppendDT (1)根据不同boot_img_hdr部署bootimage (BootImage.h中有3种部署,后续再讨论)(2)GetSocDtb GetBoardDtb (msm-id) (board-id)去匹配dtb以及dtboApplyOverlay将主设备树和叠加设备树从存储中加载到内存中,将合并后的地址用于内核启动中(3)board-id是由BoardTargetId去组合得到0x01000044,组合规则如下(((platform_board_info.PlatformInfo.subtype & 0xff) << 24) |(((platform_board_info.PlatformInfo.version >> 16) & 0xff) << 16) |((platform_board_info.PlatformInfo.version & 0xff) << 8) |(platform_board_info.PlatformInfo.platform & 0xff));UpdateCmdLine 将MfgDataBoardId即BoardTargetId更新到cmdline中LinuxKernel = (LINUX_KERNEL) (UINT64)BootParamlistPtr.KernelLoadAddr;LinuxKernel ((UINT64)BootParamlistPtr.DeviceTreeLoadAddr, 0, 0, 0);
boot_img_hdr
Device Tree Overlays
Boot Image Header
Android 12 can use boot header version 3 or 4. 如果是kernel 5.4 引入GKI的版本, version 4 is the primary boot image.
Android 11 can use boot header version 3. 如果是GKI, this version must be used for the primary boot image.
Android 10 must use boot header version 2.
Android 9 must use boot header version 1.
Android 8 and lower are considered as using a boot image header version 0./* When the boot image header has a version of BOOT_HEADER_VERSION_ZERO/ONE/TWO,* the structure of the boot image is as follows:* +-----------------+ ------- -------- -------* | boot header | 1 page* +-----------------+* | kernel | n pages* +-----------------+ v0* | ramdisk | m pages v1* +-----------------+ v2 * | second stage | o pages * +-----------------+ ------- * | recovery dtbo | p pages * +-----------------+ --------* | dtb.img | q pages --------
Android是支持A/B分区分别用于boot和ota,在DTBImgCheckAndAppendDT 这个函数中会去判断boot image header;GKI后可以看到partition xml会有新增vendor_boot_a,引入一个vendor_boot.img镜像,dtb的镜像存放也就从boot转移到vendor_boot中(原先的位置时在bootimage的ramdisk下面),以及原先的camera驱动转变成camera.ko后,烧写boot是不生效的。
/* When the boot image header has a version of 3, the structure of the boot* image is as follows:** +---------------------+* | boot header | 4096 bytes* +---------------------+* | kernel | m pages* +---------------------+* | ramdisk | n pages* +---------------------+** m = (kernel_size + 4096 - 1) / 4096* n = (ramdisk_size + 4096 - 1) / 4096** Note that in version 3 of the boot image header, page size is fixed at 4096 bytes.** The structure of the vendor boot image (introduced with version 3 and* required to be present when a v3 boot image is used) is as follows:** +---------------------+* | vendor boot header | 1 page* +---------------------+* | vendor ramdisk | o pages* +---------------------+* | dtb | p pages* +---------------------+* o = (vendor_ramdisk_size + page_size - 1) / page_size* p = (dtb_size + page_size - 1) / page_size
LOG
way one:
mfg_load_from_eeprom failed -22
PlatformID:: Read PlatformID from GPIOway two:
PlatformID:: Read PlatformID from eepromDecompressing kernel image total time: 476 ms
Find Best Dtbo count = 46 DtPlatformtype = 0x44 DtPlatformSoctype = 0x0, DtPlatformSubtype = 0x1