Nandpro v2.0d

This pack is for the Xecuter NAND-X and also includes the signed x64 Windows Drivers

libusb0 = standard windows 32 bit NAND PRO drivers

libusb0_x64 = standard windows 64 bit NAND PRO drivers (Unsigned so follow same rules as signing the PortIO64 Jungle Flasher driver)

ptlibusb0_x64 = signed windows 64 bit NAND PRO drivers. Not official. Use only if you cant get the above working.

Usage:

	Make connections to MAINBRD and run the app.
	MAINBRD needs to be plugged in to AC power.
	Actually powered on or not does not matter.
	While running NandPro application reset will occur.
	After nand operation is complete, reset will be released.
	
	printf("Useage:\n\r\n\r");
	
	printf("NandPro dev: -r# Filename (HexStartBlock HexBlockCount)\t->Read\n");	
	printf("NandPro dev: -w# Filename (HexStartBlock HexBlockCount)\t->Write\n");	
	printf("NandPro dev: -e# (HexStartBlock HexBlockCount)\t\t->Erase\n\n");
	printf("dev: is hardware interface usb: or lpt:\n");
	printf("dev: can also be a filename:, to be used as a 'Virtual Nand Device'\n");
	printf("     Virtual device config can be forced, by appending :HexConfigValue\n");
	printf("# is nand size (16, 64, 256, 512) in MegaBytes\n");
	printf("(Optional) block range limit, defaults to entire device\n");
	printf("-r# Read saving file RAW (with SPARE)\n");
	printf("-R# Read saving file without SPARE\n");
	printf("!r# Read saving only the SPARE data\n");
	printf("-w# Write RAW (with SPARE) file\n");
	printf("+w# Write RAW (with SPARE) file, init SPARE, block numbers, ECC\n");
	printf("@w# Write RAW (with SPARE) file, init block numbers, ECC\n");
	printf("*w# Write RAW (with SPARE) file, init ECC\n");
	printf("+W# Write while ADDING SPARE from file without SPARE\n");
	
===============================================================================
NOTE:

	SPARE is the 16 bytes following a data block.
	ECC is 26 bits located within the spare area.
	Block numbers are also contained in spare area.

===============================================================================

Typical command line:

Read entire 16M flash, including SPARE:
	NandPro dev: -r16 nand.bin

Write entire 16M flash, including SPARE:
	NandPro dev: -w16 nand.bin

Advanced command line examples:

Read encrypted key vault with SPARE:
nandpro dev: -r16 rawkv.bin 1 1

Read encrypted key vault from a "Virtual Nand" dev:, named vnand.bin, with SPARE :
nandpro vnand.bin: -r16 rawkv.bin 1 1

Write encrypted key vault:
nandpro dev: -w16 rawkv.bin 1 1

Flash a xell.bin compiler output (no SPARE) to block 40, adding SPARE while flashing:
nandpro dev: +W16 xell.bin 40

Read config block from a "Virtual Nand", named vnand.bin, without SPARE:
nandpro vnand.bin: -R16 configblk.bin 0x??? 1

Write above config block to dev: adding the SPARE back in:
nandpro dev: +W16 configblk.bin 0x??? 1

Write a "small" python.ECC file to "full size" "Virtual Nand" :
nandpro vnand.bin: -w16 python.ECC

Write to a dev:, from another RAW file, fixing ECC while writing:
nandpro dev: -w16 DumpWithErrors.bin


General Notes:

Reading and writing defaults to the entire device.
The start block argumnet is optional and dictates the starting block to program.
The ending block is also optional, and end if no block is specified, programming will
	continue until end of file or end of specified nand size.

Large block nands have different SPARE format than small block nands.
The software uses the detected device's SPARE format for all (+) write operations.
Files written RAW (-) are not translated in any way.

The "nand size" argument only sets the limit of available blocks for device operations.
	It is not hardware related, and need not exactly match the true device.
	
There is no need to erase before programming.

You can hex edit a block, and use Nandpro to fix its ECC when you write it back.

The "Case" of the command generally indicates if I/O file will contain SPARE or not
	Upper Case:	No SPARE
	Lower Case:	RAW (with SPARE)

The "Virtual Nand" file can be read or be programmed, as if it where a device.
The "Virtual Nand" file must be a raw file, containing SPARE.
This can be used to extract or inject data from\to an existing raw dump.
Example: To inject a "small" python image into an existing
	"full size" image, or to extract individual blocks from an existing raw dump.

READING WILL OVER-WRITE AN EXISTING FILE WITHOUT WARNING!
NEW LOG FILE WILL OVERWRITE OLD WITHOUT WARNING!


//History:
//
//2.0
//Initial Release
//
//2.0a
//Fixed usage for +W, +w
//Fixed problem with payload injection for large block nands
//Fixed miscalc of file blocks togo when injecting !raw
//No ARM code impact
//
//
//2.0b
//Remove "Press Any Key" for unattended batch file processing
//Removed retry on individual sectors, retry entire block instead, including erase
// attempt to program all sectors anyway, then report status
//ARM code update required for above
//Added ARM HW version test, (U32) 0000 0001 required or abort
//Added "Virtual Nand" device
//
//
//2.0c
//Bit settling verify feature added for LPT reading
//Add support for Jasper16a
//Improved detection for virtual nand device, fixes some problems with writing to vnand.
//Allways corrects the ECC bytes (but not SPARE), even in raw mode
// ie: A raw file that has been hex edited can simply be flashed with -w
//
//Added command line swithces
//%r will read SPARE data only, 16 bytes per block
//@w will write RAW file, while correcting block numbers
//Can "force" a flash config on command line by appending :HexFlashConfig
//
//2.0d
//For compatibility purposes -w does not calculate ECC
//Raw files are flashed pure using -w. To correct ECC errors use *w instead
// ie: A raw file that has been hex edited can simply be flashed with *w
//


Note:
For the vnand: device the flash config is normally automatically detected.
Some "hybrid" 256/512 images can not be detected properly, to mount these files the config
 value must be forced by specifying it as the last argument on the command line, preceeded by a ':'.
Only vnand: device may be forced!

Example:
nandpro vnand.bin: -r64 rawkv.bin 1 1 :AA3020

