PROCEDURE
=========

The preparation seems easiest to do in three batches, rather than trying to do a single board 
from start to finish.

First Batch
-----------
For the first batch, program the CPLDs. I don't need to instruct on this and I didn't provide 
any tools. 

Second Batch
------------

For the second batch, you will program the boards over BJL. You will first need to edit "flash.bat" 
for your copy of BJL and any switches you need to pass. Make sure the last argument is always "tmp.cof", 
that's what bjlskunkflash.exe writes after patching the BIOS with the serial number.

The current BIOS is "skunkbios_2.0.2_noverify.cof". The "noverify" means it doesn't check if you are 
trying to flash v2 on a board that already has v1 (which is the problem you were having with that one 
board the other day). So it will just blindly try to flash it. 

1) Bring up your command prompt
2) Ensure that 'flash.bat' is in the current folder, and that it has been set up for your system. 
3) Make sure that the BJL cable is attached to the Jag and the PC.
4) Remainder of the steps are for each board.
5) Power off the Jaguar! Hot swapping can fry the flash chip. :/
6) Insert the Skunkboard. It is NOT necessary to attach the USB cable.
7) Power on the Jag, ensure it starts in BJL mode.
8) Run flash.bat 
9) You will be prompted for the board's serial number. We decided that this run is 1100 and up, so 
   that's what it enforces. (I numbered mine 1297-1299 ;) ).
10) The tool will patch the BIOS and then invoke BJL in a separate process to run it.
11) If BJL fails, or the flash fails (red or black screen), you can try to run it again.
12) If the Jag goes blue, then success. 
13) Power off the Jaguar, and remove the Skunkboard
14) Repeat from step 5 as needed.


Third Batch
-----------

The third batch is the testing run. You need to have the latest JCP.EXE installed and working in 
the path. Remove the BJL cable to prevent conflict with the games!

Note that doom.jag and avp.jag have been modified with the universal "TYPEAB" header, in 
order to compare properly with the dumps that JCP writes. 

The script will first dump the version and serial number in large type to the console, so you can 
verify they are sensible, and verify the BIOS. It will then perform a set of upload and download 
tests to the flash - it will take about 12 minutes to run including 4 minutes of game run time 
(2 minutes on each bank), during which you should casually listen/glance over to make sure it's 
playing clean and not glitching or crashing. When done, you'll get a success or a failure. So!

This script automatically resets the Jaguar numerous times, so you have to make sure BJL is 
disabled so the machine boots into the Skunkboard directly.

This script verifies the banks are working separate from each other by interleaving writes and 
dumps between them.

I don't test 6MB mode explicitly, since there's no way to properly dump it and automatically verify. 
But if both 4MB banks work, then a 6MB problem is going to be software instead of hardware, since we 
have checked all the address lines.

The 2 second delay after a reset is long enough 99% of the time. Occasionally JCP may fail out with 
a 'can't find EZ-Host', because the delay wasn't quite long enough for Windows to re-detect the Jag. 
Watch for those errors and re-run as needed.

1) Bring up your command prompt
2) Ensure that 'test2.bat', 'zerocart.bin', 'avp.jag' and 'doom.jag' are in the current folder, and 
   that jcp.exe is in the path. Make sure 'diff' is in the path and working. (I include a Windows one).
3) Remainder of the steps are for each board.
4) Power off the Jaguar! Hot swapping can fry the flash chip. :/
6) Insert the Skunkboard. DO attach the USB cable between the board and the PC.
7) Power on the Jag, ensure it goes to the Skunkboard green screen (no BJL!)
8) Run test2.bat
9) Check that the displayed version is 2.00.02, and that the serial number is more than 1100 (looks valid, 
   anyway).
10) Casually observe the roughly 12 minutes of test. In particular watch/listen when the game runs to ensure 
    it's not glitching and doesn't crash.
11) When the test is done and succeeds, power off the Jaguar and remove the SKunkboard. This one's good!
12) If any test fails, power off and set the board aside for analysis
13) Repeat from step 4 as needed.


Sample runs
-----------

-----------------------------------------------------------------------

C:\WORK\jaguar\skunk\sources\bjlSkunkFlash>flash
.
Using BIOS file 'skunkbios_2.0.2_noverify.cof'
Using command line 'bjlxp.exe -p 0xac00 tmp.cof'
Ensure Jaguar is in BJL receive mode, ensure skunkboard is in machine.
Also check BJL cable is attached! Boot revision 2.0.2

Enter serial number for board in decimal format, 4 digits max (will save as hex)
: 1299
Writing serial number 1299 to board, using command:
> bjlxp.exe -p 0xac00 tmp.cof
Done, wait for BJL to exit.
If successful, the screen should go BLUE.
If BJL hung or the flash failed, power cycle the Jaguar and try again.

C:\WORK\jaguar\skunk\sources\bjlSkunkFlash>

-----------------------------------------------------------------------

C:\WORK\jaguar\skunk\sources\bjlSkunkFlash>test2
jcp v02.02.04 built on Apr 11 2009

Resetting jaguar...
** Please check the serial number is valid! **
jcp v02.02.04 built on Apr 11 2009


 XXX         XXX   XXX         XXX   XXX          X    XXX   XXX   XXX
X   X       X   X X   X       X   X X   X       XXX   X   X X   X X   X
    X       X   X X   X       X   X     X         X       X X   X X   X
  XX        X   X X   X       X   X   XX          X     XX   XXXX  XXXX
 X          X   X X   X       X   X     X         X    X        X     X
X           X   X X   X       X   X X   X         X   X         X     X
XXXXX   XX   XXX   XXX    XX   XXX   XXX        XXXXX XXXXX  XXX   XXX

.
Dumping the BIOS...
.
jcp v02.02.04 built on Apr 11 2009

COFF File:  Skip 168 bytes, base addr is $10000, length is 1417 bytes
Sending...
Jag accepted start request at $00010000.

Finished in 15 millis, 94KB/second.

Starting console...
Opened bios.bin for writing...
Closing file...
Console terminating.
Compare to baseline...
jcp v02.02.04 built on Apr 11 2009

Resetting jaguar...
.
Load the zeros file to bank 1...
.
jcp v02.02.04 built on Apr 11 2009

Sending...
..
Waiting for erase to complete (about 18s)..
Cart ROM:  Skip 8192 bytes, base addr is $802000, length is 4186112 bytes
Sending........................................................................-
...........................................................
Jag accepted start request at $00802000.

Finished in 21203 millis, 197KB/second.
jcp v02.02.04 built on Apr 11 2009

Resetting jaguar...
Now dump it back...
jcp v02.02.04 built on Apr 11 2009

Beginning dump to 'test.bin'...
Sending...

Receiving flash...
Closing file...

Dumped 4MB in 26s - 157KB/s
* Dump complete.
Diff the files...
.
Try a game in bank 1...
.
jcp v02.02.04 built on Apr 11 2009

Sending...
..
Waiting for erase to complete (about 18s)..
Cart ROM:  Skip 8192 bytes, base addr is $802000, length is 4186112 bytes
Sending........................................................................-
...........................................................
Jag accepted start request at $00802000.

Finished in 20985 millis, 199KB/second.
Letting it run for 2 minutes...
jcp v02.02.04 built on Apr 11 2009

Resetting jaguar...
.
Load the zeros file to bank 2...
.
jcp v02.02.04 built on Apr 11 2009

Using bank 2
Sending...
..
Waiting for erase to complete (about 18s)..
Cart ROM:  Skip 8192 bytes, base addr is $802000, length is 4186112 bytes
Sending........................................................................-
...........................................................
Jag accepted start request at $00802000.

Finished in 21219 millis, 197KB/second.
jcp v02.02.04 built on Apr 11 2009

Resetting jaguar...
Now dump it back...
jcp v02.02.04 built on Apr 11 2009

Using bank 2
Beginning dump to 'test.bin'...
Sending...

Receiving flash...
Closing file...

Dumped 4MB in 26s - 157KB/s
* Dump complete.
Diff the files...
.
Now dump bank 1 to check game...
.
jcp v02.02.04 built on Apr 11 2009

Beginning dump to 'test.bin'...
Sending...

Receiving flash...
Closing file...

Dumped 4MB in 26s - 157KB/s
* Dump complete.
Diff the files...
jcp v02.02.04 built on Apr 11 2009

Resetting jaguar...
.
Try a game in bank 2...
.
jcp v02.02.04 built on Apr 11 2009

Using bank 2
Sending...
..
Waiting for erase to complete (about 18s)..
Cart ROM:  Skip 8192 bytes, base addr is $802000, length is 4186112 bytes
Sending......................................................................../
...........................................................
Jag accepted start request at $00802000.

Finished in 21172 millis, 197KB/second.
Letting it run for 2 minutes...
jcp v02.02.04 built on Apr 11 2009

Resetting jaguar...
.
Write the zeros back to bank 1
.
jcp v02.02.04 built on Apr 11 2009

Sending...
..
Waiting for erase to complete (about 18s)..
Cart ROM:  Skip 8192 bytes, base addr is $802000, length is 4186112 bytes
Sending........................................................................\
...........................................................
Jag accepted start request at $00802000.

Finished in 21188 millis, 197KB/second.
jcp v02.02.04 built on Apr 11 2009

Resetting jaguar...
.
Now dump bank 2 back...
.
jcp v02.02.04 built on Apr 11 2009

Using bank 2
Beginning dump to 'test.bin'...
Sending...
Waiting to handshake with 68k (control-c to abort)

Receiving flash...
Closing file...

Dumped 4MB in 28s - 146KB/s
* Dump complete.
Diff the files...
jcp v02.02.04 built on Apr 11 2009

Resetting jaguar...
.
Write the zeros back to bank 2
.
jcp v02.02.04 built on Apr 11 2009

Using bank 2
Sending...
..
Waiting for erase to complete (about 18s)..
Cart ROM:  Skip 8192 bytes, base addr is $802000, length is 4186112 bytes
Sending........................................................................|
...........................................................
Jag accepted start request at $00802000.

Finished in 21219 millis, 197KB/second.
jcp v02.02.04 built on Apr 11 2009

Resetting jaguar...
.
!!!!!SUCCESS!!!!!
C:\WORK\jaguar\skunk\sources\bjlSkunkFlash>

