diff --git a/board/provision.h b/board/provision.h index 9091322..0b09d8f 100644 --- a/board/provision.h +++ b/board/provision.h @@ -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); +} + diff --git a/board/spi_flasher.h b/board/spi_flasher.h index fbdbab8..b9f38dd 100644 --- a/board/spi_flasher.h +++ b/board/spi_flasher.h @@ -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;