Running Alan Cox’s Fuzix OS on a Z80 emulator

This past Halloween, Alan Cox announced Fuzix OS, a project for building a UNIX-like operating system for 8 bit computers, based on UZI sources. This OS targets a number of physical machines, both old and homebrew computers, and some emulators too.

The easiest and more approachable way for trying Fuzix OS is running it on cpmsim, which comes bundled inside the Z80pack package. If want to give it a try the easy way, just continue reading.


Getting and building SDCC and Z80pack

SDCC (Small Device C Compiler) is an specialized C compiler for microcontrollers. For building SDCC, we’re going to need some other software packages on our distro:

  • GCC (I’m not sure if an specific version is need. As refernce, I’ve used 4.8)
  • GCC C++
  • bison
  • flex
  • boost-devel

We’re also going to check out an specific revision from SVN, as the latest tarball lacks some features required by Fuzix. Once checked out, the usual configure & make recipe will do the trick:

svn checkout http://svn.code.sf.net/p/sdcc/code/trunk sdcc-code -r9145
cd sdcc-code/sdcc
./configure --prefix=/usr --disable-pic14-port --disable-pic16-port
make
sudo make install

As for Z80pack, the procedure is pretty similar, but this time the latest tarball is enough:

wget http://www.autometer.de/unix4fun/z80pack/ftp/z80pack-1.24.tgz
tar xzvf z80pack-1.24.tgz
cd z80pack-1.24/cpmsim/srcsim
make -f Makefile.linuxc
cd ../srctools
make

Creating Fuzix OS disk images

Now it’s time to get our hands dirty with the code we’re really interested in. The build process is still a bit crude, but improving day by day. Let’s see:

git clone https://github.com/EtchedPixels/FUZIX.git
cd FUZIX/Standalone
make
cd ../Kernel
sed 's/TARGET=.*/TARGET=z80pack/' Makefile > Makefile.tmp && mv Makefile.tmp Makefile
make

At the moment (probably, this is going to be fixed in a near future), we need to manually copy the userspace library to an specific location (/opt/fcc):

cd ../Library
make
cd libs
make
cd ..
sudo mkdir -p /opt/fcc/lib /opt/fcc/include /opt/fcc/bin
sudo cp -a libs/crt0.rel libs/c.lib libs/syslib.lib /opt/fcc/lib
sudo cp -a include/* /opt/fcc/include
sudo cp -a tools/fcc tools/binman tools/syscall /opt/fcc/bin

Now we can continue building the userspace utils and putting everything together inside two disk images:

cd ../Applications/util
make
cd ../../Kernel/platform-z80pack
./createdrives

At this point, you should have two new files named drivea.cpm (a floppy disk with the kernel and a small number of binaries) and drivei.cpm (a hard disk for mounting on /usr with the binaries that doesn’t fit on the floppy) inside Kernel/platform-z80pack.
Running Fuzix OS!

Now we just need to copy both disk images to $Z80PACK_PATH/cpmsim/disks and start the simulator. In my case, as I’ve put the sources for Z80pack on $HOME/sources/z80pack-1.24, I just need to do this:

rm $HOME/sources/z80pack-1.24/cpmsim/disks/drive*
cp drivea.cpm drivei.cpm $HOME/sources/z80pack-1.24/cpmsim/disks
cd $HOME/sources/z80pack-1.24/cpmsim
./cpmsim

You should be greeted by Fuzix, asking you for a boot device:

slp@linux-zz59:~/sources/z80pack-1.24/cpmsim> ./cpmsim

####### ##### ### ##### ### # #
# # # # # # # # ## ##
# # # # # # # # # # #
# ##### # # ##### ##### # # # #
# # # # # # # # #
# # # # # # # # # #
####### ##### ### ##### ### # #

Release 1.24, Copyright (C) 1987-2014 by Udo Munk

CPU speed is unlimited

Booting...

-
FUZIX version 0.1
Copyright (c) 1988-2002 by H.F.Bower, D.Braun, S.Nitschke, H.Peraza
Copyright (c) 1997-2001 by Arcady Schekochikhin, Adriano C. R. da Cunha
Copyright (c) 2013-2015 Will Sowerbutts <will@sowerbutts.com>
Copyright (c) 2014 Alan Cox <alan@etchedpixels.co.uk>
Devboot
480kB total RAM, 416kB available to processes (15 processes max)
Enabling interrupts ... ok.
bootdev:

Enter 0 as boot device, log in with as root, and mount the hard disk on /usr.

bootdev: 0
Mounting root fs (root_dev=0): OK
Starting /init
init version 0.8.1ac
06login: root

ssh# mount /dev/hda /usr
05ssh# id
05uid=0(root) gid=0(root)
05ssh# banner FUZIX
FFFFFFF U U ZZZZZZZ I I X X
F U U Z I X X
F U U Z I X X
FFFFF U U Z I X
F U U Z I X X
F U U Z I X X
F UUUUU ZZZZZZZ III X X
ssh#

That’s it. Now you can start playing around, getting familiar with Fuzix at its code. If you like the feeling, the beauty of the 8 bit simplicity, then perhaps you’ll consider running it on a physical machine, like one of the N8VEM boards, or Will Sowerbutts’ FPGA based socz80 (if you have a DE0-nano board, you can try my port to this hardware).

Happy (8 bit) hacking!

18 thoughts on “Running Alan Cox’s Fuzix OS on a Z80 emulator

  1. Can you please inform how to make the Javascript language work with this operating system. It is necessary to support the Javascript language for proper operating system operatings.

    1. Heh, good one 🙂

      But, hey, trying to build a Javascript interpreter that fits into 48K could be a fun exercise. I’ll try to keep this in mind for a future boring evening.

  2. Thanks for the post. I followed your post but I am getting this…

    FUZIX version 0.1
    Copyright (c) 1988-2002 by H.F.Bower, D.Braun, S.Nitschke, H.Peraza
    Copyright (c) 1997-2001 by Arcady Schekochikhin, Adriano C. R. da Cunha
    Copyright (c) 2013-2015 Will Sowerbutts
    Copyright (c) 2014-2015 Alan Cox
    Devboot
    480kB total RAM, 416kB available to processes (15 processes max)
    Enabling interrupts … ok.
    bootdev: 0
    Mounting root fs (root_dev=0): OK
    Starting /init

    panic: no /init
    System halted, bye.

    help?

    1. I’ve just tried again, and it works here. Did “Applications/util/init” build successfully?

      I also advise you to check out revision “14b844a063e08bdffec00c7b094a34151d2dbf10” from FUZIX’s repo, since it’s changing a lot these days, and sometimes is partially broken.

      1. Should have wrote this earlier. I got this error Ubuntu 1204, then I tried it on Arch and it works fine. Thanks.

        1. Did you figure out what was wrong? I get the same error on my macbook. While everything (after some tweeking) compiled fine.

          1. No, not really. Luckily, I had an Arch Linux VM at hand, so I did not bother to take a look inside.

  3. Continued… I did some debugging, I think its failing at this check

    if (!((getperm(ino) & OTH_EX) &&
    (ino->c_node.i_mode & F_REG) &&
    (ino->c_node.i_mode & (OWN_EX | OTH_EX | GRP_EX)))) {
    udata.u_error = EACCES;
    goto nogood;
    }

    in Kernel/syscall_exec.c

  4. Getting the following:
    bootdev: 0
    Mounting root fs (root_dev=0): OK
    Starting /init
    init version 0.8.1ac
    06login: root

    ssh# mount /dev/hda /usr
    05mount: Unknown error
    ssh#

  5. Finally got FUZIX to boot after fixing some undefined globals in the user space programs. _toupper did not get linked even thought it seems to be present in syslib. This kept several important programs, including init, from building. Finally got it straightened out by inserting a macro for toupper into the files that would not build. Boots perfectly now! Thanks for your efforts with this project. I grew up on CP/M and 8-bit systems and I have always had a soft spot for them.

  6. Further: drivea.dsk image wouldn’t build at first because it got filled up before all the user space programs could be copied to it. Had to move rmdir to drivei.dsk

  7. You actually make it seem so easy with your presentation but I
    find this matter to be actually something which I think
    I would never understand. It seems too complicated and very broad for
    me. I am looking forward for your next post, I’ll try to get the hang
    of it!

  8. I have made it a bit easier for those who have problems to build them self. You’ll find ready to use disk images at the z80pack repository, that I build from time to time. This is just to have a look about the project status, you definitely should learn to build it your self.

Leave a Reply

Your email address will not be published. Required fields are marked *