lyphotoes 发布的帖子
-
飞凌 OK113i-C 全志T113-i开发板 CAN 通信C代码测试
飞凌官方手册中关于CAN测试部分使用的是命令行进行的简单测试,实际开发过程中还是要使用C代码去操作CAN设备,本帖主要讲解怎么使用C代码对CAN设备进行读写的收发操作。
First of all ,先查看所有网卡信息,看看板上是否有CAN设备网络:
root@ok113i:/# ifconfig -a can0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 NOARP MTU:16 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:10 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) can1 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 NOARP MTU:16 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:10 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) Interrupt:1 eth0 Link encap:Ethernet HWaddr BA:E9:F2:1C:9D:87 inet addr:192.168.0.232 Bcast:0.0.0.0 Mask:255.255.255.0 inet6 addr: fe80::b8e9:f2ff:fe1c:9d87/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:421 errors:0 dropped:14 overruns:0 frame:0 TX packets:9 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:27272 (26.6 KiB) TX bytes:726 (726.0 B) Interrupt:39 ip6tnl0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 NOARP MTU:1452 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) sit0 Link encap:IPv6-in-IPv4 NOARP MTU:1480 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) wlan0 Link encap:Ethernet HWaddr 2C:C3:E6:67:4D:3B BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
1. CAN组网前的准备,设置CAN通信服务的通信速率。
使用如下命令分别设置CAN0和CAN1的通信速率:
root@ok113i:/home/forlinx# ip link set can0 up type can bitrate 500000 [ 4075.425084] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready root@ok113i:/home/forlinx# ip link set can1 up type can bitrate 500000 [ 4086.037967] IPv6: ADDRCONF(NETDEV_CHANGE): can1: link becomes ready
以上设置can0 和 can1 通信速率均为500kbps,这个速率值务必记住,所有接入组网的的can节点都是以这个速率通信。
2. 使用C语言写一个CAN通信的发送接收测试程序,主要验证CAN发送和接收数据是否正常。
#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <signal.h> #include <string.h> #include "can_apply.h" #define MASTR_CAN1_ID 0x100 #define MASTR_CAN2_ID 0x101 #define RX_MSG_NUM 16 #define MAX_BUF_LEN 64 typedef enum { CAN_1, CAN_2, CAN_RES }can_type; typedef struct{ int can_id; unsigned char can_dlc; unsigned char data[MAX_BUF_LEN]; }can_msg_t; static int bexit = 0; static int can0_sock,can1_sock; can_msg_t can_rx_msg[RX_MSG_NUM]; unsigned int can1_id = 0; unsigned int can2_id = 0; void signal_handler(int signo) { printf("signal %d(%s) received\n", signo, strsignal(signo)); bexit = 1; } int can_send_data(can_type type, unsigned char *buf, int len) { int i, j; int cnt; int sock; int ret = 0; struct can_frame frame; if(type == CAN_1) { sock = can0_sock; frame.can_id = can1_id; } else { sock = can1_sock; frame.can_id = can2_id; } for(i = 0; i < len; i += 8) { cnt = len - i; if(cnt > 8) frame.can_dlc = 8; else frame.can_dlc = cnt; for(j=0; j<frame.can_dlc; j++) { frame.data[j] = buf[i+j]; } if(can_send(sock, frame) < 0) { ret = -1; break; } } return ret; } void can_recv_data(int sock) { static unsigned char tail = 0; int i; int can_id; unsigned char can_dlc; unsigned char *data; struct can_frame frame; int index = can0_sock == sock ? 0 : 1; if(can_recv(sock, &frame) < 0) return ; can_id = frame.can_id; can_dlc = frame.can_dlc; data = frame.data; printf("CAN%d dlc = %d, can_id = %x\ndata:", index,frame.can_dlc, frame.can_id); for(i=0; i<frame.can_dlc; i++) printf("0x%02x ", frame.data[i]); printf("\n"); } void *can_proc_start(void *arg) { int nready; int maxfd; fd_set readfds; int sock = *(int *)arg; FD_ZERO(&readfds); FD_SET(sock, &readfds); maxfd = sock; while(!bexit) { nready = select(maxfd+1, &readfds, NULL, NULL, NULL); if(nready < 0) { perror("can select"); break; } else if(nready == 0) { continue; } /* data is ready */ if(FD_ISSET(sock, &readfds)) { can_recv_data(sock); } else { ; } } close(sock); pthread_detach(pthread_self()); pthread_exit(0); } // 初始化CAN0和CAN1设备,并创建两个接收数据处理线程 static void can_sock_init() { pthread_t tid; can0_sock = can_open("can0"); if(can0_sock < 0) return ; can1_sock = can_open("can1"); if(can1_sock < 0) return ; if (0 != pthread_create(&tid, NULL, can_proc_start, (void *)&can0_sock)) { return ; } if (0 != pthread_create(&tid, NULL, can_proc_start, (void *)&can1_sock)) { return ; } can1_id = MASTR_CAN1_ID; can2_id = MASTR_CAN2_ID; printf("can open sucess can0_sock:%d, can1_sock:%d\n", can0_sock, can1_sock); } int main(int argc, char *argv[]) { char *send_data = "hello,can!"; signal(SIGINT, signal_handler); signal(SIGPIPE, signal_handler); signal(SIGTERM, signal_handler); can_sock_init(); // 初始化CAN0和CAN1设备数据,并创建接收线程 do { sleep(1); can_send_data(CAN_1, (unsigned char *)send_data, strlen(send_data) - 1); } while (!bexit); return 0; }
测试程序主要实现了如下功能:
- 建立两个接收数据线程接收CAN设备的数据并打印CAN网络上的数据。
- 通过CAN0设备定时1秒发送一串"hello,can!"数据到CAN网络。
3. 运行并验证程序功能。
PC上使用CAN分析工具按下图接好线
打开CAN调试软件,配置成500kbps的速率并打开设备,如下:
使用CAN调试软件给设备发送数据,如下:
将编译好的程序上传到板子上并运行,以下是正常收到数据后程序的打印信息:
root@ok113i:/home/forlinx# ./can_test can open sucess can0_sock:3, can1_sock:4 ## PC往CAN0口发送测试数据接收打印 CAN0 dlc = 6, can_id = 201 data:0x30 0x31 0x32 0x33 0x34 0x55 CAN0 dlc = 6, can_id = 201 data:0x30 0x31 0x32 0x33 0x34 0x55 CAN0 dlc = 6, can_id = 201 data:0x30 0x31 0x32 0x33 0x34 0x55 CAN0 dlc = 6, can_id = 201 data:0x30 0x31 0x32 0x33 0x34 0x55 CAN0 dlc = 6, can_id = 201 data:0x30 0x31 0x32 0x33 0x34 0x55 CAN0 dlc = 6, can_id = 201 data:0x30 0x31 0x32 0x33 0x34 0x55 CAN0 dlc = 6, can_id = 201 data:0x30 0x31 0x32 0x33 0x34 0x55 CAN0 dlc = 6, can_id = 201 data:0x30 0x31 0x32 0x33 0x34 0x55 CAN0 dlc = 6, can_id = 201 data:0x30 0x31 0x32 0x33 0x34 0x55 ## PC往CAN1 口发送测试数据接收打印 CAN1 dlc = 6, can_id = 201 data:0x30 0x31 0x32 0x33 0x34 0x55 CAN1 dlc = 6, can_id = 201 data:0x30 0x31 0x32 0x33 0x34 0x55 CAN1 dlc = 6, can_id = 201 data:0x30 0x31 0x32 0x33 0x34 0x55 CAN1 dlc = 6, can_id = 201 data:0x30 0x31 0x32 0x33 0x34 0x55 CAN1 dlc = 6, can_id = 201 data:0x30 0x31 0x32 0x33 0x34 0x55 CAN1 dlc = 6, can_id = 201 data:0x30 0x31 0x32 0x33 0x34 0x55 CAN1 dlc = 6, can_id = 201 data:0x30 0x31 0x32 0x33 0x34 0x55 CAN1 dlc = 6, can_id = 201 data:0x30 0x31 0x32 0x33 0x34 0x55 CAN1 dlc = 6, can_id = 201 data:0x30 0x31 0x32 0x33 0x34 0x55 CAN1 dlc = 6, can_id = 201 data:0x30 0x31 0x32 0x33 0x34 0x55
测试程序工程结构
├── build # 编译目录 ├── can_apply.c # CAN 操作简单封装C源码 ├── can_apply.h # CAN 操作简单封装头文件 ├── CMakeLists.txt # cmake 编译规则文件 ├── cross-t113-i.cmake # CMake嵌入式交叉编译工具链文件 └── main.c # 测试程序主体源代码
工程源代码编译
cd build cmake .. -DCMAKE_TOOLCHAIN_FILE=../cross-t113-i.cmake make Scanning dependencies of target can_test [ 33%] Building C object CMakeFiles/can_test.dir/main.c.o [ 66%] Building C object CMakeFiles/can_test.dir/can_apply.c.o [100%] Linking C executable can_test [100%] Built target can_test
工程使用cmake进行编译,需要注意的是要根据实际情况修改
cross-t113-i.cmake
中的GCC交叉编译工具的路径。# # CMake Toolchain file for crosscompiling on ARM. # # This can be used when running cmake in the following way: # cd build-t113/ # cmake .. -DCMAKE_TOOLCHAIN_FILE=../cross-t113-i.cmake # or set(CROSS_PATH /home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/t113_i/ok113i/longan/buildroot/host) # Target operating system name. set(CMAKE_SYSTEM_NAME Linux) set (CMAKE_C_FLAGS "-std=gnu11" CACHE STRING "Set C Compiler Flags" FORCE) # Name of C compiler. set(CMAKE_C_COMPILER "${CROSS_PATH}/bin/arm-linux-gnueabi-gcc") set(CMAKE_CXX_COMPILER "${CROSS_PATH}/bin/arm-linux-gnueabi-g++") set (CMAKE_C_FLAGS "-std=gnu11 -mcpu=cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4 -mno-unaligned-access -fno-aggressive-loop-optimizations -ffunction-sections" CACHE STRING "Set C Compiler Flags" FORCE) set (CMAKE_CXX_FLAGS "-mcpu=cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4 -mno-unaligned-access -fno-aggressive-loop-optimizations -ffunction-sections" CACHE STRING "Set C++ Compiler Flags" FORCE) # link flags set(CMAKE_LINK_FLAGS "${CMAKE_LINK_FLAGS} -mcpu=cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4 -mno-unaligned-access -fno-aggressive-loop-optimizations" CACHE STRING "Set link Flags" FORCE) SET(CMAKE_SYSTEM_PROCESSOR "armv7-a_hardfp") add_definitions(-fPIC) add_definitions(-DARMLINUX) add_definitions(-D__gnu_linux__) # Where to look for the target environment. (More paths can be added here) set(CMAKE_FIND_ROOT_PATH "${CROSS_PATH}/arm-buildroot-linux-gnueabi/sysroot") # Adjust the default behavior of the FIND_XXX() commands: # search programs in the host environment only. set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) # Search headers and libraries in the target environment only. set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
测试工程源代码
can-test.tar.gz -
飞凌 OK113i-C 全志T113-i开发板 rtl8723du WIFI 功能测试及蓝牙驱动移植
飞凌 OK113i-C 全志T113-i开发板板载一个RTL8723du wifi/蓝牙二合一模块,板子出厂已经移植好了WIFI驱动但是蓝牙驱动没有,所以这篇文章我们主要做蓝牙驱动的移植和功能验证。
./build.sh menuconfig
在
Device Drivers > Network device support > Wireless LAN
下找到Realtek 8723D USB WiFi
选项。
默认是开启的。默认wifi驱动联网尝试
wpa_supplicant -Dnl80211 -iwlan0 -c /etc/wpa_supplicant.conf -B udhcpc -i wlan0 udhcpc: started, v1.29.3 udhcpc: sending discover udhcpc: sending select for 192.168.0.111 udhcpc: lease of 192.168.0.111 obtained, lease time 7200 deleting routers adding dns 192.168.1.1 adding dns 192.168.0.1
wpa_supplicant.conf 文件
network={ ssid="TP-LINK_142C" psk="123445678" } update_config=1 ctrl_interface=DIR=/var/run/wpa_supplicant
打印网卡信息:
ifconfig eth0 Link encap:Ethernet HWaddr BA:E9:F2:1C:9D:87 inet addr:192.168.0.232 Bcast:0.0.0.0 Mask:255.255.255.0 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) Interrupt:39 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:41 errors:0 dropped:0 overruns:0 frame:0 TX packets:41 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:3936 (3.8 KiB) TX bytes:3936 (3.8 KiB) wlan0 Link encap:Ethernet HWaddr 2C:C3:E6:67:4D:3B inet addr:192.168.0.111 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::2ec3:e6ff:fe67:4d3b/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:86 errors:0 dropped:0 overruns:0 frame:0 TX packets:19 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:17189 (16.7 KiB) TX bytes:3763 (3.6 KiB)
至此,wifi连接路由器成功,可以ping 百度验证是否联网成功。
蓝牙功能
首先打印设备上的蓝牙设备
hciconfig -a
输出为空,应该是没有蓝牙驱动。看来出厂并没有带蓝牙驱动,下一步自行移植蓝牙驱动,板上的无线芯片模组使用的是rtl8723du是一款bt4.2和 wifi 2.4G芯片。
蓝牙驱动移植
- 修改kernel config
修改OK113i-linux-sdk/kernel/linux-5.4/arch/arm/configs/OK113I_linux_defconfig
文件添加如下一行
CONFIG_BT_HCIBTUSB_RTLBTUSB=m
- 修改Kconfig
添加如下:
config BT_HCIBTUSB_RTLBTUSB tristate "Realtek HCI USB driver support" depends on USB help Realtek Bluetooth HCI USB driver. This driver is required if you want to use Realtek Bluetooth device with USB interface. Say Y here to compile support for Bluetooth USB devices into the kernel or say M to compile it as module (rtk_btusb).
- 修改Makefile
在文档最后添加:
obj-$(CONFIG_BT_HCIBTUSB_RTLBTUSB) := rtk_btusb.o rtk_btusb-objs := rtk_bt.o rtk_misc.o rtk_coex.o
- 将驱动文件中如下文件复制到内核目录
OK113i-linux-sdk/kernel/linux-5.4/drivers/bluetooth
下:
rtk_bt.c rtk_bt.h rtk_coex.c rtk_coex.h rtk_misc.c rtk_misc.h
- 编译内核驱动
./build.sh kernel
编译完成后会在
OK113i-linux-sdk/out/t113_i/ok113i/longan/dist
目录下生成rtk_btusb.ko
驱动文件,将该驱动文件和驱动文件对应的固件文件(rtl8723du_fw.bin和rtl8723du_config.bin)放在板子/lib/firmware/
下为了方便查看驱动加载过程报错信息,打开内核打印信息:
echo 8 4 1 7 > /proc/sys/kernel/printk
将编译好的驱动文件和固件文件上传到板卡上,并将估计文件存放在板卡
/lib/firmware
目录下。scp out/t113_i/ok113i/longan/dist/rtk_btusb.ko root@192.168.0.105:/home/forlinx/ scp /home/luoyang/Documents/Dev/Bluetooth/V4-8761蓝牙_Linux驱动/20210819_LINUX_BT_DRIVER/rtkbt-firmware/lib/firmware/rtl8723du* root@192.168.0.105:/home/forlinx/ cp rtl8723du_config /lib/firmware/rtl8723du_config.bin cp rtl8723du_fw /lib/firmware/rtl8723du_fw.bin
加载驱动试试,报错:
insmod rtk_btusb.ko [ 4832.222554] rtk_btusb: module uses symbol (kernel_read) from namespace VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver, but does not import it. [ 4832.238042] rtk_btusb: Unknown symbol kernel_read (err -22) [ 4832.298908] rtk_btusb: module uses symbol (kernel_read) from namespace VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver, but does not import it. [ 4832.314387] rtk_btusb: Unknown symbol kernel_read (err -22) insmod: can't insert 'rtk_btusb.ko': Invalid argument
在rtk_bt.c文件最后一行添加:
MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver);
重新编译驱动,然后上传并加载试试。
root@ok113i:/home/forlinx# insmod rtk_btusb.ko [ 7964.303169] rtk_btusb: Realtek Bluetooth USB driver ver 3.1.32e1d0b.20210819-170430 [ 7964.311850] rtk_btcoex: rtk_btcoex_init: version: 1.2 [ 7964.317513] rtk_btcoex: create workqueue [ 7964.322343] rtk_btcoex: alloc buffers 1408, 2240 for ev and l2 [ 7964.329075] rtk_btusb: btusb_probe intf->cur_altsetting->desc.bInterfaceNumber 0 [ 7964.337365] rtk_btusb: btusb_probe can_wakeup 1, may wakeup 0 [ 7964.343827] rtk_btusb: patch_add [ 7964.347451] rtk_btusb: auto suspend is disabled [ 7964.352568] rtk_btusb: pid = 0xd723 [ 7964.356478] rtk_btusb: patch_add: Reset gEVersion to 0xff [ 7964.362590] rtk_btusb: set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks); [ 7964.370965] rtk_btusb: btusb_probe: done [ 7964.375679] usbcore: registered new interface driver rtk_btusb [ 7964.377514] rtk_btusb: btusb_open start [ 7964.386578] rtk_btusb: btusb_open hdev->promisc ==0 [ 7964.392129] rtk_btusb: download_patch start root@ok113i:/home/forlinx# [ 7964.396839] rtk_btusb: chip type value: 0x71 [ 7964.403997] rtk_btusb: HCI reset. [ 7964.416814] rtk_btusb: read_ver_rsp->lmp_subver = 0x8723 [ 7964.423054] rtk_btusb: read_ver_rsp->hci_rev = 0xd [ 7964.428449] rtk_btusb: patch_entry->lmp_sub = 0x8723 [ 7964.434017] rtk_btusb: load_firmware start [ 7964.438638] rtk_btusb: lmp_version = 0x8723 [ 7964.443325] rtk_btusb: config filename rtl8723du_config [ 7964.449952] rtk_btusb: no bdaddr file /opt/bdaddr [ 7964.455252] rtk_btusb: Origin cfg len 22 [ 7964.459688] rtk_btusb: 55 ab 23 87 10 00 d9 00 01 0f e4 00 01 08 8d 00 [ 7964.467005] rtk_btusb: 01 fa 8f 00 01 bf [ 7964.471497] rtk_btusb: New cfg len 22 [ 7964.475600] rtk_btusb: 55 ab 23 87 10 00 d9 00 01 0f e4 00 01 08 8d 00 [ 7964.482969] rtk_btusb: 01 fa 8f 00 01 bf [ 7964.487399] rtk_btusb: fw name is rtl8723du_fw [ 7964.492801] rtk_btusb: This is not 8723a, use new patch style! [ 7964.499374] rtk_btusb: rtk_get_eversion: gEVersion 255 [ 7964.505815] rtk_btusb: eversion->status = 0x0, eversion->version = 0x2 [ 7964.513566] rtk_btusb: load_firmware: New gEVersion 2 [ 7964.519331] rtk_btusb: rtk_get_fw_project_id: opcode 0, len 1, data 9 [ 7964.526565] rtk_btusb: lmp_version is 8723, project_id is 8723, match! [ 7964.533909] rtk_btusb: fw_version = 0x82a8a133 [ 7964.538921] rtk_btusb: number_of_total_patch = 3 [ 7964.544092] rtk_btusb: chipID 3 [ 7964.547606] rtk_btusb: patch_length 0x889c [ 7964.552220] rtk_btusb: start_offset 0x00004940 [ 7964.557198] rtk_btusb: Svn version: -1433992835 [ 7964.562301] rtk_btusb: Coexistence: BTCOEX_20210106-3b3b [ 7964.568274] rtk_btusb: buf_len = 0x88b2 [ 7964.572647] rtk_btusb: fw: exists, config file: exists [ 7964.578430] rtk_btusb: load_firmware done [ 7964.582960] rtk_btusb: download_data start [ 7964.855824] rtk_btusb: download_data done [ 7964.860346] rtk_btusb: HCI reset. [ 7964.873812] rtk_btusb: read_ver_rsp->lmp_subver = 0xa133 [ 7964.880054] rtk_btusb: read_ver_rsp->hci_rev = 0x82a8 [ 7964.885730] rtk_btusb: patch_entry->lmp_sub = 0x8723 [ 7964.891337] rtk_btusb: Rtk patch end 0 [ 7964.895538] rtk_btusb: btusb_open set HCI_RUNNING [ 7964.900945] rtk_btcoex: Open BTCOEX [ 7964.904856] rtk_btusb: btusb_open end [ 7964.911832] rtk_btcoex: BTCOEX hci_rev 0x82a8 [ 7964.916883] rtk_btcoex: BTCOEX lmp_subver 0xa133 [ 7964.943829] rtk_btusb: btusb_notify: hci0 evt 3 [ 7967.007992] rtk_btusb: btusb_flush add delay [ 7967.022915] rtk_btusb: btusb_close [ 7967.045574] rtk_btcoex: Close BTCOEX [ 7967.049615] rtk_btcoex: -x
以上信息说明蓝牙驱动加载成功。
此时,再一次查看系统的蓝牙设备信息会打印如下:root@ok113i:/home/forlinx# hciconfig -a hci0: Type: Primary Bus: USB BD Address: 2C:C3:E6:67:4D:3C ACL MTU: 1021:8 SCO MTU: 255:12 DOWN RX bytes:584 acl:0 sco:0 events:30 errors:0 TX bytes:369 acl:0 sco:0 commands:30 errors:0 Features: 0xff 0xff 0xff 0xfa 0xdb 0xbd 0x7b 0x87 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH HOLD SNIFF PARK Link mode: SLAVE ACCEPT
蓝牙工具软件使用
蓝牙驱动安装成功后就可以对蓝牙设备进行配对连接并进行播放音频操作了,此处我们选择通过蓝牙连接家里的智能音箱天猫精灵作为蓝牙音频输出设备,涉及的蓝牙工具软件开发板上出厂移植好了,所以此处省去了移植这些工具软件的步骤。
- 启动系统蓝牙服务
bluetoothd
,使其在后台运行
bluetoothd -d -n & root@ok113i:/# bluetoothd[1516]: Bluetooth daemon 5.50 bluetoothd[1516]: src/adapter.c:adapter_init() sending read version command bluetoothd[1516]: Starting SDP server bluetoothd[1516]: src/sdpd-service.c:register_device_id() Adding device id record for 0002:1d6b:0246:0532 bluetoothd[1516]: src/plugin.c:plugin_init() Loading builtin plugins bluetoothd[1516]: src/plugin.c:add_plugin() Loading hostname plugin bluetoothd[1516]: src/plugin.c:add_plugin() Loading wiimote plugin bluetoothd[1516]: src/plugin.c:add_plugin() Loading autopair plugin bluetoothd[1516]: src/plugin.c:add_plugin() Loading policy plugin bluetoothd[1516]: src/plugin.c:add_plugin() Loading neard plugin bluetoothd[1516]: src/plugin.c:add_plugin() Loading sap plugin bluetoothd[1516]: src/plugin.c:add_plugin() Loading a2dp plugin bluetoothd[1516]: src/plugin.c:add_plugin() Loading avrcp plugin bluetoothd[1516]: src/plugin.c:add_plugin() Loading network plugin bluetoothd[1516]: src/plugin.c:add_plugin() Loading input plugin bluetoothd[1516]: src/plugin.c:add_plugin() Loading hog plugin bluetoothd[1516]: src/plugin.c:add_plugin() Loading health plugin bluetoothd[1516]: src/plugin.c:add_plugin() Loading gap plugin bluetoothd[1516]: src/plugin.c:add_plugin() Loading scanparam plugin bluetoothd[1516]: src/plugin.c:add_plugin() Loading deviceinfo plugin bluetoothd[1516]: src/plugin.c:add_plugin() Loading midi plugin bluetoothd[1516]: src/plugin.c:add_plugin() Loading battery plugin bluetoothd[1516]: src/plugin.c:plugin_init() Loading plugins /usr/lib/bluetooth/plugins bluetoothd[1516]: src/plugin.c:add_plugin() Loading sixaxis plugin bluetoothd[1516]: profiles/health/hdp.c:hdp_manager_start() Starting Health manager bluetoothd[1516]: profiles/input/suspend-none.c:suspend_init() bluetoothd[1516]: profiles/network/manager.c:read_config() Config options: Security=true bluetoothd[1516]: kernel lacks bnep-protocol support bluetoothd[1516]: System does not support network plugin bluetoothd[1516]: plugins/neard.c:neard_init() Setup neard plugin bluetoothd[1516]: plugins/sixaxis.c:sixaxis_init() bluetoothd[1516]: src/main.c:main() Entering main loop bluetoothd[1516]: src/rfkill.c:rfkill_event() RFKILL event idx 0 type 1 op 0 soft 0 hard 0 bluetoothd[1516]: Bluetooth management interface 1.14 initialized bluetoothd[1516]: src/adapter.c:read_version_complete() sending read supported commands command bluetoothd[1516]: src/adapter.c:read_version_complete() sending read index list command bluetoothd[1516]: src/adapter.c:read_commands_complete() Number of commands: 65 bluetoothd[1516]: src/adapter.c:read_commands_complete() Number of events: 35 bluetoothd[1516]: src/adapter.c:read_commands_complete() enabling kernel-side connection control bluetoothd[1516]: src/adapter.c:read_index_list_complete() Number of controllers: 0 root@ok113i:/#
- 通过
bluetoothctl
对蓝牙设备操作,主要包括:蓝牙设备信息打印查看,蓝牙设备开启和关闭、蓝牙外设扫描、查看扫描到的蓝牙外设设备、配对连接等,下面实例命令行中##
开头的行是注释
## 进入bluetoothctl root@ok113i:/# bluetoothctl bluetoothd[1516]: src/agent.c:agent_ref() 0x8c9338: ref=1 bluetoothd[1516]: src/agent.c:register_agent() agent :1.1 Agent registered ## 蓝牙设备信息打印查看 [bluetooth]#show Controller 2C:C3:E6:67:4D:3C (public) Name: BlueZ 5.50 Alias: BlueZ 5.50 Class: 0x00000000 Powered: no Discoverable: no Pairable: yes UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb) UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb) UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb) UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb) UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb) Modalias: usb:v1D6Bp0246d0532 Discovering: no ## 蓝牙设备开启和关闭 [bluetooth]#power on [bluetooth]# [ 417.686414] rtk_btusb: btusb_open start bluetoothd[1516]: src/adapter.c:[ 417.691880] rtk_btusb: btusb_open hdev->promisc ==0 property_set_mode() sending Set [ 417.700202] rtk_btusb: download_patch start Powered command for index 0 [ 417.707637] rtk_btusb: chip type value: 0x71 [ 417.714939] rtk_btusb: HCI reset. [ 417.727699] rtk_btusb: read_ver_rsp->lmp_subver = 0xa133 [ 417.733654] rtk_btusb: read_ver_rsp->hci_rev = 0x82a8 [ 417.739344] rtk_btusb: patch_entry->lmp_sub = 0x8723 [ 417.744905] rtk_btusb: Firmware already exists [ 417.749914] rtk_btusb: Rtk patch end 1 [ 417.754125] rtk_btusb: btusb_open set HCI_RUNNING [ 417.759504] rtk_btcoex: Open BTCOEX [ 417.763412] rtk_btusb: btusb_open end [ 417.769720] rtk_btcoex: BTCOEX hci_rev 0x82a8 [ 417.774656] rtk_btcoex: BTCOEX lmp_subver 0xa133 bluetoothd[1516]: src/adapter.c:property_set_mode_complete() Success (0x00) bluetoothd[1516]: src/adapter.c:new_settings_callback() Settings: 0x00000ad1 bluetoothd[1516]: src/adapter.c:settings_changed() Changed settings: 0x00000001 bluetoothd[1516]: src/adapter.c:adapter_start() adapter /org/bluez/hci0 has been enabled bluetoothd[1516]: src/adapter.c:trigger_passive_scanning() Changing power on succeeded [CHG] Controller 2C:C3:E6:67:4D:3C Powered: yes ## 蓝牙设备开启和关闭 [bluetooth]#scan on [bluetooth]#scan off ## 查看扫描到的蓝牙外设设备 [bluetooth]#devices Device F1:22:33:1A:48:9B F1-22-33-1A-48-9B Device C4:DE:E2:DF:E8:22 Keep_CC_50200973 Device 34:29:EF:5B:D2:D3 34-29-EF-5B-D2-D3 Device E8:F5:63:87:03:9D Mi Band 3 Device B8:8C:29:87:72:C9 midea Device 04:7F:0E:40:4A:BD BEIJING-EU5 Device CC:B5:D1:FB:45:3A SMI-M14 Device 45:B8:CC:87:53:F8 45-B8-CC-87-53-F8 Device 84:7C:9B:6D:FF:11 midea_db_2943 Device 10:9E:3A:92:2E:DA �方�糖(80:7A) ## 配对连接 [bluetooth]#connect 10:9E:3A:92:2E:DA Attempting to connect to 10:9E:3A:92:2E:DA bluetoothd[1516]: src/device.c:connect_profiles() /org/bluez/hci0/dev_10_9E_3A_92_2E_DA (all), client :1.2 bluetoothd[1516]: profiles/audio/a2dp.c:a2dp_sink_connect() path /org/bluez/hci0/dev_10_9E_3A_92_2E_DA bluetoothd[1516]: a2dp-sink profile connect failed for 10:9E:3A:92:2E:DA: Protocol not available Failed to connect: org.bluez.Error.Failed
报错了,因为没有提前运行
bluealsa
这个程序,运行如下:bluealsa -p a2dp-source & [2] 1537 root@ok113i:/home/forlinx# bluetoothd[1516]: profiles/audio/avdtp.c:avdtp_register_sep() SEP 0x8cc378 registered: type:0 codec:2 seid:1 bluetoothd[1516]: src/adapter.c:adapter_service_add() /org/bluez/hci0 bluetoothd[1516]: src/sdpd-service.c:add_record_to_server() Adding record with handle 0x10003 bluetoothd[1516]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000019-0000-1000-8000-00805f9 bluetoothd[1516]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000100-0000-1000-8000-00805f9 bluetoothd[1516]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00001002-0000-1000-8000-00805f9 bluetoothd[1516]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 0000110a-0000-1000-8000-00805f9 bluetoothd[1516]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 0000110d-0000-1000-8000-00805f9 bluetoothd[1516]: src/adapter.c:adapter_service_insert() /org/bluez/hci0 bluetoothd[1516]: src/adapter.c:add_uuid() sending add uuid command for index 0 bluetoothd[1516]: Endpoint registered: sender=:1.3 path=/A2DP/MPEG24/Source/1 bluetoothd[1516]: src/adapter.c:dev_class_changed_callback() Class: 0x080000 bluetoothd[1516]: profiles/audio/avdtp.c:avdtp_register_sep() SEP 0x8c63f0 registered: type:0 codec:0 seid:2 bluetoothd[1516]: Endpoint registered: sender=:1.3 path=/A2DP/SBC/Source/1
至此,再进入bluetoothctl 连接天猫精灵试试,首先输入
devices
命令打印出扫描到的设备信息,然后使用connect xx:xx:xx:xx:xx:xx
连接上想要连接的蓝牙设备,连接成功后提示符会变成[连接的设备]
样式,具体如下:[bluetooth]#devices Device F1:22:33:1A:48:9B F1-22-33-1A-48-9B Device C4:DE:E2:DF:E8:22 Keep_CC_50200973 Device 34:29:EF:5B:D2:D3 34-29-EF-5B-D2-D3 Device E8:F5:63:87:03:9D Mi Band 3 Device B8:8C:29:87:72:C9 midea Device 04:7F:0E:40:4A:BD BEIJING-EU5 Device CC:B5:D1:FB:45:3A SMI-M14 Device 45:B8:CC:87:53:F8 45-B8-CC-87-53-F8 Device 84:7C:9B:6D:FF:11 midea_db_2943 Device 10:9E:3A:92:2E:DA �方�糖(80:7A) [bluetooth]#connect 10:9E:3A:92:2E:DA ... [�方�糖(80:7A)]# list Controller 2C:C3:E6:67:4D:3C BlueZ 5.50 [default] ## 退出bluetoothctl程序 [�方�糖(80:7A)]# exit
- 蓝牙音频播放
因为此处我们使用alsa-utils
工具集中的 aplay 进行音频播放测试,所以仅仅支持PCM
和WAV
等音频格式,要是想直接播放 mp3 或者 mp4 等格式音频文件需要借助MPD
或者FFmpeg
等软件。
上一步我们在bluetoothctl中打印扫描并连接了蓝牙音箱,蓝牙音箱的设备地址如下:
[bluetooth]#devices Device F1:22:33:1A:48:9B F1-22-33-1A-48-9B Device C4:DE:E2:DF:E8:22 Keep_CC_50200973 Device 34:29:EF:5B:D2:D3 34-29-EF-5B-D2-D3 Device E8:F5:63:87:03:9D Mi Band 3 Device B8:8C:29:87:72:C9 midea Device 04:7F:0E:40:4A:BD BEIJING-EU5 Device CC:B5:D1:FB:45:3A SMI-M14 Device 45:B8:CC:87:53:F8 45-B8-CC-87-53-F8 Device 84:7C:9B:6D:FF:11 midea_db_2943 Device 10:9E:3A:92:2E:DA �方�糖(80:7A)
根据上面信息我们可以看到天猫精灵方糖的蓝牙设备地址是
10:9E:3A:92:2E:DA
,所以我们可以使用如下命令进行音频播放测试:root@ok113i:/# aplay -D bluealsa:DEV=10:9E:3A:92:2E:DA ./wishforyou.wav Playing WAVE './wishforyou.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo bluetoothd[1516]: profiles/audio/transport.c:media_owner_create() Owner created: sender=:1.3 bluetoothd[1516]: profiles/audio/avdtp.c:avdtp_ref() 0x8cf3c0: ref=2 bluetoothd[1516]: profiles/audio/a2dp.c:a2dp_sep_lock() SEP 0x8c63f0 locked bluetoothd[1516]: profiles/audio/avdtp.c:avdtp_ref() 0x8cf3c0: ref=3 bluetoothd[1516]: profiles/audio/a2dp.c:setup_ref() 0x8ccad0: ref=1 bluetoothd[1516]: profiles/audio/transport.c:transport_set_state() State changed /org/bluez/hci0/dev_10_9E_3A_92_2E_DA/fd0: TRANSPORT_STATE_IDLE -> TRANSPORT_STATE_REQUESTING bluetoothd[1516]: profiles/audio/transport.c:media_request_create() Request created: method=Acquire id=4 bluetoothd[1516]: profiles/audio/transport.c:media_owner_add() Owner :1.3 Request Acquire bluetoothd[1516]: profiles/audio/transport.c:media_transport_set_owner() Transport /org/bluez/hci0/dev_10_9E_3A[ 1901.267056] rtk_btcoex: update_profile_state: btrtl_coex.prof4 _92_2E_DA/fd0 Owner :1.3 blueto[ 1901.276315] rtk_btcoex: update_profile_state: btrtl_coex.profile_status = 4 othd[1516]: profiles/audio/avdtp[ 1901.287222] rtk_btcoex: rtk_notify_profileinfo_to_fw: BufferSize 5 .c:session_cb() bluetoothd[151[ 1901.296656] rtk_btcoex: rtk_notify_profileinfo_to_fw: NumberOfHandles 1 6]: profiles/audio/avdtp.c:avdtp[ 1901.307101] rtk_btcoex: rtk_notify_profileinfo_to_fw: handle 0x0003 _parse_resp() START request succ[ 1901.316801] rtk_btcoex: rtk_notify_profileinfo_to_fw: profile_bitmap 0x04 eeded bluetoothd[1516]: profile[ 1901.327316] rtk_btcoex: rtk_notify_profileinfo_to_fw: profile_status 0x04 s/audio/a2dp.c:start_cfm() Sourc[ 1901.337472] rtk_btcoex: rtk_vendor_cmd_to_fw: opcode 0xfc19 e 0x8c63f0: Start_Cfm bluetooth[ 1901.346663] rtk_btcoex: Length 629 d[1516]: /org/bluez/hci0/dev_10_[ 1901.353083] rtk_btcoex: rtp: v 2, cc 0, pt 96 9E_3A_92_2E_DA/fd0: fd(20) ready[ 1901.360767] rtk_btcoex: syncword: 9c bluetoothd[1516]: profiles/aud[ 1901.367663] rtk_btcoex: freq 48kHz io/transport.c:media_owner_remov[ 1901.374144] rtk_btcoex: blocks 16 e() Owner :1.3 Request Acquire [ 1901.380646] rtk_btcoex: channel mode JOINT_STEREO bluetoothd[1516]: profiles/audio[ 1901.388829] rtk_btcoex: allocation method LOUDNESS /transport.c:transport_set_state[ 1901.396877] rtk_btcoex: subbands 8 () State changed /org/bluez/hci0[ 1901.403488] rtk_btcoex: bitpool 32 /dev_10_9E_3A_92_2E_DA/fd0: TRAN[ 1901.410192] rtk_btcoex: rtk_vendor_cmd_to_fw: opcode 0xfc51 SPORT_STATE_REQUESTING -> TRANSPORT_STATE_ACTIVE bluetoothd[1516]: profiles/audio/a2dp.c:setup_unref() 0x8ccad0: ref=0 bluetoothd[1516]: profiles/audio/a2dp.c:setup_free() 0x8ccad0 bluetoothd[1516]: profiles/audio/avdtp.c:avdtp_unref() 0x8cf3c0: ref=2 bluetoothd[1516]: profiles/audio/avdtp.c:avdtp_sep_set_state() stream state changed: OPEN -> STREAMING bluetoothd[1516]: profiles/audio/sink.c:sink_set_state() State changed /org/bluez/hci0/dev_10_9E_3A_92_2E_DA: SINK_STATE_CONNECTED -> SINK_STATE_PLAYING bluetoothd[1516]: profiles/audio/transport.c:transport_update_playing() /org/bluez/hci0/dev_10_9E_3A_92_2E_DA/fd0 State=TRANSPORT_STATE_ACTIVE Playing=1 [ 1902.124926] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 20 [ 1903.164933] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 22 [ 1904.204932] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 21 [ 1905.244932] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 14 [ 1906.284931] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 26 [ 1907.324939] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 18 [ 1908.364936] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 18 [ 1909.404933] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 20 [ 1910.444937] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 13 [ 1911.484925] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 16 [ 1912.524927] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 14 [ 1913.564933] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 13 [ 1914.604934] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 10 [ 1915.644932] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 7 [ 1916.684940] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 8 [ 1917.724923] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 9 [ 1918.764925] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 15 [ 1919.804933] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 21 [ 1920.844937] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 21 [ 1921.884941] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 27 [ 1922.924932] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 20 [ 1923.964933] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 16 [ 1925.004927] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 19 [ 1926.044934] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 31 [ 1927.084937] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 22 [ 1928.124936] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 31 [ 1929.164931] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 32 [ 1930.204929] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 18 [ 1931.244931] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 36 [ 1932.284931] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 24 [ 1933.324936] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 21 [ 1934.364932] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 20 [ 1935.404930] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 11 [ 1936.444934] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 15 [ 1937.484928] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 17 [ 1938.524946] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 20 [ 1939.564928] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 13 [ 1940.604935] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 19 [ 1941.644929] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 16 [ 1942.684932] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 28
不出意外的话可以听到播放的歌曲声音了。
参考
- 修改kernel config
-
飞凌 OK113i-C 全志T113-i开发板初体验
板子做工精致很有份量,拿在手里沉甸甸的,各种接口一应俱全——USB、TF 卡座、SIM卡座、4G模块卡座、网口、RGB LCD接口、LVDS、RS485、CAN、各种音频口、TV-in/TV-Out,板上还自带一个RTL8723du wifi/蓝牙二合一模块,作为一块主打工业控制的主控板这些接口实属绰绰有余了。手里的板子是256MB内存+256MB nand flash版本(这个是低配版本,还有个512MB+8GB emmc的高配版本),飞凌开发文档中提到已经移植好了Qt5开发环境,所以这个内存跑跑Qt的UI程序是再合适不过了,可惜手里没有匹配的开箱即用的LCD显示屏不然接上直接能试试出厂自带的Qt测试程序了。
提供的开发资料中已经包含有Ubuntu 20.04 的虚拟机文件,因为是直接用的Linux版本系统,所以需要自己搭建开发环境,以下所涉内容都是在装有Ubuntu 20.04的PC上进行操作,而且,因为以前在安装过T113-S3的开发环境,所以在编译SDK过程中并没有碰到其他因缺少依赖软件报的错误。
T113-i longan linux开发环境搭建
解压sdk
cat OK113i-linux-sdk.tar.bz2* | tar jx -C ~/Dev/sdk/T113-i/
编译前的准备
除了 gcc,ncurse,bison,autoconf,wget,patch,texinfo,zlib,dos2unix 之外需要安装如下:
sudo apt-get install git sudo apt-get install gnupg sudo apt-get install flex sudo apt-get install bison sudo apt-get install gperf sudo apt-get install build-essential sudo apt-get install zip sudo apt-get install curl sudo apt-get install libc6-dev sudo apt-get install libncurses5-dev:i386 sudo apt-get install x11proto-core-dev sudo apt-get install libx11-dev:i386 sudo apt-get install libreadline6-dev:i386 sudo apt-get install libgl1-mesa-glx:i386 sudo apt-get install libgl1-mesa-dev sudo apt-get install g++-multilib sudo apt-get install mingw32 sudo apt-get install tofrodos sudo apt-get install python-markdown sudo apt-get install libxml2-utils sudo apt-get install xsltproc sudo apt-get install zlib1g-dev:i386 sudo apt-get install gawk sudo dpkg-reconfigure dash 选择no sudo apt-get install libgl1-mesa-dev:i386 sudo apt install u-boot-tools
初次编译内核
./build.sh config Welcome to mkscript setup progress All available platform: 0. linux Choice [linux]: 0 All available board: 0. ok113i Choice [ok113i]: 0 All available flash: 0. default 1. nor 2. nand Choice [default]: 0 All available display_type: 0. tvout_pal 1. tvout_ntsc 2. lcd_800x480 3. lcd_1024x600 4. mipi_1024x600 5. lvds_1280x800 Choice [tvout_pal]: 2 Relocating the buildroot SDK from /home/forlinx/work/OK113i-linux-sdk/out/t113_i/ok113i/longan/buildroot/host to /home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/t113_i/ok113i/longan/buildroot/host ... /home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk File "<string>", line 1 import os.path; print os.path.relpath('/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/kernel/linux-5.4/arch/arm/configs/OK113I_linux_defconfig', '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/kernel/linux-5.4/arch/arm/configs') ^ SyntaxError: invalid syntax ERROR: Can't find kernel defconfig!
python 报系统库语法错误,根据经验是系统python版本问题,首先查看系统中python版本号
python --version Python 3.8.10
不出意外的话编译系统依赖python 2.7,所以切换到python 2.7版本,具体操作如下:
首先,查看系统有几个python版本update-alternatives --list python /usr/bin/python2 /usr/bin/python3
然后,通过如下切换到想要的版本
update-alternatives --config python There are 2 choices for the alternative python (providing /usr/bin/python). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/python3 2 auto mode 1 /usr/bin/python2 1 manual mode 2 /usr/bin/python3 2 manual mode Press <enter> to keep the current choice[*], or type selection number: 1
切换后,再确认python 版本:
python --version Python 2.7.18
最后再试一次:
./build.sh config Welcome to mkscript setup progress All available platform: 0. linux Choice [linux]: 0 All available board: 0. ok113i Choice [ok113i]: 0 All available flash: 0. default 1. nor 2. nand Choice [default]: 0 All available display_type: 0. tvout_pal 1. tvout_ntsc 2. lcd_800x480 3. lcd_1024x600 4. mipi_1024x600 5. lvds_1280x800 Choice [lcd_1024x600]: 2 This buildroot SDK has already been relocated! /home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk INFO: kernel defconfig: generate /home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/kernel/linux-5.4/.config by /home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/kernel/linux-5.4/arch/arm/configs/OK113I_linux_defconfig HOSTCC scripts/basic/fixdep HOSTCC scripts/kconfig/conf.o HOSTCC scripts/kconfig/confdata.o HOSTCC scripts/kconfig/expr.o LEX scripts/kconfig/lexer.lex.c YACC scripts/kconfig/parser.tab.[ch] HOSTCC scripts/kconfig/lexer.lex.o HOSTCC scripts/kconfig/parser.tab.o HOSTCC scripts/kconfig/preprocess.o HOSTCC scripts/kconfig/symbol.o HOSTLD scripts/kconfig/conf *** Default configuration is based on 'OK113I_linux_defconfig' # # configuration written to .config # make: Entering directory '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/buildroot/buildroot-201902' GEN /home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/t113_i/ok113i/longan/buildroot/Makefile Config.in.legacy:1769:warning: choice value used outside its choice group /home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/buildroot/buildroot-201902/configs/OK113I_linux_defconfig:3159:warning: override: reassigning to symbol BR2_PACKAGE_OTA_BURNBOOT # # configuration written to /home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/t113_i/ok113i/longan/buildroot/.config # make: Leaving directory '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/buildroot/buildroot-201902' INFO: buildroot defconfig is OK113I_linux_defconfig
编译内核试试:
./build.sh kernel ACTION List: mkkernel;======== Execute command: mkkernel INFO: build kernel ... INFO: prepare_buildserver INFO: Prepare toolchain ... toolchain_archivedir=/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/build/toolchain/gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabi.tar.xz build server start. (cd /home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/build && [ -x mkkernel.sh ] && ./mkkernel.sh) CLEAN scripts/basic CLEAN scripts/kconfig CLEAN include/config include/generated CLEAN .config Using default config /home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/kernel/linux-5.4/arch/arm/configs/OK113I_linux_defconfig ... make[1]: Entering directory '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/kernel/build' ...... ...... make[1]: Leaving directory '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/kernel/build' [NAND]: Build module driver make: Entering directory '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/kernel/linux-5.4/modules/nand' [NAND] NOT buid as ko make: Leaving directory '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/kernel/linux-5.4/modules/nand' make: Entering directory '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/kernel/linux-5.4/modules/nand' [NAND] NOT buid as ko make: Leaving directory '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/kernel/linux-5.4/modules/nand' [NAND]: Build done [ GPU]: Build module driver make: Entering directory '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/kernel/linux-5.4/modules/gpu' Nothing to do for unsupport configuration make: Leaving directory '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/kernel/linux-5.4/modules/gpu' make: Entering directory '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/kernel/linux-5.4/modules/gpu' Nothing to do for unsupport configuration make: Leaving directory '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/kernel/linux-5.4/modules/gpu' [ GPU]: Build done ---build dts for sun8iw20p1 ok113i----- '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/kernel/build/arch/arm/boot/dts//board.dtb' -> '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/kernel/staging/sunxi.dtb' Copy modules to target ... 16149 blocks 25241 blocks build_ramfs Copy boot.img to output directory ... sun8iw20p1 compile Kernel successful INFO: Prepare toolchain ... toolchain_archivedir=/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/build/toolchain/gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabi.tar.xz Using default config /home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/kernel/linux-5.4/arch/arm/configs/OK113I_linux_defconfig ... make[1]: Entering directory '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/kernel/build' GEN Makefile *** Default configuration is based on 'OK113I_linux_defconfig' # # No change to .config # make[1]: Leaving directory '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/kernel/build' ---build dts for sun8iw20p1 ok113i----- make[1]: Entering directory '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/kernel/build' DTC arch/arm/boot/dts/board.dtb make[1]: Leaving directory '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/kernel/build' '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/kernel/build/arch/arm/boot/dts//board.dtb' -> '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/kernel/staging/sunxi.dtb' '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/kernel/staging/sunxi.dtb' -> '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/t113_i/ok113i/longan/sunxi.dtb' INFO: build kernel OK.
内核编译完后
OK113i-linux-sdk/out
目录需要注意,这个是所有的编译输出目录,后面buildroot
编译完也是在这个目录编译输出的。此目录中如下几个目录需要特别记住:- 编译内核的交叉编译工具链
在OK113i-linux-sdk/out/gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabi
目录下就是编译内核的交叉编译工具链。 - buildroot的交叉编译工具链
在OK113i-linux-sdk/out/t113_i/ok113i/longan/buildroot/host/bin/
中arm-linux-gnueabi-g++
等,编译应用程序的时候使用这个编译工具。 - 内核编译输出目录
在OK113i-linux-sdk/out/kernel
目录下就是内核编译目录位置,具体结构如下所示:
├── build # 编译生成的临时文件 │ ├── arch │ ├── block │ ├── certs │ ├── crypto │ ├── drivers #编译生成的驱动模块在此目录中 │ ├── fs │ ├── include │ ├── init │ ├── ipc │ ├── kernel │ ├── lib │ ├── Makefile │ ├── mm │ ├── modules.builtin │ ├── modules.builtin.modinfo │ ├── modules.order │ ├── Module.symvers │ ├── net │ ├── scripts │ ├── security │ ├── sound │ ├── source -> /home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/kernel/linux-5.4 │ ├── System.map │ ├── usr │ ├── virt │ ├── vmlinux │ └── vmlinux.o └── staging └── sunxi.dtb #猜测是设备树
比如内核编译后wifi模块的驱动文件就存放在
OK113i-linux-sdk/out/kernel/build/drivers/net/wireless/rtl8723du
目录下的8723du.ko
kernel menuconfig 配置
build.sh menuconfig
上面设置的config居然是out目录下的文件,重新编译会被覆盖。
编译阶段打印使用这个配置/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/kernel/linux-5.4/arch/arm/configs/OK113I_linux_defconfig
,试着改这个试试。buildroot 编译
./build.sh rootfs
默认全部编译运行
build.sh
,会有如下打印有用信息,此处记录下:编译Qt测试程序时候的打印
... /home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/t113_i/ok113i/longan/buildroot/host/bin/arm-linux-gnueabi-g++ -c -pipe -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os --sysroot=/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/t113_i/ok113i/longan/buildroot/host/arm-buildroot-linux-gnueabi/sysroot -O2 -O3 -Wall -W -D_REENTRANT -fPIC -DQT_NO_UITOOLS -DQT_NO_DEBUG -DQT_WEBKITWIDGETS_LIB -DQT_PRINTSUPPORT_LIB -DQT_WIDGETS_LIB -DQT_WEBKIT_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/t113_i/ok113i/longan/buildroot/host/arm-buildroot-linux-gnueabi/sysroot/usr/include/qt5 -I/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/t113_i/ok113i/longan/buildroot/host/arm-buildroot-linux-gnueabi/sysroot/usr/include/qt5/QtWebKitWidgets -I/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/t113_i/ok113i/longan/buildroot/host/arm-buildroot-linux-gnueabi/sysroot/usr/include/qt5/QtPrintSupport -I/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/t113_i/ok113i/longan/buildroot/host/arm-buildroot-linux-gnueabi/sysroot/usr/include/qt5/QtWidgets -I/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/t113_i/ok113i/longan/buildroot/host/arm-buildroot-linux-gnueabi/sysroot/usr/include/qt5/QtWebKit -I/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/t113_i/ok113i/longan/buildroot/host/arm-buildroot-linux-gnueabi/sysroot/usr/include/qt5/QtGui -I/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/t113_i/ok113i/longan/buildroot/host/arm-buildroot-linux-gnueabi/sysroot/usr/include/qt5/QtNetwork -I/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/t113_i/ok113i/longan/buildroot/host/arm-buildroot-linux-gnueabi/sysroot/usr/include/qt5/QtCore -I. -I. -I/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/t113_i/ok113i/longan/buildroot/host/mkspecs/devices/linux-buildroot-g++ -o settings.o settings.cpp /home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/t113_i/ok113i/longan/buildroot/host/bin/qmake -o Makefile /home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/platform/framework/auto/qt_demo/terminal/terminal.pro ) && make -f Makefile build emmc rootfs PARTITION_FEX=/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/device/config/chips/t113_i/configs/ok113i/longan/sys_partition.fex ROOTFS_FEX_LINE=64 ROOTFS_FEX_STR= size = 2097152 ROOTFS_FEX_SIZE= 2097152 EXT4_SIZE=1073741824(1073741824/1024/1024) /home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/device/config/chips/t113_i/configs/ok113i/longan/sys_partition.fex rootfs.fex size is 2097152 EXT4_SIZE= 2097152*512=1073741824 Creating filesystem with parameters: Size: 1073741824 Block size: 4096 Blocks per group: 32768 Inodes per group: 8192 Inode size: 256 Journal blocks: 4096 Label: Blocks: 262144 Block groups: 8 Reserved blocks: 0 Reserved block group size: 63 Created filesystem with 8976/65536 inodes and 94920/262144 blocks /home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/build/bin/make_ext4fs -s -l 1073741824 /home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/t113_i/ok113i/longan/rootfs.ext4 /home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/t113_i/ok113i/longan/buildroot/target
可以知道:
sysroot
=/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/out/t113_i/ok113i/longan/buildroot/host/arm-buildroot-linux-gnueabi/sysroot
- 移植好的qmake所在路径:
OK113i-linux-sdk/out/t113_i/ok113i/longan/buildroot/host/bin/qmake
- Qt示例工程源代码在
/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/platform/framework/auto/qt_demo
目录 - 编译好的驱动模块都在
OK113i-linux-sdk/out/t113_i/ok113i/longan/dist
目录下面:
OK113i-linux-sdk/out/t113_i/ok113i/longan/dist$ tree . ├── 8723du.ko ├── c2590_mipi.ko ├── gc030a_mipi.ko ├── gc0310_mipi.ko ├── gc2385_mipi.ko ├── gc5025_mipi.ko ├── imx278_2lane_mipi.ko ├── imx278_mipi.ko ├── imx386_2lane_mipi.ko ├── imx386_mipi.ko ├── md5.ko ├── modules.alias ├── modules.alias.bin ├── modules.builtin ├── modules.builtin.alias.bin ├── modules.builtin.bin ├── modules.dep ├── modules.dep.bin ├── modules.devname ├── modules.order ├── modules.softdep ├── modules.symbols ├── modules.symbols.bin ├── Module.symvers ├── nvp6158.ko ├── ov2680_mipi.ko ├── ov5640.ko ├── ov8858_r2a_4lane.ko ├── sha1_generic.ko ├── sp5409_mipi.ko ├── sunxi-ce.ko ├── vf-test.ko ├── xr819s.ko ├── xr829.ko ├── xradio_btlpm.ko └── xr_usb_serial_common.ko
最后总结
板子出厂的rootfs中包含的基础软件是真的很全面,基本可以做到开箱即用了,wifi驱动也已经适配了,wpa_supplicant、bluealsa、bluez、alsa、tinyalsa等工具软件也已经包含。因为目前手头没有能直接可用的显示屏,所以HMI显示和视频解码等高级功能没法体验。不过对于喜欢折腾的先适配一块触摸显示屏还是很有必要的,这样可玩性更高。
- 编译内核的交叉编译工具链
-
ubuntu 20.04 编译MQ-Dual Longan SDK
安装编译需要的依赖软件包
除了
gcc,ncurse,bison,autoconf,wget,patch,texinfo,zlib,dos2unix
之外需要安装如下:sudo apt-get install git sudo apt-get install gnupg sudo apt-get install flex sudo apt-get install bison sudo apt-get install gperf sudo apt-get install build-essential sudo apt-get install zip sudo apt-get install curl sudo apt-get install libc6-dev sudo apt-get install libncurses5-dev:i386 sudo apt-get install x11proto-core-dev sudo apt-get install libx11-dev:i386 sudo apt-get install libreadline6-dev:i386 sudo apt-get install libgl1-mesa-glx:i386 sudo apt-get install libgl1-mesa-dev sudo apt-get install g++-multilib sudo apt-get install mingw32 sudo apt-get install tofrodos sudo apt-get install python-markdown sudo apt-get install libxml2-utils sudo apt-get install xsltproc sudo apt-get install zlib1g-dev:i386 sudo apt-get install gawk sudo dpkg-reconfigure dash 选择no sudo apt-get install libgl1-mesa-dev:i386 sudo apt install u-boot-tools
参照官方文档《T113_Longan_Linux_SDK开发环境配置手册.pdf》进行编译主要差异如下
- 增加这一句
sudo apt-get install libgl1-mesa-dev:i386
同时,最后有一条ln -s
没有照做。 - 编译过程遇到报错,具体看下面的参考文档一节
- "mkimage" command not found - U-Boot images will not be built --->
sudo apt install u-boot-tools
编译过程如下:
source ./build/envsetup.sh ......... ./build.sh ....... media/qotone/Dev/SW/sdk/t113-longan/platform/framework/auto/kernel/xr829/Makefile:19: CROSS_COMPILE: arm-linux-gnueabi- Building modules, stage 2. MODPOST 1 modules CC [M] /media/qotone/Dev/SW/sdk/t113-longan/platform/framework/auto/kernel/xr829/xr829.mod.o LD [M] /media/qotone/Dev/SW/sdk/t113-longan/platform/framework/auto/kernel/xr829/xr829.ko make[1]: Leaving directory '/media/qotone/Dev/SW/sdk/t113-longan/out/kernel/build' '/media/qotone/Dev/SW/sdk/t113-longan/platform/framework/auto/kernel/xr829/xr829.ko' -> '/media/qotone/Dev/SW/sdk/t113-longan/platform/../out/t113/evb1_auto/longan/buildroot/target/lib/modules/5.4.61/xr829.ko' PARTITION_FEX=/media/qotone/Dev/SW/sdk/t113-longan/device/config/chips/t113/configs/evb1_auto/longan/sys_partition.fex ROOTFS_FEX_LINE=64 ROOTFS_FEX_STR= size = 2097152 ROOTFS_FEX_SIZE= 2097152 EXT4_SIZE=1073741824(1073741824/1024/1024) /media/qotone/Dev/SW/sdk/t113-longan/device/config/chips/t113/configs/evb1_auto/longan/sys_partition.fex rootfs.fex size is 2097152 EXT4_SIZE= 2097152*512=1073741824 Creating filesystem with parameters: Size: 1073741824 Block size: 4096 Blocks per group: 32768 Inodes per group: 8192 Inode size: 256 Journal blocks: 4096 Label: Blocks: 262144 Block groups: 8 Reserved blocks: 0 Reserved block group size: 63 Created filesystem with 7384/65536 inodes and 54559/262144 blocks /media/qotone/Dev/SW/sdk/t113-longan/build/bin/make_ext4fs -s -l 1073741824 /media/qotone/Dev/SW/sdk/t113-longan/out/t113/evb1_auto/longan/rootfs.ext4 /media/qotone/Dev/SW/sdk/t113-longan/out/t113/evb1_auto/longan/buildroot/target INFO: pack rootfs ok ... INFO: ---------------------------------------- INFO: build lichee OK. INFO: ---------------------------------------- /build.sh pack ACTION List: mkpack ;======== Execute command: mkpack INFO: packing firmware ... INFO: Use BIN_PATH: /media/qotone/Dev/SW/sdk/t113-longan/device/config/chips/t113/bin copying tools file copying configs file copying product configs file /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/aultls32.fex /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/aultools.fex /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/boot_package.cfg /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/boot_package.fex /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/boot_package_nor.cfg /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/cardscript.fex /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/cardscript_secure.fex /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/cardtool.fex /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/diskfs.fex /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/dragon_toc.cfg /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/env-recovery.cfg /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/env.cfg /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/env_ab.cfg /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/env_burn.cfg /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/env_dragon.cfg /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/env_nor.cfg /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/esm.fex /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/image.cfg /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/image_crashdump.cfg /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/image_linux.cfg /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/image_nor.cfg /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/parameter.fex /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/split_xxxx.fex /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/sunxi.fex /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/sw-subimgs-ab-rdiff.cfg /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/sw-subimgs-ab.cfg /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/sw-subimgs-recovery.cfg /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/sys_config.fex /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/sys_partition-recovery.fex /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/sys_partition.fex /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/sys_partition_ab.fex /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/sys_partition_dump.fex /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/sys_partition_nor.fex /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/sys_partition_private.fex /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/sysrecovery.fex /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/toc0.fex /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/toc1.fex /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/usbtool.fex /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/usbtool_crash.fex /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/usbtool_test.fex copying boot resource copying boot file '/media/qotone/Dev/SW/sdk/t113-longan/device/config/chips/t113/bin/boot0_nand_sun8iw20p1.bin' -> '/media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/boot0_nand.fex' '/media/qotone/Dev/SW/sdk/t113-longan/device/config/chips/t113/bin/boot0_sdcard_sun8iw20p1.bin' -> '/media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/boot0_sdcard.fex' '/media/qotone/Dev/SW/sdk/t113-longan/device/config/chips/t113/bin/boot0_spinor_sun8iw20p1.bin' -> '/media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/boot0_spinor.fex' '/media/qotone/Dev/SW/sdk/t113-longan/device/config/chips/t113/bin/fes1_sun8iw20p1.bin' -> '/media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/fes1.fex' '/media/qotone/Dev/SW/sdk/t113-longan/device/config/chips/t113/bin/u-boot-sun8iw20p1.bin' -> '/media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/u-boot.fex' '/media/qotone/Dev/SW/sdk/t113-longan/device/config/chips/t113/bin/dsp0.bin' -> '/media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/dsp0.fex' '/media/qotone/Dev/SW/sdk/t113-longan/device/config/chips/t113/bin/optee_sun8iw20p1.bin' -> '/media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/optee.fex' '/media/qotone/Dev/SW/sdk/t113-longan/device/config/chips/t113/bin/boot0_nand_sun8iw20p1.bin' -> '/media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/boot0_nand.fex' '/media/qotone/Dev/SW/sdk/t113-longan/device/config/chips/t113/bin/boot0_sdcard_sun8iw20p1.bin' -> '/media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/boot0_sdcard.fex' '/media/qotone/Dev/SW/sdk/t113-longan/device/config/chips/t113/bin/boot0_spinor_sun8iw20p1.bin' -> '/media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/boot0_spinor.fex' '/media/qotone/Dev/SW/sdk/t113-longan/device/config/chips/t113/bin/fes1_sun8iw20p1.bin' -> '/media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/fes1.fex' '/media/qotone/Dev/SW/sdk/t113-longan/device/config/chips/t113/bin/u-boot-sun8iw20p1.bin' -> '/media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/u-boot.fex' '/media/qotone/Dev/SW/sdk/t113-longan/device/config/chips/t113//bin/dsp0.bin' -> '/media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/dsp0.fex' '/media/qotone/Dev/SW/sdk/t113-longan/device/config/chips/t113/bin/optee_sun8iw20p1.bin' -> '/media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/optee.fex' copying boot file 2.0 '/media/qotone/Dev/SW/sdk/t113-longan/out/t113/evb1_auto/longan/boot0_nand_sun8iw20p1.bin' -> '/media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/boot0_nand.fex' '/media/qotone/Dev/SW/sdk/t113-longan/out/t113/evb1_auto/longan/boot0_sdcard_sun8iw20p1.bin' -> '/media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/boot0_sdcard.fex' '/media/qotone/Dev/SW/sdk/t113-longan/out/t113/evb1_auto/longan/boot0_spinor_sun8iw20p1.bin' -> '/media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/boot0_spinor.fex' '/media/qotone/Dev/SW/sdk/t113-longan/out/t113/evb1_auto/longan/fes1_sun8iw20p1.bin' -> '/media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/fes1.fex' '/media/qotone/Dev/SW/sdk/t113-longan/out/t113/evb1_auto/longan/sboot_sun8iw20p1.bin' -> '/media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/sboot.bin' '/media/qotone/Dev/SW/sdk/t113-longan/out/t113/evb1_auto/longan/u-boot-sun8iw20p1.bin' -> '/media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/u-boot.fex' copying additional files /media/qotone/Dev/SW/sdk/t113-longan/out/t113/evb1_auto/longan/.sunxi.dts: Warning (alias_paths): /aliases: aliases property name must include only lowercase and '-' dbg1 pack /media/qotone/Dev/SW/sdk/t113-longan/out/t113/evb1_auto/longan/dtc -W no-unit_address_vs_reg -W no-simple_bus_reg -W no-unique_unit_address -W no-cooling_device_property -W no-unit_address_format -I dtb -O dts -o /media/qotone/Dev/SW/sdk/t113-longan/out/t113/evb1_auto/longan/.sunxi.dts /media/qotone/Dev/SW/sdk/t113-longan/out/t113/evb1_auto/longan/sunxi.dtbs update optee sboot file Path=/media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/sboot.bin script file Path=/media/qotone/Dev/SW/sdk/t113-longan/out/pack_out/sys_config.bin extd_head.select_mode:0 magic:$�� �� script update sboot ok pack boot package GetPrivateProfileSection read to end content_count=3 --mkenvimage create redundant env data!-- --redundant env data size 0x20000--- packing for linux normal this is not a partition key gpt_head->header_crc32 = 0x3e898e5f GPT----part num 8--- gpt_entry: 128 gpt_header: 92 GPT:boot-resource: 8000 10685 GPT:env : 10686 10e85 GPT:env-redund : 10e86 11685 GPT:boot : 11686 1a005 GPT:rootfs : 1a006 21a005 GPT:dsp0 : 21a006 21a805 GPT:private : 21a806 222805 GPT:UDISK : 222806 222815 update gpt file ok update mbr file ok /media/qotone/Dev/SW/sdk/t113-longan/tools/pack/pctools/linux/eDragonEx/ /media/qotone/Dev/SW/sdk/t113-longan/out/pack_out Begin Parse sys_partion.fex Add partion boot-resource.fex BOOT-RESOURCE_FEX Add partion very boot-resource.fex BOOT-RESOURCE_FEX FilePath: boot-resource.fex FileLength=dad400Add partion env.fex ENV_FEX000000000 Add partion very env.fex ENV_FEX000000000 FilePath: env.fex FileLength=20000Add partion env.fex ENV_FEX000000000 Add partion very env.fex ENV_FEX000000000 FilePath: env.fex FileLength=20000Add partion boot.fex BOOT_FEX00000000 Add partion very boot.fex BOOT_FEX00000000 FilePath: boot.fex FileLength=10db000Add partion rootfs.fex ROOTFS_FEX000000 Add partion very rootfs.fex ROOTFS_FEX000000 FilePath: rootfs.fex FileLength=c636270Add partion dsp0.fex DSP0_FEX00000000 Add partion very dsp0.fex DSP0_FEX00000000 FilePath: dsp0.fex FileLength=3fc78sys_config.fex Len: 0x2355 board.fex Len: 0x400 config.fex Len: 0x1400 split_xxxx.fex Len: 0x200 sys_partition.fex Len: 0xc21 sunxi.fex Len: 0xe800 boot0_nand.fex Len: 0xc000 boot0_sdcard.fex Len: 0xc000 u-boot.fex Len: 0xec000 u-boot-crash.fex Len: 0x25 toc1.fex Len: 0x8 toc0.fex Len: 0x8 fes1.fex Len: 0x4bc0 boot_package.fex Len: 0x140000 usbtool.fex Len: 0x2d200 usbtool_crash.fex Len: 0x1ec00 aultools.fex Len: 0x288b7 aultls32.fex Len: 0x2511f cardtool.fex Len: 0x11e00 cardscript.fex Len: 0x6de sunxi_gpt.fex Len: 0x2000 sunxi_mbr.fex Len: 0x10000 dlinfo.fex Len: 0x4000 arisc.fex Len: 0x6 vmlinux.fex Len: 0x36ba88b boot-resource.fex Len: 0xdad400 Vboot-resource.fex Len: 0x4 env.fex Len: 0x20000 Venv.fex Len: 0x4 env.fex Len: 0x20000 Venv.fex Len: 0x4 boot.fex Len: 0x10db000 Vboot.fex Len: 0x4 rootfs.fex Len: 0xc636270 Vrootfs.fex Len: 0x4 dsp0.fex Len: 0x3fc78 Vdsp0.fex Len: 0x4 BuildImg 0 Dragon execute image.cfg SUCCESS ! ----------image is at---------- size:288M /media/qotone/Dev/SW/sdk/t113-longan/out/t113_linux_evb1_auto_uart0.img pack finish
使用过程中遇到的问题
- 使用官方windows烧录工具烧写tf卡默认是选择的量产卡,应该选择启动卡
参考文档
- 增加这一句