Skip to content

Conversation

@unicornx
Copy link
Contributor

支持 01Studio 开发板使用 sdio 工作。

01Studio 将 TF 插槽连接到 sdio0,这与标准 canmv v1.0/v1.1 开发板(使用 sdio1)不同。

更新配置菜单,

  • SDIO设备现在是二选一。
  • 根文件系统类型也是多选一。目前只支持 cromfs 和 elmFAT。
  • 修改根文件系统默认的挂载分区为 sd0p1

删除配置 BSP_SD_SDIO_DEV,目前直接根据 SDIO 设备的选择结构设置 mmcsd_change。

消除 drv_sdhci.c 文件的告警以及规整代码格式。该文件逻辑没有本质修改。

同步并更新.config/rtconfig.h 到最新版本。

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

[

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

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

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

  • BSP:
  • .config:
  • 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 the BSP label May 20, 2025
@github-actions
Copy link

github-actions bot commented May 20, 2025

📌 Code Review Assignment

🏷️ Tag: bsp_k230

Path: bsp/k230
Reviewers: unicornx

Changed Files (Click to expand)
  • bsp/k230/.config
  • bsp/k230/Kconfig
  • bsp/k230/applications/mnt.c
  • bsp/k230/board/Kconfig
  • bsp/k230/drivers/interdrv/sdio/drv_sdhci.c
  • bsp/k230/rtconfig.h

📊 Current Review Status (Last Updated: 2025-05-20 10:34 UTC)

  • unicornx Pending Review

📝 Review Instructions

  1. 维护者可以通过单击此处来刷新审查状态: 🔄 刷新状态
    Maintainers can refresh the review status by clicking here: 🔄 Refresh Status

  2. 确认审核通过后评论 LGTM/lgtm
    Comment LGTM/lgtm after confirming approval

  3. PR合并前需至少一位维护者确认
    PR must be confirmed by at least one maintainer before merging

ℹ️ 刷新CI状态操作需要具备仓库写入权限。
ℹ️ Refresh CI status operation requires repository Write permission.

@unicornx unicornx requested a review from Rbb666 May 20, 2025 05:06
@unicornx unicornx added the BSP: K230 BSP related with K230 label May 20, 2025
@supperthomas supperthomas requested a review from Copilot May 20, 2025 06:54
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

Adds SDIO support for the k230 BSP by introducing selectable SDIO devices, switching the default root filesystem to elmFAT, updating mount logic, and cleaning up driver formatting.

  • Exposed SDIO device choice and root-FS type in Kconfig, defaulting to SDIO0 and elmFAT
  • Enabled vDSO and updated rtconfig.h defaults (mount partition, root-FS)
  • Refactored drv_sdhci.c to remove warnings and unify brace usage
  • Updated mnt.c to mount elmFAT or CROMFS based on config

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
bsp/k230/rtconfig.h Enable SDIO, vDSO, set default SD partition and elmFAT
bsp/k230/drivers/interdrv/sdio/drv_sdhci.c Clean up warnings, include mm_aspace, unify if/while braces
bsp/k230/board/Kconfig Add SDIO device choice, default to SDIO0
bsp/k230/Kconfig Add root-FS type choice, default to elmFAT
bsp/k230/applications/mnt.c Mount root from SDIO elmFAT or CROMFS, update console output
bsp/k230/.config Reflect chosen defaults for SDIO and elmFAT in generated config
Comments suppressed due to low confidence (1)

bsp/k230/board/Kconfig:36

  • [nitpick] Indentation of this default differs from surrounding entries; aligning it with the rest of the block improves Kconfig readability.
                    default n

Comment on lines 30 to 31
while (mmcsd_wait_cd_changed(100) != MMCSD_HOST_PLUGED)
;
Copy link

Copilot AI May 20, 2025

Choose a reason for hiding this comment

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

Avoid an infinite busy-wait loop without a timeout or yielding; consider adding a timeout counter or yielding to the scheduler to prevent blocking other tasks.

Suggested change
while (mmcsd_wait_cd_changed(100) != MMCSD_HOST_PLUGED)
;
int timeout = 50; // Timeout after 50 iterations (5 seconds if each iteration waits 100ms)
while (mmcsd_wait_cd_changed(100) != MMCSD_HOST_PLUGED)
{
if (--timeout <= 0)
{
rt_kprintf("Timeout waiting for MMCSD host to be plugged!\n");
return -1; // Return an error code to indicate failure
}
rt_thread_mdelay(100); // Yield to the scheduler
}

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

accepted and fixed

Comment on lines 61 to 64
rt_kprintf("tempfs mounted on /dev/shm failed!\n");
}

#ifdef BSP_SD_SDIO_DEV
while (mmcsd_wait_cd_changed(100) != MMCSD_HOST_PLUGED)
;

if (dfs_mount(BSP_SD_MNT_DEVNAME, "/mnt", "elm", 0, 0) != 0)
{
rt_kprintf("Dir /mnt mount failed!\n");
else {
rt_kprintf("tempfs mounted on /dev/shm success!\n");
Copy link

Copilot AI May 20, 2025

Choose a reason for hiding this comment

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

The filesystem name 'tempfs' appears to be a typo; the standard name is 'tmpfs', so updating the message improves clarity.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment on lines +198 to +202
if (host->tx_delay_line > 256)
{
LOG_E("host%d: tx_delay_line err\n", host->index);
} else if (host->tx_delay_line > 128) {
} else if (host->tx_delay_line > 128)
{
Copy link

Copilot AI May 20, 2025

Choose a reason for hiding this comment

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

[nitpick] The brace style around this if (and many following blocks) has been shifted from the project's usual K&R style; consider restoring consistent brace placement for readability and compliance with the coding standard.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

没有问题

Support sdio work for 01Studio board.

01Studio connect TF socket with sdio0, which is
different from standard canmv v1.0/v1.1 board
(which uses sdio1).

Updated configuration menu,
- SDIO devices are now a choice of two.
- Root file system types are also a choice of multiple.
  Currently only cromfs and elmFAT are supported.
- Modified the default mount partition of the root file
  system to sd0p1

Deleted the configuration BSP_SD_SDIO_DEV, and now
directly set mmcsd_change according to the selection of
the SDIO device.

Eliminated the warning of the drv_sdhci.c and
egularized the code format. The logic of this file
has not been essentially modified.

Sync and update the .config/rtconfig.h to the latest.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
@unicornx
Copy link
Contributor Author

Pull Request Overview

Adds SDIO support for the k230 BSP by introducing selectable SDIO devices, switching the default root filesystem to elmFAT, updating mount logic, and cleaning up driver formatting.

  • Exposed SDIO device choice and root-FS type in Kconfig, defaulting to SDIO0 and elmFAT
  • Enabled vDSO and updated rtconfig.h defaults (mount partition, root-FS)
  • Refactored drv_sdhci.c to remove warnings and unify brace usage
  • Updated mnt.c to mount elmFAT or CROMFS based on config

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
Comments suppressed due to low confidence (1)

not an issue, rejected.

@Rbb666 Rbb666 merged commit 3f1653b into RT-Thread:master May 21, 2025
36 checks passed
@unicornx unicornx deleted the dev-sdio0 branch May 26, 2025 05:53
@Rbb666 Rbb666 mentioned this pull request Sep 18, 2025
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BSP: K230 BSP related with K230 BSP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants