uboot: fix first-time volume creation on empty UBI - #169
Open
ByteArray0 wants to merge 1 commit into
Open
Conversation
Yuzhii0718
added a commit
to Yuzhii0718/bl-mt798x-dhcpd
that referenced
this pull request
Mar 16, 2026
--- inspred from <hanwckf/bl-mt798x#169>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Fix the issue where Web failsafe gets stuck during the first-time creation of the fit volume on an empty UBI.
Reproduction Steps
Creating dynamic volume fitLogs:
Testing shows that if the
fitvolume is created manually in the U-Boot command line first, then flashing again will show that thefitvolume 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 byubi_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 卷卡住的问题。
复现步骤
Creating dynamic volume fit日志:
经测试发现,若手动在 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 上下文被清空。