USB for RC

Let your Z80 talk directly to enumerate and operate many different types of USB devices

USB for RC

Bring your RCBus/RC2014 build into the 90’s with true native support for Universal Serial Bus. Enable the Z80 drivers in a new RomWBW ROM images and then connect your system to:

There are plans to update the software to further improve keyboard support, and add support for other USB devices, such as USB to Centronics adapters for dot matrix printers, ethernet adapters, and other useful USB devices.

General Description

This is a kit based on the CH376 USB Module.

The CH376 module provides a high level interface for connecting to the most common mass storage devices, but that interface is limited and will not work through hubs. The CH376 module also supports driving the USB communication directly, enabling the ability to operate any compatible USB device. The drivers I originally wrote for MSX-DOS have been ported to RomWBW. These drivers, written in C for the Z80, fully support enumerating and discovering the attached USB devices, and enable the Z80 to understand the ‘USB Protocol’ directly.

Key features

Images

Testing Status

The correct interfacing with any USB device is mostly limited by the software drivers that have been specifically written to enable appropriate support under MSX-DOS/NEXTOR. So any limitation or issue can probably, once identified, be corrected with a software update.

There has certainly not been any USB certification conducted. Just lots of manual testing by me. There are possibly still things in the software that are not following the rules.

Hot swapping of devices is not supported. Insert your USB devices then power on or reset. You can change floppies, but unpluging and re-inserting any USB device will require a reboot

Please note, that due to some timing limitation of the CH376 mode, some devices or the module itself, may fail to get detected on initial boot/power-on. Hit the reset button and it should be detected fine.

There are 4 main USB classes implemented to date:

SCSI: Flash/Thumb and HDD drives

  • I have tested against 9 different Thumb/flash drives of varying sizes.
  • Tested against a couple of external magnetic hard disk drives.
  • A couple of modern USB keyboards

UFI: Floppy drives

  • I have tested against 3 USB 3 1/2" floppy drives. They each operated slightly differently. For the most part they all work.
  • I did experience some specific compatibility issues with these drives - but so did windows, so I suspect its more limitations of the specific drives.
TEAC drive - purchased on ebay. Seems to be the most common available today
  • Recommended
  • Can format, read and write to 720K and 1.44MB (Please note formatting is not currently supported on RomWBW nor CP/M)
IBM drive - Seems to be an 'older' TEAC drive internally
  • can read and write 720K and 1.44Mb disk
  • formatting was unreliable - 720K formatted does not seem to be supported (Please note formatting is not currently supported on RomWBW nor CP/M)
Imation drive - Old drive
  • read/write 720K disk ok
  • does not support HD 1.44MB
  • formatting not tested (Please note formatting is not currently supported on RomWBW nor CP/M)

USD Hub

All but one of the hubs tested works. All but one of the hub seemed to have been ‘certified’.

Orico 4 Port USB 3.0 Transparent Hub
  • Highly Recommended
  • externally powered which is really recommend if using floppy disks
Generic USB hubs
  • all tested ok

What’s included in this kit

The full kits includes everything you need (PCB, capacitors, IC sockets, CH376S module, connectors, and the ICs). And an optional small Flash drive that’s been tested and confirmed to work.

Bill of Materials

Count Name
4 0.1uF
1 220uF
3 1N4148
2 3mm leds
1 4.7kΩ (3mm)
2 470Ω Resistor (3mm)
1 CH376S USB Module
1 74HCT138
1 74HCT32
1 74HC74
2 Right Angle 1x20 Header
2 14 POS IC SOCKET
1 16 POS IC SOCKET
1 512MB USB Flash Drive (optional)
1 PCB

What else do I need to make this work?

Updating RomWBW

You will probably need to update your image of RomWBW. Please refer to the official instructions for updating and flashing the ROM at https://github.com/wwarthen/RomWBW

The configuration changes you will need to set are describe below:

CHENABLE       .SET FALSE ; DISABLE THE CH375 FLASH ONLY DRIVER
CH0USBENABLE   .SET FALSE ; DISABLE THE CH375 FLASH ONLY DRIVER
CH1USBENABLE   .SET FALSE ; DISABLE THE CH375 FLASH ONLY DRIVER

CHNATIVEENABLE .SET TRUE  ; CH376: ENABLE CH376 NATIVE USB DRIVER
CHSCSIENABLE   .SET TRUE  ; CH376: ENABLE CH376 NATIVE MASS STORAGE DEVICES (REQUIRES CHNATIVEENABLE)
CHUFIENABLE    .SET TRUE  ; CH376: ENABLE CH376 NATIVE UFI FLOPPY DISK DEVICES (REQUIRES CHNATIVEENABLE)
CHNATIVEFORCE	 .SET	TRUE	; CH376: DISABLE AUTO-DETECTION OF MODULE - ASSUMES ITS INSTALLED

At this time, the USB drivers are not on the mainline (master) of RomWBW - you can use my fork of the project https://github.com/dinoboards/RomWBW/tree/dean-ch376-usb-native-5 to build an image for your system.

As the CH376 native driver code size is quite large compared to many other HBIOS drivers, you may need to disable other drivers in your configuration (such as IDEENABLE, FDENABLE, SDENABLE)

To enable the USB Keyboard, you will also need a TMS/V9958 video adapter installed and its driver enabled. The keyboard driver is a sub part of the general CRT interface. The keyboard does not replace the serial input.

TMSENABLE    .SET TRUE           ; TMS: ENABLE TMS9918 VIDEO/KBD DRIVER (TMS.ASM)
TMSMODE      .SET TMSMODE_MSXUKY ; TMS: DRIVER MODE: TMSMODE_[SCG|N8|MSX|MSXKBD|MSXMKY|MBC|COLECO|DUO|NABU|MSXUKY]
                                 ; USB KEYBOARD WITH MSX COMPATIBLE VIDEO
TMSTIMENABLE .SET TRUE           ; TMS: ENABLE TIMER INTERRUPTS (REQUIRES IM1)

USBKYBENABLE .SET TRUE           ; USB KEYBOARD DRIVER

Once booted into CP/M over serial, you can type the following command to switch to the Video output and keyboard input:

STAT CON:=CRT:

Please note the software driver for the Keyboard is still under development - and not all keys will be mapped, and characters may get dropped if you type too fast.

Port Mapping

The board use the following IO addresses

Port Description
$88 (r/w) CH376 data port
$89 (r/w) CH376 command port
$8A (w) LED control (bit 0 and 1 only)
$8B (w) mirror of $8A

Resources

Disclaimer

Please note that this is a kit, produced by a non-expert (me) for hackers, DIYers’ and retro lovers, to tinker with. Please exercise caution and follow good safety practices. You will be working with sharp knives, a hot soldering iron, and small metal components. Be mindful of the risks involved in the build process. I will do my best to answer any questions you may have.

This kit is provided as-is, with no guarantees or warranties. By assembling and using this kit, you acknowledge that you do so at your own risk. The creator cannot be held responsible for any damage, injury, or loss that may occur during the assembly or operation of this kit.