]> git.sur5r.net Git - openocd/commitdiff
flash/nor/kinetis: prevent segfaulting with an HLA
authorPaul Fertser <fercerpav@gmail.com>
Sun, 15 Jun 2014 14:33:30 +0000 (18:33 +0400)
committerSpencer Oliver <spen@spen-soft.co.uk>
Wed, 18 Jun 2014 20:32:06 +0000 (20:32 +0000)
HLAs do not provide direct DAP access, so the best we can do about it
is skipping it.

Change-Id: I877ef8fd2d86e40e7442a637cdba182cfd60e05a
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2173
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
src/flash/nor/kinetis.c

index 42677a385c6482bf45d71f4c6c3443cdfab75acd..6f47461e549ef3fff357920bc54f12901fb2f7bd 100644 (file)
@@ -298,6 +298,11 @@ COMMAND_HANDLER(kinetis_mdm_mass_erase)
        struct cortex_m_common *cortex_m = target_to_cm(target);
        struct adiv5_dap *dap = cortex_m->armv7m.arm.dap;
 
+       if (!dap) {
+               LOG_ERROR("Cannot perform mass erase with a high-level adapter");
+               return ERROR_FAIL;
+       }
+
        int retval;
        const uint8_t original_ap = dap->ap_current;
 
@@ -379,6 +384,11 @@ COMMAND_HANDLER(kinetis_check_flash_security_status)
        struct cortex_m_common *cortex_m = target_to_cm(target);
        struct adiv5_dap *dap = cortex_m->armv7m.arm.dap;
 
+       if (!dap) {
+               LOG_WARNING("Cannot check flash security status with a high-level adapter");
+               return ERROR_OK;
+       }
+
        uint32_t val;
        int retval;
        const uint8_t origninal_ap = dap->ap_current;