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 Pegasos 2 version but installation is not as straightforward as on real hardware. This is because the Pegasos 2 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 below.

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. 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. A known problem is that SFS partitions need a -cpu option to work (see Known Problems below) and the boot partition must use FFS because the firmware can only read that. Also check that the block size is set to a sane value as it may auto select a too large default.

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 amihaboot.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 in problem #1 described on the main 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.

You can continue to use the boot partition or change the Kickstart files on the system partition to add the graphics driver. When installing updates you should either update the boot partition manually copying modified files from the system partition or you can add the graphics driver again 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.

Known problems

  1. Memory size is currently limited to 1 gigabyte with pegasos2.rom. This may be fixed in the future but using BBoot without ROM already supports memory size up the the platform maximum of 2 gigabytes.
  2. PCI cards such as network cards don't work with QEMU versions before v8.0.0 with pegasos2 machine
  3. SFS partitions don't show up on QEMU before v8.1.0 without a CPU known by AmigaOS such as -cpu 7457 or -cpu g3 QEMU options. It seems the PPC version of SmartFileSystem Kickstart module does not work with the 7400 G4 CPU QEMU emulates by default in v8.0.0 and earlier. Replacing SmartFileSystem with a 68k version is also a possible work around but specifying an appropriate CPU is enough and fixes this problem. After QEMU v8.1.0 the default is -cpu 7457 so no explicit option is needed any more.
  4. Using the default CPU can be faster but may have some problems with older SDL versions which may either be a bug in SDL or something with using SM502 driver. Using -cpu g3 instead may work around this.
  5. The rtl8139 driver in AmigaOS 4.1FE Update 1 or 2 may not work correctly. This can be fixed by downgrading to the version on the 4.1FE install CD.
  6. When using the ALSA audio backend on Linux sound may crackle. This can be avoided by adding -audiodev alsa,id=audio0,out.try-poll=off to QEMU command line. This option has changed to -audio in QEMU v8.2.0.
  7. There is a delay during boot with siliconmotion502.chip driver version 53.10 (53.9 does not have this problem). This is fixed in version 53.12 from OS4Depot but that version can only be installed after 4.1FE Updates 1 and 2.
  8. See main page for further known problems.