在Raspberry Pi Zero W中配置TFT LCD Framebuffer驱动

TFT LCD Framebuffer驱动配置

文章目录

  • TFT LCD Framebuffer驱动配置
    • 1、硬件准备
    • 2、软件配置
      • 2.1 启用SPI驱动
      • 2.2 TFT LCD设备驱动树配置

本文将以ILI9341 LCD为例,将详细介绍如何配置TFT LCD的Framebuffer驱动。

1、硬件准备

  • Raspberry Pi Zero W开发板一个(镜像Linux内核版本为5.18.84+)
  • TFT LCD 模块一个(ILI9341驱动IC)
  • 连接线
  • 数据线
  • 面包板

TFT LCD与Raspberry Pi Zero W接线如下:

序号TFT LCDRaspberry PI
1VCC3.3V或5V
2GNDGND
3SCKGPIO 11 SCLK (SPI0)
4SDAGPIO10 MOSI (SPI0)
5RSTGPIO 6
6DCGPIO 5
7CSGPIO8 Chip-Enable-CE0(SPI0)

Raspberry PI Zero W的引脚如下:

在这里插入图片描述

2、软件配置

2.1 启用SPI驱动

在命令行中输入:

sudo raspi-config

在这里插入图片描述

选择3 Interface Options进入接口驱动配置页面:

在这里插入图片描述

选择I4 SPI Enable/disable automatic loading of SPI kernel module开启或关闭SPI驱动。

另外,如果不想在命令中配置,也可以在图形界面中配置。还可以修改/boot/config.txt文件:

在这里插入图片描述

#符号删除即可启用spi。

2.2 TFT LCD设备驱动树配置

下面将创建自定义的DTS文件。下面将创建一个名称为ili9341.dts的文件。其内容如下:

/dts-v1/;
/plugin/;/ {compatible = "brcm,bcm2835";// Enable the SPI controllerfragment@0 {target = <&spi0>;__overlay__ {status = "okay";};};// Enabling the SPI controller also enables spidev on cs0, so we have disable itfragment@1 {target = <&spidev0>;__overlay__ {status = "disabled";};};fragment@2 {target = <&spi0>;__overlay__ {/* needed to avoid dtc warning */#address-cells = <1>;#size-cells = <0>;display: display@0{// MIPI DBI compatible driver// This driver is used because it can ignore an illegal rotate value// and doesn't have a set_gamma() function.compatible = "ilitek,ili9341";reg = <0>; // Chip Select 0spi-max-frequency = <32000000>; // 32MHzreset-gpios = <&gpio 6 1>; // reset is active low hence the 1dc-gpios = <&gpio 5 0>;width = <320>;height = <240>;buswidth = <8>; // Most controllers use this value// This is a hack to prevent fb_s6d02a1.c:set_var() from issuing// command 0x36 after the init sequence has been applied and thus// changing the config.rotate = <1>;// see drivers/staging/fbtft/fb_ili9341.c:init_display() for how this looks in the driver// Command 0x36 is taken from the fb_ili9341.c:set_var() function.init = <0x10000010x20000050x10000280x10000cf 0x00 0x83 0x300x10000ed 0x64 0x03 0x12 0x810x10000e8 0x85 0x01 0x790x10000cb 0x39 0x2c 0x00 0x34 0x020x10000f7 0x200x10000ea 0x00 0x000x10000c0 0x260x10000c1 0x110x10000c5 0x35 0x3e0x10000c7 0xbe0x100003a 0x550x1000036 0x280x10000b1 0x00 0x1b0x1000026 0x010x10000f2 0x080x1000026 0x010x10000e0 0x1f 0x1a 0x18 0x0a 0x0f 0x06 0x45 0x87 0x32 0x0a 0x07 0x02 0x07 0x05 0x000x10000e1 0x00 0x25 0x27 0x05 0x10 0x09 0x3a 0x78 0x4d 0x05 0x18 0x0d 0x38 0x3a 0x1f0x10000b7 0x070x10000b6 0x0a 0x82 0x27 0x000x10000110x20000640x10000290x2000064>;debug = <0x4000000>; // print init commands to the kernel log};};};
};

请根据自己的接线修改引脚:

  • reset-gpios:LCD 的RES引脚
  • dc-gpios:LCD的DC引脚

init为LCD的初始化指令。

编译DTS

在命令行中,执行如下命令:

dtc -o ili9341.dtbo ili9341.dts

将编译好的dtbo文件复制到/boot/overlays/

sudo cp ili9341.dtbo /boot/overlays/

配置overlays

打开/boot/config.txt文件,在文件末尾添加如下内容:

dtoverlay=ili9341

保存并重新启动系统。在系统启动完成后,在命令行执行命令:

dmesg

可以看到TFT的Framebuffer内核日志信息:

[   40.657276] fbtft: module is from the staging directory, the quality is unknown, you have been warned.
[   40.911475] fb_ili9341: module is from the staging directory, the quality is unknown, you have been warned.
[   41.314042] SPI driver fb_ili9341 has no spi_device_id for ilitek,ili9341
[   41.314487] fb_ili9341 spi0.0: fbtft_property_value: width = 320
[   41.314532] fb_ili9341 spi0.0: fbtft_property_value: height = 240
[   41.314562] fb_ili9341 spi0.0: fbtft_property_value: buswidth = 8
[   41.314594] fb_ili9341 spi0.0: fbtft_property_value: debug = 67108864
[   41.314620] fb_ili9341 spi0.0: fbtft_property_value: rotate = 1
[   41.457358] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[   41.515507] fb_ili9341 spi0.0: init: write_register:
[   41.515554] fb_ili9341 spi0.0: buf[0] = 01
[   41.515705] fb_ili9341 spi0.0: init: msleep(5)
[   41.547050] fb_ili9341 spi0.0: init: write_register:
[   41.547097] fb_ili9341 spi0.0: buf[0] = 28
[   41.549533] fb_ili9341 spi0.0: init: write_register:
[   41.549576] fb_ili9341 spi0.0: buf[0] = CF
[   41.549607] fb_ili9341 spi0.0: buf[1] = 00
[   41.549628] fb_ili9341 spi0.0: buf[2] = 83
[   41.549649] fb_ili9341 spi0.0: buf[3] = 30
[   41.550784] fb_ili9341 spi0.0: init: write_register:
[   41.550821] fb_ili9341 spi0.0: buf[0] = ED
[   41.550848] fb_ili9341 spi0.0: buf[1] = 64
[   41.550868] fb_ili9341 spi0.0: buf[2] = 03
[   41.550888] fb_ili9341 spi0.0: buf[3] = 12
[   41.550907] fb_ili9341 spi0.0: buf[4] = 81
[   41.551978] fb_ili9341 spi0.0: init: write_register:
[   41.552019] fb_ili9341 spi0.0: buf[0] = E8
[   41.552045] fb_ili9341 spi0.0: buf[1] = 85
[   41.552067] fb_ili9341 spi0.0: buf[2] = 01
[   41.552088] fb_ili9341 spi0.0: buf[3] = 79
[   41.556254] fb_ili9341 spi0.0: init: write_register:
[   41.556350] fb_ili9341 spi0.0: buf[0] = CB
[   41.556382] fb_ili9341 spi0.0: buf[1] = 39
[   41.556404] fb_ili9341 spi0.0: buf[2] = 2C
[   41.556424] fb_ili9341 spi0.0: buf[3] = 00
[   41.556444] fb_ili9341 spi0.0: buf[4] = 34
[   41.556464] fb_ili9341 spi0.0: buf[5] = 02
[   41.558014] fb_ili9341 spi0.0: init: write_register:
[   41.558055] fb_ili9341 spi0.0: buf[0] = F7
[   41.558083] fb_ili9341 spi0.0: buf[1] = 20
[   41.559167] fb_ili9341 spi0.0: init: write_register:
[   41.559208] fb_ili9341 spi0.0: buf[0] = EA
[   41.559236] fb_ili9341 spi0.0: buf[1] = 00
[   41.559257] fb_ili9341 spi0.0: buf[2] = 00
[   41.561600] fb_ili9341 spi0.0: init: write_register:
[   41.561643] fb_ili9341 spi0.0: buf[0] = C0
[   41.561672] fb_ili9341 spi0.0: buf[1] = 26
[   41.561848] fb_ili9341 spi0.0: init: write_register:
[   41.561904] fb_ili9341 spi0.0: buf[0] = C1
[   41.561935] fb_ili9341 spi0.0: buf[1] = 11
[   41.566661] fb_ili9341 spi0.0: init: write_register:
[   41.566706] fb_ili9341 spi0.0: buf[0] = C5
[   41.566736] fb_ili9341 spi0.0: buf[1] = 35
[   41.566757] fb_ili9341 spi0.0: buf[2] = 3E
[   41.569197] fb_ili9341 spi0.0: init: write_register:
[   41.569236] fb_ili9341 spi0.0: buf[0] = C7
[   41.569267] fb_ili9341 spi0.0: buf[1] = BE
[   41.569440] fb_ili9341 spi0.0: init: write_register:
[   41.569465] fb_ili9341 spi0.0: buf[0] = 3A
[   41.569489] fb_ili9341 spi0.0: buf[1] = 55
[   41.571529] fb_ili9341 spi0.0: init: write_register:
[   41.571572] fb_ili9341 spi0.0: buf[0] = 36
[   41.571600] fb_ili9341 spi0.0: buf[1] = 28
[   41.580923] fb_ili9341 spi0.0: init: write_register:
[   41.580969] fb_ili9341 spi0.0: buf[0] = B1
[   41.580998] fb_ili9341 spi0.0: buf[1] = 00
[   41.581019] fb_ili9341 spi0.0: buf[2] = 1B
[   41.588734] fb_ili9341 spi0.0: init: write_register:
[   41.588781] fb_ili9341 spi0.0: buf[0] = 26
[   41.588811] fb_ili9341 spi0.0: buf[1] = 01
[   41.633770] fb_ili9341 spi0.0: init: write_register:
[   41.633816] fb_ili9341 spi0.0: buf[0] = F2
[   41.633847] fb_ili9341 spi0.0: buf[1] = 08
[   41.636043] fb_ili9341 spi0.0: init: write_register:
[   41.636086] fb_ili9341 spi0.0: buf[0] = 26
[   41.636116] fb_ili9341 spi0.0: buf[1] = 01
[   41.669646] fb_ili9341 spi0.0: init: write_register:
[   41.669691] fb_ili9341 spi0.0: buf[0] = E0
[   41.669720] fb_ili9341 spi0.0: buf[1] = 1F
[   41.669740] fb_ili9341 spi0.0: buf[2] = 1A
[   41.669759] fb_ili9341 spi0.0: buf[3] = 18
[   41.669779] fb_ili9341 spi0.0: buf[4] = 0A
[   41.669800] fb_ili9341 spi0.0: buf[5] = 0F
[   41.669819] fb_ili9341 spi0.0: buf[6] = 06
[   41.669838] fb_ili9341 spi0.0: buf[7] = 45
[   41.669857] fb_ili9341 spi0.0: buf[8] = 87
[   41.669877] fb_ili9341 spi0.0: buf[9] = 32
[   41.669897] fb_ili9341 spi0.0: buf[10] = 0A
[   41.669918] fb_ili9341 spi0.0: buf[11] = 07
[   41.669938] fb_ili9341 spi0.0: buf[12] = 02
[   41.669958] fb_ili9341 spi0.0: buf[13] = 07
[   41.669977] fb_ili9341 spi0.0: buf[14] = 05
[   41.669997] fb_ili9341 spi0.0: buf[15] = 00
[   41.683625] fb_ili9341 spi0.0: init: write_register:
[   41.683670] fb_ili9341 spi0.0: buf[0] = E1
[   41.683788] fb_ili9341 spi0.0: buf[1] = 00
[   41.683815] fb_ili9341 spi0.0: buf[2] = 25
[   41.683838] fb_ili9341 spi0.0: buf[3] = 27
[   41.683859] fb_ili9341 spi0.0: buf[4] = 05
[   41.683879] fb_ili9341 spi0.0: buf[5] = 10
[   41.683899] fb_ili9341 spi0.0: buf[6] = 09
[   41.683919] fb_ili9341 spi0.0: buf[7] = 3A
[   41.683939] fb_ili9341 spi0.0: buf[8] = 78
[   41.683958] fb_ili9341 spi0.0: buf[9] = 4D
[   41.683977] fb_ili9341 spi0.0: buf[10] = 05
[   41.683998] fb_ili9341 spi0.0: buf[11] = 18
[   41.684019] fb_ili9341 spi0.0: buf[12] = 0D
[   41.684038] fb_ili9341 spi0.0: buf[13] = 38
[   41.684059] fb_ili9341 spi0.0: buf[14] = 3A
[   41.684079] fb_ili9341 spi0.0: buf[15] = 1F
[   41.693430] fb_ili9341 spi0.0: init: write_register:
[   41.693474] fb_ili9341 spi0.0: buf[0] = B7
[   41.693504] fb_ili9341 spi0.0: buf[1] = 07
[   41.707164] fb_ili9341 spi0.0: init: write_register:
[   41.707209] fb_ili9341 spi0.0: buf[0] = B6
[   41.707240] fb_ili9341 spi0.0: buf[1] = 0A
[   41.707261] fb_ili9341 spi0.0: buf[2] = 82
[   41.707283] fb_ili9341 spi0.0: buf[3] = 27
[   41.707303] fb_ili9341 spi0.0: buf[4] = 00
[   41.719204] fb_ili9341 spi0.0: init: write_register:
[   41.719250] fb_ili9341 spi0.0: buf[0] = 11
[   41.721594] fb_ili9341 spi0.0: init: msleep(100)
[   41.833878] fb_ili9341 spi0.0: init: write_register:
[   41.833925] fb_ili9341 spi0.0: buf[0] = 29
[   41.834076] fb_ili9341 spi0.0: init: msleep(100)

在设备目录中,我们将可以看到有两个framebuffer设备文件,fb0,fb1,其中fb1就是我们的TFT LCD的Framebuffer设备。

在这里插入图片描述

从内核日志输出可以知道,fb_ili9341已经启动。结果如下:

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/329573.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

修改Gitee用户名

首先进入首页&#xff0c;点击右上角下拉列表中的账号设置 只想改姓名的话&#xff0c;就只要改下下面这里 还想把个人空间地址改了的话还要改下面这里

java基于SSM的二手交易平台设计与开发论文

摘 要 现代经济快节奏发展以及不断完善升级的信息化技术&#xff0c;让传统数据信息的管理升级为软件存储&#xff0c;归纳&#xff0c;集中处理数据信息的管理方式。本二手交易平台就是在这样的大环境下诞生&#xff0c;其可以帮助使用者在短时间内处理完毕庞大的数据信息&am…

智慧医院预约及支付平台—智慧支付

医保支付流程 自费支付流程 智慧医院支付业务介绍 社保卡绑定(身份认证) 认证方案:银行身份已验证客户,可通过本人银行登记的手机号码登录医院APP后,在完善APP注册身份信息时,将相关信息发送苏州银行,由银行核对客户身份信息正确性并将社保卡绑定本人手机。核实后的身份…

2024阿里云优惠活动有哪些?

2024年阿里云优惠活动大全&#xff0c;包括阿里云服务器优惠活动清单、配置价格表、域名优惠活动、阿里云建站活动、阿里云优惠代金券免费领取、对象存储OSS活动、企业邮箱优惠、无影云电脑优惠、CDN特惠等等&#xff0c;阿里云百科aliyunbaike.com分享2024阿里云优惠活动大全_…

解决ImportError: Failed to import test module: sys.__init__

解决ImportError: Failed to import test module: sys.init 背景 学习通过文件夹执行测试脚本时&#xff0c;出现了错误&#xff1a;ImportError: Failed to import test module: sys.__init__ 解决过程 根据报错信息&#xff1a;sys is not a package大胆猜测可能是文件名…

算法第十三天-组合总和Ⅱ

组合总和Ⅱ 题目要求 解题思路 按顺序搜索&#xff0c;设置合理的变量&#xff0c;在搜索的过程中判断是否会出现重复集结果。重点理解对输入数组排序的作用和参考代码中 大剪枝和小剪枝 的意思 这道题域上一问的区别在于&#xff1a; 第39题&#xff1a;candidates中的数字…

使用ChatGPT生成项目需求文档模板

前言 我们在工作中需要编写的技术文档有多种形式&#xff0c;包括Word、Excel、PDF及一些在线形式。我们可以借助ChatGPT生成文本&#xff0c;然而&#xff0c;它不能直接生成Word、Excel、PDF等格式的文档。因此&#xff0c;我们需要利用其他工具来帮助我们生成一些模板&…

JavaScript 中的数组过滤

在构建动态和交互式程序时&#xff0c;您可能需要添加一些交互式功能。例如&#xff0c;用户单击按钮以筛选一长串项目。 您可能还需要处理大量数据&#xff0c;以仅返回与指定条件匹配的项目。 在本文中&#xff0c;您将学习如何使用两种主要方法在 JavaScript 中过滤数组。…

Dockerfile的EXPOSE

文章目录 环境总结测试使用EXPOSE测试1&#xff1a;不做端口映射测试2&#xff1a;-p 8080:80测试3&#xff1a;-P测试4&#xff1a;--networkhost 不使用EXPOSE 参考 环境 RHEL 9.3Docker Community 24.0.7 总结 如果懒得看测试的详细信息&#xff0c;可以直接看结果&#…

对象克隆学习

假如说你想复制一个简单变量。很简单&#xff1a; int apples 5; int pears apples; 不仅仅是int类型&#xff0c;其它七种原始数据类型(boolean,char,byte,short,float,double.long)同样适用于该类情况。 但是如果你复制的是一个对象&#xff0c;情况就有些复杂了。 …

【linux应用开发】进程通信总结——使用管道、消息队列、共享内存、信号量实现l进程通信的详细教程

文章目录 简介无名管道有名管道IPC key标识消息队列共享内存信号量 简介 进程间通信&#xff08;IPC, Inter-Process Communication&#xff09;是指在操作系统中&#xff0c;不同进程之间交换数据、信息和命令的过程。在一个多任务的操作系统中&#xff0c;多个进程可以同时运…

【IDEA】 解决在idea中连接 Mysql8.0,驱动无法下载问题

本篇继【idea】解决sprintboot项目创建遇到的问题2-CSDN博客 目录 一、Failed to download https://download.jetbrains.com/idea/jdbc-drivers/MySQL/8/LICENSE.txt:Remote host terminated the handshake 二、no dirver files provided com.mysql.cj.jdbc.Driver 三、Serv…