AVR boot loader question

Background:

I'm working on an arduino project that uses the Atmega328 chip which is limited to 2K ram but run into an issue were I run out of RAM, however I have available PROGMEM space.

The program uses an LCD screen to display real time information from sensors but also has menus for changing configurations using buttons.

Is there a way to split up the individual sketch into 2 sketches which would both reside in the program memory and load only 1 of the sketches based on holding a button (i.e. pin 1 is low or high)?

I haven't seen anything like this out there in the wild, but I want to know if someone who knows enough about this could tell me if its feasible.

V/r,

-Mapes

mapes:
Background:

I'm working on an arduino project that uses the Atmega328 chip which is limited to 2K ram but run into an issue were I run out of RAM, however I have available PROGMEM space.

The program uses an LCD screen to display real time information from sensors but also has menus for changing configurations using buttons.

Is there a way to split up the individual sketch into 2 sketches which would both reside in the program memory and load only 1 of the sketches based on holding a button (i.e. pin 1 is low or high)?

I haven't seen anything like this out there in the wild, but I want to know if someone who knows enough about this could tell me if its feasible.

V/r,

-Mapes

No, only one sketch per upload allowed.
However your problem sounds like it could most likely be solved by moving a lot of your print statements to the lcd of constant string data to FLASH memory in your sketch rather then having them occupy SRAM memory. If you search around I'm sure you can find examples of how to do that.

Lefty

I lot of the forum posts I have read recommend putting all of the strings into progmem as well.

If I can not have two sketches could I make 1 sketch that first performs the menu, and then after the menu is settings are completed and stored in the eeprom, clear the ram of all the menu data (strings, min/max constants, etc)?

I've heard this being mentioned on another forum post of RAM being recovered from functions. Is this a possibility?

V/r,

-Mapes

I guess it's sorta possible, in principle. You'd be counting on the fact that each individual sketch would be copying/using JUST that RAM that it needed. There are major complications with data-that-must-be shared (like the interrupt vector table.)

You can have your high-level code do pretty much the same sort of things. Replace ram strings with progmem strings, put variables inside function (on the stack) instead of in globals, etc.

Hi Mapes

You can free up a tremendous amount of RAM by moving the strings to PROGMEM so they're only consuming RAM for a short time during runtime rather than being allocated from the start. You also have the EEPROM for this purpose, though it's a 2 step process rather than just using the F() macro inline in your code. ie have a preload sketch that writes these literals to the EEPROM and access them during your main sketch's runtime in the order you know them to be.

To be certain though, what was your symptom you saw for running out of RAM?

Cheers !
Geoff