Allow DFU if OTP block is not locked yet (#405)

* Allow DFU if OTP block is not locked yet

* Fixed misra

* Fixed logic
master
robbederks 2019-12-17 22:00:17 +01:00 committed by GitHub
parent ce13938ab3
commit 1c6093559d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -11,3 +11,9 @@ void get_provision_chunk(uint8_t *resp) {
}
}
uint8_t chunk[PROVISION_CHUNK_LEN];
bool is_provisioned(void) {
(void)memcpy(chunk, (uint8_t *)0x1fff79e0, PROVISION_CHUNK_LEN);
return (memcmp(chunk, "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", 0x20) != 0);
}

View File

@ -68,8 +68,8 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired)
#ifdef ALLOW_DEBUG
if (hardwired) {
#else
// no more bootstub on UNO
if (hardwired && hw_type != HW_TYPE_UNO) {
// no more bootstub on UNO once OTP block is flashed
if (hardwired && ((hw_type != HW_TYPE_UNO) || (!is_provisioned()))) {
#endif
puts("-> entering bootloader\n");
enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC;