BB-88 runs Minix

This is a log entry about BB-88. See the project page to know more about it.

Minix logo Running Minix on BB-88 was certainly not part of my goals when I started this project, but at some point, seeing how I could get MS-DOS running, I thought I should at least give it a try.

Freshly booted Minix on BB-88

Now, although Minix can run in the very limited amount of memory a 8088 can address, that's not exactly the ideal setup, and there are limitation. Thankfully, most shortcomings are covered in the FAQ:

Minix Installation

Without a floppy disk interface, the only way for me to install Minix was to transfer an existing system onto a Compact Flash. My first tentatives to install it inside a QEMU virtual machine did not go well because of this bug in the floppy drive emulation in QEMU.

This is where the disk images of Minix QD prepared by David Given came to the rescue. I went straight to the Minix 1.7 image and didn't even bother playing with the Minix 2.0 one. I booted it in QEMU with the following command:

/usr/bin/qemu-system-i386 \
    -monitor stdio \
    -cpu 486 \
    -k fr-be \
    -machine accel=kvm \
    -m 64 \
    -hda /path/to/minix-qd-1.7-hd-64MB-test.img \
    -boot once=a,menu=off \
    -net nic \
    -net user \
    -rtc base=localtime \
    -name "Minix QD 1.7.5"

That allowed me to have a quick look at the content of the image, then I transfered it to a new Compact Flash and started BB-88. At this stage, I spent an insane amount of time chasing red herrings, trying to get it past the bootloader. In the end, all these issues were caused by not only one, but two defective Compact Flash cards! Once I switched to a known good Trancend one, the MBR executed fine, the partition boot sector executed fine and loaded the monitor, that I could interrupt by pressing ESCape.

Booting Minix

I needed to be able to interrupt the monitor to change the boot parameters. The Compact Flash might be IDE compatible, it is at a non-standard base address, and it uses what's referred to as the 'Chuck mod'. This is a change that improves the performance of the IDE interface on an 8-bit bus, but the software needs to be adapted accordingly. Instead of making all the changes in the at_wini driver in Minix, I instructed Minix to use the BIOS functions to access the disk.

>hd=bios
>boot

It looked like it was able to start, but after the initial loading, the screen would stay desperately empty.

Back in the VM, I edited /etc/ttytab to enable the console on the serial line so that I could get a shell, then re-imaged the Compact Flash and booted BB-88 again, this time to be greeted with a login prompt in Minicom! I got Minix running on my breadboard computer!

Armed with my serial console, I quickly found the cause of the black screen: my BIOS wasn't setting the I/O port address of the CRTC in the BIOS Data Area. Minix's console driver uses this to determine whether the console is color (CGA) or monochrome (MDA) when there's no EGA or VGA adapter. Once the firmware was fixed, the console came to life and worked beautifully.

Some improvements and a new font

With the system running, it was time to play with it and take advantage of BB-88's hardware.

The first, simple, change was to make a Belgian keymap. That was reasonably straightforward.

The second modification was to make the console use a slightly different video mode, showing 30 lines of text in 640x480 instead of the 25 lines shown in 640x400. It was a good warm-up for the next step, and I had to rebuild and reboot on the new kernel quite a few times before I got it working correctly.

Then, building upon that freshly acquired knowledge, I decided to adapt and improve the loadfont program. This required modifications in console.c and tty.c part of the kernel. To avoid interfering with the existing code for the more standard video adapters, the boot parameter 'video' must be set explicitely to 'bbga'. This is handled in glo.h and start.c.

In BB-88, the character generation ROM is actually a RAM, mapped in memory at address 0xA0000. Four different fonts can be stored in memory, each in its bank, and two bits of the Mode Register are used to select the active bank. My version of the loadfont program leaves the default font untouched in bank 0 and uploads the new font in bank 2. This ensures an easy way back to a readable console in case the loaded font is all garbled.

But the new feature I like the most is that it also reprograms the CRTC to adjust the display to the height of the new font. With this 12x8 font, I now get 40 lines of text instead of the classic 25 lines. I also had to implement the actual support for the change of geometry of the console, making sure the tty's winsize structure was correctly updated every time a new font was loaded.

The file console.c from the Minix kernel, opened in vi, displayed on BB-88 with a custom
font, in all its 40 lines glory

You can download the font if you like it. This is a text-mode font that you can open in Fontraption.

I now have a nice Minix environment that I can use on BB-88, in addition to MS-DOS. So, what's next?