Device tree customization
Step 5: Generate the CDT so that SBL becomes aware of the new hardware variant ID and passes this information to LK - please refer to solution
Boot Procedure
1. sbl1 load default cdt table(config_data_table[]) in sbl1.mbn.
1. sbl1 check CDT partition which is saved in boot partition of emmc. If yes, overwrite the default cdt table.
3. sbl1 pass platform info to lk by SMEM
5. lk pass correct dt entry address to kernel
Key Functions
SBL1
boot_update_config_data_table(boot_images\core\boot\secboot3\src\boot_config_emmc.c)
LK
dev_tree_get_entry_ptr(bootable\bootloader\lk\platform\msm_shared\dev_tree.c)
Key Enumeration
boot_images\core\api\systemdrivers\DDIChipInfo.h
DALCHIPINFO_ID_MSM8626 = 145,
DALCHIPINFO_ID_MSM8226 = 158,
boot_images\core\api\systemdrivers\DDIPlatformInfo.h
...
DALPLATFORMINFO_TYPE_CDP = 0x01, /**< Target is a MSM CDP/SURF device. */
DALPLATFORMINFO_TYPE_MTP_MSM = 0x08, /**< Target is a MSM MTP device. */
DALPLATFORMINFO_TYPE_QRD = 0x0B, /**< Target is a QRD device. */
DT Header
About dt.img format, please refer to dtbtool.txt and bootable\bootloader\lk\platform\msm_shared\smem.h
kernel\arch\arm\boot\dts\msm8226-cdp.dts
model = "Qualcomm MSM 8226 CDP";
compatible = "qcom,msm8226-cdp", "qcom,msm8226", "qcom,cdp";
qcom,msm-id = <145 1 0>;
kernel\arch\arm\boot\dts\msm8226-mtp.dts
model = "Qualcomm MSM 8226 MTP";
compatible = "qcom,msm8226-mtp", "qcom,msm8226", "qcom,mtp";
qcom,msm-id = <145 8 0>;
kernel\arch\arm\boot\dts\msm8226-qrd.dts
model = "Qualcomm MSM 8226 QRD";
compatible = "qcom,msm8226-qrd", "qcom,msm8226", "qcom,qrd";
qcom,msm-id = <145 11 0>;
kernel\arch\arm\boot\dts\msm8916-qrd-skuh.dts
model = "Qualcomm Technologies, Inc. MSM 8916 QRD SKUH";
compatible = "qcom,msm8916-qrd-skuh", "qcom,msm8916-qrd", "qcom,msm8916", "qcom,qrd";
qcom,board-id = <0x1000b 0> , <0x1000b 4>;
Notes: Here subtype = 0/4; major version= 01 minor version = 00, platform type = 0b
CDT Description XML
boot_images\core\boot\secboot3\scripts\jedec_lpddr2_single_channel.xml
<device id="cdb0">
<props name="platform_id" type="DALPROP_ATTR_TYPE_BYTE_SEQ">
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, end
</props>
</device>
Example of 8x26 device
CDP:
0x03, 0x01, 0x01, 0x00, 0x00, 0x00, end
MTP:
0x03, 0x08, 0x01, 0x00, 0x00, 0x00, end
QRD:
0x03, 0x0B, 0x01, 0x00, 0x00, 0x00, end
Example of 8916 device
QRD SKUH:
0x03, 0x0B, 0x01, 0x00, 0x04, 0x00, end
Byte 0: platform_id Version
Byte 1: platform_id type:
0x01: Target is a SURF device
0x08: Target is a MTP device
0x0B: Target is a QRD device
Byte 2: platform_id major platform version
Byte 3: platform_id minor platform version
Byte 4: platform_id subtype
What's you need do?
Generate CDT image and boot_cdt_array.c
Program CDT image on device
cd boot_images/core/boot/secboot3/scripts/emmc_cdt_program_scripts
python ../../../../storage/tools/ptool/ptool.py -x partition.xml -p 2
modify <jedec_lpddr2_single_channel.xml>
QRD HW V2:
0x03, 0x0B, 0x02, 0x00, 0x00, 0x00, end
python cdt_generator.py jedec_lpddr2_single_channel.xml platform_ddr.bin
cp platform_ddr.bin emmc_cdt_program_scripts
T32
run platform_ddr_emmc_cdt_program.cmm
QPST
platform_ddr_prog_cfg.xml
Change default CDT in sbl1 image
Generate DT Binary
Temp workaround
After previous step, if the device still stop at LK(usb port fastboot), you can try this temp workaround
bootable\bootloader\lk\platform\msm_shared\dev_tree.c
struct dt_entry * dev_tree_get_entry_ptr(struct dt_table *table)
{
<snip>
//workaround: find out the DTB entry index from boot.img(or dt.img)
// change below code, force return expected expected dt_entry_ptr,
if((dt_entry_ptr->platform_id == board_platform_id()) /* &&
(dt_entry_ptr->variant_id == 1) &&
(dt_entry_ptr->soc_rev == 0) */ )
{
return dt_entry_ptr ++;
How to debug
When mismatch issue happens, lk normally will print error log with below format:
ERROR: Unable to find suitable device tree for device ( [ chipset id ] [ soc version ] [ platform id type] [ platform subtype] )
for example as below
ERROR: Unable to find suitable device tree for device (164/0x00010001/11/0)
Match Procedure
1. SBL will get chipset id, soc version from H/W regiser
2. SBL fetch platform id type and platform subtype from CDT partitioin
3. SBL write those information into share memory
4. LK get those information and try to find suitable DTS entry.
[chipset id] and [soc version]:
For device:
read from H/W register, can not modify
For DTS:
qcom,msm-id = <chipset_id, soc version>
[Platform id type] and [platform subtype]:
For device, defined in CDT xml file with below format:
boot_images\core\boot\secboot3\scripts\jedec_lpddr2_single_channel.xml
<device id="cdb0">
<props name="platform_id" type="DALPROP_ATTR_TYPE_BYTE_SEQ">
0x03, 0x0B, 0x01, 0x00, 0x04, 0x00, end
</props>
</device>
Byte 0: platform_id Version
Byte 1: platform_id type:
0x01: Target is a SURF device
0x08: Target is a MTP device
0x0B: Target is a QRD device
Byte 2: platform_id major platform version
Byte 3: platform_id minor platform version
Byte 4: platform_id subtype
So what you need is to care about Byte 1 and Byte 4
For DTS:
qcom,board-id = <platform_id, subtype_id>
发布日期:2021-06-30 21:52:21
浏览次数:3
分类:技术文章
本文共 7249 字,大约阅读时间需要 24 分钟。
Step 1: OEMs can create their own device tree by adding "qcom,msm-id/qcom,board-id" entry at the top of their file. The hardware variant ID has to be unique and created by the OEMs. Please refer to slides 10-13 in doc # .
qcom,msm-id = <x z>;
qcom,board-id = <y y'>;
qcom,board-id = <y y'>;
x = ID for platform id
y = ID for CDP, MTP (hardware variants) etc. -- This needs to be created by the OEMs
y' = ID for subtype (assumed zero if absent)
z = ID for soc revision
Only "y" needs to be created, rest of the IDs remain the same.
Step 2: OEMs should also add their new hardware variant in "compatible" string in the new device tree file being created :
For example: compatible = "qcom,msm8916-xxx", "qcom,msm8916", "yyyy,xxx"
In this example, "yyyy,xxx" is the new compatible string for the new hardware variant.
Addition of a new SOC entry
Step 3: A new SOC entry should be defined (for the corresponding compatible string created in step 2) in the file include/soc/qcom/socinfo.h :
For example: # define of_board_is_xxx() of_machine_is_compatible(“yyyy,xxx”)
Please make sure to use the same string ("yyyy,xx") as created in Step 2 above.
Based on this soc entry, different GPIOs are installed. Please refer to solution # for GPIO configuration in kernel.
Makefile changes
Step 4: Please make sure that the new device tree file gets compiled by modifying the Makefile accordingly.
File: arch/arm64/boot/dts/qcom/Makefile
Please add the new DTB file entry under the appropriate target config so that it gets compiled.
Generation of CDT
Boot Procedure
1. sbl1 load default cdt table(config_data_table[]) in sbl1.mbn.
1. sbl1 check CDT partition which is saved in boot partition of emmc. If yes, overwrite the default cdt table.
3. sbl1 pass platform info to lk by SMEM
- sbl1 - SMEM_HW_SW_BUILD_ID
- lk - SMEM_BOARD_INFO_LOCATION
5. lk pass correct dt entry address to kernel
Key Functions
SBL1
boot_update_config_data_table(boot_images\core\boot\secboot3\src\boot_config_emmc.c)
LK
dev_tree_get_entry_ptr(bootable\bootloader\lk\platform\msm_shared\dev_tree.c)
Key Enumeration
boot_images\core\api\systemdrivers\DDIChipInfo.h
DALCHIPINFO_ID_MSM8626 = 145,
DALCHIPINFO_ID_MSM8226 = 158,
boot_images\core\api\systemdrivers\DDIPlatformInfo.h
...
DALPLATFORMINFO_TYPE_CDP = 0x01, /**< Target is a MSM CDP/SURF device. */
DALPLATFORMINFO_TYPE_MTP_MSM = 0x08, /**< Target is a MSM MTP device. */
DALPLATFORMINFO_TYPE_QRD = 0x0B, /**< Target is a QRD device. */
DT Header
About dt.img format, please refer to dtbtool.txt and bootable\bootloader\lk\platform\msm_shared\smem.h
kernel\arch\arm\boot\dts\msm8226-cdp.dts
model = "Qualcomm MSM 8226 CDP";
compatible = "qcom,msm8226-cdp", "qcom,msm8226", "qcom,cdp";
qcom,msm-id = <145 1 0>;
kernel\arch\arm\boot\dts\msm8226-mtp.dts
model = "Qualcomm MSM 8226 MTP";
compatible = "qcom,msm8226-mtp", "qcom,msm8226", "qcom,mtp";
qcom,msm-id = <145 8 0>;
kernel\arch\arm\boot\dts\msm8226-qrd.dts
model = "Qualcomm MSM 8226 QRD";
compatible = "qcom,msm8226-qrd", "qcom,msm8226", "qcom,qrd";
qcom,msm-id = <145 11 0>;
kernel\arch\arm\boot\dts\msm8916-qrd-skuh.dts
model = "Qualcomm Technologies, Inc. MSM 8916 QRD SKUH";
compatible = "qcom,msm8916-qrd-skuh", "qcom,msm8916-qrd", "qcom,msm8916", "qcom,qrd";
qcom,board-id = <0x1000b 0> , <0x1000b 4>;
Notes: Here subtype = 0/4; major version= 01 minor version = 00, platform type = 0b
CDT Description XML
boot_images\core\boot\secboot3\scripts\jedec_lpddr2_single_channel.xml
<device id="cdb0">
<props name="platform_id" type="DALPROP_ATTR_TYPE_BYTE_SEQ">
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, end
</props>
</device>
Example of 8x26 device
CDP:
0x03, 0x01, 0x01, 0x00, 0x00, 0x00, end
MTP:
0x03, 0x08, 0x01, 0x00, 0x00, 0x00, end
QRD:
0x03, 0x0B, 0x01, 0x00, 0x00, 0x00, end
Example of 8916 device
QRD SKUH:
0x03, 0x0B, 0x01, 0x00, 0x04, 0x00, end
Byte 0: platform_id Version
Byte 1: platform_id type:
0x01: Target is a SURF device
0x08: Target is a MTP device
0x0B: Target is a QRD device
Byte 2: platform_id major platform version
Byte 3: platform_id minor platform version
Byte 4: platform_id subtype
What's you need do?
Generate CDT image and boot_cdt_array.c
- cd boot_images\core\boot\secboot3\scripts
- modify <jedec_lpddr2_single_channel.xml>
- python cdt_generator.py jedec_lpddr2_single_channel.xml <cdt image>.bin
Program CDT image on device
cd boot_images/core/boot/secboot3/scripts/emmc_cdt_program_scripts
python ../../../../storage/tools/ptool/ptool.py -x partition.xml -p 2
modify <jedec_lpddr2_single_channel.xml>
QRD HW V2:
0x03, 0x0B, 0x02, 0x00, 0x00, 0x00, end
python cdt_generator.py jedec_lpddr2_single_channel.xml platform_ddr.bin
cp platform_ddr.bin emmc_cdt_program_scripts
T32
run platform_ddr_emmc_cdt_program.cmm
QPST
platform_ddr_prog_cfg.xml
Change default CDT in sbl1 image
- copy boot_cdt_array.c to boot_images\core\boot\secboot3\hw\msm8x26
- modify config_data_table[] in boot_cdt_array.c
- rebuild sbl1
- program sbl1 image
Generate DT Binary
- <modify dts>
- dtc -p 1024 -O dtb -o msm8626.dtb msm8626.dts
- cat zImage msm8626.dtb > boot.img
- program boot image
Temp workaround
After previous step, if the device still stop at LK(usb port fastboot), you can try this temp workaround
bootable\bootloader\lk\platform\msm_shared\dev_tree.c
struct dt_entry * dev_tree_get_entry_ptr(struct dt_table *table)
{
<snip>
//workaround: find out the DTB entry index from boot.img(or dt.img)
// change below code, force return expected expected dt_entry_ptr,
if((dt_entry_ptr->platform_id == board_platform_id()) /* &&
(dt_entry_ptr->variant_id == 1) &&
(dt_entry_ptr->soc_rev == 0) */ )
{
return dt_entry_ptr ++;
How to debug
When mismatch issue happens, lk normally will print error log with below format:
ERROR: Unable to find suitable device tree for device ( [ chipset id ] [ soc version ] [ platform id type] [ platform subtype] )
for example as below
ERROR: Unable to find suitable device tree for device (164/0x00010001/11/0)
Match Procedure
1. SBL will get chipset id, soc version from H/W regiser
2. SBL fetch platform id type and platform subtype from CDT partitioin
3. SBL write those information into share memory
4. LK get those information and try to find suitable DTS entry.
[chipset id] and [soc version]:
For device:
read from H/W register, can not modify
For DTS:
qcom,msm-id = <chipset_id, soc version>
[Platform id type] and [platform subtype]:
For device, defined in CDT xml file with below format:
boot_images\core\boot\secboot3\scripts\jedec_lpddr2_single_channel.xml
<device id="cdb0">
<props name="platform_id" type="DALPROP_ATTR_TYPE_BYTE_SEQ">
0x03, 0x0B, 0x01, 0x00, 0x04, 0x00, end
</props>
</device>
Byte 0: platform_id Version
Byte 1: platform_id type:
0x01: Target is a SURF device
0x08: Target is a MTP device
0x0B: Target is a QRD device
Byte 2: platform_id major platform version
Byte 3: platform_id minor platform version
Byte 4: platform_id subtype
So what you need is to care about Byte 1 and Byte 4
For DTS:
qcom,board-id = <platform_id, subtype_id>
转载地址:https://loongembedded.blog.csdn.net/article/details/51015438 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
留言是一种美德,欢迎回访!
[***.207.175.100]2024年04月29日 06时18分50秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
一个牛逼的数据库操作命令行工具:mycli
2019-05-01
掌握 Python 爬虫的所有技巧,都在这里!
2019-05-01
史上最烂项目:苦撑12年,600多万行代码...
2019-05-01
关于进程与线程,史上最浅显易懂的一个简单解释
2019-05-01
别人用B站看弹幕,我用B站搞爬虫
2019-05-01
把 14 亿中国人都拉到一个微信群,在技术上能实现吗?
2019-05-01
这些代码神注释,请收下我的膝盖
2019-05-01
斯坦福后空翻机器人设计、代码全开源,成本降至3000美元,人人皆可DIY
2019-05-01
618|Python购书攻略
2019-05-01
请停止学习框架
2019-05-01
考研比惨五大专业排行榜,第一名没人不服!
2019-05-01
没钱没公司,怎么做一款付费产品
2019-05-01
Python 3.8 新特性来袭
2019-05-01
老程序员“被嫌弃”
2019-05-01
神器:公众号如何从第一篇文章开始看
2019-05-01
查询亿级数据毫秒级返回!Elasticsearch 是如何做到的?
2019-05-01
FastAPI 构建 API 服务,究竟有多快?
2019-05-01
为什么Quora选择用Python语言?
2019-05-01
一劳永逸学编程的方法
2019-05-01