Skip to content

Conversation

@godmial
Copy link
Contributor

@godmial godmial commented May 30, 2025

拉取/合并请求描述:(PR description)

[

为什么提交这份PR (why to submit this PR)

gd32470z-lckfb 开发板增加板载 SPI Flash 的支持,包括驱动适配、文档补充与 Kconfig 配置项扩展。

你的解决方案是什么 (what is your solution)

  • 增加 SPI Flash 初始化逻辑,支持多 SPI 总线(SPI0~SPI4)通过配置数组挂载;
  • 支持 SFUD 框架探测 flash,并支持挂载为 elmfat 文件系统(需关闭 DFS);
  • 完善 README.md 文档,提供详细 menuconfig 配置路径说明;
  • 更新 Kconfig,新增 SPI4 及 DMA 配置项;
  • 增加 MAINTAINERS 信息,标明维护者身份。

请提供验证的bsp和config (provide the config and bsp)

  • BSP: gd32470z-lckfb
  • .config: 开启 RT_USING_SPI, RT_USING_SFUD, BSP_USING_SPI, BSP_USING_SPI4,关闭 RT_USING_DFS
  • action:
    ]

当前拉取/合并请求的状态 Intent for your PR

必须选择一项 Choose one (Mandatory):

  • 本拉取/合并请求是一个草稿版本 This PR is for a code-review and is intended to get feedback
  • [*] 本拉取/合并请求是一个成熟版本 This PR is mature, and ready to be integrated into the repo

代码质量 Code Quality:

我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:

  • [*] 已经仔细查看过代码改动的对比 Already check the difference between PR and old code
  • [*] 代码风格正确,包括缩进空格,命名及其他风格 Style guide is adhered to, including spacing, naming and other styles
  • [*] 没有垃圾代码,代码尽量精简,不包含#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up
  • [*] 所有变更均有原因及合理的,并且不会影响到其他软件组件代码或BSP All modifications are justified and not affect other components or BSP
  • [*] 对难懂代码均提供对应的注释 I've commented appropriately where code is tricky
  • [*] 代码是高质量的 Code in this PR is of high quality
  • [*] 已经使用formatting 等源码格式化工具确保格式符合RT-Thread代码规范 This PR complies with RT-Thread code specification
  • [*] 如果是新增bsp, 已经添加ci检查到.github/workflows/bsp_buildings.yml 详细请参考链接BSP自查

@github-actions github-actions bot added BSP BSP: GD32 BSP related with GD32 labels May 30, 2025
@supperthomas supperthomas requested a review from Copilot May 30, 2025 05:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for SPI Flash on the gd32470z-lckfb board while refactoring the SPI Flash driver to support multiple SPI buses and updating documentation and configuration files.

  • Refactors the flash driver to use a configuration array for multiple SPI buses
  • Adds new Kconfig options for SPI4 and related DMA settings
  • Updates README.md with new SPI Flash mount instructions and revises maintainers info

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
bsp/gd32/arm/libraries/gd32_drivers/drv_spi_flash.c Refactored driver to support multi-SPI bus attachment and SFUD probe
bsp/gd32/arm/gd32470z-lckfb/board/Kconfig Added configuration options for SPI4 and its DMA settings
bsp/gd32/arm/gd32470z-lckfb/README.md Updated documentation for SPI Flash usage and configuration
MAINTAINERS Updated maintainer information for the board

return RT_EOK;
}
INIT_COMPONENT_EXPORT(rt_hw_spi_flash_with_sfud_init);
result = rt_hw_spi_device_attach(cfg->bus_name, cfg->device_name, cfg->cs_pin);
Copy link

Copilot AI May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling in the for loop overwrites the result from each iteration. Consider aggregating the success state across multiple device attachments or revising the error reporting to ensure that a successful attachment isn't masked by a subsequent failure.

Copilot uses AI. Check for mistakes.
else
{
rt_kprintf("spi flash mount failed!\n");
if (dfs_mount(cfg->flash_name, "/", "elm", 0, 0) == RT_EOK)
Copy link

Copilot AI May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mounting all SPI Flash devices to the root directory "/" could lead to conflicts when multiple devices are attached. Consider using unique mount points or a strategy to prevent potential mount point collisions.

Copilot uses AI. Check for mistakes.
@kurisaW
Copy link
Member

kurisaW commented Jun 5, 2025

请给出测试截图

static const struct spi_flash_config flash_configs[] =
{
#ifdef BSP_USING_SPI0
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这块格式化有点问题,建议重新刷一下格式

{
.bus_name = "spi4",
.device_name = "spi40",
.flash_name = "gd25qsp",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个flash_name确定不是gd25q_spi4

@godmial
Copy link
Contributor Author

godmial commented Jun 6, 2025

请给出测试截图

image

@godmial godmial requested a review from Rbb666 June 6, 2025 01:05
@godmial
Copy link
Contributor Author

godmial commented Jun 6, 2025

@kurisaW @Rbb666

@Rbb666
Copy link
Member

Rbb666 commented Jun 9, 2025

请给出测试截图

image

请作者也添加下针对flash的读,写,擦相关的测试截图吧

@godmial
Copy link
Contributor Author

godmial commented Jun 9, 2025

请给出测试截图

image

请作者也添加下针对flash的读,写,擦相关的测试截图吧

flash_test
使用SFDU的bench操作涵盖了读和写测试

@Rbb666 Rbb666 closed this Jun 9, 2025
@Rbb666 Rbb666 reopened this Jun 9, 2025
@Rbb666 Rbb666 merged commit aec10aa into RT-Thread:master Jun 9, 2025
117 checks passed
@godmial godmial deleted the gd32_spi_test branch June 19, 2025 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BSP: GD32 BSP related with GD32 BSP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants