Can the Atmega328 run code from RAM ?
Dunno. Is why I'm asking. The memory model seems flexible enough but I've not done a deep dive. But this is how programs load and go, no? You can jump to a known address, no? So if you load an array and jump to it. Or does the Harvard architecture prevent that? I know not all Arduinos are Harvard, so it should work on the non-Harvard machines.
This sounds clearly to me like a need for an operating system. Load many large apps into memory from SD card and execute. Pi zero has an operating system, Pico does not. I'm sure it could be done in Pico, but @outbackhut would have to "reinvent the wheel".
No.
Yes.
No, because the boot loader would need to be modified to do this.
lot of confusion in this tread. so some summary
the code on Mega runs from the flash memory. you report 300% of dynamic memory, which is RAM, not flash. so you have to move some data (not code) to flash (or to SD card).
Raspberry Pico is an MCU, not a usual Raspberry Pi mini computer .
the tread should focus on Mega, not on Pi Zero price
Hey, I didn't know that. Which ones are not Harvard?
Ok. thanks for the explanation. Boot loader makes sense.
Read it somewhere, but can't recall. I seem to recall a memory model diagram with two cols, one Harvard and one Von Neumann with different part numbers under each, but I'm not up to speed on all the variants as, for now, I'm strictly MEGA 2560 based. I've got all the power and screw terminal shields and mounts and crap all worked out for that platform.
No thanks
I'm trying to make a Arduino OS
The ARM and ESP -based Arduinos are generally capable of running code from RAM. But most of the SAMD-based boards don't really have enough RAM to make it interesting.
An interpreter (Bitlash, Forth, micro- or circuit- Python) might work if your "applications" are quite short (You'd want to copy them into RAM for performance reasons, probably.)
An RPi Pico, or one of the other boards based on it, has substantial flash (2MB on a Pico to 8MB on an Adafruit Feather rp2040 ($12) or 16MB on a Sparkfun ThingPlus rp2040 ($20 - with an SD socket.)) and enough RAM to make this possible. So do many ESP32 boards.
Note that there would be substantial "software engineering" effort to get individual small "apps" from an SD card working. You'd have to divide up the functions that would be part of the flash-based code, and what functions would be usable from the "apps", and how they would interact. Essentially an "OS", as some have said.
I've moved the stuff about expensive components at the request of one of the contibutors because it wasn't relevant to the OP's question.
The 8K internal RAM becomes dedicated stack space, occupies the 1st 8K address space.
The 8 banks of 64K have their 1st 8K unusable, leaving 8K to 64K heap in 8 banks.
Will you be writing an interpreter that reads source from SD?
== re-inventing the wheel
Generally in this situation, you can just buy your way out of trouble with better hardware (Due, Teensy, Feather for example) and use the Mega for another project.
As noted earlier though, posting your code will likely get you hints about how to reduce your RAM usage.
School's out.
for summer ?
It's winter here ![]()
No second line:-
for ever.
![]()
What you miss is that the AVR Instruction Pointer points into FLASH MEMORY.
Code in flash can read data in RAM (SD has a 512 byte buffer by default) and cause code in flash to execute, which is why I asked if what's wanted is an Interpreter.
Whatever you're planning is going to teach you a lot of what not to do.