Some boards have identical hardware id and differ only in hardware revision (e.g. Acher C20 and Archer C20i). Such case confuse image inspection code and it selects wrong board info structure.
Rework the board detection code to make it consider the hw revision field. Now it returns best match board info: * if possible then return board info with matched hw_id & hw_rev * otherwise return first board info with matched hw_id (fallback to old behaviour) Signed-off-by: Sergey Ryazanov <ryazanov....@gmail.com> --- tools/firmware-utils/src/mktplinkfw2.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tools/firmware-utils/src/mktplinkfw2.c b/tools/firmware-utils/src/mktplinkfw2.c index 6ef51db55b..9425ad3c82 100644 --- a/tools/firmware-utils/src/mktplinkfw2.c +++ b/tools/firmware-utils/src/mktplinkfw2.c @@ -272,16 +272,22 @@ static struct board_info *find_board(char *id) return ret; } -static struct board_info *find_board_by_hwid(uint32_t hw_id) +static struct board_info *find_board_by_hwid(uint32_t hw_id, uint32_t hw_rev) { struct board_info *board; + struct board_info *match = NULL; for (board = boards; board->id != NULL; board++) { - if (hw_id == board->hw_id) - return board; + if (hw_id != board->hw_id) + continue; + if (match && hw_rev != board->hw_rev) + continue; + match = board; + if (hw_rev == board->hw_rev) + return match; }; - return NULL; + return match; } static struct flash_layout *find_layout(char *id) @@ -799,7 +805,7 @@ static int inspect_fw(void) goto out_free_buf; hdr = (struct fw_header *)buf; - board = find_board_by_hwid(ntohl(hdr->hw_id)); + board = find_board_by_hwid(ntohl(hdr->hw_id), ntohl(hdr->hw_rev)); if (!board) board = &custom_board; -- 2.13.0 _______________________________________________ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev