Store version in the bootloader. Debug code.

pull/238/head
Szczepan Zalega 2019-08-24 08:51:17 +02:00
rodzic 7fddd58704
commit cb13fb65de
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: D9BAE35991DE5B22
5 zmienionych plików z 30 dodań i 1 usunięć

Wyświetl plik

@ -1712,8 +1712,14 @@ static void ctap_state_init()
ctap_reset_rk();
}
#include "version.h"
void ctap_init()
{
printf1(TAG_ERR,"Current firmware version address: %p\r\n", &firmware_version);
printf1(TAG_ERR,"Current firmware version: %d.%d.%d.%d (%02x.%02x.%02x.%02x)\r\n",
firmware_version.major, firmware_version.minor, firmware_version.patch, firmware_version.reserved,
firmware_version.major, firmware_version.minor, firmware_version.patch, firmware_version.reserved
);
crypto_ecc256_init();
authenticator_read_state(&STATE);

Wyświetl plik

@ -1,7 +1,7 @@
#include "version.h"
static const version_t firmware_version __attribute__ ((section (".flag"))) __attribute__ ((__used__)) = {
const version_t firmware_version __attribute__ ((section (".flag"))) __attribute__ ((__used__)) = {
.major = SOLO_VERSION_MAJ,
.minor = SOLO_VERSION_MIN,
.patch = SOLO_VERSION_PATCH,

Wyświetl plik

@ -33,5 +33,7 @@ typedef struct {
} version_t;
bool is_newer(const version_t* const newer, const version_t* const older);
const version_t firmware_version ;
#endif

Wyświetl plik

@ -112,7 +112,20 @@ uint8_t * last_addr;
bool is_firmware_version_newer_or_equal()
{
printf1(TAG_BOOT, "Dump last 8 bytes: %p\r\n", last_addr);
dump_hex1(TAG_BOOT, last_addr, 8);
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
);
dump_hex1(TAG_BOOT, (uint8_t*)(&current_firmware_version) - 16, 32);
volatile version_t * new_version = ((volatile version_t *) last_addr);
printf1(TAG_BOOT,"Uploaded firmware version: %u.%u.%u.%u (%02x.%02x.%02x.%02x)\r\n",
new_version->major, new_version->minor, new_version->patch, new_version->reserved,
new_version->major, new_version->minor, new_version->patch, new_version->reserved
);
dump_hex1(TAG_BOOT, (uint8_t *) last_addr, 8);
dump_hex1(TAG_BOOT, (uint8_t *) NEW_FW_VERSION_ADDR, 8);
dump_hex1(TAG_BOOT, (uint8_t *) NEW_FW_VERSION_ADDR+8, 8);

Wyświetl plik

@ -138,6 +138,14 @@ int main()
printf1(TAG_GEN,"recv'ing hid msg \n");
extern volatile version_t current_firmware_version;
printf1(TAG_BOOT,"Current firmware version address: %p\r\n", &current_firmware_version);
printf1(TAG_BOOT,"Current firmware version: %d.%d.%d.%d (%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
);
dump_hex1(TAG_BOOT, (uint8_t*)(&current_firmware_version) - 16, 32);
while(1)
{