0
\$\begingroup\$

I am working on a project, and for it I need to run a microcontroller program off of an EEPROM. I know I can set it up with an Arduino to load the program into internal memory and run it from there, but ideally I want to be able to run the MCU directly from the EEPROM. Is this possible, and if so, what MCU should I use? The final program should be around 8-16 kilobits large.

asked Oct 22, 2021 at 23:41
\$\endgroup\$
4
  • 1
    \$\begingroup\$ "I need to run a microcontroller program off of an EEPROM"_ - why? \$\endgroup\$ Commented Oct 23, 2021 at 0:47
  • \$\begingroup\$ You can load the program from EEPROM to MCU Flash using bootloader but you are limited by number of erase/write cycles of AVR flash (10k times). Also you must think the Arduino itself uses bootloader already. There are better MCUs for doing this job which can run program from SRAM etc... \$\endgroup\$ Commented Oct 23, 2021 at 1:22
  • \$\begingroup\$ esp8266/esp32 use external serial flash chips and are supported by Arduino tools. Or you can use other techniques like a virtual machine to fetch instructions from the external eeprom/flash and interpret them. There's a few examples of this out on the webs. Or there's languages like uLisp that can read their program from external devices. You're spoilt for options. \$\endgroup\$ Commented Oct 23, 2021 at 1:26
  • \$\begingroup\$ Run an interpreter on the Arduino, use the language of your choice to reside in the EEPROM ....Python, Basic or FORTH. \$\endgroup\$ Commented Oct 23, 2021 at 3:37

3 Answers 3

3
\$\begingroup\$

Only 2K bytes memory? You could use an old-school 80C51 and parallel EEPROM. Maybe okay for an experiment, but hardly recommended for a product.

Or, moving ahead a few decades to the 40nm process node, an RP2040 which has a bootloader to read external QSPI flash into on-chip SRAM. You can use C or Micropython.

But really, your constraint of using an external EEPROM seems highly artificial. If it's not a school project maybe consider an MCU with internal FRAM, flash or something like that.

answered Oct 23, 2021 at 4:24
\$\endgroup\$
1
\$\begingroup\$

The capability you're asking for is called 'Execute In Place', or XiP. And unfortunately the ATMega328 doesn't support this; it only can run from its internal memories. You'll need to use overlays, loading routines in as you use them.

If you want to stick with AVR there are versions with larger onboard flash that could handle your program so you wouldn't need an external EEPROM.

If you're willing to use a larger device (e.g., STM32), many of these support XiP.

Related: https://stackoverflow.com/questions/54283543/confused-about-the-xip-execute-in-place-function-of-qspi-flash

Also: https://www.st.com/resource/en/application_note/dm00514974-external-memory-code-execution-on-stm32f7x0-value-line-stm32h750-value-line-stm32h7b0-value-line-and-stm32h730-value-line-mcus-stmicroelectronics.pdf

answered Oct 23, 2021 at 0:16
\$\endgroup\$
2
  • \$\begingroup\$ Just a comment that XIP usually means running code from an external SPI memory, but the question does not say if the external memory will be a a SPI device or something like 27C16. \$\endgroup\$ Commented Oct 23, 2021 at 8:23
  • \$\begingroup\$ OP put an arduino tag on the Q, which unlike an 8051 doesn’t support execution from a parallel EPROM or EEPROM device like that. As it is, NOR flash has largely supplanted EEPROM for code memory anyway. \$\endgroup\$ Commented Oct 23, 2021 at 17:32
1
\$\begingroup\$

There are a few options for running a microcontroller program from an external interface.

  1. XIP: This interface can typically run programs from a SPI/QSPI serial NAND flash memory. Many ARM processors can do this. The downside of XIP is that its typically serial, so it can take each instruction several clock cycles to load, which means overall execution can be slower.

  2. External Bus Inteface: This is found on some older microcontroller architectures. For example the MC9S12DTxxx family of processors made by NXP have external parallel memory busses that can run from a parallel memory interface such as an SRAM, NOR flash, or ROM.

  3. Have a small boot loader in internal flash that loads the program from the external memory and then executes it. To do this you need a microcontroller that can execute code from SRAM. Some notable examples would be ARM microcontrollers, and MIPS based ones (like Microchips PIC32 series). This is the most flexible options because the external memory could literally be anything. NAND flash, NOR flash, EEPROM, USB drive, SD card, etc.

answered Oct 23, 2021 at 4:41
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.