Commodore‎ > ‎C128‎ > ‎

Fast Serial for µIEC

Jim Brain has produced a small and effective mass-storage device for Commodore computers called the µIEC/SD. This device is really tiny (as it was designed to be embedded inside a Commodore computer case). It reads SD cards and connects to the serial bus (it also has a connection to the cassette port for power). It supports standard (slow) serial protocol and also some 'fastloader' protocols popular with the C64. The most common is probably JiffyDOS.

In order to take advantage of the faster speed of the JiffyDOS loader, you normally need JiffyDOS ROMs in your Commodore computer. Another way is with a software solution for C128 users called JiffySoft128 (or JLOAD128). Although this works, it must be loaded into RAM before it can be used -- and there is always the possibility the RAM will be overwritten by a program (resulting in a system crash).

However, the C128 was designed with a hardware solution to improve loading over the serial bus, appropriately called fast-serial. The uIEC was designed with the possibility for fast-serial in mind, but an official version that supports fast-serial has not been released. So I thought I should share the version I created.

  Features  
  • Supports burst-load (normal in C128 mode)
  • Supports sector burst-read and -write (normal in CP/M mode)
  • Supports most of the BCIS commands (all of the 1571)
  • Still supports other fastloaders (like JiffyDOS)
  • Still supports standard (slow) serial (normal in C64 mode)
I have not had any problem using it on my C128, and others have reported it works for them as well. However, some have reported a problem when using it with the C64 and datasette. It works fine for me in C64 mode, but I do not own a datassette. Another thing to consider before installing this firmware in your uIEC is that it is based on an older release, so it does not support the new GEOS drivers.
 
You can download the firmware update here. Copy this file to the root directory of an SD card. With the computer and uIEC turned off, insert the SD card and power on the system. The uIEC will update the firmware -- you will know because the drive light will rapidly flash for several seconds as the firmware is updated. If you would like to see how it works or want to improve it, you can download the source code here.
 
With fast-serial installed in your uIEC, you no longer need to worry about running JLOAD or installing new ROMs in your C128 to enjoy very fast load speeds. Faster than the C1571 or C1581. And of course an SD card can hold a LOT more data than a floppy disk. Enjoy!

 

  Testimonial  
I have been using this now for over a year without any problem, but don't take my word for it. Listen to this report by C128 Alive! forum member, tokra:
...it's like upgrading from a 1541 to a 1571. My C128 is back to speed again! It seems like a shame to use Jiffy DOS when the C128 has Fast Serial by design...

Definitely one of the coolest advances in retro-computing lately :-)

If you've ever suffered with a C1541, you know what he is talking about. I would also like to point out that the improvement is relative to a C1571, which is to say, a uIEC with fast-serial is much faster than a C1571, it is even faster than a C1581 and CMD-HD!  If that doesn't impress you, then I guess nothing will :) Just so you know I'm not quoting out of context, you can view the entire forum thread here.

 

  Theory  
Although I had a lot of experience programming the C128 and C1571 and had read many publications from CBM, MOS, and third parties when I started this project, there were still a few suprises.  In particular, there were 3 suprises you may find to be an interesting read.
 
First off, the documentation I have read about fast-serial always implied to me (it was never fully explained) that the host controller (usually the C128) would send a Host Request Fast (HRF) signal at the start of any serial-bus command.  Serial bus commands (as opposed to normal data) are identified by the activation of the Attention (ATN) serial bus line before the data bits are sent.  So, I always assumed (based on the description) that the HRF signal was sent after ATN was activated but before the command was sent.  However, in programming the Atmel processor of the uIEC, I soon discovered that this is wrong.
 
To understand how this misunderstaning occurred, look (below) at the best diagram of fast-serial protocol I could find by Commodore Business Machines (from the C1571 Users Guide, page 91).  You should note it does not even show the ATN line or mention the HRF signal.  So naturally I had to assume their words was correct.
 
Not-so-informative diagram of fast-serial protocol by Commodore Business Machines
For your education, I made up a more complete diagram.  Below you can see that the HRF signal is sent before the command is ever started!  This should be a concern for anybody who wants to write software/firmware to support fast-serial because there is no warning that information is about to be sent on the DATA line, the CLK line is left undefined, and there is only an after-the-fact activation of ATN to imply that an HRF signal was previously sent.  I think that is a bit strange...
A diagram of Host Request Fast on the fast-serial bus, as I understand it
 
To summarize the diagram, the following things occur (you can follow allong if you disassemble the C128 KERNAL starting at $E358):
  1. The DATA line is released (presumably it will go to +5V).
  2. The C128 sends $FF on the fast-serial line which keeps DATA at +5V but toggles SRQ 8 times.
  3. The C128 waits 128 microseconds.
  4. The Command begins by pulling ATN and CLK to 0V.
  5. The C128 waits 1000 microseconds (slightly more if the VIC-II screen is not blanked).
  6. The device (C1541, C1571, etc.) should pull DATA to 0V
  7. The C128 checks DATA and reports DEVICE NOT PRESENT if it has not been pulled down to 0V.
  8. The C128 releases CLK (it should go to +5V).
  9. The C128 waits for DATA to be released
  10. The device may send Device Request Fast (DRF) signal
  11. Once DATA is released (C128 will wait forever), it checks the CIA to see if the device supports fast-serial
  12. The C128 sends the command using slow-serial protocol (even if device supports fast-serial)
  13. The C128 waits a moment for the device to acknowledge command by pulling DATA down to 0V.
  14. The C128 may release ATN (if the command is complete)
There are several things to note in this process.  To start, I don't think it is very efficient; it seems like 192 microseconds (about 10%) could be saved if the C128 sent the HRF signal during the 1000 microseconds that it is waiting for the 'device present' signal.  Maybe there is a good reason for that.  More importantly, you should next see that in step 10 the device may send a 'Device Request Fast' signal.  It seems that the C1571 never sends this during the first command byte.  That makes sense to me because the first command byte specifies the device number; remember there can be multiple devices on the serial bus and it would be wrong for the C1571 (or other fast-serial device) to send DRF before it knows it is the device that the C128 wants to talk to!  Finally, relating to step 14, the C128 may release the ATN line if the command is complete.  As just mentioned the first command byte specifies the device, while the second command byte (if any) specifies the secondary address.
 
The second interesting thing about fast-serial protocol is that the DATA is inverted.  During slow-serial, the DATA voltage parallels the bit value, so 0V = 0 and +5V = 1, but during fast-serial transmission it is opposite: +5V = 0 and 0V = 1.  Interesting detail but not difficult to understand.
 
The third interesting fact of the fast-serial protocol is the bit order.  During slow-serial, the data bits are sent low-bit-first (little endian), but during fast-serial protocol the data bits are sent high-bit-first (big endian).  Another interesting but not difficult concept.
 
Sorry if that is a bit too technical, but hopefully you learned something.  I sure did! 

 

  More  
If that wasn't enough geek speak, then you may want to check out this article by Pasi Ojala.  There he describes the problem with fast-serial and C64 and datasette with genuine CBM hardware (relates to the datasette problem mentioned earlier).  More importantly, it tells how people with C64 instead of C128 can modify their machine to use fast-serial protocol as well.  Of course you will need a special loader (provided) to take advantage of fast-serial, so it then becomes like SJLOAD or any other fast loader for the C64...

© H2Obsession, 2011, 2012

Comments