验证环境
- Win10 64位
- Keil MDK 5.30
- ART-Pi 开发板:STM32H750XBH6开发板
- 工程:最小RT-Thread 系统,版本:RT-Thread v4.1.0 released
功能验证
- 构建最小系统,开启了ART-Pi 板载LCD驱动
- 验证SPI 屏是否能正常驱动,为了后面运行LVGL
问题一:内存申请失败
- 发现初始化提示 内存申请失败,LCD 的测试例程无法通过
___ ______ _____ ______ _ ______ _____ _____ _____
/ _ \ | ___ \|_ _| | ___ \(_) | ___ \/ _ \/ _ \|_ _|
/ /_\ \| |_/ / | | ______ | |_/ / _ | |_/ /| | | || | | | | |
| _ || / | | |______|| __/ | | | ___ \| | | || | | | | |
| | | || |\ \ | | | | | | | |_/ /\ \_/ /\ \_/ / | |
\_| |_/\_| \_| \_/ \_| |_| \____/ \___/ \___/ \_/
Powered by RT-Thread.
[D/drv.sdram] sdram init success, mapped at 0xC0000000, size is 33554432 bytes, data width is 16
[I/I2C] I2C bus [i2c2] registered
\ | /
- RT - Thread Operating System
/ | \ 4.1.0 build Apr 2 2022 16:47:54
2006 - 2022 Copyright by RT-Thread team
[E/drv.spi_lcd] init frame buffer failed!
msh >
msh >
msh >ile
msh >ili
ili9488_test
msh >ili9488_test
(device != RT_NULL) assertion failed at function:rt_spi_transfer, line number:260
解决方法
- 解决方法,开启RT-Thread memheap,片内的SRAM不够,可以使用开发板的外部SDRAM
问题二:LCD初始化死机
\ | /
- RT - Thread Operating System
/ | \ 4.1.0 build Apr 2 2022 17:09:28
2006 - 2022 Copyright by RT-Thread team
psr: 0x21000000
r00: 0xc008082f
r01: 0x40003800
r02: 0x0000ffff
r03: 0x000003e8
r04: 0x24000324
r05: 0x000003e8
r06: 0x00000534
r07: 0x0000ffff
r08: 0xc008082f
r09: 0x00000000
r10: 0x0000ffff
r11: 0x0000ffff
r12: 0x00000000
lr: 0x90004f91
pc: 0x90005144
hard fault on thread: main
thread pri status sp stack size max used left tick error
-------- --- ------- ---------- ---------- ------ ---------- ---
tidle0 31 ready 0x00000058 0x00000100 34% 0x0000001c 000
main 10 running 0x000000a8 0x00000800 19% 0x0000000a 000
FPU active!
usage fault:
SCB_CFSR_UFSR:0x100 UNALIGNED
问题解决
- 开始怀疑内存对齐问题,手动申请大块内存,发现没有死机
- 通过软件单步调试,最终不断缩小问题的【范围】
- 最后确认死机来自ST HAL SPI 驱动
- 【尝试方法一】:更换ST HAL库,发现问题依旧
- 【尝试方法二】:对比ART-Pi SDK,对比驱动,定位在:
drv_spi.c
- 通过代码对比ART-PI SDK 正常点屏的
drv_spi.c
驱动,最终定位在一个SPI 的配置上
$ git diff rtt_4.1.0/libraries/HAL_Drivers/drv_spi.c
diff --git a/rtt_4.1.0/libraries/HAL_Drivers/drv_spi.c b/rtt_4.1.0/libraries/HAL_Drivers/drv_spi.c
index 7630d39..79f65bb 100644
--- a/rtt_4.1.0/libraries/HAL_Drivers/drv_spi.c
+++ b/rtt_4.1.0/libraries/HAL_Drivers/drv_spi.c
@@ -228,7 +228,7 @@ static rt_err_t stm32_spi_init(struct stm32_spi *spi_drv, struct rt_spi_configur
spi_handle->Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE;
spi_handle->Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_ENABLE;
spi_handle->Init.IOSwap = SPI_IO_SWAP_DISABLE;
- spi_handle->Init.FifoThreshold = SPI_FIFO_THRESHOLD_08DATA;
+ spi_handle->Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA;
#endif
if (HAL_SPI_Init(spi_handle) != HAL_OK)
- 解决方法为:
spi_handle->Init.FifoThreshold = SPI_FIFO_THRESHOLD_08DATA;
要改为:
spi_handle->Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA;
- 这个方法算是临时的解决方法,后面研究有效的解决方法,次方法发现刷屏【卡顿】
编译下载
- 通过修复
drv_spi.c
的配置,配置了memheap,发现屏幕正常的点亮了
小结
- 熟悉RT-Thread 最新版本 ART-Pi 最小工程的搭建方法
- 熟悉 ART-Pi 板载 SPI LCD的驱动方法
- 修复LCD无法点亮的问题