OSI Disk Tool  a floppy disk read/write utility for Ohio Scientific Computers

The OSI Disk Tool is the next stage of development after OSI Dump, a utility to transfer OSI disk contents through the serial port to a remote computer.  The OSI Disk Tool adds the ability to write disk contents stored on a remote computer back to an OSI diskette while maintaining the functionality of the original OSIDump utility. It is compatible with all OSI systems with a floppy interface such as C1/C2/C4/C8 and C3 serial systems.

OSI Dump sends all data received on an OSI disk track including garbage bytes, however the timing/position of the data is lost.  There are various delays on the diskette between index hole, track headers, and sectors of data that are important to reproduce the disk image.  The OSI Disk Tool is able to recreate the lost timing data, allowing disk contents to be recreated from previously dumped data. In addition, it can identify noise/garbage bytes and remove them before write. It also removes trailing filler bytes. It effectively does a clean operation on the data before writing to the target disk.

OSI Disk Tool is compatible with OS65D, OS65U, HexDos, and variations of the OS65D format used with Dos/65, PicoDos, OSI CPM V1.4, CPM V2.22, UCSD p-System, and the OSI boot track on both 5.25 and 8 floppy disks.

For write operations, data is only sent from a host computer using the Xmodem/CRC protocol.  This block transfer format gives a robust way of transferring data, with the ability to pause transfers to write disk tracks when necessary.  TeraTerm ( https://sourceforge.net/projects/tera-term/) works well on PCs.

Uploaded disk contents need to be in OSI raw image binary format, HEX format or HFE etc. is not supported.


Operation
Ensure you have a working serial connection from your host computer to the OSI as this program is controlled via the serial port. *Important* Set serial word format to 8N2 (8 bit, no parity, 2 stop bits). OSI Disk Tool requires at least 16K working memory.

Begin by entering the ROM monitor on the OSI after reset.  Press 'M' at the H/D/M or D/C/W/M prompt. 
On video based systems press 'L' to begin load, send disktool.lod as raw ASCII from your terminal program.
For serial based systems send disktool.65a as raw ASCII from your terminal program. When loaded the program should start automatically, if not <reset>, press 'M' and then 'G' to start.

The program loads beginning at address $0300, which is also the start location.
To restart on video based systems, enter the ROM Monitor M Enter . 0 3 0 0 G
To restart on serial based systems, press G in the ROM monitor or enter:
L012D 03 00 RG  to reinitialize the Go vector

Once running you can switch the serial word format to 8N1 which speeds up transfers.

You should see the following menu on your terminal:

MemTop=$7FFF


 OSI Serial Disk Tool
----------------------
1. Dump Raw Image
3. Receive Disk Xmodem
4. Select Drive
5. Set Drive Type
6. Set Serial Divisor
7. Xmodem/Hex xfer opts
8. Exit
L. View log
W. Write DiskTool to Disk
T. Test Read Disk

Drv=A/5.25 @2MHz  Baud@1x Xmdm
--->

What does the status line show?
Drv=A/5.25 @2MHz  Baud@1x Xmdm
Drv= shows currently select disk and disk size
@2MHz shows calculated CPU speed
Baud@1x shows baud rate divisor (/16 = 1x  /1 = 16x)
Xmdm shows current transfer selection (Xmodem/XmodemCRC/HEX)
MEMTOP = $xFFF reports the highest page active. Not all bytes on all pages are tested, just the highest xFF which passes R/W test. (So you could still have bad RAM at some locations which would go undetected.)

Option 1. Dump Raw Image
Use this to transfer a disk image from the OSI to a remote computer.  By default OSI Disk Tool communicates via Xmodem.  
The dumped data contains the contents of the track except for the last 4 bytes, which contain the high water value for the number of bytes received, stored as a value in the last two bytes in low high order, and XOR of that value in the 2 bytes preceding that.  For instance if the last 4 bytes contain 58 F7 A7 08, the disk controller read 08A7 bytes of data, the XOR of that is F758.
You can cancel transfer by pressing ESC or ^X during dump.
Use HEX dump to see the bytes read from the disk in a more verbose manner.

Option 3. Receive disk [via] Xmodem
Ensure the selected disk type matches your system 5.25" or 8" (option 5), insert a writable disk in the drive then select option 3. Receive disk Xmodem' from the menu to begin transfer.  
Send the desired disk image via XMODEM from your terminal program.  

Video systems will display progress information on the OSI screen during transfer
All systems can view the information after transfer by pressing l (log).

You can cancel transfer by pressing ESC or ^X or aborting transfer with your terminal program.

Option 4. Select Drive
Choose the disk drive you want to access A-D (0 to 3)

Option 5. Set Drive Type
Change from 5.25 to 8 disk drive types.

Option 6. Set Serial Divisor
By default the OSI ACIA (serial port) is set to internally divide the incoming baud rate by 16. So an OSI with a 300 baud serial port is clocked at 4800 baud internally.  This option allows you to change the divisor from 16 to 1, speeding up serial I/O by 16x.  You must change the baud rate of your host computer when you change this setting.  Note: speeding up your serial port from 9600 to 9600x16 (153,600) baud will probably not result in reliable operation.

Option 7. Xmodem/Hex xfer opts
Use this option to change the method of transmission for Dumping Raw Images, and the Xmodem protocol for all transfers. By default the transfer will be set to Xmodem (Checksum).  Use this option to switch to Xmodem/CRC  or Hex data dump instead. 

Option 8. Exit
Returns to ROM monitor/Resets the OSI.

L. View Log
The log is created when writing disk images, it contains the results of the transfer along with any verify errors that may occur.  This information is shown on the display for video based OSI systems in addition to being added to the log.   For serial systems the log is the only way to see the status of write operations. The log uses available RAM above the disk buffers, currently $4500+

What does the status/log information show?
When you write disks, OSI Disk Tool will indicate what type of data it has encountered such as the following:
Write Track 0 boot 2052...OK
Write Track 1 65D  1/5 2/5 3/1 2835...OK
Write Track 2 65D  1/11 2825...OK
Write Track 3 65D  1/11 2825...OK
Write Track 4 65D  1/11 2825...OK
Write Track 5 65D  1/2 2/1 3/2 4/1 5/1 6/1 7/1 8/1 2604...OK
Write Track 6 65D  1/2 2/1 3/2 4/1 5/1 6/1 7/1 8/1 2604...OK
Write Track 7 65D  1/1 2/1 3/1 4/1 5/1 6/1 7/1 8/1 2092...OK
Write Track 8 65D  1/1 2/1 3/1 4/1 5/8 3101...OK
Write Track 9 65D  1/11 2825...OK
...

It shows the track number, the recognized track format, the sector number, /, and sector size in 256 byte pages (for OS65D) and the number of bytes written. A blank sector indicates a blank track with no sectors, however track header is present because the 65D type was indicated.
Possible track formats are boot, 65D, 65U, HexDos, and ??.  
?? indicates a blank/corrupt or unidentified format.  Track data will be written as received, however no timing delays will be incorporated into the written data. This could make disks readable but not update-able/writable in the future. It generally indicates corrupted data.

W. Write Disktool to disk
Disktool will create a bootable copy of itself to the currently selected drive. This makes it faster to create a bootable copy then sending the program as a disk image again.

T. Test Read Disk
Use this to quickly tests disk readabiliy & track length. 
It will display recognized track types & it will also measures the track length and index hole size in bit lengths.
When using this function it will display something like 
"Drive capacity is 24990 bits/track 610 bits index length 5.25" drive" before analyzing and displaying the track data.

This means it did a disk controller test to see how many bits could be written (while the disk was not in write mode) for one complete rotation of the disk. It also indicates the duration of the index pulse.
I find my Gotek to return "Drive capacity is 25990 bits/track 240 bits index length 5.25" drive" and my real drive "Drive capacity is 24940 bits/track 400 bits index length 5.25" drive"

400 bits * 1000 / 125000 bps  on 5.25" floppy  = duration of index hole in milliseconds = 3.2 or more easily: bits index length/125 for 5.25  (or /250 for 8")

At 300RPM the ideal bits/track would be 125000 bps clock *.2 (time of 1 rotation in seconds) = 25000 so we could calc RPM  or something.  But I really just wanted a way to determine index hole duration.

These displayed numbers aren't too useful by themselves, but they can be converted to more useful values. I just didn't want to add the math routines that handle 16bit multiplication & division.... yet


Limitations
OSI Disk Tool may be confused by OS65D type disks with malformed sectors (too small, too large or invalid sector numbers). Garbage in, garbage out!
After write, data is reread from the disk, processed, and compared to the track in memory. If the comparison fails, it will attempt to write again 3 times until it gives up. Since the data comparison is done with a raw read, it is possible a Parity Error could be present in the data but ignored.  Its likely the disk data would be corrupted anyway. If you are having problems, ensure your disk drive operates correctly. Try using David Gessweins OSI Floppy Disk Test program to verify proper operation. http://www.pdp8online.com/osi/osi-floppy-test.shtml  Also clean your disk heads!  Old floppies can leave quite a residue!

There is no verification of floppy disk types.  If you have an 8 disk and write using 5.25 settings the operation will complete successfully, however the disk will most likely be unusable. If you reverse the condition, OSI Disk Tool will not be able to identify the disk type, so tracks will be written as unknown. 

The OSI dump format contains more space per track than is normally available on real disk drives. If you attempt to write random data to a disk there will likely be data loss near the end of each track as it is truncated by hardware limitations.  Usually one half-page (128 bytes) less than track length can be successfully written to real disk drives.

It is important to have correctly sized disk images when writing disks.  8 drives require tracks with $F00 (3840) bytes per track or 295680 bytes per disk. 5.25 drives require $900 (2304) bytes per track or 92160 bytes per disk. Technically you can write any data to the floppy, short files will end writing early, long file transfers will be terminated when the disk is full.

Dumping disk images
When reading OSI disks you have the option of transferring the data in hexadecimal dumps or with Xmodem.  Xmodem transfer is recommended because the amount of data sent is 3x smaller, and even with overhead, is more than 2x faster to transfer!
The data transferred is all the data read from the disk after the index hole has passed. The track buffer is initialized to 0 before read.  The last two bytes of the track buffer indicate the maximum number of bytes read from the disk before the index hole at the end of the track.  OSI disk images can contain garbage bytes before and after track data when the disk ACIA is initialized or the write signal is terminated.

OSI Dump Format
Due to limitations of the disk interface, all OSI disk data must be read through the incorporated serial port chip.  Thus the dump file contains only the bytes stored on the disk without timing information.
For 5.25 disks the dump file consists of 40 tracks of 2304 ($900) bytes of data.
For 8 disks the dump file consists of 77 tracks of 3840 ($F00) bytes of data.
The last two bytes contain the number of bytes read from the disk in Hi, Lo order. The two bytes previous to those contain the XOR of the last two bytes as verification.

Mark Spankus 10/2020 

Revision History
V1.0 Initial Release
V1.1 Rework Xmodem, fix bugs  Add standard Xmodem transfer option to be compatible with Mac/Linux lrzsz communications library.
V1.2 Correct xmodem bugs
V1.3 Check for CANcel returning from writing track
V1.4 Fix Hex dump Reading Message
7/13/2022 Added DiskTool5 and DiskTool8 floppy disk images for faster booting


V2.0 Added self-write, Test Read and fixed a few errors.

