Repository navigation
Fixing a bug in reverse lookup of ID to enum - #125
Merged
Merged
Conversation
Member
|
Code-wise looks good to me, but I still didn't get to get hands-on with FW on the ET, neither do I have a board to test the change on, so I'll refrain from the approval and let Vidas and Gianluca properly approve it. |
glguida
approved these changes
Apr 6, 2026
glguida
left a comment
Member
There was a problem hiding this comment.
Yes, this is something that I noticed back when I was playing with it.
Thanks for the patch!
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.
When I was trying to replace SP_BL2 in the image I've noticed that SP_BL2 resolves to numeric ID 0x9 in the enum at firmware-flash-tool/include/esperanto_flash_image.h:18. The replace path then matches regions by numeric region_id, not by the printed string, at firmware-flash-tool/src/esperanto_flash_image_replace.c:90.
The bad output comes from region_id_to_name(), which assumes the lookup table is in enum order, but the table has PMIC_FW_S0 and PMIC_FW_S1 inserted before SP_BL1/SP_BL2 at firmware-flash-tool/src/parse_template_file.c:31. So ID 0x9 gets mislabeled as PMIC_FW_S1 when printed at firmware-flash-tool/src/parse_template_file.c:71.
Arguably this can be maintained at the cost of precise ordering, but it seems that a quick scan of the table is a better option