关于IT8951 Tinydrm Driver开源项目学习的心得

关于IT8951 Tinydrm Driver开源项目学习的心得

项目名称: julbouln/tinydrm_it8951
项目链接:https://github.com/julbouln/tinydrm_it8951

以下是该项目的README.md正文:

tinydrm kernel module for Waveshare it8951 based eink kits

Tested on raspberry pi zero w with kernel 4.19, only 6" panel is
supported

Setup (on raspian):

$ cd tinydrm_it8951 $ make

you can test it with

$ sudo sh utils/load.sh

To enable the screen at boot:

Raspberry Pi

  • copy it8951.ko in your /lib/modules directory (eg /lib/modules/4.19.66+/kernel/drivers/gpu/drm/tinydrm/)
  • generate overlay : sudo make rpi_overlay
  • add modules tinydrm and it8951 in /etc/modules
  • add a line “dtoverlay=it8951” in /boot/config.txt
  • add “fbcon=map:1 vt.color=0xf0” at the end of /boot/cmdline.txt
  • to disable cursor blinking, add a line “echo 0 > /sys/class/graphics/fbcon/cursor_blink” in /etc/rc.local

Beaglebone

  • generate overlay: sudo make bb_spi0_overlay
  • sudo cp IT8951-00A0.dtbo /lib/firmware/
  • edit /boot/uEnv.txt to add dtb : dtb_overlay=/lib/firmware/IT8951-00A0.dtbo - add “vt.color=0xf0” at
    the end of cmdline= in /boot/uEnv.txt

You can now reboot, the eink panel will be the screen by default

验证用硬件平台:Raspberry Zero W
从树莓派官网下载和制作启动TF卡的步骤省略,连接显示器键盘完成wifi和ssh的配置,重新启动,通过ssh连接树莓派。

Connecting to 172.20.10.2:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Linux raspberrypi 4.19.93+ #1290 Fri Jan 10 16:34:37 GMT 2020 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Tue Jan 28 04:43:37 2020 from 172.20.10.3
pi@raspberrypi:~ $ 

更新树莓派的系统文件然后重启设备。

$sudo apt-get update
$sudo apt-get upgrade

Processing triggers for libc-bin (2.28-10+rpi1) ...
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for dbus (1.12.16-1) ...
Processing triggers for install-info (6.5.0.dfsg.1-4+b1) ...
pi@raspberrypi:~ $ sudo reboot
Connection closing...Socket close.

Connection closed by foreign host.

Disconnected from remote host(Raspi-Zero-Hyman) at 13:24:15.

Type `help' to learn how to use Xshell prompt.
[D:\~]$ 

所有准备工作完成开始测试。

1. 克隆项目
git clone https://github.com/julbouln/tinydrm_it8951.git
2. 编译
pi@raspberrypi:~ $ cd tinydrm_it8951/
pi@raspberrypi:~/tinydrm_it8951 $ make
make -C /lib/modules/`uname -r`/build M=$PWD
make[1]: Entering directory '/usr/src/linux-headers-4.19.93+'
  CC [M]  /home/pi/tinydrm_it8951/it8951.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/pi/tinydrm_it8951/it8951.mod.o
  LD [M]  /home/pi/tinydrm_it8951/it8951.ko
make[1]: Leaving directory '/usr/src/linux-headers-4.19.93+'
pi@raspberrypi:~/tinydrm_it8951 $ 

如果编译时出现类似错误,说明内核头文件没有安装

make -C /lib/modules/`uname -r`/build M=$PWD
make[1]: *** /lib/modules/4.19.75-v7l+/build: 没有那个文件或目录。 停止。
make: *** [Makefile:4:default] 错误 2

需要先安装内核头文件后执行编译

sudo apt-get install raspberrypi-kernel-headers
3. 将编译好的it8951.ko拷贝到系统文件夹
pi@raspberrypi:~/tinydrm_it8951 $ sudo cp it8951.ko /lib/modules/4.19.93+/kernel/drivers/gpu/drm/tinydrm/
pi@raspberrypi:~/tinydrm_it8951 $ ls /lib/modules/4.19.93+/kernel/drivers/gpu/drm/tinydrm/
core  ili9225.ko  ili9341.ko  it8951.ko  mi0283qt.ko  mipi-dbi.ko  repaper.ko  st7586.ko  st7735r.ko
4. generate overlay : sudo make rpi_overlay
pi@raspberrypi:~/tinydrm_it8951 $ sudo make rpi_overlay 
dtc -I dts -O dtb -o boot/overlays/it8951.dtb rpi-overlays/it8951-overlay.dts
boot/overlays/it8951.dtb: Warning (unit_address_vs_reg): /fragment@0/__overlay__/spidev@0: node has a uniname, but no reg property
boot/overlays/it8951.dtb: Warning (unit_address_vs_reg): /fragment@0/__overlay__/spidev@1: node has a uniname, but no reg property
FATAL ERROR: Couldn't open output file boot/overlays/it8951.dtb: No such file or directory
make: *** [Makefile:13: rpi_overlay] Error 1

这里发生一个错误,经过检查发现,Makefile中rpi_overlay选项下目标文件路径少写了一个‘/’。

原文件:

KDIR ?= /lib/modules/`uname -r`/build

default:
	$(MAKE) -C $(KDIR) M=$$PWD

install:
	$(MAKE) -C $(KDIR) M=$$PWD modules_install

clean:
	$(MAKE) -C $(KDIR) M=$$PWD clean

rpi_overlay:
	dtc -I dts -O dtb -o boot/overlays/it8951.dtb rpi-overlays/it8951-overlay.dts
bb_spi0_overlay:
	cpp -x assembler-with-cpp -nostdinc -I /opt/source/dtb-4.19-ti/include -undef -D__DTS__ bbb-overlays/IT8951-SPI0-00A0.dts | dtc -i /opt/source/dtb-4.19-ti/include -I dts -O dtb -b 0 -o /lib/firmware/IT8951-SPI0-00A0.dtbo -
bb_spi1_overlay:
	cpp -x assembler-with-cpp -nostdinc -I /opt/source/dtb-4.19-ti/include -undef -D__DTS__ bbb-overlays/IT8951-SPI1-00A0.dts | dtc -i /opt/source/dtb-4.19-ti/include -I dts -O dtb -b 0 -o /lib/firmware/IT8951-SPI1-00A0.dtbo -

修改为:

KDIR ?= /lib/modules/`uname -r`/build

default:
	$(MAKE) -C $(KDIR) M=$$PWD

install:
	$(MAKE) -C $(KDIR) M=$$PWD modules_install

clean:
	$(MAKE) -C $(KDIR) M=$$PWD clean

rpi_overlay:
	dtc -I dts -O dtb -o /boot/overlays/it8951.dtb rpi-overlays/it8951-overlay.dts
bb_spi0_overlay:
	cpp -x assembler-with-cpp -nostdinc -I /opt/source/dtb-4.19-ti/include -undef -D__DTS__ bbb-overlays/IT8951-SPI0-00A0.dts | dtc -i /opt/source/dtb-4.19-ti/include -I dts -O dtb -b 0 -o /lib/firmware/IT8951-SPI0-00A0.dtbo -
bb_spi1_overlay:
	cpp -x assembler-with-cpp -nostdinc -I /opt/source/dtb-4.19-ti/include -undef -D__DTS__ bbb-overlays/IT8951-SPI1-00A0.dts | dtc -i /opt/source/dtb-4.19-ti/include -I dts -O dtb -b 0 -o /lib/firmware/IT8951-SPI1-00A0.dtbo -
	

修改Makefile文件后重新编译:

pi@raspberrypi:~/tinydrm_it8951 $ nano Makefile 
pi@raspberrypi:~/tinydrm_it8951 $ sudo make rpi_overlay 
dtc -I dts -O dtb -o /boot/overlays/it8951.dtb rpi-overlays/it8951-overlay.dts
/boot/overlays/it8951.dtb: Warning (unit_address_vs_reg): /fragment@0/__overlay__/spidev@0: node has a un name, but no reg property
/boot/overlays/it8951.dtb: Warning (unit_address_vs_reg): /fragment@0/__overlay__/spidev@1: node has a un name, but no reg property
pi@raspberrypi:~/tinydrm_it8951 $ 
5. add modules tinydrm and it8951 in /etc/modules
pi@raspberrypi:~/tinydrm_it8951 $ sudo nano /etc/modules

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
tinydrm
it8951
6. add a line “dtoverlay=it8951” in /boot/config.txt
pi@raspberrypi:~/tinydrm_it8951 $ sudo nano /boot/config.txt 

[all]
#dtoverlay=vc4-fkms-v3d
dtoverlay=it8951
7. add “fbcon=map:1 vt.color=0xf0” at the end of /boot/cmdline.txt
pi@raspberrypi:~/tinydrm_it8951 $ sudo nano /boot/cmdline.txt 

console=serial0,115200 console=tty1 root=PARTUUID=6c586e13-02 rootfstype=ext4 elevator=deadline fsck.re$…………$sck.repair=yes rootwait fbcon=map:1 vt.color=0xf0

8. add a line “echo 0 > /sys/class/graphics/fbcon/cursor_blink” in /etc/rc.local
pi@raspberrypi:~/tinydrm_it8951 $ sudo nano /etc/rc.local

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi
echo 0 > /sys/class/graphics/fbcon/cursor_blink

exit 0
9. 编译安装完成,重启检查模块是否加载正常
pi@raspberrypi:~/tinydrm_it8951 $ sudo reboot
pi@raspberrypi:~/tinydrm_it8951 $ Connection closing...Socket close.

Connection closed by foreign host.

Disconnected from remote host(Raspi-Zero-Hyman) at 15:25:55.

Type `help' to learn how to use Xshell prompt.
[D:\~]$ 

Connecting to 172.20.10.2:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Linux raspberrypi 4.19.93+ #1290 Fri Jan 10 16:34:37 GMT 2020 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Tue Jan 28 07:20:11 2020 from 172.20.10.3
pi@raspberrypi:~ $ lsmod | grep "it8951"
it8951                 20480  0
tinydrm                24576  1 it8951
drm_kms_helper        184320  4 tinydrm,it8951
drm                   430080  4 tinydrm,it8951,drm_kms_helper
pi@raspberrypi:~ $ cd tinydrm_it8951/
10. 成功
  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hymnal

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值