Merge pull request #213 from gsmcmullin/k22f_security_hack
K22F security hack
This commit is contained in:
commit
2f5295ba14
|
@ -176,6 +176,7 @@ void platform_init(void)
|
||||||
|
|
||||||
void platform_srst_set_val(bool assert)
|
void platform_srst_set_val(bool assert)
|
||||||
{
|
{
|
||||||
|
gpio_set_val(TMS_PORT, TMS_PIN, 1);
|
||||||
if ((platform_hwversion() == 0) ||
|
if ((platform_hwversion() == 0) ||
|
||||||
(platform_hwversion() >= 3)) {
|
(platform_hwversion() >= 3)) {
|
||||||
gpio_set_val(SRST_PORT, SRST_PIN, assert);
|
gpio_set_val(SRST_PORT, SRST_PIN, assert);
|
||||||
|
|
|
@ -82,6 +82,7 @@ static bool kinetis_cmd_unsafe(target *t, int argc, char *argv[])
|
||||||
static int kl_gen_flash_erase(struct target_flash *f, target_addr addr, size_t len);
|
static int kl_gen_flash_erase(struct target_flash *f, target_addr addr, size_t len);
|
||||||
static int kl_gen_flash_write(struct target_flash *f,
|
static int kl_gen_flash_write(struct target_flash *f,
|
||||||
target_addr dest, const void *src, size_t len);
|
target_addr dest, const void *src, size_t len);
|
||||||
|
static int kl_gen_flash_done(struct target_flash *f);
|
||||||
|
|
||||||
static void kl_gen_add_flash(target *t,
|
static void kl_gen_add_flash(target *t,
|
||||||
uint32_t addr, size_t length, size_t erasesize)
|
uint32_t addr, size_t length, size_t erasesize)
|
||||||
|
@ -92,6 +93,7 @@ static void kl_gen_add_flash(target *t,
|
||||||
f->blocksize = erasesize;
|
f->blocksize = erasesize;
|
||||||
f->erase = kl_gen_flash_erase;
|
f->erase = kl_gen_flash_erase;
|
||||||
f->write = kl_gen_flash_write;
|
f->write = kl_gen_flash_write;
|
||||||
|
f->done = kl_gen_flash_done;
|
||||||
f->align = 4;
|
f->align = 4;
|
||||||
f->erased = 0xff;
|
f->erased = 0xff;
|
||||||
target_add_flash(t, f);
|
target_add_flash(t, f);
|
||||||
|
@ -233,6 +235,24 @@ static int kl_gen_flash_write(struct target_flash *f,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int kl_gen_flash_done(struct target_flash *f)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (unsafe_enabled)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (target_mem_read8(f->t, FLASH_SECURITY_BYTE_ADDRESS) ==
|
||||||
|
FLASH_SECURITY_BYTE_UNSECURED)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
uint32_t val = target_mem_read32(f->t, FLASH_SECURITY_BYTE_ADDRESS);
|
||||||
|
val = (val & 0xffffff00) | FLASH_SECURITY_BYTE_UNSECURED;
|
||||||
|
kl_gen_command(f->t, FTFA_CMD_PROGRAM_LONGWORD,
|
||||||
|
FLASH_SECURITY_BYTE_ADDRESS, (uint8_t*)&val);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*** Kinetis recovery mode using the MDM-AP ***/
|
/*** Kinetis recovery mode using the MDM-AP ***/
|
||||||
|
|
||||||
/* Kinetis security bits are stored in regular flash, so it is possible
|
/* Kinetis security bits are stored in regular flash, so it is possible
|
||||||
|
|
Loading…
Reference in New Issue