{"id":2837,"date":"2024-08-10T12:23:47","date_gmt":"2024-08-10T16:23:47","guid":{"rendered":"https:\/\/biosrhythm.com\/?p=2837"},"modified":"2024-12-29T18:20:25","modified_gmt":"2024-12-29T23:20:25","slug":"using-appletalk-with-qemu-9-on-raspberry-pi-5","status":"publish","type":"post","link":"https:\/\/biosrhythm.com\/?p=2837","title":{"rendered":"Using AppleTalk with QEMU 9 on Raspberry Pi 5"},"content":{"rendered":"\n<p>I recently built QEMU from scratch on the Raspberry Pi 5 and wanted to document my steps. My goal was to run two different Mac emulations: a 68k and PPC Mac, specifically with AppleTalk networking functioning over Ethernet.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"840\" height=\"629\" src=\"https:\/\/biosrhythm.com\/wp-content\/uploads\/2024\/08\/Screenshot-2024-08-08-at-11.14.40\u202fPM-840x629.png\" alt=\"\" class=\"wp-image-2838\" srcset=\"https:\/\/biosrhythm.com\/wp-content\/uploads\/2024\/08\/Screenshot-2024-08-08-at-11.14.40\u202fPM-840x629.png 840w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2024\/08\/Screenshot-2024-08-08-at-11.14.40\u202fPM-300x225.png 300w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2024\/08\/Screenshot-2024-08-08-at-11.14.40\u202fPM-768x575.png 768w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2024\/08\/Screenshot-2024-08-08-at-11.14.40\u202fPM-1536x1150.png 1536w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2024\/08\/Screenshot-2024-08-08-at-11.14.40\u202fPM.png 2008w\" sizes=\"(max-width: 840px) 100vw, 840px\" \/><\/figure>\n\n\n\n<!--more-->\n\n\n\n<p>Assumptions: Raspberry Pi 5 with Raspbian Bookworm 64-bit using Ethernet interface eth0. This part builds on the work from <a rel=\"noreferrer noopener\" href=\"https:\/\/www.chrisrcook.com\/2023\/09\/27\/building-qemu-8-0-on-raspberry-pi-os\/\" target=\"_blank\">this blog post by Chris Crook<\/a>.<\/p>\n\n\n\n<p>I started with a stock installation of Raspbian 64-bit Bookworm with desktop.<\/p>\n\n\n\n<p>First, update your Raspberry Pi.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt-get update\nsudo apt-get upgrade\nsudo reboot<\/code><\/pre>\n\n\n\n<p>Next, install QEMU dependencies.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt-get install git libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev ninja-build libaio-dev libbluetooth-dev libcapstone-dev libbrlapi-dev libbz2-dev libcap-ng-dev libcurl4-gnutls-dev libgtk-3-dev libibverbs-dev libjpeg62-turbo-dev libncurses5-dev libnuma-dev librbd-dev librdmacm-dev libsasl2-dev libsdl2-dev libseccomp-dev libsnappy-dev libssh-dev libvde-dev libvdeplug-dev libvte-2.91-dev libxen-dev liblzo2-dev valgrind xfslibs-dev libnfs-dev bison flex libiscsi-dev libusb-1.0-0-dev libusbredirparser-dev<\/code><\/pre>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/www.qemu.org\/download\/#source\" target=\"_blank\">Download the latest version of QEMU source<\/a>. At the time of this writing, that is version <a rel=\"noreferrer noopener\" href=\"https:\/\/download.qemu.org\/qemu-9.1.0-rc1.tar.xz\" target=\"_blank\">9.1.0-rc1<\/a>. Save it to your Downloads folder in your home directory.<\/p>\n\n\n\n<p>Unpack it, configure it, and start building it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd Downloads\ntar -xzvf qemu-9.1.0-rc1.tar.xz\ncd qemu-9.1.0-rc1\n.\/configure\nmake<\/code><\/pre>\n\n\n\n<p>It took my Raspberry Pi a couple of hours to complete the build. Afterwards, you should have binaries inside the build folder. Test it with the following command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/build\/qemu-system-m68k -version\n.\/build\/qemu-system-ppc -version<\/code><\/pre>\n\n\n\n<p>You should get something like &#8220;QEMU emulator version 9.0.90&#8221; back. Finally, install everything.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo make install<\/code><\/pre>\n\n\n\n<p>You can check that it worked by issuing the command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>which qemu-system-ppc<\/code><\/pre>\n\n\n\n<p>Which should respond with &#8220;<code>\/usr\/local\/bin\/qemu-system-ppc<\/code>&#8221; meaning it&#8217;s been installed.<\/p>\n\n\n\n<p>Next, setup the bridged networking for QEMU. <a rel=\"noreferrer noopener\" href=\"https:\/\/www.spad.uk\/posts\/really-simple-network-bridging-with-qemu\/\" target=\"_blank\">Part of this came from this guide.<\/a> Install bridge-utils.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt-get install bridge-utils<\/code><\/pre>\n\n\n\n<p>Next, create a new folder and file called bridge.conf with a single line to allow the new bridge interface, arbitrarily called &#8220;br0&#8221;. And also set permissions on the bridge helper.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkdir \/usr\/local\/etc\/qemu\nsudo echo \"allow br0\" &gt; \/usr\/local\/etc\/qemu\/bridge.conf\nsudo chmod 0644 \/usr\/local\/etc\/qemu\/bridge.conf\nsudo chmod u+s \/usr\/lib\/qemu\/qemu-bridge-helper<\/code><\/pre>\n\n\n\n<p>Next, we&#8217;re going to create some startup scripts for QEMU. The first two will manage bringing up and tearing down the bridge interface. The third will actually start QEMU and start the bridge first if needed.<\/p>\n\n\n\n<p>The first two scripts start the bridge interface and use the IP address information from eth0 and move it to br0 and vice versa. I called these <code>br0-up.sh<\/code> and <code>br0-down.sh<\/code>. These scripts allows you to use DHCP on your Ethernet interface and use that IP address for the bridge. When  you want to tear down the bridge, the script reassigns the address back to eth0.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n\n# br0-up.sh\n\n# Check sudo\nif &#91; \"$EUID\" -ne 0 ]; then\n  echo \"Please run with sudo.\"\n  exit\nfi\n\n# Get interface eth0 details\nETH=`ifconfig eth0 |grep netmask |sed 's\/^ *\/\/' |cut -d\" \" -f2`\nMASK=`ifconfig eth0 |grep netmask |sed 's\/^ *\/\/' |cut -d\" \" -f5`\nBROADCAST=`ifconfig eth0 |grep netmask |sed 's\/^ *\/\/' |cut -d\" \" -f8`\nGATEWAY=`ip route |grep default |cut -d\" \" -f3`\n\nif &#91; \"x$ETH\" = \"x\" ]; then\n  echo \"Unable to determine current IP address of interface eth0.\"\n  echo \"Interface has no IP or bridge already started?\"\n  exit -1\nelse\n  echo \"Interface eth0 ip address: $ETH\"\nfi\n\n# Setup br0 if not already enabled\nif &#91;&#91; $(ifconfig -a |grep br0) ]]; then\n  echo \"Interface br0 already loaded.\"\n  exit 0\nfi\n\n# Take down eth0, bring back up with no IP address\nifconfig eth0 0.0.0.0 promisc up\n# Create bridge\nbrctl addbr br0\nbrctl addif br0 eth0\nbrctl stp br0 off\n# Assign interface br0 with the IP address and add gw\nifconfig br0 $ETH netmask $MASK broadcast $BROADCAST\nsleep 0.5\nroute add default gw $GATEWAY\n\necho \"Bridge interface br0 up.\"<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n\n# br0-down.sh\n\n# Check sudo\nif &#91; \"$EUID\" -ne 0 ]; then\n  echo \"Please run with sudo.\"\n  exit\nfi\n\n# Get interface br0 details\nETH=`ifconfig br0 |grep netmask |sed 's\/^ *\/\/' |cut -d\" \" -f2`\nMASK=`ifconfig br0 |grep netmask |sed 's\/^ *\/\/' |cut -d\" \" -f5`\nBROADCAST=`ifconfig br0 |grep netmask |sed 's\/^ *\/\/' |cut -d\" \" -f8`\nGATEWAY=`ip route |grep default |cut -d\" \" -f3`\n\nifconfig br0 down\nbrctl delbr br0\nifconfig eth0 -promisc\nifconfig eth0 $ETH netmask $MASK broadcast $BROADCAST\nsleep 0.5\nroute add default gw $GATEWAY\n\necho \"Interface br0 down and interface eth0 restored to previous settings.\"<\/code><\/pre>\n\n\n\n<p><strong>Note:<\/strong> This will interrupt any currently existing network connections on the Raspberry Pi.<\/p>\n\n\n\n<p>Finally, we&#8217;ll create a script to start QEMU. It will first check if the bridge interface exists, and if not, will run that script first. There are two scripts here. The first is for the m68k Mac (Quadra 800) and the second is the PPC Mac (PowerMac G4).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n\n# start-m68k.sh\n\n# Check sudo\nif &#91; \"$EUID\" -ne 0 ]; then\n  echo \"Please run with sudo.\"\n  exit\nfi\n\nif &#91;&#91; -z \"$(ifconfig -a |grep br0)\" ]]; then\n  echo \"Bringing up bridge interface br0.\"\n  .\/br0-up.sh\nfi\n\nqemu-system-m68k \\\n-M q800 \\\n-m 128 \\\n-display gtk \\\n-audio none \\\n-bios Q800.ROM \\\n-g 800x600 \\\n-device scsi-hd,scsi-id=0,drive=hd0 \\\n-drive format=raw,media=disk,if=none,id=hd0,file=yourhd.hda \\\n-net nic,model=dp83932,macaddr=52:54:00:00:00:02 \\\n-net bridge,br=br0<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n\n# start-m68k.sh\n\n# Check sudo\nif &#91; \"$EUID\" -ne 0 ]; then\n  echo \"Please run with sudo.\"\n  exit\nfi\n\nif &#91;&#91; -z \"$(ifconfig -a |grep br0)\" ]]; then\n  echo \"Bringing up bridge interface br0.\"\n  .\/br0-up.sh\nfi\n\nqemu-system-ppc \\\n  -accel tcg \\\n  -L pc-bios \\\n  -boot c \\\n  -M mac99,via=pmu \\\n  -m 512 \\\n  -drive file=yourhd.hda,format=raw,media=disk \\\n  -net nic,model=sungem,macaddr=52:54:00:00:00:01 \\\n  -net bridge,br=br0<\/code><\/pre>\n\n\n\n<p>Replace the text <code>yourhd.hda<\/code> with the name of your hard drive image. I found it easier to create these using MiniVMac on my desktop and then converting them to drive images using <a rel=\"noreferrer noopener\" href=\"https:\/\/diskjockey.onegeekarmy.eu\/\" target=\"_blank\">Disk Jockey<\/a>. The alternative is to create a blank HD image and add lines to mount a CD-ROM. That&#8217;s not covered here but I can add it if there&#8217;s interest.<\/p>\n\n\n\n<p>Set permissions to executable on your new scripts.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>chmod 755 br0-down.sh\nchmod 755 br0-up.sh\nchmod 755 start-m68k.sh\nchmod 755 start-ppc.sh<\/code><\/pre>\n\n\n\n<p>Launch one of your start QEMU scripts from the terminal.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/start-m68k.sh\n.\/start-ppc.sh<\/code><\/pre>\n\n\n\n<p>A new QEMU window should open and the Mac should begin booting. Once booted, you may have to go to the Network or AppleTalk Control Panel and select Ethernet. Afterwards, go to the Chooser and you should now see your other AppleTalk devices on your Ethernet network.<\/p>\n\n\n\n<p>If you have <a href=\"https:\/\/biosrhythm.com\/?p=2791\" data-type=\"post\" data-id=\"2791\" target=\"_blank\" rel=\"noreferrer noopener\">setup a support server with another Raspberry Pi using a TashTalk hat and TashRouter<\/a>, you can see LocalTalk printers such as ImageWriter II or ImageWriter LQ.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"840\" height=\"595\" src=\"https:\/\/biosrhythm.com\/wp-content\/uploads\/2024\/08\/Screenshot-2024-08-10-at-12.02.36\u202fPM-840x595.png\" alt=\"\" class=\"wp-image-2841\" srcset=\"https:\/\/biosrhythm.com\/wp-content\/uploads\/2024\/08\/Screenshot-2024-08-10-at-12.02.36\u202fPM-840x595.png 840w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2024\/08\/Screenshot-2024-08-10-at-12.02.36\u202fPM-300x212.png 300w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2024\/08\/Screenshot-2024-08-10-at-12.02.36\u202fPM-768x544.png 768w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2024\/08\/Screenshot-2024-08-10-at-12.02.36\u202fPM.png 1014w\" sizes=\"(max-width: 840px) 100vw, 840px\" \/><\/figure>\n\n\n\n<p><strong>Note:<\/strong> One caveat is the sound for the 68k Mac wouldn&#8217;t work so I used a switch to disable it.<\/p>\n\n\n\n<p>You can even run both simultaneously and they&#8217;re able to see each other over AppleTalk so you can share files between them. It even plays nicely with MiniVMac using LToUDP (with an appropriate LToUDP router like TashRouter).<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"840\" height=\"460\" src=\"https:\/\/biosrhythm.com\/wp-content\/uploads\/2024\/08\/Screenshot-2024-08-10-at-12.18.56\u202fPM-840x460.png\" alt=\"\" class=\"wp-image-2842\" srcset=\"https:\/\/biosrhythm.com\/wp-content\/uploads\/2024\/08\/Screenshot-2024-08-10-at-12.18.56\u202fPM-840x460.png 840w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2024\/08\/Screenshot-2024-08-10-at-12.18.56\u202fPM-300x164.png 300w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2024\/08\/Screenshot-2024-08-10-at-12.18.56\u202fPM-768x421.png 768w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2024\/08\/Screenshot-2024-08-10-at-12.18.56\u202fPM-1536x842.png 1536w, https:\/\/biosrhythm.com\/wp-content\/uploads\/2024\/08\/Screenshot-2024-08-10-at-12.18.56\u202fPM-2048x1122.png 2048w\" sizes=\"(max-width: 840px) 100vw, 840px\" \/><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently built QEMU from scratch on the Raspberry Pi 5 and wanted to document my steps. My goal was to run two different Mac emulations: a 68k and PPC Mac, specifically with AppleTalk networking functioning over Ethernet.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2,90,13],"tags":[],"_links":{"self":[{"href":"https:\/\/biosrhythm.com\/index.php?rest_route=\/wp\/v2\/posts\/2837"}],"collection":[{"href":"https:\/\/biosrhythm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/biosrhythm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/biosrhythm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/biosrhythm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2837"}],"version-history":[{"count":8,"href":"https:\/\/biosrhythm.com\/index.php?rest_route=\/wp\/v2\/posts\/2837\/revisions"}],"predecessor-version":[{"id":2952,"href":"https:\/\/biosrhythm.com\/index.php?rest_route=\/wp\/v2\/posts\/2837\/revisions\/2952"}],"wp:attachment":[{"href":"https:\/\/biosrhythm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2837"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/biosrhythm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2837"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/biosrhythm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2837"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}