libusb 串口 android,rk3399pro通过修改内核&编译支持luat air720上网及串口通讯

编译环境:ubuntu 18.0.4的PC机

一、安装编译依赖库

sudo apt-get install repo git-core gitk git-gui gcc-arm-linux-gnueabihf u-boot-tools device-tree-compiler \

gcc-aarch64-linux-gnu mtools parted libudev-dev libusb-1.0-0-dev python-linaro-image-tools \

linaro-image-tools gcc-4.8-multilib-arm-linux-gnueabihf gcc-arm-linux-gnueabihf libssl-dev \

gcc-aarch64-linux-gnu g+conf autotools-dev libsigsegv2 m4 intltool libdrm-dev curl sed make \

binutils build-essential gcc g++ bash patch gzip bzip2 perl tar cpio python unzip rsync file bc wget \

libncurses5 libqt4-dev libglib2.0-dev libgtk2.0-dev libglade2-dev cvs git mercurial rsync openssh-client \

subversion asciidoc w3m dblatex graphviz python-matplotlib libc6:i386 libssl-dev texinfo \

liblz4-tool genext2fs lib32stdc++6

二、下载gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu

wget http://releases.linaro.org/components/toolchain/binaries/6.3-2017.05/aarch64-linux-gnu/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu.tar.xz

三、下载rk339pro内核源码

git clone https://github.com/rockchip-toybrick/kernel

四、修改内核源文件

修改make.sh(注意改成gcc-linaro的路径)

#!/bin/bash

VERSION="2.0"

JOB=`sed -n "N;/processor/p" /proc/cpuinfo|wc -l`

DTB=toybrick-$2

TKCC=/data/software/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-

function help()

{

echo "Usage: ./make.sh os board"

echo

echo "Parameter:"

echo "1) os: should be android or linux"

echo "2) board:"

echo " - prod: TB-RK3399ProD"

echo " - prop: TB-RK3399ProP"

echo " - prox: TB-RK3399ProX"

echo " - 96ai: TB-96AI"

echo

echo "e.g. ./make.sh android prod"

echo " ./make.sh android prop"

echo " ./make.sh android 96ai"

echo " ./make.sh android prox"

echo " ./make.sh linux prod"

echo " ./make.sh linux prop"

echo " ./make.sh linux 96ai"

echo " ./make.sh linux prox"

}

function make_extlinux_conf()

{

echo "label rockchip-kernel-4.4" > boot_linux/extlinux/extlinux.conf

echo " kernel /extlinux/Image" >> boot_linux/extlinux/extlinux.conf

echo " fdt /extlinux/toybrick.dtb" >> boot_linux/extlinux/extlinux.conf

echo " append earlycon=uart8250,mmio32,0xff1a0000 initrd=/initramfs-toybrick-${VERSION}.img root=PARTUUID=614e0000-0000-4b53-8000-1d28000054a9 rw rootwait rootfstype=ext4" >> boot_linux/extlinux/extlinux.conf

}

if [ $# -lt 2 ];then

help

exit 1

fi

case $1 in

android)

make rockchip_defconfig

make ARCH=arm64 rk3399pro-${DTB}-android.img -j${JOB}

;;

linux)

rm -rf boot_linux

mkdir -p boot_linux/extlinux

make rockchip_linux_defconfig

case $2 in

prod)

DTB=rk3399pro-toybrick-prod-linux

make ARCH=arm64 ${DTB}-edp.img CROSS_COMPILE=${TKCC} -j${JOB}

make ARCH=arm64 ${DTB}-mipi.img CROSS_COMPILE=${TKCC} -j${JOB}

cp -f arch/arm64/boot/dts/rockchip/${DTB}-edp.dtb boot_linux/extlinux/toybrick-edp.dtb

cp -f arch/arm64/boot/dts/rockchip/${DTB}-mipi.dtb boot_linux/extlinux/toybrick-mipi.dtb

;;

prop)

DTB=rk3399pro-toybrick-prop-linux

;;

96ai)

DTB=rk3399pro-toybrick-96ai-linux

;;

prox)

DTB=rk3399pro-toybrick-prox-linux

make ARCH=arm64 ${DTB}-edp.img -j${JOB}

make ARCH=arm64 ${DTB}-mipi.img -j${JOB}

cp -f arch/arm64/boot/dts/rockchip/${DTB}-edp.dtb boot_linux/extlinux/toybrick-edp.dtb

cp -f arch/arm64/boot/dts/rockchip/${DTB}-mipi.dtb boot_linux/extlinux/toybrick-mipi.dtb

;;

*)

help

exit 1

;;

esac

make ARCH=arm64 ${DTB}.img CROSS_COMPILE=${TKCC} -j${JOB}

cp -f arch/arm64/boot/dts/rockchip/${DTB}.dtb boot_linux/extlinux/toybrick.dtb

cp -f arch/arm64/boot/dts/rockchip/${DTB}.dtb boot_linux/extlinux/toybrick-default.dtb

cp -f arch/arm64/boot/Image boot_linux/extlinux/

make_extlinux_conf

cp -f initramfs-toybrick-${VERSION}.img boot_linux/

cp -f rescue.sh boot_linux/

if [ "`uname -i`" == "aarch64" ]; then

echo y | mke2fs -b 4096 -d boot_linux -i 8192 -t ext2 boot_linux.img $((64 * 1024 * 1024 / 4096))

else

genext2fs -b 32768 -B $((64 * 1024 * 1024 / 32768)) -d boot_linux -i 8192 -U boot_linux.img

fi

;;

*)

help

exit 1

;;

esac

exit 0

Add VID add PID

File: [KERNEL]/drivers/usb/serial/option.c

static const struct option_blacklist_info longssung_u9300_blacklist = {

.reserved = BIT(4),

};

*/

/********************************************************************/

static const struct usb_device_id option_ids[] = {

//+add by airm2m for Air72x

{ USB_DEVICE(0x1286, 0x4e3d) },

//-add by airm2m for Air72x

{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },

{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },

{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) },

{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_QUAD) },

{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_QUAD_LIGHT) },

{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_NDIS) },

五、编译

初次编译大约5分钟左右

./make.sh linux prod

编译完成后根目录会有内核镜像:boot_linux.img

六、下载内核

使用官方工具 AndroidTool_Release_v2.64,将上一步编译好的内核下载至rk3399pro(可以只下载boot_linux.img)

image.png

7、网络参数设置

一切编译好之后,将air720D插入rk3399pro的mini pcie口并且把sim卡插入(注意别把sim卡插反了)

启动后查看设备

ls /dev/ttyUSB*

设置网络参数:

设置网卡1 内网ip /etc/network/interfaces

# interfaces(5) file used by ifup(8) and ifdown(8)

# Include files from /etc/network/interfaces.d:

source-directory /etc/network/interfaces.d

auto lo

#开机自动连接网络

auto eth0

iface lo inet loopback

allow-hotplug eth0

#static表示使用固定ip,dhcp表述使用动态ip

iface eth0 inet static

#设置ip地址

address 192.168.1.8

netmask 255.255.255.0

gateway 192.168.1.1

dns-nameservers 114.114.114.114 8.8.8.8

此时查看ifconfig ,如果没有出现 rndis_host 1-1:1.0 eth1 中的 eth1 ,则发送ifconfig -a ,此时发现有eth1 但是 没有ip 地址,发送 udhcpc -i eth1 出现地址后,即可使用此网卡进行上网

#下载

sudo apt install udhcpc

#执行

udhcpc -i eth1

出现地址后,即可使用此网卡进行上网

八、通讯air720获取iccid和imei

#可用minicom工具

sudo apt install minicom

#打开串口

sudo minicom -D /dev/ttyUSB1

九、参考:

你可能感兴趣的:(libusb,串口,android)