您的位置首页>硬件>

fireflyCORE-3399PRO主板JD4--Android开发

导读 大家好,我是极客范的本期栏目编辑小友,现在为大家讲解fireflyCORE-3399PRO主板JD4--Android开发问题。安卓开发亚行使用序安卓Debug Br

大家好,我是极客范的本期栏目编辑小友,现在为大家讲解fireflyCORE-3399PRO主板JD4--Android开发问题。

安卓开发

亚行使用

安卓Debug Bridge全称Adb,是安卓的命令行调试工具,可以完成跟踪系统日志、上传下载文件、安装应用等多项功能。

准备连接

支持两种ADB链接模式:USB和网络连接。

USB模式

在开发板上,输入选项-开发人员选项,并勾选“USB调试”选项

AIO-3399PRO-JD4采用双公usb数据线连接设备和主机的USB3.0端口。

主机/设备模式切换

设置-连接的设备-连接到电脑

网络模式

网络亚行

检查RK3399Pro的IP地址,PC可以通过网络访问。示例:

adb连接IP adb外壳

窗口下的亚行安装

首先,请参考安装RK USB驱动程序一节安装驱动程序。然后在http://adbshell.com/download/download-adb-for-windows.html下载adb.zip,解压到C:\adb,方便调用。打开命令行窗口,输入:

cd C:\adb adb外壳

如果一切正常,您可以进入adb shell并在设备上运行命令。

Ubuntu下的亚行安装

安装adb工具:

sudo apt-get安装android-tools-adb

添加设备标识:

Mkdir-p ~/。安卓VI ~/。安卓/亚行_ USB.ini #添加以下第0x2207行

加入udev规则:

sud VI/etc/udev/rules . d/51-Android . rules #添加以下行:子系统==' USB ',attr { idvendor }==' 2207 ',模式=' 0666 '

再次插拔USB电缆,或者运行以下命令使udev规则生效:

sudo udevadm控制-重新加载-规则sudo udevadm触发器

重新启动adb服务器

sudo ADB kill-服务器ADB start-服务器

常见的亚行命令

连接管理

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

adb设备

如果有多个连接的设备,您需要使用序列号来区分它们:

导出ANDROID _ SERIAL=adb shell ls

在多个设备下连接指定的设备。

Adb -s序列号外壳

您可以通过网络连接adb:

#在设备端重启adbd,在TCP端口5555处监听adb tcpip 5555 #此时可以断开USB连接#远程连接设备,设备的ip地址为192.168.1 . 100 ADB Connect 192 . 168 . 1 . 1003360555 #断开ADB断开192 . 168 . 1。

调试获取系统日志 adb logcat

用法

adb logcat [选项] [应用标签]

示例

# 查看全部日志 adb logcat # 仅查看部分日志 adb logcat -s WifiStateMachine StateMachine 运行命令 adb shell获取详细运行信息 adb bugreport

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

示例

adb bugreport # 保存到本地,方便用编辑器查看 adb bugreport >bugreport.txt root 权限

如果 TARGET_BUILD_VARIANT 使用的是 userdebug 模式,要获得 root 权限,需要先运行:

adb root

让 adb 的设备端切换到 root 权限模式,这样 adb remount 等需要 root 权限的命令才会成功。

应用管理安装应用 adb install

用法:

adb install [选项] 应用包.apk

选项包括:

-l forward-lock -r 重新安装应用,保留原先数据 -s 安装到 SD 卡上,而不是内部存储

示例:

# 安装 facebook.apk adb install facebook.apk # 升级 twitter.apk adb install -r twitter.apk

如果安装成功,工具会返回成功提示 “Success”;失败的话,一般是以下几种情况:

INSTALL_FAILED_ALREADY_EXISTS: 此时需要用 -r 参数来重新安装。

INSTALL_FAILED_SIGNATURE_ERROR: 应用的签名不一致,可能是发布版和调试版签名不同所致。如果确认 APK 文件签名正常,可以用 adb uninstall 命令先卸载旧的应用,然后再安装。

INSTALL_FAILED_INSUFFICIENT_STORAGE: 存储空间不足,需要检查设备存储情况。

卸载应用 adb uninstall

用法:

adb uninstall 应用包名称

示例:

adb uninstall com.android.chrome

应用包名称可以用以下命令列出:

adb shell pm list packages -f

运行结果是:

package:/system/app/Bluetooth.apk=com.android.bluetooth

前面是 apk 文件,后面则是对应的包名称。

命令行帮助信息 adb helpAndroid Debug Bridge version 1.0.31 -a - directs adb to listen on all interfaces for a connection -d - directs command to the only connected USB device returns an error if more than one USB device is present. -e - directs command to the only running emulator. returns an error if more than one emulator is running. -s - directs command to the device or emulator with the given serial number or qualifier. Overrides ANDROID_SERIAL environment variable. -p - simple product name like 'sooner', or a relative/absolute path to a product out directory like 'out/target/product/sooner'. If -p is not specified, the ANDROID_PRODUCT_OUT environment variable is used, which must be an absolute path. -H - Name of adb server host (default: localhost) -P - Port of adb server (default: 5037) devices [-l] - list all connected devices ('-l' will also list device qualifiers) connect [:] - connect to a device via TCP/IP Port 5555 is used by default if no port number is specified. disconnect [[:]] - disconnect from a TCP/IP device. Port 5555 is used by default if no port number is specified. Using this command with no additional arguments will disconnect from all connected TCP/IP devices. device commands: adb push [-p] - copy file/dir to device ('-p' to display the transfer progress) adb pull [-p] [-a] [] - copy file/dir from device ('-p' to display the transfer progress) ('-a' means copy timestamp and mode) adb sync [ ] - copy host->device only if changed (-l means list but don't copy) (see 'adb help all') adb shell - run remote shell interactively adb shell - run remote shell command adb emu - run emulator console command adb logcat [ ] - View device log adb forward --list - list all forward socket connections. the format is a list of lines with the following format:"""""\n"adb forward - forward socket connections forward specs are one of: tcp: localabstract: localreserved: localfilesystem: dev: jdwp: (remote only) adb forward --no-rebind - same as 'adb forward ' but fails if is already forwarded adb forward --remove - remove a specific forward socket connection adb forward --remove-all - remove all forward socket connections adb jdwp - list PIDs of processes hosting a JDWP transport adb install [-l] [-r] [-d] [-s] [--algo --key --iv ] - push this package file to the device and install it ('-l' means forward-lock the app) ('-r' means reinstall the app, keeping its data) ('-d' means allow version code downgrade) ('-s' means install on SD card instead of internal storage) ('--algo', '--key', and '--iv' mean the file is encrypted already) adb uninstall [-k] - remove this app package from the device ('-k' means keep the data and cache directories) adb bugreport - return all information from the device that should be included in a bug report. adb backup [-f ] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared] [-all] [-system|-nosystem] [] - write an archive of the device's data to . If no -f option is supplied then the data is written to"backup.ab"in the current directory. (-apk|-noapk enable/disable backup of the .apks themselves in the archive; the default is noapk.) (-obb|-noobb enable/disable backup of any installed apk expansion (aka .obb) files associated with each application; the default is noobb.) (-shared|-noshared enable/disable backup of the device's shared storage / SD card contents; the default is noshared.) (-all means to back up all installed applications) (-system|-nosystem toggles whether -all automatically includes system applications; the default is to include system apps) ( is the list of applications to be backed up. If the -all or -shared flags are passed, then the package list is optional. Applications explicitly given on the command line will be included even if -nosystem would ordinarily cause them to be omitted.) adb restore - restore device contents from the backup archive adb help - show this help message adb version - show version num scripting: adb wait-for-device - block until device is online adb start-server - ensure that there is a server running adb kill-server - kill the server if it is running adb get-state - prints: offline | bootloader | device adb get-serialno - prints: adb get-devpath - prints: adb status-window - continuously print device status for a specified device adb remount - remounts the /system partition on the device read-write adb reboot [bootloader|recovery] - reboots the device, optionally into the bootloader or recovery program adb reboot-bootloader - reboots the device into the bootloader adb root - restarts the adbd daemon with root permissions adb usb - restarts the adbd daemon listening on USB adb tcpip - restarts the adbd daemon listening on TCP on the specified port networking: adb ppp [parameters] - Run PPP over USB. Note: you should not automatically start a PPP connection. refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1 [parameters] - Eg. defaultroute debug dump local notty usepeerdns adb sync notes: adb sync [ ] can be interpreted in several ways: - If is not specified, both /system and /data partitions will be updated. - If it is"system"or"data", only the corresponding partition is updated. environmental variables: ADB_TRACE - Print debug information. A comma separated list of the following values 1 or all, adb, sockets, packets, rwx, usb, sync, sysdeps, transport, jdwp ANDROID_SERIAL - The serial number to connect to. -s takes priority over this if given. ANDROID_LOG_TAGS - When used with the logcat option, only these debug tags are printed. 编译 Android8.1 固件准备工作

编译 Android 对机器的配置要求较高:

64 位 CPU

16GB 物理内存+交换内存

100GB 空闲的磁盘空间用于构建,源码树另外占用大约 25GB

官方推荐 Ubuntu 14.04 操作系统,经测试,Ubuntu 12.04 也可以编译运行成功,只需要满足 http://source.android.com/source/building.html 里的软硬件配置即可。编译环境的初始化可参考 http://source.android.com/source/initializing.html 。

安装 OpenJDK 8:

sudo apt-get install openjdk-8-jdk

提示:安装 openjdk-8-jdk,会更改 JDK 的默认链接,这时可用:

$ sudo update-alternatives --config java $ sudo update-alternatives --config javac

来切换 JDK 版本。SDK 在找不到操作系统默认 JDK 的时候会使用内部设定的 JDK 路径,因此,为了让同一台机器可以编译 Android 5.1 及之前的版本,去掉链接更方便:

$ sudo /var/lib/dpkg/info/openjdk-8-jdk:amd64.prerm remove

Ubuntu 12.04 软件包安装:

sudo apt-get install git gnupg flex bison gperf build-essential \ zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \ libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \ g++-multilib mingw32 tofrodos gcc-multilib ia32-libs \ python-markdown libxml2-utils xsltproc zlib1g-dev:i386 \ lzop libssl1.0.0 libssl-dev

Ubuntu 14.04 软件包安装:

sudo apt-get install git-core gnupg flex bison gperf libsdl1.2-dev \ libesd0-dev libwxgtk2.8-dev squashfs-tools build-essential zip curl \ libncurses5-dev zlib1g-dev pngcrush schedtool libxml2 libxml2-utils \ xsltproc lzop libc6-dev schedtool g++-multilib lib32z1-dev lib32ncurses5-dev \ lib32readline-gplv2-dev gcc-multilib libswitch-perl \ libssl1.0.0 libssl-dev 下载 Android 8.1 SDK

Android SDK 源码包比较大,可以通过如下方式获取Android8.1源码包:

下载

[下载SDK]完成后先验证一下 MD5 码:

$ md5sum /path/to/rk3399pro_firefly_aiojd4_android8.1_20190430.7z.001 $ md5sum /path/to/rk3399pro_firefly_aiojd4_android8.1_20190430.7z.002 $ md5sum /path/to/rk3399pro_firefly_aiojd4_android8.1_20190430.7z.003 70dd51416594d36e140d2eef0738e270 rk3399pro_firefly_aiojd4_android8.1_20190430.7z.001 ac8234b94df1b812afd6a4c8c42976cb rk3399pro_firefly_aiojd4_android8.1_20190430.7z.002 68b2da1653aed2d9d80871d7ad21272d rk3399pro_firefly_aiojd4_android8.1_20190430.7z.003

确认无误后,就可以解压:

cd ~/proj/ 7z x ./rk3399pro_firefly_aiojd4_android8.1_20190430.7z.001 -oAIO-RK3399ProJD4 cd ./AIO-RK3399proJD4 git reset --hard

更新

以下为从 gitlab 处更新的方法:

#1. 进入SDK根目录 cd ~/proj/AIO-RK3399ProJD4 #2. 下载远程bundle仓库 git clone https://gitlab.com/TeeFirefly/rk3399pro-oreo-bundle.git .bundle #3. 若下载仓库失败,则可以从下方百度云下载[bundle压缩包]并解压到SDK根目录,解压指令如下: 7z x rk3399pro-oreo-bundle.7z -r -o. && mv rk3399pro-oreo-bundle/ .bundle/ #4. 更新SDK,并且后续更新不需要再次拉取远程仓库,直接执行以下命令即可 .bundle/update #5. 按照提示已经更新内容到 FETCH_HEAD,同步FETCH_HEAD到firefly分支 git rebase FETCH_HEAD

百度云下载[bundle压缩包]

AIO-RK3399ProJD4产品编译方法HDMI显示编译./FFTools/make.sh -d rk3399pro-firefly-aiojd4 -j8 -l rk3399pro_firefly_aiojd4-userdebug ./FFTools/mkupdate/mkupdate.sh -l rk3399pro_firefly_aiojd4-userdebug 手动编译AIO-3399ProJD4

编译前执行如下命令配置环境变量:

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar

编译kernel:

cd ~/proj/AIO-RK3399ProJD4/kernel/ make ARCH=arm64 firefly_defconfig make -j8 ARCH=arm64 rk3399pro-firefly-aiojd4.img

编译uboot:

cd ~/proj/AIO-RK3399ProJD4/u-boot/ ./make.sh rk3399pro

编译android:

cd ~/proj/AIO-RK3399ProJD4/ source build/envsetup.sh lunch rk3399pro_firefly_aioJD4-userdebug make -j8 ./mkimage.sh 打包成统一固件 update.img

编译完可以用Firefly官方的脚本打包成统一固件,执行如下命令:

./FFTools/mkupdate/mkupdate.sh update

打包完成后将在rockdev/Image-rk3399pro_firefly_aiojd4/下生成统一固件:update.img

在 Windows 下打包统一固件 update.img 也很简单,将编译生成的文件拷贝到 AndroidTool 的 rockdev\Image 目录中,然后运行 rockdev 目录下的 mkupdate.bat 批处理文件即可创建 update.img 并存放到 rockdev\Image 目录里。

烧写分区映像

编译的时候执行 ./mkimage.sh 会重新打包 boot.img 和 system.img, 并将其它相关的映像文件拷贝到目录 rockdev/Image-rk3399pro_firefly_aiojd4/ 中。以下列出一般固件用到的映像文件:

boot.img :Android 的初始文件映像,负责初始化并加载 system 分区。

kernel.img :内核映像。

misc.img :misc 分区映像,负责启动模式切换和急救模式的参数传递。

parameter.txt :emmc的分区信息

recovery.img :急救模式映像。

resource.img :资源映像,内含开机图片和内核的设备树信息。

system.img :Android 的 system 分区映像,ext4 文件系统格式。

trust.img :休眠唤醒相关的文件

MiniLoaderAll.bin :Loader文件

uboot.img :uboot文件

oem.img :预置媒体资源及数据包

vendor.img :产品标识和驱动

请参照 如何升级固件 一文来烧写分区映像文件。

如果使用的是 Windows 系统,将上述映像文件拷贝到 AndroidTool (Windows 下的固件升级工具)的 rockdev\Image 目录中,之后参照升级文档烧写分区映像即可,这样的好处是使用默认配置即可,不用修改文件的路径。

update.img 方便固件的发布,供终端用户升级系统使用。一般开发时使用分区映像比较方便。

定制 Android 固件前言

定制 Android 固件,有两种方法:

改源码,然后编译生成固件。

在现有固件的基础上进行裁剪。

前一种方法,可以从各个层面去定制 Android,自由度大,但对编译环境和技术要求比较高,参见《编译 Android8.1 固件》一文。现在介绍后一种方法,分为解包、定制和打包三个阶段。主机操作系统为 Linux,采用的工具为开源软件。

固件格式

统一固件 release_update.img,内含启动加载器 loader.img 和真正的固件数据 update.img

release_update.img |- loader.img `- update.img

update.img 是个复合文件,内含多个文件,由 package-file 描述。一个典型的 package-file 为:

# NAME Relative path package-file package-file bootloader Image/MiniLoaderAll.bin parameter Image/parameter.txt trust Image/trust.img uboot Image/uboot.img misc Image/misc.img resource Image/resource.img kernel Image/kernel.img boot Image/boot.img recovery Image/recovery.img system Image/system.img backup RESERVED #update-script update-script #recover-script recover-script

package-file

update.img 的打包说明文件,update.img 里也含有一份 package-file。

Image/MiniLoaderAll.bin

启动加载器,即 bootloader。

Image/parameter.txt

参数文件,可以设定内核启动参数,里面有重要的分区信息。

Image/trust.img,trust.img 是U-Boot作为二级loader 的打包。

Image/misc.img

misc 分区的映像,用来控制 Android 是正常启动,还是进入急救模式(Recovery Mode)。

Image/kernel.img

Android 内核。

Image/resource.img

资源映像,内有内核开机图片和内核设备树信息(Device Tree Blob)。

Image/boot.img

Android 内核的内存启动盘(initrd),是内核启动后最先加载的根文件系统,包含重要的初始化动作,一般不需要改动。

Image/recovery.img

Android 急救模式的映像,内含内核和急救模式的根文件系统。

Image/system.img

对应于 Android 的 /system 分区,是以下的定制对象。

解包,就是提取 release_update.img 里的 update.img, 然后解压出内含 package-file 所声明的多个文件。打包,则是个逆过程,将 package-file 将所列的多个文件合成 update.img,加进 loader.img,最终生成 release_update.img 。

工具准备git clone https://github.com/TeeFirefly/rk2918_tools.git cd rk2918_tools make sudo cp afptool img_unpack img_maker mkkrnlimg /usr/local/bin 解包

解压 release_update.img

$ cd /path/to/your/firmware/dir $ img_unpack AIO-3399ProJD4_Android8.1.0_HDMI_190509.img img rom version: 6.0.1 build time: 2016-10-27 14:58:18 chip: 33333043 checking md5sum....OK

解压 update.img

$ cd img $ afptool -unpack update.img update Check file...OK ------- UNPACK ------- package-file 0x00000800 0x000002AC Image/MiniLoaderAll.bin 0x00001000 0x0004394E Image/parameter.txt 0x00045000 0x00000368 Image/trust.img 0x00045800 0x00400000 Image/uboot.img 0x00445800 0x00400000 Image/misc.img 0x00845800 0x0000C000 Image/resource.img 0x00851800 0x00038800 Image/kernel.img 0x0088A000 0x012D2014 Image/boot.img 0x01B5C800 0x0017893C Image/recovery.img 0x01CD5800 0x00866B8C Image/system.img 0x0253C800 0x41A9110C Image/vendor.img 0x43FCE000 0x1206E0A0 Image/oem.img 0x5603C800 0x00058094 RESERVED 0x00000000 0x00000000 UnPack OK!

查看 update 目录下的文件树

$ cd update/ $ tree . ├── Image │ ├── boot.img │ ├── kernel.img │ ├── MiniLoaderAll.bin │ ├── misc.img │ ├── oem.img │ ├── parameter.txt │ ├── recovery.img │ ├── resource.img │ ├── system.img │ ├── trust.img │ ├── uboot.img │ └── vendor.img ├── loader.img ├── package-file └── RESERVED 1 directory, 15 files

这样,固件就解包成功了,下面就开始定制吧。

打包

首先要检查一下 system.img 的大小,对照 parameter 文件的分区情况(可参考文档Parameter 文件格式,作必要的大小调整。例如,parameter.txt 文件里的 system 分区大小,可以找到 CMDLINE 一行,然后找到 system 字符串:

0x00200000@0x000B0000(system)

@ 前面就是分区的大小,单位是 512 字节,这样该 system 分区的大小就是:

$ echo $(( 0x00200000 * 512 / 1024 / 1024))M 1024M

只要 system.img 的大小不超过 1024M,parameter 文件就不用更改。如果分区不用更改,可以直接用烧写工具将新的 system.img 烧写到开发板的 system 分区上做试验。否则,需要制作新固件并烧写后再行测试。以下是打包成统一固件 update.img 所需要的步骤:

合成 update.img :

# 当前的目录仍然为 update/ ,内有 package-file, package-file 所列的文件均存在 # 将参数文件拷贝一份到 paramter, 因为 afptool 默认要用到 $ cp Image/parameter.txt parameter $ afptool -pack . ../update_new.img ------ PACKAGE ------ Add file: ./package-file Add file: ./Image/MiniLoaderAll.bin Add file: ./Image/parameter.txt Add file: ./Image/trust.img Add file: ./Image/uboot.img Add file: ./Image/misc.img Add file: ./Image/resource.img Add file: ./Image/kernel.img Add file: ./Image/boot.img Add file: ./Image/recovery.img Add file: ./Image/system.img Add file: ./Image/vendor.img Add file: ./Image/oem.img Add file: ./RESERVED Add CRC... ------ OK ------ Pack OK!

合成 release_update.img :

$ img_maker -rk33 loader.img update_new.img release_update_new.img generate image... append md5sum... success!

release_update_new.img 即为最终生成的可烧写的统一固件文件。

常见问题固件的版本在哪设置

在 parameter 文件中找到下行并修改即可,注意版本号为数字,中间两个点号不能省略。

FIRMWARE_VER: 8.1Android开发ADB 使用前言

adb,全称 Android Debug Bridge,是 Android 的命令行调试工具,可以完成多种功能,如跟踪系统日志,上传下载文件,安装应用等。

准备连接

支持两种ADB链接方式:USB和网络连接。

USB方式

在开发板上进入选项->开发人员选项,勾上 “USB 调试” 选项

AIO-3399PRO-JD4用双公头usb数据线连接设备USB3.0口和主机

host/device模式切换

设置->Connected devices(已关联的设备)->连接到PC

网络方式

网络ADB

查看RK3399Pro的IP地址,PC端通过网络访问。例:

adb connect + IP adb shell Windows下的 ADB 安装

首先参照安装 RK USB 驱动一节安装好驱动。然后到 http://adbshell.com/download/download-adb-for-windows.html 下载 adb.zip,解压到C:\adb以方便调用。 打开命令行窗口,输入:

cd C:\adb adb shell

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

Ubuntu 下的 ADB 安装

安装 adb 工具:

sudo apt-get install android-tools-adb

加入设备标识:

mkdir -p ~/.android vi ~/.android/adb_usb.ini # 添加以下一行 0x2207

加入 udev 规则:

sudo vi /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

如果有多个连接设备,则需要使用序列号来区分:

export ANDROID_SERIAL= adb shell ls

多设备下连接指定设备

adb -s 序列号 shell

可以通过网络来连接 adb:

# 让设备端的 adbd 重启,并在 TCP 端口 5555 处监听 adb tcpip 5555 # 此时可以断开 USB 连接 # 远程连接设备,设备的 IP 地址是 192.168.1.100 adb connect 192.168.1.100:5555 # 断开连接 adb disconnect 192.168.1.100:5555 调试获取系统日志 adb logcat

用法

adb logcat [选项] [应用标签]

示例

# 查看全部日志 adb logcat # 仅查看部分日志 adb logcat -s WifiStateMachine StateMachine 运行命令 adb shell获取详细运行信息 adb bugreport

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

示例

adb bugreport # 保存到本地,方便用编辑器查看 adb bugreport >bugreport.txt root 权限

如果 TARGET_BUILD_VARIANT 使用的是 userdebug 模式,要获得 root 权限,需要先运行:

adb root

让 adb 的设备端切换到 root 权限模式,这样 adb remount 等需要 root 权限的命令才会成功。

应用管理安装应用 adb install

用法:

adb install [选项] 应用包.apk

选项包括:

-l forward-lock -r 重新安装应用,保留原先数据 -s 安装到 SD 卡上,而不是内部存储

示例:

# 安装 facebook.apk adb install facebook.apk # 升级 twitter.apk adb install -r twitter.apk

如果安装成功,工具会返回成功提示 “Success”;失败的话,一般是以下几种情况:

INSTALL_FAILED_ALREADY_EXISTS: 此时需要用 -r 参数来重新安装。

INSTALL_FAILED_SIGNATURE_ERROR: 应用的签名不一致,可能是发布版和调试版签名不同所致。如果确认 APK 文件签名正常,可以用 adb uninstall 命令先卸载旧的应用,然后再安装。

INSTALL_FAILED_INSUFFICIENT_STORAGE: 存储空间不足,需要检查设备存储情况。

卸载应用 adb uninstall

用法:

adb uninstall 应用包名称

示例:

adb uninstall com.android.chrome

应用包名称可以用以下命令列出:

adb shell pm list packages -f

运行结果是:

package:/system/app/Bluetooth.apk=com.android.bluetooth

前面是 apk 文件,后面则是对应的包名称。

命令行帮助信息 adb helpAndroid Debug Bridge version 1.0.31 -a - directs adb to listen on all interfaces for a connection -d - directs command to the only connected USB device returns an error if more than one USB device is present. -e - directs command to the only running emulator. returns an error if more than one emulator is running. -s - directs command to the device or emulator with the given serial number or qualifier. Overrides ANDROID_SERIAL environment variable. -p - simple product name like 'sooner', or a relative/absolute path to a product out directory like 'out/target/product/sooner'. If -p is not specified, the ANDROID_PRODUCT_OUT environment variable is used, which must be an absolute path. -H - Name of adb server host (default: localhost) -P - Port of adb server (default: 5037) devices [-l] - list all connected devices ('-l' will also list device qualifiers) connect [:] - connect to a device via TCP/IP Port 5555 is used by default if no port number is specified. disconnect [[:]] - disconnect from a TCP/IP device. Port 5555 is used by default if no port number is specified. Using this command with no additional arguments will disconnect from all connected TCP/IP devices. device commands: adb push [-p] - copy file/dir to device ('-p' to display the transfer progress) adb pull [-p] [-a] [] - copy file/dir from device ('-p' to display the transfer progress) ('-a' means copy timestamp and mode) adb sync [ ] - copy host->device only if changed (-l means list but don't copy) (see 'adb help all') adb shell - run remote shell interactively adb shell - run remote shell command adb emu - run emulator console command adb logcat [ ] - View device log adb forward --list - list all forward socket connections. the format is a list of lines with the following format:"""""\n"adb forward - forward socket connections forward specs are one of: tcp: localabstract: localreserved: localfilesystem: dev: jdwp: (remote only) adb forward --no-rebind - same as 'adb forward ' but fails if is already forwarded adb forward --remove - remove a specific forward socket connection adb forward --remove-all - remove all forward socket connections adb jdwp - list PIDs of processes hosting a JDWP transport adb install [-l] [-r] [-d] [-s] [--algo --key --iv ] - push this package file to the device and install it ('-l' means forward-lock the app) ('-r' means reinstall the app, keeping its data) ('-d' means allow version code downgrade) ('-s' means install on SD card instead of internal storage) ('--algo', '--key', and '--iv' mean the file is encrypted already) adb uninstall [-k] - remove this app package from the device ('-k' means keep the data and cache directories) adb bugreport - return all information from the device that should be included in a bug report. adb backup [-f ] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared] [-all] [-system|-nosystem] [] - write an archive of the device's data to . If no -f option is supplied then the data is written to"backup.ab"in the current directory. (-apk|-noapk enable/disable backup of the .apks themselves in the archive; the default is noapk.) (-obb|-noobb enable/disable backup of any installed apk expansion (aka .obb) files associated with each application; the default is noobb.) (-shared|-noshared enable/disable backup of the device's shared storage / SD card contents; the default is noshared.) (-all means to back up all installed applications) (-system|-nosystem toggles whether -all automatically includes system applications; the default is to include system apps) ( is the list of applications to be backed up. If the -all or -shared flags are passed, then the package list is optional. Applications explicitly given on the command line will be included even if -nosystem would ordinarily cause them to be omitted.) adb restore - restore device contents from the backup archive adb help - show this help message adb version - show version num scripting: adb wait-for-device - block until device is online adb start-server - ensure that there is a server running adb kill-server - kill the server if it is running adb get-state - prints: offline | bootloader | device adb get-serialno - prints: adb get-devpath - prints: adb status-window - continuously print device status for a specified device adb remount - remounts the /system partition on the device read-write adb reboot [bootloader|recovery] - reboots the device, optionally into the bootloader or recovery program adb reboot-bootloader - reboots the device into the bootloader adb root - restarts the adbd daemon with root permissions adb usb - restarts the adbd daemon listening on USB adb tcpip - restarts the adbd daemon listening on TCP on the specified port networking: adb ppp [parameters] - Run PPP over USB. Note: you should not automatically start a PPP connection. refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1 [parameters] - Eg. defaultroute debug dump local notty usepeerdns adb sync notes: adb sync [ ] can be interpreted in several ways: - If is not specified, both /system and /data partitions will be updated. - If it is"system"or"data", only the corresponding partition is updated. environmental variables: ADB_TRACE - Print debug information. A comma separated list of the following values 1 or all, adb, sockets, packets, rwx, usb, sync, sysdeps, transport, jdwp ANDROID_SERIAL - The serial number to connect to. -s takes priority over this if given. ANDROID_LOG_TAGS - When used with the logcat option, only these debug tags are printed. 编译 Android8.1 固件准备工作

编译 Android 对机器的配置要求较高:

64 位 CPU

16GB 物理内存+交换内存

100GB 空闲的磁盘空间用于构建,源码树另外占用大约 25GB

官方推荐 Ubuntu 14.04 操作系统,经测试,Ubuntu 12.04 也可以编译运行成功,只需要满足 http://source.android.com/source/building.html 里的软硬件配置即可。编译环境的初始化可参考 http://source.android.com/source/initializing.html 。

安装 OpenJDK 8:

sudo apt-get install openjdk-8-jdk

提示:安装 openjdk-8-jdk,会更改 JDK 的默认链接,这时可用:

$ sudo update-alternatives --config java $ sudo update-alternatives --config javac

来切换 JDK 版本。SDK 在找不到操作系统默认 JDK 的时候会使用内部设定的 JDK 路径,因此,为了让同一台机器可以编译 Android 5.1 及之前的版本,去掉链接更方便:

$ sudo /var/lib/dpkg/info/openjdk-8-jdk:amd64.prerm remove

Ubuntu 12.04 软件包安装:

sudo apt-get install git gnupg flex bison gperf build-essential \ zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \ libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \ g++-multilib mingw32 tofrodos gcc-multilib ia32-libs \ python-markdown libxml2-utils xsltproc zlib1g-dev:i386 \ lzop libssl1.0.0 libssl-dev

Ubuntu 14.04 软件包安装:

sudo apt-get install git-core gnupg flex bison gperf libsdl1.2-dev \ libesd0-dev libwxgtk2.8-dev squashfs-tools build-essential zip curl \ libncurses5-dev zlib1g-dev pngcrush schedtool libxml2 libxml2-utils \ xsltproc lzop libc6-dev schedtool g++-multilib lib32z1-dev lib32ncurses5-dev \ lib32readline-gplv2-dev gcc-multilib libswitch-perl \ libssl1.0.0 libssl-dev 下载 Android 8.1 SDK

Android SDK 源码包比较大,可以通过如下方式获取Android8.1源码包:

下载

[下载SDK]完成后先验证一下 MD5 码:

$ md5sum /path/to/rk3399pro_firefly_aiojd4_android8.1_20190430.7z.001 $ md5sum /path/to/rk3399pro_firefly_aiojd4_android8.1_20190430.7z.002 $ md5sum /path/to/rk3399pro_firefly_aiojd4_android8.1_20190430.7z.003 70dd51416594d36e140d2eef0738e270 rk3399pro_firefly_aiojd4_android8.1_20190430.7z.001 ac8234b94df1b812afd6a4c8c42976cb rk3399pro_firefly_aiojd4_android8.1_20190430.7z.002 68b2da1653aed2d9d80871d7ad21272d rk3399pro_firefly_aiojd4_android8.1_20190430.7z.003

确认无误后,就可以解压:

cd ~/proj/ 7z x ./rk3399pro_firefly_aiojd4_android8.1_20190430.7z.001 -oAIO-RK3399ProJD4 cd ./AIO-RK3399proJD4 git reset --hard

更新

以下为从 gitlab 处更新的方法:

#1. 进入SDK根目录 cd ~/proj/AIO-RK3399ProJD4 #2. 下载远程bundle仓库 git clone https://gitlab.com/TeeFirefly/rk3399pro-oreo-bundle.git .bundle #3. 若下载仓库失败,则可以从下方百度云下载[bundle压缩包]并解压到SDK根目录,解压指令如下: 7z x rk3399pro-oreo-bundle.7z -r -o. && mv rk3399pro-oreo-bundle/ .bundle/ #4. 更新SDK,并且后续更新不需要再次拉取远程仓库,直接执行以下命令即可 .bundle/update #5. 按照提示已经更新内容到 FETCH_HEAD,同步FETCH_HEAD到firefly分支 git rebase FETCH_HEAD

百度云下载[bundle压缩包]

AIO-RK3399ProJD4产品编译方法HDMI显示编译./FFTools/make.sh -d rk3399pro-firefly-aiojd4 -j8 -l rk3399pro_firefly_aiojd4-userdebug ./FFTools/mkupdate/mkupdate.sh -l rk3399pro_firefly_aiojd4-userdebug 手动编译AIO-3399ProJD4

编译前执行如下命令配置环境变量:

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar

编译kernel:

cd ~/proj/AIO-RK3399ProJD4/kernel/ make ARCH=arm64 firefly_defconfig make -j8 ARCH=arm64 rk3399pro-firefly-aiojd4.img

编译uboot:

cd ~/proj/AIO-RK3399ProJD4/u-boot/ ./make.sh rk3399pro

编译android:

cd ~/proj/AIO-RK3399ProJD4/ source build/envsetup.sh lunch rk3399pro_firefly_aioJD4-userdebug make -j8 ./mkimage.sh 打包成统一固件 update.img

编译完可以用Firefly官方的脚本打包成统一固件,执行如下命令:

./FFTools/mkupdate/mkupdate.sh update

打包完成后将在rockdev/Image-rk3399pro_firefly_aiojd4/下生成统一固件:update.img

在 Windows 下打包统一固件 update.img 也很简单,将编译生成的文件拷贝到 AndroidTool 的 rockdev\Image 目录中,然后运行 rockdev 目录下的 mkupdate.bat 批处理文件即可创建 update.img 并存放到 rockdev\Image 目录里。

烧写分区映像

编译的时候执行 ./mkimage.sh 会重新打包 boot.img 和 system.img, 并将其它相关的映像文件拷贝到目录 rockdev/Image-rk3399pro_firefly_aiojd4/ 中。以下列出一般固件用到的映像文件:

boot.img :Android 的初始文件映像,负责初始化并加载 system 分区。

kernel.img :内核映像。

misc.img :misc 分区映像,负责启动模式切换和急救模式的参数传递。

parameter.txt :emmc的分区信息

recovery.img :急救模式映像。

resource.img :资源映像,内含开机图片和内核的设备树信息。

system.img :Android 的 system 分区映像,ext4 文件系统格式。

trust.img :休眠唤醒相关的文件

MiniLoaderAll.bin :Loader文件

uboot.img :uboot文件

oem.img :预置媒体资源及数据包

vendor.img :产品标识和驱动

请参照 如何升级固件 一文来烧写分区映像文件。

如果使用的是 Windows 系统,将上述映像文件拷贝到 AndroidTool (Windows 下的固件升级工具)的 rockdev\Image 目录中,之后参照升级文档烧写分区映像即可,这样的好处是使用默认配置即可,不用修改文件的路径。

update.img 方便固件的发布,供终端用户升级系统使用。一般开发时使用分区映像比较方便。

定制 Android 固件前言

定制 Android 固件,有两种方法:

改源码,然后编译生成固件。

在现有固件的基础上进行裁剪。

前一种方法,可以从各个层面去定制 Android,自由度大,但对编译环境和技术要求比较高,参见《编译 Android8.1 固件》一文。现在介绍后一种方法,分为解包、定制和打包三个阶段。主机操作系统为 Linux,采用的工具为开源软件。

固件格式

统一固件 release_update.img,内含启动加载器 loader.img 和真正的固件数据 update.img

release_update.img |- loader.img `- update.img

update.img 是个复合文件,内含多个文件,由 package-file 描述。一个典型的 package-file 为:

# NAME Relative path package-file package-file bootloader Image/MiniLoaderAll.bin parameter Image/parameter.txt trust Image/trust.img uboot Image/uboot.img misc Image/misc.img resource Image/resource.img kernel Image/kernel.img boot Image/boot.img recovery Image/recovery.img system Image/system.img backup RESERVED #update-script update-script #recover-script recover-script

package-file

update.img 的打包说明文件,update.img 里也含有一份 package-file。

Image/MiniLoaderAll.bin

启动加载器,即 bootloader。

Image/parameter.txt

参数文件,可以设定内核启动参数,里面有重要的分区信息。

Image/trust.img,trust.img 是U-Boot作为二级loader 的打包。

Image/misc.img

misc 分区的映像,用来控制 Android 是正常启动,还是进入急救模式(Recovery Mode)。

Image/kernel.img

Android 内核。

Image/resource.img

资源映像,内有内核开机图片和内核设备树信息(Device Tree Blob)。

Image/boot.img

Android 内核的内存启动盘(initrd),是内核启动后最先加载的根文件系统,包含重要的初始化动作,一般不需要改动。

Image/recovery.img

Android 急救模式的映像,内含内核和急救模式的根文件系统。

Image/system.img

对应于 Android 的 /system 分区,是以下的定制对象。

解包,就是提取 release_update.img 里的 update.img, 然后解压出内含 package-file 所声明的多个文件。打包,则是个逆过程,将 package-file 将所列的多个文件合成 update.img,加进 loader.img,最终生成 release_update.img 。

工具准备git clone https://github.com/TeeFirefly/rk2918_tools.git cd rk2918_tools make sudo cp afptool img_unpack img_maker mkkrnlimg /usr/local/bin 解包

解压 release_update.img

$ cd /path/to/your/firmware/dir $ img_unpack AIO-3399ProJD4_Android8.1.0_HDMI_190509.img img rom version: 6.0.1 build time: 2016-10-27 14:58:18 chip: 33333043 checking md5sum....OK

解压 update.img

$ cd img $ afptool -unpack update.img update Check file...OK ------- UNPACK ------- package-file 0x00000800 0x000002AC Image/MiniLoaderAll.bin 0x00001000 0x0004394E Image/parameter.txt 0x00045000 0x00000368 Image/trust.img 0x00045800 0x00400000 Image/uboot.img 0x00445800 0x00400000 Image/misc.img 0x00845800 0x0000C000 Image/resource.img 0x00851800 0x00038800 Image/kernel.img 0x0088A000 0x012D2014 Image/boot.img 0x01B5C800 0x0017893C Image/recovery.img 0x01CD5800 0x00866B8C Image/system.img 0x0253C800 0x41A9110C Image/vendor.img 0x43FCE000 0x1206E0A0 Image/oem.img 0x5603C800 0x00058094 RESERVED 0x00000000 0x00000000 UnPack OK!

查看 update 目录下的文件树

$ cd update/ $ tree . ├── Image │ ├── boot.img │ ├── kernel.img │ ├── MiniLoaderAll.bin │ ├── misc.img │ ├── oem.img │ ├── parameter.txt │ ├── recovery.img │ ├── resource.img │ ├── system.img │ ├── trust.img │ ├── uboot.img │ └── vendor.img ├── loader.img ├── package-file └── RESERVED 1 directory, 15 files

这样,固件就解包成功了,下面就开始定制吧。

打包

首先要检查一下 system.img 的大小,对照 parameter 文件的分区情况(可参考文档Parameter 文件格式,作必要的大小调整。例如,parameter.txt 文件里的 system 分区大小,可以找到 CMDLINE 一行,然后找到 system 字符串:

0x00200000@0x000B0000(system)

@ 前面就是分区的大小,单位是 512 字节,这样该 system 分区的大小就是:

$ echo $(( 0x00200000 * 512 / 1024 / 1024))M 1024M

只要 system.img 的大小不超过 1024M,parameter 文件就不用更改。如果分区不用更改,可以直接用烧写工具将新的 system.img 烧写到开发板的 system 分区上做试验。否则,需要制作新固件并烧写后再行测试。以下是打包成统一固件 update.img 所需要的步骤:

合成 update.img :

# 当前的目录仍然为 update/ ,内有 package-file, package-file 所列的文件均存在 # 将参数文件拷贝一份到 paramter, 因为 afptool 默认要用到 $ cp Image/parameter.txt parameter $ afptool -pack . ../update_new.img ------ PACKAGE ------ Add file: ./package-file Add file: ./Image/MiniLoaderAll.bin Add file: ./Image/parameter.txt Add file: ./Image/trust.img Add file: ./Image/uboot.img Add file: ./Image/misc.img Add file: ./Image/resource.img Add file: ./Image/kernel.img Add file: ./Image/boot.img Add file: ./Image/recovery.img Add file: ./Image/system.img Add file: ./Image/vendor.img Add file: ./Image/oem.img Add file: ./RESERVED Add CRC... ------ OK ------ Pack OK!

合成 release_update.img :

$ img_maker -rk33 loader.img update_new.img release_update_new.img generate image... append md5sum... success!

release_update_new.img 即为最终生成的可烧写的统一固件文件。

常见问题固件的版本在哪设置

在 parameter 文件中找到下行并修改即可,注意版本号为数字,中间两个点号不能省略。

FIRMWARE_VER: 8.1 .dfma { position: relative; width: 1000px; margin: 0 auto; } .dfma a::after { position: absolute; left: 0; bottom: 0; width: 30px; line-height: 1.4; text-align: center; background-color: rgba(0, 0, 0, .5); color: #fff; font-size: 12px; content:"广告"; } .dfma img { display: block; }
郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。