1 fireflyROC-RK3308B主板CC-ADB调试工具简介-德赢Vwin官网 网

fireflyROC-RK3308B主板CC-ADB调试工具简介

描述

ADB 使用
前言

ADB,全称 Android Debug Bridge,是 Android 的命令行调试工具,可以完成多种功能,主要有:

  • 运行设备的 shell(命令行)

  • 管理模拟器或设备的端口映射

  • 计算机和设备之间上传/下载文件

  • 将本地 apk 软件安装至模拟器或硬件设备

ADB是一个“客户端-服务器端”程序,其中客户端主要是指 PC,服务器端是 Android 设备的实体机器或者虚拟机。根据 PC 连接 Box 机器的方式不同,ADB 可以分为两类:

  • 网络 ADB:主机通过有线/无线网络(同一局域网)连接到硬件设备

  • USB ADB:主机通过 USB 线连接到硬件设备

为了在ROC-RK3308B-CC也能使用ADB工具进行调试,我们移植了adb服务。但由于并非Android设备,很多adb命令类似adb logcat、adb install等不能使用,仅作为普通的调试辅助工具,可以进行shell交互、上传下载文件等操作。同样,网络远程ADB调试不能使用。

Buildroot 配置

RK3308

 
准备连接

ROC-RK3308B-CC 只能使用USB ADB功能,使用USB ADB有以下限制:

  • 只支持 USB OTG 口

  • 不支持多个客户端同时使用(如 cmd 窗口,eclipse 等)

  • 只支持主机连接一个设备,不支持连接多个设备

用 USB Type-C 线连接设备和主机,运行adbdevices命令,如果显示机器的序列号,表示连接成功。

Windows下的 ADB 安装

首先参照安装 RK USB 驱动一节安装好驱动。然后下载 adb.zip,解压到C:\adb以方便调用。

打开命令行窗口,输入:

cdC:\adb adb shell

如果一切正常,就可以进入adbshell,在设备上面运行命令。

Ubuntu 下的 ADB 安装
  • 安装adb工具:

sudo apt-get install android-tools-adb
  • 加入设备标识:

mkdir -p ~/.android vim ~/.android/adb_usb.ini# 添加以下一行0x2207
  • 加入udev规则:

sudo vim /etc/udev/rules.d/51-android.rules# 添加以下一行:SUBSYSTEM=="usb", ATTR{idVendor}=="2207",MODE="0666"
  • 重新插拔USB线,或运行以下命令,让udev规则生效:

sudo udevadm control --reload-rules sudo udevadm trigger
  • 重新启动adb服务器

sudo adb kill-server adb start-server
常用 ADB 命令
连接管理

列出所有连接设备及其序列号

adb devices

如果有多个连接设备,通过以下命令,使用序列号来区分:

exportANDROID_SERIAL=<序列号> adb shell ls

进入设备的 shell

adb shell

从电脑上传文件到设备

adb push <本地路径> <远程路径>

从设备下载文件到电脑

adb pull <远程路径> <本地路径>

暂不支持网络 adb 调试。

获取详细运行信息 adb bugreport

adb bugreport 用于错误报告,里面包含大量有用的信息。

示例:

adb bugreport# 保存到本地,方便用编辑器查看adb bugreport >bugreport.txt
命令行帮助信息 adb help

注意:并不是所有命令都能使用,帮助信息只做参考

AndroidDebugBridgeversion1.0.31-a-directsadbtolistenonallinterfacesforaconnection-d-directscommandtotheonlyconnectedUSBdevicereturnsanerrorifmorethanoneUSBdeviceispresent.-e-directscommandtotheonlyrunningemulator.returnsanerrorifmorethanoneemulatorisrunning.-s-directscommandtothedeviceoremulatorwiththegivenserialnumberorqualifier.OverridesANDROID_SERIALenvironmentvariable.-p-simpleproductnamelike'sooner',orarelative/absolutepathtoaproductoutdirectorylike'out/target/product/sooner'.If-pisnotspecified,theANDROID_PRODUCT_OUTenvironmentvariableisused,whichmustbeanabsolutepath.-H-Nameofadbserverhost(default:localhost)-P-Portofadbserver(default:5037)devices[-l]-listallconnecteddevices('-l'willalsolistdevicequalifiers)connect[:]-connecttoadeviceviaTCP/IPPort5555isusedbydefaultifnoportnumberisspecified.disconnect[[:]]-disconnectfromaTCP/IPdevice.Port5555isusedbydefaultifnoportnumberisspecified.UsingthiscommandwithnoadditionalargumentswilldisconnectfromallconnectedTCP/IPdevices.devicecommands:adbpush[-p]-copyfile/dirtodevice('-p'todisplaythetransferprogress)adbpull[-p][-a][]-copyfile/dirfromdevice('-p'todisplaythetransferprogress)('-a'meanscopytimestampandmode)adbsync[]-copyhost->deviceonlyifchanged(-lmeanslistbutdon't copy)(see'adb help all')adbshell-runremoteshellinteractivelyadbshell-runremoteshellcommandadbemu-runemulatorconsolecommandadblogcat[]-Viewdevicelogadbforward--list-listallforwardsocketconnections.theformatisalistoflineswiththefollowingformat:" "" ""\n"adbforward-forwardsocketconnectionsforwardspecsareoneof:tcp:localabstract:localreserved:localfilesystem:dev:jdwp:(remoteonly)adbforward--no-rebind-sameas'adb forward 'butfailsifisalreadyforwardedadbforward--remove-removeaspecificforwardsocketconnectionadbforward--remove-all-removeallforwardsocketconnectionsadbjdwp-listPIDsofprocesseshostingaJDWPtransportadbinstall[-l][-r][-d][-s][--algo--key--iv]-pushthispackagefiletothedeviceandinstallit('-l'meansforward-locktheapp)('-r'meansreinstalltheapp,keepingitsdata)('-d'meansallowversioncodedowngrade)('-s'meansinstallonSDcardinsteadofinternalstorage)('--algo','--key',and'--iv'meanthefileisencryptedalready)adbuninstall[-k]-removethisapppackagefromthedevice('-k'meanskeepthedataandcachedirectories)adbbugreport-returnallinformationfromthedevicethatshouldbeincludedinabugreport.adbbackup[-f][-apk|-noapk][-obb|-noobb][-shared|-noshared][-all][-system|-nosystem][]-writeanarchiveofthedevice's data to .Ifno-foptionissuppliedthenthedataiswrittento"backup.ab"inthecurrentdirectory.(-apk|-noapkenable/disablebackupofthe.apksthemselvesinthearchive;thedefaultisnoapk.)(-obb|-noobbenable/disablebackupofanyinstalledapkexpansion(aka.obb)filesassociatedwitheachapplication;thedefaultisnoobb.)(-shared|-nosharedenable/disablebackupofthedevice'ssharedstorage/SDcardcontents;thedefaultisnoshared.)(-allmeanstobackupallinstalledapplications)(-system|-nosystemtoggleswhether-allautomaticallyincludessystemapplications;thedefaultistoincludesystemapps)(isthelistofapplicationstobebackedup.Ifthe-allor-sharedflagsarepassed,thenthepackagelistisoptional.Applicationsexplicitlygivenonthecommandlinewillbeincludedevenif-nosystemwouldordinarilycausethemtobeomitted.)adbrestore-restoredevicecontentsfromthebackuparchiveadbhelp-showthishelpmessageadbversion-showversionnumscripting:adbwait-for-device-blockuntildeviceisonlineadbstart-server-ensurethatthereisaserverrunningadbkill-server-killtheserverifitisrunningadbget-state-prints:offline|bootloader|deviceadbget-serialno-prints:adbget-devpath-prints:adbstatus-window-continuouslyprintdevicestatusforaspecifieddeviceadbremount-remountsthe/systempartitiononthedeviceread-writeadbreboot[bootloader|recovery]-rebootsthedevice,optionallyintothebootloaderorrecoveryprogramadbreboot-bootloader-rebootsthedeviceintothebootloaderadbroot-restartstheadbddaemonwithrootpermissionsadbusb-restartstheadbddaemonlisteningonUSBadbtcpip-restartstheadbddaemonlisteningonTCPonthespecifiedportnetworking:adbppp[parameters]-RunPPPoverUSB.Note:youshouldnotautomaticallystartaPPPconnection.referstothettyforPPPstream.Eg.dev:/dev/omap_csmi_tty1[parameters]-Eg.defaultroutedebugdumplocalnottyusepeerdnsadbsyncnotes:adbsync[]canbeinterpretedinseveralways:-Ifisnotspecified,both/systemand/datapartitionswillbeupdated.-Ifitis"system"or"data",onlythecorrespondingpartitionisupdated.environmentalvariables:ADB_TRACE-Printdebuginformation.Acommaseparatedlistofthefollowingvalues1orall,adb,sockets,packets,rwx,usb,sync,sysdeps,transport,jdwpANDROID_SERIAL-Theserialnumbertoconnectto.-stakespriorityoverthisifgiven.ANDROID_LOG_TAGS-Whenusedwiththelogcatoption,onlythesedebugtagsareprinted.

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表德赢Vwin官网 网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分