您尚未登录。

楼主 #1 2021-04-24 15:18:20

无痕
会员
注册时间: 2021-02-04
已发帖子: 28
积分: 10

5.2内核,启动SPI屏幕(ili9341)失败

内核版本:zero-5.2.y

按照晕哥写的教程,一步一步操作。
https://whycan.com/t_576.html#p1579

内核启动log中显示如下:

[    1.052704] fbtft_of_value: buswidth = 8
[    1.056628] fbtft_of_value: debug = 0
[    1.060326] fbtft_of_value: rotate = 270
[    1.064244] fbtft_of_value: fps = 10
[    1.068691] fb_ili9341 spi0.0: Failed to request reset-gpios GPIO:-2
[    1.075218] fb_ili9341: probe of spi0.0 failed with error -2

是不是zero-5.2.y的内核太新了,改了什么东西,导致按照上面的流程操作后,启动失败。

离线

楼主 #3 2021-04-24 15:42:22

无痕
会员
注册时间: 2021-02-04
已发帖子: 28
积分: 10

Re: 5.2内核,启动SPI屏幕(ili9341)失败

哇酷小二 说:

获取dtb 里面 reset 引脚错误

linux错误代码: https://mariadb.com/kb/en/operating-system-error-codes/

sun8i-v3.dtsi下的pio节点

		pio: pinctrl@1c20800 {
			compatible = "allwinner,sun8i-v3s-pinctrl";
			reg = <0x01c20800 0x400>;
			interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>,
				     <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_PIO>, <&osc24M>, <&osc32k>;
			clock-names = "apb", "hosc", "losc";
			gpio-controller;
			#gpio-cells = <3>;
			interrupt-controller;
			#interrupt-cells = <3>;

			emac_rgmii_pins: emac-rgmii-pins {
				pins = "PD0", "PD1", "PD2", "PD3", "PD4",
				       "PD5", "PD7", "PD8", "PD9", "PD10",
				       "PD12", "PD13", "PD15", "PD16", "PD17";
				function = "emac";
				drive-strength = <40>;
			};

			i2c0_pins: i2c0-pins {
				pins = "PB6", "PB7";
				function = "i2c0";
			};

			pwm0_pins: pwm0 {
				pins = "PB4";
				function = "pwm0";
			};

			uart0_pb_pins: uart0-pb-pins {
				pins = "PB8", "PB9";
				function = "uart0";
			};

			lcd_rgb666_pins_a: lcd-rgb666-pe {
				pins = "PE0", "PE1", "PE2", "PE3", "PE4", "PE5",
				       "PE6", "PE7", "PE8", "PE9", "PE10", "PE11",
				       "PE12", "PE13", "PE14", "PE15", "PE16", "PE17",
				       "PE18", "PE19", "PE23", "PE24";
				function = "lcd";
			};

			mmc0_pins: mmc0-pins {
				pins = "PF0", "PF1", "PF2", "PF3",
				       "PF4", "PF5";
				function = "mmc0";
				drive-strength = <30>;
				bias-pull-up;
			};

			mmc1_pins: mmc1-pins {
				pins = "PG0", "PG1", "PG2", "PG3",
				       "PG4", "PG5";
				function = "mmc1";
				drive-strength = <30>;
				bias-pull-up;
			};

			spi0_pins: spi0-pins {
				pins = "PC0", "PC1", "PC2", "PC3";
				function = "spi0";
			};

			pwm1_pins: pwm1 {
				pins = "PB5";
				function = "pwm1";
			};

		csi1_8bit: csi1-8bit@0 {
       			pins 	 = "PE6","PE7","PE8","PE9","PE10","PE11","PE12","PE13","PE14","PE15";
       			bias-disable;
       			function = "csi";
			};

		csi1_clk: csi1-clk@0 {
			pins = "PE0","PE2","PE3";
			bias-disable;
			function = "csi";
		};

		csi1_mclk: csi1-mclk@0 {
			pins = "PE1";
			bias-disable;
			function = "csi";
		};

		i2c1_pins: i2c1 {
			pins = "PE21", "PE22";
			function = "i2c1";
		};

		};

sun8i-v3s-licheepi-zero.dts下的spi节点

163 &spi0 {
164      status = "okay";
165      ili9341@0 {
166             compatible = "ilitek,ili9341";
167             reg = <0>;
168             spi-max-frequency = <15000000>;
169             rotate = <270>;
170             bgr;
171             fps = <10>;
172             buswidth = <8>;
173             reset-gpios = <&pio 1 7 GPIO_ACTIVE_LOW>;
174             dc-gpios = <&pio 1 5 GPIO_ACTIVE_LOW>;
175            debug = <0>;
176       };
177 };

173 reset-gpios = <&pio 1 7 GPIO_ACTIVE_LOW>; 指的是PB7,是i2c0的SDA引脚,讲道理是可以获取到这个引脚的。配置教程上面也说了,SPI屏幕的复位引脚可以直接接电源的,所以不接PB7也可以。所以我不清楚为什么会获取dtb里面 reset 引脚发生错误

离线

楼主 #5 2021-04-24 15:58:35

无痕
会员
注册时间: 2021-02-04
已发帖子: 28
积分: 10

Re: 5.2内核,启动SPI屏幕(ili9341)失败

哇酷小二 说:

你的i2c0使能了吗?也是用pb7?

没动过i2c0的设备树代码。

在sun8i-v3s-licheepi-zero.dts中有i2c0这个节点

111 &i2c0 {
112     status = "okay";
113     ns2009: ns2009@48 {
114         compatible = "nsiway,ns2009";
115         reg = <0x48>;
116     };
117 };

离线

楼主 #7 2021-04-24 17:31:40

无痕
会员
注册时间: 2021-02-04
已发帖子: 28
积分: 10

Re: 5.2内核,启动SPI屏幕(ili9341)失败

哇酷小二 说:

当然要动啊,删除或者改


status = "disabled";

修改后还是报原来的错误。

[    1.176248] fbtft_of_value: buswidth = 8
[    1.180222] fbtft_of_value: debug = 0
[    1.183881] fbtft_of_value: rotate = 270
[    1.187798] fbtft_of_value: fps = 10
[    1.192082] fb_ili9341 spi0.0: Failed to request reset-gpios GPIO:-2
[    1.198681] fb_ili9341: probe of spi0.0 failed with error -2

下面我重新贴下几个文件的相关代码。

sun8i-v3s-licheepi-zero.dts文件

183 &spi0 {
184       status = "okay";
185       ili9341@0 {
186              compatible = "ilitek,ili9341";
187              reg = <0>;
188              spi-max-frequency = <15000000>;
189              rotate = <270>;
190              bgr;
191              fps = <10>;
192              buswidth = <8>;
193              reset-gpios = <&pio 1 7 GPIO_ACTIVE_LOW>;
194              dc-gpios = <&pio 1 5 GPIO_ACTIVE_LOW>;
195              debug = <0>;
196       };
197 };

sun8i-v3s.dtsi文件

521         i2c0: i2c@1c2ac00 {
522             compatible = "allwinner,sun6i-a31-i2c";
523             reg = <0x01c2ac00 0x400>;
524             interrupts = <GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>;
525             clocks = <&ccu CLK_BUS_I2C0>;
526             resets = <&ccu RST_BUS_I2C0>;
527             pinctrl-names = "default";
528             pinctrl-0 = <&i2c0_pins>;
529             status = "eabled";
530             #address-cells = <1>;
531             #size-cells = <0>;
532         };

离线

楼主 #9 2021-04-24 17:45:19

无痕
会员
注册时间: 2021-02-04
已发帖子: 28
积分: 10

Re: 5.2内核,启动SPI屏幕(ili9341)失败

哇酷小二 说:

当然要动啊,删除或者改


status = "disabled";


我刚刚在内核4.13.16版本上,按照教程一步步操作,发现没有遇到在5.2版本上的错误。
下面是运行成功的log,但是屏幕并没有亮起来。

[    1.244305] fbtft_of_value: buswidth = 8
[    1.248267] fbtft_of_value: debug = 0
[    1.251925] fbtft_of_value: rotate = 270
[    1.255841] fbtft_of_value: fps = 10
[    1.304740] mmc0: host does not support reading read-only switch, assuming write-enable
[    1.314784] mmc0: new high speed SDHC card at address 1234
[    1.320956] mmcblk0: mmc0:1234 SA08G 7.21 GiB
[    1.327049]  mmcblk0: p1 p2
[    1.609569] Console: switching to colour frame buffer device 40x30
[    1.616454] graphics fb0: fb_ili9341 frame buffer, 320x240, 150 KiB video memory, 16 KiB buffer memory, fps=10, spi32766.0 at 15 MHz

使用下面的命令,并没有发现屏幕出现变化

cat /dev/urandom > /dev/fb0
cat /dev/zero > /dev/fb0

离线

楼主 #10 2021-04-24 17:46:57

无痕
会员
注册时间: 2021-02-04
已发帖子: 28
积分: 10

Re: 5.2内核,启动SPI屏幕(ili9341)失败

哇酷小二 说:

没理由,只能怀疑你改错了文件,或者dtb没有起作用。

我百度了下那错误,找到这个帖子,但是我看不懂。晕哥可以看下它写的内容
https://blog.csdn.net/qulang000/article/details/114686525

离线

楼主 #11 2021-04-24 21:04:08

无痕
会员
注册时间: 2021-02-04
已发帖子: 28
积分: 10

Re: 5.2内核,启动SPI屏幕(ili9341)失败

无痕 说:
哇酷小二 说:

没理由,只能怀疑你改错了文件,或者dtb没有起作用。

我百度了下那错误,找到这个帖子,但是我看不懂。晕哥可以看下它写的内容
https://blog.csdn.net/qulang000/article/details/114686525


按照里面的操作,修改bug引脚相关代码后,还是报同样的错误。

离线

楼主 #13 2021-04-25 20:55:39

无痕
会员
注册时间: 2021-02-04
已发帖子: 28
积分: 10

Re: 5.2内核,启动SPI屏幕(ili9341)失败

阿黄 说:

贴出你相关的几个完整设备树文件吧

完整的设备树文件如下

sun8i-v3s.dtsi

/*
 * Copyright (C) 2016 Icenowy Zheng <icenowy@aosc.xyz>
 *
 * This file is dual-licensed: you can use it either under the terms
 * of the GPL or the X11 license, at your option. Note that this dual
 * licensing only applies to this file, and not this project as a
 * whole.
 *
 *  a) This file is free software; you can redistribute it and/or
 *     modify it under the terms of the GNU General Public License as
 *     published by the Free Software Foundation; either version 2 of the
 *     License, or (at your option) any later version.
 *
 *     This file is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 * Or, alternatively,
 *
 *  b) Permission is hereby granted, free of charge, to any person
 *     obtaining a copy of this software and associated documentation
 *     files (the "Software"), to deal in the Software without
 *     restriction, including without limitation the rights to use,
 *     copy, modify, merge, publish, distribute, sublicense, and/or
 *     sell copies of the Software, and to permit persons to whom the
 *     Software is furnished to do so, subject to the following
 *     conditions:
 *
 *     The above copyright notice and this permission notice shall be
 *     included in all copies or substantial portions of the Software.
 *
 *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 *     OTHER DEALINGS IN THE SOFTWARE.
 */

#include <dt-bindings/interrupt-controller/arm-gic.h>
#include <dt-bindings/clock/sun8i-v3s-ccu.h>
#include <dt-bindings/reset/sun8i-v3s-ccu.h>

/ {
	#address-cells = <1>;
	#size-cells = <1>;
	interrupt-parent = <&gic>;

	chosen {
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;


		//simplefb_lcd: framebuffer@0 {
		//	compatible = "allwinner,simple-framebuffer",
		//		     "simple-framebuffer";
		//	allwinner,pipeline = "de0-lcd0";
		//	clocks = <&ccu CLK_BUS_TCON0>, <&display_clocks 0>,
		//		 <&display_clocks 6>, <&ccu CLK_TCON0>;
		//	status = "disabled";
		//};
	};

	cpus {
		#address-cells = <1>;
		#size-cells = <0>;

		cpu@0 {
			compatible = "arm,cortex-a7";
			device_type = "cpu";
			reg = <0>;
			clocks = <&ccu CLK_CPU>;
		};
	};

	de: display-engine {
		compatible = "allwinner,sun8i-v3s-display-engine";
		allwinner,pipelines = <&mixer0>;
		status = "disabled";
	};

	timer {
		compatible = "arm,armv7-timer";
		interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
			     <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
			     <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
			     <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
	};

	clocks {
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;

		osc24M: osc24M_clk {
			#clock-cells = <0>;
			compatible = "fixed-clock";
			clock-frequency = <24000000>;
			clock-output-names = "osc24M";
		};

		osc32k: osc32k_clk {
			#clock-cells = <0>;
			compatible = "fixed-clock";
			clock-frequency = <32768>;
			clock-output-names = "osc32k";
		};
	};

	soc {
		compatible = "simple-bus";
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;

		display_clocks: clock@1000000 {
			compatible = "allwinner,sun8i-v3s-de2-clk";
			reg = <0x01000000 0x100000>;
			clocks = <&ccu CLK_DE>,
				 <&ccu CLK_BUS_DE>;
			clock-names = "mod",
				      "bus";
			resets = <&ccu RST_BUS_DE>;
			#clock-cells = <1>;
			#reset-cells = <1>;
		};

		mixer0: mixer@1100000 {
			compatible = "allwinner,sun8i-v3s-de2-mixer";
			reg = <0x01100000 0x100000>;
			clocks = <&display_clocks 0>,
				 <&display_clocks 6>;
			clock-names = "bus",
				      "mod";
			resets = <&display_clocks 0>;
			assigned-clocks = <&display_clocks 6>;
			assigned-clock-rates = <150000000>;

			ports {
				#address-cells = <1>;
				#size-cells = <0>;

				mixer0_out: port@1 {
					reg = <1>;

					mixer0_out_tcon0: endpoint {
						remote-endpoint = <&tcon0_in_mixer0>;
					};
				};
			};
		};

		syscon: syscon@1c00000 {
			compatible = "allwinner,sun8i-v3s-system-controller",
				"syscon";
			reg = <0x01c00000 0x1000>;
		};

		tcon0: lcd-controller@1c0c000 {
			compatible = "allwinner,sun8i-v3s-tcon";
			reg = <0x01c0c000 0x1000>;
			interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_TCON0>,
				 <&ccu CLK_TCON0>;
			clock-names = "ahb",
				      "tcon-ch0";
			clock-output-names = "tcon-pixel-clock";
			#clock-cells = <0>;
			resets = <&ccu RST_BUS_TCON0>;
			reset-names = "lcd";
			status = "disabled";

			ports {
				#address-cells = <1>;
				#size-cells = <0>;

				tcon0_in: port@0 {
					reg = <0>;

					tcon0_in_mixer0: endpoint {
						remote-endpoint = <&mixer0_out_tcon0>;
					};
				};

				tcon0_out: port@1 {
					#address-cells = <1>;
					#size-cells = <0>;
					reg = <1>;
				};
			};
		};

		dma: dma-controller@01c02000 {
			compatible = "allwinner,sun8i-v3s-dma";
			reg = <0x01c02000 0x1000>;
			interrupts = <GIC_SPI 50 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_DMA>;
			resets = <&ccu RST_BUS_DMA>;
			#dma-cells = <1>;
		};

		mmc0: mmc@1c0f000 {
			compatible = "allwinner,sun7i-a20-mmc";
			reg = <0x01c0f000 0x1000>;
			clocks = <&ccu CLK_BUS_MMC0>,
				 <&ccu CLK_MMC0>,
				 <&ccu CLK_MMC0_OUTPUT>,
				 <&ccu CLK_MMC0_SAMPLE>;
			clock-names = "ahb",
				      "mmc",
				      "output",
				      "sample";
			resets = <&ccu RST_BUS_MMC0>;
			reset-names = "ahb";
			interrupts = <GIC_SPI 60 IRQ_TYPE_LEVEL_HIGH>;
			pinctrl-names = "default";
			pinctrl-0 = <&mmc0_pins>;
			status = "disabled";
			#address-cells = <1>;
			#size-cells = <0>;
		};

		mmc1: mmc@1c10000 {
			compatible = "allwinner,sun7i-a20-mmc";
			reg = <0x01c10000 0x1000>;
			clocks = <&ccu CLK_BUS_MMC1>,
				 <&ccu CLK_MMC1>,
				 <&ccu CLK_MMC1_OUTPUT>,
				 <&ccu CLK_MMC1_SAMPLE>;
			clock-names = "ahb",
				      "mmc",
				      "output",
				      "sample";
			resets = <&ccu RST_BUS_MMC1>;
			reset-names = "ahb";
			interrupts = <GIC_SPI 61 IRQ_TYPE_LEVEL_HIGH>;
			pinctrl-names = "default";
			pinctrl-0 = <&mmc1_pins>;
			status = "disabled";
			#address-cells = <1>;
			#size-cells = <0>;
		};

		mmc2: mmc@1c11000 {
			compatible = "allwinner,sun7i-a20-mmc";
			reg = <0x01c11000 0x1000>;
			clocks = <&ccu CLK_BUS_MMC2>,
				 <&ccu CLK_MMC2>,
				 <&ccu CLK_MMC2_OUTPUT>,
				 <&ccu CLK_MMC2_SAMPLE>;
			clock-names = "ahb",
				      "mmc",
				      "output",
				      "sample";
			resets = <&ccu RST_BUS_MMC2>;
			reset-names = "ahb";
			interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
			status = "disabled";
			#address-cells = <1>;
			#size-cells = <0>;
		};

		usb_otg: usb@1c19000 {
			compatible = "allwinner,sun8i-h3-musb";
			reg = <0x01c19000 0x0400>;
			clocks = <&ccu CLK_BUS_OTG>;
			resets = <&ccu RST_BUS_OTG>;
			interrupts = <GIC_SPI 71 IRQ_TYPE_LEVEL_HIGH>;
			interrupt-names = "mc";
			phys = <&usbphy 0>;
			phy-names = "usb";
			extcon = <&usbphy 0>;
			status = "disabled";
		};

		usbphy: phy@1c19400 {
			compatible = "allwinner,sun8i-v3s-usb-phy";
			reg = <0x01c19400 0x2c>,
			      <0x01c1a800 0x4>;
			reg-names = "phy_ctrl",
				    "pmu0";
			clocks = <&ccu CLK_USB_PHY0>;
			clock-names = "usb0_phy";
			resets = <&ccu RST_USB_PHY0>;
			reset-names = "usb0_reset";
			status = "disabled";
			#phy-cells = <1>;
		};

		ehci0: usb@01c1a000 {
			compatible = "allwinner,sun8i-v3s-ehci", "generic-ehci";
			reg = <0x01c1a000 0x100>;
			interrupts = <GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_EHCI0>, <&ccu CLK_BUS_OHCI0>;
			resets = <&ccu RST_BUS_EHCI0>, <&ccu RST_BUS_OHCI0>;
			status = "disabled";
		};

		ohci0: usb@01c1a400 {
			compatible = "allwinner,sun8i-v3s-ohci", "generic-ohci";
			reg = <0x01c1a400 0x100>;
			interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_EHCI0>, <&ccu CLK_BUS_OHCI0>,
				 <&ccu CLK_USB_OHCI0>;
			resets = <&ccu RST_BUS_EHCI0>, <&ccu RST_BUS_OHCI0>;
			status = "disabled";
		};

		ccu: clock@1c20000 {
			compatible = "allwinner,sun8i-v3s-ccu";
			reg = <0x01c20000 0x400>;
			clocks = <&osc24M>, <&osc32k>;
			clock-names = "hosc", "losc";
			#clock-cells = <1>;
			#reset-cells = <1>;
		};

		rtc: rtc@1c20400 {
			compatible = "allwinner,sun6i-a31-rtc";
			reg = <0x01c20400 0x54>;
			interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
				     <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>;
		};

		csi1: csi@1cb4000 {
			compatible = "allwinner,sun8i-v3s-csi";
			reg = <0x01cb4000 0x1000>;
			interrupts = <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_CSI>,
					<&ccu CLK_CSI1_SCLK>,
					<&ccu CLK_DRAM_CSI>;
			clock-names = "bus", "mod", "ram";
			resets = <&ccu RST_BUS_CSI>;
			status = "disabled";
		};

		pio: pinctrl@1c20800 {
			compatible = "allwinner,sun8i-v3s-pinctrl";
			reg = <0x01c20800 0x400>;
			interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>,
				     <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_PIO>, <&osc24M>, <&osc32k>;
			clock-names = "apb", "hosc", "losc";
			gpio-controller;
			#gpio-cells = <3>;
			interrupt-controller;
			#interrupt-cells = <3>;

			emac_rgmii_pins: emac-rgmii-pins {
				pins = "PD0", "PD1", "PD2", "PD3", "PD4",
				       "PD5", "PD7", "PD8", "PD9", "PD10",
				       "PD12", "PD13", "PD15", "PD16", "PD17";
				function = "emac";
				drive-strength = <40>;
			};

			i2c0_pins: i2c0-pins {
				pins = "PB6", "PB7";
				function = "i2c0";
			};

			pwm0_pins: pwm0 {
				pins = "PB4";
				function = "pwm0";
			};

			uart0_pb_pins: uart0-pb-pins {
				pins = "PB8", "PB9";
				function = "uart0";
			};

			lcd_rgb666_pins_a: lcd-rgb666-pe {
				pins = "PE0", "PE1", "PE2", "PE3", "PE4", "PE5",
				       "PE6", "PE7", "PE8", "PE9", "PE10", "PE11",
				       "PE12", "PE13", "PE14", "PE15", "PE16", "PE17",
				       "PE18", "PE19", "PE23", "PE24";
				function = "lcd";
			};

			mmc0_pins: mmc0-pins {
				pins = "PF0", "PF1", "PF2", "PF3",
				       "PF4", "PF5";
				function = "mmc0";
				drive-strength = <30>;
				bias-pull-up;
			};

			mmc1_pins: mmc1-pins {
				pins = "PG0", "PG1", "PG2", "PG3",
				       "PG4", "PG5";
				function = "mmc1";
				drive-strength = <30>;
				bias-pull-up;
			};

			spi0_pins: spi0-pins {
				pins = "PC0", "PC1", "PC2", "PC3";
				function = "spi0";
			};

			pwm1_pins: pwm1 {
				pins = "PB5";
				function = "pwm1";
			};

		csi1_8bit: csi1-8bit@0 {
       			pins 	 = "PE6","PE7","PE8","PE9","PE10","PE11","PE12","PE13","PE14","PE15";
       			bias-disable;
       			function = "csi";
			};

		csi1_clk: csi1-clk@0 {
			pins = "PE0","PE2","PE3";
			bias-disable;
			function = "csi";
		};

		csi1_mclk: csi1-mclk@0 {
			pins = "PE1";
			bias-disable;
			function = "csi";
		};

		i2c1_pins: i2c1 {
			pins = "PE21", "PE22";
			function = "i2c1";
		};




		};


		timer@1c20c00 {
			compatible = "allwinner,sun4i-a10-timer";
			reg = <0x01c20c00 0xa0>;
			interrupts = <GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>,
				     <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&osc24M>;
		};

		wdt0: watchdog@1c20ca0 {
			compatible = "allwinner,sun6i-a31-wdt";
			reg = <0x01c20ca0 0x20>;
			interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>;
		};

		pwm: pwm@1c21400 {
			compatible = "allwinner,sun8i-v3s-pwm",
				     "allwinner,sun7i-a20-pwm";
			reg = <0x01c21400 0x400>;
			clocks = <&osc24M>;
			#pwm-cells = <3>;
			status = "disabled";
		};

		lradc: lradc@1c22800 {
			compatible = "allwinner,sun4i-a10-lradc-keys";
			reg = <0x01c22800 0x400>;
			interrupts = <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>;
			status = "disabled";
		};

		codec: codec@01c22c00 {
			#sound-dai-cells = <0>;
			compatible = "allwinner,sun8i-v3s-codec";
			reg = <0x01c22c00 0x400>;
			interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_CODEC>, <&ccu CLK_AC_DIG>;
			clock-names = "apb", "codec";
			resets = <&ccu RST_BUS_CODEC>;
			dmas = <&dma 15>, <&dma 15>;
			dma-names = "rx", "tx";
			allwinner,codec-analog-controls = <&codec_analog>;
			status = "disabled";
		};

		codec_analog: codec-analog@01c23000 {
			compatible = "allwinner,sun8i-v3s-codec-analog";
			reg = <0x01c23000 0x4>;
		};

		uart0: serial@1c28000 {
			compatible = "snps,dw-apb-uart";
			reg = <0x01c28000 0x400>;
			interrupts = <GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH>;
			reg-shift = <2>;
			reg-io-width = <4>;
			clocks = <&ccu CLK_BUS_UART0>;
			resets = <&ccu RST_BUS_UART0>;
			status = "disabled";
		};

		uart1: serial@1c28400 {
			compatible = "snps,dw-apb-uart";
			reg = <0x01c28400 0x400>;
			interrupts = <GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH>;
			reg-shift = <2>;
			reg-io-width = <4>;
			clocks = <&ccu CLK_BUS_UART1>;
			resets = <&ccu RST_BUS_UART1>;
			status = "disabled";
		};

		uart2: serial@1c28800 {
			compatible = "snps,dw-apb-uart";
			reg = <0x01c28800 0x400>;
			interrupts = <GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>;
			reg-shift = <2>;
			reg-io-width = <4>;
			clocks = <&ccu CLK_BUS_UART2>;
			resets = <&ccu RST_BUS_UART2>;
			status = "disabled";
		};

		i2c0: i2c@1c2ac00 {
			compatible = "allwinner,sun6i-a31-i2c";
			reg = <0x01c2ac00 0x400>;
			interrupts = <GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_I2C0>;
			resets = <&ccu RST_BUS_I2C0>;
			pinctrl-names = "default";
			pinctrl-0 = <&i2c0_pins>;
			#address-cells = <1>;
			#size-cells = <0>;
		};

		i2c1: i2c@1c2b000 {
			compatible = "allwinner,sun6i-a31-i2c";
			reg = <0x01c2b000 0x400>;
			interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_I2C1>;
			resets = <&ccu RST_BUS_I2C1>;
			status = "disabled";
			#address-cells = <1>;
			#size-cells = <0>;
		};

		emac: ethernet@1c30000 {
			compatible = "allwinner,sun8i-h3-emac";
			syscon = <&syscon>;
			reg = <0x01c30000 0x10000>;
			interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>;
			interrupt-names = "macirq";
			resets = <&ccu RST_BUS_EMAC>;
			reset-names = "stmmaceth";
			clocks = <&ccu CLK_BUS_EMAC>;
			clock-names = "stmmaceth";
			status = "disabled";

			mdio: mdio {
				#address-cells = <1>;
				#size-cells = <0>;
				compatible = "snps,dwmac-mdio";
			};

			mdio-mux {
				compatible = "allwinner,sun8i-h3-mdio-mux";
				#address-cells = <1>;
				#size-cells = <0>;

				mdio-parent-bus = <&mdio>;
				/* Only one MDIO is usable at the time */
				internal_mdio: mdio@1 {
					compatible = "allwinner,sun8i-h3-mdio-internal";
					reg = <1>;
					#address-cells = <1>;
					#size-cells = <0>;

					int_mii_phy: ethernet-phy@1 {
						compatible = "ethernet-phy-ieee802.3-c22";
						reg = <1>;
						clocks = <&ccu CLK_BUS_EPHY>;
						resets = <&ccu RST_BUS_EPHY>;
					};
				};

				external_mdio: mdio@2 {
					reg = <2>;
					#address-cells = <1>;
					#size-cells = <0>;
				};
			};
		};

		spi0: spi@1c68000 {
			compatible = "allwinner,sun8i-h3-spi";
			reg = <0x01c68000 0x1000>;
			interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_SPI0>, <&ccu CLK_SPI0>;
			clock-names = "ahb", "mod";
			pinctrl-names = "default";
			pinctrl-0 = <&spi0_pins>;
			resets = <&ccu RST_BUS_SPI0>;
			status = "enabled";
			#address-cells = <1>;
			#size-cells = <0>;
		};

		gic: interrupt-controller@1c81000 {
			compatible = "arm,gic-400";
			reg = <0x01c81000 0x1000>,
			      <0x01c82000 0x1000>,
			      <0x01c84000 0x2000>,
			      <0x01c86000 0x2000>;
			interrupt-controller;
			#interrupt-cells = <3>;
			interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>;
		};
	};
};

sun8i-v3s-licheepi-zero.dts:

/*
 * Copyright (C) 2016 Icenowy Zheng <icenowy@aosc.xyz>
 *
 * This file is dual-licensed: you can use it either under the terms
 * of the GPL or the X11 license, at your option. Note that this dual
 * licensing only applies to this file, and not this project as a
 * whole.
 *
 *  a) This file is free software; you can redistribute it and/or
 *     modify it under the terms of the GNU General Public License as
 *     published by the Free Software Foundation; either version 2 of the
 *     License, or (at your option) any later version.
 *
 *     This file is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 * Or, alternatively,
 *
 *  b) Permission is hereby granted, free of charge, to any person
 *     obtaining a copy of this software and associated documentation
 *     files (the "Software"), to deal in the Software without
 *     restriction, including without limitation the rights to use,
 *     copy, modify, merge, publish, distribute, sublicense, and/or
 *     sell copies of the Software, and to permit persons to whom the
 *     Software is furnished to do so, subject to the following
 *     conditions:
 *
 *     The above copyright notice and this permission notice shall be
 *     included in all copies or substantial portions of the Software.
 *
 *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 *     OTHER DEALINGS IN THE SOFTWARE.
 */

/dts-v1/;
#include "sun8i-v3s.dtsi"
#include "sunxi-common-regulators.dtsi"

/ {
	model = "Lichee Pi Zero";
	compatible = "licheepi,licheepi-zero", "allwinner,sun8i-v3s";

	aliases {
		serial0 = &uart0;
	};

	chosen {
		stdout-path = "serial0:115200n8";
	};
	
	pir{
		label = "licheepi:blue:usr";
		gpio-pir = <&pio 6 5 GPIO_ACTIVE_HIGH>; /* PG5 */
	};

	door_magnet{
		label = "licheepi:blue:usr";
		gpio-door_magnet = <&pio 6 4 GPIO_ACTIVE_HIGH>; /* PG4 */
	};

	leds {
		compatible = "gpio-leds";

		blue_led {
			label = "licheepi:blue:usr";
			gpios = <&pio 6 1 GPIO_ACTIVE_LOW>; /* PG1 */
		};

		green_led {
			label = "licheepi:green:usr";
			gpios = <&pio 6 0 GPIO_ACTIVE_LOW>; /* PG0 */
			default-state = "on";
		};

		red_led {
			label = "licheepi:red:usr";
			gpios = <&pio 6 2 GPIO_ACTIVE_LOW>; /* PG2 */
		};
	};

	door_key{
		compatible = "door_key";
		key-gpio = <&pio 6 3 GPIO_ACTIVE_LOW>;
	};

	lcd_key{
		compatible = "lcd_key";
		key-gpio = <&pio 6 2 GPIO_ACTIVE_LOW>;
	};
};
&ehci0 {
	status = "okay";
};

&mmc0 {
	broken-cd;
	bus-width = <4>;
	vmmc-supply = <&reg_vcc3v3>;
	status = "okay";
};


&i2c0 {
	status = "okay";
	
	ns2009: ns2009@48 {
		compatible = "nsiway,ns2009";
		reg = <0x48>;
	};
};

&ohci0 {
	status = "okay";
};

&uart0 {
	pinctrl-0 = <&uart0_pb_pins>;
	pinctrl-names = "default";
	status = "okay";
};

&usb_otg {
	dr_mode = "otg";
	status = "okay";
};

&usbphy {
	usb0_id_det-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>;
	status = "okay";
};

&csi1 {
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&csi1_clk &csi1_8bit>;

	port {
		csi1_ep: endpoint {
	
		remote-endpoint = <&ov2640_0>;
		hsync-active = <0>;
		vsync-active = <0>;
		bus-width = <10>;
	    	pclk-sample = <1>;
		
		};
	};
 };

&i2c1 {
	pinctrl-0 = <&i2c1_pins>;
	pinctrl-names = "default";
	status = "okay";

	
	ov2640: camera@30 {
		compatible = "ovti,ov2640";
		reg = <0x30>;
		pinctrl-names = "default";
		pinctrl-0 = <&csi1_mclk>;
		clocks = <&ccu CLK_CSI1_MCLK>;
		clock-names = "xvclk";
		assigned-clocks = <&ccu CLK_CSI1_MCLK>;
		assigned-clock-rates = <24000000>;
		
		port {
			ov2640_0: endpoint {
				remote-endpoint = <&csi1_ep>;
				bus-width = <10>;
			};
		};
	};
};

&spi0 {
      status = "okay";
      ili9341@0 {
             compatible = "ilitek,ili9341";
             reg = <0>;
             spi-max-frequency = <15000000>;
             rotate = <270>;
             bgr;
             fps = <10>;
             buswidth = <8>;
             reset-gpios = <&pio 1 7 GPIO_ACTIVE_LOW>;
             dc-gpios = <&pio 1 5 GPIO_ACTIVE_LOW>;
             debug = <0>;	 
      };
};

离线

楼主 #15 2021-04-26 23:23:20

无痕
会员
注册时间: 2021-02-04
已发帖子: 28
积分: 10

Re: 5.2内核,启动SPI屏幕(ili9341)失败

阿黄 说:

&i2c0 {
    status = "disable";
   
    ns2009: ns2009@48 {
        compatible = "nsiway,ns2009";
        reg = <0x48>;
    };
};

改了之后还是报下面的错误

[    1.165724] fbtft_of_value: buswidth = 8
[    1.169696] fbtft_of_value: debug = 0
[    1.173355] fbtft_of_value: rotate = 270
[    1.177272] fbtft_of_value: fps = 10
[    1.181547] fb_ili9341 spi0.0: Failed to request reset-gpios GPIO:-2
[    1.188150] fb_ili9341: probe of spi0.0 failed with error -2

离线

楼主 #18 2021-04-27 22:17:10

无痕
会员
注册时间: 2021-02-04
已发帖子: 28
积分: 10

Re: 5.2内核,启动SPI屏幕(ili9341)失败

心情复杂 说:

我在5.7改了fbtft-core.c 的 fbtft_request_one_gpio  fbtft_reset 函数 能用 你可以试试

static int fbtft_request_one_gpio(struct fbtft_par *par,
				  const char *name, int index,
				  struct gpio_desc **gpiop)
{
    struct device *dev = par->info->device;
    struct device_node *node = dev->of_node;
    int gpio, flags, ret = 0;
    enum of_gpio_flags of_flags;
	char gpio_names[32];

	sprintf(gpio_names, "%s-gpios", name);
    if (of_find_property(node, gpio_names, NULL)) {
        gpio = of_get_named_gpio_flags(node, gpio_names, index, &of_flags);
        if (gpio == -ENOENT)
            return 0;
        if (gpio == -EPROBE_DEFER)
            return gpio;
        if (gpio < 0) {
            dev_err(dev,
                "failed to get '%s' from DT\n", gpio_names);
            return gpio;
        }

         //active low translates to initially low 
        flags = (of_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_LOW :
                            GPIOF_OUT_INIT_HIGH;
        ret = devm_gpio_request_one(dev, gpio, flags,
                        dev->driver->name);
        if (ret) {
            dev_err(dev,
                "gpio_request_one('%s'=%d) failed with %d\n",
                gpio_names, gpio, ret);
            return ret;
        }

        *gpiop = gpio_to_desc(gpio);
        fbtft_par_dbg(DEBUG_REQUEST_GPIOS, par, "%s: '%s' = GPIO%d\n",
                            __func__, gpio_names, gpio);
    }
    return ret;
}

static void fbtft_reset(struct fbtft_par *par)
{
	if (!par->gpio.reset)
		return;
	fbtft_par_dbg(DEBUG_RESET, par, "%s()\n", __func__);
	gpiod_set_value_cansleep(par->gpio.reset, 1);
	usleep_range(20, 40);
	gpiod_set_value_cansleep(par->gpio.reset, 0);
	msleep(120);
	gpiod_set_value_cansleep(par->gpio.reset, 1);
	msleep(10);
}

我按照你贴出来的代码修改后,编译内核的时候报下面的错误,我是不是需要在头文件那里添加什么呀?

  CALL    scripts/atomic/check-atomics.sh
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  CC      drivers/staging/fbtft/fbtft-core.o
drivers/staging/fbtft/fbtft-core.c: In function ‘fbtft_request_one_gpio’:
drivers/staging/fbtft/fbtft-core.c:102:24: error: storage size of ‘of_flags’ isn’t known
     enum of_gpio_flags of_flags;
                        ^
drivers/staging/fbtft/fbtft-core.c:107:9: error: implicit declaration of function ‘of_get_named_gpio_flags’ [-Werror=implicit-function-declaration]
         gpio = of_get_named_gpio_flags(node, gpio_names, index, &of_flags);
         ^
drivers/staging/fbtft/fbtft-core.c:119:29: error: ‘OF_GPIO_ACTIVE_LOW’ undeclared (first use in this function)
         flags = (of_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_LOW :
                             ^
drivers/staging/fbtft/fbtft-core.c:119:29: note: each undeclared identifier is reported only once for each function it appears in
drivers/staging/fbtft/fbtft-core.c:119:51: error: ‘GPIOF_OUT_INIT_LOW’ undeclared (first use in this function)
         flags = (of_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_LOW :
                                                   ^
drivers/staging/fbtft/fbtft-core.c:120:29: error: ‘GPIOF_OUT_INIT_HIGH’ undeclared (first use in this function)
                             GPIOF_OUT_INIT_HIGH;
                             ^
drivers/staging/fbtft/fbtft-core.c:121:9: error: implicit declaration of function ‘devm_gpio_request_one’ [-Werror=implicit-function-declaration]
         ret = devm_gpio_request_one(dev, gpio, flags,
         ^
drivers/staging/fbtft/fbtft-core.c:102:24: warning: unused variable ‘of_flags’ [-Wunused-variable]
     enum of_gpio_flags of_flags;
                        ^
cc1: some warnings being treated as errors
scripts/Makefile.build:278: recipe for target 'drivers/staging/fbtft/fbtft-core.o' failed
make[3]: *** [drivers/staging/fbtft/fbtft-core.o] Error 1
scripts/Makefile.build:498: recipe for target 'drivers/staging/fbtft' failed
make[2]: *** [drivers/staging/fbtft] Error 2
make[2]: *** Waiting for unfinished jobs....
scripts/Makefile.build:498: recipe for target 'drivers/staging' failed
make[1]: *** [drivers/staging] Error 2
Makefile:1077: recipe for target 'drivers' failed
make: *** [drivers] Error 2

离线

楼主 #19 2021-04-27 22:27:40

无痕
会员
注册时间: 2021-02-04
已发帖子: 28
积分: 10

Re: 5.2内核,启动SPI屏幕(ili9341)失败

哇酷小二 说:
无痕 说:
哇酷小二 说:

没理由,只能怀疑你改错了文件,或者dtb没有起作用。

我百度了下那错误,找到这个帖子,但是我看不懂。晕哥可以看下它写的内容
https://blog.csdn.net/qulang000/article/details/114686525

都按这个改了?如果也改了,把of获取reset gpio那一段屏蔽起来,看看能不能获取dc gpio.

屏蔽掉reset引脚后,就报dc-gpio没找到哈哈哈

[    1.165822] fbtft_of_value: buswidth = 8
[    1.169792] fbtft_of_value: debug = 0
[    1.173452] fbtft_of_value: rotate = 270
[    1.177369] fbtft_of_value: fps = 10
[    1.181647] fb_ili9341 spi0.0: Failed to request dc-gpios GPIO:-2
[    1.187902] fb_ili9341: probe of spi0.0 failed with error -2

离线

楼主 #20 2021-04-27 22:38:55

无痕
会员
注册时间: 2021-02-04
已发帖子: 28
积分: 10

Re: 5.2内核,启动SPI屏幕(ili9341)失败

无痕 说:
心情复杂 说:

我在5.7改了fbtft-core.c 的 fbtft_request_one_gpio  fbtft_reset 函数 能用 你可以试试

static int fbtft_request_one_gpio(struct fbtft_par *par,
				  const char *name, int index,
				  struct gpio_desc **gpiop)
{
    struct device *dev = par->info->device;
    struct device_node *node = dev->of_node;
    int gpio, flags, ret = 0;
    enum of_gpio_flags of_flags;
	char gpio_names[32];

	sprintf(gpio_names, "%s-gpios", name);
    if (of_find_property(node, gpio_names, NULL)) {
        gpio = of_get_named_gpio_flags(node, gpio_names, index, &of_flags);
        if (gpio == -ENOENT)
            return 0;
        if (gpio == -EPROBE_DEFER)
            return gpio;
        if (gpio < 0) {
            dev_err(dev,
                "failed to get '%s' from DT\n", gpio_names);
            return gpio;
        }

         //active low translates to initially low 
        flags = (of_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_LOW :
                            GPIOF_OUT_INIT_HIGH;
        ret = devm_gpio_request_one(dev, gpio, flags,
                        dev->driver->name);
        if (ret) {
            dev_err(dev,
                "gpio_request_one('%s'=%d) failed with %d\n",
                gpio_names, gpio, ret);
            return ret;
        }

        *gpiop = gpio_to_desc(gpio);
        fbtft_par_dbg(DEBUG_REQUEST_GPIOS, par, "%s: '%s' = GPIO%d\n",
                            __func__, gpio_names, gpio);
    }
    return ret;
}

static void fbtft_reset(struct fbtft_par *par)
{
	if (!par->gpio.reset)
		return;
	fbtft_par_dbg(DEBUG_RESET, par, "%s()\n", __func__);
	gpiod_set_value_cansleep(par->gpio.reset, 1);
	usleep_range(20, 40);
	gpiod_set_value_cansleep(par->gpio.reset, 0);
	msleep(120);
	gpiod_set_value_cansleep(par->gpio.reset, 1);
	msleep(10);
}

我按照你贴出来的代码修改后,编译内核的时候报下面的错误,我是不是需要在头文件那里添加什么呀?

  CALL    scripts/atomic/check-atomics.sh
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  CC      drivers/staging/fbtft/fbtft-core.o
drivers/staging/fbtft/fbtft-core.c: In function ‘fbtft_request_one_gpio’:
drivers/staging/fbtft/fbtft-core.c:102:24: error: storage size of ‘of_flags’ isn’t known
     enum of_gpio_flags of_flags;
                        ^
drivers/staging/fbtft/fbtft-core.c:107:9: error: implicit declaration of function ‘of_get_named_gpio_flags’ [-Werror=implicit-function-declaration]
         gpio = of_get_named_gpio_flags(node, gpio_names, index, &of_flags);
         ^
drivers/staging/fbtft/fbtft-core.c:119:29: error: ‘OF_GPIO_ACTIVE_LOW’ undeclared (first use in this function)
         flags = (of_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_LOW :
                             ^
drivers/staging/fbtft/fbtft-core.c:119:29: note: each undeclared identifier is reported only once for each function it appears in
drivers/staging/fbtft/fbtft-core.c:119:51: error: ‘GPIOF_OUT_INIT_LOW’ undeclared (first use in this function)
         flags = (of_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_LOW :
                                                   ^
drivers/staging/fbtft/fbtft-core.c:120:29: error: ‘GPIOF_OUT_INIT_HIGH’ undeclared (first use in this function)
                             GPIOF_OUT_INIT_HIGH;
                             ^
drivers/staging/fbtft/fbtft-core.c:121:9: error: implicit declaration of function ‘devm_gpio_request_one’ [-Werror=implicit-function-declaration]
         ret = devm_gpio_request_one(dev, gpio, flags,
         ^
drivers/staging/fbtft/fbtft-core.c:102:24: warning: unused variable ‘of_flags’ [-Wunused-variable]
     enum of_gpio_flags of_flags;
                        ^
cc1: some warnings being treated as errors
scripts/Makefile.build:278: recipe for target 'drivers/staging/fbtft/fbtft-core.o' failed
make[3]: *** [drivers/staging/fbtft/fbtft-core.o] Error 1
scripts/Makefile.build:498: recipe for target 'drivers/staging/fbtft' failed
make[2]: *** [drivers/staging/fbtft] Error 2
make[2]: *** Waiting for unfinished jobs....
scripts/Makefile.build:498: recipe for target 'drivers/staging' failed
make[1]: *** [drivers/staging] Error 2
Makefile:1077: recipe for target 'drivers' failed
make: *** [drivers] Error 2

在该文件添加下面这个头文件后,编译就不报错了
#include <linux/of_gpio.h>

离线

楼主 #21 2021-04-28 00:17:40

无痕
会员
注册时间: 2021-02-04
已发帖子: 28
积分: 10

Re: 5.2内核,启动SPI屏幕(ili9341)失败

reset GPIO能申请到了,但是dc引脚又出问题了,报下面的错误。

[    1.165851] fbtft_of_value: buswidth = 8
[    1.169818] fbtft_of_value: debug = 0
[    1.173478] fbtft_of_value: rotate = 270
[    1.177395] fbtft_of_value: fps = 10
[    1.181682] @ pdata->display.buswidth = 8
[    1.185755] @ par->gpio.dc = 0
[    1.188882] fb_ili9341 spi0.0: Missing info about 'dc' gpio. Aborting.

追log追到这里,原因是par->gpio.dc = 0导致下面的if条件成立。这问题奇奇怪怪的。

1173     if (pdata->display.buswidth != 9 &&  par->startbyte == 0 &&
1174         !par->gpio.dc) {
1175         printk ("@ pdata->display.buswidth = %d\n", pdata->display.buswidth);
1176         printk ("@ par->gpio.dc = %d\n", par->gpio.dc);
1177         dev_err(par->info->device,
1178             "Missing info about 'dc' gpio. Aborting.\n");
1179         return -EINVAL;
1180     }

另外我今晚跟着教程走,在4.17的内核中能够成功驱动手上的屏幕,所以屏幕是正常的。
注意屏幕上的LED引脚要接3.3V

离线

楼主 #23 2021-04-28 15:38:55

无痕
会员
注册时间: 2021-02-04
已发帖子: 28
积分: 10

Re: 5.2内核,启动SPI屏幕(ili9341)失败

心情复杂 说:
无痕 说:

reset GPIO能申请到了,但是dc引脚又出问题了,报下面的错误。

[    1.165851] fbtft_of_value: buswidth = 8
[    1.169818] fbtft_of_value: debug = 0
[    1.173478] fbtft_of_value: rotate = 270
[    1.177395] fbtft_of_value: fps = 10
[    1.181682] @ pdata->display.buswidth = 8
[    1.185755] @ par->gpio.dc = 0
[    1.188882] fb_ili9341 spi0.0: Missing info about 'dc' gpio. Aborting.

追log追到这里,原因是par->gpio.dc = 0导致下面的if条件成立。这问题奇奇怪怪的。

1173     if (pdata->display.buswidth != 9 &&  par->startbyte == 0 &&
1174         !par->gpio.dc) {
1175         printk ("@ pdata->display.buswidth = %d\n", pdata->display.buswidth);
1176         printk ("@ par->gpio.dc = %d\n", par->gpio.dc);
1177         dev_err(par->info->device,
1178             "Missing info about 'dc' gpio. Aborting.\n");
1179         return -EINVAL;
1180     }

另外我今晚跟着教程走,在4.17的内核中能够成功驱动手上的屏幕,所以屏幕是正常的。
注意屏幕上的LED引脚要接3.3V

你这不明显是DC申请不到吗? 可以在 fbtft_request_one_gpio 添加点打印函数 看看?

如果dc申请不到的话,不应该是报类似下面的错误吗?

[    1.181547] fb_ili9341 spi0.0: Failed to request reset-gpios GPIO:-2

应该是报[    1.181547] fb_ili9341 spi0.0: Failed to request dc-gpios GPIO:-2

我感觉不是dc申请不到哈。不过晚点,我会按照你说,把那个地方打印出来看看。

离线

楼主 #24 2021-04-28 21:01:49

无痕
会员
注册时间: 2021-02-04
已发帖子: 28
积分: 10

Re: 5.2内核,启动SPI屏幕(ili9341)失败

心情复杂 说:
无痕 说:

reset GPIO能申请到了,但是dc引脚又出问题了,报下面的错误。

[    1.165851] fbtft_of_value: buswidth = 8
[    1.169818] fbtft_of_value: debug = 0
[    1.173478] fbtft_of_value: rotate = 270
[    1.177395] fbtft_of_value: fps = 10
[    1.181682] @ pdata->display.buswidth = 8
[    1.185755] @ par->gpio.dc = 0
[    1.188882] fb_ili9341 spi0.0: Missing info about 'dc' gpio. Aborting.

追log追到这里,原因是par->gpio.dc = 0导致下面的if条件成立。这问题奇奇怪怪的。

1173     if (pdata->display.buswidth != 9 &&  par->startbyte == 0 &&
1174         !par->gpio.dc) {
1175         printk ("@ pdata->display.buswidth = %d\n", pdata->display.buswidth);
1176         printk ("@ par->gpio.dc = %d\n", par->gpio.dc);
1177         dev_err(par->info->device,
1178             "Missing info about 'dc' gpio. Aborting.\n");
1179         return -EINVAL;
1180     }

另外我今晚跟着教程走,在4.17的内核中能够成功驱动手上的屏幕,所以屏幕是正常的。
注意屏幕上的LED引脚要接3.3V

你这不明显是DC申请不到吗? 可以在 fbtft_request_one_gpio 添加点打印函数 看看?

感谢大佬指点,按照你的指示,在fbtft_request_one_gpio加打印函数调试,发现问题,现在已经解决,屏幕已经点亮。

离线

楼主 #25 2021-04-28 21:10:45

无痕
会员
注册时间: 2021-02-04
已发帖子: 28
积分: 10

Re: 5.2内核,启动SPI屏幕(ili9341)失败

昨天调试后报下面这个错误,根据楼上大佬说的是IO没有申请成功,让我在fbtft_request_one_gpio加打印函数看看,我照做了(一定要勤动手),结果真的发现问题。

[    1.165851] fbtft_of_value: buswidth = 8
[    1.169818] fbtft_of_value: debug = 0
[    1.173478] fbtft_of_value: rotate = 270
[    1.177395] fbtft_of_value: fps = 10
[    1.181682] @ pdata->display.buswidth = 8
[    1.185755] @ par->gpio.dc = 0
[    1.188882] fb_ili9341 spi0.0: Missing info about 'dc' gpio. Aborting.

fbtft_request_one_gpio加入打印函数后的代码,关键的打印函数在108行。

5 static int fbtft_request_one_gpio(struct fbtft_par *par,
  76                   const char *name, int index,
  77                   struct gpio_desc **gpiop)
  78 {
  79 /*
  80     struct device *dev = par->info->device;
  81     struct device_node *node = dev->of_node;
  82     int ret = 0;
  83 
  84     if (of_find_property(node, name, NULL)) {
  85         *gpiop = devm_gpiod_get_index(dev, dev->driver->name, index,
  86                           GPIOD_OUT_HIGH);
  87         if (IS_ERR(*gpiop)) {
  88             ret = PTR_ERR(*gpiop);
  89             dev_err(dev,
  90                 "Failed to request %s GPIO:%d\n", name, ret);
  91             return ret;
  92         }
  93         fbtft_par_dbg(DEBUG_REQUEST_GPIOS, par, "%s: '%s' GPIO\n",
  94                   __func__, name);
  95     }
  96 
  97     return ret;
  98 */
  99 
 100     struct device *dev = par->info->device;
 101     struct device_node *node = dev->of_node;
 102     int gpio, flags, ret = 0;
 103     enum of_gpio_flags of_flags;
 104     char gpio_names[32];

 106     sprintf(gpio_names, "%s-gpios", name);
 108     printk("@ gpio_names = %s\n", gpio_names);
 109     if (of_find_property(node, gpio_names, NULL)) {
 110         gpio = of_get_named_gpio_flags(node, gpio_names, index, &of_flags);
 111         printk ("@ gpio = %d | ENOENT = %d | EPROBE_DEFER = %d  \n", gpio, ENOENT, EPROBE_DEFER);
 112         if (gpio == -ENOENT)
 113             return 0;
 114         if (gpio == -EPROBE_DEFER)
 115             return gpio;
 116         if (gpio < 0) {
 117             dev_err(dev,
 118                 "failed to get '%s' from DT\n", gpio_names);
 119             return gpio;
 120         }
 121 
 122          //active low translates to initially low 
 123         flags = (of_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_LOW :
 124                             GPIOF_OUT_INIT_HIGH;
 125         ret = devm_gpio_request_one(dev, gpio, flags,
 126                         dev->driver->name);
 127         if (ret) {
 128             dev_err(dev,
 129                 "gpio_request_one('%s'=%d) failed with %d\n",
 130                 gpio_names, gpio, ret);
 131             return ret;
 132         }
 133 
 134         *gpiop = gpio_to_desc(gpio);
 135         fbtft_par_dbg(DEBUG_REQUEST_GPIOS, par, "%s: '%s' = GPIO%d\n",
 136                             __func__, gpio_names, gpio);
 137     }
 138     return ret;
 139 }

内核启动后输出的如下内容

[    1.165851] fbtft_of_value: buswidth = 8
[    1.169818] fbtft_of_value: debug = 0
[    1.173480] fbtft_of_value: rotate = 90
[    1.177309] fbtft_of_value: fps = 30
[    1.181541] @ gpio_names = reset-gpios-gpios
[    1.185883] @ gpio_names = dc-gpios-gpios
[    1.189960] @ gpio_names = rd-gpios-gpios
[    1.193969] @ gpio_names = wr-gpios-gpios
[    1.197999] @ gpio_names = cs-gpios-gpios
[    1.202004] @ gpio_names = latch-gpios-gpios
[    1.206267] @ gpio_names = db-gpios-gpios
[    1.210286] @ gpio_names = led-gpios-gpios
[    1.214377] @ gpio_names = aux-gpios-gpios
[    1.218478] @ gpio_names = db-gpios-gpios
[    1.222481] @ gpio_names = led-gpios-gpios
[    1.226570] @ gpio_names = aux-gpios-gpios
[    1.230668] @ gpio_names = db-gpios-gpios
[    1.234671] @ gpio_names = led-gpios-gpios
[    1.238770] @ gpio_names = aux-gpios-gpios
[    1.242859] @ gpio_names = db-gpios-gpios
[    1.246861] @ gpio_names = led-gpios-gpios
[    1.250961] @ gpio_names = aux-gpios-gpios
[    1.255049] @ gpio_names = db-gpios-gpios
[    1.259062] @ gpio_names = led-gpios-gpios
[    1.263151] @ gpio_names = aux-gpios-gpios
[    1.267239] @ gpio_names = db-gpios-gpios
[    1.271251] @ gpio_names = led-gpios-gpios
[    1.275340] @ gpio_names = aux-gpios-gpios
[    1.279440] @ gpio_names = db-gpios-gpios
[    1.283443] @ gpio_names = led-gpios-gpios
[    1.287531] @ gpio_names = aux-gpios-gpios
[    1.291630] @ gpio_names = db-gpios-gpios
[    1.295632] @ gpio_names = led-gpios-gpios
[    1.299731] @ gpio_names = aux-gpios-gpios
[    1.303821] @ gpio_names = db-gpios-gpios
[    1.307823] @ gpio_names = led-gpios-gpios
[    1.311921] @ gpio_names = aux-gpios-gpios
[    1.316010] @ gpio_names = db-gpios-gpios
[    1.320022] @ gpio_names = led-gpios-gpios
[    1.324111] @ gpio_names = aux-gpios-gpios
[    1.328210] @ gpio_names = db-gpios-gpios
[    1.332213] @ gpio_names = led-gpios-gpios
[    1.336302] @ gpio_names = aux-gpios-gpios
[    1.340400] @ gpio_names = db-gpios-gpios
[    1.344403] @ gpio_names = led-gpios-gpios
[    1.348502] @ gpio_names = aux-gpios-gpios
[    1.352591] @ gpio_names = db-gpios-gpios
[    1.356593] @ gpio_names = led-gpios-gpios
[    1.360693] @ gpio_names = aux-gpios-gpios
[    1.364781] @ gpio_names = db-gpios-gpios
[    1.368794] @ gpio_names = led-gpios-gpios
[    1.372884] @ gpio_names = aux-gpios-gpios
[    1.376973] @ gpio_names = db-gpios-gpios
[    1.380985] @ gpio_names = led-gpios-gpios
[    1.385065] @ gpio_names = aux-gpios-gpios
[    1.389165] @ gpio_names = db-gpios-gpios
[    1.393167] @ gpio_names = led-gpios-gpios
[    1.397255] @ gpio_names = aux-gpios-gpios
[    1.401356] @ pdata->display.buswidth = 8
[    1.405358] @ par->gpio.dc = 0
[    1.408425] fb_ili9341 spi0.0: Missing info about 'dc' gpio. Aborting. @xkt
[    1.415483] fb_ili9341: probe of spi0.0 failed with error -22

我是输出设备树中IO口的名称,发现reset和dc引脚的名称为:reset-gpios-gpios dc-gpios-gpios。跟设备树上的节点名称不一样,所以真如楼上大佬说的,是引脚没有申请成功!所以只需要把驱动和设备树的引脚名称修改为一致就好了。有多种修改方法。

离线

楼主 #27 2021-04-28 23:35:49

无痕
会员
注册时间: 2021-02-04
已发帖子: 28
积分: 10

Re: 5.2内核,启动SPI屏幕(ili9341)失败

心情复杂 说:
无痕 说:
心情复杂 说:

你这不明显是DC申请不到吗? 可以在 fbtft_request_one_gpio 添加点打印函数 看看?

感谢大佬指点,按照你的指示,在fbtft_request_one_gpio加打印函数调试,发现问题,现在已经解决,屏幕已经点亮。

大佬不敢当 roll 我也是个小菜鸡
啥问题 ? 可以分享上来下,让大家学习下。


问题描述已经发在楼上了哈哈

最近编辑记录 无痕 (2021-04-28 23:36:22)

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn