Go Down

Topic: Expand flash memory on Arduino (Read 12037 times) previous topic - next topic

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.

PeterH

Have you reviewed your code to see whether it could be made smaller?
I only provide help via the forum - please do not contact me for private consultancy.

matinzk


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.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

retrolefty


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

PeterH

I only provide help via the forum - please do not contact me for private consultancy.

liudr


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.

orangeLearner

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.

holmes4

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

http://en.wikipedia.org/wiki/Overlay_(programming)

Mark

AWOL

You could use a programmer, and reclaim the space taken by the boot loader.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

wildbill

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  ;)

liudr


The tricky part will be persuading them to read that much code  ;)


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.

JoeN

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.
I have only come here seeking knowledge. Things they would not teach me of in college.

matinzk

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.

Graynomad

Quote
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
Rob Gray aka the GRAYnomad www.robgray.com

Go Up