Pages

Friday, 23 August 2013

Resurrecting the OS-9/68K (OSK) kernel using the FAME 68K Emulator

The Motorola 68000, sadly, is mostly a relic nowadays. It had a beautiful instruction set and a clean architecture, from software all the way down to the bus protocols. Alas, all good things must pass...

However, there was a damn good operating system written for this CPU which I just can't stand to see die slowly, rotting on lost floppy discs and SCSI drives. The OS of which I speak is the OS-9 RTOS by Microware: a microkernel which was originally written for the Motorola 6809 CPU as a contract from Motorola to showcase their new CPU (most famously used on the Tandy Color Computer, various GIMIX systems, the Sharp X68000 series in Japan, and the Fairlight/CMI synthesizers of the early 80s), then ported to the Motorola 68k series of processors, the x86, ARM and Hitachi SH series, amongst others.

This operating system has been really short-changed by history. Ask most programmers which consumer (non-mainframe/UNIX/'big-iron') system was able to do multitasking and/or timesharing; you'll usually get answers of the Commodore Amiga, or the PC, or the Mac. They're all wrong. OS-9 was doing this in 1979, before the Commodore 64 even existed, with a full-fledged UNIX-style shell environment and all of the flexibility that philosophy brought with it, in less than 64 kilobytes!

The folks at Microware really should be legends in the industry for their forward-thinking software. Applications, device drivers, the kernel, and even instances of devices were all modules using an object-based structure that could be configured at boot time, then subsequently reconfigured at run-time, as modules were added or removed, with no reboots. Hmm, it only took, what, twenty-plus years, for other mainstream desktop operating systems to achieve this (and imperfectly)?

With that in mind, I now place here a small lifeline for this amazing operating system in the hopes it will be preserved (and perhaps improved...)

OS-9/68k 'RUSSBOX' Emulator Proof of Concept

This uses the FAME/68K emulation library under Cygwin to boot an OS-9 68000 'idealized' abstract system of my own design (by 'abstract', I mean a system which doesn't correspond to any 'real' historical system and is as simple as possible for the purpose of booting OS-9).

--
BUILDING AND RUNNING THE RUSSBOX OS-9/68K (TEST EMULATION):

Requirements
--
Windows XP or newer
cygwin

From the cygwin prompt in your home directory:

$ git clone git://tripe.blitter.com/git/os9_68k_sdk_v12.git MWOS
$ cd MWOS
[This gives the pristine MWOS OS-9/68k port dev tree, sans Hawk UI cruft, etc.]
$ git checkout origin/rlm-sys-1
[This switches to a branch which adds the virtual 'RUSSBOX' support files:
  MWOS/OS9/68000/PORTS/RUSSBOX - plus some .d/.a files to support the virtual
  hardware in higher directories within MWOS/...]

$ git submodule add git://tripe.blitter.com/git/rlm-sys-1.git \
     OS9/68000/PORTS/RUSSBOX/rlm-sys-1
[This is the emulator itself, using FAME 68k library]

$ cd OS9/68000/PORTS/RUSSBOX

$ . ./mwos_env.sh

[open a second cygwin terminal]
$ cd MWOS/OS9/68000/PORTS/RUSSBOX/rlm-sys-1/
$ stty -echo -icanon -icrnl -inlcr min 1 && nc -u 127.0.0.1 8800

[return to first cygwin terminal]
./run.sh

[switch to second cygwin terminal]
[press ENTER]
[You should see a RomBug: prompt.]
[Type [.],[ENTER] to see 68k registers]
[Type [g],[ENTER] to start boot]
[After a few seconds you should see the OS-9 '$' prompt.]
[Type some common OS-9 commands, eg 'devs', 'free', 'mdir', 'dir']

NOTES

The backspace/del key doesn't work.. the terminal via UDP is primitive and the exact setup for 'stty' above can probably be improved to at least let through delete properly.

Typing CTRL-C on the OS-9 terminal also terminates the stty connection, rather than transmitting CTRL-C through to the OS-9 target.

** NOTE after typing CTRL-C to interrupt the UDP terminal, one must type blindly:

stty echo

.. to turn on echo for the cygwin shell again.

Eventually I would like to write a dedicated UDP terminal + emulator 'front panel' that can pass all ascii codes through properly, and integrate in other ways with the virtual target (such as some way to show the virtual framebuffer, I/O, etc.)

While rudimentary this serves as a demonstration that the FAME/68k emulation library is sufficiently accurate to fully bootstrap and run the OS-9 68000 kernel and as such we can preserve the OS-9/68k operating system in an environment which will never be subject to the ravages of time, dying hardware etc. :)

rlm-2013-08-22

20 comments:

  1. Great work! Too bad Motorola didn't beat Intel on the desktop. 68k/CPU32 forever!

    ReplyDelete
  2. I absolutely love the work you've done with OSk and FAME.

    I too am interested in the preservation of OS-9. I took a bit different tact: I used the OS-9/x86 (OS-9000) eval CD, a bit of elbow grease, and some work-arounds with some PC emulators to produce a working OS-9000 VirtualBox image. I never got MAUI working, but networking and NFS is all set.

    My HD image includes the native-hosted Ultra C compiler, as well.

    The current line of thinking, when I get some real time to dig in, is to port os9exec (or perhaps create something similar) to OS-9/x86, thereby allowing OS-9/68k applications to run on OS-9/x86.

    I'm not super-familiar with the Windows-hosted MW tools, or Cygwin for that matter. If you have the time, I'd appreciate any pointers you could give in what would be needed to integrate the two MWOS trees for 68k and x86. Hopefully this weekend I'll get a bit of time to diff some things and figure out if the Windows bins are even the same versions and so forth.

    And of course, if you'd like a copy of the x86 stuff, you are welcome to it.

    ReplyDelete
    Replies
    1. Yes, I would definitely be interested in trying out the x86 virtualbox image! Great to hear someone has gotten that working with networking as well.

      As I understand it, OS-9000 was written mostly in C, so the codebases may not be easily integrated. The cross compile tools are all DOS so I don't know if one would be able to build OS-9 68k modules from the OS-9000 environment if that's what you mean...

      Anyway yes please contact me about it :)

      Delete
    2. This comment has been removed by a blog administrator.

      Delete
  3. Hello,

    I have a practical and industrial application for an OS9 68040 emulator, and a project to develop it. Could you please contact me to discuss?

    ReplyDelete
  4. Your git repo isn't connecting (connection refused). Is it gone forever?

    ReplyDelete
    Replies
    1. Should be fixed now. Note the git repository paths had to change slightly, I have updated them in the post.

      Delete
  5. Came across this recently and I must say I'm very interested. So far, I haven't been able to get anything to compile. Will continue to work on it.

    ReplyDelete
    Replies
    1. What error do you get trying to build? I haven't touched this in a while but I'll try to help if you can give more details.

      Delete
  6. DangerRuss: first of all, thank you very much for this post! I'm working on a legacy industrial system which uses a 68k CPU and OS-9. I've been looking high and low for a way to emulate the hardware and am cloning your git repo as I write this. Would you be open to chatting over email about your work on the 68k/OS-9 platform? I'm a dedicated embedded engineer by day and software mercenary part-time trying to rapidly gain knowledge... and reading over your profile I think we may have a lot in common.

    ReplyDelete
  7. Hope you get this, it seems google in general is having conniptions tonight (or maybe it's this laptop I'm using).

    Anyways... sure, fire off a mail to me at 'rmagee' at gmail... I haven't worked on this in around two years to be honest (since shortly after posting it). But I'd be happy to answer any questions, perhaps it'll kick my butt to do some more work on it.

    Try it out and let me know if the instructions above work for you.

    What OS-9 system are you working on? I haven't worked on real 68k hardware in many years now sadly.. but perhaps something here can help you.

    ReplyDelete
  8. Is the os9_68k_sdk_v12 file still available?

    ReplyDelete
    Replies
    1. Hi, sorry -- blogger apparently is broken for Firefox now and I had to load up Chromium to reply to you! Sheesh.

      It was a firewall issue, please try pulling the git repo now.

      Delete
  9. Hi Ppl! I own an old Bosch Motortester and found that it runs on OS-9000. I have lots of floppies containing the OS. Can anybody give me a hint how i can make images of those floppies? DD under linux does not work. ;-)
    Thanks a lot

    frank

    fk@man-kat1.org

    ReplyDelete
    Replies
    1. Hi, if your OS-9000 box still boots and runs, you can make images of the disks by following the guide here:

      https://docs.google.com/document/d/1_7Y6i06PLMXfMX0sFKhO8L_IMEOu0F56Vb61dmVOzMg/edit?usp=sharing


      You'll need a Windows box and a good term program that supports zmodem and/or kermit (TeraTerm Pro is what I used).

      Delete
    2. Here is a link to the utils I used from Linux many years ago to read OS9 disks. They use the linux 'fdrawcmd' to achieve a low-level read of the physical media.

      https://drive.google.com/open?id=0ByNvoX1GE59_NWhIY29UMnJCbnc

      Credit to Bob van der Poel for writing this.

      NOTE you'll also need 'fdrawcmd', part of the 'fdutils' package. It's available from Debian, or source is in git here: git://anonscm.debian.org/collab-maint/fdutils.git

      Delete
  10. Hi Russ
    Very nice job.
    I tried the:
    git clone git://tripe.blitter.com/git/os9_68k_sdk_v12.git MWOS

    but it times out.
    Any way to get a copy ??
    Also, the guy , who made OS9000/x86 run in Virtual Box, can he be contacted ??
    Ole

    ReplyDelete
    Replies
    1. Hello, apologies for the delay. git repos should now be back online.

      Delete
  11. Ack, my server appears to be down -- and I'm out of town until Tues the 10th of January! My apologies. I'll see if I can get things up again as soon as I get back.

    I can ask the gentleman who has been tinkering with OS-9000 if he'd be OK with me connecting you two, sure :)

    Happy New Year!

    ReplyDelete