做为设备设计和制造的公司,我们除了不能制造/生产PCB/PCBA/外壳,其它设备上的所有模块几乎都是自己设计的。那么,作为软件,会涉及到哪些设计内容呢?
- 选定主chipset/soc,例如qcmxxx/sdmxxx。
- 根据chipset,拉取Qualcomm 源码,并搭建local开发环境。当然,前提是和Qualcomm签订协议。
- 由于我的项目是基于服务器开发的,所以,Local 开发环境中代码部分都是在服务器上的docker中进行编辑和编译。代码有对应的gerrit服务器进行维护。
- 重点了来了,正如我前面所说,我的项目是基于同平台来设计和生产不同的产品,而且产品的形态和使用场景差别比较大,这就要求我们要单独定义产品代码。最好是能够在amss/kernel/framework/都可以进行相应定制。
- 大概的构建过程为:Qualcomm Chipset -> Qualcomm Platform Codebase & IDP identification -> Customer(ODM) product identification
- 既然要有不同的产品,那么到底该如何定义?在何处定义?
引入,Qualcomm的CDT机制:
什么是CDT(Configuration Data Table)?借用Qualcomm的原文内容:
CDT/eCDT is a data block that contains platform/device-dependent data, such as the hardware platform ID and DDR SDRAM configuration. Various software modules can use this information to reduce dependency and perform dynamic initialization.
A primary goal of the CDT and platform ID is to have one identical software build work across different hardware platforms and form factors and their different hardware revisions and variations. Additionally, abstracting the DDR type and configuration information to the external storage device enables the support of second source memory vendors easily without requiring separate software builds. CDT is programmed into storage devices such as eMMC, UFS, or EEPROM at the factory. If CDT is not present/programmed in the storage device, a default copy of CDT that is linked to the build at compile time is retrieved and used. The boot loader fetches a CDT from a storage device or retrieves a linked CDT, so the process is transparent to other modules. The CDT contains information that software must know before it can even boot successfully. It currently holds: ■ Platform ID data structure (PlatformInfoMemType) ■ DDR device type, mode (interleaved or noninterleaved), density (rank/chipselects), and JEDEC specification default timing data; this DDR configuration may exist, depending on the target A hardware platform may boot without a platform ID installed bootup, but there are risks involved. Boot loaders default the hardware platform as UNKNOWN in this case. Also, the DDR driver defaults to the built-in default device type and configuration (mode, density, timing). If drivers or services packaged within the boot loaders or later in the system/HLOS/kernel have a hard dependency on the hardware platform information, then behavior is undefined. Also, if the DDR configuration in the hardware platform is different from the built-in default, it fails to boot.On the latest QTI family platforms, the DDR parameters have been migrated to the XBL configuration binary. The customer can still find the platform ID in the boot_cdt_array.c file, but no DDR parameters are included in this file. For any DDR settings information, see the XBL Configuration Guide (80-PE663-1).
简单的讲,CDT就是给目标产品定义属性,而且这个属性是运行时生效。那就涉及到定义,和对应的解析代码的编写。一般,CDT时刷在emmc或者ufs中的一个单独分区中。开机时候,xbl可以在开机的很早阶段就进行读取,并进行设备个性化的配置。CDT为同一套软件来设配多产品提供了便捷。
这里提到,CDT中目前还保留了platform ID信息,但是从上面高通的说明中,ddr信息已经放在了 XBL configuration binary(应该是比较新的一个功能,2021年开始的吗?),这个后面可以详细的再讨论。
CDT的制作:
cdt一般以name.bin的形式存在,在notepad的hex-editor中打开,可以看到类似如下的内容:
而这些内容通常是同过的一个py脚本来生成对应的.bin文件。命令如下:
python cdt_generator.py cdt_configure.xml CDT.bin;
这样执行之后,会生成对应的CDT.bin 还有一个boot_cdt_array.c文件。这个.c文件里面其实就一个array。如果,如果启动过程中(被erase all了),emmc或者ufs中没有刷一个cdt.bin,那么这个.c文件中的配置就会被加载。后面我们最好也是同步改一下boot_cdt_array.c;
所以,要有定制的CDT.bin, 就要先配置cdt_configure.xml;那么cdt_configure.xml的内容又是什么?
CDT.bin的格式:
通常,我们比较关心的是platform ID information 这部分;
使用实例:(这里的6个byte,注意其后面的定义)
CDB0-> Platform ID, CDB1-> DDR Parameters ....
有关代码: