Skip to content

Fix bug after reset fw-read & slot active/inactive bug - #404

Merged
BenReed161 merged 2 commits into
Microsemi:masterfrom
BenReed161:fw-update-fix
Aug 6, 2026
Merged

Fix bug after reset fw-read & slot active/inactive bug#404
BenReed161 merged 2 commits into
Microsemi:masterfrom
BenReed161:fw-update-fix

Conversation

@BenReed161

Copy link
Copy Markdown
Collaborator

No description provided.

The fw_slot calculation for MRPC_FW_IMG_GET was inverted: even
part_ids (active slots like BL20=4) were mapped to fw_slot=1
(inactive) and odd part_ids (inactive like BL21=5) mapped to
fw_slot=0 (active). This caused fw-read of the active partition to
actually read the inactive slot, failing when inactive is Invalid.

Fix by using part_id % 2 directly, which correctly maps even IDs to
slot 0 and odd IDs to slot 1.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@lsgunth lsgunth left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One very minor cosmetic thing, other than that it looks good to me. Thanks!

Comment thread lib/fw.c Outdated
return 1;
}


Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra blank line?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the catch, reverted change

All Gen6 partition types (CFG, BL2, IMG) require the full partition
content for a successful fw-update roundtrip. CFG includes appended
DCBI blocks, BL2/IMG include required padding to flash sector
boundaries.

Pass image_len=0 unconditionally so fw_img_get uses the firmware's
total_len response, which reports the correct full content size for
each partition type.

Additionally, close and reopen the device before issuing
MRPC_FW_IMG_GET to ensure firmware has fully initialized its flash
state after a recent hard-reset. Without this, the firmware may
return corrupted image data.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@BenReed161
BenReed161 merged commit 8fbf11a into Microsemi:master Aug 6, 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.

2 participants