Closed DanielO closed 1 year ago
cmd_verify and listDevices have the same problem. Patch:
diff --git a/UsbdmTcl_DLL/src/UsbdmTclInterpreterImp.cpp b/UsbdmTcl_DLL/src/UsbdmTclInterpreterImp.cpp
index 59985c7f..518132f5 100755
--- a/UsbdmTcl_DLL/src/UsbdmTclInterpreterImp.cpp
+++ b/UsbdmTcl_DLL/src/UsbdmTclInterpreterImp.cpp
@@ -2767,7 +2767,11 @@ static int cmd_setDevice(ClientData, Tcl_Interp *interp, int argc, Tcl_Obj *cons
try {
if (strcmp(deviceName, "-list") == 0) {
- return listDevices();
+ if (deviceInterface == 0) {
+ PRINT("Set target first\n");
+ return TCL_ERROR;
+ }
+ return listDevices();
}
PRINT("Changing interface options\n");
USBDM_ExtendedOptions_t &bdmOptions(bdmInterface->getBdmOptions());
@@ -2846,6 +2850,10 @@ static int cmd_program(ClientData, Tcl_Interp *interp, int argc, Tcl_Obj *const
PRINT("Load file first\n");
return TCL_ERROR;
}
+ if (deviceInterface == 0) {
+ PRINT("Set device first\n");
+ return TCL_ERROR;
+ }
UsbdmTclInterperPtr ti = UsbdmTclInterpreterImp::getInteractiveInterpreter();
log.print("interp = %p\n", interp);
log.print("getInteractiveUsbdmTclInterpreter = %p\n", UsbdmTclInterpreterImp::getInteractiveInterpreter().get());
@@ -2895,6 +2903,10 @@ static int cmd_verify(ClientData, Tcl_Interp *interp, int argc, Tcl_Obj *const *
PRINT("Load file first\n");
return TCL_ERROR;
}
+ if (deviceInterface == 0) {
+ PRINT("Set device first\n");
+ return TCL_ERROR;
+ }
UsbdmTclInterperPtr ti = UsbdmTclInterpreterImp::getInteractiveInterpreter();
log.print("interp = %p\n", interp);
log.print("getInteractiveUsbdmTclInterpreter = %p\n", UsbdmTclInterpreterImp::getInteractiveInterpreter().get());
There are a number of other related problems. In particular the program and verify command release the interfaces incorrectly. This has been fixed in the last lot of changes. I do not recommend programming using UsbdmScript as it is less reliable than using the programmer applications in command line mode. This function was really intended for testing.
OK fair enough.
The following crashes due to derefing deviceInterface which is nullptr in cmd_program:
Adding this simple check after the 'flashImage == 0' test fixes it for me: