Skip to content

bsp: allwinner: fix RT-Smart boot on D1 - #11714

Open
lanceharvie wants to merge 4 commits into
RT-Thread:masterfrom
lanceharvie:fix/allwinner-d1-rtsmart
Open

bsp: allwinner: fix RT-Smart boot on D1#11714
lanceharvie wants to merge 4 commits into
RT-Thread:masterfrom
lanceharvie:fix/allwinner-d1-rtsmart

Conversation

@lanceharvie

Copy link
Copy Markdown

Problem

The Allwinner D1 RT-Smart BSP retained stale startup, MMU, serial, and storage integration code which prevented successful operation on real D1/C906 hardware.

Problems included an obsolete MMU initialization path and kernel address assumptions, allocation before heap initialization, duplicate BSS and UART initialization, Serial V1 configuration, an incorrect console device and baud default, and missing D1 SDMMC partition integration.

Resolution

  • Migrate D1 board initialization to the current common64 MMU model.
  • Identity-map the D1 kernel region at its real 0x45000000 load address.
  • Initialize the heap before allocating BSP components.
  • Remove duplicate BSS and UART HAL initialization.
  • Enable Serial V2 with UART0 at 115200 8N1.
  • Restore the D1 SDMMC0 partition port using current device APIs.
  • Mount ROMFS as a deterministic root filesystem.
  • Resolve watchdog/reset ownership and stale configuration dependencies.
  • Document the D1/C906 hardware and current build procedure.

Validation

The functional bring-up was tested on real Allwinner D1 / T-Head C906 hardware in the Sipeed Lichee RV 86 Panel class and reached an interactive RT-Smart shell:

msh />

Runtime testing covered scheduler operation, system ticks, thread sleep/wakeup, UART0 console, SDMMC block access, ROMFS/devfs, lwIP initialization, and kernel heap/page allocation.

The master-based series builds successfully with the RT-Thread RISC-V musl toolchain:

text      775663
data       46560
bss       417024
total    1239247

The hardware-validated prototype was based on RT-Thread v5.0.2. This current-master adaptation still requires a final board regression using firmware with the corrected T-Head CLINT devicetree binding; that firmware change is separate from this RT-Thread series.

@CLAassistant

CLAassistant commented Aug 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

Copy link
Copy Markdown

👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread!

为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。
To ensure your code complies with RT-Thread's coding style, please run the code formatting workflow by following the steps below (If the formatting of CI fails to run).


🛠 操作步骤 | Steps

  1. 前往 Actions 页面 | Go to the Actions page
    点击进入工作流 → | Click to open workflow →

  2. 点击 Run workflow | Click Run workflow

  • Use workflow from 保持默认分支(通常为 master
    Keep the default branch (usually master) in Use workflow from
  • branch 输入框填写 PR 分支 fix/allwinner-d1-rtsmart
    Enter PR branch fix/allwinner-d1-rtsmart in the branch field
  • 设置需排除的文件/目录(目录请以"/"结尾)
    Set files/directories to exclude (directories should end with "/")
  1. 等待工作流完成 | Wait for the workflow to complete
    格式化后的代码将作为独立提交推送至你的分支。
    The formatting changes will be pushed to your branch as a separate commit.

完成后,提交将自动更新至 fix/allwinner-d1-rtsmart 分支,关联的 Pull Request 也会同步更新。
Once completed, commits will be pushed to the fix/allwinner-d1-rtsmart branch automatically, and the related Pull Request will be updated.

如有问题欢迎联系我们,再次感谢您的贡献!💐
If you have any questions, feel free to reach out. Thanks again for your contribution!

@github-actions github-actions Bot added the BSP label Aug 16, 2026
@Rbb666

Rbb666 commented Aug 17, 2026

Copy link
Copy Markdown
Member

@rcitach 麻烦帮忙review下

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates the Allwinner D1 RT-Smart BSP bring-up path so it can boot and run reliably on real D1/C906 hardware, aligning the BSP with RT-Thread’s current RISC-V common64 MMU model and refreshing console/storage integration.

本 PR 旨在修复全志 D1(C906)RT-Smart BSP 的启动与运行问题,使其与当前 RT-Thread RISC-V common64 MMU 模型对齐,并更新串口控制台与存储/文件系统集成,以支持真实硬件稳定启动与交互。

Changes / 变更点:

  • Update D1 board init to common64 MMU mapping flow, and adjust kernel VA start/load assumptions (identity mapping around the real load address).
    更新 D1 板级初始化到 common64 MMU 初始化流程,并修正内核虚拟地址起始/加载地址假设(按实际加载地址进行恒等映射)。
  • Switch console configuration to uart0 and adjust UART default baudrate handling; migrate to Serial V2 config for D1.
    将控制台切换到 uart0,并支持通过 BSP 配置设置默认波特率;D1 侧启用 Serial V2 配置。
  • Restore SDMMC usage selection behavior and add a D1 partition port + ROMFS root mount path.
    恢复/修正 SDMMC 使用选择逻辑,新增 D1 分区适配代码,并以 ROMFS 挂载为确定性根文件系统。

PR checklist note / PR 清单提示:

  • Title format: current title bsp: allwinner: fix RT-Smart boot on D1 does not match the repository guideline “[module/vendor][subsystem] Description (lowercase)”. Consider something like: [allwinner][d1] Fix RT-Smart boot on D1.
    标题格式:当前标题不符合仓库建议的“[模块/厂商][子系统] 描述(小写)”格式,可考虑例如:[allwinner][d1] Fix RT-Smart boot on D1

Reviewed changes

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

Show a summary per file
File Description
bsp/allwinner/libraries/libos/src/os.c Adjust used_card_no default for D1 SDMMC selection.
bsp/allwinner/libraries/drivers/sdmmc/drv_sdmmc.c Initialize only selected SDMMC hosts; return explicit status.
bsp/allwinner/libraries/drivers/Kconfig Avoid selecting FAL for D1 when enabling FS.
bsp/allwinner/libraries/drivers/drv_uart.c Allow BSP-configured default UART baudrate (fallback preserved).
bsp/allwinner/d1/rtconfig.py Add -D__ASSEMBLY__ for assembler-with-cpp builds.
bsp/allwinner/d1/rtconfig.h Update console name, kernel VA start, Serial V2, SDMMC options, baudrate macro.
bsp/allwinner/d1/.config Sync menuconfig outputs with new console/MMU/serial/SDMMC settings.
bsp/allwinner/d1/Kconfig Add BSP_UART_DEFAULT_BAUDRATE Kconfig option.
bsp/allwinner/d1/link.lds Export text range symbols for potential runtime use.
bsp/allwinner/d1/board/board.c Migrate to common64 MMU setup; adjust init ordering; console device selection.
bsp/allwinner/d1/applications/mnt.c Mount ROMFS on / as deterministic root FS.
bsp/allwinner/d1/README.md Document validated hardware, console settings, load address, and build steps.
bsp/allwinner/d1/ports/SConscript New ports aggregation SConscript for submodules.
bsp/allwinner/d1/ports/partition/SConscript Build glue for partition port under SDMMC dependency.
bsp/allwinner/d1/ports/partition/partition.h Partition API/types for the BSP port.
bsp/allwinner/d1/ports/partition/partition.c Partition block-device adapter implementation for D1.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +144 to +148
/* open the block device */
rt_device_open(device, RT_DEVICE_OFLAG_RDWR);
/* get block device geometry */
rt_device_control(device, RT_DEVICE_CTRL_BLK_GETGEOME, &geometry);

Comment on lines +4 to +10
objs = []
cwd = GetCurrentDir()
list = os.listdir(cwd)

for item in list:
if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
objs = objs + SConscript(os.path.join(item, 'SConscript'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants