Sketch upload fails: Too Much RAM

Just got my arduboy today

I made this here: https://codebender.cc/sketch:331927

I am using the latest Arduino IDE and the Arduboy library I downloaded through the library manager.

When I upload this, and then try to upload anything else after, the upload fails. Sometimes I can get it to accept some other sketch by using a paper clip on the reset button, but generally this sketch causes the Arduboy to stop accepting new uploads.

What the hell is going on?

That worldMap array will take up over 1K of RAM. The screen buffer requires another 1K, so you’re going to be getting pretty close to using the total RAM available. You’re probably running into a known problem with the bootloader.

Try holding down the UP button when powering up and plugging in your Arduboy. This will enter “flashlight” mode and the RGB LED will light up white and the display will remain blank. (If you have one of the 8000 later Kickstarter Arduboys, with the RGB LED installation problem then the RGB LED will not turn on, but if the display remains blank then you’re probably in “flashlight” mode.) See if you can then load a new sketch.

1 Like

I see. Is there any way I can have a level and use less RAM? Maybe use something like a boolean to store the level data? Or would that even help? I was hoping to include a few sprites in the game

(later edit) I found this http://playground.arduino.cc/Code/DatatypePractices

And discovered that all I need to do is change the worldMap to be a char array instead of an integer array and everything works fine.

Still, it is a pain how limited the RAM is. I’ll have to compress this more

“Flashlight mode” happens with no LED for me. But my green LED works. It’s the white LED which doesn’t.

If the array is constant and you only read from it but don’t have to write to it, you could put it in flash using PROGMEM.

[quote=“MLXXXp, post:4, topic:1795”]
If the array is constant and you only read from it but don’t have to write to it, you could put it in flash using PROGMEM.
[/quote]Thanks, that’s helpful.

(later edit) Adding “PROGMEM” causes strange behavior. I think there might be problems with using that on multi-dimensional arrays.

There isn’t a white LED. The LED to the left of the screen (which probably lights up blue and dims when the ARDUBOY logo scrolls down at the start of the sketch) is an RGB (red, green, blue) LED. It contains a separate red, green and blue LED in one package, each separately controllable. If you light them all at the same time you get white. If yours doesn’t light up in flashlight mode then it’s been installed incorrectly.

Using PROGMEM on things other than single dimensional arrays can be tricky. I think you have to treat everything as a linear group of bytes and do the indexing math yourself. Details are here.