Skip to content

Fix incomplete NAND sysupgrade (kernel only, rootfs skipped)#23

Merged
HiGarfield merged 1 commit into
masterfrom
copilot/upgrade-firmware-completely
Jun 21, 2026
Merged

Fix incomplete NAND sysupgrade (kernel only, rootfs skipped)#23
HiGarfield merged 1 commit into
masterfrom
copilot/upgrade-firmware-completely

Conversation

Copilot AI commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Problem

After commit 1a04e13, NAND firmware upgrades only wrote the kernel but skipped rootfs upgrade entirely.

Root Cause

Line 267 in package/base-files/files/lib/upgrade/nand.sh inverted the kernel MTD check:

[ "$kernel_length" = 0 -o ! -z "$kernel_mtd" ] && has_kernel=0

The ! -z "$kernel_mtd" condition (NOT empty) incorrectly set has_kernel=0 when a kernel MTD partition existed, preventing the kernel UBI volume write in nand_upgrade_prepare_ubi().

Fix

Corrected the logic to properly detect when kernel MTD partition is absent:

[ "$kernel_length" = 0 -o -z "$kernel_mtd" ] && has_kernel=0

Now has_kernel=0 only when kernel data is missing OR kernel MTD partition doesn't exist, allowing both kernel and rootfs to be written to UBI volumes during upgrade.

Change line 267 from '! -z' to '-z' to properly check if kernel_mtd is empty.
The previous logic incorrectly set has_kernel=0 when kernel_mtd was NOT empty,
preventing the kernel from being written to UBI volume and causing incomplete upgrades.
@HiGarfield HiGarfield marked this pull request as ready for review June 21, 2026 18:40
Copilot AI review requested due to automatic review settings June 21, 2026 18:40
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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

Fixes a regression in the NAND sysupgrade TAR path where has_kernel could be forced to 0 even when a kernel MTD partition exists, preventing the kernel UBI volume from being created/updated during upgrade preparation.

Changes:

  • Corrected the kernel MTD presence check in nand_upgrade_tar() by replacing ! -z "$kernel_mtd" with -z "$kernel_mtd" when deciding whether to clear has_kernel.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@HiGarfield HiGarfield merged commit b220bbc into master Jun 21, 2026
1 check passed
@HiGarfield HiGarfield deleted the copilot/upgrade-firmware-completely branch June 21, 2026 19:00
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.

3 participants