I made some homemade Arduboy with Serial Flash memory that can store max 500 games to play on the road. I hope to share how to load games to it, including how to store games into the serial flash memory and create your own consolidated game package to play on the road.
You can view this youtube video for the end to end creation process and explanation
Step 1: Set Up Arduino IDE
If you are new to Arduino, browse to https://www.arduino.cc to download the Arduino IDE for the operating system you are using e.g.windows 10 or Mac OSX or Linux.
Then install it.
Step 2: Make the USBasp Cable
Unlike loading binary codes/games to any Arduino board, programming the bootloader cannot be done through the USB port.
To burn the custom bootloader (Cathy3K) to the Atmega32U4 chip, you need to get a USBasp programmer. However, our creation works at 3.3V, we need to further modify the USBasp programmer to function in 3.3V.
Refer to the following instructable project to modify your USBasp programmer to work at both 3.3V or 5V through jumper settings.
Then follow the pin layout and the video to make the USBasp to ArduBaby program cable. the original USBasp cable that comes with the USBasp has two connectors, each 10 pins. We will chop this cable in half, and connect a 6 pin male header to one end while keeping the other end that connects with the USBasp board at 10pin.
This other end will connect the GND, VCC, MOSI, MISO, SCK, Reset pins from the USBasp to the corresponding pins of the ATmega32U4 through the male header that connects to the first six pins of the female header on the Ardubaby (my version of homemade Arduboy). Your version may have different pin layout. You can reference my video to change the design to fit your version of homemade Arduboy.
To do the program or burn the bootloader to ATmega32U4, you will remove the button hat and plug in this 6-pin USBasp cable.
Make sure you mark which pin is pin one clearly on the header of the cable so that will will not make the wrong connection. When I design the pin layout for the Ardubaby button hat headers, I tried to arrange the pins such that even if you swapped pin 1 with pin 13, the -ve power supply will not accidentally meet with the +ve power supply to avoid damages. However, you never know, other things may happen that could still damage your kit if you connect at the incorrect direction.
I will burn a tiny hole to mark that on the header using the tip of the solder iron.
Step 3: Burn the Bootloader
MR.Blinky created the Arduboy-homemade-package for homemade Arduboy.
His package includes the board drivers and library of Arduboy that works with different versions of the original Arduboy as well as he homemade ones.
1. Browse to MR.Blinky’s GitHub folder for the homemade Arduboy. https://github.com/MrBlinky/Arduboy-homemade-package 2. Follow the instructions on the GitHub to configure your Arduino IDE with the homemade package. 3. First copy the url of the “Additional board manager” for Arduboy homemade package. https://raw.githubusercontent.com/MrBlinky/Arduboy-homemade-package/master/package_arduboy_homemade_index.json
4. Start Arduino IDE. Click Preferences from the Arduino top menu. Paste this text into the “Additional Boards Manager URLs” Note: If you already have other text on this field, insert this additional text at the beginning, then add a “,” and keep the other text intact. 5. Exit Arduino IDE and start the IDE again to take effect of the change above. 6. Click Tools -> Board: -> Board Manager. Enter homemade to search. Select to install the Arduboy homemade package by Mr.Blinky. Then click update to get the latest version. The package will be added to Arduino. 7. Now select Tools-> Board: “Home-made Arduboy. and select the following parameters for Homemade Arduboy” Based on : “SparkFun Pro Micro 5V - Standard wiring” Core: “Arduboy Optimized core” Bootloader: “Cathy3K” Programmer: USBasp 8. Turn off the Ardubaby and remove the button hat. 9. Set the jumper on the USBasp to 3.3V. Make sure you are using a modified USBasp that works entirely in 3.3V. 10. Connect the USBasp to the USB port of your computer. Connect the special USBasp to ArduBaby cable to USBasp, and the other end to the button hat header of the Ardubaby, line up pin 1 to pin 1. Only the first 6 pins of the Ardubaby is used for bootloader burning.
11. Your Ardubaby should be powered on now through the 3.3V power supplied by the USBasp. 12. Press the reset button of the ArduBaby once. 13. Clink the Tools->Boards->Burn Bootloader button on the Arduino IDE. 14. Check the message to see if the bootloader burn is successful. 15. If not, check the cable and make sure you connect the pins in the correct direction and line up pin 1 with pin 1. Sometimes, the Ardubaby will start playing a previous game if the boot menu times out. So, you need to click the Burn bootloader button quickly right after you press the reset button to put the Ardubaby at the waiting for flash mode. 16. If it's all good, the ArduBaby will reboot and you will see either the boot up menu, or the previous game you have loaded to the ArduBaby.
Step 4: Compile and Upload Single Games to Arduboy
Games for Arduboy can be downloaded from the following sources:
Arduboy community forum for games: https://community.arduboy.com/c/games
The GitHub search on "Arduboy games" https://github.com/topics/arduboy-game or just search "GitHub arduboy games" on google.
Game collections shared by others. e.g. Erwin's Arduboy collections
You can download the source code of the game that you car load to Arduino and upload to the Arduboy. See the video on how this is done.
or just the hex file (the compiled binary file but presented in Hex number print out to a text file instead of binary file).
YFor source code, just open the source code within Arduino IDE.
The source code e.g. picovaders.ino need to be stored in a folder of the same name e.g. picovaders
The required Arduboy2 libraries should be already installed in the previous step where we load the board manager for Arduboy homemade package.
Just connect the Arduboy to the USB port of your computer.
Switch it on, then click Upload button on the Arduino IDE to compile and upload the code to the Arduboy to play the game.
Step 5: Upload Single Hex Files
Hex file is a text file containing binary codes resulting form the compilation of your Arduino program (sketch), but represented in a text file format using two digit hexadecimal numbers 0-9,A-F.
You can get these hex file in different ways.
1. We can download hex files from the different sources we explained above:
https://community.arduboy.com/c/games Erwin's Arduboy Game Collections http://arduboy.ried.cl
Search for "Arduboy games" on GitHub.com or on google.com
Save these hex files into files with an extension of .hex.
2. Alternatively, you can make your own hex file.
In the Arduino IDE select Sketch > Export Compiled Binary. Your sketch will be compiled, then a copy of the compiled .hex file will be output to the directory of your sketch. Browse to the sketch folder or in the IDE select Sketch > Show Sketch Folder to see the hex file. If you installed MR.Blinky's homemade package two version of the .hex file will be created. For example, if you compile the picovaders.ino sketh, the following two .hex files will be created.
picovaders.ino-arduboy-promicro-ssd1306.hex picovaders.ino with_bootloader-arduboy-promicro-ssd1306.hex
We will use the first file: picovaders.ino-arduboy-promicro-ssd1306.hex
3. To upload hex file to Arduboy, you need to use an uploader. There are many on the internet. I like to use MR.Blinky's uploader as it's simple to use.
Browse to https://github.com/MrBlinky/Arduboy-Python-Utilities and follow the instructions there to install MR.Blinky's Arduboy Python utilities. If you do not have a python installed, you need to follow the instruction to install python and the required python modules first.
4. Connect the Arduboy to the USB port of your computer. Switch on the Arduboy.
5. Start the shell program in your operating system e.g. the terminal app in Mac OSX or the command prompt in windows to type the following commands to upload the hex file to the Arduboy. Taking our previous sketch picovaders.ino as an example.
python uploader.py picovaders.ino-arduboy-promicro-ssd1306.hex
6. Once the game is uploaded, the Arduboy will reset and start the game.
Step 6: Write Games to Serial Flash
1. To write the consolidated game file to serial flash, you need to use MR.Blinky's Arduboy Python Utilities again. You should have this already installed if you follow the previous step.
Otherwise, browse to https://github.com/MrBlinky/Arduboy-Python-Utilities and follow the instructions there to install MR.Blinky's Arduboy Python utilities. If you do not have a python installed, you need to follow the instruction to install python and the required python modules first.
2. Create the index file for the consolidated game image file to hold as many as 500 games.
We will use the Use the flashcart-builder.py script to build the a consolidated game image files for all the games you want to store into the serial flash of the Arduboy. A 16MB Serial flash can hold as many as 500 games. This script builds a binary flash image from an index file (.csv) and the following 2 files for each game: a. .hex files that is the text file containing the hexadecimal codes of the binary images of the compiled Arduboy games. Refer to the See the example-flashcart\flashcart-index.csv file for example syntax. This file is included in the package if you click Clone or Download. b. .png graphical image files to be displayed on the bootloader menu on Arduboy so you know which game you will be selecting. Some of the game repositories will have this graphical file together with their game source file or hex file. If you cannot find it, you can create your own by either running the game on the Arduboy emulator (https://felipemanga.github.io/ProjectABE/) and capture the screen. Or just type the name of the game on a power pint, then screen capture that. Then the graphics you captured/created down to 128x64 pixel using paint brush in windows, or preview in Mac OSX.
The youtube video also explains how to put things the right place of this .csv index file. One thing to note, the examples .csv file from MR.Blinky's GitHub is used in Windows PC, backslash "\" are used in the pathnames . If you are using a liunx system or MAC OSX you need to change it to "/".
To get a quick start, you can download my package of 63 games from https://github.com/cheungbx/ArduBaby 63games.zip
This package contains the hex files and png files of the 63 games I have chosen, plus the games.csv index file and the games-image.bin file that is built using the flashcard-builder.py script.
You can add more games into games.csv and build your own consolidated game binary image file to be written to the serial flash. You can put max 500 games on the 16M serial flash.
I'll explain how to make the .csv file using the games.csv that you can download form my GitHub.
Even though the .csv file can be opened using excel. DO NOT use excel to open the file. It'll corrupt the file. Please use a plain text editor only. You can use notepad in windows. I used the textEdit in MAC and click "Format"-> "Make Plain Text".
The first line of the .csv file is the header you can ignore. List;Discription;Title screen;Hex file
The second line point to the graphical image file (must be 128x64 pixel in png file format) for the boot loader manu screen. 0;Bootloader;arduboy_loader.png;;;
The games are configured starting from the third line. Games are organised into groups in the bootloader menu called categories. This line is the group title of the list of games for that group e.g. Action Game. It also points to the graphical image file for the group of games. The "1" at the beginning denotes group number 1. All games that follows this group will start with this number. 1;Action Games;category-screens\Action.png;;;
Then you add one line for each game within that group. Starting with group number 1, name of the game, and the path of the graphic file for a snapshot of the screen, and the path of the hex file. All separated by ";". Add one more ";" to skip the parameter for the save file. 1;1943;Arcade/Nineteen43.png;Arcade/Nineteen43.hex;; 1;2048;Arcade/2048.png;Arcade/2048.hex;;
After you finished the first group of games, you can add the second group of games and so on. e.g.
9;Demo & Test;demos/demotest.png;;; 9;Hot butter;demos/HotButter_AB.png;demos/HotButter_AB.hex;; 9;Flashcart test;demos/flashcart-test/flashcart-test-title.png;demos/flashcart-test/flashcart-test.hex;demos/flashcart-test/badapple-frames.bin;
The last line has a save file in the parameter which is a cartoon movie.
3. To build the consolidated game image file, type the command , where games.csv is your game index file.
python flashcart-builder.py games.csv
This will create a file named games-image.bin
4. Write the consolidated game image file to Arduboy.
We use MR.Blinky's flashcart-writer.py script to write the consolidated game image file to the serial flash memory of the Arduboy.
If you are using my sample games-image.bin file you can type this command.
python flashcart-writer.py games-image.bin
If you are using an SSD1309 OLED screen instead of the SSD1306 OLED on the standard build, you can patch the screen driver on the fly. To automatically apply the SSD1309 patch to the uploaded image, make a copy of flashcart-writer.py and rename it to flashcart-writer-1309.py. Then type
python flashcart-writer-1309.py games-image.bin
Step 7: Play Games From Serial Flash
To play games from serial flash, switch on the Arduboy.
If you already have a game loaded, the game will start automatically. Press the reset button on the top of the Ardubaby once to go to the bootloader menu.
The bootloader menu will be displayed. The RGB LED will light up in sequence.
If you see an icon that looks like a USB port displayed instead, that means your serial flash memory chip is not working. Pls check the wiring.
If you do not press any keys within 12 seconds, the game already stored in the ATMega32U4's internal flash memory will be run.
To go back from a game to the bootloader menu, just press the Reset button once.
You can press the left or right button to scroll through the different category (group) of games. Press the down or up button to scroll through the games within a category (group). Press the "B" button to copy the game from the serial flash memory onto the ATMega32U4's internal Flash memory. The game will start within a second.
Now you have a tiny game console that you can play on the road.
I challenge you to collect and load up your 16M Serial flash with 500 games. I haven't seen anyone who's done that yet to fill up the serial flash. If you can do that, do share that consolidated game file with us.
Step 8: References
A full instruction of this will be published in this link of Instructables.com
Youtube video for the demonstration of the ArduBaby game console https://youtu.be/o-qVoYADaHU
Youtube video for the 3.3V modification of the USBasp bootloader programmer. https://youtu.be/VeiZZJ9koNY
Game files and schematics of the circuit in this video can be found at this GitHub link https://github.com/cheungbx/ArduBaby
MR.Blinky's GitHub link for Arduboy home made package https://github.com/MrBlinky/Arduboy-homemade-pack...
MR.Blinky's GitHub link for python utilities for game upload and serial flash memory operations https://github.com/MrBlinky/Arduboy-Python-Utilit...
Erwin's Arduboy Game Collections http://arduboy.ried.cl
Credits to the creator (Kevin Bates), the Arduboy is a very successful 8 bit game console. There were thousands of games written by the hobbyist who shared them freely on the community forum of Arduboy so more people can learn how to code.
Credits to MR.Blinky for creating the homemade package , the flashcart, and the python utilities.