AmigaOS 4.1 installation on QEMU pegasos2 machine

Introduction

The pegasos2 machine is available in QEMU since v6.1.0 and was improved in v8.0.0 to be able to run AmigaOS 4.1 PegasosII version but installation is not as straightforward as on real hardware. This is because the PegasosII AmigaOS 4.1 install CD does not have a graphics card driver that matches any of the video cards emulated by QEMU, so booting the install CD will not produce video output. To make it work, a suitable graphics driver has to be added to AmigaOS Kickstart to make it possible to boot and install it. This can be done in several ways. My first idea was to create a USB boot image or modify the CD. This was tested and documented by Rene Engel in this document. This page describes an alternative method that creates the boot partition on the hard disk image before the installation so no change to the CD is necessary. This still needs the firmware ROM image from a real machine but an even simpler method using BBoot is now available that works without any ROM and is now the recommended way instead of the one described here.

Prerequisites

  1. AmigaOS 4.1 Pegasos II version. Preferably 4.1 Final Edition (Pegasos2InstallCD-53.54.iso) but older 4.1 versions should also work (tested with 4.1 Update 1 Peg2InstallCD-Upd1.iso). This is commercially available from Hyperion Entertainment or retailers,
  2. A QEMU version with pegasos2 machine (minimum v6.1.0), v8.0.0 may be required for ARM64 hosts such as macOS on Apple Silicon Macs and since PCI cards such as an ethernet interface do not work with pegasos2 in earlier QEMU versions the latest version is recommended on other hosts as well. See main page for details..
  3. Pegasos II firmware ROM is needed for AmigaOS boot loader. This is not distributable due to copyright reasons but was available in a firmware update named up050404 (see here) and can be extracted using this script.
  4. The siliconmotion502.chip driver for AmigaOS Kickstart, at least version 53.9 or newer. This can be found in the Sam460ex version or in AmigaOS4.1Update3.lha update for original AmigaOS 4.1 (not FE) version. This driver also needs PCIGraphics.card version 53.9 or newer which is already on 4.1FE Pegasos 2 install CD but for older AmigaOS 4.1 versions this also needs to be updated. A new enough PCIGraphics.card version can be found in AmigaOS4.1FinalEditionUpdate1.lha update. The latest SM502 driver is available on OS4Depot but version 53.12 does not work with 4.1FE without updates so cannot be used with a 4.1FE install CD. This driver can only be added after installing 4.1FE Updates 1 and 2 after first using older 53.9 driver for installation. See this page for reference on Kickstart file versions in different AmigaOS 4.1 versions and updates.
  5. Some way to create disk image file with RDB partitions and FFS filesystem. This could be an AmigaOS version running on sam460ex or UAE. The HDToolBox in AROS should also work but when creating RDB partition table it puts it in sector 1 instead of sector 0 which does not work with pegasos2.rom so it may not be suitable at the moment. We will use rdbtool and xdftool from amitools below but you can do the same by any other way you are familiar with.

Step 1: Preparing boot files for QEMU pegasos2

  1. Copy the amigaboot.of, bootloader_prepare and bootloader_setup files from the top level directory and the whole System/Kickstart directory from AmigaOS 4.1 Pegasos 2 install CD to a temporary place where it can be modified. You should end up with this tree with Kickstart containing the contents of System/Kickstart on the CD:
    amigaboot.of
    bootloader_prepare
    bootloader_setup
    Kickstart/
    
  2. Copy siliconmotion502.chip to Kickstart and if PCIGraphics.card is older than version 53.9 then update that to a newer version as well.
  3. If using version 53.12 of siliconmotion502.chip update kernel from AmigaOS 4.1FinalEdition Update2 as well.
  4. Modify Kickstart/Kicklayout to add the graphics driver. Add a MODULE line for siliconmotion502.chip right after where other chip drivers are loaded after PCIGraphics.card. (The PCIGraphics.card is already there so no change is needed for that even if it had to be updated to newer version.) The result should look like this:
    MODULE Kickstart/PCIGraphics.card
    MODULE Kickstart/ATIRadeon.chip
    MODULE Kickstart/3dfxVoodoo.chip
    MODULE Kickstart/siliconmotion502.chip
    
    Some other chip drivers may also be present depending on your AmigaOS version. No need to change or remove those, just make sure there is a line for the added SM502 driver.

Step 2: Creating boot partition and adding Kickstart files

Create a raw disk image with an RDB partition table and add a boot partition with FFS filesystem to hold the boot files and copy the files prepared in previous step to that partition. The boot partition does not have to be set bootable, we just need it to start the system with the SM502 driver but then mount the CD or system partition for the rest of the boot. The boot partition should be the first partition, the rest of the disk image can be partitioned and formatted from AmigaOS later. This can be done in multiple ways, below is an example using amitools.
rdbtool amigahd.img create size=1Gi + init + add size=32MiB name=BOOT
# Note that rdbtool takes Gi for disk image size but MiB for partition size
xdftool amigahd.img open part=BOOT + format Boot ffs+intl
xdftool amigahd.img open part=BOOT + write amigaboot.of
xdftool amigahd.img open part=BOOT + write bootloader_prepare
xdftool amigahd.img open part=BOOT + write bootloader_setup
xdftool amigahd.img open part=BOOT + write Kickstart Kickstart

Step 3: Installing AmigaOS

  1. Start QEMU with the hard disk image prepared above and the installation CD-ROM. The command line for this is:
    qemu-system-ppc -machine pegasos2 \
      -bios pegasos2.rom -rtc base=localtime \
      -serial stdio -vga none -device sm501 \
      -drive media=disk,format=raw,file=amigahd.img \
      -cdrom Peg2InstallCD.iso
    
    You should see output from PegasosII firmware in the terminal where the command is started about the firmware initialising the system and detecting one QEMU HARDDISK on channel 0 unit 0 and a QEMU DVD-ROM on channel 1 unit 0, then end with an ok prompt. There could be some other errors because some parts of the real machine is not emulated but these are harmless and can be ignored as long as the memory, CPU, hard disk and DVD drive are detected and you get the ok prompt. In case of any other error check the command line for typos or mistakes.
  2. At the firmware ok prompt type the following command to start booting:
    boot hd:0 amigaboot.of
    
    This should print a boot menu with two options: one for booting from the CD and another from booting from the boot partition (Volume BOOT). Select the option to boot from our BOOT volume. The system should start and the AmigaOS GUI should be displayed in the QEMU window with options to set locale, setup disk, start installation or boot into live CD. Depending on AmigaOS version the screen mode may be low resolution 640x480 8 bit mode or a higher resolution 16 bit mode (in 4.1FE and later). If the install screen does not appear check that all previous steps have been done correctly
  3. From this point installation can be done as on real hardware. If you have low resolution display mode, starting MedaToolbox hard disk preparation utility may produce garbled screen. This can be fixed by pulling the screen down a bit by dragging the top of the screen downwards where a screen bar would appear on normal AmigaOS screens. Despite this screen does not display a screen bar it can be pulled down and that fixes the garbled graphics (this may be a bug in AmigaOS not in emulation but I don't know for sure). With higher resolution modes or newer AmigaOS versions this does not happen and the MediaToolbox should display correctly. You can create partitions for the rest of the disk as normal and start installation.

Booting the installed system

After installation exit QEMU, remove the cdrom option and boot as above with boot hd:0 amihaboot.of and then select the BOOT volume instead of DH0 or what you named the system partition. This should boot the installed system. If the system partition is not found it can be specified with an option e.g. boot hd:0 amigaboot.of bootdevice=DH0

On first boot the display mode may be set incorrectly which can result in a blue screen either with broken graphics as described in problem #1 on the known problems page or only with some text visible. The solution is to blindly get to ScreenMode Prefs and select a better graphics mode such as a 16 bit mode.

When installing updates you should either update the boot partition manually copying modified files from the system partition or if your system partition is using a file system readable by the firmware you can add the graphics driver to the system partition and redo the Kicklayout changes after each update.

The nvram is not emulated yet therefore firmware environment variables are not preserved so the boot command has to be typed at each boot. This can be automated with tools like expect or an alternative with less dependencies like empty.

Troubleshooting

See known problems page in case of problems or main page for further informaion.