From 6f273cadd8660e07d84be4538d9c4c54aabbba57 Mon Sep 17 00:00:00 2001 From: dragonmux Date: Wed, 22 Jun 2022 00:21:38 -0400 Subject: [PATCH] kinetis: Try to be safer about our FCCOB writes so the Flash controller's less likely to get mad --- src/target/kinetis.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/target/kinetis.c b/src/target/kinetis.c index 3c075bd..c38cc98 100644 --- a/src/target/kinetis.c +++ b/src/target/kinetis.c @@ -407,13 +407,15 @@ static bool kinetis_fccob_cmd(target *t, uint8_t cmd, uint32_t addr, const uint3 } while (!(fstat & FTFx_FSTAT_CCIF)); /* Write command to FCCOB */ - addr &= 0xffffff; - addr |= (uint32_t)cmd << 24; + addr &= 0x00ffffffU; + addr |= cmd << 24U; target_mem_write32(t, FTFx_FCCOB0, addr); - if (data) { + if (data && n_items) { target_mem_write32(t, FTFx_FCCOB4, data[0]); if (n_items > 1) target_mem_write32(t, FTFx_FCCOB8, data[1]); + else + target_mem_write32(t, FTFx_FCCOB8, 0); } /* Enable execution by clearing CCIF */