0
\$\begingroup\$

So i know this question is being asked almost everyday on thousands of forums, but i am still going to ask that same question but with a different intent.

Question #1: As an example lets use linux bootable stick. you stick it in and you can use the whole operating system without even installing it. What i would like to do is have my code on SD card and plug it in a device of my own (arduino board) and have this arduino execute code (without copying it in to the flash) with ability to select which part of the code it executes. so it is like bunch of independent programs on SD card.

Question #2: And again linux example, basically it copies the OS in to RAM and executes it from RAM, since there is no external ram on any of the arduino boards how can it be attached, maybe using some DRAM controller could help ? for example attaching 2 GB of ram.i know it is overkill or an 8 bit controller, but what if i would like to add more ram to lets say cortex M33 which is 32 bit controller and i am doing some video processing and i need space to store video, results of processing, and store a program that does processing.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ This isn't an EE question. \$\endgroup\$
    – Janka
    Commented May 29, 2019 at 14:27
  • 1
    \$\begingroup\$ You cannot execute code from external media. It has to be loaded into the address space of the CPU, which means system RAM. \$\endgroup\$
    – Janka
    Commented May 29, 2019 at 14:29
  • \$\begingroup\$ choose a platform that matches the task you want it to do rather than choose a platform and try to make it do a task it cant do or doesnt do well...also note that the cortex-m is a core not a chip, your question is related to the chip design not the processor core you have to find a chip that has a memory interface which is independent of the core processor. there are some that have interfaces out there but sounds like you want a pi-zero or a full sized pi. \$\endgroup\$
    – old_timer
    Commented May 29, 2019 at 14:43
  • \$\begingroup\$ It is an EE question with respect to a chip interface and how to use it, but it isnt a stackexchange question (yet). \$\endgroup\$
    – old_timer
    Commented May 29, 2019 at 14:44
  • \$\begingroup\$ @Janka it is EE question cause i am asking about connecting and interfacing of 2 or more hardware elements \$\endgroup\$ Commented May 29, 2019 at 15:21

2 Answers 2

0
\$\begingroup\$

Question #1: As an example lets use linux bootable stick. you stick it in and you can use the whole operating system without even installing it. What i would like to do is have my code on SD card and plug it in a device of my own (arduino board) and have this arduino execute code (without copying it in to the flash) with ability to select which part of the code it executes. so it is like bunch of independent programs on SD card.

That's not a question. But you can do this because your computer copies a program from the USB stick into RAM, then executes it from RAM. That program loads more programs from the USB stick into RAM. Specifically the BIOS/UEFI loads the bootloader, which loads the kernel, which loads all your programs. At no point is anything executing from the SD card; it's all executing from RAM (and the BIOS executes from flash).

The AVR chip used in the Arduino cannot execute code from RAM, only from Flash. There is no way to execute code from RAM because of the way the chip is designed.

You could invent your own programming language, and write an interpreter that reads instructions from RAM or from an SD card. It won't be incredibly fast. There are plenty of resources for writing interpreters on the Internet.

Question #2: And again linux example, basically it copies the OS in to RAM and executes it from RAM, since there is no external ram on any of the arduino boards how can it be attached[?]

The AVR chip used in the Arduino has internal RAM, but not very much. It doesn't support adding more RAM to work with your program automatically, but you can still write a program that accesses a RAM chip by using the digital pins.

, maybe using some DRAM controller could help ?

Possibly. Probably not. I'm not aware of off-the-shelf DRAM controllers that are suitable for use with an Arduino - usually they're integrated into very complex chips (like CPUs). You can use SRAM, or you can look for "PSRAM" or "pseudo-SRAM", which is DRAM with a built-in controller that makes it look like SRAM.

for example attaching 2 GB of ram.

2GB is quite a lot. For 2GB you will probably need to go with DRAM, unfortunately. I can't tell you how to control DRAM from an Arduino but if you really need this then maybe ask a specific question about it.

Do you really need 2GB of RAM? It will take a long time to fill it up at Arduino speeds. If you just need 2GB of storage, consider an SD card.

i know it is overkill or an 8 bit controller, but what if i would like to add more ram to lets say cortex M33 which is 32 bit controller

Some of the STM32 microcontrollers (which are based on the Cortex M33) do have a "FSMC" block, or "Flexible Static Memory Controller", which allows them to automatically access various kinds of external memory, including SRAM and Flash. There should be more information in ST's datasheets and application notes, and Google.

and i am doing some video processing and i need space to store video, results of processing, and store a program that does processing.

Usually a microcontroller is processing video in real time (otherwise you'd do it on your PC). So you should only need to store a few frames of video - not 2GB.

\$\endgroup\$
1
\$\begingroup\$

when I plug a linux stick into my computer my computer is unable to execute from that stick in the same way that an avr is unable to execute from external storage. (there are exceptions but not in the arduio case)

How it works in your computer is code that is on rom (can execute from there) runs and loads code into ram which knows how to load code from media into ram and then run it in ram. And that code in ram can load more code into ram and run that code in ram and so on. You would need to do a similar thing with the arduino.

Another popular approach is to use a scripty (interpreted) language, basic, python, etc. The firmware on the avr could be the virtual machine that interprets a compiled version of the language and that firmware could read that bytecode from any media you choose. Slow, but functions. This is how things like the basic stamp work(ed).

It is rare but there are some mcus (dont think anything avr, but could be proven wrong) that have an sram or other interface that can be mapped into an executable memory space. Kinda stops becoming an mcu at that point, and is usually for cases where you want to run a beefy operating system that wont fit on chip, so a processor/system that is more suited to an operating system being run on it.

\$\endgroup\$
1
  • \$\begingroup\$ I am looking for a direction is which i should go study. i thought about interpreters maybe you can recomend a place where i can find more materials on that topic ?. and regarding Cortex M is core not a chip what do u mean by that ? i thought it falls under MCU with memory and other peripherals on it \$\endgroup\$ Commented May 29, 2019 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.