From: Michael McMaster Date: Wed, 20 Jan 2021 12:17:42 +0000 (+1000) Subject: Add test code for nor flash 5.2 work X-Git-Url: http://git.codesrc.com/gitweb.cgi?a=commitdiff_plain;h=88330f61d2ee899c1b6f9d02ee7ec1deeaae2cdb;p=scsi2sd-util.git Add test code for nor flash 5.2 work --- diff --git a/scsi2sd.io.usb4java/pom.xml b/scsi2sd.io.usb4java/pom.xml new file mode 100755 index 0000000..90c8fd6 --- /dev/null +++ b/scsi2sd.io.usb4java/pom.xml @@ -0,0 +1,156 @@ + + + 4.0.0 + + + com.codesrc + scsi2sd-util + 1.0-SNAPSHOT + + + scsi2sd.io.usb4java + jar + + scsi2sd.io.usb4java + http://www.codesrc.com + + + Michael McMaster + michael@codesrc.com + + + + + UTF-8 + 1.3.0 + + + + + target + target/classes + ${project.artifactId}-${project.version} + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.0 + + 10 + 10 + + + + + org.apache.maven.plugins + maven-shade-plugin + + + + module-info.java + commons-lang3.jar + + + + + + + package + + shade + + + + + + + org.moditect + moditect-maven-plugin + + + add-module-infos + package + + add-module-info + + + true + + + src/main/java/module-info.java + + + + + + + + + + + + + + org.usb4java + usb4java + 1.3.0 + + + + org.usb4java + libusb4java + ${libusb4java.version} + linux-x86 + + + org.usb4java + libusb4java + ${libusb4java.version} + linux-x86-64 + + + org.usb4java + libusb4java + ${libusb4java.version} + win32-x86 + + + org.usb4java + libusb4java + ${libusb4java.version} + win32-x86-64 + + + org.usb4java + libusb4java + ${libusb4java.version} + darwin-x86-64 + + + org.usb4java + libusb4java + ${libusb4java.version} + linux-arm + + + org.usb4java + libusb4java + ${libusb4java.version} + linux-aarch64 + + + + + org.apache.commons + commons-lang3 + 3.8.1 + provided + + + + + 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 index 0000000..05f9beb --- /dev/null +++ b/scsi2sd.io.usb4java/src/main/java/module-info.java @@ -0,0 +1,21 @@ +// Copyright (C) 2020 Michael McMaster +// +// 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 . + +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 index 0000000..0014500 --- /dev/null +++ b/scsi2sd.io.usb4java/src/main/java/org/usb4java/package-info.java @@ -0,0 +1,2 @@ +package org.usb4java; +class CompileDummy {} diff --git a/scsi2sd.io/src/main/java/com/codesrc/scsi2sd/io/Commands.java b/scsi2sd.io/src/main/java/com/codesrc/scsi2sd/io/Commands.java index edd93de..d33b58b 100644 --- a/scsi2sd.io/src/main/java/com/codesrc/scsi2sd/io/Commands.java +++ b/scsi2sd.io/src/main/java/com/codesrc/scsi2sd/io/Commands.java @@ -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, } diff --git a/scsi2sd.io/src/main/java/com/codesrc/scsi2sd/io/V3FirmwareUsbDevice.java b/scsi2sd.io/src/main/java/com/codesrc/scsi2sd/io/V3FirmwareUsbDevice.java index 9044185..d1d81a5 100644 --- a/scsi2sd.io/src/main/java/com/codesrc/scsi2sd/io/V3FirmwareUsbDevice.java +++ b/scsi2sd.io/src/main/java/com/codesrc/scsi2sd/io/V3FirmwareUsbDevice.java @@ -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() { diff --git a/scsi2sd.io/src/main/java/com/codesrc/scsi2sd/io/V6FirmwareUsbDevice.java b/scsi2sd.io/src/main/java/com/codesrc/scsi2sd/io/V6FirmwareUsbDevice.java index 7177637..657cf08 100644 --- a/scsi2sd.io/src/main/java/com/codesrc/scsi2sd/io/V6FirmwareUsbDevice.java +++ b/scsi2sd.io/src/main/java/com/codesrc/scsi2sd/io/V6FirmwareUsbDevice.java @@ -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 index 0000000..3babdd5 --- /dev/null +++ b/scsi2sd.ui/launcher @@ -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 $@