当前位置:   article > 正文

全志开发板,自用linux的常用方法(持续更新20231221)_dx0960be40a1

dx0960be40a1

查看当前目录下大小

du -h -d=1

查找 打包解压

grep -nwr “mipi” ./
find ./ -name mipi
find . -name “Kconfig” | xargs grep -n “MIPI

tar -jcvf jclvgl_20221108.tar.bz2 ./jclvgl 打包
tar -jxvf 解压

tar -zcvf sunxi-vin-2022-11-15.tar.bz2 ./sunxi-vin/*

*.tar 用 tar –xvf 解压

制作一个全新镜像

1 获取ubantu18镜像,可以直接copy韦东山的空白镜像使用,密码123456
2 添加双网卡(一个网卡桥接到物理网口,用于烧写拷贝文件到核心板;另一个网卡用于shell通讯或上网。),其中一个网卡桥接模式,注意虚拟机网卡直连根据需要选择对应硬件,ip固定为192.168.5.50 网关192.168.5.1 子网掩码255.255.255.0
3 添加root外部控制 设置root 密码 123456
sudo passwd root
su root
sudo gedit /etc/ssh/sshd_config
在文件中找到#PermitRootLogin prohibit-password,将它改为PermitRootLogin yes
修改完成之后,重启ssh服务:/etc/init.d/ssh restart
确认时区 timedatectl
修改时区 sudo timedatectl set-timezone Asia/Shanghai
4 将linux源代码copy到ubantu
将开发环境copy到乌班图
将一个配套的环境配置.sh文件copy到ubantu

ubuntu_env_install.sh 文件
add-apt-repository ppa:openjdk-r/ppa
apt-get update
echo y | apt-get install openjdk-8-jdk
echo y | apt-get install m4
echo y | apt-get install bison
echo y | apt-get install zlib1g-dev
echo y | apt-get install g+±multilib gcc-multilib lib32ncurses5-dev
echo y | apt-get install lib32readline-gplv2-dev lib32z1-dev
echo y | apt-get install lzop
echo y | apt-get install u-boot-tools
echo y | apt-get install libxml2-utils
echo y | apt-get install jack
echo y | apt-get install libz-dev
echo y | apt-get install lib32z1-dev
echo y | apt-get install gnupg flex gperf
echo y | apt-get install genext2fs
echo y | apt-get install android-tools-fastboot
echo y | apt-get install gawk
echo y | apt-get install curl

5 执行 ubuntu_env_install.sh 注意需要一个回车
执行 tar xvf T507-gcc-linaro-7.4.1-Qt5.9.0.tar.bz2 -C /
执行 tar xvf TQT507_linux_V1.2.tar.bz2 -C /

针对1.0版本的多个压缩包的解压方式
解压linux源码相关(内核文件被搞成了两个压缩包,经过探索,发现这个解压方式可行)
sudo cat TQT507_linux_V1.0.tar.* | sudo tar -jxv -C /

6 配置环境(开发板的环境)
sudo gedit /etc/environment
path后面追加
/opt/EmbedSky/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu/bin:/opt/EmbedSky/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu/qt_env/qt59.0/bin/

生效文件source /etc/environment
检测版本号 aarch64-linux-gnu-gcc -v

配置qt环境 (ubantu18配置失败,再议)
sudo gedit /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf
将第一行的/usr/bin/qmake 替换为交叉编译器中 qmake 的路径
/opt/EmbedSky/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu/qt_env/qt5.9.0/bin/
/usr/lib/x86_64-linux-gnu
执行 qmake -v
7 首次编译镜像(最新版镜像有.config文件和.config.old文件)
#整个工程(源代码的目录)
cd /opt/EmbedSky/TQT507/CoreA/longan/
sudo ./build.sh config 1.linux->2.longan->0.t507->2.evb->0.default
sudo ./build.sh brandy
cd /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/
cp .config .config.old
sudo ./build.sh
sudo ./build.sh pack
8 转移文件 mipi ffmpeg pro jclvgl 推荐将pro文件整体压缩再移动然后根据需要重新make
tar -jcvf jclvgl.tar.bz2 ./jclvgl 打包
tar -jxvf jclvgl.tar.bz2 解压
tar -zcvf 压缩文件名.tar.gz 被压缩文件名
tar -zxvf 压缩文件名.tar.gz

9 驱动 mipi,修改部分文件 先保存原始的,编译时候可能出现部分错误,注意修正部分源码
tar -jcvf sunxi-vin-tqt507.tar.bz2 ./sunxi-vin
8 库 ffmpeg 详情参考编译
make clean && make -j4 && make install
9 应用 lvgl
make clean && make -j4
10 打包应用,修改启动文件
cd /opt/EmbedSky/TQT507/CoreA/longan

替换部分文件kernel/linux-4.9/drivers/video/fbdev/sunxi/disp2/disp

动态库
cp /root/jclvgl/lib/libswscale.so.6.8.112 /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/usr/lib/
cp /root/jclvgl/lib/libswresample.so.4.9.100 /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/usr/lib/
cp /root/jclvgl/lib/libavutil.so.57.37.100 /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/usr/lib/
cp /root/jclvgl/lib/libavformat.so.59.33.100 /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/usr/lib/
cp /root/jclvgl/lib/libavdevice.so.59.8.101 /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/usr/lib/
cp /root/jclvgl/lib/libavcodec.so.59.48.100 /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/usr/lib/

cd /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/usr/lib/

rm -rf libavcodec.so.59
rm -rf libavcodec.so
rm -rf libavformat.so.59
rm -rf libavformat.so
rm -rf libavutil.so.57
rm -rf libavutil.so
rm -rf libswscale.so.6
rm -rf libswscale.so
rm -rf libswresample.so.4
rm -rf libswresample.so
rm -rf libavdevice.so.59
rm -rf libavdevice.so

ln -s ./libavcodec.so.59.48.100 libavcodec.so.59
ln -s ./libavcodec.so.59.48.100 libavcodec.so
ln -s ./libavformat.so.59.33.100 libavformat.so.59
ln -s ./libavformat.so.59.33.100 libavformat.so
ln -s ./libavutil.so.57.37.100 libavutil.so.57
ln -s ./libavutil.so.57.37.100 libavutil.so
ln -s ./libswscale.so.6.8.112 libswscale.so.6
ln -s ./libswscale.so.6.8.112 libswscale.so
ln -s ./libswresample.so.4.9.100 libswresample.so.4
ln -s ./libswresample.so.4.9.100 libswresample.so
ln -s ./libavdevice.so.59.8.101 libavdevice.so.59
ln -s ./libavdevice.so.59.8.101 libavdevice.so

启动文件 静态文件初始化
/opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/root/

设备树修改
cd /opt/EmbedSky/TQT507/CoreA/longan/device/config/chips/t507/configs/evb/
fb0_width -> 0 fb0_height -> 0
选择对应的dts文件, 填充对应屏幕信息

启动

初始化ssh

ifconfig eth0 down
ifconfig eth1 192.168.5.8 up
ifconfig

修改系统时间,修改密码远程登陆失败,需要修改系统时间,修改密码,将系统时间同步到硬件时间
date -s 2023-05-25
date -s 18:00:30
hwclock -w
ifconfig eth1 192.168.5.8 up
passwd root

使用SD卡传文件

mount /dev/mmcblk1p1 /mnt &&
cp /mnt/jclvgldemo /root/ &&
chmod +x /root/jclvgldemo &&
cd /root/ &&
./jclvgldemo

开机logo目录

/opt/EmbedSky/TQT507/CoreA/longan/device/config/chips/t507/boot-resource/boot-resource/
注意开机logo色彩数限制在224,因此需要将一般的图片进行转化
具体参考
https://blog.csdn.net/weixin_43782998/article/details/112283499?utm_medium=distribute.wap_relevant.none-task-blog-2defaultbaidujs_title~default-13-112283499-blog-87876573.wap_blog_relevant_default&spm=1001.2101.3001.4242.8&utm_relevant_index=14

此处转化比较复杂
pngtopnm linuxlogo.png >linuxlogo.pnm //将png转换成pnm
pnmquant 224 linuxlogo.pnm> linuxlogo224.pnm //将pnm图片的颜色数限制在224
pnmtoplainpnm linuxlogo224.pnm > linuxlogo224.ppm //将pnm图片转换成最终的ppm

最后将ppm文件下载下来,利用网页在线转化为 bmp 格式
https://onlineconvertfree.com/zh/convert/ppm/

经过测试,发现以下网站可以直接将png转bmp
https://cdkm.com/cn/png-to-bmp

官方提供的SDK方法库

/opt/EmbedSky/TQT507/CoreA/longan/platform/framework/auto/sdk_lib
cd /opt/EmbedSky/TQT507/CoreA/longan
grep -nwr “sensor_dma_buffer_alloc” ./

编译configure ffmpeg

X264交叉编译
./configure --enable-shared --enable-static --host=aarch64-linux-gnu --cross-prefix=aarch64-linux-gnu- --disable-opencl --enable-pic --disable-asm --prefix=$PWD/_install

make

make install

export PKG_CONFIG_PATH=/root/pro/ffmpeg/x264/lib/pkgconfig

/opt/EmbedSky/TQT507/CoreA/longan

–extra-ldflags指定库文件目录
–extra-cflags 指定头文件目录
–enable-shared 生成动态库
编译ffmpeg

git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg

./configure --help

//先disable//在根据需要添加对应的库–enable-libx264
./configure --disable-all --disable-autodetect --disable-podpages --disable-asm --enable-avcodec --enable-avformat --enable-decoders --enable-encoders --enable-demuxers --enable-parsers --enable-protocol=‘file’ --enable-swscale --enable-avdevice --enable-swresample --enable-ffplay --enable-ffmpeg --enable-version3 --enable-gpl --enable-nonfree --enable-ffprobe --enable-zlib --cc=aarch64-linux-gnu-gcc --strip=aarch64-linux-gnu-strip --arch=arm64 --prefix=/root/jclvgl_2023_01_31 --enable-cross-compile --enable-shared --extra-ldflags=“-L/opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/host/lib -L/opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/usr/lib -L/opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/lib -L/root/pro/pkg-config-0.29.2/glib” --extra-cflags=“-I/opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/host/include/ -I/opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/host/aarch64-buildroot-linux-gnu/sysroot/usr/include”

//zcl 修改的配置方案
//–disable-armv5te --disable-armv6 --disable-armv6t2
// --enable-libfreetype --enable-postproc
./configure --enable-shared --disable-static --disable-autodetect --disable-podpages --disable-asm --enable-gpl --enable-nonfree --enable-ffplay --enable-swscale --enable-pthreads --disable-x86asm --enable-libx264 --enable-avcodec --enable-avformat --enable-encoders --enable-demuxers --enable-parsers --enable-protocol=‘file’ --enable-swscale --enable-avdevice --enable-swresample --enable-ffplay --enable-ffmpeg --enable-version3 --target-os=linux --enable-zlib --disable-ffprobe --cc=aarch64-linux-gnu-gcc --strip=aarch64-linux-gnu-strip --arch=arm64 --prefix=/root/jclvgl_2023_01_31 --enable-cross-compile --extra-ldflags=“-L/opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/host/lib -L/opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/usr/lib -L/opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/lib -L/root/pro/pkg-config-0.29.2/glib” --extra-cflags=“-I/opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/host/include/ -I/opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/host/aarch64-buildroot-linux-gnu/sysroot/usr/include”

make clean && make -j4 && make install

参考
./configure -prefix= D E S T L I B D I R − − e x t r a − c f l a g s = − I {DEST_LIB_DIR} --extra-cflags=-I DESTLIBDIRextracflags=I{DEST_LIB_DIR}/include --extra-cflags=-I D E S T L I B D I R / i n c l u d e / f r e e t y p e 2 − − e x t r a − l d f l a g s = − L {DEST_LIB_DIR}/include/freetype2 --extra-ldflags=-L DESTLIBDIR/include/freetype2extraldflags=L{DEST_LIB_DIR}/lib

编译后copy到开发板

cp /root/jclvgl/lib/libswscale.so.6.8.112 /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/usr/lib/
cp /root/jclvgl/lib/libswresample.so.4.9.100 /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/usr/lib/
cp /root/jclvgl/lib/libavutil.so.57.37.100 /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/usr/lib/
cp /root/jclvgl/lib/libavformat.so.59.33.100 /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/usr/lib/
cp /root/jclvgl/lib/libavdevice.so.59.8.101 /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/usr/lib/
cp /root/jclvgl/lib/libavcodec.so.59.48.100 /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/usr/lib/

cd /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/usr/lib/

//zhou add…
rm -rf libavcodec.so.59
rm -rf libavcodec.so
rm -rf libavformat.so.59
rm -rf libavformat.so
rm -rf libavutil.so.57
rm -rf libavutil.so
rm -rf libswscale.so.6
rm -rf libswscale.so
rm -rf libswresample.so.4
rm -rf libswresample.so
rm -rf libavdevice.so.59
rm -rf libavdevice.so
rm -rf libavfilter.so
rm -rf libavfilter.so.8
rm -rf libpostproc.so
rm -rf libpostproc.so.56
rm -rf libx264.so

ln -s ./libavcodec.so.59.63.100 libavcodec.so.59
ln -s ./libavcodec.so.59.63.100 libavcodec.so
ln -s ./libavformat.so.59.38.100 libavformat.so.59
ln -s ./libavformat.so.59.38.100 libavformat.so
ln -s ./libavutil.so.57.44.100 libavutil.so.57
ln -s ./libavutil.so.57.44.100 libavutil.so
ln -s ./libswscale.so.6.8.112 libswscale.so.6
ln -s ./libswscale.so.6.8.112 libswscale.so
ln -s ./libswresample.so.4.9.100 libswresample.so.4
ln -s ./libswresample.so.4.9.100 libswresample.so
ln -s ./ libavdevice.so.59.8.101 libavdevice.so.59
ln -s ./ libavdevice.so.59.8.101 libavdevice.so
ln -s ./libavfilter.so.8.56.100 libavfilter.so
ln -s ./libavfilter.so.8.56.100 libavfilter.so.8
ln -s ./libpostproc.so.56.7.100 libpostproc.so
ln -s ./libpostproc.so.56.7.100 libpostproc.so.56
ln -s ./libx264.so.164 libx264.so

编译后copy到开发板
cp -r * /home/book/nfs_rootfs/lib
cp -r * /usr/lib
cd /usr/lib

cp libswscale.so.6.8.112 /root/jclvgl_2023_01_31/lib
cp libswresample.so.4.9.100 /root/jclvgl_2023_01_31/lib
cp libavutil.so.57.37.100 /root/jclvgl_2023_01_31/lib
cp libavformat.so.59.33.100 /root/jclvgl_2023_01_31/lib
cp libavdevice.so.59.8.101 /root/jclvgl_2023_01_31/lib
cp libavcodec.so.59.48.100 /root/jclvgl_2023_01_31/lib

cp libswscale.so.6.8.112 /usr/lib/
cp libswresample.so.4.9.100 /usr/lib/
cp libavutil.so.57.37.100 /usr/lib/
cp libavformat.so.59.33.100 /usr/lib/
cp libavdevice.so.59.8.101 /usr/lib/
cp libavcodec.so.59.48.100 /usr/lib/

编译后copy到开发板
cp libswscale.so.6.8.112 /home/book/nfs_rootfs/lib
cp libswresample.so.4.9.100 /home/book/nfs_rootfs/lib
cp libavutil.so.57.37.100 /home/book/nfs_rootfs/lib
cp libavformat.so.59.33.100 /home/book/nfs_rootfs/lib
cp libavdevice.so.59.8.101 /home/book/nfs_rootfs/lib
cp libavcodec.so.59.48.100 /home/book/nfs_rootfs/lib

编译内核

编译内核

解压linux源码相关(内核文件被搞成了两个压缩包,经过探索,发现这个解压方式可行)
sudo cat TQT507_linux_V1.0.tar.* | sudo tar -jxv -C /

tar -zxvf libpng-1.6.38.tar.gz

tar -jcvf uboot.tar.bz2 u-boot-2018/ 打包镜像
tar -jcvf jclvgl_20221108.tar.bz2 ./jclvgl

tar -jxvf 解压

cd /opt/EmbedSky/TQT507/CoreA/longan/

编译 u-boot
sudo ./build.sh brandy
编译longan
sudo ./build.sh config
编译内核
cd ./kernel/linux-4.9
sudo cp ./config-tq-coreA-linux .config
cd /opt/EmbedSky/TQT507/CoreA/longan
sudo ./build.sh kernel
编译 buildroot
cd ./buildroot/buildroot-201902/
sudo cp config-tq-coreA-linux …/…/out/t507/evb/longan/buildroot/.config
cd /opt/EmbedSky/TQT507/CoreA/longan
sudo ./build.sh
打包镜像
sudo ./build.sh pack

#系统编译 四分钟左右
cd /opt/EmbedSky/TQT507/CoreA/longan/
sudo ./build.sh brandy
sudo ./build.sh kernel
sudo ./build.sh
sudo ./build.sh pack

修改内核配置

cd /opt/EmbedSky/TQT507/CoreA/longan/
cd ./kernel/linux-4.9
make menuconfig ARCH=arm64

注意这个地方耗时

kernel:Device Drivers > Network device support > Wireless LAN

修改bulidroot

cd /opt/EmbedSky/TQT507/CoreA/longan/
cd ./buildroot/buildroot-201902/
cp config-tq-coreA-linux …/…/out/t507/evb/longan/buildroot/.config
make menuconfig ARCH=arm64 O=…/…/out/t507/evb/longan/buildroot/

注意开启这个开关,不然无法开启ssh

Target packages > Networking applications > openssh
系统编译 四分钟左右
cd /opt/EmbedSky/TQT507/CoreA/longan/
sudo ./build.sh brandy
sudo ./build.sh kernel
sudo ./build.sh
sudo ./build.sh pack

cd /opt/EmbedSky/TQT507/CoreA/longan/ && sudo ./build.sh && sudo ./build.sh pack

cd /opt/EmbedSky/TQT507/CoreA/longan/
sudo ./build.sh brandy
sudo ./build.sh kernel && sudo ./build.sh && sudo ./build.sh pack

cd /opt/EmbedSky/TQT507/CoreA/longan/
sudo ./build.sh brandy
sudo ./build.sh
sudo ./build.sh pack

cd /opt/EmbedSky/TQT507/CoreA/longan/
sudo ./build.sh brandy && sudo ./build.sh pack

cd /opt/EmbedSky/TQT507/CoreA/longan/
sudo ./build.sh && sudo ./build.sh pack

tick_printf(“func:%s \t line:%d\n”, func,LINE);
tick_printf(“func:%s \t line:%d \tval:%d\n”, func,LINE,val);

开机第一个脚本位置
/opt/EmbedSky/TQT507/CoreA/longan/platform/framework/auto/rootfs/etc/init.d/rcS
可将app启动有关的驱动先挂载,把app启动放置在第一位
(或者驱动在使用时进行挂载)
/opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target
/opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/root
驱动挂载
//
应用程序调节
cd /root
nohup ./jclvgldemo >/dev/null &
声音调节
tinymix “LINEOUT volume” “31”
tinymix “digital volume” “0”

Ini文件屏幕
Ini文件屏幕rbg5英寸 854*480
[panel_lcd]
x_lcd = 480
y_lcd = 854
pix_clk_lcd = 33600
hbp_lcd = 60
hfp_lcd = 60
hsw_lcd = 30
vbp_lcd = 25
vfp_lcd = 25
vsw_lcd = 10
rgb_lcd = 24

Ini文件屏幕10英寸rgb 1024*600
[panel_lcd]
x_lcd = 1024
y_lcd = 600
pix_clk_lcd = 51200
hbp_lcd = 25
hfp_lcd = 75
hsw_lcd = 20
vbp_lcd = 10
vfp_lcd = 10
vsw_lcd = 10
rgb_lcd = 24

Ini文件屏幕10英寸单路lvds 800*1280
[panel_lvds]
x_lvds=800
y_lvds=1280
pix_clk_lvds=60000
hbp_lvds=80
hfp_lvds=80
hsw_lvds=20
vbp_lvds=20
vfp_lvds=20
vsw_lvds=5
rgb_lvds=24
bpp_lvds=32
pass_lvds=split
mode_lvds=ns

设备树位置

cd /opt/EmbedSky/TQT507/CoreA/longan/device/config/chips/t507/configs/evb/
/opt/EmbedSky/TQT507/CoreA/longan/device/config/chips/t507/configs/evb/board.dts

开发板设备树反编译

FDT反编译
1、反编译工具 DTC
ubuntu执行DTC命令,如果没有安装会有下面提示
dtc

Command ‘dtc’ not found, but can be installed with:

sudo snap install device-tree-compiler # version 1.6.1, or
sudo apt install device-tree-compiler

See ‘snap info device-tree-compiler’ for additional versions.

如果是android的话prebuilts和out目录中也有dtc:

prebuilts/misc/linux-x86/dtc

out/host/linux-x86/bin

按提示安装dtc,安装完用dtc -h查看帮助

2、目标文件
可以从设备中获取
/sys/firmware/fdt

3、DTC命令参数
dtc编译器可以把dts文件编译成为dtb,也可把dtb编译成为dts文件,编译命令格式如下:

dtc [-I input-format] [-O output-format][-o output-filename] [-V output_version] input_filename
参数说明:
input-format:

“dtb”: “blob” format

“dts”: “source” format.

output-format:

“dtb”: “blob” format

“dts”: “source” format

output_version:
定义”blob”的版本,在dtb文件的字段中有表示,支持1 2 3和16,默认是3

4、反编译
dtc -I dtb -O dts fdt -o test.dtsi
-I 输入格式 dtb
-O 输出格式 dts
-o 输出文件名 test.dtsi
fdt输入文件

设备树中屏幕信息修改

关于屏幕显示,可以直接修改设备树信息 详细操作可以参考
lcd_ht 行时间 = hbp+hfp+hspw+lcd_x
lcd_vt 场时间 = vbp+vfp+vspw+lcd_y
此处与配置文件有不同之处

开发手册-内核 gt9xx@5d
lvds使用
/opt/EmbedSky/TQT507/CoreA/longan/device/config/chips/t507/configs/evb/board-coreA_lvds.dts

		fb0_format               = <0>;
		fb0_width                = <0>;
		fb0_height               = <0>;
  • 1
  • 2
  • 3

800*1280 lvds屏幕定义如下
lcd_x = <800>;
lcd_y = <1280>;
lcd_dclk_freq = <60>;

		lcd_hbp             = <80>;
		lcd_ht              = <980>;
		lcd_hspw            = <20>;
		lcd_vbp             = <20>;
		lcd_vt              = <1325>;
		lcd_vspw            = <5>;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

rgb使用
/opt/EmbedSky/TQT507/CoreA/longan/device/config/chips/t507/configs/evb/board-coreA_lcd.dts
1024*600 rgb
lcd_x = <1024>;
lcd_y = <600>;
lcd_dclk_freq = <51>;

		lcd_hbp             = <160>;
		lcd_ht              = <1414>;
		lcd_hspw            = <70>;
		lcd_vbp             = <23>;
		lcd_vt              = <645>;
		lcd_vspw            = <10>;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

480*854 rgb
lcd_x = <480>;
lcd_y = <854>;
lcd_dclk_freq = <34>;

		lcd_hbp             = <60>;
		lcd_ht              = <630>;
		lcd_hspw            = <30>; 
		lcd_vbp             = <25>;
		lcd_vt              = <914>;
		lcd_vspw            = <10>;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

1280*800
lcd_x = <1280>;
lcd_y = <800>;
lcd_width = <150>;
lcd_height = <94>;
lcd_dclk_freq = <65>;

lcd_hbp = <80>;
lcd_ht = <1440>;
lcd_hspw = <10>;
lcd_vbp = <15>;
lcd_vt = <838>;
lcd_vspw = <8>;

480*854 rgb
lcd0: lcd0@01c0c000 {
lcd_used = <1>;

		lcd_driver_name     = "bp101wx1";
		lcd_backlight       = <50>;
		lcd_if              = <0>;

		lcd_x               = <480>;
		lcd_y               = <854>;
		lcd_width           = <150>; 
		lcd_height          = <94>;
		lcd_dclk_freq       = <33>; 

		lcd_pwm_used        = <1>;
		lcd_pwm_ch          = <0>;
		lcd_pwm_freq        = <5000>;
		lcd_pwm_pol         = <1>;
		lcd_pwm_max_limit   = <255>;


		lcd_hbp             = <60>;
		lcd_ht              = <630>;
		lcd_hspw            = <30>; 
		lcd_vbp             = <25>;
		lcd_vt              = <914>;
		lcd_vspw            = <10>;

		lcd_lvds_if         = <0>;
		lcd_lvds_colordepth = <0>;
		lcd_lvds_mode       = <0>;
		lcd_frm             = <0>;
		lcd_hv_clk_phase    = <0>;
		lcd_hv_sync_polarity= <0>;
		lcd_gamma_en        = <0>;
		lcd_bright_curve_en = <0>;
		lcd_cmap_en         = <0>;
		lcd_fsync_en        = <0>;
		lcd_fsync_act_time  = <1000>;
		lcd_fsync_dis_time  = <1000>;
		lcd_fsync_pol       = <0>;

		deu_mode            = <0>;
		lcdgamma4iep        = <22>;
		smart_color         = <90>;

		lcd_pin_power = "bldo1";

		lcd_power = "dc1sw";
		lcd_bl_en        = <&pio PE 15 1 0 3 1>;
		pinctrl-0 = <&rgb24_pins_a>;
		pinctrl-1 = <&rgb24_pins_b>;

	};
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50

加入新的库,创建软连接,镜像根文件位置

cp /root/jclvgl/lib/libswscale.so.6.8.112 /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/usr/lib/
cp /root/jclvgl/lib/libswresample.so.4.9.100 /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/usr/lib/
cp /root/jclvgl/lib/libavutil.so.57.37.100 /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/usr/lib/
cp /root/jclvgl/lib/libavformat.so.59.33.100 /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/usr/lib/
cp /root/jclvgl/lib/libavdevice.so.59.8.101 /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/usr/lib/
cp /root/jclvgl/lib/libavcodec.so.59.48.100 /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/usr/lib/

cd /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/usr/lib/

rm -rf libavcodec.so.59
rm -rf libavcodec.so
rm -rf libavformat.so.59
rm -rf libavformat.so
rm -rf libavutil.so.57
rm -rf libavutil.so
rm -rf libswscale.so.6
rm -rf libswscale.so
rm -rf libswresample.so.4
rm -rf libswresample.so
rm -rf libavdevice.so.59
rm -rf libavdevice.so

ln -s ./libavcodec.so.59.48.100 libavcodec.so.59
ln -s ./libavcodec.so.59.48.100 libavcodec.so
ln -s ./libavformat.so.59.33.100 libavformat.so.59
ln -s ./libavformat.so.59.33.100 libavformat.so
ln -s ./libavutil.so.57.37.100 libavutil.so.57
ln -s ./libavutil.so.57.37.100 libavutil.so
ln -s ./libswscale.so.6.8.112 libswscale.so.6
ln -s ./libswscale.so.6.8.112 libswscale.so
ln -s ./libswresample.so.4.9.100 libswresample.so.4
ln -s ./libswresample.so.4.9.100 libswresample.so
ln -s ./libavdevice.so.59.8.101 libavdevice.so.59
ln -s ./libavdevice.so.59.8.101 libavdevice.so

启动后台播放

nohup /root/jclvgldemo >/dev/null &
ps|grep jc
cp /mnt/jclvgldemo ./

简单驱动编译

Makefile

mount -t nfs -o nolock,vers=3 192.168.5.12:/home/book/nfs_rootfs /mnt && ps -ef | grep jc | grep -v grep | awk ‘{print $1}’ | xargs kill

ps -ef | grep jc | grep -v grep | awk ‘{print $1}’ | xargs kill

mount -t nfs -o nolock,vers=3 192.168.5.12:/home/book/nfs_rootfs /mnt

编译

cd /opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/drivers/media/platform/sunxi-vin/modules/sensor

make -f tp_Makefile kernel_modules

make -f /opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/drivers/media/platform/sunxi-vin/modules/sensor/tp_Makefile kernel_modules

dmesg | grep hello_

insmod helloworld.ko

-f  不检查目前kernel版本与模块编译时的kernel版本是否一致,强制将模块载入。

-k  将模块设置为自动卸除。

-m  输出模块的载入信息。

-o<模块名称>  指定模块的名称,可使用模块文件的文件名。

-p  测试模块是否能正确地载入kernel。

-s  将所有信息记录在系统记录文件中。

-v  执行时显示详细的信息。

-x  不要汇出模块的外部符号。

-X  汇出模块所有的外部符号,此为预设置。

rmmod helloworld.ko

dmesg | grep hello_

insmod helloworld.ko

lsmod

cp /mnt/helloworld.ko /root/

KERNELDIR := /opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/
CURRENT_PATH := $(shell pwd)

export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-

OUTPUT = /home/book/nfs_rootfs

target := helloworld
obj-m := $(target).o

APP_NAME := $(target)_app

build: kernel_modules

kernel_modules:
$(MAKE) -C ( K E R N E L D I R ) M = (KERNELDIR) M= (KERNELDIR)M=(CURRENT_PATH) modules
cp $(target).ko $(OUTPUT)

clean:
$(MAKE) -C ( K E R N E L D I R ) M = (KERNELDIR) M= (KERNELDIR)M=(CURRENT_PATH) clean

//helloworld.c
#include <linux/init.h>
#include <linux/module.h>

static int hello_init(void)
{
printk(“hello_ hello, world!\r\n”);

return 0;
  • 1

}

static void hello_exit(void)
{
printk(“hello_ byebye!\r\n”);
}

module_init(hello_init);
module_exit(hello_exit);

MODULE_LICENSE(“GPL”);
//MODULE_AUTHOR(“SIXER”); //声明作者信息

摄像头驱动编译makefile修改,可直接生成.ko

KERNELDIR := /opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/
CURRENT_PATH := $(shell pwd)

export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-

kernel_modules:
$(MAKE) -C ( K E R N E L D I R ) M = (KERNELDIR) M= (KERNELDIR)M=(CURRENT_PATH) modules
cp /opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/drivers/media/platform/sunxi-vin/vin_io.ko /home/book/nfs_rootfs
cp /opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/drivers/media/platform/sunxi-vin/vin_v4l2.ko /home/book/nfs_rootfs
cp /opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/drivers/media/platform/sunxi-vin/modules/sensor/tp2855_mipi.ko /home/book/nfs_rootfs

clean:
$(MAKE) -C ( K E R N E L D I R ) M = (KERNELDIR) M= (KERNELDIR)M=(CURRENT_PATH) clean

CONFIG_CSI_VIN := m
CONFIG_SUPPORT_ISP_TDM := m
CONFIG_ARCH_SUN50IW9P1 := active

obj-$(CONFIG_CSI_VIN) += modules/sensor/

obj- ( C O N F I G C S I V I N ) + = m o d u l e s / a c t u a t o r / o b j − (CONFIG_CSI_VIN) += modules/actuator/ obj- (CONFIGCSIVIN)+=modules/actuator/obj(CONFIG_CSI_VIN) += vin_io.o
vin_io-y := vin-cci/csi_cci_reg.o
vin_io-y += vin-cci/bsp_cci.o
vin_io-y += vin-cci/cci_helper.o
vin_io-y += vin-cci/sunxi_cci.o
vin_io-y += utility/vin_supply.o
vin_io-y += utility/vin_os.o
vin_io-y += modules/sensor/sensor-compat-ioctl32.o
vin_io-y += modules/sensor/sensor_helper.o
obj-$(CONFIG_CSI_VIN) += modules/sensor/tp2855_mipi.o

obj-$(CONFIG_CSI_VIN) += vin_v4l2.o
vin_v4l2-y := vin-csi/sunxi_csi.o
vin_v4l2-y += vin-csi/parser_reg.o

vin_v4l2-y += vin-mipi/sunxi_mipi.o
ifneq ($(strip ( C O N F I G A R C H S U N 8 I W 15 P 1 ) ) , ) v i n v 4 l 2 − y + = v i n − m i p i / b s p m i p i c s i . o e l s e i f n e q ( (CONFIG_ARCH_SUN8IW15P1)),) vin_v4l2-y += vin-mipi/bsp_mipi_csi.o else ifneq ( (CONFIGARCHSUN8IW15P1)),)vinv4l2y+=vinmipi/bspmipicsi.oelseifneq((strip ( C O N F I G A R C H S U N 8 I W 19 P 1 ) ) , ) v i n v 4 l 2 − y + = v i n − m i p i / b s p m i p i c s i . o e l s e i f n e q ( (CONFIG_ARCH_SUN8IW19P1)),) vin_v4l2-y += vin-mipi/bsp_mipi_csi.o else ifneq ( (CONFIGARCHSUN8IW19P1)),)vinv4l2y+=vinmipi/bspmipicsi.oelseifneq((strip ( C O N F I G A R C H S U N 50 I W 9 P 1 ) ) , ) v i n v 4 l 2 − y + = v i n − m i p i / b s p m i p i c s i . o e l s e i f n e q ( (CONFIG_ARCH_SUN50IW9P1)),) vin_v4l2-y += vin-mipi/bsp_mipi_csi.o else ifneq ( (CONFIGARCHSUN50IW9P1)),)vinv4l2y+=vinmipi/bspmipicsi.oelseifneq((strip ( C O N F I G A R C H S U N 8 I W 17 ) ) , ) v i n v 4 l 2 − y + = v i n − m i p i / b s p m i p i c s i v 1. o   v i n − m i p i / c o m b o r x / c o m b o r x r e g n u l l . o   v i n − m i p i / p r o t o c o l / p r o t o c o l r e g . o   v i n − m i p i / d p h y / d p h y r e g . o e l s e i f n e q ( (CONFIG_ARCH_SUN8IW17)),) vin_v4l2-y += vin-mipi/bsp_mipi_csi_v1.o \ vin-mipi/combo_rx/combo_rx_reg_null.o\ vin-mipi/protocol/protocol_reg.o \ vin-mipi/dphy/dphy_reg.o else ifneq ( (CONFIGARCHSUN8IW17)),)vinv4l2y+=vinmipi/bspmipicsiv1.o vinmipi/comborx/comborxregnull.o vinmipi/protocol/protocolreg.o vinmipi/dphy/dphyreg.oelseifneq((strip ( C O N F I G A R C H S U N 8 I W 16 ) ) , ) v i n v 4 l 2 − y + = v i n − m i p i / c o m b o r x / c o m b o r x r e g . o e l s e i f n e q ( (CONFIG_ARCH_SUN8IW16)),) vin_v4l2-y += vin-mipi/combo_rx/combo_rx_reg.o else ifneq ( (CONFIGARCHSUN8IW16)),)vinv4l2y+=vinmipi/comborx/comborxreg.oelseifneq((strip $(CONFIG_ARCH_SUN50IW10)),)
vin_v4l2-y += vin-mipi/combo_csi/combo_csi_reg.o
else
vin_v4l2-y += vin-mipi/bsp_mipi_csi_null.o
vin-mipi/combo_rx/combo_rx_reg_null.o
endif

vin_v4l2-y += vin-isp/sunxi_isp.o
ifneq ($(strip ( C O N F I G A R C H S U N 8 I W 16 P 1 ) ) , ) v i n v 4 l 2 − y + = v i n − i s p / i s p 520 / i s p 52 0 r e g c f g . o e l s e i f n e q ( (CONFIG_ARCH_SUN8IW16P1)),) vin_v4l2-y += vin-isp/isp520/isp520_reg_cfg.o else ifneq ( (CONFIGARCHSUN8IW16P1)),)vinv4l2y+=vinisp/isp520/isp520regcfg.oelseifneq((strip ( C O N F I G A R C H S U N 8 I W 19 P 1 ) ) , ) v i n v 4 l 2 − y + = v i n − i s p / i s p 521 / i s p 52 1 r e g c f g . o e l s e i f n e q ( (CONFIG_ARCH_SUN8IW19P1)),) vin_v4l2-y += vin-isp/isp521/isp521_reg_cfg.o else ifneq ( (CONFIGARCHSUN8IW19P1)),)vinv4l2y+=vinisp/isp521/isp521regcfg.oelseifneq((strip $(CONFIG_ARCH_SUN50IW10P1)),)
vin_v4l2-y += vin-isp/isp522/isp522_reg_cfg.o
else
vin_v4l2-y += vin-isp/isp500/isp500_reg_cfg.o
endif

vin_v4l2- ( C O N F I G S U P P O R T I S P T D M ) + = v i n − t d m / v i n t d m . o v i n v 4 l 2 − (CONFIG_SUPPORT_ISP_TDM) += vin-tdm/vin_tdm.o vin_v4l2- (CONFIGSUPPORTISPTDM)+=vintdm/vintdm.ovinv4l2(CONFIG_SUPPORT_ISP_TDM) += vin-tdm/tdm_reg.o
vin_v4l2-y += vin-vipp/sunxi_scaler.o
vin_v4l2-y += vin-vipp/vipp_reg.o
vin_v4l2-y += modules/flash/flash.o
vin_v4l2-y += utility/bsp_common.o
vin_v4l2-y += utility/config.o
vin_v4l2-y += utility/cfg_op.o
vin_v4l2-y += vin-stat/vin_h3a.o
vin_v4l2-y += vin-video/vin_video.o
vin_v4l2-y += vin-video/vin_core.o
vin_v4l2-y += vin-video/dma_reg.o
vin_v4l2-y += top_reg.o
vin_v4l2-y += vin.o

分析驱动IIC如何调用(RTC时钟)

找到参考文件
/opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/drivers/input/touchscreen/edt-ft5x06.c
参考文件 RTC时钟
/opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/drivers/rtc/rtc-pcf8563.c
参考文件 RTC时钟分析驱动IIC如何调用

飞凌OKT507

/home/forlinx/work/OKT507-linux-sdk/kernel/linux-4.9/drivers/media/platform/sunxi-vin/modules/actuator/
/home/forlinx/work/OKT507-linux-sdk/platform/framework/auto/cmd_demo/csitest/

/home/forlinx/work/OKT507-linux-sdk
sudo ./build.sh
sudo ./build.sh pack

cp /home/book/nfs_rootfs/mult_video_display_1080 /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/root/
cp /home/book/nfs_rootfs/mult_video_display_720 /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/root/

摄像头源码位置

/opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/include/media/sunxi_camera_v2.h
//自定义私有数据处理
struct senseor_private_modify {
unsigned int flag;
unsigned int key;
unsigned int val;
};

#define VIDIOC_VIN_SENSOR_PRIVATE_MODIFY _IOWR(‘V’, BASE_VIDIOC_PRIVATE + 74, struct senseor_private_modify)

/opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/drivers/media/platform/sunxi-vin/modules/sensor/tp2854_mipi.c
/opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/drivers/media/platform/sunxi-vin/modules/sensor/tp2815_mipi.c

tar -

摄像头,红色电源,黑色低,白色(内部电源正-可不用),黄色,信号线。 720P 25帧, 可以接9V,可能显示没那么好

cp /opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/drivers/media/platform/sunxi-vin/vin_io.ko /home/book/nfs_rootfs && cp /opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/drivers/media/platform/sunxi-vin/vin_v4l2.ko /home/book/nfs_rootfs && cp /opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/drivers/media/platform/sunxi-vin/modules/sensor/tp2855_mipi.ko /home/book/nfs_rootfs

mount -t nfs -o nolock,vers=3 192.168.5.12:/home/book/nfs_rootfs /mnt

cp /mnt/vin_io.ko /lib/modules/4.9.170
cp /mnt/vin_v4l2.ko /lib/modules/4.9.170
cp /mnt/tp2855_mipi.ko /lib/modules/4.9.170

//20230202/
insmod /lib/modules/4.9.170/videobuf2-core.ko
insmod /lib/modules/4.9.170/videobuf2-memops.ko
insmod /lib/modules/4.9.170/videobuf2-dma-contig.ko
insmod /lib/modules/4.9.170/videobuf2-v4l2.ko
insmod /lib/modules/4.9.170/vin_io.ko
insmod /lib/modules/4.9.170/tp2855_mipi.ko
insmod /lib/modules/4.9.170/vin_v4l2.ko
/20230202

insmod /lib/modules/4.9.170/videobuf2-core.ko
insmod /lib/modules/4.9.170/videobuf2-memops.ko
insmod /lib/modules/4.9.170/videobuf2-v4l2.ko

insmod /lib/modules/4.9.170/videobuf2-dma-contig.ko
insmod /lib/modules/4.9.170/vin_io.ko
insmod /lib/modules/4.9.170/tp2855_mipi.ko
insmod /lib/modules/4.9.170/vin_v4l2.ko

cp /mnt/jc_05_camera_ffmpeg /root/ && ./jc_05_camera_ffmpeg

rmmod /lib/modules/4.9.170/vin_v4l2.ko
rmmod /lib/modules/4.9.170/tp2855_mipi.ko
rmmod /lib/modules/4.9.170/vin_io.ko
rmmod /lib/modules/4.9.170/videobuf2-v4l2.ko
rmmod /lib/modules/4.9.170/videobuf2-dma-contig.ko
rmmod /lib/modules/4.9.170/videobuf2-memops.ko
rmmod /lib/modules/4.9.170/videobuf2-core.ko

insmod /lib/modules/4.9.170/vf-test.ko
find / -name *.ko

测试demo
ps -ef | grep jc | grep -v grep | awk ‘{print $1}’ | xargs kill && fbinit 0 && cd /root && ./mult_video_display -o 0

摄像头makefile修改,方便直接生成.ko

KERNELDIR := /opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/
CURRENT_PATH := $(shell pwd)

export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-

kernel_modules:
$(MAKE) -C ( K E R N E L D I R ) M = (KERNELDIR) M= (KERNELDIR)M=(CURRENT_PATH) modules
cp /opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/drivers/media/platform/sunxi-vin/vin_io.ko /home/book/nfs_rootfs
cp /opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/drivers/media/platform/sunxi-vin/vin_v4l2.ko /home/book/nfs_rootfs
cp /opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/drivers/media/platform/sunxi-vin/modules/sensor/tp2855_mipi.ko /home/book/nfs_rootfs

clean:
$(MAKE) -C ( K E R N E L D I R ) M = (KERNELDIR) M= (KERNELDIR)M=(CURRENT_PATH) clean

CONFIG_CSI_VIN := m
CONFIG_SUPPORT_ISP_TDM := m
CONFIG_ARCH_SUN50IW9P1 := active

obj-$(CONFIG_CSI_VIN) += modules/sensor/

obj- ( C O N F I G C S I V I N ) + = m o d u l e s / a c t u a t o r / o b j − (CONFIG_CSI_VIN) += modules/actuator/ obj- (CONFIGCSIVIN)+=modules/actuator/obj(CONFIG_CSI_VIN) += vin_io.o
vin_io-y := vin-cci/csi_cci_reg.o
vin_io-y += vin-cci/bsp_cci.o
vin_io-y += vin-cci/cci_helper.o
vin_io-y += vin-cci/sunxi_cci.o
vin_io-y += utility/vin_supply.o
vin_io-y += utility/vin_os.o
vin_io-y += modules/sensor/sensor-compat-ioctl32.o
vin_io-y += modules/sensor/sensor_helper.o
obj-$(CONFIG_CSI_VIN) += modules/sensor/tp2855_mipi.o

obj-$(CONFIG_CSI_VIN) += vin_v4l2.o
vin_v4l2-y := vin-csi/sunxi_csi.o
vin_v4l2-y += vin-csi/parser_reg.o

vin_v4l2-y += vin-mipi/sunxi_mipi.o
ifneq ($(strip ( C O N F I G A R C H S U N 8 I W 15 P 1 ) ) , ) v i n v 4 l 2 − y + = v i n − m i p i / b s p m i p i c s i . o e l s e i f n e q ( (CONFIG_ARCH_SUN8IW15P1)),) vin_v4l2-y += vin-mipi/bsp_mipi_csi.o else ifneq ( (CONFIGARCHSUN8IW15P1)),)vinv4l2y+=vinmipi/bspmipicsi.oelseifneq((strip ( C O N F I G A R C H S U N 8 I W 19 P 1 ) ) , ) v i n v 4 l 2 − y + = v i n − m i p i / b s p m i p i c s i . o e l s e i f n e q ( (CONFIG_ARCH_SUN8IW19P1)),) vin_v4l2-y += vin-mipi/bsp_mipi_csi.o else ifneq ( (CONFIGARCHSUN8IW19P1)),)vinv4l2y+=vinmipi/bspmipicsi.oelseifneq((strip ( C O N F I G A R C H S U N 50 I W 9 P 1 ) ) , ) v i n v 4 l 2 − y + = v i n − m i p i / b s p m i p i c s i . o e l s e i f n e q ( (CONFIG_ARCH_SUN50IW9P1)),) vin_v4l2-y += vin-mipi/bsp_mipi_csi.o else ifneq ( (CONFIGARCHSUN50IW9P1)),)vinv4l2y+=vinmipi/bspmipicsi.oelseifneq((strip ( C O N F I G A R C H S U N 8 I W 17 ) ) , ) v i n v 4 l 2 − y + = v i n − m i p i / b s p m i p i c s i v 1. o   v i n − m i p i / c o m b o r x / c o m b o r x r e g n u l l . o   v i n − m i p i / p r o t o c o l / p r o t o c o l r e g . o   v i n − m i p i / d p h y / d p h y r e g . o e l s e i f n e q ( (CONFIG_ARCH_SUN8IW17)),) vin_v4l2-y += vin-mipi/bsp_mipi_csi_v1.o \ vin-mipi/combo_rx/combo_rx_reg_null.o\ vin-mipi/protocol/protocol_reg.o \ vin-mipi/dphy/dphy_reg.o else ifneq ( (CONFIGARCHSUN8IW17)),)vinv4l2y+=vinmipi/bspmipicsiv1.o vinmipi/comborx/comborxregnull.o vinmipi/protocol/protocolreg.o vinmipi/dphy/dphyreg.oelseifneq((strip ( C O N F I G A R C H S U N 8 I W 16 ) ) , ) v i n v 4 l 2 − y + = v i n − m i p i / c o m b o r x / c o m b o r x r e g . o e l s e i f n e q ( (CONFIG_ARCH_SUN8IW16)),) vin_v4l2-y += vin-mipi/combo_rx/combo_rx_reg.o else ifneq ( (CONFIGARCHSUN8IW16)),)vinv4l2y+=vinmipi/comborx/comborxreg.oelseifneq((strip $(CONFIG_ARCH_SUN50IW10)),)
vin_v4l2-y += vin-mipi/combo_csi/combo_csi_reg.o
else
vin_v4l2-y += vin-mipi/bsp_mipi_csi_null.o
vin-mipi/combo_rx/combo_rx_reg_null.o
endif

vin_v4l2-y += vin-isp/sunxi_isp.o
ifneq ($(strip ( C O N F I G A R C H S U N 8 I W 16 P 1 ) ) , ) v i n v 4 l 2 − y + = v i n − i s p / i s p 520 / i s p 52 0 r e g c f g . o e l s e i f n e q ( (CONFIG_ARCH_SUN8IW16P1)),) vin_v4l2-y += vin-isp/isp520/isp520_reg_cfg.o else ifneq ( (CONFIGARCHSUN8IW16P1)),)vinv4l2y+=vinisp/isp520/isp520regcfg.oelseifneq((strip ( C O N F I G A R C H S U N 8 I W 19 P 1 ) ) , ) v i n v 4 l 2 − y + = v i n − i s p / i s p 521 / i s p 52 1 r e g c f g . o e l s e i f n e q ( (CONFIG_ARCH_SUN8IW19P1)),) vin_v4l2-y += vin-isp/isp521/isp521_reg_cfg.o else ifneq ( (CONFIGARCHSUN8IW19P1)),)vinv4l2y+=vinisp/isp521/isp521regcfg.oelseifneq((strip $(CONFIG_ARCH_SUN50IW10P1)),)
vin_v4l2-y += vin-isp/isp522/isp522_reg_cfg.o
else
vin_v4l2-y += vin-isp/isp500/isp500_reg_cfg.o
endif

vin_v4l2- ( C O N F I G S U P P O R T I S P T D M ) + = v i n − t d m / v i n t d m . o v i n v 4 l 2 − (CONFIG_SUPPORT_ISP_TDM) += vin-tdm/vin_tdm.o vin_v4l2- (CONFIGSUPPORTISPTDM)+=vintdm/vintdm.ovinv4l2(CONFIG_SUPPORT_ISP_TDM) += vin-tdm/tdm_reg.o
vin_v4l2-y += vin-vipp/sunxi_scaler.o
vin_v4l2-y += vin-vipp/vipp_reg.o
vin_v4l2-y += modules/flash/flash.o
vin_v4l2-y += utility/bsp_common.o
vin_v4l2-y += utility/config.o
vin_v4l2-y += utility/cfg_op.o
vin_v4l2-y += vin-stat/vin_h3a.o
vin_v4l2-y += vin-video/vin_video.o
vin_v4l2-y += vin-video/vin_core.o
vin_v4l2-y += vin-video/dma_reg.o
vin_v4l2-y += top_reg.o
vin_v4l2-y += vin.o

对于makefile的改进

关于全局对外宏定义的位置
/opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/include/media/sunxi_camera_v2.h
关于gpio的结构体的补充
/opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/include/linux/sunxi-gpio.h

摄像头测试
ps -ef | grep jc | grep -v grep | awk ‘{print $1}’ | xargs kill && fbinit 0 && cd /root && ./mult_video_display -o 0

关闭当前进程
ps -ef | grep jc | grep -v grep | awk ‘{print $1}’ | xargs kill

关闭屏幕
fbinit 0

V4L_PLATFORM_DRIVERS VIDEO_SUNXI_VIN

开启menuconfig
cd /opt/EmbedSky/TQT507/CoreA/longan/
cd ./kernel/linux-4.9
make menuconfig ARCH=arm64

厂家说的位置
/opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/drivers/media/platform/sunxi-vin/

vin_io-y += modules/sensor/tp2855_mipi.o

配置文件 kconfig
/opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/drivers/media/platform/Kconfig
->
/opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/drivers/media/platform/sunxi-vin/Kconfig

20221104
/opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/drivers/media/v4l2-core/v4l2-common.c
v4l2_i2c_subdev_init 绑定s4l2和iic,双向绑定

/opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/drivers/base/core.c
int dev_set_name(struct device *dev, const char *fmt, …)
va_start(vargs, fmt);
err = kobject_set_name_vargs(&dev->kobj, fmt, vargs);
va_end(vargs);
return err;
device_register
device_initialize(dev);
device_add(dev);
int device_create_file(struct device *dev, const struct device_attribute *attr)
sysfs_create_file

设备树
vind0:vind@0 {
vind0_clk = <324000000>;
status = “okay”;

		csi_cci0:cci@0 {
			status = "okay";
		};
		csi_cci1:cci@1 {
			status = "disabled";
		};
		csi0:csi@0 {
			status = "okay";
		};
		csi1:csi@1 {
			status = "disabled";
		};
		actuator0:actuator@0 {
			device_type = "actuator0";
			actuator0_name = "ad5820_act";
			actuator0_slave = <0x18>;
			actuator0_af_pwdn = <>;
			actuator0_afvdd = "afvcc-csi";
			actuator0_afvdd_vol = <2800000>;
			status = "disabled";
		};
		flash0:flash@0 {
			device_type = "flash0";
			flash0_type = <2>;
			flash0_en = <>;
			flash0_mode = <>;
			flash0_flvdd = "";
			flash0_flvdd_vol = <>;
			device_id = <0>;
			status = "disabled";
		};
		sensor0:sensor@0 {
			device_type = "sensor0";
			sensor0_mname = "tp2855_mipi";
			sensor0_twi_cci_id = <0>; 
			sensor0_twi_addr = <0x8E>;
			sensor0_mclk_id = <0>;
			sensor0_pos = "rear";
			sensor0_isp_used = <0>;
			sensor0_fmt = <0>;
			sensor0_stby_mode = <0>;
			sensor0_vflip = <0>;
			sensor0_hflip = <0>;
			sensor0_iovdd-supply = <&reg_cldo2>;
		/*	sensor0_iovdd_vol = <1800000>; */
			sensor0_avdd-supply = <&reg_bldo5>;
			sensor0_avdd_vol = <1200000>;
			sensor0_dvdd-supply = <>;
			sensor0_dvdd_vol = <>;
			sensor0_power_en = <>;
			sensor0_reset = <&pio PE 9 1 0 1 0>;
			sensor0_pwdn = <>;
			sensor0_sm_vs = <>;
			status	= "okay";
		};
		sensor1:sensor@1 {
			device_type = "sensor1";
			sensor1_mname = "nvp6158";
			sensor1_twi_cci_id = <1>;
			sensor1_twi_addr = <0x64>;
			sensor1_mclk_id = <1>;
			sensor1_pos = "front";
			sensor1_isp_used = <0>;
			sensor1_fmt = <0>;
			sensor1_stby_mode = <0>;
			sensor1_vflip = <0>;
			sensor1_hflip = <0>;
			sensor1_cameravdd-supply = <&reg_aldo5>;
			sensor1_cameravdd_vol = <3300000>;
			sensor1_iovdd-supply = <&reg_bldo3>;
			sensor1_iovdd_vol = <3300000>;
			sensor1_avdd-supply = <&reg_bldo4>;
			sensor1_avdd_vol = <1200000>;
			sensor1_dvdd-supply = <&reg_bldo5>;
			sensor1_dvdd_vol = <1200000>;
			sensor1_power_en = <>;
			/*sensor1_reset = <&pio PI 12 1 0 1 0>;*/
			/*sensor1_pwdn = <&pio PI 14 1 0 1 0>;*/
			sensor1_sm_vs = <>;
			status	= "disabled";
		};
		vinc0:vinc@0 {
			vinc0_csi_sel = <0>;
			vinc0_mipi_sel = <0>;
			vinc0_isp_sel = <0>;
			vinc0_isp_tx_ch = <0>;
			vinc0_rear_sensor_sel = <0>;
			vinc0_front_sensor_sel = <0>;
			vinc0_sensor_list = <0>;
			status = "okay";
		};
		vinc1:vinc@1 {
			vinc1_csi_sel = <0>;
			vinc1_mipi_sel = <0>;
			vinc1_isp_sel = <0>;
			vinc1_isp_tx_ch = <1>;
			vinc1_rear_sensor_sel = <0>;
			vinc1_front_sensor_sel = <0>;
			vinc1_sensor_list = <0>;
			status = "okay";
		};
		vinc2:vinc@2 {
			vinc2_csi_sel = <0>;
			vinc2_mipi_sel = <0>;
			vinc2_isp_sel = <0>;
			vinc2_isp_tx_ch = <2>;
			vinc2_rear_sensor_sel = <0>;
			vinc2_front_sensor_sel = <0>;
			vinc2_sensor_list = <0>;
			status = "okay";
		};
		vinc3:vinc@3 {
			vinc3_csi_sel = <0>;
			vinc3_mipi_sel = <0>;
			vinc3_isp_sel = <0>;
			vinc3_isp_tx_ch = <3>;
			vinc3_rear_sensor_sel = <0>;
			vinc3_front_sensor_sel = <0>;
			vinc3_sensor_list = <0>;
			status = "okay";
		};
		vinc4:vinc@4 {
			vinc4_csi_sel = <1>;
			vinc4_mipi_sel = <0xff>;
			vinc4_isp_sel = <1>;
			vinc4_isp_tx_ch = <2>;
			vinc4_rear_sensor_sel = <1>;
			vinc4_front_sensor_sel = <1>;
			vinc4_sensor_list = <0>;
			status = "disabled";
		};
		vinc5:vinc@5 {
			vinc5_csi_sel = <1>;
			vinc5_mipi_sel = <0xff>;
			vinc5_isp_sel = <1>;
			vinc5_isp_tx_ch = <3>;
			vinc5_rear_sensor_sel = <1>;
			vinc5_front_sensor_sel = <1>;
			vinc5_sensor_list = <0>;
			status = "disabled";
		};
	};
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142

屏幕源码
/opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/drivers/video/fbdev/sunxi/disp2/

查看屏幕详细信息
cat /sys/class/disp/disp/attr/sys

部分屏幕函数调用
disp_init_lcd

内核 pr_info(“[DISP] %s \t %d”,func,LINE);
tcon0_cfg
disp_al_lcd_cfg
disp_al_vdevice_cfg
disp_al_lcd_cfg
disp_lcd_fake_enable
disp_lcd_enable
disp_lcd_reflush_work
disp_lcd_enable

Uboot->printf(“[DISP] %s \t %d”,func,LINE);
tcon0_cfg
disp_al_lcd_cfg
disp_al_vdevice_cfg
disp_al_vdevice_cfg
disp_vdevice_tcon_simple_enable
disp_vdevice_tcon_enable

disp_al_lcd_cfg
disp_lcd_pre_enable
__disp_lcd_enable
disp_lcd_enable

tcon0_cfg
disp_al_lcd_cfg
disp_lcd_pre_enable

屏幕设备树在开发板位置
/sys/firmware/devicetree/base/soc@03000000/

mount /dev/mmcblk1p1 /mnt
cp -r /sys/firmware/devicetree/base/soc@03000000/* /mnt/tree/
ls -l /mnt/tree/

屏幕背光调节1.2镜像版本
echo 10 > /sys/devices/platform/soc/soc@03000000:backlight_lvdslcd/backlight/backlight_lvdslcd/brightness

或者
echo xx > /sys/class/backlight/backlight_lcd/brightness

设备树
backlight_lvdslcd: backlight_lvdslcd {
compatible = “pwm-backlight”;
brightness-levels = <
0 1 2 3 4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23
24 25 26 27 28 29 30 31
32 33 34 35 36 37 38 39
40 41 42 43 44 45 46 47
48 49 50 51 52 53 54 55
56 57 58 59 60 61 62 63
64 65 66 67 68 69 70 71
72 73 74 75 76 77 78 79
80 81 82 83 84 85 86 87
88 89 90 91 92 93 94 95
96 97 98 99 100 101 102 103
104 105 106 107 108 109 110 111
112 113 114 115 116 117 118 119
120 121 122 123 124 125 126 127
128 129 130 131 132 133 134 135
136 137 138 139 140 141 142 143
144 145 146 147 148 149 150 151
152 153 154 155 156 157 158 159
160 161 162 163 164 165 166 167
168 169 170 171 172 173 174 175
176 177 178 179 180 181 182 183
184 185 186 187 188 189 190 191
192 193 194 195 196 197 198 199
200 201 202 203 204 205 206 207
208 209 210 211 212 213 214 215
216 217 218 219 220 221 222 223
224 225 226 227 228 229 230 231
232 233 234 235 236 237 238 239
240 241 242 243 244 245 246 247
248 249 250 251 252 253 254 255 >;
df-brightness-level = <128>;
//enable-gpios = <&gpio0 20 GPIO_ACTIVE_HIGH>;
pinctrl-names = “default”;
//pinctrl-0 = <&bl_en>;
//pwms = <&pwm0 0 1000000>;
pwm-cfg = <0 500 0>; //pwmid Hz 极性
pwm-delay-us = <10000>;
};

分析uboot源码

配置文件位置
/opt/EmbedSky/TQT507/CoreA/longan/brandy/brandy-2.0/u-boot-2018/configs/sun50iw9p1_defconfig
CONFIG_SUNXI_BURN=n 后uboot启动可减少1s

控制背光
/opt/EmbedSky/TQT507/CoreA/longan/brandy/brandy-2.0/u-boot-2018/drivers/video/sunxi/disp2/disp/de/disp_display.c bsp_disp_lcd_backlight_enable return -1

uprintf(0,“disp_sys_script_get_item info->lcd_if val:%d ret:%d \n”,value,ret);

brandy/brandy-2.0/u-boot-2018/common/autoboot.c
文件内有修改,未修改前,延时1秒左右(266行和267行)
udelay(10000);->udelay(100);
while (!abort && get_timer(ts) < 1000);->while (!abort && get_timer(ts) < 1);

编译最后生成的bin文件
/opt/EmbedSky/TQT507/linux-4.9/longan/device/config/chips/t507/bin/u-boot-sun50iw9p1.bin

原始烧录PhoenixSuit烧录方式,先通过usb将img文件中的uboot搞到内存中,然后运行uboot,下载镜像,如果uboot有问题就会导致无法下载镜像,可通过打印验证

使用fastboot烧录时候
报错分区不存在,看下sys_partition.fex里面的分区信息,没有就创建分区

开机logo位置
/opt/EmbedSky/TQT507/CoreA/longan/device/config/chips/t507/boot-resource/boot-resource/
经过测试,发现以下网站可以直接将png转bmp
https://cdkm.com/cn/png-to-bmp

开机logo显示源码位置
board/sunxi/board_common.c board_bootlogo_display
boot_gui_init();
tick_printf(“func:%s \t line:%d\n”, func,LINE);
int ret = -1;
int advert_enable = 0;
ret = script_parser_fetch(“/soc/target”, “advert_enable”,
(int *)&advert_enable, sizeof(int) / 4);
if ((ret == 0) && (advert_enable == 1)) {
ret = sunxi_advert_display(“Reserve0”, “advert.bmp”);
if (ret == 0) {
return;
}
}
sunxi_bmp_display(“bootlogo.bmp”);

sunxi_bmp_display
do_fat_fsload
show_bmp_on_fb

drivers/video/sunxi/bootGUI/boot_gui.c

查找函数可以使用 grep
eg: grep “board_init_f” ./ -nwr

查找函数名也可以使用 u-boot.map
在u-boot中,就有一种快速方法“从众多的同名函数中找到与我们相关的那一个”:
编译出来完的uboot会生成一个u-boot.map文件,你只要以这个“函数的名字”为关键字去u-boot.map中查找,就能找到编译出来的uboot映像,使用的是哪个文件中的函数了。
生成map案例 gcc -Wl,-Map,a.map foo.c -o foo

eg: 查找 _start

文件u-boot.lds中入口函数 _start

查找 _start:
找到 vectors.S 因为有vectors.o 故确认就是这个

此处类似c语言的宏定义,目的时构建中断向量表,其中一个中断向量表的处理函数如下

之后程序开始执行reset函数,其中reset函数定义在arch\arm\cpu\armv7\start.S中

总上可以看出 reset 才是上电后,uboot执行的第一个函数,
之后,设置cpu,等操作,然后执行 _main 定义在arch\arm\lib\crt0.S中

找打_main位置 brandy\brandy-2.0\u-boot-2018\arch\arm\lib

核心代码位置
board_init_f common/board_f.c
board_init_r common/board_r.c

Uboot 读取sdcard开始位置

之前的分析资料

mkfile打印
$(info __debuginfo__227 )

cd /opt/EmbedSky/TQT507/CoreA/longan/
tar -jcvf uboot.tar.bz2 u-boot-2018/ 打包镜像
修改uboot
编译 u-boot
sudo ./build.sh brandy
sudo ./build.sh pack
最终执行指令
/opt/EmbedSky/TQT507/CoreA/longan/brandy/brandy-2.0/build.sh -p sun50iw9p1
然后进入 /opt/EmbedSky/TQT507/CoreA/longan/brandy/brandy-2.0/u-boot-2018/
make distclean
make sun50iw9p1_defconfig
make -j16

配置文件位置
/opt/EmbedSky/TQT507/CoreA/longan/brandy/brandy-2.0/u-boot-2018/configs/sun50iw9p1_defconfig
CONFIG_SUNXI_BURN=n 后uboot启动可减少1s

简化后
/
/
CONFIG_BOOTDELAY=1
CONFIG_SUNXI_FDT_SAVE=y
CONFIG_ARM=y
CONFIG_ARCH_SUNXI=y
CONFIG_MACH_SUN50IW9=y
#CONFIG_AXP_GPIO=y
CONFIG_DEFAULT_DEVICE_TREE=“sun50iw9-common”

CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set

CONFIG_CONSOLE_MUX=y
CONFIG_OF_BOARD=y
CONFIG_SYS_TEXT_BASE=0x4A000000

#system
CONFIG_ARM_SMCCC=y
CONFIG_SUNXI_DMA=y
CONFIG_PHYS_64BIT=y

#I2C
CONFIG_SYS_I2C_SUNXI=y
CONFIG_SYS_SUNXI_R_I2C0_SLAVE=0x34
CONFIG_SYS_SUNXI_R_I2C0_SPEED=400000
CONFIG_R_I2C0_ENABLE=y
CONFIG_SYS_SUNXI_I2C4_SLAVE=0x70
CONFIG_SYS_SUNXI_I2C4_SPEED=200000
CONFIG_I2C4_ENABLE=y
#power
CONFIG_SUNXI_POWER=y
CONFIG_SUNXI_PMU=y
CONFIG_AXP1530_POWER=y
CONFIG_AXP1530_SUNXI_I2C_SLAVE=0x36
CONFIG_SUNXI_AXP152_POWER=y
CONFIG_AXP152_SUNXI_I2C_SLAVE=0x30
CONFIG_AXP858_POWER=y
CONFIG_AXP858_SUNXI_I2C_SLAVE=0x36
CONFIG_SUNXI_TRY_POWER_SPLY=y

flash

CONFIG_SUNXI_SDMMC=y
CONFIG_MMC=y
CONFIG_SUNXI_FLASH=n
CONFIG_SUNXI_NAND=n
CONFIG_CMD_SUNXI_NAND=n
CONFIG_SUNXI_COMM_NAND_V1=n

#usb otg config
CONFIG_SUNXI_USB=y
CONFIG_SUNXI_EFEX=y
CONFIG_SUNXI_BURN=n

#partition
CONFIG_EFI_PARTITION=n

#image
CONFIG_ANDROID_BOOT_IMAGE=y

#sprite
CONFIG_SUNXI_SPRITE=y
CONFIG_SUNXI_SECURE_STORAGE=y
CONFIG_SUNXI_SPRITE_CARTOON=y

#power
CONFIG_SUNXI_NO_PMIC=y

#secure feature
CONFIG_SUNXI_SECURE_BOOT=y
CONFIG_SUNXI_IMAGE_VERIFIER=y
CONFIG_SUNXI_KEYBOX=y

#android
CONFIG_SUNXI_MAC=n
CONFIG_SUNXI_USER_KEY=n
CONFIG_SUNXI_AVB=n
CONFIG_SUNXI_ANDROID_BOOT=n
CONFIG_SUNXI_SERIAL=n

#homlet
CONFIG_SUNXI_HOMLET=n
CONFIG_RECOVERY_KEY=y
CONFIG_IR_BOOT_RECOVERY=n
CONFIG_SUNXI_DRM_SUPPORT=y
CONFIG_SUNXI_HDCP_IN_SECURESTORAGE=n
CONFIG_SUNXI_HDCP_HASH=n

#freq limit
CONFIG_SUNXI_CHECK_LIMIT_VERIFY=y
CONFIG_SUNXI_LIMIT_CPU_FREQ=y

#cmd
CONFIG_CMD_SUNXI_TIMER=y
CONFIG_CMD_SUNXI_SPRITE=y
CONFIG_CMD_SUNXI_EFEX=y
CONFIG_CMD_SUNXI_BURN=y
CONFIG_CMD_GPT=y
CONFIG_CMD_FAT=y
CONFIG_CMD_SUNXI_MEMTEST=n
CONFIG_CMD_FASTBOOT=y

Clock

CONFIG_CLK_SUNXI=y

BOOT GUI

CONFIG_BOOT_GUI=y

CONFIG_UPDATE_DISPLAY_MODE is not set

CONFIG_CONFIG_LCD_CHECK_SKIP_OPEN is not set

CONFIG_BOOT_GUI_DOUBLE_BUF is not set

CONFIG_BOOT_GUI_TEST is not set

SUNXI LOGO DISPLAY

CONFIG_CMD_SUNXI_BMP=y
CONFIG_SUNXI_ADVERT_PICTURE=y
CONFIG_LZMA=y

CONFIG_SUNXI_SPINOR_BMP is not set

CONFIG_ENABLE_ADVERT_PICTURE is not set

CONFIG_CMD_SUNXI_JPEG is not set

CONFIG_DISP2_SUNXI=y

#CONFIG_HDMI2_CEC_SUNXI=y
CONFIG_HDMI2_DISP2_SUNXI=y
#CONFIG_HDMI2_FREQ_SPREAD_SPECTRUM_NEW=y

CONFIG_VDPO_DISP2_SUNXI is not set

CONFIG_TV_DISP2_SUNXI=y

CONFIG_DISP2_TV_GM7121 is not set

CONFIG_DISP2_TV_AC200 is not set

CONFIG_EDP_DISP2_SUNXI is not set

CONFIG_EINK_PANEL_USED is not set

LCD panels select

CONFIG_LCD_SUPPORT_GG1P4062UTSW is not set

CONFIG_LCD_SUPPORT_DX0960BE40A1 is not set

CONFIG_LCD_SUPPORT_TFT720X1280 is not set

CONFIG_LCD_SUPPORT_FD055HD003S is not set

CONFIG_LCD_SUPPORT_HE0801A068 is not set

CONFIG_LCD_SUPPORT_ILI9341 is not set

CONFIG_LCD_SUPPORT_LH219WQ1 is not set

CONFIG_LCD_SUPPORT_LS029B3SX02 is not set

CONFIG_LCD_SUPPORT_LT070ME05000 is not set

CONFIG_LCD_SUPPORT_S6D7AA0X01 is not set

CONFIG_LCD_SUPPORT_T27P06 is not set

CONFIG_LCD_SUPPORT_TFT720x1280 is not set

CONFIG_LCD_SUPPORT_WTQ05027D01 is not set

CONFIG_LCD_SUPPORT_H245QBN02 is not set

CONFIG_LCD_SUPPORT_ST7789V is not set

CONFIG_LCD_SUPPORT_ST7796S is not set

CONFIG_LCD_SUPPORT_ST7701S is not set

CONFIG_LCD_SUPPORT_T30P106 is not set

CONFIG_LCD_SUPPORT_TO20T20000 is not set

CONFIG_LCD_SUPPORT_FRD450H40014 is not set

CONFIG_LCD_SUPPORT_S2003T46G is not set

CONFIG_LCD_SUPPORT_WILLIAMLCD is not set

CONFIG_LCD_SUPPORT_LQ101R1SX03 is not set

CONFIG_LCD_SUPPORT_INET_DSI_PANEL is not set

CONFIG_LCD_SUPPORT_WTL096601G03 is not set

CONFIG_LCD_SUPPORT_BP101WX1=y
CONFIG_LCD_SUPPORT_M133X56=y
CONFIG_SUNXI_ANDROID_OVERLAY=y
CONFIG_SUNXI_OVERLAY=y

Display engine feature select

CONFIG_DISP2_SUNXI_SUPPORT_SMBL is not set

CONFIG_DISP2_SUNXI_SUPPORT_ENAHNCE is not set

PWM_SUNXI

CONFIG_PWM_SUNXI is not set

CONFIG_PWM_SUNXI_NEW=y

CUR_VERSION=2019
CONFIG_SYS_RTC_BUS_NUM=1
CONFIG_T507_COREA=y
#CONFIG_TQIMX6Q_4=y

/
/

brandy/brandy-2.0/u-boot-2018/common/autoboot.c
文件内有修改,未修改前,延时1秒左右(266行和267行)
udelay(10000);->udelay(100);
while (!abort && get_timer(ts) < 1000);->while (!abort && get_timer(ts) < 1);

编译最后生成的bin文件
/opt/EmbedSky/TQT507/linux-4.9/longan/device/config/chips/t507/bin/u-boot-sun50iw9p1.bin

原始烧录PhoenixSuit烧录方式,先通过usb将img文件中的uboot搞到内存中,然后运行uboot,下载镜像,如果uboot有问题就会导致无法下载镜像,可通过打印验证

使用fastboot烧录时候
报错分区不存在,看下sys_partition.fex里面的分区信息,没有就创建分区

虚拟机意外崩溃,导致网卡丢失

sudo service network-manager stop
sudo rm /var/lib/NetworkManager/NetworkManager.state
sudo service network-manager start

//以下两部作为备用
sudo gedit /etc/NetworkManager/NetworkManager.conf
(把false改成true)
sudo service network-manager restart

底板声音调节

sudo service network-manager stop
tinymix “LINEOUT volume” “31”
tinymix “digital volume” “0”

全志硬件编解码

源码参考路径:/opt/EmbedSky/TQT507/CoreA/longan/platform/framework/auto/sdk_demo/
关于mali的s路径位置: /opt/EmbedSky/TQT507/CoreA/longan/out/t507/evb/longan/buildroot/target/usr/lib/libmali.so

驱动挂载

mount 可直接理解为“挂载”挂接光驱、USB设备的目录,加载后,会在mnt里多出相应设备的目录。

//开发板那边执行
mount -t nfs -o nolock,vers=3 192.168.5.12:/home/book/nfs_rootfs /mnt

cp led_platform_driver.ko /home/book/nfs_rootfs
cp main /home/book/nfs_rootfs

查看挂载文件

ls -l /mnt/
rm xxx 删除

格式u盘

查看U盘 sudo fdisk -l
卸载文件系统 sudo umount /dev/sdb1
挂载文件 mount /dev/mmcblk1p1 /etc/fstab

mount /dev/mmcblk1 /etc/upfile //128gb 256gb 512gb

格式化成为ext3文件系统 sudo mkfs -V -t ext3 /dev/sdb1
//可以格式化的格式有:ext2、ext3、ext4、vfat、nfs等

新建文件夹: mkdir xxx
查看容量: df -h
查看磁盘分区的UUID: blkid
查看当前系统挂载的信息: cat /etc/fstab
查看分区的label和uuid : dumpe2fs -h /dev/mmcblk1p1

配置开机自动挂载:
vim /etc/fstab
加入:
UUID=“de263213-addb-47b7-9101-5c474ef32f79” /tfcard ext3 defaults 0 1

修改完成/etc/fstab后,执行mount –a验证一下命令是否正确。

测试wifi(6221A)

测试wifi联网 cd /test_utils/wifi/sta && sh link.sh
1 编译内核驱动 8723 此处使用的是8723ds.ko
6223A芯片,8723ds.ko驱动
6221A芯片,8821cs.ko驱动
2 装载驱动 insmod /lib/modules/4.9.170/8723ds.ko
3 进入测试目录 cd /test_utils/wifi/sta
4 计算 ssid 与密码 wpa_passphrase test 12345678
将生成的psk作为密码项复制到 wpa_supplicant.conf
5 修改wifi名称和密码 vi wpa_supplicant.conf
6 开始链接 sh link.sh

wpa_passphrase mate20pro— shuaishuaishuai

测试wifi广域网,使用wget,实测只能下载http文件ftp文件,无法下载https文件
测试链接 wget -O /dev/null http://139.196.72.37:9121/file/test/test.tar.gz

测试wifi局域网使用 iperf 工具,因为linux上版本是2.所以win上下载也应该是2

Win下载地址
https://iperf.fr/download/windows/iperf-2.0.9-win64.zip
此处测试,模拟真实环境,电脑作为客户端,板子作为服务端,
板子上执行指令 iperf -s -w 50M
(板子作服务器,tcp窗口设置为50M,实际测试最大设置为448kbyte)

电脑端执行指令 iperf -c 172.16.88.238 -t 10 –i 1 –w 50M
(电脑端做客户端,链接ip服务器,总时间10秒,没1秒打印一次信息,tcp窗口设置为50M)

设置http开启wifi热点
cd /test_utils/wifi/ap
sh send_ap.sh

cd /test_utils/wifi/ap && sh send_ap.sh

iperf -s -w 50M
iperf -c 192.168.0.2 -t 600 -i 2 -w 50M

测试蓝牙

串口蓝牙
rtk_hciattach -n -s 115200 /dev/ttySAC1 rtk_h5&
hciconfig -a
hciconfig hci0 up
先扫描,看看结果 hcitool scan
使本设备自身可被发现 hciconfig hci0 piscan
进入 bluetoothctl 的预处理 /usr/libexec/bluetooth/bluetoothd -C -n &
进入 bluetoothctl 指令 bluetoothctl
bluetoothctl 常用指令(可以用于蓝牙配对)
scan on
scan off
discoverable on
agent NoInputNoOutput
default-agent
pair xx:xx:xx:xx:xx:xx
quit
使用 obexctl 传文件
预处理 /usr/libexec/bluetooth/obexd -r /mnt -a -n &
进入 obexctl 终端 obexctl
connect xx:xx:xx:xx:xx:xx
发送文件到手机,如:/sendfile.txt(注意传输的文件名称或者类型,同名文件等可能被手机重命名,某些类型的文件可能不能被手机接收)(注意传输文件名称时,是从根文件开始的)
send /sendfile.txt
quit

编译sqlite3

https://www.sqlite.org/download.html
下载 https://www.sqlite.org/2023/sqlite-autoconf-3420000.tar.gz
编译 参考 https://blog.csdn.net/CSDN_dyq111/article/details/109843092
./configure --help
./configure CC=aarch64-linux-gnu-gcc --host=arm64 --prefix=/opt/install --enable-shared
make clean && make -j4 && make install
安装
ln -s ./libsqlite3.so.0.8.6 libsqlite3.so
ln -s ./libsqlite3.so.0.8.6 libsqlite3.so.0

Dface人脸识别

测试码 (SN_CODE)
BDLIAK37BE2BG5YE

申请网页
https://user.bitanswer.cn/logon

注意时间校准

离线授权
./tools/licenceLocalInfo [SN_CODE] [OUTPUT_FILE]
此处 ./tools/licenceLocalInfo BDLIAK37BE2BG5YE code_2023_07_14.txt

激活
./tools/licenceAuthOffline [UPDATE_FILE]
此处 ./tools/licenceAuthOffline 2023-07-08_BDLIAK37BE2BG5YE.upd

设备号

查看主设备号 cat /proc/devices

驱动调试

date -s 2023-07-24
date -s 18:33:48
hwclock -w
ifconfig eth1 192.168.5.8 up
passwd root

cat /dev/input/event5 | hexdump 触摸屏测试。
cat /proc/bus/input/devices 查看输入设备列表

放在开发板里面执行:
mount -t nfs -o nolock,vers=3 192.168.5.12:/home/book/nfs_rootfs /mnt

usb串口驱动
kernel/linux-4.9/drivers/usb/serial
sudo make -C /opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/ M=‘pwd’/kernel/linux-4.9/drivers/usb/serial

cp SC7A20_i2c_driver.ko /lib/modules/4.9.170
cp SC7A20_i2c_driver.c /opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/drivers/i2c/
cp SC7A20_i2c_reg.h /opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/drivers/i2c/

//设备树目录
/proc/device-tree/soc@03000000/twi@0x05003000/RDA5807M@11

insmod /lib/modules/4.9.170/led3.ko
rmmod /lib/modules/4.9.170/led3.ko

加载驱动insmod以及 modprobe(第一次在模块下调用depmod命令)
卸载驱动 rmmod
查看挂载的驱动 lsmod

创建设备节点 mknod /dev/nameHello c 200 0
查看节点 ls /dev/nameHello -l

查看当前控制台的打印级别 cat /proc/sys/kernel/printk
4 4 1 7
其中第一个“4”表示内核打印函数printk的打印级别,只有级别比他高的信息才能在控制台上打印出来,既 0-3级别的信息

修改打印
echo “新的打印级别 4 1 7” > /proc/sys/kernel/printk

查看日志 dmesg | grep hello_
清空日志 dmesg -c

Pwm设备树文档位置
/opt/EmbedSky/TQT507/CoreA/longan/kernel/linux-4.9/Documentation/devicetree/bindings/pwm/

4G模块使用

获取 USB 设备的供应商 ID(Vendor ID)和产品 ID(Product ID):lsusb

 /dev/ttyUSB0 Diagnostic port for log messages
 /dev/ttyUSB1 AT port for AT commands communication
 /dev/ttyUSB2 Modem port for PPP dial up
 /dev/ttyUSB3 NMEA port for GNSS NMEA message output

测试:cat /dev/ttyUSB3 &
echo -e “at\r\n”>/dev/ttyUSB1
echo -e “AT+CGNSSPWR=1\r\n”>/dev/ttyUSB1
echo -e “AT+CGNSSTST=1\r\n”>/dev/ttyUSB1
echo -ne " AT+CGNSSPWR=1\r\n" | busybox microcom -t 9000 /dev/ttyUSB2
echo -ne “AT+CGNSSTST=1\r\n” | busybox microcom -t 300 /dev/ttyUSB2
echo -ne “AT+CGNSSTST=0\r\n” | busybox microcom -t 300 /dev/ttyUSB2

echo -ne “AT+CGNSSINFO\r\n” | busybox microcom -t 1000 /dev/ttyUSB2
busybox microcom -t 9000 /dev/ttyUSB3

//网卡配置
echo -ne “AT+DIALMODE?\r\n” | busybox microcom -t 300 /dev/ttyUSB2
echo -ne “AT+DIALMODE=0\r\n” | busybox microcom -t 300 /dev/ttyUSB2 //0打开usbnet

echo -ne “AT$MYCONFIG?\r\n” | busybox microcom -t 300 /dev/ttyUSB2
echo -ne “AT$MYCONFIG=“usbnetmode”,0\r\n” | busybox microcom -t 300 /dev/ttyUSB2

echo -ne “AT+USBNETIP?\r\n” | busybox microcom -t 300 /dev/ttyUSB2
echo -ne “AT+USBNETIP=1\r\n” | busybox microcom -t 300 /dev/ttyUSB2

echo -ne “AT+USBNETMAC?\r\n” | busybox microcom -t 300 /dev/ttyUSB2

echo -ne " AT+CPSI?\r\n" | busybox microcom -t 300 /dev/ttyUSB2

udhcpc -i usb0 //自动获取ip地址

sudo bash //乌班图上面用
sudo echo -ne “at+simcomati\r\n” | busybox microcom -t 3000 /dev/ttyUSB2 //查看版本号
echo -e “at+simcomati\r\n”>/dev/ttyUSB1

拨号:pppd call simcom-pppd-asr &
断开:

下wget –P /etc/upfile https://files-cdn.cnblogs.com/files/RYSBlog/YUVPlayer.zip?t=1667271754&download=true
http://www.126xiaoshuo.cc/api/txt_down.php?articleid=75994&articlename=%E6%98%9F%E9%97%A8

simcom-connect-chat-lt:
联通:
#named simcom-connect-chat and place in /etc/ppp/peers
ABORT “BUSY”
ABORT “NO CARRIER”
ABORT “NO DIALTONE”
ABORT “ERROR”
ABORT “NO ANSWER”
TIMEOUT 30
“” AT
OK ATE0
OK ATI;+CSQ;+CPIN?;+COPS?;+CGREG?;&D2

Insert the APN provided by your network operator, default apn is 3gnet

#zhou add… liantong
OK AT+CGDCONT=1,“IP”,“3GNET”,0,0
OK ATD*99#
CONNECT

移动:
#named simcom-connect-chat and place in /etc/ppp/peers
ABORT “BUSY”
ABORT “NO CARRIER”
ABORT “NO DIALTONE”
ABORT “ERROR”
ABORT “NO ANSWER”
TIMEOUT 30
“” AT
OK ATE0
OK ATI;+CSQ;+CPIN?;+COPS?;+CGREG?;&D2

Insert the APN provided by your network operator, default apn is 3gnet

OK AT+CGDCONT=1,“IP”,“cmnet”,0,0
OK ATD99**1#
CONNECT

电信:
#named simcom-connect-chat and place in /etc/ppp/peers
ABORT “BUSY”
ABORT “NO CARRIER”
ABORT “NO DIALTONE”
ABORT “ERROR”
ABORT “NO ANSWER”
TIMEOUT 30
“” AT
OK ATE0
OK ATI;+CSQ;+CPIN?;+COPS?;+CGREG?;&D2

dianxin

OK AT+CGDCONT=1,“IP”,“CTNET”,0,0
OK ATD*99#
CONNECT

测试wifi

测试wifi联网 cd /test_utils/wifi/sta && sh link.sh
1 编译内核驱动 8723 此处使用的是8723ds.ko
6223A芯片,8723ds.ko驱动
6221A芯片,8821cs.ko驱动
2 装载驱动 insmod /lib/modules/4.9.170/8723ds.ko
3 进入测试目录 cd /test_utils/wifi/sta
4 计算 ssid 与密码 wpa_passphrase test 12345678
将生成的psk作为密码项复制到 wpa_supplicant.conf
5 修改wifi名称和密码 vi wpa_supplicant.conf
6 开始链接 sh link.sh

wpa_passphrase mate20pro— shuaishuaishuai

测试wifi广域网,使用wget,实测只能下载http文件ftp文件,无法下载https文件
测试链接 wget -O /dev/null http://139.196.72.37:9121/file/test/test.tar.gz

测试wifi局域网使用 iperf 工具,因为linux上版本是2.所以win上下载也应该是2

Win下载地址
https://iperf.fr/download/windows/iperf-2.0.9-win64.zip
此处测试,模拟真实环境,电脑作为客户端,板子作为服务端,
板子上执行指令 iperf -s -w 50M
(板子作服务器,tcp窗口设置为50M,实际测试最大设置为448kbyte)

电脑端执行指令 iperf -c 172.16.88.238 -t 10 –i 1 –w 50M
(电脑端做客户端,链接ip服务器,总时间10秒,没1秒打印一次信息,tcp窗口设置为50M)

设置http开启wifi热点
cd /test_utils/wifi/ap
sh send_ap.sh

cd /test_utils/wifi/ap && sh send_ap.sh

iperf -s -w 50M
iperf -c 192.168.0.2 -t 600 -i 2 -w 50M

测试蓝牙

串口蓝牙
rtk_hciattach -n -s 115200 /dev/ttySAC1 rtk_h5&
hciconfig -a
hciconfig hci0 up
先扫描,看看结果 hcitool scan
使本设备自身可被发现 hciconfig hci0 piscan
进入 bluetoothctl 的预处理 /usr/libexec/bluetooth/bluetoothd -C -n &
进入 bluetoothctl 指令 bluetoothctl
bluetoothctl 常用指令(可以用于蓝牙配对)
scan on
scan off
discoverable on
agent NoInputNoOutput
default-agent
pair xx:xx:xx:xx:xx:xx
quit
使用 obexctl 传文件
预处理 /usr/libexec/bluetooth/obexd -r /mnt -a -n &
进入 obexctl 终端 obexctl
connect xx:xx:xx:xx:xx:xx
发送文件到手机,如:/sendfile.txt(注意传输的文件名称或者类型,同名文件等可能被手机重命名,某些类型的文件可能不能被手机接收)(注意传输文件名称时,是从根文件开始的)
send /sendfile.txt
quit

查询 所有的输入子系统的设备

cat /proc/bus/input/devices
cat /dev/input/event1 | hexdump
cat /dev/input/event0 | hexdump

cat /dev/input/event2 | hexdump

修改默认密码

在这里插入图片描述
#修改buildroot配置
cd /opt/EmbedSky/TQT507/CoreA/longan/
cd ./buildroot/buildroot-201902/
make menuconfig ARCH=arm64 O=…/…/out/t507/evb/longan/buildroot/

驱动应用使用

Linux的man 1 2 3用法.
查看系统命令man 1 ls
查看open –》 man 2 open
参看库函数 man 3 printf

单独编译应用 aarch64-linux-gnu-gcc main.c -o main
运行应用 ./main /dev/nameHello

fbinit ff
kill
ps

加上可执行权限 chmod +x ./testApp

设备树

Dts一般存放为位置arch/arm/boot/dts 或者 arch/arm64/boot/dts

标签:完整名称@地址

设备树在系统中的体现,存放在根节点 /proc/device-tree/目录下面。采用cat查看。

DTS DTB DTC的关系
DTS相当于源码,编译后生成DTB,DTC是编译DTS的工具。

#include”xxxxx.dtsi”

/{
chosen{
};

aliases{
};
}

节点chosen主要是为了uboot向linux内核传递数据,重点是bootargs参数。一般.dts文件中chosen节点通常为空或者内容很少。

Uboot接触过dtb,最终通过bootz 80800000—83000000来启动内核;在uboot源码中查找common/fdt_support.c文件中有chosen属性,里面有个fdt_chosen;

设备树标准属性
compatible属性 用于描述兼容性,内容是一连串字符串。

	老的方案,在内核里添加一个机器ID号:
  • 1

MACHINE_START(_type,_name) //在内核里添加了一个ID号
……
MACHINE_END
这个id放在了mach-types.h内。

新的方案,使用设备树,不使用机器ID,而是使用根节点/下的compatible属性。在arch.h中定义了DT_ MACHINE_START
DT_ MACHINE_START(_name,_namestr)
……
MACHINE_END

model属性 描述设备模块信息。
status属性 描述设备状态 “okay”表示设备可用;“disabled”表示不可操作,但是未来可以变为可操作;“fail”表明设备不可操作;“fail-sss”和fail的含义相同,后面的sss部分是检测到的错误内容。
reg 属性 描述地址相关的。reg = <起始地址1 地址长度1 ……>;
  • 1
  • 2
  • 3

#address-cells=<1>; #size-cells=<1>;地址个数为1,地址长度个数为1;注意,这只是影响了子节点,不会影响父节点。
Ranges属性 是一个地址映射/转换表,ranges属性每个项目由子地址、父地址和地址空间长度三部分组成:chil-bus-address,parent-bus-address,length.

设备树dtb复制到开发板:cp arch/arm/boot/dts/xxxxxx.dtb /home/zzk/linux/tftpboot/ -f

Linux内核的OF操作函数

在驱动中使用OF函数获取设备树属性内容。Include/linux/of.h

驱动获取结构体设备树节点内容:of_find_node_by_name(起始位置,查找的名字);
//起始位置如果是NULL就表示根节点开始。
通过device_type属性查找指定的节点:of_find_node_by_type(起始位置,device_type属性值);
of_find_compatible_node(…);
of_find_matching_node_and_match(…);
of_find_node_by_path(const char *path);
……
struct device_node{
const char *name;/节点名字/
……
};

of_find_ property(const struct device_node *np,const char *name,int *lenp);
int of_property_count_elems_of_size(const struct device_node *np,const char *propname,int *lenp);//返回属性数量
struct property {
char *name;
……
};

Linux驱动中对gpio的操作函数

  1. 首先,获取GPIO所处的设备节点,比如:of_find_node_by_path.
  2. 获取GPIO编号,of_get_named_gpio函数,返回值就是GPIO编号。
  3. 请求此GPIO编号,gpio_request函数
  4. 设置GPIO,输入或输出,gpio_direction_input或gpio_direction_output.
  5. 如果是输入,通过gpio_get_value函数读取GPIO值,如果是输出,通过gpio_set_value.

Linux内核定时器

1.定义一个结构体 time_list 头文件#include <linux/timer.h> 和 #include <linux/jiffies.h>
2. 初始化定时器
init_timer(&led3_dev.timer);
led3_dev.timer.function = my_timer_func;
led3_dev.timer.expires = jiffies + msecs_to_jiffies(100);
led3_dev.timer.data = (unsigned long)&led3_dev;
add_timer(&led3_dev.timer);
3.定时器处理函数
static void my_timer_func(unsigned long arg)
{
struct led3_dev dev = (struct led3_dev)arg;
mod_timer(dev->timer,jiffies + msecs_to_jiffies(100));
}

Linux驱动ioctl用法

有两个compat_ioctl或者unlocked_ioctl,这两个函数功能一样,区别在于在64位系统上,32位的应用程序调用将会使用此函数。在32位的系统上运行32位的应用程序调用的是unlocked_ioctl.

函数原型 : long (*unlocked_ioctl)(struct file *,unsigned int ,unsigned long)
Ioctl的命令是自己定义的,但是要符合linux规则。定义规格则
#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size)))
#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))

Linux的platform驱动

注册platform device 函数:int platform_device_register(struct platform_device *pdev);
卸载 platform_device_unregister(struct platform_device *pdev);

static const struct of_device_id led_of_match[] =
{
{
.compatible = “alientek,gpioled”,
},
{
/Sentinel/
},
};

static struct platform_driver led_platform_driver = {
.driver = {
.name = “platform_led”,//无设备树的时候,用于名字匹配
.of_match_table = led_of_match,//设备树匹配表
},
.probe = led_driver_probe,
.remove = led_driver_remove,

};

//可以采用宏代替
module_platform_driver(led_pwm_driver);

驱动函数接口

  1. container_of的用途说明
    container_of的主要作用是:通过已知的一个数据结构成员指针ptr,数据结构类型type,以及这个成员指针在这个数据结构中的成员名member,来获取指向这个数据结构的指针type *。

FrameBuffer与屏幕显示
驱动框架:

根目录说明

linux系统根目录下各个目录用途说明:
1、/ 根目录 --------- 所有目录挂在其下
2、/boot --------- 存放Ubuntu内核和系统启动文件。系统启动时这些文件先被装载。
3、/etc --------- 系统的配置文件目录。密码文件、设置网卡信息、环境变量的设置等都在此目录中,许多网络配置文件也在其中。
4、/lib --------- 根文件系统目录下程序和核心模块的共享库。这个目录里存放着系统最基本的动态链接共享库,类似于Windows下的system32目录,几乎所有的应用程序都需要用到这些共享库。
5、/media --------- 主要用于挂载多媒体设备。ubuntu系统自动挂载的光驱、usb设备,存放临时读入的文件。
6、/proc --------- 这个目录是系统内存的映射,我们可以直接访问这个目录来获取系统信息。也就是说,这个目录的内容不在硬盘上而是在内存里。
7、/sbin   --------- s就是Super User的意思,这里存放的是系统管理员使用的系统管理程序,如系统管理、目录查询等关键命令文件。
8、/tmp --------- 这个目录是用来存放一些临时文件的,所有用户对此目录都有读写权限。
9、/home  --------- 用户的主目录。下面是自己定义的用户名的文件夹。每个用户的设置文件,用户的桌面文件夹,还有用户的数据都放在这里。
10、/mnt   --------- 此目录主要是作为挂载点使用。通常包括系统引导后被挂载的文件系统的挂载点。如挂载Windows下的某个分区。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/134509
推荐阅读
相关标签
  

闽ICP备14008679号