X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Fflash%2Fnor%2Ftcl.c;h=f056e07538eb8db3fb52a9c4ee79e770fa4ef604;hb=31ea7037b3df7e567a9eb34d28947d118c4cada1;hp=95ca8192f79ebb22ca010756bffff8d6d56920cd;hpb=d92773b2057ef163cd062b2408b99bdc3404f905;p=openocd.git diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c index 95ca8192f7..f056e07538 100644 --- a/src/flash/nor/tcl.c +++ b/src/flash/nor/tcl.c @@ -98,10 +98,18 @@ COMMAND_HANDLER(handle_flash_info_command) if (retval != ERROR_OK) return retval; - /* We must query the hardware to avoid printing stale information! */ - retval = p->driver->protect_check(p); - if (retval != ERROR_OK) - return retval; + /* If the driver does not implement protection, we show the default + * state of is_protected array - usually protection state unknown */ + if (p->driver->protect_check == NULL) { + retval = ERROR_FLASH_OPER_UNSUPPORTED; + } else { + /* We must query the hardware to avoid printing stale information! */ + retval = p->driver->protect_check(p); + if (retval != ERROR_OK && retval != ERROR_FLASH_OPER_UNSUPPORTED) + return retval; + } + if (retval == ERROR_FLASH_OPER_UNSUPPORTED) + LOG_WARNING("Flash protection check is not implemented."); command_print(CMD_CTX, "#%d : %s at 0x%8.8" PRIx32 ", size 0x%8.8" PRIx32