Android在Fastboot裡添加命令

來源:互聯網
上載者:User

標籤:android   fastboot   添加命令   

fastboot 是android 預設的一種debug 方法,它的好處是在進入linux kernel 之前
即可操作。
預設fastboot 支援的命令:
<span style="font-size:14px;">usage: fastboot [ <option> ] <command>commands:update <filename> reflash device fromupdate.zipflashall flash boot+ recovery + systemflash <partition> [ <filename> ] write a file to a flashpartitionerase <partition> erase a flashpartitionformat <partition> format a flashpartitiongetvar <variable> display abootloader variableboot <kernel> [ <ramdisk> ] download and boot kernelflash:raw boot <kernel> [ <ramdisk> ] create bootimage and flash itdevices list allconnected devicescontinue continuewith autobootreboot rebootdevice normallyreboot-bootloader reboot deviceinto bootloaderhelp show thishelp messageoptions:-w erase userdata and cache (andformat if supported by partition type)-u do not first erase partitionbefore formatting-s <specific device> specify device serial number or path todevice port-l with "devices", lists devicepaths-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 baseaddress-n <page size> specify the nand page size.default: 2048-S <size>[K|M|G] automatically sparse filesgreater than size. 0 to disable</span>


fastboot 提供了擴充的命令符號
<span style="font-size:14px;">fastboot oem command args</span>

下面以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部落格 http://blog.csdn.net/zhoumushui

我的GitHub:周木水的GitHub https://github.com/zhoumushui


Android在Fastboot裡添加命令

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.