基于Dragonboard 410c的启动分析

     我们都知道在启动的时候会先跑lk(little kernel),然后才会跑kernel,在某些场景下我们需要修改lk里面的东西。所以就去简单的看了一下,在启动的时候lk做什么事了。

     代码路径:

    bootable/bootloader/lk/app/aboot/aboot.c

   进入后从aboot_init()开始:

   1.target_display_init(device.display_panel);

    这是在lk中对显示相关的初始化等,这部分没问题的话,开机时就可以看到开机log。

   2.正常启动

 if (is_user_force_reset())

     goto normal_boot;


normal_boot:
         if (!boot_into_fastboot)
         {
             if (target_is_emmc_boot())
             {
                 if(emmc_recovery_init())
                     dprintf(ALWAYS,"error in emmc_recovery_init\n");
                 if(target_use_signed_kernel())
                 {
                     if((device.is_unlocked) || (device.is_tampered))
                     {
                     #ifdef TZ_TAMPER_FUSE
                         set_tamper_fuse_cmd();
                     #endif
                     #if USE_PCOM_SECBOOT
                         set_tamper_flag(device.is_tampered);
                     #endif
                     }
                 }
                 boot_linux_from_mmc();
             }
             else
             {
                 recovery_init();
         #if USE_PCOM_SECBOOT
             if((device.is_unlocked) || (device.is_tampered))
                 set_tamper_flag(device.is_tampered);
         #endif
                 boot_linux_from_flash();
             }
             dprintf(CRITICAL, "ERROR: Could not do normal boot. Reverting "
                 "to fastboot mode.\n");
         }

可以看到,当boot_into_fastboot = false时,系统还不会正常启动,这里会判断是否进入升级模式或者外部。

    如果target_is_emmc_boot()返回1,就可以从emmc正常启动了。

    boot_linux_from_mmc();

    如果target_is_emmc_boot()返回0,就会进入升级模式了。

     recovery_init();

    boot_linux_from_flash();


    3.组合键的作用:

    (1)音量减键和音量加键同时按下进入下载模式(没有试过):

     if (keys_get_state(KEY_VOLUMEUP) && keys_get_state(KEY_VOLUMEDOWN))
         {
             dprintf(ALWAYS,"dload mode key sequence detected\n");
             if (set_download_mode(EMERGENCY_DLOAD))
             {
                 dprintf(CRITICAL,"dload mode not supported by target\n");
             }
             else
             {
                 reboot_device(DLOAD);
                 dprintf(CRITICAL,"Failed to reboot into dload mode\n");
             }
             boot_into_fastboot = true;
         }

(2)按下home键或者音量减键进入recovery模式,按下返回键或者音量减键进入fastboot模式

      if (!boot_into_fastboot)
         {
             if (keys_get_state(KEY_HOME) || keys_get_state(KEY_VOLUMEUP))
                 boot_into_recovery = 1;
             if (!boot_into_recovery &&
                 (keys_get_state(KEY_BACK) || keys_get_state(KEY_VOLUMEDOWN)))
                 boot_into_fastboot = true;
         }

    aboot_init 就简单的介绍完了,在调试的时候有时为了方便,会让设备每次启动都自动进入fastboot 模式,如果想继续往下跑,可以执行:fastboot continue

    如何让设备每次启动都进如fastboot 模式呢?很简单,只需要做如下修改即可:

  

+ boot_into_fastboot = true;

  normal_boot:
         if (!boot_into_fastboot)
         {
             if (target_is_emmc_boot())
             {   















评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值