Guard CONFIG_ENV_OFFSET/SIZE in hi-common.h to prevent saveenv destroying kernel - #10
Merged
Conversation
The previous fix used CONFIG_ENV_SIZE in the malloc definition, but hi-common.h redefines CONFIG_ENV_SIZE from 0x40000 to 0x10000 after hi3516av200.h, silently shrinking the heap from 768KB to 576KB. Use a literal 0x40000 + 768KB = 1MB total heap. This value: - Fits UBI's 124KB vmalloc after TFTP (issue #5) - Stays within SPL MMU page table limits for cold NAND boot (issue #7) Tested on hardware: cold NAND boot OK, full 7-partition UBI restore OK. Closes #7 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
hi-common.h unconditionally overrides CONFIG_ENV_OFFSET from 0x80000 to 0x40000, placing the U-Boot environment at 256KB — inside the kernel area on NAND cameras. saveenv then erases the 128KB block at 0x40000-0x5FFFF, destroying kernel data starting at 0x50000. Wrap CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, and CONFIG_ENV_SECT_SIZE with #ifndef guards so board-specific values are preserved. Also pad mini-boot.bin to 1MB in build.sh — SPI NAND cold boot requires the full boot partition to be written (the FMC memory-mapped interface needs contiguous page data across erase block boundaries). Tested on hardware: cold NAND boot + full UBI restore both pass. Closes #9 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
widgetii
force-pushed
the
fix/ubi-write-after-tftp
branch
from
April 22, 2026 17:57
5cb24f8 to
2fc0df9
Compare
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
hi-common.hunconditionally overridesCONFIG_ENV_OFFSETfrom0x80000to0x40000, placing the environment at 256KB — inside the kernel area on NANDsaveenverases the 128KB block at 0x40000-0x5FFFF, destroying kernel data at 0x50000CONFIG_ENV_OFFSET,CONFIG_ENV_SIZE, andCONFIG_ENV_SECT_SIZEwith#ifndefguards (same pattern as theCONFIG_SYS_MALLOC_LENfix in Fix ubi write failing after TFTP on hi3516av200 #6)Test plan
Closes #9
🤖 Generated with Claude Code