dfucore.c: Announce no writable bootloader pages when device is read proteced
or bootloader is write protected. Device read protection or write protection on first 4 bootloader pages can only be removed by mass erase. Triggering mass erase with a program running from flash is doomed for failure. User can force bootloader update, at their own risk to brick the device.
This commit is contained in:
parent
b09a522f37
commit
b7235da97f
|
@ -124,12 +124,13 @@ static const char *usb_strings[] = {
|
|||
if_string,
|
||||
};
|
||||
|
||||
static char upd_if_string[] = UPD_IFACE_STRING;
|
||||
static const char *usb_strings_upd[] = {
|
||||
"Black Sphere Technologies",
|
||||
BOARD_IDENT_UPD,
|
||||
serial_no,
|
||||
/* This string is used by ST Microelectronics' DfuSe utility */
|
||||
UPD_IFACE_STRING,
|
||||
upd_if_string,
|
||||
};
|
||||
|
||||
static uint32_t get_le32(const void *vp)
|
||||
|
@ -355,6 +356,12 @@ static char *get_dev_unique_id(char *s)
|
|||
if (fuse_flash_size == 0x40) /* Handle F103x8 as F103xC! */
|
||||
fuse_flash_size = 0x80;
|
||||
max_address = FLASH_BASE + (fuse_flash_size << 10);
|
||||
/* If bootloader pages are write protected or device is read
|
||||
* protected, deny bootloader update.
|
||||
* User can still force updates, at his own risk!
|
||||
*/
|
||||
if (((FLASH_WRPR & 0x03) != 0x03) || (FLASH_OBR & FLASH_OBR_RDPRT_EN))
|
||||
upd_if_string[30] = '0';
|
||||
/* Fetch serial number from chip's unique ID */
|
||||
for(i = 0; i < 8; i++) {
|
||||
s[7-i] = ((unique_id >> (4*i)) & 0xF) + '0';
|
||||
|
|
Loading…
Reference in New Issue