Bootloader: get uploaded application version from the 4 last bytes of its firmware

This commit is contained in:
Szczepan Zalega
2019-08-24 08:49:31 +02:00
parent 3a1ea275cc
commit 7fddd58704
3 changed files with 8 additions and 9 deletions

View File

@ -19,7 +19,7 @@
#include "ctap_errors.h"
#include "log.h"
static volatile version_t current_firmware_version __attribute__ ((section (".flag2"))) __attribute__ ((__used__)) = {
volatile version_t current_firmware_version __attribute__ ((section (".flag2"))) __attribute__ ((__used__)) = {
.major = SOLO_VERSION_MAJ,
.minor = SOLO_VERSION_MIN,
.patch = SOLO_VERSION_PATCH,
@ -106,15 +106,13 @@ int is_bootloader_disabled()
uint32_t * auth = (uint32_t *)(AUTH_WORD_ADDR+4);
return *auth == 0;
}
uint8_t * last_addr;
#include "version.h"
bool is_firmware_version_newer_or_equal()
{
printf1(TAG_BOOT,"Current firmware version: %u.%u.%u.%u\r\n",
current_firmware_version.major, current_firmware_version.minor, current_firmware_version.patch, current_firmware_version.reserved);
volatile version_t * new_version = ((volatile version_t *) NEW_FW_VERSION_ADDR);
printf1(TAG_BOOT,"Uploaded firmware version: %u.%u.%u.%u\r\n",
new_version->major, new_version->minor, new_version->patch, new_version->reserved);
volatile version_t * new_version = ((volatile version_t *) last_addr);
dump_hex1(TAG_BOOT, (uint8_t *) NEW_FW_VERSION_ADDR, 8);
dump_hex1(TAG_BOOT, (uint8_t *) NEW_FW_VERSION_ADDR+8, 8);
@ -127,6 +125,7 @@ bool is_firmware_version_newer_or_equal()
printf1(TAG_BOOT,"NEW_FW_VERSION_ADDR: %p\r\n", NEW_FW_VERSION_ADDR);
printf1(TAG_BOOT,"NEW_FW_VERSION_ADDR: %p\r\n", ptr->app_version );
printf1(TAG_BOOT,"NEW_FW_VERSION_ADDR: %p\r\n", new_version );
printf1(TAG_BOOT,"NEW_FW_VERSION_ADDR last_addr: %p\r\n", last_addr );
printf1(TAG_BOOT,"current firm add: %p\r\n", &current_firmware_version );
printf1(TAG_BOOT," ptr->bootloader_data ");
dump_hex1(TAG_BOOT, (uint8_t *) ptr->bootloader_data, 8);
@ -208,8 +207,7 @@ int bootloader_bridge(int klen, uint8_t * keyh)
}
// Do the actual write
flash_write((uint32_t)ptr,req->payload, len);
last_addr = (uint8_t *)ptr + len - 8 + 4;
break;
case BootDone:
// Writing to flash finished. Request code validation.