Skip to content

rpieepromab: Check bootloader minimum version#195

Merged
pelwell merged 1 commit into
raspberrypi:masterfrom
mathewb64:rpieepromab-mfg-ver-check
Jun 2, 2026
Merged

rpieepromab: Check bootloader minimum version#195
pelwell merged 1 commit into
raspberrypi:masterfrom
mathewb64:rpieepromab-mfg-ver-check

Conversation

@mathewb64
Copy link
Copy Markdown
Contributor

Abort the update if the version of the provided update is less than the bootloader minimum version of the board.

Comment thread rpieepromab/main.c Outdated
return -1;
}

for (size_t i = 0; i < n; i++) {
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.

Could you use ntohl instead ?

@mathewb64 mathewb64 force-pushed the rpieepromab-mfg-ver-check branch from a34c34b to 5f85a46 Compare June 1, 2026 14:12
Comment thread rpieepromab/main.c Outdated
return -1;
}

for (size_t i = 0; i + marker_len <= data_len; i++) {
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.

Sorry, I've just realised that you could use memmem here instead for a simpler search

Copy link
Copy Markdown
Contributor

@timg236 timg236 left a comment

Choose a reason for hiding this comment

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

Otherwise looks ok

@mathewb64 mathewb64 force-pushed the rpieepromab-mfg-ver-check branch from 5f85a46 to 4d283c5 Compare June 1, 2026 15:41
Comment thread rpieepromab/main.c Outdated
}

memcpy(&tmp, buf, sizeof(tmp));
*min_boot_ver = ntohl(tmp);
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.

It's not a strong preference - I leave it up to you to decide - but have you considered:

   *min_boot_ver = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];

and dropping tmp, the memcpy and the include (and GNU_SOURCE?)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah that looks better

Abort the update if the version of the provided update is less
than the bootloader minimum version of the board.
@mathewb64 mathewb64 force-pushed the rpieepromab-mfg-ver-check branch from 4d283c5 to 122bc4f Compare June 2, 2026 08:34
@pelwell pelwell merged commit c166688 into raspberrypi:master Jun 2, 2026
4 checks passed
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