Firefly Ubuntu 使用手册 本使用手册适用与Firefly Ubuntu Desktop & Minimal 系统,部分与UI显示相 关的介绍,只针对Desktop系统。 强烈建议使用Ubuntu 18.04, 如使用其它版本系统,本文档可能部分章节不能完 全适用。 《创建 Ubuntu 根文件系统》 《编译 Ubuntu 固件(GPt)》 adb 使用 ADB Core-3399-JD4需要修改kernel/arch/arm64/boot/dts/rockchip/rk3399 -firefly-aiojd4.dts相关dts将usbdrd_dwc3_0设置为peripheral模式,之后该 usb只能作为从设备使用。 &usbdrd_dwc3_0 { dr_mode = "peripheral"; }; 重新编译和烧写Kernel Core-3399-JD4用双公头USB数据线连接设备usb3.0接口和PC主机; adb devices adb shell 网络ADB 查看开发板 IP 地址,PC 端通过网络访问: adb connect + IP adb shell 安装linux-headers和linux-image DEBIAN包下载链接: 链接: https://pan.baidu.com/s/1HH_1M1QqdQQAVIXp3NnPvw 取码:ddd6 安装头文件 sudo dpkg -i linux-headers-4.4.194+_4.4.194+-5_arm64.deb sudo dpkg -i linux-image-4.4.194+_4.4.194+-5_arm64.deb cd /usr/src/linux-headers-4.4.194+ make headers_check make headers_install #make scripts 可能会出错但是不要紧 make scripts Qt交叉编译环境支持 Firefly发布的Qt交叉编译工具链,适用于以下环境: Host: x86-64 / Ubuntu 18.04 Target: Firefly RK3399 RK3328 PX30 / Ubuntu 18.04 Minimal&Desktop 工具链完整支持wenEngine, 支持EGLFS LinuxFB XCB 等backend. 下载地址 链接:https://pan.baidu.com/s/1tNGqG4XSYuDxe_AdDegOAA 提取码:FFQT 部署 详情参见Qt5.12.2_Release.md 注意,文档中所有路径的名称不可更改,否则会导致编译或者运行出错。 编译 在host端,进入Qt工程目录,qmake && make 即可. 运行 工具链中提供了两个测试Demo,分别对应EGLFS和LinuxFB Backend,用户在部署 完成后,可以在host端build demo,在tartget端运行demo以测试部署是否成功 。 更换设备开机和桌面LOGO 开机的LOGO 开机LOGO是存放在SDK/kernel里面的,修改完之后重新编译kernel linux-sdk/kenel/logo.bmp 桌面的LOGO 更换后重启系统即可 /usr/share/lubuntu/ ├── images │   └── lubuntu-ff-logo.png #桌面左上角的小图标 └── wallpapers └── firefly-default-wallpaper.png #桌面壁纸 创建WIFI热点 硬件要求: 需要有无线网卡,且支持移动热点功能 点击桌面右上角"Ethernet Network"图标,选择"Edit Connection..." 选择"+"图标,Add a new connection 选择"Wi-Fi",后点击"Create" Wi-Fi设置: 设置SSID Mode:选择Hotspot Device: 选择无线网卡(wlan) 选择适当的加密方式: 点击"Save" 即刻完成热点创建 设置静态IP (使用netplan) 使用netplan设置静态IP addresses gateway4:设置网关 nameservers: DNS nameservers ethernets: 以太网配置项 wifis: wifi配置项 root@firefly:~# vim /etc/netplan/netplan.yaml root@firefly:~# netplan apply netplan的内容如下: network: ethernets: eth0: addresses: [168.168.4.3/24] gateway4: 168.168.0.1 dhcp4: yes optional: true wifis: wlan0: addresses: [168.168.4.23/24] gateway4: 168.168.0.1 dhcp4: yes dhcp6: no access-points: "ssid": password: "password" version: 2 or network: ethernets: eth0: addresses: [168.168.4.3/24] gateway4: 168.168.0.1 dhcp4: no optional: true nameservers: addresses: [202.96.128.166] wifis: wlan0: addresses: [168.168.4.23/24] gateway4: 168.168.0.1 dhcp4: no dhcp6: no access-points: "ssid": password: "password" version: 2 netplan更多配置示例: https://netplan.io/examples USB 以太网 USB 以太网,主要实现的是将设备的 OTG 接口做外设模式,模拟成一个网络接 口,然后主机通过 USB 连接设备并通过设备访问互联网。以下是基于 Firefly- RK3399 设备进行的具体操作。 操作环境: Ubuntu 系统的 PC 机 Firefly-RK3399 设备 内核设置 在内核目录下,打开内核配置选项菜单: make firefly_linux_defconfig make menuconfig 进入内核配置菜单后依次选择:"Device Drivers" -> "USB Support" -> "USB Gadget Support"。 将 "USB Gadget Driver" 设置成编译成模块,然后可以在下边找到 "Ethernet Gadget (with CDC Ethernet support)" 选项,同样选择编译成模块。同时要选 择上 "RNDIS support"。 USB Gadget Drivers USB functions configurable through configfs Ethernet Gadget (with CDC Ethernet support) [*] RNDIS support (NEW) 接着在 "kernel" 目录下编译内核: make rk3399-firefly.img -j12 编译完成后将内核烧录到设备中,烧录过程请参考维基教程: 升级固件 中的分区镜像烧写部分。然后将内核目录下生成的下列模块复制到设备中: drivers/usb/gadget/function/u_ether.ko drivers/usb/gadget/function/usb_f_ecm_subset.ko drivers/usb/gadget/function/usb_f_ecm.ko drivers/usb/gadget/function/usb_f_rndis.ko drivers/usb/gadget/function/usb_f_eem.ko drivers/usb/gadget/legacy/g_ether.ko drivers/usb/gadget/libcomposite.ko 然后在设备上,依次加载上述模块: insmod libcomposite.ko insmod u_ether.ko insmod usb_f_ecm_subset.ko insmod usb_f_rndis.ko insmod usb_f_ecm.ko insmod usb_f_eem.ko insmod g_ether.ko 注意: 要先加载 "libcomposite.ko" 和 "u_ether.ko",后面的模块才可以加载进去 。 IP 地址设置 用数据线连接 PC 机和设备的 OTG 接口,在 PC 机中执行 "lsusb" 命令可以查 看到 USB 以太网设备,即说明连接成功。 firefly@Desktop:~$ lsusb Bus 002 Device 003: ID 09da:5814 A4Tech Co., Ltd. Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 005: ID 04f2:b2ea Chicony Electronics Co., Ltd Integrated Camera [ThinkPad] Bus 001 Device 004: ID 0a5c:21e6 Broadcom Corp. BCM20702 Bluetooth 4.0 [ThinkPad] Bus 001 Device 003: ID 147e:1002 Upek Biometric Touchchip/Touchstrip Fingerprint Sensor Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 003 Device 003: ID 0525:a4a2 Netchip Technology, Inc. Linux-USB Ethernet/RNDIS Gadget Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub 输出信息中 ID 0525:a4a2 Netchip Technology, Inc. Linux-USB Ethernet/RNDIS Gadget 即为 USB 网卡设备。 设备插入网线,使设备可以连接外网。 在设备中 IP 的设置: 输入执行 "ifconfig -a" 命令,可以查看到以下信息: root@firefly:~# ifconfig -a # eth0 是有线网卡 eth0: flags=4163 mtu 1500 inet 168.168.100.48 netmask 255.255.0.0 broadcast 168.168.255.255 inet6 fe80::1351:ae2f:442e:e436 prefixlen 64 scopeid 0x20 ether 8a:4f:c3:77:94:ac txqueuelen 1000 (Ethernet) RX packets 9759 bytes 897943 (897.9 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 236 bytes 35172 (35.1 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 42 base 0x8000 ... # usb0 是虚拟的 usb 网卡 usb0: flags=4098 mtu 1500 ether 4a:81:b1:34:d2:ad txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 然后给 usb0 网卡自定义一个适当的 IP: 注意要设置 usb0 的 IP 和有线网卡 eth0 的 IP 不在同一网段!! ifconfig usb0 192.168.1.101 在 PC 机中 IP 的设置: # 先查看 USB 虚拟网卡 firefly@Desktop:~$ ifconfig enp0s20u2i1: flags=4163 mtu 1500 inet 192.168.2.90 netmask 255.255.255.0 broadcast 192.168.2.255 inet6 fe80::871c:b87e:1327:7fd4 prefixlen 64 scopeid 0x20 ether 46:fe:6e:97:ee:a6 txqueuelen 1000 (以太网) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1 bytes 54 (54.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ... # 设置 USB 网卡的 IP 地址和设备的 usb0 的 IP 地址在同一网段 firefly@Desktop:~$ sudo ifconfig enp0s20u2i1 192.168.1.100 #设置默认网关:要设置为设备 usb0 的 ip 地址,因为后面要通过 usb0 来进行流量的转发 firefly@Desktop:~$ sudo route add default gw 192.168.1.101 设置完设备和 PC 机的 IP 后,互相是可以 ping 通的,PC 机也可以用 "ssh" 命令登录到设备。 网络共享实现 PC 机上网 在设备上:首先打开 IPv4 的转发功能: echo 1 > /proc/sys/net/ipv4/ip_forward 如果希望每次重启设备后都自动打开转发功能,请直接修改 "/etc/sysctl.conf" 文件的 "net.ipv4.ip_forward" 值为1。修改文件参数后 要执行 "sysctl -p" 命令重新载入 "/etc/sysctl.conf" 文件,使 IPv4 转发 功能生效。 添加规则进行流量转发: iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j SNAT --to-source 168.168.100.48 现在 PC 主机就可以访问网络了。如果 PC 机可以 ping 通设备的 usb0 和 eth0,但是无法上外网,则需要修改 PC 机的 DNS,在 "/etc/resolv.conf" 中 做以下添加: nameserver 8.8.8.8 nameserver 8.8.4.4 配置过程中要注意以下几点: 对应好上述步骤中自己设备上的各个 IP 地址,注意设备上的 USB 虚拟网卡 IP 和有线网络 IP 不在同一网段; PC 机虚拟 USB 网卡的网关要设置为设备虚拟 USB 网卡的 IP 地址; 设备上的虚拟网卡 IP 地址、IP 转发功能、流量转发规则等设置会在设备重启 后恢复,用户可以自行查找资料如何开机自动设置这些配置。 导出设备系统 此章节适用于: 当用户已经在一台设备上完成工作环境的部署,需要将当前环境 完整导出,以批量部署到其它同平台设备上。用户也可以通过导出设备文件系统 来备份当前的开发环境。 《导出设备系统》 屏幕旋转 Firefly Ubuntu Desktop 使用ff_rotate脚本来控制屏幕旋转: ff_rotate root@firefly:~# ff_rotate rotate screen and touchscreen run as root ff_rotate orientation: left, right, normal, inverted #图像输出翻转 root@firefly:~# ff_rotate inverted 显示版本信息 ffgo 通过Firefly 提供的ffgo命令可以方便的查看固件信息,便于开发者调试以及定 位问题。 当用户需要向Firefly反馈信息时,需要附上ffgo version显示的版本信息。 root@firefly:~# ffgo Usage: ffgo : show this usage ffgo update: update ffgo ffgo version: get version ffgo cmdlist: get support cmd list ffgo [cmd]: run cmd in cmd list root@firefly:~# ffgo update update success root@firefly:~# ffgo version OS: Ubuntu 18.04.4 LTS MODEL: Firefly-RK3399 Board (Linux Opensource) FIREFLY: v2.03-1-g2ed565c DATE: 20200617-1042 KERNEL: Linux version 4.4.194-59119-g968ba5005831 (jincheng@jincheng-System-Product-Name) (local/firefly-linux/rk3399/firefly: 968ba5005831c5f69d68d95984451fd2a7c457c0) (gcc version 6.3.1 20170404 (Lina0 恢复出厂设置 Firefly Ubuntu 支持恢复出厂设置。 注意,此出厂设置表示恢复为设备最后一次升级固件之后的初始状态 root@firefly:~# recovery Usage: update