Successfully locate and open stlinkv1 by usb
[fw/stlink] / src / test_sg.c
index 137eca4cf1a34e894ba60be8a75b32340c3ec7e2..742ba445387d72bfaed11aab7be2209027a7add8 100644 (file)
@@ -6,13 +6,10 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <scsi/sg_lib.h>
-#include <scsi/sg_pt.h>
 #include "stlink-common.h"
 
 int main(int argc, char *argv[]) {
        // set scpi lib debug level: 0 for no debug info, 10 for lots
-       const int scsi_verbose = 2;
        char *dev_name;
 
        switch (argc) {
@@ -32,14 +29,11 @@ int main(int argc, char *argv[]) {
                dev_name = argv[1];
                break;
        default:
+        fprintf(stderr, "bzzt\n");
                return EXIT_FAILURE;
        }
 
-       fputs("*** stlink access test ***\n", stderr);
-       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, 99);
        if (sl == NULL)
                return EXIT_FAILURE;
 
@@ -174,7 +168,7 @@ int main(int argc, char *argv[]) {
        stlink_force_debug(sl);
        stlink_status(sl);
 #endif
-#if 1 /* read the system bootloader */
+#if 0 /* read the system bootloader */
        fputs("\n++++++++++ reading bootloader ++++++++++++++++\n\n", stderr);
        stlink_fread(sl, "/tmp/barfoo", sl->sys_base, sl->sys_size);
 #endif
@@ -200,6 +194,7 @@ int main(int argc, char *argv[]) {
        stlink_run_at(sl, sl->sram_base);
 #endif
 
+#if 0
        stlink_run(sl);
        stlink_status(sl);
        //----------------------------------------------------------------------
@@ -207,7 +202,8 @@ int main(int argc, char *argv[]) {
        stlink_exit_debug_mode(sl);
        stlink_current_mode(sl);
        stlink_close(sl);
+#endif
 
        //fflush(stderr); fflush(stdout);
        return EXIT_SUCCESS;
-}
\ No newline at end of file
+}