Android Qcom board-id加载镜像学习

高通 MSM8K bootloader : SBL1
高通平台CDT解析和制作方法
lk启动之boot_linux_from_mmc

    很早就听说过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 data


boot_config_data_table_init
    boot_update_config_data_table  default table boot_cdt_array_a/b.c
         boot_flash_configure_target_image for loading CDT bin image 

BOOT.XF.4.1/boot_images/QcomPkg/Tools 生成boot_cdt_array.c可以覆盖default
    python cdt_generator.py cdp_1.0_jedec_lpddr4.xml custom_cdt.bin

BOOT.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               0x00

devicetree borad_id
Platform subtype   Platform MajorVersion   Platform MinVersion  Platform typeId
      0x01                 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
LinuxLoaderEntry

abl/bootloader/edk2/QcomModulePkg/Library/BootLib/BootLinux.c
BootLinux
	GetImage                IsBuildUseRecoveryAsBoot boot or recovery 获取image buffer and size
	GZipPkgCheck            depress gzip(kernel)
	DTBImgCheckAndAppendDT (1)根据不同boot_img_hdr部署bootimage (BootImage.h中有3种部署,后续再讨论)
			               (2)GetSocDtb GetBoardDtb (msm-id) (board-id)去匹配dtb以及dtbo
			                  ApplyOverlay将主设备树和叠加设备树从存储中加载到内存中,将合并后的地址用于内核启动中
			               (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 GPIO

way two:
PlatformID:: Read PlatformID from eeprom

Decompressing kernel image total time: 476 ms
Find Best Dtbo count = 46 DtPlatformtype = 0x44 DtPlatformSoctype = 0x0, DtPlatformSubtype = 0x1
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值