Emulation with simavr-arduboy

Don’t sweat it, those are pretty minor issues for the way I’m using this, at least. It’s been immensely helpful as I’ve been using it as a near-live preview for implementing game UI, and instantly testing the behavior of other game data. In the future, I’d like to be able to use this as part of automated testing.

I will document the steps for Windows 10, but basically is getting the Bash Terminal from the Windows Store https://www.microsoft.com/store/apps/9NBLGGH4MSV6 and an xwindow server (and checking google for solving the compilation errors… like a normal linux user)

1 Like

In fairness that’s a bad way for a game to ‘crash’ itself, that’s what exit(0) is for.

I wasn’t aware that worked on an Arduino. I figured it would be better to put it in a known state, since there’s no OS to fall back to! But thanks, I’m still working on improving my debugging tools. Although, after looking it up, it seems like exit(0) just puts it in an infinite loop anyway. :smiley:

It also stops interrupts, and I’m not sure if it’s the same for all devices.
I had a feeling on certain devices it had a means of handling things diffferently, I can’t find exit in the source code though.

It might be possible to tweak the simulator to recognise RJMP -2 and halt accordingly.

OK, here are the Windows 10 instructions:

  1. Install Ubuntu Bash from the Windows Store (https://www.microsoft.com/store/apps/9NBLGGH4MSV6). Google the instructions, I think you have to enable developer mode
  2. Install an X-server for Windows, for example Xming (free) http://www.straightrunning.com/XmingNotes/ or Xmanager (paid) https://www.netsarang.com/products/xmg_overview.html
  3. Checkout simavr-arduboy as instructed above in Linux/Mac instructions (you can use Github desktop):

The following steps are inside the ubuntu bash. Go to simavr directory and open a bash terminal from there:

  1. Make the terminal use the X-server you installed with sudo nano $HOME/.bashrc and add export DISPLAY=:0 at the end. Exit and save with Ctrl+X, Y. Exit and reopen the terminal.
  2. Install dependencies: sudo apt-get install pkg-config freeglut3-dev mesa-utils make libmpc3 gcc gcc-avr avr-libc
  3. make
  4. Run it from the examples/board_arduboy directory with ./obj-x86_64-linux-gnu/sim_arduboy.elf path_to_hex
  5. A window will pop with the game

The Ubuntu terminal works in a similar fashion to the old cmd or powershell, so it is possible to send commands as the argument, for example bash -c "some linux command" so the integration could be seamless:

But that is for another moment.

I managed to get it going, but I had issues with the instructions as they are detailed above. I wasinstalling on a Macintosh with Sierra 10.12.6

Produced the error below:

Error: osx-cross/avr/simavr is a head-only formula
Install with brew install --HEAD osx-cross/avr/simavr

I simply installed it using the suggested command.

Produced the error below:

Cloning into ‘simavr-arduboy’…
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I changed the command to:

git clone GitHub - dxxb/simavr-arduboy: simavr is a lean, mean and hackable AVR simulator for linux & OSX

… and it worked properly.

Thank you @filmote and @eried! I have updated instructions for OSX and added a link to the post with instructions for Windows 10.

This is really good. I would love to see this actively developed.

Is there any way to display the serial output?

This is really good. I would love to see this actively developed.

Thanks! But it IS being actively developed :face_with_raised_eyebrow:

Is there any way to display the serial output?

Not yet but it is on the todo list. I haven’t tried yet but I believe simavr should have most (if not all) of the bis and pieces to emulate the serial port.

:astonished: Sorry I meant contributed to (by others) !

1 Like

:smile: I’d love to see that too. People are welcome to open pull requests on GitHub to contribute code. For those who want to contribute, please discuss what they intend to do first mostly to avoid duplication of effort.


I’d love to help get it to the point where it could run on windows natively without having to do all the ‘install ubuntu and x-window server’ shenanigans.

It’s using SDL at its core, so I don’t see how it came from using a cross-platform library to not being able to run on Windows.
(I know that’s not your fault, it’s the actions of the person (or people) who wrote the original that you forked.)

Sadly doing so isn’t high on my list of priorities at the minute, I’ve got several other projects to tie-up first before I could actively contribute.

@filmote For what it’s worth, I understood what you meant by ‘actively developed’.

I would love to have a C# emulator :stuck_out_tongue:

1 Like


I pushed a new update. Some fixes to simavr and some improvements to the arduboy board. I looked into serial I/O and I saw there is a set of patches to support usbip being evaluated right now. The issue with usbip is that it’s most likely going to work on linux only.

Are you referring to simavr? Not sure if it used SDL in the past but it doesn’t now. It’s strange though for the core of a simulator to rely on SDL. What I noticed is that the code assumes GNU compiler extensions so there is very little hope to make it compile with Visual Studio.

Speaking of SDL, I want to swap the current GLUT based implementation of window handling with SDL.

Me too, it looks like simavr itself doesn’t depend on many libraries. Using cygwin, SDL libraries and an Arduino IDE installation as shortcut for installing avr-libc and avr-gcc should be enough to compile on a windows system.

Next I’ll look into enabling support for gdb debugging of the .hex image being run.

Do we use the same git command to retrieve this one?

Do we use the same git command to retrieve this one?

From the root of the git repo run: git fetch origin and then git reset --hard origin/arduboy
This will force your lock repository checkout directory to match the remote branch arduboy.

1 Like

Ah, I double checked and there was a readme of one of the boards that had a mention of SDL but nowhere else. Either I skimmed that and got the wrong end of the stick or I completely got my wires crossed because I’ve been involved in another project that uses SDL recently.

I could possibly help you there, I have a fair bit of experience with SDL2. I’ve never done anything too fancy but I’ve got OpenGL contexts running before and done the basics like opening windows, making an event-handling loop, setting up and using a renderer. (As a heads up: make sure that if trying to make a hardware accelerated renderer doesn’t work, that you try to use a software-based one before making the program give up. I used to have a laptop and long-story short, accelerated rendering doesn’t like certain computers that don’t have GPUs or Windows’ “safe mode”, but software rendering does.)

I uploaded a simple program I made a few years back to github.

I have several copies of SDL2 and I have the Arduino IDE but no Cygwin as of yet.
I haven’t had chance to look under the hood to see how/why it’s using them, and I’ll be honest, me and make don’t get on very well, I’ve only ever managed to successfully use it once. I’m more of a ‘write my own’ kind of person when it comes to tools.

To be honest though I’m alright with waiting until I’ve got the time to read through the code and play around with it.

Unlike poor @filmote I’ve still got an actual Arduboy to test things on.

I’m pretty sure I remember that teacher who was on here a while back asking about a simulator though. I can’t remember her name, I’ve got a feeling her icon/avatar was a duck though. Either way, she’ll probably be thrilled when she finds out.

Its coming soon … I can see they have left Singapore and Australia is not that far away!

1 Like

@Zanners59 was her name.