Lab Manual Appendix

A-2: USB-to-serial Adapter HOWTO

Setting Up the Serial Port

To use the USB-to-serial adapter in Windows, a driver must first be installed. The USB-to-serial adapters use the Prolific PL-2303 chipset for high compatibility with a wide range of serial devices. The adapters have been tested and work well with Windows XP and Windows Vista. While they may work well in other versions of Windows as well, this guide is only for Windows XP users. The USB-to-serial adapters have not been tested on Windows Vista; however, a driver is available for Windows Vista and it seems to work well. Linux users will find a working Prolific USB-to-serial adapter driver in the kernel (called USB_SERIAL_PL2303). On the lab computers, this driver is provided for you—plugging the adapter in should let it "just work."

  1. Download the Prolific USB-to-serial drivers from http://spakov.com/ha. (You may optionally use another version if you wish.) If you are a Windows Vista user, download the Windows Vista version of the drivers from http://spakov.com/hb.
  2. Unzip the downloaded file and run the PL-2303 Driver Installer.exe program. If you are a Windows Vista user, you should execute the downloaded program.
  3. After driver installation is complete, plug in the USB-to-serial adapter to a USB port. Let Windows detect the device and load the correct driver.
  4. Open Device Manager by choosing "Run…" from the Start menu and entering

    mmc %systemroot%\system32\devmgmt.msc

    and clicking OK. If you are a Windows Vista user, click the Start button and open Device Manager by entering the same command in the "Start Search" box and pressing Enter. You may need to allow Windows User Account Control to permit the action.
    Device Manager

    The Device Manager window.

  5. Expand the "Ports (COM & LPT)" node by clicking the small plus sign to the left of the node's name.
  6. Notice the "Prolific USB-to-Serial Comm Port" node. This is the USB-to-serial adapter. If the COM port number is 16, then you're done. Otherwise, continue with these instructions.
  7. Locate the node called "Prolific USB-to-Serial Comm Port" and open its properties by right clicking the node and selecting "Properties…."
  8. In the resulting window, select the "Port Settings" tab if it is not already active. Make sure the selected options match those in the picture below. Click the "Advanced…" button.
    Properties

    The "Prolific USB-to-Serial Comm Port" Properties window.

  9. In the Advanced Settings window, select COM16. This will allow moka5 to access the COM port. Also make sure that the options match those in the picture below. Click OK when you are done.
    Advanced

    The Advanced Settings window.

  10. Apply settings and close any remaining windows.

Caveats Thanks to Windows

Obviously, to use the USB-to-serial device, you must first determine the device's Windows COM port number. By following this guide, you have assigned COM16 to the USB-to-serial adapter. Unfortunately, because of design decisions related to the development of Windows, the device will probably be assigned a different COM port number every time you plug it in. Additionally, this COM port number is often unreasonably high (in my case, my adapter was assigned COM44 for no apparent reason). Because of this, it is probably necessary to check the adapter's COM port number before each use.

Using the Serial Port with Linux

Serial devices in Linux are traditionally named ttyS0, ttyS1, ttyS2, and so on. These devices, like all devices on a Linux system, would traditionally be located in the /dev/ directory. However, USB-to-serial adapters are not handled by the standard serial port driver in Linux—instead, as mentioned above, the PL2303 driver handles these. Instead of showing up in /dev/ttySn, USB-to-serial devices are named /dev/ttyUSBn. Therefore, this device name should be used in Linux instead of ttySn.

So, to conclude, on the lab computers, you should use /dev/ttyUSB0 as the serial device name.

Using m6811load with a USB-to-serial Adapter

Using the --port command-line option with m6811load allows you to specify which serial port to use for communicating with the HC11. For example, if your USB-to-serial adapter is located at /dev/ttyUSB0, then you could upload simple.s19 to the HC11 by using a command similar to this one:

m6811load --port=/dev/ttyUSB0 simple.s19

You can also use -p instead of --port to specify the serial port to use:

m6811load -p /dev/ttyUSB0 simple.s19

The /dev/ portion of the serial port specification is optional. Therefore, you could accomplish the same using:

m6811load --port=ttyUSB0 simple.s19

or, the shortest form:

m6811load -p ttyUSB0 simple.s19

If you do not specify a serial port device, m6811load will use /dev/ttyS0 as the default device. In Cygwin, it is difficult to say whether or not this will end up corresponding to your USB-to-serial adapter. Therefore, you should always use the --port option to specify the correct port. However, if you are using a system with a built-in serial port (i.e., most older desktop PCs), Cygwin's ttyS0 device probably points to this port.

Run

man m6811load

for details about m6811load's command-line options. You can also execute

m6811load --help

for a more brief summary of m6811load's command-line options.

Using the Serial Port with moka5

Assuming you have followed these directions so far, the USB-to-serial adapter should be present on your Windows system at COM16. The CS3432 virtual machine is configured to automatically connect the serial port at COM16 to the virtual machine—however, there is a caveat. The virtual machine sees the serial port as a "real" serial device, not as a USB-to-serial adapter. Therefore, the virtual machine will connect any Windows serial port at COM16 to the virtual machine at /dev/ttyS0.

What does this mean for you, the student? It's simple: you don't need to use any --port option with m6811load since the default (/dev/ttyS0) is automatically mapped to the correct serial port. In theory, as long as the USB-to-serial adapter is connected before you start the virtual machine, it should "just work."

Note: You should always have the USB-to-serial adapter connected in Windows as COM16 before you start the virtual machine. If you connect the adapter while the virtual machine is running, you will receive an error message. The reason for this is that the virtual machine is trying to connect the USB-to-serial adapter as /dev/ttyUSB0. Ordinarily, this wouldn't be a problem—however, the USB implementation of VMware (which powers moka5) is such that the USB-to-serial adapter will only work while it is connected as a native Windows device (COM16).

Using the Serial Port with Cygwin

As mentioned before, under Linux, serial devices are traditionally called ttyS0, ttyS1, ttyS2, and so on. These devices, like all devices on a Linux system, would traditionally be located in the /dev/ directory. Since Windows uses COM ports instead of these device names, Cygwin uses a creative way to allow serial devices to be referenced using their COM port numbers. Cygwin does not maintain any /dev/ directory at all. Instead, it automatically monitors system calls to devices and emulates a /dev/ directory for devices that actually exist. This means that while no /dev/ttyS0 device node actually exists in Cygwin, if a serial port is found, Cygwin may allow access to it using /dev/ttyS0. However, this presents a problem: which ttySn devices in Cygwin correspond to which COM devices in Windows?

Cygwin has solved this problem cleverly by allowing users to reference devices using their Windows COM port numbers. Like its ttySn device emulation, Cygwin also recognizes devices such as /dev/com1 or /dev/com8, for example. Naturally, these correspond to COM1 and COM8 in Windows, respectively. However, Cygwin only supports up to 16 COM ports (COM1, /dev/com1 through COM16, /dev/com16). This is why it is necessary to assign the USB-to-serial adapter a new COM port number if Windows assigns it a number above 16. We have chosen COM16 as the port number we'd like you to use.

To summarize, instead of referencing a serial device using a /dev/ttySn device, use a /dev/comn device instead. For example, if your USB-to-serial adapter is assigned COM port number 16 (COM16) in Windows, you would use the /dev/com16 device to reference it in Cygwin.


A-1: Commonly Used UNIX Commands A-2: USB-to-serial Adapter HOWTO A-3: Using minicom