fastboot 是android 默認的一種debug 方法,它的好處是在進入linux kernel 之前
即可操作。
默認fastboot 支持的命令:
usage: fastboot [ ] commands: update reflash device from update.zip flashall flash boot + recovery + system flash [ ] write a file to a flash partition erase erase a flash partition format format a flash partition getvar display a bootloader variable boot [ ] download and boot kernel flash:raw boot [ ] create bootimage and flash it devices list all connected devices continue continue with autoboot reboot reboot device normally reboot-bootloader reboot device into bootloader help show this help message options: -w erase userdata and cache (and format if supported by partition type) -u do not first erase partition before formatting -s specify device serial number or path to device port -l with "devices", lists device paths -p specify product name -c override kernel commandline -i specify a custom USB vendor id -b specify a custom kernel base address -n specify the nand page size. default: 2048 -S [K|M|G] automatically sparse files greater than size. 0 to disable
fastboot 提供瞭擴展的命令符號
fastboot oem command args
下面以fastboot oem hello test 來說明如何擴展
(1).在bootable/bootloader/lk/app/mt_boot/fastboot.c
的fastboot_init 函數中添加一個新的register
//第一個參數是命令的名稱 //第二個參數是命令的執行函數 //第三個參數是在security IC 中是否還提供此命令 fastboot_register("oem hello", cmd_oem_hello, FALSE);
(2). 實現cmd_oem_hello 函數
void cmd_oem_hello(const char *arg, void *data, unsigned size) {
//註意args 是以command 結束開始,即" args" if(!strncmp(arg, " OK", strlen(" OK"))){ fastboot_okey("OK"); }else{ fastboot_fail("Not OK"); } }
(3). 與PC 端交互
您可以使用下面已經定義好的三個函數與PC 端交互
fastboot_okey(const char* result); fastboot_fail(const char* reason); fastboot_info(const char* reason);
註意這三個打印字符串的長度都不能超過64-1-4 = 59 個字
轉載請註明出處:周木水的CSDN博客 https://blog.csdn.net/zhoumushui
我的GitHub:周木水的GitHub https://github.com/zhoumushui