有用的连接:

Rockchip官方资料:

http://opensource.rock-chips.com/wiki_Main_Page

http://opensource.rock-chips.com/wiki_RK3399

http://opensource.rock-chips.com/wiki_Boot_option

http://opensource.rock-chips.com/wiki_U-Boot#Download_U-Boot

Firefly官方资料:

http://wiki.t-firefly.com/index.php/Firefly-RK3399

http://wiki.t-firefly.com/index.php/Firefly-RK3399/Flash_image

SDK

https://gitlab.com/TeeFirefly/FireNow-Nougat

https://gitlab.com/TeeFirefly/FireNow-Marshmallow

1、烧写工具

这里用到的主要是upgrade_tool,在按住recovery键开机会进入下载模式,此时运行这个工具,然后选择板子对应的设备号,就会进入命令行:

$sudo upgrade_tool
List of rockusb connected
DevNo= Vid=0x2207,Pid=0x330c,LocationID= Loader
Found rockusb,Select input DevNo,Rescan press <R>,Quit press <Q>: ---------------------Tool Usage ---------------------
Help: H
Quit: Q
Version: V
Clear Screen: CS
------------------Upgrade Command ------------------
ChooseDevice: CD
SwitchDevice: SD
UpgradeFirmware: UF <Firmware>
UpgradeLoader: UL <Loader>
DownloadImage: DI <-p|-b|-k|-s|-r|-m image> [parameter file]
DownloadBoot: DB <Loader>
EraseFlash: EF <Loader|firmware>
LowerFormat: LF
----------------Professional Command -----------------
TestDevice: TD
ResetDevice: RD [subcode]
ResetPipe: RP [pipe]
ReadFlashID: RID
ReadFlashInfo: RFI
ReadChipInfo: RCI
ReadSector: RS <BeginSec> <SectorLen> [-decode] [File]
WriteSector: WS <BeginSec> <File>
ReadLBA: RL <BeginSec> <SectorLen> [File]
WriteLBA: WL <BeginSec> <File>
EraseBlock: EB <CS> <BeginBlock> <BlokcLen> [--Force]
------------------------------------------------------- Rockusb>

我们可以利用这个工具完成很多操作。

这个工具的下载地址:  百度云Linux_Upgrade_Tool_v1.24.zip

帮助手册: upgrade_tool帮助手册.pdf

2、使用upgrade_tool烧写uboot.img

阅读wiki:http://wiki.t-firefly.com/index.php/Firefly-RK3399/Flash_image 可以知道各个镜像在emmc中对应的地址:

从这里可以看到uboot被烧写到了emmc的0x2000处。

烧写方法1:

进入upgrade_tool的命令行模式,执行:

Rockusb>WL 0x2000 uboot.img

烧写方法2:

直接执行:

sudo upgrade_tool wl 0x2000 ./uboot.img

其中wl也可以写成WL

用upgrade_tool烧写其他分区的镜像的命令如下:

烧写统一固件 update.img:
sudo upgrade_tool uf update.img 烧写分区镜像:
sudo upgrade_tool di -b /path/to/boot.img
sudo upgrade_tool di -k /path/to/kernel.img
sudo upgrade_tool di -s /path/to/system.img
sudo upgrade_tool di -r /path/to/recovery.img
sudo upgrade_tool di -m /path/to/misc.img
sudo upgrade_tool di resource /path/to/resource.img
sudo upgrade_tool di -p paramater #烧写 parameter
sudo upgrade_tool ul bootloader.bin # 烧写 bootloader
sudo upgrade_tool di trust /path/to/trust.img #烧写 trust

di参数的格式: di <分区名称/缩写> <对应的镜像文件的路径信息>,具体分区的名字可以查看parameter.txt文件,比如上面用upgrade_tool烧写uboot也可以用:

sudo upgrate_tool di uboot /path/to/uboot.img

从parameter.txt中可以得到如下emmc的分区:

mtdparts=rk29xxnand:0x00002000@0x00002000(uboot),0x00002000@0x00004000(trust),0x00002000@0x00006000(misc),0x00008000@0x00008000(resource),0x0000C000@0x00010000(kernel),0x00010000@0x0001C000(boot),0x00010000@0x0002C000(recovery),0x00038000@0x0003C000(backup),0x00040000@0x00074000(cache),0x00300000@0x000B4000(system),0x00008000@0x003B4000(metadata),0x00002000@0x003BC000(baseparamer),-@0x003BE000(userdata)

uboot:对应的是uboot.img

trust:对应的是trust.img, 其中含有ATF以及休眠唤醒相关的文件

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

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

kernel: 内核映像,对应的是kernel.img

boot: Android 的初始文件映像,即ramdisk,负责初始化并加载 system 分区,对应的是boot.img

recovery:急救模式映像,对应的是recovery.img

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

3、在maskrom模式也可以使用upgrade_tool

4、audit2allow的使用

在kernel log里可以看到很多avc的log:

[  143.450213] type= audit(1358499630.406:): avc: denied { read open } for pid= comm="vm" path="/system/bin/sh" dev="mmcblk1p10" ino= scontext=u:r:sudaemon:s0 tcontext=u:object_r:shell_exec:s0 tclass=file permissive=
[ 143.450484] type= audit(1358499630.406:): avc: denied { execute_no_trans } for pid= comm="vm" path="/system/bin/sh" dev="mmcblk1p10" ino= scontext=u:r:sudaemon:s0 tcontext=u:object_r:shell_exec:s0 tclass=file permissive=
[ 143.450738] type= audit(1358499630.410:): avc: denied { getattr } for pid= comm="sh" path="/system/bin/sh" dev="mmcblk1p10" ino= scontext=u:r:sudaemon:s0 tcontext=u:object_r:shell_exec:s0 tclass=file permissive=
[ 143.462718] type= audit(1358499630.423:): avc: denied { getattr } for pid= comm="sh" path="/dev/pts/0" dev="devpts" ino= scontext=u:r:sudaemon:s0 tcontext=u:object_r:devpts:s0 tclass=chr_file permissive=
[ 143.463075] type= audit(1358499630.423:): avc: denied { ioctl } for pid= comm="sh" path="/dev/pts/0" dev="devpts" ino= ioctlcmd= scontext=u:r:sudaemon:s0 tcontext=u:object_r:devpts:s0 tclass=chr_file permissive=

可以用下面的办法将上面的这些语句转换为类似下面的selinux的语法:

allow adbd graphics_device:dir { search };
allow adbd surfaceflinger:fifo_file rw_file_perms;

首先将要转换的avc信息保存到一个临时文件中,比如tmp.txt

然后用adb pull将板子上的sepolicy文件拷贝出来:adb pull /sepolicy

设置环境变量ANDROID_BUILD_TOP为Android源码的路径:export ANDROID_BUILD_TOP=/home/pengdonglin/disk_ext/Firefly/RK3399/sdk_7_1_1

然后Android源码中提供的audit2allow工具进行转换:./external/selinux/prebuilts/bin/audit2allow -p ~/logcat/rk3399/selinux/sepolicy -i ~/logcat/rk3399/selinux/tmp.txt

5、fastboot的使用

参考:http://opensource.rock-chips.com/wiki_Fastboot

使用方法:

Rockchip use 0x2207 as its USB vendor ID. This VID is not in Google's original fastboot code. So every fastboot command have to use "-i" parameter to specify vid to fastboot.
To list all the Rockchip devices attached to your USB port in fastboot mode.

进入fastboot:

adb reboot fastboot

在uboot的log中可以看到:

#Boot ver: --#1.06
empty serial no.
reboot normal.

查看:

fastboot -i 0x2207 devices
0123456789    fastboot

6、用命令进入下载模式

在Android系统下进入:

adb reboot bootloader

在fastboot模式下进入:

fastboot reboot-bootloader

可以在uboot的log中看到:

#Boot ver: --#1.06
empty serial no.
reboot rockusb.

此时我们可以适用upgrade_tool进行镜像的烧写等等。

7、unlock设备

在fastboot模式下执行下面的命令:

先执行 fastboot -i 0x2207 oem unlock

然后在5s内执行 fastboot -i 0x2207  oem unlock_accept

8、使用fastboot启动内核

在进行开发时,为了延长flash的寿命,每次改完内核后,没有必要每次都烧进emmc。fastboot提供了boot命令。

默认的uboot已经支持fastboot了,但是在用fastboot boot启动新的kernel时提示如下错误:

creating boot image...
creating boot image - 18911232 bytes
downloading 'boot.img'...
FAILED (remote: not support "-u" option)
finished. total time: 0.000s
通过分析uboot代码发现,fastboot每次只能接受16MB的数据,而我们的kernel.img为19MB,所以需要修改uboot代码:

diff --git a/u-boot/include/configs/rk_default_config.h b/u-boot/include/configs/rk_default_config.h
index d408d05..849b8ca
--- a/u-boot/include/configs/rk_default_config.h
+++ b/u-boot/include/configs/rk_default_config.h
@@ -, +, @@
* CONFIG_FASTBOOT_TRANSFER_BUFFER_SIZE should be larger than our boot/recovery image size.
*/
#define CONFIG_FASTBOOT_TRANSFER_BUFFER_SIZE CONFIG_RK_BOOT_BUFFER_SIZE
-#define CONFIG_FASTBOOT_TRANSFER_BUFFER_SIZE_EACH (CONFIG_FASTBOOT_TRANSFER_BUFFER_SIZE >> 1)
+#define CONFIG_FASTBOOT_TRANSFER_BUFFER_SIZE_EACH (CONFIG_FASTBOOT_TRANSFER_BUFFER_SIZE)

从新编译uboot,将生成的uboot.img烧写到emmc中,重新启动。

然后用下面的命令:

adb reboot fastboot

fastboot -i 0x2207 boot /home/pengdonglin/disk_ext/Firefly/RK3399/sdk_7_1_1/kernel/kernel.img

==

Firefly-RK3399笔记的更多相关文章

  1. firefly rk3399 增加 HL-340 驱动(编译内核)

    前言:新下载了firefly rk3399 ubuntu固件16.04,但是发现没有HL-340 USB转串口的驱动,而机器人底盘驱动是HL-340的,所以一直提示无法找到设备驱动. 由于没有技术支持 ...

  2. 萤火虫系统(firefly) RK3399 python3 安装 tensorflow

    前言: 继续之前在RK3399上安装深度学习的一些环境,主要碰到的坑给大家分享一下,为了让大家少走弯路.这次是安装tensorflow,话不多说,直接开撸. --------------------- ...

  3. 萤火虫系统(firefly) RK3399 python3 安装 spicy

    最近一直在研究深度学习,公司里正好也有个项目是需要在RK3399的板子上跑人脸识别. 原本在linux_x86系统上轻轻松松装的环境到了RK3399板子上(firefly系统)安装起来真的非常麻烦,需 ...

  4. 九鼎RK3399笔记一:Linux平台手册

    @ 目录 一.git下载九鼎SDK 二.安装所需的软件包: 三.安装 kernel 及 u-boot 编译需要依赖的软件包 四.安装文件系统需要依赖的软件包 五.安装 Buildroot 编译需要依赖 ...

  5. ARM64编译工具链下载

    下面是自制的用于编译ARMv8指令的交叉编译工具链: 1.运行在PC上,支持SVE指令,不支持SVE ACLE,版本GCC9.2 https://pan.baidu.com/s/1_NnwajWCel ...

  6. [Firefly引擎][学习笔记三][已完结]所需模块封装

    原地址:http://www.9miao.com/question-15-54671.html 学习笔记一传送门学习笔记二传送门 学习笔记三导读:        笔记三主要就是各个模块的封装了,这里贴 ...

  7. [Firefly引擎][学习笔记二][已完结]卡牌游戏开发模型的设计

    源地址:http://bbs.9miao.com/thread-44603-1-1.html 在此补充一下Socket的验证机制:socket登陆验证.会采用session会话超时的机制做心跳接口验证 ...

  8. [Firefly引擎][学习笔记一][已完结]带用户验证的聊天室

    原地址:http://bbs.9miao.com/thread-44571-1-1.html 前言:早在群里看到大鸡蛋分享他们团队的Firefly引擎,但一直没有时间去仔细看看,恰好最近需要开发一个棋 ...

  9. [Firefly引擎][学习笔记四][已完结]服务器端与客户端的通讯

    原地址:http://www.9miao.com/question-15-54981.html 传送门:学习笔记一学习笔记二学习笔记三 前言:学习笔记三是模块封装,这个在持续开发中会不断更新, 因为写 ...

随机推荐

  1. 记JS一个错误,

    在定义变量时候,如果直接定义 var obj=null;那么,在转码时候,比如转为base64,此时或出现特殊的文字(也是汉字,只是很少见少用的文字,而且,出现的文字是根据你给obj赋值决定的,) 由 ...

  2. Python学习(十八)—— 数据库(三)

    转载自http://www.cnblogs.com/linhaifeng/articles/7356064.html 一.数据操作 1.插入数据INSERT 1. 插入完整数据(顺序插入) 语法一: ...

  3. python模块安装查看、包制作

    一. 模块安装 ubuntu : apt-get install python-pip redhat: yum install python-pip pip install 模块 pip instal ...

  4. YII框架增删改查常用语句

    //实例化db $db = new \yii\db\Query(); //插入 $db->createCommand()->insert('user', [ 'name' => 't ...

  5. springmvc基础使用配置

    前言 本案例是在idea编辑器下,maven管理项目的前提下. 步骤 1.新建maven项目 2.配置web.xml <?xml version="1.0" encoding ...

  6. 004 使用SpringMVC开发restful API二--编写用户详情

    一:编写用户详情服务 1.任务 @PathVariable隐射url片段到java方法的参数 在url声明中使用正则表达式 @JsonView控制json输出内容 二:@PathVariable 1. ...

  7. Python 获取计算机全名(fully qualified host name)

    Python 获取计算机全名(fully qualified host name) import socket socket.getfqdn() socket.gethostname()

  8. Visual Studio 2019及其注册码

    Visual Studio 2019 更快地进行代码编写.更智能地执行操作.使用同类最佳IDE 创建未来.     下载Visual Studio         使用从初始设计到最终部署的完整工具集 ...

  9. eclipse配置tomcat,让java web项目运行起来!

    做项目,搞开发.开发环境配置时第一步.只有环境搭好了,以后的事情才能顺利进行! 这不需求来了,负一屏项目有新功能需要添加,临时接手,要进行服务器前端开发.这个项目是以前后台java人员进行开发的.都是 ...

  10. BZOJ.2565.[国家集训队]最长双回文串(Manacher/回文树)

    BZOJ 洛谷 求给定串的最长双回文串. \(n\leq10^5\). Manacher: 记\(R_i\)表示以\(i\)位置为结尾的最长回文串长度,\(L_i\)表示以\(i\)开头的最长回文串长 ...