Fix ubi write failing after TFTP on hi3516av200 - #6
Merged
Conversation
`ubi write` failed with -ENOMEM after any TFTP transfer because `vmalloc(126976)` (malloc for one LEB) could not find 124KB of free heap. The root cause was that hi-common.h unconditionally redefined CONFIG_SYS_MALLOC_LEN to (CONFIG_ENV_SIZE + 512KB), silently overriding the board-specific value set in hi3516av200.h. This left only ~576KB of heap, of which ~548KB was consumed by UBI structures and network stack allocations after TFTP. Guard CONFIG_SYS_MALLOC_LEN in hi-common.h with #ifndef so board-specific values are preserved, and increase the hi3516av200 malloc pool from 128KB to 2MB. Closes #5 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The #ifndef guard in hi-common.h now lets board-specific CONFIG_SYS_MALLOC_LEN values through. The hi3519v101 default of 128KB was below the 512KB minimum required by UBI, causing a build error. Increase to 2MB to match hi3516av200. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2 tasks
widgetii
added a commit
that referenced
this pull request
Apr 22, 2026
…ying kernel (#10) ## Summary - `hi-common.h` unconditionally overrides `CONFIG_ENV_OFFSET` from `0x80000` to `0x40000`, placing the environment at 256KB — inside the kernel area on NAND - `saveenv` erases the 128KB block at 0x40000-0x5FFFF, destroying kernel data at 0x50000 - Wrap `CONFIG_ENV_OFFSET`, `CONFIG_ENV_SIZE`, and `CONFIG_ENV_SECT_SIZE` with `#ifndef` guards (same pattern as the `CONFIG_SYS_MALLOC_LEN` fix in #6) ## Test plan - [x] Cold NAND boot — passes - [x] Full 7-partition UBI restore — all partitions written, zero errors Closes #9 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: john-1 <john-1@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
ubi writefailed with-ENOMEMafter any TFTP transfer becausehi-common.hunconditionally redefinedCONFIG_SYS_MALLOC_LENto 768KB, overriding the board-specific value inhi3516av200.hubi writeneedsCONFIG_SYS_MALLOC_LENinhi-common.hwith#ifndefand increase hi3516av200 malloc pool from 128KB to 2MBRoot cause
hi3516av200.hdefinesCONFIG_SYS_MALLOC_LENat line 104, then#includeshi-common.hat line 358.hi-common.hunconditionally redefinesCONFIG_SYS_MALLOC_LENtoCONFIG_ENV_SIZE + 512*1024, silently discarding whatever the board header set. This is why the issue reporter's attempt to increase malloc to 2MB inhi3516av200.hhad no effect.Debug instrumentation on real hardware confirmed:
Test plan
defib restorewith all 7 MTD partitions (including 4 UBI partitions viaubi writeafter TFTP) on real hi3516av200 hardware — all partitions written successfully, zero errorsCloses #5
🤖 Generated with Claude Code