Expand flash memory on Arduino

Hi everyone.

I'm doing a project using an, Arduino Mega 2560, and currently have ran out of flash memory. In other words my sketch is more than 243025 bytes of course.

Is there a way of expanding the memory on an Arduino at all? I'm stuck at the moment of what I should do.

Any help/suggestions is appreciated.

Thanks.

Have you reviewed your code to see whether it could be made smaller?

Yes,

Need it all.

http://www.ruggedcircuits.com/html/quadram.html

SRAM is available to add - read the '2560 spec & see if Flash is also accessible.
If not, perhaps lookup tables, long strings of text, etc. can be moved out of flash into external memory lke serial EEPROM.

matinzk:
Hi everyone.

I'm doing a project using an, Arduino Mega 2560, and currently have ran out of flash memory. In other words my sketch is more than 243025 bytes of course.

Is there a way of expanding the memory on an Arduino at all? I'm stuck at the moment of what I should do.

Any help/suggestions is appreciated.

Thanks.

Could you explain to us what is in your sketch that is taking up so much program space? That would be one tremendous program if it's all pure code. Are you saving massive amount of string data to flash?

Lefty

matinzk:
Yes,

Need it all.

Yes, but does it all need to be that big?

CrossRoads:
http://www.ruggedcircuits.com/html/quadram.html

SRAM is available to add - read the '2560 spec & see if Flash is also accessible.
If not, perhaps lookup tables, long strings of text, etc. can be moved out of flash into external memory lke serial EEPROM.

I have the QuadRAM. It is just RAM. You can load it up with EEPROM or SD card text strings and start assigning pointers to these strings. Use these pointers the same way as regular memory pointers but the whole 512KB SRAM needs to be paged first (maybe like apple 2) and then accessed directly since the bus is only 16 bit.

matinzk, At the least, if possible, post part of your code for everyone else to give you some suggestions. If you are already using QuadRAM or other expanded SRAM, well, you have a BIG project so never mind. If you are just using the on-board 8KB SRAM, it is hard to believe 240KB of well-optimized code will work with such little SRAM, so there is probably room to spare. I do a lot of code trimming besides contract programming. If interested, PS me.

You have to use data compression and trade some CPU cycles for your memory. Avoid long strings of text and large arrays, or decrease resolution. For example, in the SAE J1939, many different values need to be represented using only 8 or 16 bits, so there is a different multiplier for each type of value. If temperature goes from -256C to 256C, then you can store it as an 8-bit value and multiply it by 2 instead of using a 16-bit value. The tradeoff is that your resolution is now 2 degrees instead of 1.

You could try this with external memory (eg external Ram/flash/sd card).

Mark

You could use a programmer, and reclaim the space taken by the boot loader.

It's obviously a huge sketch, but you might consider posting (attaching) it. It's quite possible someone here will be able to see ways to shrink it. The tricky part will be persuading them to read that much code :wink:

wildbill:
The tricky part will be persuading them to read that much code :wink:

You can only get people to help you debug a few hundred lines of code unless they are doing something very similar to what you are doing. Otherwise, post it on gigs and collaboration and offer a monetary reward. Remember, if the project is this long, you can't compile and debug it without all the attached hardware. Only those with the hardware can help you. Recently I invested $100 in shields to write a program for someone.

Is that sketch really all code or is there data embedded into it (text, fonts, anything) that could be pushed off to a serial EEPROM? Microchip makes some very nices ones that are quite inexpensive and easy to use.

Thanks guys for all the good replies and comments.

I was busy trying to work out a way around making my code smaller, and I think I have succeeded.

The project uses a 4dsystems vga-II module connected to an LCD. I've got a uSD card in the module. Depending on some input to the Arduino images change. I was originally calling each photo directly using the Raw technique within the 4dsystems. This meant each image took 15 lines of code. So imagine if I had 100 images that'd be 1500 lines of code!

Now I have manipulated the code, and used one of the available libraries for these modules, so each image now would have the 1 line to be shown, rather 15.

By the way the project is a prototype for a learning device for a company we're working with and may go into production, upon approval.

The next issue I have is that each image gets drawn very slowly. Do you think I need to upgrade to something like the ChipKit MAX32. I want the images to bang appear not get drawn slowly.

Thanks guys.

This meant each image took 15 lines of code. So imagine if I had 100 images that'd be 1500 lines of code!

I don't understand this but if you've fixed it then good.

As for the speed, do you know where the bottleneck is, you could add an ARM50 and find that it's the serial connection or even the 4DS processor.

Have you done the maths, now many bytes have to be transferred to redraw a screen? What baud rate are you using?


Rob

Graynomad:

This meant each image took 15 lines of code. So imagine if I had 100 images that'd be 1500 lines of code!

I don't understand this but if you've fixed it then good.

As for the speed, do you know where the bottleneck is, you could add an ARM50 and find that it's the serial connection or even the 4DS processor.

Have you done the maths, now many bytes have to be transferred to redraw a screen? What baud rate are you using?


Rob

Not sure how many bytes. The screen is 640 x 480 pixels. I am on 38400 bps baudrate. I have contacted the person who wrote the library also to see if he has tested with ChipKit or not and what the results are.

Thanks.

Are you dumping graphics from the uSD? If so you'd better post on the 4DS forum because it's out of the Arduino's hands.

Or are your drawing lines etc?

What exactly is happening?


Rob

Yes I'm dumping graphics from the uSD.

When I wanna show an image and I call it, it gets drawn fro the top to the bottom and takes probably ~1 second for it to draw, need a faster time than that.

Then I'd get onto 4DS, this has nothing to do with the Arduino as far as I can tell.

I assume you're using serial mode for the display? It may be better to reflash it to 4DGL and write your own code for the PICASO processor but I doubt it.

Possibly another option is to use a faster SD card.


Rob

Imagine it was 4DS that was slow. Is it advisable to go with a system by connecting Arduino to a Raspberry pie like platform? Have Arduino handle the control sides of things and send data to the pie to show as graphics? Is it even possible?

Thanks.