Pages: [1] 2 3   Go Down
Author Topic: Expand flash memory on Arduino  (Read 10050 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 247
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12577
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

0
Offline Offline
Full Member
***
Karma: 0
Posts: 247
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes,

Need it all.

Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 525
Posts: 26523
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12577
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes,

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

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

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7171
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


0
Offline Offline
Full Member
***
Karma: 2
Posts: 125
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Poole, Dorset, UK
Offline Offline
Edison Member
*
Karma: 50
Posts: 2207
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Mark
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25847
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

"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.

New Jersey
Offline Offline
Faraday Member
**
Karma: 65
Posts: 3638
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-wink
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7171
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The tricky part will be persuading them to read that much code  smiley-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.
Logged


Show Your Work
Offline Offline
Edison Member
*
Karma: 14
Posts: 1072
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I have only come here seeking knowledge. Things they would not teach me of in college.

0
Offline Offline
Full Member
***
Karma: 0
Posts: 247
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8474
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Pages: [1] 2 3   Go Up
Jump to: