Also flag out some places where code appears unused.
##
VPATH=src
-SOURCES_LIB=stlink-common.c stlink-usb.c #stlink-sg.c
+SOURCES_LIB=stlink-common.c stlink-usb.c stlink-sg.c
OBJS_LIB=$(SOURCES_LIB:.c=.o)
TEST_PROGRAMS=test_usb #test_sg
LDFLAGS=-lusb-1.0 -L. -lstlink
/* simple wrapper around the stlink_flash_write function */
+// TODO - this should be done as just a simple flag to the st-util command line...
+
#include <stdio.h>
#include <stdlib.h>
if (o.devname != NULL) /* stlinkv1 */
{
static const int scsi_verbose = 2;
- sl = stlink_quirk_open(o.devname, scsi_verbose);
+ sl = stlink_v1_open(o.devname, scsi_verbose);
if (sl == NULL) goto on_error;
}
else /* stlinkv2 */
const int X_index = 7;
DevName[X_index] = DevNum + '0';
if (!access(DevName, F_OK)) {
- sl = stlink_quirk_open(DevName, 0);
+ sl = stlink_v1_open(DevName, 0);
ExistDevCount++;
}
} else if (DevNum < 100) {
DevName[X_index] = DevNum / 10 + '0';
DevName[Y_index] = DevNum % 10 + '0';
if (!access(DevName, F_OK)) {
- sl = stlink_quirk_open(DevName, 0);
+ sl = stlink_v1_open(DevName, 0);
ExistDevCount++;
}
}
return 1;
}
} else {
- sl = stlink_quirk_open(state.devicename, state.logging_level);
+ sl = stlink_v1_open(state.devicename, state.logging_level);
}
break;
}
#include "stlink-common.h"
-#if CONFIG_USE_LIBSG
-// sgutils2 (apt-get install libsgutils2-dev)
-#include <scsi/sg_lib.h>
-#include <scsi/sg_pt.h>
#include "stlink-sg.h"
-#endif
// Suspends execution of the calling process for
void _stlink_sg_close(stlink_t *sl) {
if (sl) {
+#if FINISHED_WITH_SG
struct stlink_libsg *slsg = sl->backend_data;
scsi_pt_close_device(slsg->sg_fd);
free(slsg);
+#endif
}
}
//TODO rewrite/cleanup, save the error in sl
+#if FINISHED_WITH_SG
static void stlink_confirm_inq(stlink_t *stl, struct sg_pt_base *ptvp) {
struct stlink_libsg *sl = stl->backend_data;
const int e = sl->do_scsi_pt_err;
"category (%d)\n", cat);
}
}
+#endif
void stlink_q(stlink_t *sl) {
+#if FINISHED_WITH_SG
struct stlink_libsg* sg = sl->backend_data;
DD(sl, "CDB[");
for (int i = 0; i < CDB_SL; i++)
stlink_confirm_inq(sl, ptvp);
// TODO recycle: clear_scsi_pt_obj(struct sg_pt_base * objp);
destruct_scsi_pt_obj(ptvp);
+#endif
}
// TODO thinking, cleanup
-stlink_t* stlink_quirk_open(const char *dev_name, const int verbose) {
+stlink_t* stlink_v1_open(const char *dev_name, const int verbose) {
stlink_t *sl = stlink_open(dev_name, verbose);
if (sl == NULL) {
-#if defined(CONFIG_USE_LIBUSB)
struct stlink_libsg {
int sg_fd;
int do_scsi_pt_err;
reg reg;
};
-#else
- struct stlink_libsg {};
-#endif
- stlink_t* stlink_quirk_open(const char *dev_name, const int verbose);
+ stlink_t* stlink_v1_open(const char *dev_name, const int verbose);
#ifdef __cplusplus
}
if (submit_wait(handle, handle->rep_trans)) return -1;
res = handle->rep_trans->actual_length;
}
+
if ((handle->protocoll == 1) && terminate) {
+ fprintf(stderr, "This is never used....\n");
+ exit(EXIT_FAILURE);
/* Read the SG reply */
unsigned char sg_buf[13];
libusb_fill_bulk_transfer
int i = 0;
memset(cmd, 0, sizeof (sl->c_buf));
if(slu->protocoll == 1) {
+ fprintf(stderr, "This is never used....\n");
cmd[i++] = 'U';
cmd[i++] = 'S';
cmd[i++] = 'B';
printf("libusb_alloc_transfer\n");
goto on_libusb_error;
}
-
+ // TODO - could use the scanning techniq from stm8 code here...
slu->ep_rep = 1 /* ep rep */ | LIBUSB_ENDPOINT_IN;
slu->ep_req = 2 /* ep req */ | LIBUSB_ENDPOINT_OUT;
slu->sg_transfer_idx = 0;
+ // TODO - never used at the moment, always CMD_SIZE
slu->cmd_len = (slu->protocoll == 1)? STLINK_SG_SIZE: STLINK_CMD_SIZE;
/* success */
fprintf(stderr, "Using sg_lib %s : scsi_pt %s\n", sg_lib_version(),
scsi_pt_version());
- stlink_t *sl = stlink_quirk_open(dev_name, scsi_verbose);
+ stlink_t *sl = stlink_v1_open(dev_name, scsi_verbose);
if (sl == NULL)
return EXIT_FAILURE;