Menu

Home

Paul Osmialowski

zxmmcfid: A ZXMMC mass storage device FID driver for CP/M

This is a FID driver for the CP/M Plus system enabling access to the specific IDEDOS partitions created on a ZXMMC mass storage. Note that since the FID drivers are loaded at a very late stage of the CP/M Plus startup process, the software described here does not enable you to boot CP/M Plus from ZXMMC storage, you still need to boot it from a floppy disk or a Gotek device.

Constraints

  • supports slot 0 only
  • up to 8GB MMC cards (cyls/2/128 C/H/S geometry only)
  • PLUSIDEDOS partition table only (starting at sector 0 or sector 128)
  • partition table must be terminated with the UNUSED partition (IDEDOS type 0)
  • up to three partitions (searched by name), static drive letters assignment:
C: CP/M
D: SOFTWARE
E: DEVEL
  • searching partitions by name is case sensitive (upper case names only!)
  • searching through 16MB +3DOS (IDEDOS type 3) partitions only
  • giving up on searching at the first UNUSED partition (IDEDOS type 0)
  • can fall into an infinite loop if there are more than 2040 partitions

Building it

First on UNIX:

$ pasmo --prl zxmmc.asm zxmmc.fid

...then on CP/M:

> fidcsum zxmmc.fid

(get fidcsum.com from https://www.seasip.info/Cpm/software/fidcsum.com).

After the preparations described above, copy zxmmc.fid file to your bootable CP/M floppy disk (or a bootable .dsk +3 disk image for being booted from a Gotek device). Note that CP/M Plus system can be booted only from the A: drive.

WARNING! Don't use Gotek's jumper solution to force it to be A: drive! This can smash your onboard disk controller! If you really need your Gotek device to become A: drive, equip your Spectrum computer with a hardware A/B drive switch as described on this page: https://zxnet.co.uk/spectrum/floppy_drive_swap.

Using it in the FUSE emulator

The best machine for using ZXMMC device is the ZX Spectrum +3e, therefore it is recommended to pick this one from the Fuse - Select Machine menu (or ensure such selection through FUSE command line switches).

To use ZXMMC mass storage emulation with FUSE, download a set of +3e ROMs from this address: http://www.worldofspectrum.org/zxplus3e/files/p3eroms.zip and unpack them to some meaningful place, e.g. $HOME/fuse/roms. They will be used later to start the emulator with FUSE-compatible disk image.

Prepare MMC card (or FUSE-compatible disk image)

A single MMC card can be shared by many operating systems (+3DOS, CP/M, Fuzix, etc.) using various partitioning schemes. Namely, an IDEDOS partition table (used by +3DOS and CP/M) can exist alongside a MS-DOS partition table (used by e.g. to hold Fuzix partitions).

IDEDOS partition table uses C/H/S addressing and +3e's +3DOS uses 24-bit unsigned integer values for C/H/S addresses (16 bits for cylinder number, 8 bits for combined head and sector number, always reporting two heads and 128 sectors per head), therefore, with each sector being 512-bytes in size, the biggest supported MMC card or disk image is 8GB (65536 cylinders, two heads, 128 sectors per head).

ZXMMC FID driver looks for an IDEDOS partition table at the very first sector (sector 0) of a disk (MMC card). If it cannot be found there, the driver attempts to find it in the 128-th sector. This allows having two partition tables on a disk (MMC card), a standard MS-DOS partition table and an IDEDOS partition table with
all its IDEDOS partitions created in the first primary MS-DOS partition starting at the sector 128. This is compatible to the +3e's +3DOS behaviour.

To prepare an MMC card (or FUSE-compatible disk image) suitable for being shared between +3DOS, CP/M and Fuzix, follow these steps:

  • Create empty raw image (256MB should be sufficient for a demonstration purpose):
$ dd if=/dev/zero of=256MB.rawimg bs=268435456 count=1
  • Create MS-DOS partition table (follow example fdisk session given below):
$ fdisk -c=dos 256MB.rawimg

Welcome to fdisk (util-linux 2.33.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
DOS-compatible mode is deprecated.

Created a new DOS disklabel with disk identifier 0xfbeb3b95.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (63-524287, default 63): 128
Last sector, +/-sectors or +/-size{K,M,G,T,P} (128-524287,
 default 524287): +419967

Created a new partition 1 of type 'Linux' and of size 205.1 MiB.

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 19
Changed type of partition 'Linux' to 'unknown'.

Command (m for help): p
Disk 256MB.rawimg: 256 MiB, 268435456 bytes, 524288 sectors
Geometry: 255 heads, 63 sectors/track, 32 cylinders
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xfbeb3b95

Device        Boot Start    End Sectors   Size Id Type
256MB.rawimg1        128 420095  419968 205.1M 19 unknown

Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (63-524287, default 63): 420096
Last sector, +/-sectors or +/-size{K,M,G,T,P} (420096-524287,
 default 524287): +65535

Created a new partition 2 of type 'Linux' and of size 32 MiB.

Command (m for help): t
Partition number (1,2, default 2): 2
Hex code (type L to list all codes): 7e

Changed type of partition 'Linux' to 'unknown'.

Command (m for help): p
Disk 256MB.rawimg: 256 MiB, 268435456 bytes, 524288 sectors
Geometry: 255 heads, 63 sectors/track, 32 cylinders
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xfbeb3b95

Device        Boot  Start    End Sectors   Size Id Type
256MB.rawimg1         128 420095  419968 205.1M 19 unknown
256MB.rawimg2      420096 485631   65536    32M 7e unknown

Command (m for help): n
Partition type
   p   primary (2 primary, 0 extended, 2 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (3,4, default 3): 3
First sector (63-524287, default 63): 485632
Last sector, +/-sectors or +/-size{K,M,G,T,P} (485632-524287,
 default 524287): +8191

Created a new partition 3 of type 'Linux' and of size 4 MiB.

Command (m for help): t
Partition number (1-3, default 3): 3
Hex code (type L to list all codes): 7f

Changed type of partition 'Linux' to 'unknown'.

Command (m for help): p
Disk 256MB.rawimg: 256 MiB, 268435456 bytes, 524288 sectors
Geometry: 255 heads, 63 sectors/track, 32 cylinders
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xfbeb3b95

Device        Boot  Start    End Sectors   Size Id Type
256MB.rawimg1         128 420095  419968 205.1M 19 unknown
256MB.rawimg2      420096 485631   65536    32M 7e unknown
256MB.rawimg3      485632 493823    8192     4M 7f unknown

Command (m for help): w
The partition table has been altered.
Syncing disks.

In the example above, a MS-DOS partition table was created with three primary partitions. The first one (type 19, starting at sector 128) is a placeholder for IDEDOS partition table along with IDEDOS partitions. The second one (type 7e, size 32MB) is suitable for Fuzix operating system. The third one (type 7f, size 4MB) is for Fuzix swap.

Optionally, you can now copy Fuzix root filesystem (usually held in an image file named rootfs-z80-32) to the partition starting at the sector 420096 with the following command:

$ dd if=rootfs-z80-32 of=256MB.rawimg bs=512 seek=420096 conv=notrunc
  • Find where your MMC card is visible in your system (use dmesg and/or
    fdisk -l commands to figure it out) and copy the disk image to the MMC card
    (in the following example, MMC card was found to be /dev/sdc):
$ sudo dd if=256MB.rawimg of=/dev/sdc
  • If you want to use this disk image with FUSE emulator, you need to convert it
    to the HDF format (use raw2hdf command from fuse-utils):
$ raw2hdf 256MB.rawimg 256MB.hdf

Now you can start FUSE for +3e emulation with downloaded ROM's, ZXMMC mass storage emulation and a bootable CP/M's .dsk +3 disk image (below is a single long line):

$ fuse -m plus3e --zxmmc --zxmmc-file 256MB.hdf \
    --rom-plus3e-0 $HOME/fuse/roms/mmcen3e0.rom \
    --rom-plus3e-1 $HOME/fuse/roms/mmcen3e1.rom \
    --rom-plus3e-2 $HOME/fuse/roms/mmcen3e2.rom \
    --rom-plus3e-3 $HOME/fuse/roms/mmcen3e3.rom \
    ZXCPM3A.dsk

Create an IDEDOS partition table and the partitions

Enter +3 BASIC from the +3e power-on menu and type following command:

FORMAT TO 0, 16

Example above creates an IDEDOS partition table and sets upper limit on the number of partitions to 16. Note that although one can set this limit as high as 65535, ZXMMC FID driver may hang on an infinite loop while traversing more than 2040 partitions, hence avoid creating more than that.

Having IDEDOS partition table, you can now create IDEDOS partitions, e.g.:

NEW DATA "CP/M", 16
NEW DATA "SOFTWARE", 16
NEW DATA "DEVEL", 16

Partitions created above will be recognized (by their names and the 16MB of size per each) by the ZXMMC FID driver for the CP/M Plus operating system which should assign them C:, D: and E: drive letters respectively. Note that in order to be recognized by the FID driver, these partition names must be given all uppercase (partition names are case sensitive). Also keep in mind that 16MB is the upper limit for an IDEDOS partition size.

While being created, these partitions are also formatted for the CP/M filesystem (which is also used by +3DOS).

Create more partitions for any other uses, according to your needs. Alternatively, you can first create partitions of your interest and place CP/M Plus partitons after yours. Namely, you can create bigger disk image or use MMC card with bigger capacity (2GB at least), ensure that the IDEDOS partition table can hold at least 128 partitions and run Workbench +3e installer to let it create all the partitions it requires for its operation and create CP/M Plus partitions after them. Make sure that the UNUSED partition is always at the end of IDEDOS partition table (usually, +3DOS called by +3 BASIC takes care of that).

The number of partitions that IDEDOS partition table can hold may seem to be large, yet keep in mind that they are usually formatted for CP/M filesystem that don't have directories. Therefore partitions are used to group files. Namely, Workbench +3e creates extensive number of partitions which are visible as 'folders' in its GUI.

Keep in mind that the FUSE emulator holds all of the disk writes in the RAM memory, the changes are not written until explicitely commited. Use Media/IDE/ZXMMC/Commit menu option whenever you need your changes to become permanent.


MongoDB Logo MongoDB