Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootloader downgrade (0.6.x) #1416

Merged
merged 2 commits into from Nov 1, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion hal/src/stm32f2xx/bootloader.cpp
Expand Up @@ -44,11 +44,13 @@ bool bootloader_requires_update(const uint8_t* bootloader_image, uint32_t length
return false;

const uint32_t VERSION_OFFSET = 0x184+10;
const unsigned BOOTLOADER_0_7_0 = 13; // Module version of the bootloader shipped with 0.7.0

uint16_t current_version = *(uint16_t*)(0x8000000+VERSION_OFFSET);
uint16_t available_version = *(uint16_t*)(bootloader_image+VERSION_OFFSET);

bool requires_update = current_version<available_version;
// Downgrading from 0.7.0 requires a bootloader downgrade
bool requires_update = (current_version < available_version || current_version >= BOOTLOADER_0_7_0);
return requires_update;
}

Expand Down
4 changes: 3 additions & 1 deletion hal/src/stm32f2xx/core_hal_stm32f2xx.c
Expand Up @@ -376,7 +376,9 @@ void HAL_Core_Setup(void) {

HAL_Core_Setup_finalize();

bootloader_update_if_needed();
if (bootloader_update_if_needed()) {
HAL_Core_System_Reset();
}
HAL_Bootloader_Lock(true);

HAL_save_device_id(DCT_DEVICE_ID_OFFSET);
Expand Down