板子做工精致很有份量,拿在手里沉甸甸的,各种接口一应俱全——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开发环境搭建解压SDKcat 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 gitsudo apt-get install gnupgsudo apt-get install flexsudo apt-get install bisonsudo apt-get install gperfsudo apt-get install build-essentialsudo apt-get install zipsudo apt-get install curlsudo apt-get install libc6-devsudo apt-get install libncurses5-dev:i386sudo apt-get install x11proto-core-devsudo apt-get install libx11-dev:i386sudo apt-get install libreadline6-dev:i386sudo apt-get install libgl1-mesa-glx:i386sudo apt-get install libgl1-mesa-devsudo apt-get install g++-multilibsudo apt-get install mingw32sudo apt-get install tofrodossudo apt-get install python-markdownsudo apt-get install libxml2-utilssudo apt-get install xsltprocsudo apt-get install zlib1g-dev:i386sudo apt-get install gawksudo dpkg-reconfigure dash 选择nosudo apt-get install libgl1-mesa-dev:i386sudo apt install u-boot-tools初次编译内核./build.sh configWelcome to mkscript setup progressAll available platform: 0. linuxChoice [linux]: 0All available board: 0. ok113iChoice [ok113i]: 0All available flash: 0. default 1. nor 2. nandChoice [default]: 0All available display_type: 0. tvout_pal 1. tvout_ntsc 2. lcd_800x480 3. lcd_1024x600 4. mipi_1024x600 5. lvds_1280x800Choice [tvout_pal]: 2Relocating 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 syntaxERROR: Can't find kernel defconfig!python 报系统库语法错误,根据经验是系统python版本问题,首先查看系统中python版本号 python --versionPython 3.8.10不出意外的话编译系统依赖python 2.7,所以切换到python 2.7版本,具体操作如下:
首先,查看系统有几个python版本 update-alternatives --list python/usr/bin/python2/usr/bin/python3然后,通过如下切换到想要的版本 update-alternatives --config pythonThere 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 --versionPython 2.7.18最后再试一次: ./build.sh configWelcome to mkscript setup progressAll available platform: 0. linuxChoice [linux]: 0All available board: 0. ok113iChoice [ok113i]: 0All available flash: 0. default 1. nor 2. nandChoice [default]: 0All available display_type: 0. tvout_pal 1. tvout_ntsc 2. lcd_800x480 3. lcd_1024x600 4. mipi_1024x600 5. lvds_1280x800Choice [lcd_1024x600]: 2This buildroot SDK has already been relocated!/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdkINFO: 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/MakefileConfig.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 kernelACTION List: mkkernel;========Execute command: mkkernel INFO: build kernel ...INFO: prepare_buildserverINFO: 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.xzbuild 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 .configUsing 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 drivermake: Entering directory '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/kernel/linux-5.4/modules/nand'[NAND] NOT buid as komake: 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 komake: Leaving directory '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/kernel/linux-5.4/modules/nand'[NAND]: Build done[ GPU]: Build module drivermake: Entering directory '/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/kernel/linux-5.4/modules/gpu'Nothing to do for unsupport configurationmake: 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 configurationmake: 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 blocks25241 blocksbuild_ramfsCopy boot.img to output directory ...sun8iw20p1 compile Kernel successfulINFO: 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.xzUsing 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.dtbmake[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 rootfsPARTITION_FEX=/home/luoyang/Dev/sdk/T113-i/OK113i-linux-sdk/device/config/chips/t113_i/configs/ok113i/longan/sys_partition.fexROOTFS_FEX_LINE=64ROOTFS_FEX_STR= size = 2097152ROOTFS_FEX_SIZE= 2097152EXT4_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 2097152EXT4_SIZE= 2097152*512=1073741824Creating 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: 63Created 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显示和视频解码等高级功能没法体验。不过对于喜欢折腾的先适配一块触摸显示屏还是很有必要的,这样可玩性更高。
|