rk-android16通过 adb reboot charge 进入 Android 充电模式

📅 2026/7/7 11:22:46
rk-android16通过 adb reboot charge 进入 Android 充电模式
1. 什么是 adb reboot chargeadb reboot charge是 Android 调试桥ADB提供的一个特殊重启命令。与常规的adb reboot不同此命令会指示设备重启并直接进入一个名为“充电模式”的特殊系统状态。在该模式下Android 系统内核和基础服务会启动但用户界面如 Launcher、SystemUI和大部分用户应用不会加载设备屏幕通常保持黑屏或显示简单的充电图标。这个模式主要用于硬件和底层电源管理的调试与测试。2. 修改 Patch为了支持adb reboot charge命令通常需要在 Android 系统源码中进行修改。配置dts支持android充电或uboot充电kernel-6.12/arch/arm64/boot/dts/rockchip/rk3572_xxx.dtscharge_animation: charge-animation { compatible rockchip,uboot-charge; rockchip,uboot-charge-on 0; rockchip,android-charge-on 1; rockchip,uboot-low-power-voltage 3450; rockchip,screen-on-voltage 3500; rockchip,uboot-exit-charge-level 2; rockchip,uboot-exit-charge-voltage 3500; rockchip,uboot-exit-charge-auto 1; status okay; };使能u-boot支持u-boot/drivers/power/charge_animation.cu-boot/include/power/charge_animation.hdiff --git a/drivers/power/charge_animation.c b/drivers/power/charge_animation.c old mode 100644 new mode 100755 index 0255e5900ac..2ae6c9cc019 --- a/drivers/power/charge_animation.c b/drivers/power/charge_animation.c -211,6 211,10 static int charge_animation_of_to_plat(struct udevice *dev) pdata-low_power_voltage dev_read_u32_default(dev, rockchip,uboot-low-power-voltage, 0); /* changed xxx: for judge low power status*/ pdata-low_power_level dev_read_u32_default(dev, rockchip,uboot-low-power-level, 0); /* changed end. */ pdata-screen_on_voltage dev_read_u32_default(dev, rockchip,screen-on-voltage, 0); -238,10 242,11 static int charge_animation_of_to_plat(struct udevice *dev) } debug(mode: uboot%d, android%d; exit: soc%d%%, voltage%dmv;\n - lp_voltage%d%%, screen_on%dmv\n, lp_voltage%d%%, screen_on%dmv, lp_level%d%%\n, pdata-uboot_charge, pdata-android_charge, pdata-exit_charge_level, pdata-exit_charge_voltage, - pdata-low_power_voltage, pdata-screen_on_voltage); pdata-low_power_voltage, pdata-screen_on_voltage, pdata-low_power_level); return 0; } -511,7 516,16 static int charge_extrem_low_power(struct udevice *dev) if (voltage 0) return -EINVAL; - while (voltage pdata-low_power_voltage 50) { /* changed xxx: for judge low power status*/ soc fuel_gauge_update_get_soc(fg); if (soc 0 || soc 100) { printf(get soc failed: %d\n, soc); return -EINVAL; } printf(lp status: l%d%%, v%dmv, Thl%d%%, Thv(%d50)mv\n, soc, voltage, pdata-low_power_level, pdata-low_power_voltage); while (((voltage pdata-low_power_voltage 50) (soc pdata-low_power_level)) || (0 soc)) { /* changed end. */ if (!first_poll_fg) mdelay(FUEL_GAUGE_POLL_MS); -545,8 559,7 static int charge_extrem_low_power(struct udevice *dev) /* Update led */ leds_update(dev, soc); - printf(Extrem low power, force charging... threshold%dmv, now%dmv\n, - pdata-low_power_voltage, voltage); printf(Extrem low power, force charging... threshold%dmv, now v%dmv soc%d\n, pdata-low_power_voltage, voltage, soc); /* System suspend */ system_suspend_enter(dev); -656,12 669,14 static int charge_animation_show(struct udevice *dev) printf(Exit charge: due to charger offline\n); return 0; } - printf(Android charge mode, uboot_charge %d, pdata-android_charge %d, boot_mode %d\n, pdata-uboot_charge, pdata-android_charge, boot_mode); /* changed xxx: for enter charging mode when exec reboot charge cmd */ /* Enter android charge, set property for kernel */ - if (pdata-android_charge) { if (BOOT_MODE_CHARGING boot_mode || pdata-android_charge) { env_update(bootargs, androidboot.modecharger); - printf(Android charge mode\n); printf(Android charge mode, boot_mode %d\n, boot_mode); } /* changed end. */ //uboot lights on led ret led_get_by_label(battery_charging, led_dev); diff --git a/include/power/charge_animation.h b/include/power/charge_animation.h old mode 100644 new mode 100755 index 006533477ff..29117407c46 --- a/include/power/charge_animation.h b/include/power/charge_animation.h -20,6 20,7 struct charge_animation_pdata { int exit_charge_voltage;/* lowest voltage allowed to exit charging */ int exit_charge_level; /* lowest soc level allowed to exit charging */ int low_power_voltage; /* below this voltage, force system into charge mode anyway */ int low_power_level; /* use with low voltage, below this level, force system into charge mode anyway */ int screen_on_voltage; /* lowest voltage allowed to turn on screen */ int system_suspend; /* enter ATF system suspend, 1: enable, 0: disable */ (END)3. 使用说明连上adb后直接adb reboot charge就进入了android充电模式