Z80-mbc2/v20-mbc/68k-mbc Virtual Disks - Copying Files

by coopzone in Circuits > Arduino

3194 Views, 6 Favorites, 0 Comments

Z80-mbc2/v20-mbc/68k-mbc Virtual Disks - Copying Files

s-l1600.jpg

In this guide I will show you how to copy files to and from the disk images on the SD card used with the z80-mbc2. This same method can also be used with the v20-mbc and the 68k-mbc, but you will need to work out the disk sets etc for the different OS's.

These image files will become the disk drives under CP/M when your system is running.

If your looking for information on disk formats for UCSD Pascal the try:

https://github.com/GmEsoft/Z80-MBC2_UCSDP


Supplies

You will need a micro-sd card reader.

If your computer does not have a SD-Card reader (not many do these days) you will need a USB-SD-card reader adaptor, normally only cost £2-£3 from online market sellers like ebay etc. Make sure you get one that accepts micro sd cards.

You will need a version of cmptools for your OS.

Linux:

Most distros will let you install cpmtools from the package manager, for example:

apt install cpmtools

Windows:

Download the file:

http://www.cpm8680.com/cpmtools/cpmtoolsWin32.zip

Unzip it to a directory on your hard disk, I suggest you choose something simple like c:\cmptools, the zip file already has the directory "cmptools" as part of the archive. So when you unzip it you only need to specify C:\ as the destination. Otherwise you will ned up with a double directory like C:\cpmtool\cpmtools.

Setup the Software

zzzzz Untitled.png
Screenshot at 2021-03-08 11-16-25.png

Linux:

(for debian based distributions such as ubuntu etc)

apt install cpmtools

Windows:

download, http://www.cpm8680.com/cpmtools/cpmtoolsWin32.zip

Right click the file in explorer and choose unzip to C:\ The software is already in a folder inside the zip file
called cpmtools, so you end up with c:\cpmtools.

Now we have the software installed it's time to copy the disk definitions file (Step two explains what this file is, but for now just copy it)

Put your SD card into your card reader.

Locate the folder on the SD card called "cpmtools" inside it you will find a file called diskdefs. Copy it to the same directory you created for cpmtools, windows. Or on linux it replace the file /etc/cpmtools/diskdefs, you can do that via the gui/desktop or from a shell prompt with "sudo cp diskdefs /etc/cpmtools/diskdefs"

You can now test your install by trying to get a cp/m directory of a disk image file, below are examples. If you get error messages like unknown format etc - you have not put the diskdefs file in the right place

Linux:

cpmls -f z80mbc2-d0 /home/derek/orig_mbc2/DS0N00.DSK 0:
asciart.bas
asm.com
autoexec.sub
autoexec.txt
d.com
......

Windows: (from a cmd prompt)

C:\Users\admin>c:\cpmtools\cpmls.exe -f z80mbc2-d0 e:\DS0N00.DSK 0:
asciart.bas
asm.com
autoexec.sub
autoexec.txt
d.com
.....

In both cases, the command run is cpmls (list files) with two options, the first one is "-f z80mbc2-d0", this says use this disk format "z80mbc2-d0" definition from the file diskdefs for this image file. The second is where to find the disk image file in this case DS0N00.DSK. The next section (2) gives a lot more details on these files and how they and used, for now all you need to see is a directory listing.

About the Disk Image Files

First a word of warning, if you use the wrong combination of format (the -f) with the disk image to try and copy files to them (not cpmls) it will almost certainly corrupt the image file. So make a copy first! then read twice before you type!

To be able to give you an authentic cp/m machine, the SD card has "disk images" on it, these are single large files that are opened as a disk letter in cp/m. Each file contains it's own cp/m file system and presents to the z80-mbc2 as a physical disk would have done on an original cp/m computer. By doing it like this you get the same facilities the original cp/m machines had and all the programs run without needing to mess around with permissions etc.

The disadvantage is that each image file needs a special program (cpmtools) that understands the disk layout inside the file (diskdefs) So you can't just simply copy a file.

Image files

The Z80-MBC2 maps the disks like A: B: C: etc. into the image files on SD card. With file names like:

DS0N00.DSK or more generically DSxNyy.DSK;

The file name has this naming convection to make it easy for the IOS (and users) to map the version of cp/m and the drive letter to use, like this:

DSxNyy.DSK

x = from 0 to 9 is the OS:

0 = CP/M 2.2

1 = QP/M 2.71

2 = CP/M 3

(the other os's like UCSD pascal etc use a different image name, not relevant to cp/m)

yy = the cp/m disk drive letter:

00 = A:

01 = B:

02 = C: and so on up to 15 drive P:

So if you boot into CP/M 3 and are logged on to drive B: you would be accessing the SD card image file called DS2N01.DSK

Diskdefs

It has a further complication in that cp/m reserves some of the virtual tracks in the image file depending on if it's a boot drive ie A: or not. Further this differs from version to version of cp/m.

The diskdef file contains the details for the image layout giving the virtual track / sector layout for each type of image on the SD card, the z80mbc2 has only 3 basic disk layouts. Each one has a section in the diskdef file and has been given a name, like this:

CP/M 2.2

A: disk image DS0N00.DSK, layout name z80mbc2-d0

B: -- P: (all other drives) DS0N01.DSK -- DS0N15.DSK, layout name z80mbc2-d1

QP/M 2.71

A: disk image DS1N00.DSK, layout name z80cpm-d0

B: -- P: (all other drives) DS1N01.DSK -- DS1N15.DSK, layout name z80cpm-d1

CP/M 3

All disk images A: -- P: DS2N00.DSK -- DS2N15.DSK, layout z80mbc-cpm3

Examples

Under cp/m 2.2 drive F: would be disk image DS0N05.DSK and you would specify a format (-f) of z80mbc2-d1, so a command to list the files would be:

cpmls -f z80mbc2-d1 /home/derek/orig_mbc2/DS0N05.DSK

The path for the image file would be different on your system.

Under cp/m 3 drive A: would be disk image DS2N00.DSK and you would specify a format of z80mbc2-cpm3, so a command to list the files would be:

cpmls -f z80mbc2-cpm3 e:\DS2N00.DSK

Notes

If you specify the wrong format the listing for a directory will be garbled, but if you do this on a disk write command (when you copy a file to the disk image) you will corrupt the image file!

Copy Files From the SD Card Image

So far we have used the cmpls command to view the files on the z80-mbc2 disk images.

To copy files you need to use the command cpmcp, In the text bellow we are copying from the SD card to a local file on your HD.

Linux

to copy the pip.com file from drive A: use

cpmcp -f z80mbc2-d0 /home/derek/orig_mbc2/DS0N00.DSK 0:pip.com . 
ls pip.com
pip.com

Windows

to copy the pip.com file from drive A: use

C:\Users\admin>c:\cpmtools\cpmcp.exe -f z80mbc2-d0 e:\DS0N00.DSK 0:pip.com .

C:\Users\admin>dir pip.com
Volume in drive C has no label.
Volume Serial Number is 0CCF-BD5F

Directory of C:\Users\admin

08/03/2021 13:53 7,680 pip.com
1 File(s) 7,680 bytes
0 Dir(s) 27,874,439,168 bytes free

In both examples above, the -f chooses the correct image format. That's followed by the filename and path of the image file. Then you name the you want to copy including the cp/m user area "0:pip.com". Then lastly the destination location the "." means current directory. You can choose a different filename for the destination you you want to.

Just be carful to choose the correct disk image and format as detailed in step 2, or you will get errors like "file not found", because the directory on the cp/m image will be garbled.

Copy New Files to the SD Card Image Disks

Be carful to choose the correct disk formats, check step 2. And it's a good idea to make copies of the image files before you copy to them.

In the text below we are copying a file called "new.txt" to the cp/m 3 drive F: image file. If the file already exists this command will fail with an error:

cpmcp: can not create 00atest.txt: file already exists.

the 00 indicates user area 0 under cp/m

Linux

cpmls -f z80mbc2-cpm3 /sd/DS2N05.DSK

cpmls -f z80mbc2-cpm3 /sd/DS2N05.DSK
0:
adv.com
advi.dat
advi.ptr
advt.dat
advt.ptr
....

sudo cpmcp -f z80mbc2-cpm3 /sd/DS2N05.DSK atest.txt 0:
(note the use of sudo, you must have root permissions to copy to the image.
If you forget the sudo it will fail silently!)

cpmls -f z80mbc2-cpm3 /sd/DS2N05.DSK
0:
adv.com
advi.dat
advi.ptr
advt.dat
advt.ptr
atest.txt
diskio.bas
.....
Note the new file atest.txt

Windows

C:\Users\admin>c:\cpmtools\cpmls.exe -f z80mbc2-cpm3 e:\DS2N05.DSK
0:
adv.com
advi.dat
advi.ptr
advt.dat
advt.ptr
diskio.bas

C:\Users\admin>c:\cpmtools\cpmcp.exe -f z80mbc2-cpm3 e:\DS2N05.DSK atest.txt 0:

C:\Users\admin>c:\cpmtools\cpmls.exe -f z80mbc2-cpm3 e:\DS2N05.DSK
0:
adv.com
advi.dat
advi.ptr
advt.dat
advt.ptr
atest.txt
diskio.bas

In both the above examples, the command, cpmcp, to copy files to the SD card image has three parts:

1= -f z80mbc-cpm3 format from diskdef file is for cp/m 3 disk images

2= /path/DS2N05.DSK - full path to the image file.

3= 0: cp/m user area 0, you can specify a different area if you want to and even a different filename for the destination, like 0:newfile.txt

Note

Read step 2 and understand the image files before you copy to them. And make copies, it's quick to do and easy to revert.

Use the cpmls command to verify it works ok, as in the examples above.

Further Info for Windows and MAC Users

Windows

If you don't want to use the command prompt it is possible to use a program called cpmtoolsgui from:

http://star.gmobb.jp/koji/cgi/wiki.cgi?page=Cpmtoo...

(may need to use google translate)

You still need the diskdefs file copied to the location of the program, the just for fun website has an outline on using these tools if you want more info: https://just-for-fun.org/z80-mbc2#how_add_files_in...

However, considering NON or what you do under cp/m uses a GUI - i do't really think all the clicking and mouse moving needed makes it worth while! Also, it's possible to include the command line tools in batch files etc to automate copying files to different SD cards. You can for example have a batch file to automatically copy a file to ALL version of cp/m in one go.

Wine for Linux

The above cpmtoolsGUI will work under wine on linux. But it's not easy to setup. All sorts of missing fonts etc, so good look.

MAC OS X

cpmtools can be installed on Mac OS X in serveral ways, by far one of the simplest methods is to use the program called BREW from https://brew.sh/ follow their instructions to setup brew.

go to a command shell and type:

brew update

brew install cpmtools

You will need to copy the diskdefs file to /usr/local/share/diskdefs