怎样在fastboot 里面加入新的命令
生活随笔
收集整理的這篇文章主要介紹了
怎样在fastboot 里面加入新的命令
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
fastboot 是android 默認的一種debug 方法。它的優(yōu)點是在進入linux kernel 之前就可以操作。
默認fastboot 支持的命令:
usage: fastboot [ <option> ] <command> commands:
? update <filename>??????????????????????????? ????? reflash device from update.zip
? flashall????????????????????????????????????????? ?????????? flash boot + recovery + system
? flash <partition> [ <filename> ]????????????? write a file to a flash partition
? erase <partition>???????????????????????????????????? erase a flash partition
? format <partition>?????????????????????????????????? format a flash partition
? getvar <variable>??????????????????????????????????? display a bootloader variable
? boot <kernel> [ <ramdisk> ]????????????????? ?download and boot kernel
? flash:raw boot <kernel> [ <ramdisk> ]??? 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 <specific device>?????????????specify device serial number or path to device port
? -l???????????????????????????????????????? with "devices", lists device paths
? -p <product>???????????????????????????? specify product name
? -c <cmdline>???????????????????????????? override kernel commandline
? -i <vendor id>?????????????????????????? specify a custom USB vendor id
? -b <base_addr>?????????????????????????specify a custom kernel base address
? -n <page size>?????????????????????????? specify the nand page size. default: 2048
? -S <size>[K|M|G]???????????????????????automatically sparse files greater than size.? 0 to disable
???????????????????????????????????????????
fastboot 提供了擴展的命令符號?
fastboot oem command args 以下以fastboot oem hello test 來說明怎樣擴展
(1).在alps/bootable/bootloader/lk/app/mt_boot/fastboot.c?
的fastboot_init 函數(shù)中加入一個新的register
//第一個參數(shù)是命令的名稱
//第二個參數(shù)是命令的運行函數(shù)
//第三個參數(shù)是在security IC 中是否還提供此命令
fastboot_register("oem hello", cmd_oem_hello, FALSE); ? (2). 實現(xiàn)cmd_oem_hello 函數(shù)
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 端交互
您能夠使用以下已經(jīng)定義好的三個函數(shù)與PC 端交互
fastboot_okey(const char* result);
fastboot_fail(const char* reason);
fastboot_info(const char* reason);??????????????????????????????????
注意這三個打印字符串的長度都不能超過64-1-4 = 59 個字符
默認fastboot 支持的命令:
usage: fastboot [ <option> ] <command> commands:
? update <filename>??????????????????????????? ????? reflash device from update.zip
? flashall????????????????????????????????????????? ?????????? flash boot + recovery + system
? flash <partition> [ <filename> ]????????????? write a file to a flash partition
? erase <partition>???????????????????????????????????? erase a flash partition
? format <partition>?????????????????????????????????? format a flash partition
? getvar <variable>??????????????????????????????????? display a bootloader variable
? boot <kernel> [ <ramdisk> ]????????????????? ?download and boot kernel
? flash:raw boot <kernel> [ <ramdisk> ]??? 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 <specific device>?????????????specify device serial number or path to device port
? -l???????????????????????????????????????? with "devices", lists device paths
? -p <product>???????????????????????????? specify product name
? -c <cmdline>???????????????????????????? override kernel commandline
? -i <vendor id>?????????????????????????? specify a custom USB vendor id
? -b <base_addr>?????????????????????????specify a custom kernel base address
? -n <page size>?????????????????????????? specify the nand page size. default: 2048
? -S <size>[K|M|G]???????????????????????automatically sparse files greater than size.? 0 to disable
???????????????????????????????????????????
fastboot 提供了擴展的命令符號?
fastboot oem command args 以下以fastboot oem hello test 來說明怎樣擴展
(1).在alps/bootable/bootloader/lk/app/mt_boot/fastboot.c?
的fastboot_init 函數(shù)中加入一個新的register
//第一個參數(shù)是命令的名稱
//第二個參數(shù)是命令的運行函數(shù)
//第三個參數(shù)是在security IC 中是否還提供此命令
fastboot_register("oem hello", cmd_oem_hello, FALSE); ? (2). 實現(xiàn)cmd_oem_hello 函數(shù)
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 端交互
您能夠使用以下已經(jīng)定義好的三個函數(shù)與PC 端交互
fastboot_okey(const char* result);
fastboot_fail(const char* reason);
fastboot_info(const char* reason);??????????????????????????????????
注意這三個打印字符串的長度都不能超過64-1-4 = 59 個字符
總結
以上是生活随笔為你收集整理的怎样在fastboot 里面加入新的命令的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: StoreServ的ASIC架构师必须面
- 下一篇: rocksdb ubuntu c++源码