图1:html
高通MSM8K平台bootloader启动流程基本相似,但具体各平台,好比MSM897四、MSM891六、MSM8994等,会有微小区别。app
从上图,能够看出高通8K平台的boot过程很是不通常啊。相比MTK平台,或者高通7K平台,复杂了很是多。 下图是高通文档对启动流程的说明,函数
已经很清楚了,我这边就直接贴出来啦。ui
图2:.net
系统上电后从RPM PBL启动到 APPS PBL 而后SBL1 ,再启动APPSBL 等等,整个过程看似很是复杂,但其实不少代码OEM厂家是看不到,也修改不了的。debug
那咱们须要咱们作什么? 能作点什么呢? 呵呵!不会没事情作的。 SBL1和appsbl高通是有开放代码。调试
本章我重点关注SBL1,且主要描述我认为重点的几方面:code
1、 CDT : Platform ID和DDR参数 orm
2、 debug log :xml
3、 download : msm8K 新平台软件download支持两种协议,sahara和firehose
4、 ramdump :死机异常信息dump
好的,下面将SBL1我比较关注的点调用流程总结成以下图,后面再针对关注点展开,逐个分析。
图3:
参考以下文档和code:
80-N3411-1_B_EEPROM_SW_CDT.pdf
boot_images/core/boot/secboot3/hw/msm8916/boot_cdt_array.c
boot_images/core/systemdrivers/platforminfo/src/PlatformInfo.c
boot_images/core/boot/secboot3/scripts/cdt_generator.py
boot_images/core/boot/secboot3/scripts/jedec_lpddr3_single_channel.xml
上图3能够看到CDB0: platform info相关的代码调用有以下二函数:
voidboot_config_data_table_init(bl_shared_data_type* bl_shared_data)
{
boot_log_message("boot_config_data_table_init, Start");
boot_log_start_timer();
/*populate configuration data table's info*/
config_data_table_info.size = config_data_table_size;
config_data_table_info.cdt_ptr = config_data_table;
//get default config_data_table array from boot_cdt_array.c
boot_update_config_data_table(&config_data_table_info);
//read the cdt from eMMC and update the default config_data_table array
/*put a pointer to the table info into sbl shared data so next sbl can access it*/
bl_shared_data->sbl_shared_data->config_data_table_info = &config_data_table_info;
boot_log_stop_timer("boot_config_data_table_init, Delta");
} //该函数获取到cdt,并存放在config_data_table_info
void sbl1_hw_platform_smem(bl_shared_data_type* bl_shared_data)
{
.......
//好了
static DALResultPlatformInfo_InitSMem
(
PlatformInfoDrvCtxt *pDrvCtxt
)
{
//申请共享内存区:SMEM_HW_SW_BUILD_ID
pSMem = (DalPlatformInfoSMemType *)
smem_alloc(SMEM_HW_SW_BUILD_ID, sizeof(DalPlatformInfoSMemType));
...............
//保存platform info到共享内存
pSMem->ePlatformType = pDrvCtxt->PlatformInfo.platform;
pSMem->nPlatformVersion = pDrvCtxt->PlatformInfo.version;
pSMem->nPlatformSubtype = pDrvCtxt->PlatformInfo.subtype;
pSMem->bFusion = pDrvCtxt->PlatformInfo.fusion;
.................
return DAL_SUCCESS;
} /* END PlatformInfo_InitSMem */
花了这么多精力谈如何存platform info,得用啊?这些platform info在lk和kernel有何用呢?
lk 根据platform id及subtype id匹配正确的dts,这样后面kernel也能够利用dts里的
platform info。
注:msm8916-mtp.dts 包含以下platform id & subtype id信息。
{
model = "Qualcomm Technologies, Inc. MSM 8916 MTP xxx";
compatible = "qcom,msm8916-mtp", "qcom,msm8916", "qcom,mtp", "qcom,xxxx";
qcom,board-id = <8 0x21>; //platform id & subtype id
};
lk请参考这些函数,后面专门研究lk,再详细描述。
platform_detect //board.c , smem.h : enum platform_subtype
board_hardware_subtype //board.c , smem.h : enum platform_subtype
board_hardware_id //board.c , smem.h : enum platform_subtype
dev_tree_get_entry_info //dev_tree.c
kernel请参考setup.c
从上面CDT格式及代码分析,能够看出,若是不一样项目cdt的nPlatform和nSubtype项配置成不一样的值, 与dts 包含的platform id & subtype id信息进行匹配。就能够用来区分不一样的项目。
即:咱们在项目开发过程当中,同一个分支代码要进行多项目开发时,
sbl、lk、kernel能够利用这些信息来区分不一样项目,实现一套代码多项目配置目标。以下图:
图6:
总结:经过修改cdt和dts,sbl、lk、kernel阶段使用以下接口,能够将同一个branch代码中多项目区分出来!
sbl_board_subtype // sbl高通没有,本身开发一个接口
board_hardware_subtype // lk接口
of_board_is_xxx // kernel 接口
cdt中还有一项重要内容是CDB1: DDR参数,下面看看如何利用这些参数进行ddr初始化的。
ddr初始化涉及以下重要三函数:
boot_procedure_func_type load_qsee_pre_procs[] =
{
.......
/* Copy the configure data table from eeprom */
boot_config_data_table_init,
.......
/* Configure ddr parameters based on eeprom CDT table data. */
sbl1_ddr_set_params, // 保存cdt ddr 参数到底层
/* Initialize DDR */
(boot_procedure_func_type)sbl1_ddr_init, //初始化ddr
.......
/* Last entry in the table. */
NULL
};
下面重点介绍这三个函数:
图7:
cdt数据 config_data_table保存到config_data_table_info.cdt_ptr
图8:
sbl1_ddr_set_params调用ddr_set_params,将ddr参数保存到ddr_device_table。
获取num_of_device保存到ddr_device_table_entry_num 。
图9:
sbl1_ddr_init 经过 HAL_SDRAM_Init调用到以下函数,
HAL_SDRAM_Ram_Rank_Detection,========》cs auto detect
HAL_SDRAM_Ram_Size_Detection, =========> ram size auto detect by :row、col、bank、width , manufacture_id
ddr_params_detection , ========》 two DDR chips auto detect
HAL_SDRAM_DPE_Update_AC_Paramenters =========> update ddr timing with new DDR timing
上图说明,经过ddr_params_detection 实现一个项目自动支持多种ddr timing的方法。
好了,ddr timing就再也不多说了,详细请阅读代码及参考文档:
80-NJ172-1_A_LPDDR2_CUSTOMIZATION_FOR_MSM8x26_DEVICES.pdf
待续:《高通 MSM8K bootloader之二: SBL1》
参考资料:
80_NA157_7_C_MSM8974_Boot_Architecture_Overview.pdf
80-NL239-1_A_MSM8916_Boot_Architecture_Overview.pdf
80-N3411-1_B_EEPROM_SW_CDT.pdf
80-NJ172-1_A_LPDDR2_CUSTOMIZATION_FOR_MSM8x26_DEVICES.pdf