Introduction
The MEGA65 can use ethernet for SD card access and starting programs remotely by using the tools mega65_ftp and etherload. The tools are command-line applications, so you should be familiar with using these kinds of programs in a terminal, else you can download the GUI-tool M65Connect from Filehost. This guide also assumes that you know how to install a new core into one of the slots 1-7.
Set up
Before you start make sure:
The PC/Mac and your MEGA65 need to be connected to the same ethernet network.
IPv6 needs to be enabled on the network interface on your PC/Mac (this is default but you may have changed it)
Hardware configuration
This step is not necessary for MEGA65 (R6) produced in 2024 and delivered from batch #3.
DIP switch 2 is already ON for these devices.
The DIP switch #2 on your MEGA65 mainboard needs to be set to ON.
Unplug any cables attached to the MEGA65 (power, video, etc.)
Turn the MEGA65 to the back side and open the housing by removing the three lower screws:
Locate the DIP switch on the right side of the mainboard:
Use a small screwdriver or a pen to set DIP switch #2 to ON position. Be aware the DIP switch is up-side-down.
Close the housing, put back the three screws and plug all cables.
Download recent core
You need to have a recent development core installed in any of slot 1-7.
!! Do NOT install development cores into slot 0 !!
Head tohttps://builder.mega65.org/job/mega65-core/job/development/where you can find all development cores.
Any mega65-core from development branch dated October 10, 2023 or later should work.
Download the correct file for your MEGA65 model:DevKit, batch 1 and 2 owners : mega65r3 core
Batch 3+ owners (MEGA65 received in 2024+) : mega65r5 core
Unzip the core package after download and copy file ETHLOAD.M65 (in /sdcard-files) into the root folder of your SD card.
Install the core in slot 1-7. If you are not familiar with how to install a core read this Article.
Please be aware that these cores are still experimental and not official stable releases!
Set up MAC address
Configure a valid MAC address for the ethernet port of your MEGA65.
Press the
ALT
key during power on and then press key1
to start the Configuration Tool.Use the
Cursor Right
key to head to the NETWORK section.Enter a valid MAC address different to 00:00:00:00:00:00 or use the
R
key to create a valid random MAC address.Use
Cursor Right
key again to head to DONE section.Head to SAVE AS DEFAULTS AND EXIT with
Cursor Down
key.Head to OK with
Cursor Down
key and pressRETURN
key to save the current settings..
Be aware the MAC address is saved to your SD card, so you may need re-configure this if creating a new SD card.
Test ethernet connection
After all you want to check your ethernet connection is properly working
Hold key
NO SCROLL
while power-cycle the MEGA65.Select the core slot you have previously installed by pressing the correct key
Number
or using theCursor
keys andRETURN
key. The MEGA65 now boots with the selected core.Press the keys
SHIFT
and£
(pound) to enable the ethernet remote control. This is a security measure to only allow remote access to your MEGA65 if explicitly activated by the user via this key combination. By pressing the key combination a special char is printed which you can ignore.
If you have done everything right the power LED will start blinking green/yellow to indicate your MEGA65 can be used with mega65_ftp or etherload. Remote control needs to be re-enabled after a reset or power-off.
You should avoid to activate remote control if your MEGA65 is operated in a public or unknown network, as it allows others in your network to remote control your MEGA65 and have access to your SD card.
Working with mega65_ftp and etherload
Download MEGA65 Tools
This step is not necessary if you plan to work with M65Connect.
Download the latest version of the development branch mega65-tools to your PC, which you can find on Filehost and contains the required CLI tools etherload and mega65_ftp:
Extract the package and copy the OS related CLI tools
Copy the required files etherload(.exe/.osx) and mega65_ftp(.exe/.osx) where you want to have them.
If running into issues getting the MacOS binaries to work, please check out this article on Filehost: macOS: Running command line tools when "the developer cannot be verified" )
IPv6
The MEGA65 will communicate via a link-local IPv6 address that it automatically generates from its MAC address (EUI-64). In order for your PC/Mac to communicate with the MEGA65, you need to enable IPv6 support on your network interface that is connected to the MEGA65. All modern operating systems have IPv6 enabled by default. Unless you manually disabled it, everything should work.
In order for the auto-discovery to work, port UDP port 4510 needs to be enabled in your firewall for IPv6. Windows and MacOS will ask you the first time you start the application whether you want to allow network access of the program. Please confirm this in order to use the auto-discovery feature.
If configuring your firewall manually, note that you only need to allow this port for incoming UDP packets on the local network interface on your PC. You should not change anything in your router’s configuration for this!
How to use mega65_ftp
The mega65_ftp tool is a command-line application allowing to upload and download files to/from the SD card of the MEGA65.
Make sure the remote access to the MEGA65 is activated first via keys SHIFT
and £
(pound). The power LED needs to blink green/yellow!
In order to use mega65_ftp via ethernet, just provide the -e parameter:
mega65_ftp -e
You can now transfer files via put
and get
commands. Enter help
to get a list of available commands.
Commands can also be provided directly on the command-line instead of typing them in interactively. This is useful when using mega65_ftp in scripts to automatically perform a specific upload or download task:
mega65_ftp -e -c "put myimage.d81" -c "quit"
This will upload the file myimage.d81
from the current PC/Mac directory to the SD card.
How to use etherload
The etherload tool is used to upload programs directly into the RAM of the MEGA65 and execute them there. This is especially useful for a cross-development environment.
Again, please make sure the remote access to the MEGA65 is activated first via Shift-£ - the power LED needs to be blinking green/yellow!
Starting programs remotely
The simplest way of using etherload is to provide a prg file as argument and use the -r
parameter to run it:
etherload -r <file.prg>
The tool will determine which mode the program needs to run in (C64 or MEGA65 mode) and will do an automatic reset to the respective mode before starting the program.
The etherload program will need to do a reset first to make sure the system is in the right state. This is a fundamental difference to the m65 tool which can do a reset before RUN but does not require it. The m65 tool does not support ethernet functionality, though.
If your program requires a MOUNT
command first to have a D81 mounted from SD card, you can specify this via the -m
parameter:
etherload -m MYIMAGE.D81 -r <file.prg>
Please make sure the D81 image file is already on the SD card before running this command (for example, by uploading it first via mega65_ftp).
Starting machine language programs
The above commands work well for programs that provide BASIC code allowing them to be executed via RUN
. If you want to start a machine language program, you need to provide its starting address in hexadecimal notation:
etherload -j 8000 <file.prg>
In this case, the machine will not be reset first and etherload will do a JMP
to the provided address. The started program needs to configure relevant I/O registers as needed.
When using the -j
parameter, etherload will jump to the address with a cleared memory mapping, having only I/O mapped at $D000. Also, interrupts will be disabled when jumping to your address. This implies that the start address needs to be located in BANK 0. You will need to provide a complete initialisation routine in your program to setup the VIC-IV according to your needs.
The -j
parameter will be especially useful for game developers as they will initialise the machine state (incl. VIC-IV parameters) anyway.
The target address will be determined by the first two bytes in the provided file. If the file does not have its loading address in the first two bytes, it can be provided via the -b
parameter:
etherload -b 8000 -j 8000 <file.prg>
The loading address and the jump address can of course be different addresses.
Uploading multiple memory segments
Sometimes it is useful to upload several data files to different specific locations before uploading and starting the program. Think of developing a game that needs to load asset data files on startup: Instead of loading the files each time you start a new revision of your game during development, you can temporarily disable your loading routine and instead use etherload to upload the data directly into memory.
Let’s assume we have two files gfx.dat
and music.dat
that we want to load at addresses $20000 and $8000 before we start the main program. This can be done by calling etherload several times, but using the parameter --halt
for every invocation except the last one. This will instruct etherload to not jump to any address when done but instead wait for further etherload executions to continue loading data.
etherload -b 20000 --halt gfx.dat etherload -b 8000 --halt music.dat etherload -j 2016 game.prg
This will load the game asset files first and then will load the file game.prg and jump to address $2016 to execute it.
Note that game.prg might be a game with a BASIC header to start it, but we are not using the -r
parameter but instead -j
to start it (using the address that the BASIC header would have called in its SYS
command). This is done for a reason as -r
will restore the ROM at $20000-$3ffff first to be able to do a reset. This would overwrite our gfx.dat bytes we put at $20000. Using -j
instead will ensure we have full control over the complete memory. That way you can preload any bytes in chip ram or attic ram prior to starting your code.
If you want to skip bytes of a file when loading it to memory, you can also use the --offset
parameter. This one will skip the provided number of bytes (in hexadecimal notation) when loading the file. Let’s assume we have the program game.prg
with a start address of $2001, and we only want to load it from address $2100 (which may be its entry point), then we need to skip the first 255 bytes for loading.
etherload -j 2100 --offset ff game.prg
Using custom ROM files
If you have a specific ROM file on your PC/Mac that you want to run, you can use the -R parameter:
etherload -R 920384.ROM
This will load the ROM file “920384.ROM” from your PC/Mac, upload it to the memory of the MEGA65, and reset into that new ROM. As this upload and reset is amazingly fast, you can use this to quickly test different revisions of the ROM without having to upload them to SD card and doing a full reset on your MEGA65.
If you want to start a program together with a specific ROM revision, you can combine the -R
parameter with a program file to execute:
etherload -R 920384.ROM -r <file.prg>
Speeding up start-up time
Etherload and mega65_ftp can start faster if you directly provide the IPv6 address and interface identifier where the MEGA65 is connected to. This is because then the auto-discovery will be skipped, saving up to one second during startup.
You can trigger auto-discovery manually via etherload to find out which IP address and interface identifier to use:
etherload --discover MEGA65 found at fe80::d5ff:fe16:0%eth0
You can then us the string provided for your next launch of etherload or mega65_ftp:
etherload -i fe80::d5ff:fe16:0%eth0 -r <file.prg>
mega65_ftp -i fe80::d5ff:fe16:0%eth0
Note that the IP address is created out of your MEGA65’s MAC address, so the IP address will change if you update your MAC address.
Troubleshooting
I installed a development core as required, but pressing keys SHIFT
and £
(pound) has no effect. The power LED does not start blinking.
Please check whether the core is up-to-date and the correct core is actually running. Note that if you exit from configuration, the core from slot 0 is started and not the default core in slot 1! You may need to power-cycle after exiting configuration.
Using a WIFI bridge might cause connection problems. If you try to connect to the MEGA65 over a network there might be several reasons (firewall, settings, etc.) etherload can’t find the MEGA65.
To locate the problem connect the PC to the MEGA65 using a LAN cable and see if it’s working that way.
Another reason why the power LED is not blinking by pressing the keys SHIFT
and £
(pound) may be you forgot to set DIP switch #2 to ON or you may have set another switch than 2 to ON. Be aware the DIP switch is up-side-down.
When starting mega65_ftp or etherload, I can see the MEGA65 reacts, but then it just hangs without continuing.
This can happen if you forgot to put ETHLOAD.M65 into the root of your SD card. It can also be the ETHLOAD.M65 is outdated. Please try to flash the latest core and put the ETHLOAD.M65 file provided with that core archive on your SD card.
Triggering etherload or mega65_ftp takes longer than expected (>1 sec). How can I speed this up?
The ETHLOAD.M65 program needs to be found on the SD card when any of those programs is started. If a lot of files already existed in the root folder before ETHLOAD.M65 was copied there, it could be the system needs a long time to find it. If you want to speed this up, you may want to prepare a fresh new SD card with MEGA65 fdisk, and make sure the ETHLOAD.M65 file is copied to it during that process. That way, the start of etherload and mega65_ftp will be much faster. You can still copy a lot of other files after that to the SD card and still keep the fast startup of etherload/mega65_ftp, as ETHLOAD.M65 will still be one of the earliest entries in the FAT32 structure of the root folder.