Add Checksums to Firmware & External App images (#1809)

* Pad image to 1MB and add simple checksum

* Test code to verify firmware checksum

* Comment out unneeded zlib

* Add files via upload

* Print space remaining in ROM

* Append checksum to external apps too

* Check external app checksums when loading

* Is it 2024 already?!

* Validate firmware checksum before flashing

* Add files via upload

* Added flash error warning to nav screen

* Clang

* Replaced some hard-coded values with #defines

* Check FW checksum before USB serial flash too

* Add files via upload
This commit is contained in:
Mark Thompson 2024-01-24 16:37:21 -06:00 committed by GitHub
parent 2d98c5d311
commit 6a6c6d6502
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 179 additions and 13 deletions

View file

@ -503,8 +503,8 @@ void SystemStatusView::rtc_battery_workaround() {
month = (timestamp.FAT_date >> 5) & 0xF;
day = timestamp.FAT_date & 0x1F;
// bump to next month at 28 days for simplicity
if (++day > 28) {
// bump to next month
if (++day > rtc_time::days_per_month(year, month)) {
day = 1;
if (++month > 12) {
month = 1;
@ -547,16 +547,16 @@ InformationView::InformationView(
&ltime});
#if GCC_VERSION_MISMATCH
static constexpr Style style_gcc_warning{
.font = font::fixed_8x16,
.background = {33, 33, 33},
.foreground = Color::yellow(),
};
version.set_style(&style_gcc_warning);
version.set_style(&Styles::yellow);
#else
version.set_style(&style_infobar);
#endif
if (firmware_checksum_error()) {
version.set("FLASH ERROR");
version.set_style(&Styles::red);
}
ltime.set_style(&style_infobar);
refresh();
set_dirty();
@ -568,6 +568,17 @@ void InformationView::refresh() {
ltime.set_date_enabled(pmem::clock_with_date());
}
bool InformationView::firmware_checksum_error() {
static bool fw_checksum_checked{false};
static bool fw_checksum_error{false};
// only checking firmware checksum once per boot
if (!fw_checksum_checked) {
fw_checksum_error = (simple_checksum(FLASH_STARTING_ADDRESS, FLASH_ROM_SIZE) != FLASH_EXPECTED_CHECKSUM);
}
return fw_checksum_error;
}
/* Navigation ************************************************************/
bool NavigationView::is_top() const {