1我这里借鉴linux下的ili9341的 就是编译玩了后 在打印中没有看到任何调试信息 ,而且在dev目录下也没有看到spi 的设备
下图我我是在fbtft_device.c 中添加的SPI驱动
下面的是我Fb_lt7381.c文件的加载模块
下图是我的文件夹里面的文件
离线
我这里没有改配置文件 因为我的硬件是 一块屏幕接着V3S了 然后另一块 LT7381屏是独立(这屏幕在配置文件中没有) 他要显示是通过SPI传输数据过去才会显示
也就是系统一起来就要LT7381屏幕的初始化 同时SPI加载进来
我只在dtsi中配置要SPI就可以了
离线
现在SPI都还没有起来 打印的调试信息 有错误了
因为我PWM控制亮度的 不在V3S上了 ,PWM都在LI7381上面 通过SPI寄存器去控制PWM两块屏幕的亮度
但是在我在dts中没有定义dc 所以下面会报错 我可以将讲这个判断dc的给他去掉吗
不是很明白他这里buswidth不等于9
最近编辑记录 无情一刀 (2019-05-28 16:00:40)
离线
LI7381 有没有dc, 没有就可以在设备树和驱动都去掉。
LI7381 上面都有自己的PWM 只要通过SPI写寄存器就可以了 这样我就在设备数和驱动中可以去掉dc了
那我这里要不要勾上这个SPI的驱动了
kernel make menuconfig
Device Drivers --->
[ * ] SPI support --->
<*> User mode SPI device driver support
离线
可以去掉, 这个是生成用户设备的 /dev/spi0.0 的.
晕哥现在就是那几个文件有打印出出信息了
而且运行到屏幕初始化程序里面 这样是不是说明SPI驱动已经加载进去了
离线
因为我屏幕初始化的程序
下面的/while(read_BusChar(par)&0x02);这个将屏蔽了 也就是让这个这个初始化执行完
执行完init_display内核出现5秒重启 然后还有重启失败
static int init_display(struct fbtft_par *par)
{
printk("11+++++++++++++++++++++++++++++++++++++++++\n");
par->fbtftops.reset(par);
printk("22+++++++++++++++++++++++++++++++++++++++++\n");
msleep(100);
Lt7381_HW_Reset(par);
System_Check_Temp(par);
msleep(100);
//while(read_BusChar(par)&0x02);
LT768_initial(par);
return 0;
}
打印的信息
0.755885] 1c28800.serial: ttyS1 at MMIO 0x1c28800 (irq = 34, base_baud = 1500000) is a U6_16550A
[ 0.769379] fbtft_of_value: buswidth = 8
[ 0.773318] fbtft_of_value: rotate = 0
[ 0.778117] pdata->display.buswidth == 8par->startbyte = 0 =====-1
[ 0.784307] 11+++++++++++++++++++++++++++++++++++++++++
[ 0.926200] 22+++++++++++++++++++++++++++++++++++++++++
[ 1.286421] 22222read_BusChar(par)) == 255
[ 1.290593] !!!!!read_BusChar(par)&0x02) == 2
[ 1.295068] 22222read_BusChar(par)) == 255
[ 1.299269] !!!!!read_BusChar(par)&0x02) == 2
[ 1.303755] 22222read_BusChar(par)) == 255
[ 1.307944] !!!!!read_BusChar(par)&0x02) == 2
[ 1.312417] 22222read_BusChar(par)) == 255
[ 1.316596] !!!!!read_BusChar(par)&0x02) == 2
[ 1.321067] 22222read_BusChar(par)) == 255
[ 1.325221] !!!!!read_BusChar(par)&0x02) == 2
[ 1.329591] system_ok==0 && i==5 ==
[ 1.329591]
[ 1.566294] 22222read_BusChar(par)) == 255
[ 1.575580] !!!!!read_BusChar(par)&0x02) == 2
[ 1.580084] 22222read_BusChar(par)) == 255
[ 1.584241] !!!!!read_BusChar(par)&0x02) == 2
[ 1.588737] 22222read_BusChar(par)) == 255
[ 1.592893] !!!!!read_BusChar(par)&0x02) == 2
[ 1.597391] 22222read_BusChar(par)) == 255
[ 1.601545] !!!!!read_BusChar(par)&0x02) == 2
[ 1.606012] 22222read_BusChar(par)) == 255
[ 1.610189] !!!!!read_BusChar(par)&0x02) == 2
[ 1.614538] system_ok==0 && i==5 ==
[ 1.614538]
[ 1.846304] 22222read_BusChar(par)) == 255
[ 1.855595] !!!!!read_BusChar(par)&0x02) == 2
[ 1.860097] 22222read_BusChar(par)) == 255
[ 1.864254] !!!!!read_BusChar(par)&0x02) == 2
[ 1.868749] 22222read_BusChar(par)) == 255
[ 1.872903] !!!!!read_BusChar(par)&0x02) == 2
[ 1.877397] 22222read_BusChar(par)) == 255
[ 1.881551] !!!!!read_BusChar(par)&0x02) == 2
[ 1.886020] 22222read_BusChar(par)) == 255
[ 1.890198] !!!!!read_BusChar(par)&0x02) == 2
[ 1.894549] system_ok==0 && i==5 ==
[ 1.894549]
[ 2.126185] Return Curr System Check+++++
[ 2.276210] Unable to handle kernel NULL pointer dereference at virtual address 00000080
[ 2.284295] pgd = c0004000
[ 2.287021] [00000080] *pgd=00000000
[ 2.290602] Internal error: Oops: 5 [#1] SMP ARM
[ 2.295212] Modules linked in:
[ 2.298270] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.13.16-licheepi-zero+ #16
[ 2.305653] Hardware name: Allwinner sun8i Family
[ 2.310349] task: c382c000 task.stack: c3830000
[ 2.314889] PC is at sun6i_spi_transfer_one+0x1cc/0x36c
[ 2.320107] LR is at sun6i_spi_transfer_one+0x180/0x36c
[ 2.325324] pc : [<c0457cec>] lr : [<c0457ca0>] psr: 20000013
[ 2.331580] sp : c3831ab0 ip : c382c000 fp : 0020c498
[ 2.336797] r10: 00000001 r9 : c3a20800 r8 : c3a20400
[ 2.342014] r7 : c3831bfc r6 : 00000001 r5 : 00000001 r4 : c3a20728
[ 2.348530] r3 : 00000080 r2 : 00000081 r1 : 01c9c380 r0 : 00000000
[ 2.355049] Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none
[ 2.362173] Control: 10c5387d Table: 4000406a DAC: 00000051
[ 2.367910] Process swapper/0 (pid: 1, stack limit = 0xc3830210)
[ 2.373907] Stack: (0xc3831ab0 to 0xc3832000)
[ 2.378260] 1aa0: c3a205b0 c01512a8 00000000 c3a20690
[ 2.386427] 1ac0: c389fe84 00000000 c3831bfc c3a20400 c3831bc4 c3a209c8 c3a20690 c3a20800
[ 2.394595] 1ae0: 0020c498 c0456230 c3831afc c067eca4 00000000 0020c498 c3a20800 66666667
[ 2.402763] 1b00: 60000013 c3a2062c c3a20400 c3831bc4 00000000 c0454044 c3a209c8 c3a20690
[ 2.410930] 1b20: c3a205b0 c0455cfc 00000fa0 c3deda40 c382c000 00000009 c3831bb8 c3a20800
[ 2.419098] 1b40: c3831bc4 00000000 c3a20400 c0454044 c3a209c8 c3a20690 c3a205c4 c0455fb4
[ 2.427265] 1b60: 00000000 60000013 00000000 00000000 c3831b70 c3831b70 00000000 c3a20800
[ 2.435432] 1b80: c3831bc4 00000080 00000046 ffffff8a 00000023 c39f5800 c080e4c4 c0455fdc
[ 2.443600] 1ba0: c3831bc4 c39f5b30 00000080 c03698a4 0349e000 c067ea20 c3831c00 c3831c00
[ 2.451768] 1bc0: c3831c00 c3831c30 c3831c30 c3a20800 00000000 c0453fa4 c3831b68 00000001
[ 2.459935] 1be0: 00000000 ffffff8d c3831be8 c3831be8 00000000 c3831bf4 c3831bf4 00000080
[ 2.468102] 1c00: 00000000 00000001 00000000 00000000 00000000 00000000 00000000 00000000
[ 2.476269] 1c20: 00000000 00000000 00000802 00e4e1c0 c3831bc4 c3831bc4 c39f5b30 c3831c4e
[ 2.484436] 1c40: 00000000 c036a390 000000ff 00460000 00000002 c39f5b30 c39f5800 00000000
[ 2.492604] 1c60: c3a20800 c3a20800 00000000 c036adf0 c39f5b30 c036ae64 c39f5b30 c0367668
[ 2.500771] 1c80: c3951790 00000010 00000000 c3a20800 00000000 c01e0688 014080c0 00000000
[ 2.508938] 1ca0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 2.517104] 1cc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 2.525271] 1ce0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 2.533438] 1d00: c0a13c88 c39f5b30 c0a13c88 c3a20800 c3951790 c3a20800 00000000 c0368540
[ 2.541606] 1d20: c3a20800 c0a13d00 00000000 00000000 c0a13d10 00000000 00000000 c0453a40
[ 2.549773] 1d40: c3a20800 c0a7aca4 00000000 c04137d8 00000000 c3831d88 c0413948 00000001
[ 2.557940] 1d60: c0a7ac80 00000000 00000000 c0411eb4 c387c76c c39b6fb8 c3a20800 c3a20834
[ 2.566108] 1d80: c0a2b9d8 c04134c8 c3a20800 00000001 c3a20800 c3a20808 c3a20800 c0a2b9d8
[ 2.574275] 1da0: 00000000 c0412b64 c3a20808 c3a20400 c3a20800 c0411030 00000080 c04579b0
[ 2.582443] 1dc0: 00000000 c3a20800 c3a20800 c3a20400 00000000 c389fe10 00000000 00000001
[ 2.590610] 1de0: 00000000 c045476c c3a20400 c3dfd8b0 c3a20800 c3dfd904 00000000 c04551c4
[ 2.598778] 1e00: 00000000 c041cc58 c080e4d0 c080e594 c3a20400 00e4e1c0 00000000 c3b185d0
[ 2.606945] 1e20: c3a20400 00000000 c389fe10 c3a20728 00000000 c093783c c3e02e80 c04554e0
[ 2.615113] 1e40: c3a20400 c389fe10 00000000 00000001 c3a20728 c045824c 00000000 c080ebe8
[ 2.623281] 1e60: c3a20728 c0a2bfb8 c389fe10 ffffffed c0a2bfb8 fffffdfb c0a2bfb8 c04150a8
[ 2.631448] 1e80: c389fe10 c0a7aca4 00000000 00000000 c0a2bfb8 c04137d8 c389fe10 c0a2bfb8
[ 2.639616] 1ea0: c389fe44 00000000 000000d8 00000007 c093783c c0413944 00000000 c0a2bfb8
[ 2.647784] 1ec0: c041388c c0411e0c c3825658 c389d4b4 c0a2bfb8 c3b16680 c0a29620 c0412d64
[ 2.655951] 1ee0: c080ebe8 00000000 c0a2bfb8 c0a2bfb8 c091c658 00000000 c0937834 c041421c
[ 2.664119] 1f00: ffffe000 c091c658 00000000 c01017bc c086ba38 000000d8 00000000 c0136f80
[ 2.672286] 1f20: 60000053 c086b2f4 00000000 00000006 00000006 c07e5f28 c07dbcc0 c07dc420
[ 2.680454] 1f40: c3e02eca c3e02ee3 c0a0b158 c0a41880 c0a41880 00000006 c0a41880 c0a41880
[ 2.688621] 1f60: c09476c8 000000d8 00000007 c0900da4 00000006 00000006 00000000 c09005ac
[ 2.696788] 1f80: 00000000 00000000 c067dd6c 00000000 00000000 00000000 00000000 00000000
[ 2.704955] 1fa0: 00000000 c067dd74 00000000 c0107618 00000000 00000000 00000000 00000000
[ 2.713121] 1fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 2.721288] 1fe0: 00000000 00000000 00000000 00000000 00000013 00000000 aae82ae8 aae8aae8
[ 2.729475] [<c0457cec>] (sun6i_spi_transfer_one) from [<c0456230>] (spi_transfer_one_message+0xbc/0x3e8)
[ 2.739034] [<c0456230>] (spi_transfer_one_message) from [<c0455cfc>] (__spi_pump_messages+0x3d8/0x504)
[ 2.748417] [<c0455cfc>] (__spi_pump_messages) from [<c0455fb4>] (__spi_sync+0x180/0x184)
[ 2.756586] [<c0455fb4>] (__spi_sync) from [<c0455fdc>] (spi_sync+0x24/0x3c)
[ 2.763632] [<c0455fdc>] (spi_sync) from [<c03698a4>] (fbtft_write_spi+0x84/0xe0)
[ 2.771110] [<c03698a4>] (fbtft_write_spi) from [<c036a390>] (LT768_PLL_Initial+0x180/0x190)
[ 2.779541] [<c036a390>] (LT768_PLL_Initial) from [<c036adf0>] (LT768_initial+0xc/0x2c)
[ 2.787536] [<c036adf0>] (LT768_initial) from [<c036ae64>] (init_display+0x54/0x5c)
[ 2.795189] [<c036ae64>] (init_display) from [<c0367668>] (fbtft_register_framebuffer+0xa8/0x274)
[ 2.804054] [<c0367668>] (fbtft_register_framebuffer) from [<c0368540>] (fbtft_probe_common+0x118/0x438)
[ 2.813525] [<c0368540>] (fbtft_probe_common) from [<c0453a40>] (spi_drv_probe+0x7c/0xac)
[ 2.821700] [<c0453a40>] (spi_drv_probe) from [<c04137d8>] (driver_probe_device+0x230/0x2e4)
[ 2.830132] [<c04137d8>] (driver_probe_device) from [<c0411eb4>] (bus_for_each_drv+0x60/0x94)
[ 2.838641] [<c0411eb4>] (bus_for_each_drv) from [<c04134c8>] (__device_attach+0xb0/0x114)
[ 2.846898] [<c04134c8>] (__device_attach) from [<c0412b64>] (bus_probe_device+0x84/0x8c)
[ 2.855068] [<c0412b64>] (bus_probe_device) from [<c0411030>] (device_add+0x3f4/0x580)
[ 2.862978] [<c0411030>] (device_add) from [<c045476c>] (spi_add_device+0x9c/0x134)
[ 2.870627] [<c045476c>] (spi_add_device) from [<c04551c4>] (spi_register_controller+0x484/0x768)
[ 2.879489] [<c04551c4>] (spi_register_controller) from [<c04554e0>] (devm_spi_register_controller+0x38/0x70)
[ 2.889392] [<c04554e0>] (devm_spi_register_controller) from [<c045824c>] (sun6i_spi_probe+0x21c/0x2ac)
[ 2.898776] [<c045824c>] (sun6i_spi_probe) from [<c04150a8>] (platform_drv_probe+0x50/0xb0)
[ 2.907121] [<c04150a8>] (platform_drv_probe) from [<c04137d8>] (driver_probe_device+0x230/0x2e4)
[ 2.915984] [<c04137d8>] (driver_probe_device) from [<c0413944>] (__driver_attach+0xb8/0xbc)
[ 2.924414] [<c0413944>] (__driver_attach) from [<c0411e0c>] (bus_for_each_dev+0x68/0x9c)
[ 2.932584] [<c0411e0c>] (bus_for_each_dev) from [<c0412d64>] (bus_add_driver+0x100/0x20c)
[ 2.940840] [<c0412d64>] (bus_add_driver) from [<c041421c>] (driver_register+0x78/0xf4)
[ 2.948839] [<c041421c>] (driver_register) from [<c01017bc>] (do_one_initcall+0x44/0x168)
[ 2.957015] [<c01017bc>] (do_one_initcall) from [<c0900da4>] (kernel_init_freeable+0x140/0x1cc)
[ 2.965707] [<c0900da4>] (kernel_init_freeable) from [<c067dd74>] (kernel_init+0x8/0x108)
[ 2.973881] [<c067dd74>] (kernel_init) from [<c0107618>] (ret_from_fork+0x14/0x3c)
[ 2.981445] Code: e3530000 e2832001 15842024 01a05003 (15d35000)
[ 2.987595] ---[ end trace 647f6c18eb91f309 ]---
[ 2.992250] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
[ 2.992250]
[ 3.001382] Rebooting in 5 seconds..
[ 9.005092] Reboot failed -- System halted
离线
里面几个文件是我从TFT那边弄过来的
离线
LT768_initial
LT768_PLL_Initial
fbtft_write_spi这个调用栈检查一下, 看log信息是这样。
可以了 是一个SPI写数据的时候 参数是指针 我直接传值了
现在在dev里面有一个fb0设备了 下面的是打印出来的信息 这里fb0 缓冲区就跟操作fb1一样的吗
离线
对,可以写随机数看看 cat /dev/urandom > /dev/fbX
出现错误屏幕没有任何反应 是不是初始化还有问题了
# cat /dev/urandom > /dev/fb0
cat: write error: No space left on device
# [ 46.936106] set_addr_win WX = 0, HY == 0 == 799 478
# cat /dev/urandom > /dev/fb0
cat: write error: No space left on device
# [ 60.966237] set_addr_win WX = 0, HY == 0 == 799 478
# cat /dev/urandom > /dev/fb0
cat: write error: No space left on device
# [ 62.416096] set_addr_win WX = 0, HY == 0 == 799 478
离线
不止初始化有问题吧, 还有里面很多寄存器操作都要重新适配, 弄个逻辑分析仪抓你发出来的数据和手册是不是一致。
我屏幕的初始化 我是安装厂家提供的其他的平台代码寄存器去配置的
然后 fbtft-core.c 和device.c 和io.c 和fbtft-bus.c 是直接从linux里面的 fbtft里面复制出来的
离线
是spi屏幕吗?还得实现一个 ili9341.c 那种驱动
就是SPI的屏幕 我就是按照ili9341那种的驱动 出来里面dev下面是有一个fb0了 但是接上屏幕后 写随机数 有问题 好像没有用
最近编辑记录 无情一刀 (2019-05-29 13:58:11)
离线
那可能导致的问题太多了, 最终问题只是一个问题 -------------- 时序不正确.
你说的时序问题是SPI的时序问题 还是屏幕的初始化
SPI时序的话 我用是fbtft下面的那几个文件 fbtft-bus.c fbtft-core.c fbtft-sysfs.c 这几个文件我是没动过
唯一改过的就是fbtft_device 在display中加了自己的一个配置
{
.name = "er_fblt7381",
.spi = &(struct spi_board_info){
.modalias = "fb_lt7381",
.max_speed_hz = 32000000,
.mode = SPI_MODE_0,
.platform_data = &(struct fbtft_platform_data)
{
.display = {
.buswidth = 8,
.backlight = 1,
.width = 800,
.height = 480,
},
.bgr = true,
.gpios = (const struct fbtft_gpio []) {
{ "reset", 148 },
{ },
{ },
{},
},
}
}
},
然后就是Fb_lt7381就是关于屏幕的一些初始化 ,
我不是很清楚你说的这个时序是指的SPI 还是屏幕初始化的时序
离线
https://github.com/torvalds/linux/blob/master/drivers/staging/fbtft/fb_ili9481.c
应该是仿照这个文件改,对照驱动芯片手册改
是的 我就是仿照这个文件改的, 寄存器和时序按照他们提供的STM32平台的代码 因为厂家说只要安装那个时序就可以了
void LT768_initial(struct fbtft_par *par)
{
LT768_PLL_Initial(par);
printk("55+++++++++++++++++++++++++++++++++++++++++\n");
LT768_SDRAM_initail(par,MCLK);
printk("66+++++++++++++++++++++++++++++++++++++++++\n");
Set_LCD_Panel(par);
printk("77+++++++++++++++++++++++++++++++++++++++++\n");
}
static int init_display(struct fbtft_par *par)
{
printk("11+++++++++++++++++++++++++++++++++++++++++\n");
par->fbtftops.reset(par);
//printk("22+++++++++++++++++++++++++++++++++++++++++\n");
//msleep(100);
//Lt7381_HW_Reset(par);
printk("33+++++++++++++++++++++++++++++++++++++++++\n");
System_Check_Temp(par);
printk("44+++++++++++++++++++++++++++++++++++++++++\n");
msleep(100);
while(read_BusChar(par)&0x02);
LT768_initial(par);
return 0;
}
static struct fbtft_display display = {
.regwidth = 8,
.width = LCD_XSIZE_TFT,
.height = LCD_YSIZE_TFT,
.fbtftops = {
.init_display = init_display,
.set_addr_win = set_addr_win,
//.set_var = set_var,
},
};
FBTFT_REGISTER_DRIVER(DRVNAME, "lt7381fb,lt7381LCD", &display);
MODULE_ALIAS("spi:" DRVNAME);
MODULE_ALIAS("platform:" DRVNAME);
MODULE_ALIAS("spi:lt7381LCD");
MODULE_ALIAS("platform:lt7381LCD");
MODULE_DESCRIPTION("FB driver for the RA8875 LCD Controller");
MODULE_AUTHOR("yangsichao");
MODULE_LICENSE("GPL");
离线
.init_sequence = default_init_sequence
这个初始化不需要吗?
这个也是屏幕的初始化 我这边可以不用 因为Lt7381他们里面的初始化 就是都在写读寄存器了 包括了
离线
你就用逻辑分析仪把 SPI 数据都抓下来, 看下和 能驱动的STM32板子的书序有什么区别.
发现是SPI的CLK波形不对 这个SPI时序不对 要怎么去改了
离线
哪里不对, 截图看下。
就这个CLock 刚开始就是要一直是高
这图是完整的
离线
Channel2 MISO 一直是高?
空闲状态是要为高吗 这样不知道会不会有影响了
离线
channel 2 对应的是时序图的SDO, 那个是虚线,应该是可以忽略的意思,这样看来那个脚可以不管的。
不是通道2 是那个通道1 你和他们资料对比下那个CLK 就可以看出 他们资料上空闲是高的 而我弄出来的波形 正好是低电平 中途还有一个是为高
离线
这个时候没有使能, 时钟会自动忽略。
不是很明白你说这句话 ,如果是我要空闲状态为高电平 我要怎么去设置了
离线
我这里就是设置为模式3的 手册上面空闲就是高的的
{
.name = "er_fblt7381",
.spi = &(struct spi_board_info){
.modalias = "fb_lt7381",
.max_speed_hz = 4000000,
.mode = SPI_MODE_3,
.platform_data = &(struct fbtft_platform_data)
{
.display = {
.buswidth = 8,
.backlight = 1,
.width = 800,
.height = 480,
},
.bgr = true,
.gpios = (const struct fbtft_gpio []) {
{ "reset", 148 },
{ },
{ },
{},
},
}
}
},
离线