Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1305850
  • 博文数量: 478
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 4833
  • 用 户 组: 普通用户
  • 注册时间: 2014-06-28 11:12
文章分类

全部博文(478)

文章存档

2019年(1)

2018年(27)

2017年(21)

2016年(171)

2015年(258)

我的朋友

分类: Android平台

2015-08-15 17:15:33

[FAQ10448]如何在fastboot 里面添加新的命令
2014-09-19
Branch:JB9JB5JB3JB2...
FAQs 53 of 108
如何在Android user 版本下打开UART log? 如何在IPO关机期间使用adb?

FAQ Content

[Description]
如何在fastboot 里面添加新的命令
 
[Keyword]
fastboot new command 添加命令
 
[Solution]
fastboot 是android 默认的一种debug 方法,它的好处是在进入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 函数中添加一个新的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 个字符
阅读(678) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~