Skip to content

Xemu Mega65 ethertap

LGB edited this page Jan 12, 2018 · 9 revisions

Mega65 - Ethernet emulation via ethertap

Goal: provide ethernet controller (of Mega65) emulation within Xemu/Mega65 emulator.

Currently, it's work-in-progress, and only works on Linux. It requires TAP network interface, which is not implemented by OSX, and I currently have no idea about Windows.

On Linux

NOTE: you need to configure the TAP device manually! It's a must, since Xemu can't do it. Well, it would be able to, if you run with network administrator capabilities (usually this means, as "root"), but it's always a BIG NO to run something as privileged, especially a software which is not security audited, and it is not its primary goal either. Well, it's almost always the bad side of some Windows dudes, always use their system as the Administrator then wondering what are those security problems, oh boy ... Real systems should not use something like that ever.

Anyway, so, you need to give commands like these in a terminal window for example:

sudo ip tuntap add mode tap user lgb mega65
sudo ip addr add 10.10.10.1/24 dev mega65
sudo ip link set mega65 up

Couple of thins you must or can modify in this example:

  • lgb in the first line if my user name I use my Linux system as. Clearly, you must replace with your user name! This is needed, so that Xemu running as only a user (not root, lgb in our example) can attach to the TAP interface (named mega65 in our example)
  • 10.10.10.1/24 is an IP address and netmask used by the TAP device, you can have this, but it may conflict with your LANs if you use especially this address range! Surely, you need to choose IP in your mega65 software you run with the emulator itself to use an IP within this range, but not the 10.10.10.1 itself, as it's your Linux box itself (the TAP interface called mega65 in our examples). Again, be sure, you specify an address (range) which is not used, do not try to use the same what your LAN settings also use, or any other used by somewhere else (ie on the Internet), since then it would render that range to be inaccessible the normal way from your Linux box!
  • mega65 in all lines is the name of the interface, you can choose another as well, if you really want
  • Note, that it's not a valid question "where can I set the IP address of the emulated Mega65" (with these IP commands, at the Linux side). You can't. The TAP interface itself emulates some kind of ethernet network, and you can set the IP of your Linux box at its 'end' (it's more like having an ethernet LAN, where you can only configure your IP, the others on the net is their task!). For the emulated Mega65, the IP must be set inside the emulator itself, by the program which implements the network communication running on Mega65. Please note, that in case of DHCP (if your mega65 software wants to do DHCP to get IP, I mean) you would need a DHCP server on your Linux box listening for DHCP requests on your TAP device (mega65 in our example).

Then, you can start xemu's mega65 emulator with the following command line switch part included: -ethertap mega65. Surely, run the emulator as your user name, as usual, with the username you also specified at the first ip command, for sure.

Surely, here the mega65 must much the interface name you used with the ip commands above.

Optionally, you can check the interface status:

ifconfig mega65

You can see, that after issuing the ip command above, there is no RUNNING state reported by ifconfig, if you check that before running the emulator. However after starting Xemu's mega65 emulator (see later), you can check it again, and you should see that too, then.

Accessing the internet from Mega65

The above scheme works with the right Mega65 software on the emulator to have communication between the host OS (what runs the emulator, in our example the IP is 10.10.10.1 for that) and your mega65. If you have some software want to access the Internet, you need to have the proper network admin knowledge to do this. You must enable IP forwarding on your Linux box, the right netfilter (iptables) forwarding settings, and probably also NAT (network address translation) there too. Surely, these cannot be avoided, as this emulation emulates network interface, thus you need knowledge on this, it's quite natural thing then ...