Saturday, February 5, 2022

Getting stuff onto the Amiga 500, or "holy crap please include bootstrapping serial file transfer utilities in your OS"

Yes, I know I'm ranting about 1980s OSes, but to be quite frank, modern OSes on a variety of hardware still have a similar problem.

Wait, what do I mean you ask? Surely you will always have ethernet/wifi/USB available? I almost started writing a bit on that here given I end up working behind the scenes on modern hardware and a LOT has to be working before you can talk over the network or, heck, even boot your device. But I'll leave that for another day.

This is a similar thing to what I found in a previous blog post about boot-strapping an old PC/AT before I had useful media (read: disks and other working machines.) It's doubly tricky for the Amiga because of it's non-standard floppy disk format that can't be easily read on PCs, let alone written to. You need to have another Amiga, or some modern multi-format disk interface like the Catweasel. I lucked out and at least got working Workbench 1.3 Main and Extra disks with the Amiga 1000 I picked up - but no working Kickstart disk, hence why I'm working with the Amiga 500 right now.

Anyway, the goal of this is to get the following to work:

  • Figure out how to transfer a simple program to get a single binary over in a useful way;
  • Transfer a small enough program over to do xmodem/ymodem/zmodem;
  • Use that to bootstrap the tools to write disk image files to an Amiga 880K disk; and
  • Also write out a working Kickstart 1.3 disk for my Amiga 1000.
This is... surprisingly annoying to do.

Firstly, how to get the initial files over. Workbench didn't come with a file transfer program, even with AmigaDOS. xmodem was around in the late 70s so it could've been used. Oh well. Luckily the Extras disk includes AmigaBASIC which can speak to both the disk and the serial port. And there are guides out there for how to write a simple non-error-checking binary receive program - I used this one.

I also needed to make a null modem cable up. Now, the Amiga 500/1000 used some of the RS-232 port pins for things other than ground, so it's best you make one of your own. Here's what I used for my Amiga 500.



The Amiga 1000 uses a reversed serial port, and I will figure out that particular hilarity once I get it booting with Kickstart.

However! Not everything was, err, well documented. I remember Amiga stuff in the 90s, but not THAT well.

First up - the receive.bas program in the above link doesn't at all set the serial parameters. So before you start it you need to run the Serial preferences program and configure it up. It also assumes that you're using 1024 byte buffers, so you need to do the following:
  • Set the speed - I used 9600, it's somewhat reliable here;
  • 8/N/1, which is already setup;
  • Buffer size 1024 bytes, not 512 bytes;
  • Hardware flow control!
Then yes, on the linux side I did the same (stty 9600 -parenb cs8 crtscts -ixon -ixoff raw iutf8 -F /dev/ttyUSB0).

Ok, then running the program. It's best you get the data going into the ram disk, so set your file target as RAM:filename. Easy.

Except the block size thing. Apparently with the way AmigaBasic speaks to the serial driver the transfers have to be in block sized blocks, not just the file size. So you need to pad the file you're sending. The receive.bas program will write out the correct length for you.

I did something like this:

  • dd if=file bs=1024 conv=sync > /dev/ttyUSB0
That padded it correctly and .. well, after a few attempts I can get a ~ 20k binary to transfer OK.

Then comes the fun part, what to transfer. I started by transferring lharc. However, apparently the later versions don't work with Workbench 1.3! I had to use https://aminet.net/package/util/arc/LhA_e138 .

It took a few goes, but yes, I got a working lharc tool on the floppy disk.

Next up is transferring something less terrible to transfer files with. A lot of things are lha'ed, which is why I spent a lot of time trying to get lha to transfer. Next time I won't, I'll unpack them on the linux sending host and send the binaries.

I needed a small transfer program to work on Workbench 1.3. I found https://aminet.net/package/comm/term/amigaterm . It's small, it runs on Workbench 1.3 and it has xmodem support. Nice!

However! It's xmodem support doesn't ask for the receive file size, so it rounds it up to the nearest block size. No! Things like lha then don't seem to work right and binaries certainly don't run.

Ok, so how'd they do it in the 80s/90s? It turns out there's a little utility called "fixobj" which tries to find the actual end of a binary object inside a file and truncates it there. I unpacked https://aminet.net/package/misc/fish/fish-0010 and grabbed the small binary from it. Now I can transfer individual programs, like https://aminet.net/package/disk/misc/adf2disk11, to write out an ADF image to disk.

So, that's transferring right now upstairs via xmodem at 9600. Yeah it'll take a while. Luckily 901120  bytes (the size of an ADF image) is exactly 7040 blocks of 128 bytes each, which is what xmodem is using. Thus I should be OK without having to truncate stuff.

Once that's done I can start transferring things to get the IDE disk add-on I have here booting, and I can setup the rest of this Amiga 500 to do fun things.

What I think would've made this easier?
  • Some tiny xmodem program that can be transferred over serial relatively quickly, and can receive exact file sizes (ie it'll truncate the last block if needs be)
  • A program to actually truncate a file at a given offset so you can use amigaterm as-is to transfer files slowly but reliably, and then just manually truncate it to where it needs to be in order to use it.
  • ... and then some less tiny but working zmodem program that'll work with Workbench 1.3 to get files on and off the thing.
In any case I'm hoping by tonight I'll have this thing writing out ADF disk images OK albeit slowly, and I'll see if I can get zmodem working on something faster like 19200 baud.

1 comment:

  1. Remember kermit. I believe it had very small implementations for bootstrapping, though you'd need to trawl the archive.
    https://www.kermitproject.org/archive.html
    (Amiga is listed as an older C-Kermit port)
    Unlike ?modem it doesn't need 8-bit clean lines which was an advantage in the day...

    ReplyDelete