Building games from the command line under Linux

This is not a nice and tidy tutorial, it’s a helping hand to probably only a few people who may be looking for a specific information.

I finally got Arduboy to fit my CLI workflow and would like to share how I did it for people whose workflow is similar.

I have kind of a quick and dirty script that however seems to work. I am sharing it because I haven’t found any similar tutorial here, so hopefully it may help some other GNU/Linux newcomer to jump right in. Feel free to share any improvements on this.

I use vim as a text editor under GNU/Linux and so I want to compile and run everything from the command line. Here is the Bash script I use (I left in the variables set for my current project so that you have an idea of what to change them to):



clear; clear;

mkdir "$SKETCH_DIR/build"

./arduino-builder -hardware ./hardware -tools ./hardware/tools/avr -tools ./tools-builder -libraries ./libraries -libraries "$LIBRARY_DIR" -build-path "$SKETCH_DIR/build" -fqbn arduino:avr:leonardo "$SKETCH_DIR/$SKETCH_FILE"

if [ $? -eq 0 ]; then
  cd "$ABE_DIR"
  ./ProjectABE "$SKETCH_DIR/build/$SKETCH_FILE.hex"

It compiles the sketch using arduino-builder and if the build is successful, runs it in the ProjectABE emulator.

TIP: If it’s reasonably simple, I find it useful to make the .ino file compilable (using a few #ifdefs) for PC with the normal compiler (gcc) for quick debugging. It’s quicker, allows you to print out values in a way you’re used to and allows use of tools such as valgrind, gdb etc. (It also makes you separate the Arduboy specific code from the general logic, which later makes porting to other platforms easier.)

There’s also the Arduino Makefiles, which work well for the ArduBoy

I added one more rule to mine to launch the game in ProjectABE.


@FManga informed me that ProjectABE detects when the hex file changes and reloads it automatically, so it’s actually not even needed to launch it from the CLI. I also find it better because when launching from CLI, the window has a wrong size and position and has to be adjusted with mouse.

Oh nice, I didn’t realize that. I could position the emulator up in the corner and just leave it running then.

1 Like

Maybe one of you guys could help me out, normally I just use my tower for uploading but I wanted to fix my arch installs permissions so I could work on my laptop.

I’m not sure what distros you might use but I’ve added my user to lock and uucp which should solve any permission errors I had. When I attempt to upload however I get this error

avrdude: Error: butterfly programmer uses avr_write_page() but does not
provide a cmd() method.

It seems like the permissions aren’t my problem. Right now it appears to start to write to the arduboy only to get stuck in some error loop and soft brick the device.

hmm, I’ve never seen that error :-/

Are you using avrdude directly? I use the makefile listed above and it is mega complex. So it somehow knows exactly how to invoke avrdude correctly.

There’s also Mr.Blinky’s python uploader which also works well.

Wish I could be more help but I don’t know much about this. I just got lucky it all works fine for me.

No I’m trying to compile source in the ide and upload.

I think it has something to do with access to /dev/ttyACM0 as the uucp group includes /dev/ttyUSB0

It appears some boards use one while lenardo based ones are on acm. It might be permissions or something with stty.

I’ll have to try that makefile and the python script and see if they give the same error before I start firing off chmods

Permission errors are usually just cannot open /dev/ttyACM0: Permission denied in my experience. Which can be resolved by adding yourself to the dialout group on most distros. Your error seems more like a runtime/logic error.

Yes there’s no dialout in arch, think that’s cover by uucp. There’s a long stty -F setting I haven’t tried yet either. Normally the wiki has all the sollutions so I’ll figure it out eventually.