]> localhost Git - scsi2sd-util.git/commitdiff
Add test code for nor flash 5.2 work
authorMichael McMaster <michael@codesrc.com>
Wed, 20 Jan 2021 12:17:42 +0000 (22:17 +1000)
committerMichael McMaster <michael@codesrc.com>
Wed, 20 Jan 2021 12:17:42 +0000 (22:17 +1000)
scsi2sd.io.usb4java/pom.xml [new file with mode: 0755]
scsi2sd.io.usb4java/src/main/java/module-info.java [new file with mode: 0644]
scsi2sd.io.usb4java/src/main/java/org/usb4java/package-info.java [new file with mode: 0644]
scsi2sd.io/src/main/java/com/codesrc/scsi2sd/io/Commands.java
scsi2sd.io/src/main/java/com/codesrc/scsi2sd/io/V3FirmwareUsbDevice.java
scsi2sd.io/src/main/java/com/codesrc/scsi2sd/io/V6FirmwareUsbDevice.java
scsi2sd.ui/launcher [new file with mode: 0755]

diff --git a/scsi2sd.io.usb4java/pom.xml b/scsi2sd.io.usb4java/pom.xml
new file mode 100755 (executable)
index 0000000..90c8fd6
--- /dev/null
@@ -0,0 +1,156 @@
+<project
+        xmlns="http://maven.apache.org/POM/4.0.0"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>com.codesrc</groupId>
+        <artifactId>scsi2sd-util</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>scsi2sd.io.usb4java</artifactId>
+    <packaging>jar</packaging>
+
+    <name>scsi2sd.io.usb4java</name>
+    <url>http://www.codesrc.com</url>
+    <developers>
+        <developer>
+            <name>Michael McMaster</name>
+            <email>michael@codesrc.com</email>
+        </developer>
+    </developers>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <libusb4java.version>1.3.0</libusb4java.version>
+
+    </properties>
+
+    <build>
+        <directory>target</directory>
+        <outputDirectory>target/classes</outputDirectory>
+        <finalName>${project.artifactId}-${project.version}</finalName>
+
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.8.0</version>
+                <configuration>
+                    <source>10</source>
+                    <target>10</target>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-shade-plugin</artifactId>
+                <configuration>
+                    <artifactSet>
+                        <excludes>
+                            <exclude>module-info.java</exclude>
+                            <exclude>commons-lang3.jar</exclude>
+
+                        </excludes>
+                    </artifactSet>
+                </configuration>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>shade</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+
+            <plugin>
+                <groupId>org.moditect</groupId>
+                <artifactId>moditect-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>add-module-infos</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>add-module-info</goal>
+                        </goals>
+                        <configuration>
+                            <overwriteExistingFiles>true</overwriteExistingFiles>
+                            <module>
+                                <moduleInfoFile>
+                                    src/main/java/module-info.java
+                                </moduleInfoFile>
+                            </module>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
+        </plugins>
+    </build>
+
+
+    <dependencies>
+        <dependency>
+            <groupId>org.usb4java</groupId>
+            <artifactId>usb4java</artifactId>
+            <version>1.3.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.usb4java</groupId>
+            <artifactId>libusb4java</artifactId>
+            <version>${libusb4java.version}</version>
+            <classifier>linux-x86</classifier>
+        </dependency>
+        <dependency>
+            <groupId>org.usb4java</groupId>
+            <artifactId>libusb4java</artifactId>
+            <version>${libusb4java.version}</version>
+            <classifier>linux-x86-64</classifier>
+        </dependency>
+        <dependency>
+            <groupId>org.usb4java</groupId>
+            <artifactId>libusb4java</artifactId>
+            <version>${libusb4java.version}</version>
+            <classifier>win32-x86</classifier>
+        </dependency>
+        <dependency>
+            <groupId>org.usb4java</groupId>
+            <artifactId>libusb4java</artifactId>
+            <version>${libusb4java.version}</version>
+            <classifier>win32-x86-64</classifier>
+        </dependency>
+        <dependency>
+            <groupId>org.usb4java</groupId>
+            <artifactId>libusb4java</artifactId>
+            <version>${libusb4java.version}</version>
+            <classifier>darwin-x86-64</classifier>
+        </dependency>
+        <dependency>
+            <groupId>org.usb4java</groupId>
+            <artifactId>libusb4java</artifactId>
+            <version>${libusb4java.version}</version>
+            <classifier>linux-arm</classifier>
+        </dependency>
+        <dependency>
+            <groupId>org.usb4java</groupId>
+            <artifactId>libusb4java</artifactId>
+            <version>${libusb4java.version}</version>
+            <classifier>linux-aarch64</classifier>
+        </dependency>
+
+        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.8.1</version>
+            <scope>provided</scope>
+        </dependency>
+
+    </dependencies>
+</project>
+
diff --git a/scsi2sd.io.usb4java/src/main/java/module-info.java b/scsi2sd.io.usb4java/src/main/java/module-info.java
new file mode 100644 (file)
index 0000000..05f9beb
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright (C) 2020 Michael McMaster <michael@codesrc.com>
+//
+// This file is part of scsi2sd-util.
+//
+// scsi2sd-util 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-util 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-util.  If not, see <https://www.gnu.org/licenses/>.
+
+module com.codesrc.scsi2sd.io.usb4java {
+       exports org.usb4java;
+       requires org.apache.commons.lang3;
+}
diff --git a/scsi2sd.io.usb4java/src/main/java/org/usb4java/package-info.java b/scsi2sd.io.usb4java/src/main/java/org/usb4java/package-info.java
new file mode 100644 (file)
index 0000000..0014500
--- /dev/null
@@ -0,0 +1,2 @@
+package org.usb4java;
+class CompileDummy {}
index edd93de23577788cc725e44f051c2c1c8eaf7198..d33b58bb8efd7cc01053184a76e2cad3e37ee669 100644 (file)
@@ -89,4 +89,52 @@ public enum Commands {
     // uint8_t S2S_CFG_DEBUG
     // Response:
     DEBUG,
+
+    // Command content:
+    // uint8_t DEV_LIST
+    // Response:
+    // uint8_t Number of devices
+    // For each device:
+    // uint8_t device type
+    //  0 == SD card
+    //  1 == NOR FLASH
+    // uint32_t capacity(MSB)
+    DEV_LIST,
+
+    // Command content:
+    // uint8_t DEV_INFO
+    // uint8_t Device Number
+    // Response:
+    //  SD card:
+    //    uint8_t[16] CSD
+    //    uint8_t[16] CID
+    //  NOR Flash:
+    //    uint8_t[512] JEDEC CFI from RDID command
+    DEV_INFO,
+
+    // Command content:
+    // uint8_t DEV_ERASE
+    // uint8_t Device Number
+    // uint32_t Sector Number (MSB)
+    // uint32_t Sector Count (MSB)
+    // Response:
+    // S2S_CMD_STATUS
+    DEV_ERASE,
+
+    // Command content:
+    // uint8_t S2S_CMD_DEV_WRITE
+    // uint8_t Device Number (MSB)
+    // uint32_t Sector Number (MSB)
+    // uint8_t[512] data
+    // Response:
+    // S2S_CMD_STATUS
+    DEV_WRITE,
+
+    // Command content:
+    // uint8_t DEV_READ
+    // uint8_t Device Number (MSB)
+    // uint32_t Sector Number (MSB)
+    // Response:
+    // 512 bytes of data
+    DEV_READ,
 }
index 90441851daa81e95912c44728fe9d7b7cde14a24..d1d81a51db0c52b83c60bd88bcae79a6242f4fba 100644 (file)
@@ -78,6 +78,10 @@ public class V3FirmwareUsbDevice implements UsbDevice {
             }
         }
         this.readDebugData();
+
+        if (firmwareVersion >= 0x0485) {
+            this.readDeviceList();
+        }
     }
 
     @Override
@@ -142,6 +146,8 @@ public class V3FirmwareUsbDevice implements UsbDevice {
                 return false; //"3.5\" SCSI2SD V4.1/V4.2/V5.0 or 2.5\" SCSI2SD for Apple Powerbook";
             case 0x3003:
                 return true; //"3.5\" SCSI2SD V5.1";
+            case 0x3004:
+                return true; //"3.5\" SCSI2SD V5.2";
             case 0x0055:
                 return false; //"External DB25 SCSI2SD";
         }
@@ -160,7 +166,7 @@ public class V3FirmwareUsbDevice implements UsbDevice {
         data[0] = 0; // report ID
         this.debugHidDevice.read(data, 5000);
 
-        this.firmwareVersion = (data[62] << 8) | data[63];
+        this.firmwareVersion = (HidPacketProtocol.uint8ToInt(data[62]) << 8) | HidPacketProtocol.uint8ToInt(data[63]);
         this.sDCapacity =
                 (HidPacketProtocol.uint8ToInt(data[58]) << 24) |
                         (HidPacketProtocol.uint8ToInt(data[59]) << 16) |
@@ -168,6 +174,28 @@ public class V3FirmwareUsbDevice implements UsbDevice {
                         (HidPacketProtocol.uint8ToInt(data[61]));
     }
 
+    private void readDeviceList()
+    {
+        byte[] cmd = {
+                (byte)Commands.DEV_LIST.ordinal()
+        };
+
+        byte[] response = protocolDevice.sendHIDPacket(cmd, 1);
+        System.out.print("Found storage devices: ");
+        System.out.println(HidPacketProtocol.uint8ToInt(response[0]));
+
+        for (int i = 1; i + 4 < response.length; i += 5) {
+            OUTPUT THE TYPE AS WELL
+            int capacity = (HidPacketProtocol.uint8ToInt(response[i + 1]) << 24) |
+                    (HidPacketProtocol.uint8ToInt(response[i + 2]) << 16) |
+                    (HidPacketProtocol.uint8ToInt(response[i + 3]) << 8) |
+                    (HidPacketProtocol.uint8ToInt(response[i + 4]));
+            System.out.print("Found storage device with capacity: ");
+            System.out.println(capacity * 512L);
+        }
+    }
+
+
     @Override
     public int getMaxDisks()
     {
index 7177637c880623c0121bf6f004a9ebee1861f237..657cf0834891a33153dc95a51041c8c868f5c4d0 100644 (file)
@@ -100,7 +100,7 @@ public class V6FirmwareUsbDevice implements UsbDevice {
 
         byte[] data = protocolDevice.sendHIDPacket(cmd, 6);
 
-        this.firmwareVersion = (data[0] << 8) | data[1];
+        this.firmwareVersion = (HidPacketProtocol.uint8ToInt(data[0]) << 8) | HidPacketProtocol.uint8ToInt(data[1]);
         this.sDCapacity =
                 (HidPacketProtocol.uint8ToInt(data[2]) << 24) |
                         (HidPacketProtocol.uint8ToInt(data[3]) << 16) |
diff --git a/scsi2sd.ui/launcher b/scsi2sd.ui/launcher
new file mode 100755 (executable)
index 0000000..3babdd5
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+target/jlink-image/bin/java -Djna.debug_load=true --add-exports javafx.graphics/com.sun.javafx.css=org.controlsfx.controls --add-opens javafx.graphics/javafx.scene=org.controlsfx.controls -m com.codesrc.scsi2sd.ui/com.codesrc.scsi2sd.App $@