浅谈高通平台NON-HLOS.bin文件生成和镜像加载过程

      声明:本文只用于个人学习交流,若不慎造成侵权,请及时联系我,立即予以改正

       NON-HLOS.bin文件是BP侧的一个镜像,最终被烧写到modem分区,但最近研究发现,其不仅仅包含modem镜像,它还包含ADSP镜像、Wcnss镜像、Venus镜像、Widevine镜像,还有一些安全相关的镜像。AP侧Init进程解析init.rc时,会通过kernel PIL驱动程序加载这些镜像,最终将相应的modem、ADSP等boot起来。

 一、NON-HLOS.bin文件生成过程

编译文件:common/build/build.py,这个文件虽然有将近900行,但是最关键只有下面几行:

for step_elem in workflow_elem:

    。。。。

    step_dict = ml.XmlToDict(step_elem)

    step_func = run_step[step_elem.attrib['type']]

    step_func(step_dict)

其中step相关配置文件:contents.xml,其大概格式如下:

<workflow>

     <step type="exec">

         <params>。。。。。</params>

         <tool_name>。。。。</tool_name>

         <src_file_vars>。。。。。</src_file_vars>

         <destn_dir>。。。。。。。</destn_dir>

     </step>

</ workflow>

其中run_step定义如下:

run_step = {
   'copy'  : workflow_copy,
   'exec'  : workflow_exec,
   'delete': workflow_delete,
   'setenv': workflow_setenv
}

workflow_copy,workflow_exec,workflow_delete三个接口,恰好对应build.py脚本定义的三个函数,本文以workflow_exec为例简要说明其编译过程:

1、解析xml文件,获取setp配置内容,并放置在step_dict

2、根据xml文件type值选取合适的接口,如果step配置内容中type=exec,则相应接口为workflow_exec函数

3、调用workflow_exec函数,并将step_dict作为参数传递进去

(1) 首先调用preprocess_step函数,从参数step_dict获取step中各项配置

(2)params = ml.evaluate_params(step_dict_flavor)获取params属性中各个变量的值

(3)lg.log_exec(params),执行params属性中的命令

根据contents.xml文件中的配置,总结编译common过程如下:

1、使用pil-splitter.py工具,将相应image中属性含有pil_split进行分解

2、如果common/build/bin/asic目录下已存在non-hlos.bin文件,则删除non-hlos.bin文件

3、使用fat_creation.py工具重新生成non-hlos.bin文件

4、使用fatadd.py工具向non-hlos.bin文件添加Ver_Info.txt中内容

5、使用ptool.py工具生成相应的分区文件

6、使用checksparse.py工具分解AP的system.img,userdata.img等镜像

二、NON-HLOS.bin文件中各个子系统镜像加载过程

1、dts配置:

    pil_mss: qcom,mss@4080000 {

        compatible = "qcom,pil-q6v55-mss";

        。。。。。。

        qcom,firmware-name = "modem";

         。。。。。。

    };

    qcom,lpass@c200000 {

        compatible = "qcom,pil-tz-generic";

        。。。。。。

        qcom,firmware-name = "adsp";

         。。。。。

    };

 

    qcom,pronto@a21b000 {

        compatible = "qcom,pil-tz-generic";

        。。。。。

        qcom,firmware-name = "wcnss";

         。。。。。

    };

 

    qcom,venus@1de0000 {

        compatible = "qcom,pil-tz-generic";

        。。。。。。

        qcom,firmware-name = "venus";

        。。。。。。

    };

相应的驱动文件如下:

kernel/drivers/soc/qcom/peripheral-loader.c

kernel/drivers/soc/qcom/subsys-pil-tz.c

kernel/drivers/soc/qcom/pil-q6v5-mss.c

还需要rc文件帮忙哦,呵呵

device/qcom/common/rootdir/etc/init.qcom.rc

on early-boot

    。。。。。

    write /sys/kernel/boot_adsp/boot 1

    write /sys/kernel/boot_cdsp/boot 1

    write /sys/kernel/boot_slpi/boot 1

      从上面可知,当手机启动到kernel阶段,PIL驱动只是注册了相关设备节点,并没有发生image加载过程,直至init进程解析init.rc文件,触发了early-boot,会向对应设备节点写1,从而触发各个image加载。具体信息请参考下面log部分。

对应加载镜像log如下:

[32m[   22.662154] [33mueventd[0m: firmware: loading 'adsp.mdt' for '/devices/soc/c200000.qcom,lpass/firmware/adsp.mdt'
[32m[   22.673573] [33mueventd[0m: loading /devices/soc/c200000.qcom,lpass/firmware/adsp.mdt took 11ms
[32m[   22.697783] [33mueventd[0m: firmware: loading 'adsp.b02' for '/devices/soc/c200000.qcom,lpass/firmware/adsp.b02'
[32m[   22.708059] [33mueventd[0m: loading /devices/soc/c200000.qcom,lpass/firmware/adsp.b02 took 10ms
[32m[   22.709360] [33mueventd[0m: firmware: loading 'adsp.b03' for '/devices/soc/c200000.qcom,lpass/firmware/adsp.b03'
[32m[   22.722718] [33mueventd[0m: loading /devices/soc/c200000.qcom,lpass/firmware/adsp.b03 took 13ms
[32m[   22.724127] [33mueventd[0m: firmware: loading 'adsp.b04' for '/devices/soc/c200000.qcom,lpass/firmware/adsp.b04'
[32m[   22.815294] [33mueventd[0m: loading /devices/soc/c200000.qcom,lpass/firmware/adsp.b04 took 91ms
[32m[   22.819632] [33mueventd[0m: firmware: loading 'adsp.b05' for '/devices/soc/c200000.qcom,lpass/firmware/adsp.b05'
[32m[   22.833835] [33mueventd[0m: loading /devices/soc/c200000.qcom,lpass/firmware/adsp.b05 took 14ms
[32m[   22.846304] [33mueventd[0m: firmware: loading 'adsp.b06' for '/devices/soc/c200000.qcom,lpass/firmware/adsp.b06'
[32m[   22.856574] [33mueventd[0m: loading /devices/soc/c200000.qcom,lpass/firmware/adsp.b06 took 10ms
[32m[   22.864284] [33mueventd[0m: firmware: loading 'adsp.b07' for '/devices/soc/c200000.qcom,lpass/firmware/adsp.b07'
[32m[   22.878686] [33mueventd[0m: loading /devices/soc/c200000.qcom,lpass/firmware/adsp.b07 took 14ms
[32m[   22.880281] [33mueventd[0m: firmware: loading 'adsp.b08' for '/devices/soc/c200000.qcom,lpass/firmware/adsp.b08'
[32m[   22.887248] [33mueventd[0m: loading /devices/soc/c200000.qcom,lpass/firmware/adsp.b08 took 7ms
[32m[   22.888683] [33mueventd[0m: firmware: loading 'adsp.b09' for '/devices/soc/c200000.qcom,lpass/firmware/adsp.b09'
[32m[   22.890738] [33mueventd[0m: loading /devices/soc/c200000.qcom,lpass/firmware/adsp.b09 took 2ms
[32m[   22.891924] [33mueventd[0m: firmware: loading 'adsp.b10' for '/devices/soc/c200000.qcom,lpass/firmware/adsp.b10'
[32m[   22.903149] [33mueventd[0m: loading /devices/soc/c200000.qcom,lpass/firmware/adsp.b10 took 11ms
[32m[   22.904425] [33mueventd[0m: firmware: loading 'adsp.b11' for '/devices/soc/c200000.qcom,lpass/firmware/adsp.b11'
[32m[   22.906310] [33mueventd[0m: loading /devices/soc/c200000.qcom,lpass/firmware/adsp.b11 took 2ms
[32m[   22.908389] [33mueventd[0m: firmware: loading 'adsp.b12' for '/devices/soc/c200000.qcom,lpass/firmware/adsp.b12'
[32m[   22.910388] [33mueventd[0m: loading /devices/soc/c200000.qcom,lpass/firmware/adsp.b12 took 2ms
[32m[   22.911522] [33mueventd[0m: firmware: loading 'adsp.b13' for '/devices/soc/c200000.qcom,lpass/firmware/adsp.b13'
[32m[   22.913799] [33mueventd[0m: loading /devices/soc/c200000.qcom,lpass/firmware/adsp.b13 took 2ms
[32m[   22.914907] [33mueventd[0m: firmware: loading 'adsp.b14' for '/devices/soc/c200000.qcom,lpass/firmware/adsp.b14'
[32m[   22.917846] [33mueventd[0m: loading /devices/soc/c200000.qcom,lpass/firmware/adsp.b14 took 3ms
[32m[   22.918879] [33mueventd (499) used greatest stack depth[0m: 11184 bytes left
[32m[   24.449519] [33mueventd[0m: firmware: loading 'modem.mdt' for '/devices/soc/4080000.qcom,mss/firmware/modem.mdt'
[32m[   24.451413] [33mueventd[0m: loading /devices/soc/4080000.qcom,mss/firmware/modem.mdt took 2ms
[32m[   24.459602] [33mueventd[0m: firmware: loading 'mba.mbn' for '/devices/soc/4080000.qcom,mss/firmware/mba.mbn'
[32m[   24.470243] [33mueventd[0m: loading /devices/soc/4080000.qcom,mss/firmware/mba.mbn took 10ms
[32m[   24.474895] [33mueventd[0m: firmware: loading 'msadp' for '/devices/soc/4080000.qcom,mss/firmware/msadp'
[32m[   24.478516] [33mueventd[31m: firmware: could not find firmware for msadp
[32m[   24.486109] [33mueventd[0m: loading /devices/soc/4080000.qcom,mss/firmware/msadp took 11ms
[32m[   24.570507] [33mueventd[0m: firmware: loading 'a530_pm4.fw' for '/devices/soc/1c00000.qcom,kgsl-3d0/kgsl/kgsl-3d0/a530_pm4.fw'
[32m[   24.572554] [33mueventd[0m: loading /devices/soc/1c00000.qcom,kgsl-3d0/kgsl/kgsl-3d0/a530_pm4.fw took 2ms
[32m[   24.603141] [33mueventd[0m: firmware: loading 'a530_pfp.fw' for '/devices/soc/1c00000.qcom,kgsl-3d0/kgsl/kgsl-3d0/a530_pfp.fw'
[32m[   24.606785] [33mueventd[0m: loading /devices/soc/1c00000.qcom,kgsl-3d0/kgsl/kgsl-3d0/a530_pfp.fw took 4ms
[32m[   24.636679] [33mueventd[31m: selinux_android_restorecon(/sys/devices/soc/1c00000.qcom,kgsl-3d0/kgsl/kgsl-3d0/a530_pfp.fw) failed: Success
[32m[   24.649677] [33mueventd[0m: firmware: loading 'modem.b02' for '/devices/soc/4080000.qcom,mss/firmware/modem.b02'
[32m[   24.661766] [33mueventd[0m: loading /devices/soc/4080000.qcom,mss/firmware/modem.b02 took 12ms
[32m[   24.665311] [33mueventd[0m: firmware: loading 'modem.b04' for '/devices/soc/4080000.qcom,mss/firmware/modem.b04'
[32m[   24.673339] [33mueventd[0m: loading /devices/soc/4080000.qcom,mss/firmware/modem.b04 took 9ms
[32m[   24.682134] [33mueventd[0m: firmware: loading 'modem.b05' for '/devices/soc/4080000.qcom,mss/firmware/modem.b05'
[32m[   24.685698] [33mueventd[0m: loading /devices/soc/4080000.qcom,mss/firmware/modem.b05 took 3ms
[32m[   24.690788] [33mueventd[0m: firmware: loading 'modem.b06' for '/devices/soc/4080000.qcom,mss/firmware/modem.b06'
[32m[   24.701809] [33mueventd[0m: loading /devices/soc/4080000.qcom,mss/firmware/modem.b06 took 11ms
[32m[   24.706323] [33mueventd[0m: firmware: loading 'modem.b07' for '/devices/soc/4080000.qcom,mss/firmware/modem.b07'
[32m[   24.715939] [33mueventd[0m: loading /devices/soc/4080000.qcom,mss/firmware/modem.b07 took 9ms
[32m[   24.717611] [33mueventd[0m: firmware: loading 'modem.b08' for '/devices/soc/4080000.qcom,mss/firmware/modem.b08'
[32m[   24.733548] [33mueventd[0m: loading /devices/soc/4080000.qcom,mss/firmware/modem.b08 took 16ms
[32m[   24.735186] [33mueventd[0m: firmware: loading 'modem.b09' for '/devices/soc/4080000.qcom,mss/firmware/modem.b09'
[32m[   24.756318] [33mueventd[0m: loading /devices/soc/4080000.qcom,mss/firmware/modem.b09 took 21ms
[32m[   24.761443] [33mueventd[0m: firmware: loading 'modem.b10' for '/devices/soc/4080000.qcom,mss/firmware/modem.b10'
[32m[   24.940472] [33mueventd[0m: loading /devices/soc/4080000.qcom,mss/firmware/modem.b10 took 179ms
[32m[   24.942092] [33mueventd[0m: firmware: loading 'modem.b11' for '/devices/soc/4080000.qcom,mss/firmware/modem.b11'
[32m[   24.951367] [33mueventd[0m: loading /devices/soc/4080000.qcom,mss/firmware/modem.b11 took 9ms
[32m[   24.953021] [33mueventd[0m: firmware: loading 'modem.b12' for '/devices/soc/4080000.qcom,mss/firmware/modem.b12'
[32m[   25.014103] [33mueventd[0m: loading /devices/soc/4080000.qcom,mss/firmware/modem.b12 took 61ms
[32m[   25.027603] [33mueventd[0m: firmware: loading 'modem.b13' for '/devices/soc/4080000.qcom,mss/firmware/modem.b13'
[32m[   25.050447] [33mueventd[0m: loading /devices/soc/4080000.qcom,mss/firmware/modem.b13 took 23ms
[32m[   25.141670] [33mueventd[0m: firmware: loading 'modem.b16' for '/devices/soc/4080000.qcom,mss/firmware/modem.b16'
[32m[   25.153330] [33mueventd[0m: loading /devices/soc/4080000.qcom,mss/firmware/modem.b16 took 12ms
[32m[   25.170805] [33mueventd[0m: firmware: loading 'modem.b17' for '/devices/soc/4080000.qcom,mss/firmware/modem.b17'
[32m[   25.187436] [33mueventd[0m: loading /devices/soc/4080000.qcom,mss/firmware/modem.b17 took 17ms
[32m[   25.189230] [33mueventd[0m: firmware: loading 'modem.b18' for '/devices/soc/4080000.qcom,mss/firmware/modem.b18'
[32m[   25.292187] [33mueventd[0m: loading /devices/soc/4080000.qcom,mss/firmware/modem.b18 took 103ms
[32m[   25.293819] [33mueventd[0m: firmware: loading 'modem.b19' for '/devices/soc/4080000.qcom,mss/firmware/modem.b19'
[32m[   25.296124] [33mueventd[0m: loading /devices/soc/4080000.qcom,mss/firmware/modem.b19 took 2ms
[32m[   25.297689] [33mueventd[0m: firmware: loading 'modem.b20' for '/devices/soc/4080000.qcom,mss/firmware/modem.b20'
[32m[   25.308058] [33mueventd[0m: loading /devices/soc/4080000.qcom,mss/firmware/modem.b20 took 10ms
[32m[   45.810862] [33mueventd[0m: firmware: loading 'wcnss.mdt' for '/devices/soc/a21b000.qcom,pronto/firmware/wcnss.mdt'
[32m[   45.815055] [33mueventd[0m: loading /devices/soc/a21b000.qcom,pronto/firmware/wcnss.mdt took 4ms
[32m[   45.894831] [33mueventd[0m: firmware: loading 'wcnss.b02' for '/devices/soc/a21b000.qcom,pronto/firmware/wcnss.b02'
[32m[   45.904917] [33mueventd[0m: loading /devices/soc/a21b000.qcom,pronto/firmware/wcnss.b02 took 10ms
[32m[   45.935031] [33mueventd[0m: firmware: loading 'wcnss.b04' for '/devices/soc/a21b000.qcom,pronto/firmware/wcnss.b04'
[32m[   45.948467] [33mueventd[0m: loading /devices/soc/a21b000.qcom,pronto/firmware/wcnss.b04 took 13ms
[32m[   45.958084] [33mueventd[0m: firmware: loading 'wcnss.b06' for '/devices/soc/a21b000.qcom,pronto/firmware/wcnss.b06'
[32m[   46.062139] [33mueventd[0m: loading /devices/soc/a21b000.qcom,pronto/firmware/wcnss.b06 took 104ms
[32m[   46.067050] [33mueventd[0m: firmware: loading 'wcnss.b09' for '/devices/soc/a21b000.qcom,pronto/firmware/wcnss.b09'
[32m[   46.075972] [33mueventd[0m: loading /devices/soc/a21b000.qcom,pronto/firmware/wcnss.b09 took 9ms
[32m[   46.077078] [33mueventd[0m: firmware: loading 'wcnss.b10' for '/devices/soc/a21b000.qcom,pronto/firmware/wcnss.b10'
[32m[   46.083643] [33mueventd[0m: loading /devices/soc/a21b000.qcom,pronto/firmware/wcnss.b10 took 6ms
[32m[   46.087139] [33mueventd[0m: firmware: loading 'wcnss.b11' for '/devices/soc/a21b000.qcom,pronto/firmware/wcnss.b11'
[32m[   46.103695] [33mueventd[0m: loading /devices/soc/a21b000.qcom,pronto/firmware/wcnss.b11 took 17ms
[32m[   46.105562] [33mueventd[0m: firmware: loading 'wcnss.b12' for '/devices/soc/a21b000.qcom,pronto/firmware/wcnss.b12'
[32m[   46.110580] [33mueventd[0m: loading /devices/soc/a21b000.qcom,pronto/firmware/wcnss.b12 took 5ms
[32m[   49.471679] [33mueventd[0m: firmware: loading 'wlan/prima/WCNSS_qcom_wlan_nv.bin' for '/devices/soc/a000000.qcom,wcnss-wlan/firmware/wlan!prima!WCNSS_qcom_wlan_nv.bin'
[32m[   49.481196] [33mueventd[0m: loading /devices/soc/a000000.qcom,wcnss-wlan/firmware/wlan!prima!WCNSS_qcom_wlan_nv.bin took 9ms
[32m[   50.569611] [33mueventd[0m: firmware: loading 'cpp_firmware_v1_5_0.fw' for '/devices/soc/1b04000.qcom,cpp/firmware/cpp_firmware_v1_5_0.fw'
[32m[   50.571325] [33mueventd[0m: loading /devices/soc/1b04000.qcom,cpp/firmware/cpp_firmware_v1_5_0.fw took 2ms
[32m[   54.060534] [33mueventd[0m: firmware: loading 'venus.mdt' for '/devices/soc/1de0000.qcom,venus/firmware/venus.mdt'
[32m[   54.062479] [33mueventd[0m: loading /devices/soc/1de0000.qcom,venus/firmware/venus.mdt took 2ms
[32m[   54.087649] [33mueventd[0m: firmware: loading 'venus.b02' for '/devices/soc/1de0000.qcom,venus/firmware/venus.b02'
[32m[   54.097163] [33mueventd[0m: loading /devices/soc/1de0000.qcom,venus/firmware/venus.b02 took 9ms
[32m[   54.102347] [33mueventd[0m: firmware: loading 'venus.b03' for '/devices/soc/1de0000.qcom,venus/firmware/venus.b03'
[32m[   54.107897] [33mueventd[0m: loading /devices/soc/1de0000.qcom,venus/firmware/venus.b03 took 9ms
[32m[   54.108590] [33mueventd[0m: firmware: loading 'venus.b04' for '/devices/soc/1de0000.qcom,venus/firmware/venus.b04'
[32m[   54.111195] [33mueventd[0m: loading /devices/soc/1de0000.qcom,venus/firmware/venus.b04 took 2ms

如果你觉得本文有用,请不要忘记点赞或者评论哦,你们任何一个小举动,对我来说都是极大的鼓舞,感谢!

评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值