Fix utility Makefiles to output Windows binaries using mingw
authorMichael McMaster <michael@codesrc.com>
Mon, 14 Jul 2014 04:45:05 +0000 (14:45 +1000)
committerMichael McMaster <michael@codesrc.com>
Mon, 14 Jul 2014 04:45:05 +0000 (14:45 +1000)
14 files changed:
software/SCSI2SD/v3/SCSI2SD.cydsn/Generated_Source/PSoC5/cybootloader.c
software/SCSI2SD/v3/SCSI2SD.cydsn/SCSI2SD.cyfit
software/bootloaderhost/Makefile
software/bootloaderhost/Makefile.mingw [deleted file]
software/bootloaderhost/build.sh [new file with mode: 0755]
software/scsi2sd-config/Makefile
software/scsi2sd-config/Makefile.mingw [deleted file]
software/scsi2sd-config/build.sh [new file with mode: 0755]
software/scsi2sd-config/scsi2sd-config.cc
software/scsi2sd-debug/Makefile
software/scsi2sd-debug/Makefile.mingw [deleted file]
software/scsi2sd-debug/build.sh [new file with mode: 0755]
software/scsi2sd-debug/main.c [deleted file]
software/scsi2sd-debug/scsi2sd-debug.cc [new file with mode: 0644]

index 860d0c7..32543d5 100644 (file)
@@ -315,7 +315,7 @@ const uint8 cy_bootloader[] = {
     0xFFu, 0xF7u, 0xD4u, 0xFDu, 0x21u, 0x78u, 0x01u, 0xF0u,\r
     0xC0u, 0x02u, 0x40u, 0x2Au, 0x00u, 0xD0u, 0x18u, 0xB1u,\r
     0x00u, 0x20u, 0x20u, 0x70u, 0xFFu, 0xF7u, 0x0Cu, 0xFEu,\r
-    0x05u, 0x20u, 0xFFu, 0xF7u, 0x09u, 0xFEu, 0x80u, 0x20u,\r
+    0x14u, 0x20u, 0xFFu, 0xF7u, 0x09u, 0xFEu, 0x80u, 0x20u,\r
     0x20u, 0x70u, 0x00u, 0xF0u, 0xE7u, 0xF8u, 0x48u, 0xB0u,\r
     0x10u, 0xBDu, 0x00u, 0xBFu, 0x0Cu, 0xC1u, 0xFFu, 0x1Fu,\r
     0xFAu, 0x46u, 0x00u, 0x40u, 0x08u, 0xB5u, 0x0Au, 0x4Bu,\r
@@ -1053,7 +1053,7 @@ const uint8 cy_bootloader[] = {
     0x10u, 0xBDu, 0x82u, 0x18u, 0x03u, 0x46u, 0x93u, 0x42u,\r
     0x02u, 0xD0u, 0x03u, 0xF8u, 0x01u, 0x1Bu, 0xFAu, 0xE7u,\r
     0x70u, 0x47u, 0x00u, 0x00u, 0x80u, 0x22u, 0x00u, 0x00u,\r
-    0x4Fu, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u,\r
+    0x40u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u,\r
     0x10u, 0x51u, 0x00u, 0x40u, 0x20u, 0x00u, 0x50u, 0x51u,\r
     0x00u, 0x40u, 0x10u, 0x00u, 0xC0u, 0x51u, 0x00u, 0x40u,\r
     0x10u, 0x00u, 0x00u, 0x00u, 0x01u, 0x40u, 0x00u, 0x10u,\r
index 218cfea..439ad96 100644 (file)
Binary files a/software/SCSI2SD/v3/SCSI2SD.cydsn/SCSI2SD.cyfit and b/software/SCSI2SD/v3/SCSI2SD.cydsn/SCSI2SD.cyfit differ
index 29f24bb..d12da46 100644 (file)
@@ -4,13 +4,29 @@ CPPFLAGS = -I cybootloaderutils -I hidapi/hidapi
 CFLAGS += -Wall -Wno-pointer-sign -O2
 CXXFLAGS += -Wall -std=c++11 -O2
 
-UNAME_S := $(shell uname -s)
-ifeq ($(UNAME_S),Linux)
+TARGET ?= $(shell uname -s)
+ifeq ($(TARGET),Win32)
+       VPATH += hidapi/windows
+       LDFLAGS += -mconsole -mwindows -lsetupapi
+       BUILD = build/windows/32bit
+       CC=i686-w64-mingw32-gcc
+       CXX=i686-w64-mingw32-g++
+       EXE=.exe
+endif
+ifeq ($(TARGET),Win64)
+       VPATH += hidapi/windows
+       LDFLAGS += -mconsole -mwindows -lsetupapi
+       BUILD = build/windows/64bit
+       CC=x86_64-w64-mingw32-gcc
+       CXX=x86_64-w64-mingw32-g++
+       EXE=.exe
+endif
+ifeq ($(TARGET),Linux)
        VPATH += hidapi/linux
        LDFLAGS += -ludev
-       BUILD=build/linux
+       BUILD = build/linux
 endif
-ifeq ($(UNAME_S),Darwin)
+ifeq ($(TARGET),Darwin)
        # Should match OSX
        VPATH += hidapi/mac
        LDFLAGS += -framework IOKit -framework CoreFoundation
@@ -22,7 +38,7 @@ ifeq ($(UNAME_S),Darwin)
        BUILD=build/mac
 endif
 
-all:  $(BUILD)/bootloaderhost
+all:  $(BUILD)/bootloaderhost$(EXE)
 
 CYAPI = \
        $(BUILD)/cybtldr_api2.o \
@@ -50,10 +66,10 @@ $(BUILD)/%.o: %.cc
        mkdir -p $(dir $@)
        $(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -c -o $@
 
-$(BUILD)/bootloaderhost: $(OBJ)
+$(BUILD)/bootloaderhost$(EXE): $(OBJ)
        mkdir -p $(dir $@)
        $(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@
 
 clean:
-       rm $(BUILD)/bootloaderhost $(OBJ)
+       rm $(BUILD)/bootloaderhost$(EXE) $(OBJ)
 
diff --git a/software/bootloaderhost/Makefile.mingw b/software/bootloaderhost/Makefile.mingw
deleted file mode 100644 (file)
index 820212f..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-all:  build/windows/32bit/bootloaderhost.exe build/windows/64bit/bootloaderhost.exe
-
-CYAPI = \
-       cybootloaderutils/cybtldr_api2.c \
-       cybootloaderutils/cybtldr_api.c \
-       cybootloaderutils/cybtldr_command.c \
-       cybootloaderutils/cybtldr_parse.c \
-
-CFLAGS += -Wall -Wno-pointer-sign
-LDFLAGS=-mconsole -mwindows -lsetupapi
-
-HID_C = hidapi/windows/hid.c
-
-
-build/windows/32bit/bootloaderhost.exe: main.c $(HID_C) $(CYAPI)
-       mkdir -p $(dir $@)
-       i686-w64-mingw32-gcc $(CFLAGS) -I cybootloaderutils -I hidapi/hidapi $^ $(LDFLAGS) -o $@
-
-build/windows/64bit/bootloaderhost.exe: main.c $(HID_C) $(CYAPI)
-       mkdir -p $(dir $@)
-       x86_64-w64-mingw32-gcc $(CFLAGS) -I cybootloaderutils -I hidapi/hidapi $^ $(LDFLAGS) -o $@
-
-clean:
-       rm -r build/windows
-
diff --git a/software/bootloaderhost/build.sh b/software/bootloaderhost/build.sh
new file mode 100755 (executable)
index 0000000..a7a8f7f
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+make && \
+       make TARGET=Win32 &&
+       make TARGET=Win64
+
index 86208f4..0b75eec 100644 (file)
@@ -4,13 +4,29 @@ CFLAGS += -Wall -Wno-pointer-sign -O2
 CXXFLAGS += -Wall -std=c++11 -O2
 VPATH += ../bootloaderhost
 
-UNAME_S := $(shell uname -s)
-ifeq ($(UNAME_S),Linux)
-       VPATH += ../bootloaderhost/hidapi/linux
+TARGET ?= $(shell uname -s)
+ifeq ($(TARGET),Win32)
+       VPATH += hidapi/windows
+       LDFLAGS += -mconsole -mwindows -lsetupapi -lws2_32
+       BUILD = build/windows/32bit
+       CC=i686-w64-mingw32-gcc
+       CXX=i686-w64-mingw32-g++
+       EXE=.exe
+endif
+ifeq ($(TARGET),Win64)
+       VPATH += hidapi/windows
+       LDFLAGS += -mconsole -mwindows -lsetupapi -lws2_32
+       BUILD = build/windows/64bit
+       CC=x86_64-w64-mingw32-gcc
+       CXX=x86_64-w64-mingw32-g++
+       EXE=.exe
+endif
+ifeq ($(TARGET),Linux)
+       VPATH += hidapi/linux
        LDFLAGS += -ludev
-       BUILD=build/linux
+       BUILD = build/linux
 endif
-ifeq ($(UNAME_S),Darwin)
+ifeq ($(TARGET),Darwin)
        # Should match OSX
        VPATH += ../bootloaderhost/hidapi/mac
        LDFLAGS += -framework IOKit -framework CoreFoundation
@@ -22,7 +38,7 @@ ifeq ($(UNAME_S),Darwin)
        BUILD=build/mac
 endif
 
-all:  $(BUILD)/scsi2sd-config
+all:  $(BUILD)/scsi2sd-config$(EXE)
 
 HIDAPI = \
        $(BUILD)/hid.o \
@@ -40,9 +56,9 @@ $(BUILD)/%.o: %.cc
        mkdir -p $(dir $@)
        $(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -c -o $@
 
-$(BUILD)/scsi2sd-config: $(OBJ)
+$(BUILD)/scsi2sd-config$(EXE): $(OBJ)
        mkdir -p $(dir $@)
        $(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@
 
 clean:
-       rm $(BUILD)/scsi2sd-config $(OBJ)
+       rm $(BUILD)/scsi2sd-config$(EXE) $(OBJ)
diff --git a/software/scsi2sd-config/Makefile.mingw b/software/scsi2sd-config/Makefile.mingw
deleted file mode 100644 (file)
index ecc9a9b..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-all:  build/windows/32bit/scsi2sd-config.exe build/windows/64bit/scsi2sd-config.exe
-
-CFLAGS += -Wall
-LDFLAGS=-mconsole -mwindows -lsetupapi -lws2_32
-
-HID_C = ../bootloaderhost/hidapi/windows/hid.c
-
-
-build/windows/32bit/scsi2sd-config.exe: main.c $(HID_C)
-       mkdir -p $(dir $@)
-       i686-w64-mingw32-gcc $(CFLAGS) -I ../bootloaderhost/hidapi/hidapi $^ $(LDFLAGS) -o $@
-
-build/windows/64bit/scsi2sd-config.exe: main.c $(HID_C)
-       mkdir -p $(dir $@)
-       x86_64-w64-mingw32-gcc $(CFLAGS) -I ../bootloaderhost/hidapi/hidapi $^ $(LDFLAGS) -o $@
-
-clean:
-       rm -r build/windows
-
diff --git a/software/scsi2sd-config/build.sh b/software/scsi2sd-config/build.sh
new file mode 100755 (executable)
index 0000000..a7a8f7f
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+make && \
+       make TARGET=Win32 &&
+       make TARGET=Win64
+
index dde17b8..6e2d167 100644 (file)
 #include <memory>
 #include <sstream>
 
-#include <getopt.h>
+// Request extended stdio format macros.
+#define __STDC_FORMAT_MACROS
 #include <inttypes.h>
+
+#include <getopt.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -31,7 +34,7 @@
 #include <unistd.h>
 
 // htonl/ntohl includes.
-#ifdef WIN32
+#ifdef _WIN32
 #include <winsock2.h>
 #else
 #include <arpa/inet.h>
index d286620..c89406e 100644 (file)
@@ -1,24 +1,64 @@
-all: build/scsi2sd-debug
 
-CFLAGS += -Wall
+CPPFLAGS = -I ../bootloaderhost/hidapi/hidapi -I ../bootloaderhost
+CFLAGS += -Wall -Wno-pointer-sign -O2
+CXXFLAGS += -Wall -std=c++11 -O2
+VPATH += ../bootloaderhost
 
-UNAME_S := $(shell uname -s)
-ifeq ($(UNAME_S),Linux)
-       HID_C = ../bootloaderhost/hidapi/linux/hid.c
+TARGET ?= $(shell uname -s)
+ifeq ($(TARGET),Win32)
+       VPATH += hidapi/windows
+       LDFLAGS += -mconsole -mwindows -lsetupapi -lws2_32
+       BUILD = build/windows/32bit
+       CC=i686-w64-mingw32-gcc
+       CXX=i686-w64-mingw32-g++
+       EXE=.exe
+endif
+ifeq ($(TARGET),Win64)
+       VPATH += hidapi/windows
+       LDFLAGS += -mconsole -mwindows -lsetupapi -lws2_32
+       BUILD = build/windows/64bit
+       CC=x86_64-w64-mingw32-gcc
+       CXX=x86_64-w64-mingw32-g++
+       EXE=.exe
+endif
+ifeq ($(TARGET),Linux)
+       VPATH += hidapi/linux
        LDFLAGS += -ludev
+       BUILD = build/linux
 endif
-ifeq ($(UNAME_S),Darwin)
+ifeq ($(TARGET),Darwin)
        # Should match OSX
-       HID_C = ../bootloaderhost/hidapi/mac/hid.c
+       VPATH += ../bootloaderhost/hidapi/mac
        LDFLAGS += -framework IOKit -framework CoreFoundation
-       CFLAGS += -mmacosx-version-min=10.5 -arch x86_64 -arch i386 -arch ppc -isysroot /Xcode3.1.4/SDKs/MacOSX10.5.sdk
+       CPPFLAGS += -isysroot /Xcode3.1.4/SDKs/MacOSX10.5.sdk
+       CFLAGS += -mmacosx-version-min=10.5 -arch x86_64 -arch i386 -arch ppc
+       CXXFLAGS += -mmacosx-version-min=10.5 -arch x86_64 -arch i386 -arch ppc
        CC=/Xcode3.1.4/usr/bin/gcc
+       CXX=/Xcode3.1.4/usr/bin/g++
+       BUILD=build/mac
 endif
 
+all:  $(BUILD)/scsi2sd-debug$(EXE)
+
+HIDAPI = \
+       $(BUILD)/hid.o \
+
+OBJ = \
+       $(HIDAPI) \
+       $(BUILD)/scsi2sd-debug.o \
+       $(BUILD)/SCSI2SD_HID.o \
+
+$(BUILD)/%.o: %.c
+       mkdir -p $(dir $@)
+       $(CC) $(CPPFLAGS) $(CFLAGS) $^ -c -o $@
+
+$(BUILD)/%.o: %.cc
+       mkdir -p $(dir $@)
+       $(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -c -o $@
 
-build/scsi2sd-debug: main.c $(HID_C) $(CYAPI)
+$(BUILD)/scsi2sd-debug$(EXE): $(OBJ)
        mkdir -p $(dir $@)
-       $(CC) $(CFLAGS) -I ../bootloaderhost/hidapi/hidapi $^ $(LDFLAGS) -o $@
+       $(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@
 
 clean:
-       rm build/scsi2sd-debug
+       rm $(BUILD)/scsi2sd-debug$(EXE) $(OBJ)
diff --git a/software/scsi2sd-debug/Makefile.mingw b/software/scsi2sd-debug/Makefile.mingw
deleted file mode 100644 (file)
index 4fae0f6..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-all:  build/windows/32bit/scsi2sd-debug.exe build/windows/64bit/scsi2sd-debug.exe
-
-CFLAGS += -Wall
-LDFLAGS=-mconsole -mwindows -lsetupapi -lws2_32
-
-HID_C = ../bootloaderhost/hidapi/windows/hid.c
-
-
-build/windows/32bit/scsi2sd-debug.exe: main.c $(HID_C)
-       mkdir -p $(dir $@)
-       i686-w64-mingw32-gcc $(CFLAGS) -I ../bootloaderhost/hidapi/hidapi $^ $(LDFLAGS) -o $@
-
-build/windows/64bit/scsi2sd-debug.exe: main.c $(HID_C)
-       mkdir -p $(dir $@)
-       x86_64-w64-mingw32-gcc $(CFLAGS) -I ../bootloaderhost/hidapi/hidapi $^ $(LDFLAGS) -o $@
-
-clean:
-       rm -r build/windows
-
diff --git a/software/scsi2sd-debug/build.sh b/software/scsi2sd-debug/build.sh
new file mode 100755 (executable)
index 0000000..a7a8f7f
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+make && \
+       make TARGET=Win32 &&
+       make TARGET=Win64
+
diff --git a/software/scsi2sd-debug/main.c b/software/scsi2sd-debug/main.c
deleted file mode 100644 (file)
index cf233d7..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-//     Copyright (C) 2014 Michael McMaster <michael@codesrc.com>
-//
-//     This file is part of SCSI2SD.
-//
-//     SCSI2SD is free software: you can redistribute it and/or modify
-//     it under the terms of the GNU General Public License as published by
-//     the Free Software Foundation, either version 3 of the License, or
-//     (at your option) any later version.
-//
-//     SCSI2SD is distributed in the hope that it will be useful,
-//     but WITHOUT ANY WARRANTY; without even the implied warranty of
-//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//     GNU General Public License for more details.
-//
-//     You should have received a copy of the GNU General Public License
-//     along with SCSI2SD.  If not, see <http://www.gnu.org/licenses/>.
-
-#include <getopt.h>
-#include <inttypes.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-// htonl/ntohl includes.
-#ifdef WIN32
-#include <winsock2.h>
-#else
-#include <arpa/inet.h>
-#endif
-
-#include "hidapi.h"
-
-#define MIN(a,b) (a < b ? a : b)
-
-FILE* logfile = NULL;
-
-static void readConfig(hid_device* handle)
-{
-       // First byte is the report ID (0)
-       unsigned char buf[65];
-       memset(buf, 0, sizeof(buf));
-       int result = hid_read(handle, buf, sizeof(buf));
-
-       if (result < 0)
-       {
-               fprintf(stderr, "USB HID Read Failure: %ls\n", hid_error(handle));
-       }
-       int i;
-       for (i = 0; i < 32; ++i)
-       {
-               fprintf(logfile, "%02x ", buf[i]);
-       }
-       fprintf(logfile, "\n");
-       fflush(logfile);
-}
-
-static void usage()
-{
-       printf("Usage: scsi2sd-debug outputfile\n");
-       printf("\n");
-       printf("outputfile\tPath to the output log file.\n\n");
-       printf("\n\n");
-       exit(1);
-}
-
-
-int main(int argc, char* argv[])
-{
-       printf("SCSI2SD Debug Utility.\n");
-       printf("Copyright (C) 2014 Michael McMaster <michael@codesrc.com>\n\n");
-
-       if (argc != 2)
-       {
-               usage();
-               exit(1);
-       }
-
-       logfile = fopen(argv[1], "w");
-       if (!logfile)
-       {
-               fprintf(stderr, "Could not write to file %s.\n", argv[1]);
-               exit(1);
-       }
-
-
-       uint16_t vendorId = 0x04B4; // Cypress
-       uint16_t productId = 0x1337; // SCSI2SD
-
-       printf(
-               "USB device parameters\n\tVendor ID:\t0x%04X\n\tProduct ID:\t0x%04X\n",
-               vendorId,
-               productId);
-
-       // Enumerate and print the HID devices on the system
-       struct hid_device_info *dev = hid_enumerate(vendorId, productId);
-
-       if (!dev)
-       {
-               fprintf(stderr, "ERROR: SCSI2SD USB device not found.\n");
-               exit(1);
-       }
-
-       // We need the SECOND interface for debug data
-       while (dev && dev->interface_number != 1)
-       {
-               dev = dev->next;
-       }
-       if (!dev)
-       {
-               fprintf(stderr, "ERROR: SCSI2SD Debug firmware not enabled.\n");
-               exit(1);
-       }
-
-       printf("USB Device Found\n  type: %04hx %04hx\n  path: %s\n  serial_number: %ls",
-               dev->vendor_id, dev->product_id, dev->path, dev->serial_number);
-       printf("\n");
-       printf("  Manufacturer: %ls\n", dev->manufacturer_string);
-       printf("  Product:      %ls\n", dev->product_string);
-       printf("\n");
-
-       hid_device* handle = hid_open_path(dev->path);
-       if (!handle)
-       {
-               fprintf(
-                       stderr,
-                       "ERROR: Could not open device %s. Check permissions.\n", dev->path
-                       );
-               exit(1);
-       }
-
-
-       while (1)
-       {
-               readConfig(handle);
-       }
-
-       return 0;
-}
-
diff --git a/software/scsi2sd-debug/scsi2sd-debug.cc b/software/scsi2sd-debug/scsi2sd-debug.cc
new file mode 100644 (file)
index 0000000..542f162
--- /dev/null
@@ -0,0 +1,141 @@
+//     Copyright (C) 2014 Michael McMaster <michael@codesrc.com>
+//
+//     This file is part of SCSI2SD.
+//
+//     SCSI2SD is free software: you can redistribute it and/or modify
+//     it under the terms of the GNU General Public License as published by
+//     the Free Software Foundation, either version 3 of the License, or
+//     (at your option) any later version.
+//
+//     SCSI2SD is distributed in the hope that it will be useful,
+//     but WITHOUT ANY WARRANTY; without even the implied warranty of
+//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//     GNU General Public License for more details.
+//
+//     You should have received a copy of the GNU General Public License
+//     along with SCSI2SD.  If not, see <http://www.gnu.org/licenses/>.
+
+#include <getopt.h>
+#include <inttypes.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+// htonl/ntohl includes.
+#ifdef _WIN32
+#include <winsock2.h>
+#else
+#include <arpa/inet.h>
+#endif
+
+#include "hidapi.h"
+
+#define MIN(a,b) (a < b ? a : b)
+
+FILE* logfile = NULL;
+
+static void readConfig(hid_device* handle)
+{
+       // First byte is the report ID (0)
+       unsigned char buf[65];
+       memset(buf, 0, sizeof(buf));
+       int result = hid_read(handle, buf, sizeof(buf));
+
+       if (result < 0)
+       {
+               fprintf(stderr, "USB HID Read Failure: %ls\n", hid_error(handle));
+       }
+       int i;
+       for (i = 0; i < 32; ++i)
+       {
+               fprintf(logfile, "%02x ", buf[i]);
+       }
+       fprintf(logfile, "\n");
+       fflush(logfile);
+}
+
+static void usage()
+{
+       printf("Usage: scsi2sd-debug outputfile\n");
+       printf("\n");
+       printf("outputfile\tPath to the output log file.\n\n");
+       printf("\n\n");
+       exit(1);
+}
+
+
+int main(int argc, char* argv[])
+{
+       printf("SCSI2SD Debug Utility.\n");
+       printf("Copyright (C) 2014 Michael McMaster <michael@codesrc.com>\n\n");
+
+       if (argc != 2)
+       {
+               usage();
+               exit(1);
+       }
+
+       logfile = fopen(argv[1], "w");
+       if (!logfile)
+       {
+               fprintf(stderr, "Could not write to file %s.\n", argv[1]);
+               exit(1);
+       }
+
+
+       uint16_t vendorId = 0x04B4; // Cypress
+       uint16_t productId = 0x1337; // SCSI2SD
+
+       printf(
+               "USB device parameters\n\tVendor ID:\t0x%04X\n\tProduct ID:\t0x%04X\n",
+               vendorId,
+               productId);
+
+       // Enumerate and print the HID devices on the system
+       struct hid_device_info *dev = hid_enumerate(vendorId, productId);
+
+       if (!dev)
+       {
+               fprintf(stderr, "ERROR: SCSI2SD USB device not found.\n");
+               exit(1);
+       }
+
+       // We need the SECOND interface for debug data
+       while (dev && dev->interface_number != 1)
+       {
+               dev = dev->next;
+       }
+       if (!dev)
+       {
+               fprintf(stderr, "ERROR: SCSI2SD Debug firmware not enabled.\n");
+               exit(1);
+       }
+
+       printf("USB Device Found\n  type: %04hx %04hx\n  path: %s\n  serial_number: %ls",
+               dev->vendor_id, dev->product_id, dev->path, dev->serial_number);
+       printf("\n");
+       printf("  Manufacturer: %ls\n", dev->manufacturer_string);
+       printf("  Product:      %ls\n", dev->product_string);
+       printf("\n");
+
+       hid_device* handle = hid_open_path(dev->path);
+       if (!handle)
+       {
+               fprintf(
+                       stderr,
+                       "ERROR: Could not open device %s. Check permissions.\n", dev->path
+                       );
+               exit(1);
+       }
+
+
+       while (1)
+       {
+               readConfig(handle);
+       }
+
+       return 0;
+}
+