Boot 启动

高通芯片平台种类众多涵盖低端到高端的各种档次种类繁多:低端有诸如8909,中端有8916、8929、8937等,高端的有8953、8953、8953pro、8993,8996、8996pro。从存储介质上讲,从早期emmc慢慢发展到emcp最终由向ufs转化的趋势,运行位数更是从早期的32位全体过渡到64位地址总线。科技发展日新月异成果遍地!

也正是由于技术和平台的差异较大,很难通过一篇文章来穷尽所有高通平台的流程。好在所有的chip在boot时有很大的通性,便于举一反三,故本文将以2017年正在使用的Qcom平台为例,带领大家从宏观上把握开机流程的核心。

子系统模块架构

要了解高通的平台,必须先了解下芯片中集成了那些子系统(SubSystem)。与Intel的做法不同,高通芯片中所包含的子系统数量多,集成度高,这些子系统都有各自独立的cpu,只要在开机过程中通过主cpu子系统(APPS)引导/烧录进对应的firmware,就可以地独立运行起来。
在较新的高通芯片中较常见到的子系统(SubSystem)有下面这些:


Boot流程

既然芯片中集成了这么多颗cpu,讲解开机流程的核心就演变为讲解主cpu是如何逐步引导子cpu完整boot的流程了。



总结

上面的流程是基于中高端高通平台的通用流程,有些细节在不同平台上有细小的区别故没有特意展开。在8996平台上,高通引入了xbl这样的新机制替代了sbl1,但他们功能类似,行为相仿。

每个子系统由于都是独立的cpu,可能有些读者会产生这样的疑惑:万一某个子系统运行不正常,那Kernel如何才能对他们进行有效监控和管理呢?高通引入了QMI(Qcom Message Interface)的接口,让各个子系统可以通过其进行较为高效的数据交换,当然这些数据是可以包含系统日志(log)的,这样我们就可以对其进行一定程度上的管理和监控了。当然,我们还有一系列的driver节点,可以通过其对子系统进行reset和clock的管理。最最重要的是,每个子系统都提供了一个sub-system restart的监控节点,这样只要某个子系统异常宕机(例如modem偶尔重启,用户可能看到短暂的无服务),我们可以通过modem的引导程序,将modem子系统的整个运行内存状态完整的dump出来,这样就可以分析crash前的所有变量和堆栈状态了。

了解高通平台的boot流程,对做bsp的同仁来说是十分有必要的,我们bring up某个新平台的EVB主板时,有了基础知识才能很找到不开机时的问题点,才能尽快进行针对性的debug。

顺便分享点经验:电池电量,电池id电阻,DDR是否有部分虚焊点是常常导致无法开机的元凶。这些问题可以通过log或在edl mode下烧入不同的firehouse来快速验证。

log


Format: Log Type - Time(microsec) - Message - Optional Info
Log Type: B - Since Boot(Power On Reset),  D - Delta,  S - Statistic
S - QC_IMAGE_VERSION_STRING=BOOT.XF.2.0-00377-SDM845LZB-1
S - IMAGE_VARIANT_STRING=SDM845LA
S - OEM_IMAGE_VERSION_STRING=nreal-PowerEdge-R730
S - Boot Interface: UFS
S - Secure Boot: Off
S - Boot Config @ 0x00786070 = 0x000000c1
S - JTAG ID @ 0x00786130 = 0x2008e0e1
S - OEM ID @ 0x00786138 = 0x00000000
S - Serial Number @ 0x00784138 = 0xaffc4293
S - OEM Config Row 0 @ 0x00784188 = 0x0000000400000000
S - OEM Config Row 1 @ 0x00784190 = 0x0000000000000000
S - Feature Config Row 0 @ 0x007841a0 = 0x0050200080000400
S - Feature Config Row 1 @ 0x007841a8 = 0xe000ffff00007fff
S - Core 0 Frequency, 1516 MHz
S - PBL Patch Ver: 1
S - PBL freq: 600 MHZ
B -        94 - PBL, Start
B -      5277 - bootable_media_detect_entry
B -     45768 - bootable_media_detect_success
B -     46144 - elf_loader_entry
B -     46754 - auth_hash_seg_entry
B -     46957 - auth_hash_seg_exit
B -     52866 - elf_segs_hash_verify_entry
B -     59608 - elf_segs_hash_verify_exit
B -     60237 - auth_xbl_sec_hash_seg_entry
B -     67616 - auth_xbl_sec_hash_seg_exit
B -     67618 - xbl_sec_segs_hash_verify_entry
B -     68375 - xbl_sec_segs_hash_verify_exit
B -     68399 - PBL, End
B -     83661 - SBL1, Start
B -    206729 - boot_flash_init, Start
D -        30 - boot_flash_init, Delta
B -    210694 - xblconfig_init, Start
D -       519 - Auth Metadata
D -     89029 - xblconfig_init, Delta
B -    304756 - sbl1_ddr_set_default_params, Start
D -      1525 - sbl1_ddr_set_default_params, Delta
B -    312716 - boot_config_data_table_init, Start
B -    317352 - CDT not programmed, using default
D -      4544 - boot_config_data_table_init, Delta - (54 Bytes)
B -    331901 - CDT Version:3,Platform ID:8,Major ID:1,Minor ID:0,Subtype:0
B -    337604 - pm_device_init, Start
B -    342820 - PM: 0: PON=0x1:HARD_RESET: ON=0x80:PON_SEQ: POFF=0x2:PS_HOLD: OFF=0x80:POFF_SEQ
B -    348462 - PM: 1: PON=0x20:PON1: ON=0x80:PON_SEQ: POFF=0x8:GP1: OFF=0x80:POFF_SEQ
B -    356972 - PM: 2: PON=0x20:PON1: ON=0x80:PON_SEQ: POFF=0x8:GP1: OFF=0x80:POFF_SEQ
B -    418704 - PM: SET_VAL:Skip
D -     80672 - pm_device_init, Delta
B -    421723 - pm_driver_init, Start
D -      5337 - pm_driver_init, Delta
B -    430599 - PM: Trigger FG IMA Reset
B -    434137 - PM: Trigger FG IMA Reset.Completed
B -    442951 - PM: EntryVbatt: 4194
B -    443348 - PM: EntryVbat: 4194; EntrySOC: -1
B -    446306 - PM: ADSP result: 8
B -    450759 - PM: APSD in progress
B -    453992 - PM: BATT TEMP: 35 DegC
B -    457439 - PM: PMIC Total Heap MEM Size: 2790
B -    460763 - vsense_init, Start
D -         0 - vsense_init, Delta
B -    499651 - sbl1_ddr_set_params, Start
B -    501511 - Pre_DDR_clock_init, Start
D -        61 - Pre_DDR_clock_init, Delta
D -      7655 - sbl1_ddr_set_params, Delta
B -    511058 - sbl1_ddr_init, Start
D -     16195 - sbl1_ddr_init, Delta
B -    531127 - DSF version = 253.10, DSF SHRM version = 173.3
B -    534451 - Manufacturer ID = 1, Device Type = 7
B -    540063 - Rank 0 size = 3072 MB, Rank 1 size = 3072 MB
B -    545096 - do_ddr_training, Start
B -    551958 - Frequency = 1355 MHz
D -      3568 - do_ddr_training, Delta
B -    560346 - pImem Init Start
D -      9729 - pImem Init End, Delta
B -    571936 - clock_init, Start
D -       213 - clock_init, Delta
B -    576968 - Image Load, Start
D -      2898 - APDP Image Loaded, Delta - (0 Bytes)
B -    583068 - usb: UFS Serial - bb7c6fb2
B -    587674 - usb: fedl, vbus_low
B -    592066 - PM: 0: PON=0x1:HARD_RESET: ON=0x80:PON_SEQ: POFF=0x2:PS_HOLD: OFF=0x80:POFF_SEQ
B -    600423 - PM: 1: PON=0x20:PON1: ON=0x80:PON_SEQ: POFF=0x8:GP1: OFF=0x80:POFF_SEQ
B -    608932 - PM: 2: PON=0x20:PON1: ON=0x80:PON_SEQ: POFF=0x8:GP1: OFF=0x80:POFF_SEQ
B -    616588 - PM: SMEM Chgr Info Write Success
B -    623755 - Image Load, Start
D -       397 - Auth Metadata
D -     10218 - Segments hash check
D -     19886 - AOP Image Loaded, Delta - (178996 Bytes)
B -    646874 - Image Load, Start
D -       366 - Auth Metadata
D -       396 - Segments hash check
D -     10889 - QSEE Dev Config Image Loaded, Delta - (34340 Bytes)
B -    666577 - Image Load, Start
D -      3813 - Auth Metadata
D -     10736 - Segments hash check
D -     33977 - QSEE Image Loaded, Delta - (2038392 Bytes)
B -    703787 - Image Load, Start
D -       152 - SEC Image Loaded, Delta - (4096 Bytes)
B -    712205 - Image Load, Start
D -       397 - Auth Metadata
D -      2409 - Segments hash check
D -     17355 - QHEE Image Loaded, Delta - (384704 Bytes)
B -    732915 - Image Load, Start
D -      5063 - STI Image Loaded, Delta - (0 Bytes)
B -    741363 - Image Load, Start
D -       366 - Auth Metadata
D -       671 - Segments hash check
D -     10096 - ABL Image Loaded, Delta - (125520 Bytes)
B -    754844 - Image Load, Start
D -       458 - Auth Metadata
D -      9120 - Segments hash check
D -     29890 - APPSBL Image Loaded, Delta - (2097152 Bytes)
B -    825238 - SBL1, End
D -    741608 - SBL1, Delta
S - Flash Throughput, 132000 KB/s  (4935654 Bytes,  37262 us)
S - DDR Frequency, 1353 MHz


UEFI Start     [ 1174] SEC
ASLR        : On
DEP         : On
Timer Delta : +0 mS
RAM Entry 0 : Base 0x0000000080000000  Size 0x00000000C0000000
RAM Entry 1 : Base 0x0000000140000000  Size 0x00000000BD3A0000
UEFI Ver    : 5.0.210205.BOOT.XF.2.0-00377-SDM845LZB-1
Build Info  : 64b Feb  5 2021 11:57:18
Boot Device : UFS
PROD Mode   : TRUE
Retail      : TRUE
PM0: 20, PM1: 21, PM2: 24, 
PmicDxe: read aw9109 chipid ok: 0xB223
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ChargerLib:: ChargerLib_GetBatteryID BATT_ID_2 = 100521 
1, PmicDxe:: PmicSchgSetChargerDefaultSetting Setting ICL = 500 mA 
1, PmicDxe:: PmicSchgInitialChargerCheckup APSD done status: 0, Port Type = 8 
1, 1, 1, 1, QcomChargerDxe:: ChargerPlatform_Init Enabled WDOG.
DisplayDxe: LAB/IBB GetStatus(LabVregOk) failed after 25ms
DisplayDxe: Resolution 1440x2560 (1 intf)
Render Splash  [ 1927]
-----------------------------
Platform Init  [ 2002] BDS
Platform   : MTP
Chip Name  : SDA845
Chip Ver   : 2.1
Core 0 Freq: 1612 MHz
-----------------------------
2, ChargerLib:: ChargerLib_GetBatteryID BATT_ID_2 = 100521 
ChargerLib::ChargerLib_GetErrors ERROR Charging source not detected 
ChargerLib:: ChargerLib_GetErrors pChargingError = 11 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, PmicDxe:: PmicFgSram_ReadBattID: BATT_ID_2 = 100521 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ChargerLib:: ChargerLib_GetBatteryID BATT_ID_2 = 100521 
ChargerLib::ChargerLib_GetErrors ERROR Charging source not detected 
ChargerLib:: ChargerLib_GetErrors pChargingError = 11 
2, 2, 2, 2, 2, PmicDxe:: PmicSchgSetChargerDefaultSetting Setting ICL = 500 mA 
2, UEFI Total : 845 ms
POST Time      [ 2019] OS Loader
Loader Build Info: Feb  5 2021 11:52:49
VB: RWDeviceState: Succeed using devinfo!
Booting from slot (_a)
avb_slot_verify.c:339: DEBUG: Loading vbmeta struct from partition 'vbmeta_a'.
avb_slot_verify.c:186: DEBUG: boot_a: Loading entire partition.
avb_slot_verify.c:186: DEBUG: dtbo_a: Loading entire partition.
State: Unlocked, AvbSlotVerify returned OK, continue boot
LoadSecureApps: Load app from partition(keymaster): Status = 0x0, AppId = 1
VB2: Authenticate complete! boot state is: orange
VB2: boot state: orange(1)
Exit key detection timer
No Ffbm cookie found, ignore: Not Found
Memory Base Address: 0x80000000
Decompressing kernel image start: 12379 ms
Decompressing kernel image done: 12698 ms
12, Cmdline: console=ttyMSM0,115200n8 earlycon=msm_geni_serial,0xA84000 androidboot.hardware=qcom androidboot.console=ttyMSM0 video=vfb:640x400,bpp=32,memsize=3072000 msm_rtb.filter=0x237 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 service_locator.enable=1 sw
Memory Base Address: 0x80000000
RAM Partitions
Add Base: 0x0000000080000000 Available Length: 0x00000000C0000000 
Add Base: 0x0000000140000000 Available Length: 0x00000000BD3A0000 
ERROR: Could not get splash memory region node
kaslr-Seed is added to chosen node

Shutting Down UEFI Boot Services: 13071 ms
BDS: LogFs sync skipped, Unsupported
App Log Flush : 0 ms
Exit BS        [13093] UEFI End
[    0.000000] Booting Linux on physical CPU 0x0  ---->启动kernel 

遇到问题

拔插type-C 系统重启
硬件测试波形:

MSM_RESIN_N (RESIN_N)
MSM_RESOUT_N (RESOUT_N)
MSM_PS_HOLD (PS_HOLD) 

sbl:
0x8c0~0x8ca
打印register 参考:/boot_images/QcomPkg/Library/PmicLib/app/pon/src/pm_app_pon_log.c

#define PM_SBL_PON_STATUS_MSG_LEN 128
char pon_status_message[PM_SBL_PON_STATUS_MSG_LEN];
void print_pm_register(uint32 slave_id, uint16 addr)
{
    pm_register_data_type data;
    pm_err_flag_type err_flag = PM_ERR_FLAG__SUCCESS;
    err_flag = pm_comm_read_byte(slave_id, addr, &data, 0);
    snprintf(pon_status_message, PM_SBL_PON_STATUS_MSG_LEN, "my:0x%01X0%03x = 0x%02x ", slave_id, addr, data);
    pm_log_message(pon_status_message);
}

pm_err_flag_type dump_pm_register(void)
    {
    pm_err_flag_type err_flag = PM_ERR_FLAG__SUCCESS;
    //pm_register_data_type data;
    pm_register_data_type count;
    
    for (count = 0 ; count < 0xF ; count++)
    {
        print_pm_register(0x0, 0x840+count);
    }

    for (count = 0 ; count < 0xF ; count++)
    {
        print_pm_register(0x2, 0x840+count);
    
    }
    
    for (count = 0 ; count < 0xC ; count++)
    {
        print_pm_register(0x0, 0x8C0+count);
    }

    for (count = 0 ; count < 0xC ; count++)
    {
        print_pm_register(0x2, 0x8C0+count);
    }

    print_pm_register(0x0, 0x810);
    print_pm_register(0x2, 0x810);
    return err_flag;
}

REF:
https://blog.csdn.net/a4262562/article/details/76779236

你可能感兴趣的:(Boot 启动)