Skip to content

Commit

Permalink
keep initialize last_addr and reject if it doesnt change
Browse files Browse the repository at this point in the history
  • Loading branch information
conorpp committed Feb 13, 2020
1 parent 601c980 commit b78f2cd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions targets/stm32l432/bootloader/bootloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ typedef struct {
uint8_t payload[255 - 10];
} __attribute__((packed)) BootloaderReq;

uint8_t * last_written_app_address;
uint8_t * last_written_app_address = 0;

/**
* Erase all application pages. **APPLICATION_END_PAGE excluded**.
*/
static void erase_application()
{
int page;
last_written_app_address = (uint8_t*) APPLICATION_START_ADDR;
last_written_app_address = (uint8_t*) 0;
for(page = APPLICATION_START_PAGE; page < APPLICATION_END_PAGE; page++)
{
flash_erase_page(page);
Expand Down Expand Up @@ -114,6 +114,10 @@ int is_bootloader_disabled()
bool is_firmware_version_newer_or_equal()
{

if (last_written_app_address == 0) {
return false;
}

printf1(TAG_BOOT,"Current firmware version: %u.%u.%u.%u (%02x.%02x.%02x.%02x)\r\n",
current_firmware_version.major, current_firmware_version.minor, current_firmware_version.patch, current_firmware_version.reserved,
current_firmware_version.major, current_firmware_version.minor, current_firmware_version.patch, current_firmware_version.reserved
Expand Down

0 comments on commit b78f2cd

Please sign in to comment.