TFE on Mac VICE Build Guide

The Final Ethernet (TFE) adapter allows to connect a real Commodore 64 to the ethernet. VICE can emulate this adapter and makes your virtual C64 internet-aware. This guide describes how to compile a TFE-enabled version of the mac port.

You need to compile and setup the libpcap and libnet libraries before compiling VICE.

libpcap

  • Download lipcap from www.tcpdump.org
  • I use version 0.9.5
  • Compile a universal library with the following commands
    # build i386 version
    export CFLAGS="-arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk/"
    ./configure
    make
    cp libpcap.a libpcap-i386.a
    
    make distclean
    
    # build ppc version
    export CFLAGS="-arch ppc -isysroot /Developer/SDKs/MacOSX10.3.9.sdk/"
    ./configure
    make
    cp libpcap.a libpcap-ppc.a
    
    # combine universal lib
    lipo -create -output libpcap.a libpcap-i386.a libpcap-ppc.a
    ranlib libpcap.a
    

libnet

  • You need version 1.0.x, 1.1.x won’t work!
  • The homepage of libnet is www.packetfactory.com
  • I grabbed my lib source from Debian because the homepage was down:
    http://ftp.debian.org/debian/pool/main/libn/libnet0/libnet0_1.0.2a.orig.tar.gz
  • Libnet 1.0 is very old and needs an updated configure:
    cd libnet0_1.0.2a
    cp /usr/share/libtool/config.guess .
    cp /usr/share/libtool/config.sub .
    
  • Additionally a small patch is required to compile the source with the 10.4 SDK. In file include/libnet/libnet-headers.h find the line
    #if (__linux__)

    and replace it with

    #if (__linux__) || (defined(__APPLE__)&&defined(__i386__))
  • Compile a universal library with the following commands:
    # build i386 version
    export CFLAGS="-arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk/"
    ./configure
    make CFLAGS="$CFLAGS"
    cp lib/libnet.a lib/libnet-i386.a
    
    # build ppc version
    export CFLAGS="-arch ppc -isysroot /Developer/SDKs/MacOSX10.3.9.sdk/"
    ./configure
    make CFLAGS="$CFLAGS"
    cp lib/libnet.a lib/libnet-ppc.a
    
    # combine universal lib
    lipo -create -output lib/libnet.a lib/libnet-i386.a lib/libnet-ppc.a
    ranlib lib/libnet.a
    

Compiling VICE

  • Link both libs named libpcap and libnet in the same directory where the VICE source resides:
    libpcap
    libnet
    vice-1.20
    
  • Configure VICE with the following commands:
    PWD=`pwd`
    cd vice-1.20
    export PATH=$PWD/libnet:$PATH
    export CFLAGS="-I$PWD/libpcap -I$PWD/libnet/include"
    export CPPFLAGS="$CFLAGS"
    export LDFLAGS="-L$PWD/libpcap -L$PWD/libnet/lib"
    ./configure --enable-ethernet
    
  • Have a look at the configure output and make sure the following lines are both true:
    checking for pcap_open_live in -lpcap... yes
    checking for libnet_write_link_layer in -lnet... yes
    
  • Now compile and build VICE as usual:
    make
    make bindist
    

Setup Mac OS X for libpcap

  • For libpcap and thus VICE with TFE to work correctly on Mac OS X you need to set up the raw net devices /dev/bpf* with the correct permissions. See the document in libpcap/README.macosx for more details!
  • You need to install the following StartupItem and reboot your machine:
    cd libpcap
    mkdir -p /Library/StartupItems/
    sudo cp -r ChmodBPF /Library/StartupItems/
    
  • After a reboot the devices should be read/writable by the admin group:
    crw-rw----   1 root  admin   23,   0 Nov  1 16:55 /dev/bpf0
    crw-rw----   1 root  admin   23,   1 Nov  1 16:54 /dev/bpf1
    crw-rw----   1 root  admin   23,   2 Nov  1 16:54 /dev/bpf2
    crw-rw----   1 root  admin   23,   3 Nov  1 16:54 /dev/bpf3
    
  • Make sure that you are in the admin group, i.e. your user is allowed to manage the system!

Running VICE

  • Run your compiled x64.app
  • In the VICE menu IO Extensions there should now exist a Ethernet emulation entry.
  • Select IO Extensions/Ethernet emulation/Interface… and enter your Mac’s ethernet interface, e.g. I use en1 for my AirPort card. If you are not sure what to pick, just have a look at your ifconfig output. There the ethernet device are listed with their assigned IPs.
  • Now you can enable the TFE with IO Extensions/Ethernet emulation/Enable Ethernet

Leave a Reply