Compare commits

...

3 Commits

Author SHA1 Message Date
Conor Patrick
20fc5313cf remove unused code in bootloader 2020-02-13 17:10:30 -05:00
Conor Patrick
e45e5ed157 add temporary command to force flash locking 2020-02-13 16:58:53 -05:00
Conor Patrick
9f7866ce36 keep initialize last_addr and reject if it doesnt change 2020-02-13 15:43:53 -05:00
4 changed files with 35 additions and 2 deletions

View File

@ -542,6 +542,9 @@ extern void _check_ret(CborError ret, int line, const char * filename);
uint8_t ctaphid_custom_command(int len, CTAP_RESPONSE * ctap_resp, CTAPHID_WRITE_BUFFER * wb); uint8_t ctaphid_custom_command(int len, CTAP_RESPONSE * ctap_resp, CTAPHID_WRITE_BUFFER * wb);
extern void solo_lock_if_not_already();
uint8_t ctaphid_handle_packet(uint8_t * pkt_raw) uint8_t ctaphid_handle_packet(uint8_t * pkt_raw)
{ {
uint8_t cmd = 0; uint8_t cmd = 0;
@ -762,6 +765,16 @@ uint8_t ctaphid_custom_command(int len, CTAP_RESPONSE * ctap_resp, CTAPHID_WRITE
return 1; return 1;
break; break;
// Remove on next release
#if !defined(IS_BOOTLOADER) && defined(SOLO)
case 0x99:
solo_lock_if_not_already();
wb->bcnt = 0;
ctaphid_write(wb, NULL, 0);
return 1;
break;
#endif
#if !defined(IS_BOOTLOADER) && (defined(SOLO_EXPERIMENTAL)) #if !defined(IS_BOOTLOADER) && (defined(SOLO_EXPERIMENTAL))
case CTAPHID_LOADKEY: case CTAPHID_LOADKEY:
/** /**

View File

@ -50,7 +50,7 @@ typedef struct {
uint8_t payload[255 - 10]; uint8_t payload[255 - 10];
} __attribute__((packed)) BootloaderReq; } __attribute__((packed)) BootloaderReq;
uint8_t * last_written_app_address; uint8_t * last_written_app_address = 0;
/** /**
* Erase all application pages. **APPLICATION_END_PAGE excluded**. * Erase all application pages. **APPLICATION_END_PAGE excluded**.
@ -58,7 +58,7 @@ uint8_t * last_written_app_address;
static void erase_application() static void erase_application()
{ {
int page; 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++) for(page = APPLICATION_START_PAGE; page < APPLICATION_END_PAGE; page++)
{ {
flash_erase_page(page); flash_erase_page(page);
@ -114,6 +114,10 @@ int is_bootloader_disabled()
bool is_firmware_version_newer_or_equal() 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", 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,
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

View File

@ -199,6 +199,20 @@ int solo_is_locked(){
return tag == ATTESTATION_CONFIGURED_TAG && (device_settings & SOLO_FLAG_LOCKED) != 0; return tag == ATTESTATION_CONFIGURED_TAG && (device_settings & SOLO_FLAG_LOCKED) != 0;
} }
// Locks solo flash from debugging. Locks on next reboot.
// This should be removed in next Solo release.
void solo_lock_if_not_already() {
uint8_t buf[2048];
memmove(buf, (uint8_t*)ATTESTATION_PAGE_ADDR, 2048);
((flash_attestation_page *)buf)->device_settings |= SOLO_FLAG_LOCKED;
flash_erase_page(ATTESTATION_PAGE);
flash_write(ATTESTATION_PAGE_ADDR, buf, 2048);
}
/** device_migrate /** device_migrate
* Depending on version of device, migrates: * Depending on version of device, migrates:
* * Moves attestation certificate to data segment. * * Moves attestation certificate to data segment.

View File

@ -146,12 +146,14 @@ void device_set_clock_rate(DEVICE_CLOCK_RATE param)
case DEVICE_LOW_POWER_IDLE: case DEVICE_LOW_POWER_IDLE:
SET_CLOCK_RATE0(); SET_CLOCK_RATE0();
break; break;
#if !defined(IS_BOOTLOADER)
case DEVICE_LOW_POWER_FAST: case DEVICE_LOW_POWER_FAST:
SET_CLOCK_RATE1(); SET_CLOCK_RATE1();
break; break;
case DEVICE_FAST: case DEVICE_FAST:
SET_CLOCK_RATE2(); SET_CLOCK_RATE2();
break; break;
#endif
} }
} }