Bootloader: get uploaded application version from the 4 last bytes of its firmware
This commit is contained in:
parent
3a1ea275cc
commit
7fddd58704
@ -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", ¤t_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.
|
||||
|
@ -10,6 +10,7 @@ SRC += $(DRIVER_LIBS) $(USB_LIB)
|
||||
SRC += ../../fido2/apdu.c ../../fido2/util.c ../../fido2/u2f.c ../../fido2/test_power.c
|
||||
SRC += ../../fido2/stubs.c ../../fido2/log.c ../../fido2/ctaphid.c ../../fido2/ctap.c
|
||||
SRC += ../../fido2/ctap_parse.c ../../fido2/main.c
|
||||
SRC += ../../fido2/version.c
|
||||
SRC += ../../fido2/extensions/extensions.c ../../fido2/extensions/solo.c
|
||||
SRC += ../../fido2/extensions/wallet.c
|
||||
|
||||
|
@ -46,7 +46,7 @@
|
||||
#define LAST_ADDR (APPLICATION_END_ADDR-2048 + 8)
|
||||
#define NEW_FW_VERSION_ADDR (AUTH_WORD_ADDR-8)
|
||||
#define BOOT_VERSION_PAGE (APPLICATION_END_PAGE)
|
||||
#define BOOT_VERSION_ADDR (0x08000000 + BOOT_VERSION_PAGE*FLASH_PAGE_SIZE)
|
||||
#define BOOT_VERSION_ADDR (0x08000000 + BOOT_VERSION_PAGE*FLASH_PAGE_SIZE + 8)
|
||||
#define LAST_PAGE (APPLICATION_END_PAGE-1)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user