Final preparations before v0.3

master
Dmitry Isaenko 2019-03-20 03:07:08 +03:00
parent 53a8a2337f
commit 7c3bb790ee
4 changed files with 73 additions and 52 deletions

View File

@ -1,39 +1,35 @@
# NS-USBloader
NS-USBloader is a PC-side TinFoil (USB and Network) and GoldLeaf NSP USB uploader. Replacement for default *usb_install_pc.py*, *remote_install_pc.py* and *GoldTree*.
NS-USBloader is a PC-side TinFoil (USB and Network) and GoldLeaf (USB) NSP installer. Replacement for default **usb_install_pc.py**, **remote_install_pc.py** *(never ever use this. even if you brave. no idea why it works.)* and **GoldTree**.
With GUI and cookies.
With GUI and cookies. Wokrs on Windows, macOS and Linux.
Read more: https://developersu.blogspot.com/2019/02/ns-usbloader-en.html
Here is the version of 'not perfect but anyway' [tinfoil I use](https://cloud.mail.ru/public/DwbX/H8d2p3aYR).
Ok, I'm almost sure that this version has bugs. I don't remember where I downloaded it. But it works for me somehow..
Let's rephrase, if you have working version of TinFoil DO NOT use this one.
Sometimes I add new posts [on my home page](https://developersu.blogspot.com/search/label/NS-USBloader) about this project.
![Screenshot](https://farm8.staticflickr.com/7834/47133893471_37fd9689c4_o.png)
## License
### License
Source code spreads under the GNU General Public License v.3. You can find it in LICENSE file.
## Used libraries
### Used libraries
* [OpenJFX](https://wiki.openjdk.java.net/display/OpenJFX/Main)
* [usb4java](https://mvnrepository.com/artifact/org.usb4java/usb4java)
* Few icons taken from: [materialdesignicons](http://materialdesignicons.com/)
## Requirements
### System requirements
JRE 8u60 or higher. See below.
JRE 8u60 or higher.
## Usage
### Linux:
### Usage
#### How to start it on..
##### Linux:
1. Install JRE/JDK 8u60 or higher (openJDK is good. Oracle's one is also good). JavaFX not needed, if you're interested (it's embedded).
2. `root # java -jar /path/to/NS-USBloader.jar`
### macOS
##### macOS
Double-click on downloaded .jar file. Follow instructions. Or see 'Linux' section.
@ -41,10 +37,10 @@ Set 'Security & Privacy' settings if needed.
If you use different MacOS (not Mojave) - check release section for another JAR file.
### Windows:
##### Windows:
* Download Zadig: https://zadig.akeo.ie/
* Open tinfoil. Set 'Title Management' -> 'Usb install NSP'
* Download Zadig: [https://zadig.akeo.ie/](https://zadig.akeo.ie/)
* Open TinFoil. Set 'Title Management' -> 'Usb install NSP'
* Connect NS to PC
* Open Zadig
* Click 'Options' and select 'List All Devices'
@ -54,34 +50,67 @@ If you use different MacOS (not Mojave) - check release section for another JAR
* Get this application (JAR file) double-click on on it (alternatively open 'cmd', go to place where jar located and execute via `java -jar thisAppName.jar`)
* Remember to have fun!
## Tips&tricks
### Linux: Add user to udev rules to use NS not-from-root-account
`root # vim /etc/udev/rules.d/99-NS.rules`
#### And how to use it?
`SUBSYSTEM=="usb", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="3000", GROUP="plugdev"`
The first thing you should do it install TinFoil ([Adubbz](https://github.com/Adubbz/Tinfoil/)) or GoldLeaf ([XorTroll](https://github.com/XorTroll/Goldleaf)) on your NS. I recommend using TinFoil, but it ups to you. Take a look on app, find where is the option to install from USB and/or Network. Maybe [this article](https://developersu.blogspot.com/2019/02/ns-usbloader-en.html) will be helpful.
`root # udevadm control --reload-rules && udevadm trigger`
Here is the version of 'not perfect but anyway' [tinfoil I use](https://cloud.mail.ru/public/DwbX/H8d2p3aYR).
Ok, I'm almost sure that this version has bugs. I don't remember where I downloaded it. But it works for me somehow.
## Known bugs
* Unable to interrupt transmission when libusb awaiting for read event (when user sent NSP list but didn't selected anything on NS).
Let's rephrase, if you have working version of TinFoil **DO NOT** use this one. Ok. let's begin.
## NOTES
Table 'Status' = 'Uploaded' does not means that file installed. It means that it has been sent to NS without any issues! That's what this app about.
There are three tabs. Firs one is main.
##### First tab.
At the top of you selecting from drop-down application and protocol that you're going to use. For GoldLeaf only USB is available. Lamp icon stands for switching themes (light or dark).
Then you may drag-n-drop folder with NSPs OR files to application or use 'Select NSP files' button. Multiple selection for files available. Click it again and select files from another folder it you want, it will be added into the table.
Table.
There you can select checkbox for files that will be send to application (TF/GL). Since GoldLeaf allow you only one file transmission per time, only one file is available for selection. Also you can use space to select/un-select files and 'delete' button for deleting. By right-mouse-click you can see context menu where you can delete one OR all items from the table.
##### Second tab.
Here you can configure settings for network file transmission. Usually you shouldn't change anything. But it you're cool hacker, go ahead! The most interesting option here is 'Don't serve requests'. Architecture of the TinFoil networking is working interesting way. When you select in TF network NSP transfer, application will wait at port 2000 for the information about where should it take files from. Like '192.168.1.5:6060/my_file.nsp'. Usually NS-USBloader serves requests by implementing simplified HTTP server and bringing it up and so on. But if this option selected, you can define path to remote location of the files. For example if you set in settings 'shared.lan:80/ROMS/NS/' and add in table file 'my file.nsp' then NS-USBloader will simply tell TinFoil "Hey, go take files from 'shared.lan:80/ROMS/NS/my+file.nsp' ". Of course you have to bring 'shared.lan' host up and make file accessible from such address. All this requires more investigation. BTW, the issue could be that NS-USBloader encodes 'space' char as '+' and some web-servers understand 'space' as '%20D'. It could be fixed in later versions of NS-USBloader if I go deeper in it or you leave me feedback with information/request. As I said, this feature is interesting, but I guess won't be popular.
##### Third tab.
That's where all logs dropped. Verbose information about transmissions comes here.
Why when 'Net' once started it never ends?
Because there is HTTP server inside of application. It can't determine the moment when all transmissions finished (unless they failed). So you have to look on your NS screen and 'Interrupt' is once done.
### Tips&tricks
#### Linux: Add user to 'udev' rules to use NS not-from-root-account
```
root # vim /etc/udev/rules.d/99-NS.rules
SUBSYSTEM=="usb", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="3000", GROUP="plugdev"
root # udevadm control --reload-rules && udevadm trigger
```
### Known bugs
* Unable to interrupt transmission when libusb awaiting for read event (when user sent NSP list but didn't selected anything on NS). Also, sometimes, when network transmission started and nothing received from NS.
#### NOTES
Table 'Status' = 'Uploaded' does not mean that file installed. It means that it has been sent to NS without any issues! That's what this app about.
Handling successful/failed installation is a purpose of the other side application (TinFoil/GoldLeaf). (And they don't provide any feedback interfaces so I can't detect success/failure.)
## Translators! Traductores! Übersetzer! Թարգմանիչներ!
### Translators! Traductores! Übersetzer! Թարգմանիչներ!
If you want to see this app translated to your language, go grab [this file](https://github.com/developersu/ns-usbloader/blob/master/src/main/resources/locale.properties) and translate it.
Upload somewhere (pastebin? google drive? whatever else). [Create new issue](https://github.com/developersu/ns-usbloader/issues) and post a link. I'll grab it and add.
### Thanks for great work done by our translater~~s team~~!
#### Thanks for great work done by our translater~~s team~~!
Français by [Stephane Meden (JackFromNice)](https://github.com/JackFromNice)
## TODO:
#### TODO (maybe):
- [x] macOS QA v0.1 (Mojave)
- [x] macOS QA v0.2.2 (Mojave)
- [ ] macOS QA v0.3 (Mojave)
- [ ] macOS QA v0.3 (Mojave, High Sierra)
- [x] Windows support
- [x] code refactoring
- [x] GoldLeaf support
@ -90,9 +119,9 @@ Français by [Stephane Meden (JackFromNice)](https://github.com/JackFromNice)
- [ ] More deep file analyze before uploading.
- [x] Network mode support for TinFoil
## Thanks
#### Thanks
Appreciate assistance and support of both Vitaliy and Konstantin. Without you all this magic would not have happened.
[Konstanin Kelemen](https://github.com/konstantin-kelemen)
[Vitaliy Natarov](https://github.com/SebastianUA)
[Vitaliy Natarov](https://github.com/SebastianUA)

View File

@ -8,11 +8,11 @@
<name>NS-USBloader</name>
<artifactId>ns-usbloader</artifactId>
<version>0.3_DEV-SNAPSHOT</version>
<version>0.3-SNAPSHOT</version>
<url>https://github.com/developersu/ns-usbloader/</url>
<description>
NSP USB loader for TinFoil and GoldLeaf
NSP USB loader for TinFoil (USB and Network) and GoldLeaf
</description>
<inceptionYear>2019</inceptionYear>
<organization>
@ -140,7 +140,7 @@
<dependency>
<groupId>org.usb4java</groupId>
<artifactId>usb4java</artifactId>
<version>1.3.0</version>
<version>1.2.0</version>
<scope>compile</scope>
</dependency>
</dependencies>

View File

@ -130,11 +130,12 @@ public class NETCommunications extends Task<Void> { // todo: thows IOException?
else {
try {
this.hostPort = Integer.parseInt(hostPortNum);
serverSocket = new ServerSocket(hostPort);
logPrinter.print("NET: Using defined port number: " + hostPort, EMsgType.PASS);
}
catch (NumberFormatException exeption){ // Literally never happens.
isValid = false;
catch (NumberFormatException | IOException exeption){ // Literally never happens.
logPrinter.print("NET: Can't use port defined in settings: " + hostPortNum + "\nIt's not a valid number!", EMsgType.WARNING);
isValid = false;
close(EFileStatus.FAILED);
return;
}
@ -149,11 +150,7 @@ public class NETCommunications extends Task<Void> { // todo: thows IOException?
this.close(EFileStatus.UNKNOWN);
super.cancelled();
}
/*
Replace everything to ASCII (WEB representation)
calculate
write in first 4 bytes
* */
@Override
protected Void call() {
if (!isValid | isCancelled())
@ -201,13 +198,10 @@ write in first 4 bytes
// Go transfer
Socket clientSocket;
System.out.println("0");
work_routine:
while (true){
try {
System.out.println("0.5");
clientSocket = serverSocket.accept();
System.out.println("1");
BufferedReader br = new BufferedReader(
new InputStreamReader(clientSocket.getInputStream())
);
@ -219,7 +213,7 @@ write in first 4 bytes
LinkedList<String> tcpPacket = new LinkedList<>();
while ((line = br.readLine()) != null) {
System.out.println(line); // TODO: remove DBG
//System.out.println(line); // TODO: remove DBG
if (line.trim().isEmpty()) { // If TCP packet is ended
if (handleRequest(tcpPacket)) // Proceed required things
break work_routine;
@ -228,15 +222,13 @@ write in first 4 bytes
else
tcpPacket.add(line); // Otherwise collect data
}
System.out.println("\t\tPacket covered!\n"); // reopen client sock
// and reopen client sock
clientSocket.close();
}
catch (IOException ioe){ // If server socket closed, then client socket also closed.
System.out.println("2");
break;
}
}
System.out.println("3");
if (!isCancelled())
close(EFileStatus.UNKNOWN);
return null;

View File

@ -12,7 +12,7 @@ import java.util.Locale;
import java.util.ResourceBundle;
public class NSLMain extends Application {
public static final String appVersion = "v0.3_DEV";
public static final String appVersion = "v0.3";
@Override
public void start(Stage primaryStage) throws Exception{