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
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
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
BUILD=build/mac
endif
-all: $(BUILD)/bootloaderhost
+all: $(BUILD)/bootloaderhost$(EXE)
CYAPI = \
$(BUILD)/cybtldr_api2.o \
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)
+++ /dev/null
-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
-
--- /dev/null
+#!/bin/sh
+
+make && \
+ make TARGET=Win32 &&
+ make TARGET=Win64
+
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
BUILD=build/mac
endif
-all: $(BUILD)/scsi2sd-config
+all: $(BUILD)/scsi2sd-config$(EXE)
HIDAPI = \
$(BUILD)/hid.o \
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)
+++ /dev/null
-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
-
--- /dev/null
+#!/bin/sh
+
+make && \
+ make TARGET=Win32 &&
+ make TARGET=Win64
+
#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>
#include <unistd.h>
// htonl/ntohl includes.
-#ifdef WIN32
+#ifdef _WIN32
#include <winsock2.h>
#else
#include <arpa/inet.h>
-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)
+++ /dev/null
-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
-
--- /dev/null
+#!/bin/sh
+
+make && \
+ make TARGET=Win32 &&
+ make TARGET=Win64
+
+++ /dev/null
-// 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;
-}
-
--- /dev/null
+// 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;
+}
+