Skip to content

uboot: fix first-time volume creation on empty UBI - #169

Open
ByteArray0 wants to merge 1 commit into
hanwckf:masterfrom
ByteArray0:master
Open

uboot: fix first-time volume creation on empty UBI#169
ByteArray0 wants to merge 1 commit into
hanwckf:masterfrom
ByteArray0:master

Conversation

@ByteArray0

Copy link
Copy Markdown

Overview

Fix the issue where Web failsafe gets stuck during the first-time creation of the fit volume on an empty UBI.

Reproduction Steps

  1. A CMCC A10 router in original factory state, not flashed before
  2. Connect to the router via TTL
  3. Use the flashing function of the stock U-Boot to directly flash the fip and bl2 provided by bl-mt798x
  4. After reboot, use the web UI to flash the official OpenWrt CMCC A10 (ubootmod) firmware
  5. The flashing process gets stuck at Creating dynamic volume fit

Logs:

*** Upgrading Firmware ***
*** Data: 11010333 (0xa8011d) bytes at 0x460000dc ***
UBI partition 'ubi' already selected
Volume fit not found! Volume fip not found!
ubi0: detaching mtd6
ubi0: mtd6 is detached Erasing 'ubi' from 0x580000, size 0x7280000 ... OK
UBI partition 'ubi' already selected
Volume rootfs_data not found!
Volume fit not found!
Creating dynamic volume fit of size 11010333

Testing shows that if the fit volume is created manually in the U-Boot command line first, then flashing again will show that the fit volume already exists and its contents are being updated, and the flashing process can continue.

This indicates that the Web upgrade flow gets stuck at the stage of first-time fit volume creation on an empty UBI.

Based on this, it is inferred that this issue is not exclusive to CMCC A10; all cases involving expansion of the tail partition should have the same issue.

Cause Analysis

After erasing the raw UBI MTD partition, the current code only calls ubi_exit() and does not clear the currently selected UBI context relied on by ubi_part().

Therefore, when ubi_part() is called again later, it hits the "already selected" path, which means it does not actually re-attach to the erased partition, but instead continues using the old UBI state.

Fix

In the UBI rebuild/re-mount path, replace ubi_exit() with detach logic, so that before re-attaching the same partition, the old UBI context is cleared.


概述

修复 Web failsafe 刷机时,空 UBI 上首次创建 fit 卷卡住的问题。

复现步骤

  1. 一台原厂未刷机的 CMCC A10 路由器
  2. 使用 TTL 连接路由器
  3. 通过原厂 Uboot 的刷写功能直接刷入 bl-mt798x 提供的 fip 和 bl2
  4. 重启后使用 web-ui 刷入 OpenWrt 官方提供的 CMCC A10 (ubootmod) 固件
  5. 刷写卡在 Creating dynamic volume fit

日志:

*** Upgrading Firmware ***
*** Data: 11010333 (0xa8011d) bytes at 0x460000dc ***
UBI partition 'ubi' already selected
Volume fit not found! Volume fip not found!
ubi0: detaching mtd6
ubi0: mtd6 is detached Erasing 'ubi' from 0x580000, size 0x7280000 ... OK
UBI partition 'ubi' already selected
Volume rootfs_data not found!
Volume fit not found!
Creating dynamic volume fit of size 11010333

经测试发现,若手动在 uboot 命令行中完成 fit 卷的创建,再次刷写会显示“fit 卷已存在,更新内容”,刷写流程可以进行下去。

此现象说明,Web 升级流程会卡在空 UBI 上首次创建 fit 卷的阶段;由此推测此问题并非 CMCC A10 专属,所有涉及到扩容尾部分区的都有此问题。

原因

在擦除原始 UBI MTD 分区后,当前代码只调用了 ubi_exit(),没有清除 ubi_part() 依赖的当前已选中 UBI 上下文。

因此,后续再次调用 ubi_part() 时,会命中 "already selected",导致实际上并没有重新 attach 到擦除后的分区,而沿用了旧的 UBI 状态。

修复

在 UBI 重建/重挂载路径中,用 detach 逻辑替代 exit,确保重新 attach 同一个分区前,旧的 UBI 上下文被清空。

Yuzhii0718 added a commit to Yuzhii0718/bl-mt798x-dhcpd that referenced this pull request Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant