Don't issue mass erase if BSL password is specified.
This commit is contained in:
parent
5c5fec9acd
commit
d59fb64ac2
|
@ -74,6 +74,7 @@ struct device_breakpoint {
|
||||||
#define DEVICE_FLAG_FORCE_RESET 0x08
|
#define DEVICE_FLAG_FORCE_RESET 0x08
|
||||||
#define DEVICE_FLAG_DO_FWUPDATE 0x10
|
#define DEVICE_FLAG_DO_FWUPDATE 0x10
|
||||||
#define DEVICE_FLAG_SKIP_CLOSE 0x20
|
#define DEVICE_FLAG_SKIP_CLOSE 0x20
|
||||||
|
#define DEVICE_FLAG_BSL_NME 0x40 /* BSL no-mass-erase */
|
||||||
|
|
||||||
struct device_args {
|
struct device_args {
|
||||||
int flags;
|
int flags;
|
||||||
|
|
|
@ -404,12 +404,6 @@ static int flash_bsl_unlock(struct flash_bsl_device *dev,
|
||||||
|
|
||||||
memcpy(rx_password_cmd + 1, password, 32);
|
memcpy(rx_password_cmd + 1, password, 32);
|
||||||
|
|
||||||
/* mass erase - this might wipe Information Memory on some devices */
|
|
||||||
/* (according to the documentation it should not) */
|
|
||||||
if (flash_bsl_erase((device_t)dev, DEVICE_ERASE_MAIN, 0) < 0) {
|
|
||||||
printc_err("flash_bsl_unlock: warning: erase failed\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* send password (which is now erased FLASH) */
|
/* send password (which is now erased FLASH) */
|
||||||
if (dev->long_password) {
|
if (dev->long_password) {
|
||||||
#if defined(FLASH_BSL_VERBOSE)
|
#if defined(FLASH_BSL_VERBOSE)
|
||||||
|
@ -627,6 +621,16 @@ static device_t flash_bsl_open(const struct device_args *args)
|
||||||
|
|
||||||
delay_ms(500);
|
delay_ms(500);
|
||||||
|
|
||||||
|
/* mass erase - this might wipe Information Memory on some devices */
|
||||||
|
/* (according to the documentation it should not) */
|
||||||
|
if (!(args->flags & DEVICE_FLAG_BSL_NME)) {
|
||||||
|
printc("Performing initial mass erase...\n");
|
||||||
|
if (flash_bsl_erase((device_t)dev, DEVICE_ERASE_MAIN, 0) < 0) {
|
||||||
|
printc_err("flash_bsl_unlock: warning: erase failed\n");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* unlock device (erase then send password) */
|
/* unlock device (erase then send password) */
|
||||||
if (flash_bsl_unlock(dev, args->bsl_entry_password) < 0) {
|
if (flash_bsl_unlock(dev, args->bsl_entry_password) < 0) {
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
|
@ -404,8 +404,7 @@ static int rom_bsl_erase(device_t dev_base, device_erase_type_t type,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int unlock_device(struct rom_bsl_device *dev,
|
static int mass_erase(struct rom_bsl_device *dev)
|
||||||
const uint8_t *password)
|
|
||||||
{
|
{
|
||||||
printc_dbg("Performing mass erase...\n");
|
printc_dbg("Performing mass erase...\n");
|
||||||
|
|
||||||
|
@ -414,6 +413,12 @@ static int unlock_device(struct rom_bsl_device *dev,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int unlock_device(struct rom_bsl_device *dev,
|
||||||
|
const uint8_t *password)
|
||||||
|
{
|
||||||
printc_dbg("Sending password...\n");
|
printc_dbg("Sending password...\n");
|
||||||
|
|
||||||
if (rom_bsl_xfer(dev, CMD_RX_PASSWORD, 0, password, 32) < 0) {
|
if (rom_bsl_xfer(dev, CMD_RX_PASSWORD, 0, password, 32) < 0) {
|
||||||
|
@ -481,10 +486,12 @@ static device_t rom_bsl_open(const struct device_args *args)
|
||||||
dev->reply_buf[15],
|
dev->reply_buf[15],
|
||||||
dev->reply_buf[16]);
|
dev->reply_buf[16]);
|
||||||
|
|
||||||
if (unlock_device(dev, args->bsl_entry_password) < 0) {
|
if (!(args->flags & DEVICE_FLAG_BSL_NME) &&
|
||||||
printc_err("rom_bsl: failed to unlock\n");
|
mass_erase(dev) < 0)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
if (unlock_device(dev, args->bsl_entry_password) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
|
||||||
|
|
||||||
return (device_t)dev;
|
return (device_t)dev;
|
||||||
|
|
||||||
|
|
|
@ -352,6 +352,7 @@ static int parse_cmdline_args(int argc, char **argv,
|
||||||
fprintf(stderr, "invalid BSL password\n");
|
fprintf(stderr, "invalid BSL password\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
args->devarg.flags |= DEVICE_FLAG_BSL_NME;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LOPT_BSL_ENTRY_SEQUENCE:
|
case LOPT_BSL_ENTRY_SEQUENCE:
|
||||||
|
|
Loading…
Reference in New Issue