How to Upload Code to RPU
(hint: it’s the cable)
Uploading code to the RPU is simple to do, but requires a bunch of steps to get ready.
1) Download the Arduino IDE
2) Download/Prepare the code ZIP file
3) Plug into the Arduino (hint: it’s the cable)
4) Upload Code
Download the Arduino IDE
An IDE is an Integrated Development Environment. For Arduino, you don’t distribute binaries, you distribute the actual source code. To put the source code on your Arduino MEGA 2560 Pro, you have to compile & upload it. The thing that compiles & uploads is the IDE.
The Arduino IDE is available here for Mac, Windows, and Linux. They have a good installer and instructions on their site. You just get it and install the defaults and you should be ready to go. I like to put the software on a laptop so I can update the Arduino after it’s installed, in case there are bug-fixes or updates to apply.
Download/Prepare the code ZIP file
All the source code for games I’ve developed is on GitHub here. I name my new games without using the name of the original machine (to stay on the correct side of copyright, just in case), so you might have to poke around or use your imagination to guess that one might play SpaceBattle2022 on a Stellar Wars pinball machine. If you can’t find what you’re looking for, just shoot me a note to dickhamill@gmail.com.
Once you find the GitHub page for the code you want, click on the green Code button and then look for “Download ZIP.”
Put the code in whatever structure makes sense to you. I think Arduino creates a “Arduino” folder under your user’s Documents, so that’s a good place. When you unzip, you’ll get a folder called “BluesBrothers-main.zip” or something like that. You’re going to have to rename that folder. In the folder, you’ll find a “.ino” file. The folder that the “.ino” resides in has to be the EXACT same name as the “.ino” file. So, in my example, you’ll see BluesBrothers.ino in the unzipped folder, so you have to rename the folder from “BluesBrothers-main” to “BluesBrothers” so it matches the “.ino” file name. Clear? If not, Arduino will complain when you try to open the “.ino” file.
Next, you’ll need to open the “.ino” file in the Arduino IDE. Just double click or File>Open or whatever.
Now that you have the project in the IDE, you must configure the RPU_Config.h file to match your options. There are a bunch of options that are “commented” out of the code with two slashes at the beginning of the line. Remove the two slashes to include these options. At a minimum, you want to check that the hardware revision (near the top) matches the RPU board you’re using. There are some instructions in the file.
With the project open in the IDE, make sure everything compiles by clicking Sketch > Verify / Compile. Any error messages will show up in the bottom pane of the IDE.
Plug into the Arduino
With the code downloaded and compiled, the next step is to upload it to the Arduino. The latest RPU boards use an Arduino MEGA 2560 Pro, and right now those are shipping with Micro USB connectors, so you’ll need a cable that goes from your computer to Micro USB. There are a billion Micro USB cables out there in the world, but 99% of them are just for charging. They don’t have data capabilities, so they won’t work for uploading code.
When in doubt, get a new cable and make sure it’s a DATA cable. I use this one.
Upload the Code
Once you have the Arduino plugged into your computer with a DATA cable, you should be able to find your device under the Tools > Port menu. On a Mac, the Port will look like /dev/cu.usbserial-1120, or something like that. I think it will say USB Serial on the PC as well. If you don’t see a USB Serial port pop up when you plug in the Arduino, it’s probably your cable. That’s the most common issue. If you have a USB C to Micro USB cable, be aware that you’ll probably have to plug the cable into your computer before you plug the cable into the Arduino. Those cables have some smarts in them that needs to be powered by the computer in order for everything to work.
You also have to set these menu options:
Tools > Board > Arduino AVR Boards > Arduino Mega or Mega 2560
Tools > Processor > ATmega2560
Then just hit Sketch > Upload. It takes several seconds, but you’ll see a progress bar in the lower pane if everything is working.
The safest way to upload to the Arduino is if you’ve unplugged your Arduino from everything and just plugged it into the computer. Powered by the USB port, you’ll see tiny LEDs on the Arduino that show you if it’s connected properly and a red lamp flashes quickly when it’s being programmed. If you don’t see LEDs or you don’t get a success message in the lower pane, then something is wrong.