[device][mmcsd] Fix Arm Compiler 5 build compatibility - #11690
Conversation
📌 Code Review Assignment🏷️ Tag: componentsReviewers: @Maihuanyi Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2026-08-10 12:01 CST)
📝 Review Instructions
|
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
|
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Fixes Arm Compiler 5 (ARMCC5) build compatibility issues in MMC/SD, block layer, and partition parsing by removing non‑portable constructs and resolving naming/macro conflicts.
Changes:
- Renamed MMC command
SWITCHtoMMC_SWITCHand updated affected call sites. - Removed/avoided ARMCC5-incompatible language features (anonymous structs,
typeof-based list traversal, void* pointer arithmetic). - Added fallback partition struct when DFS is disabled and normalized sector-size usage / memory free API.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| components/drivers/sdio/dev_sd.c | Uses a compiler-safe accessor macro for SD status bitfields |
| components/drivers/sdio/dev_mmcsd_core.c | Adjusts struct initialization for ARMCC compatibility (but introduces uninitialized locals) |
| components/drivers/sdio/dev_mmc.c | Switches MMC command macro to MMC_SWITCH |
| components/drivers/sdio/dev_block.c | Introduces MMCSD_SECTOR_SIZE, removes rt_min_t usage, fixes pointer arithmetic, switches to rt_free |
| components/drivers/include/drivers/mmcsd_cmd.h | Renames SWITCH macro to MMC_SWITCH |
| components/drivers/include/drivers/mmcsd_card.h | Adds named fields for ARMCC5 and accessor macro RT_SD_STATUS_FIELD |
| components/drivers/include/drivers/blk.h | Adds dfs_partition fallback definition when DFS is disabled |
| components/drivers/block/partitions/efi.c | Replaces rt_min_t usage with explicit clamping for disk size |
| components/drivers/block/blk_dfs.c | Fixes void* pointer arithmetic by using byte pointers; adjusts DFS header inclusion |
| components/drivers/block/blk.c | Replaces typeof list iteration macros; adds DFS-optional mounted path helper |
| bsp/phytium/libraries/drivers/drv_sdif_msg.c | Updates command switch-case to use MMC_SWITCH |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| struct rt_mmcsd_req req; | ||
| struct rt_mmcsd_cmd cmd; | ||
| struct rt_mmcsd_data data; |
| rt_uint32_t sz = 0; | ||
| rt_uint32_t disk_size; | ||
| int part = 0, ret = 0; /* invalid by default */ | ||
|
|
||
| disk_size = total_sectors - 1 > RT_UINT32_MAX ? | ||
| RT_UINT32_MAX : (rt_uint32_t)(total_sectors - 1); |
拉取/合并请求描述:(PR description)
为什么提交这份PR (why to submit this PR)
Arm Compiler 5 编译 MMC/SD 与块设备代码时存在多处兼容性问题:通用的
SWITCH名称会与部分芯片寄存器宏冲突,匿名结构体和依赖typeof的链表遍历无法稳定编译,DFS 关闭时缺少分区结构定义,部分代码还使用了void *指针运算。这些问题会导致相关 BSP 在 AC5 下出现编译错误。你的解决方案是什么 (what is your solution)
MMC_SWITCH,并同步修改 Phytium SDIF 调用点,避免与芯片头文件冲突。rt_list_entry替代依赖typeof的块设备链表遍历。rt_min_t的写法。请提供验证的bsp和config (provide the config and bsp)
bsp/n32/n32hxxx/n32h760zil7-stb、bsp/qemu-vexpress-a9当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up