前言
- 【STM32H7S78-DK】开箱与rtthread工程初体验
- 【STM32H7S78-DK】rtthread 增加 psram 内存管理
概述
原先 Kconfig 已经有相应的配置项,但是存在很多问题,现在我们修改下,增加 sdcard 驱动,开启虚拟文件系统
配置工程
打开 bsp/stm32/stm32h7s7-st-disco 目录
-
打开 board/kconfig 文件,在 chip driver 目录增加 sdcard 配置,修改 onboard driver 的宏依赖


-
打开 bsp\stm32\libraries\STM32H7RSxx_HAL\SConscript 文件,增加开启 SDIO 时的 stm32 hal 库文件


-
接下来需要引入 SDIO 的引脚配置,因为 bsp 自带的 ioc 文件有问题,这边用 CubeMX 重新创建一个

-
按出厂固件的 boot 代码,需要将时钟修改进行如下调整

-
点击生成工程,将生成的目录下的 Appli 、Boot 替换 bsp/stm32/stm32h7s7-st-disco/board/CubeMX_Config/ 路径下的同名目录, ioc 也顺带替换了

-
使用 menuconfig 查看 onboard 驱动,看到已经增加 fs 配置,保存退出

-
使用 scons --target=mdk5 工具同步工程,在编译运行前还需要修改几个地方
-
打开 bsp/stm32/stm32h7s7-st-disco/board/CubeMX_Config/Appli/Core/Src/stm32h7rsxx_hal_msp.c 文件,加入 ErrorHandle 的处理函数

-
修改 bsp/stm32/libraries/HAL_Drivers/drivers/drv_sdmmc.c 文件,增加 h7rs 系列的寄存器差异

-
打开 bsp/stm32/stm32h7s7-st-disco/board/port/filesystem.c 文件,修改头文件和函数引用错误,并修改 sdcard 插卡检测的电平逻辑

-
编译下载,运行正常,看到 sd 驱动初始化,文件系统挂载成功

-
但是引入了其他问题,查看线程列表为空,其他定时器,设备列表无异常,屏蔽 mpu 之后可以显示,但是上一章其实是能显示的。目前未定位到是什么问题,有遇到过的小伙伴,帮忙指个方向

总结
得益于 st 的通用 hal 库,在 rtthread 的驱动设计里基本都可以直接使用,只需要添加小部分的芯片寄存器差异,主要是 kconfig 和 SConscript 的修改,需要匹配对应的宏 |