I know this fits close to the "stupid-question" category, but I've been researching how to execute machine code after bootloading on AVR 8-bit and have come to an understanding that the Harvard Architecture that is used on the AVR 8-bit MCUs makes it impossible to execute code from anywhere other than flash. How then is it possible to introduce new executable code at runtime using inline asm?
How is inline assembly possible on AVR 8-bit?
433 Views Asked by JSON AtThere are 2 best solutions below
nqtronix
On
... the Harvard Architecture that is used on the AVR 8-bit MCUs makes it impossible to execute code from anywhere other than flash.
Your understanding is correct, code can be only excecuted from flash.
How then is it possible to introduce new executable code at runtime using inline asm?
You can write code which writes/reads the Flash memory as plain data. In fact this is exactly what is done by any bootloaders. Even if there is no explicit "boot loader section", such as in the attiny family, accessing the flash in this way is possible. The datasheet of your part (page 263 in this example) contains a chapter for this topic, I'd suggest reading it in detail.
That said, I've not seen code which utilizes this function for running additional yet. The additional complexity might make it infeasible for a small, low power microcontroller like the AVR.
Related Questions in ASSEMBLY
- (x64 Nasm) Writeline function on Linux
- Is the compiler Xcode uses to produce Assembly code a bad compiler?
- Why do we need AX instead of MOV DS, data directly with a segment?
- Bootloader in Assembly with Linux kernel
- How should the byte sequence 0x40 0x55 be interpreted by an x86-64 emulator?
- C++ code into assembly
- Drawing circles of increasing radius
- Assembly print on screen using pop ecx
- Equivalent to asm volatile in Gfortran?
- Show 640x480 BMP image with inline ASM c++
- Keep track of numbers entered in by a user in assembly
- 8086 Assembly Arrays with I/O
- DB ASM variable in Inline ASM C++
- What does Jump to means in callgrind?
- How to convert binary into decimal in assembly x8086?
Related Questions in MICROCONTROLLER
- HOW to connect my UPS with my android device
- What is the difference between USB host VS USB OTG support when it comes to Microcontrollers?
- STM32F4 Handling peripheral error while making a DMA Transfer (RX)
- USB Full Speed polling interval
- Which is better? int8_t vs int32_t in 32 bits MCU
- Detecting EEPROM data and address bus short circuit
- Incrementing an int in a C code for microcontroller only moves the LSB
- Using SD card as external storage for Beaglebone Black
- arm-none-eabi-ld: section .ARM.exidx overlaps section .data
- FT801 chip id error on Arduino
- lpc17xx frequency detection of square wave using polling
- How to debug C program on microcontroller
- Char array of array values to pointer array
- Embedded software program block, I2C?
- Reset vector not working though RCHW is loaded with start address in MPC5777M?
Related Questions in AVR
- saving an array in EEPROM
- How to call multiple slaves for Spi data transmission?
- Changing just one byte in SD card sector
- is it possible compare a 16-bit value with a 8-bit compare match ISR
- UART RX Interrurpt fired too early
- Making a member function static makes the program fail to compile. Can't figure out why
- Arduino Programming Without Arduino Libraries - Atmel Studio
- SPI with Atmega32 and At42QT2100
- XMega: CDC on USB composite controller does not function properly
- How to build avr-gcc using android NDK
- PySerial dataSend doesn't receive data
- Efficient bit checking in embedded C Program
- Issue sending c char* over USART
- What is the efficient way of parsing string on embedded system?
- Controlling 3 stepper to move on xyz direction
Related Questions in AVR-GCC
- Ultrasonic Sensor in AVR
- itoa function for byte array
- Mismatching MCUCR definitions between handbook and AVR-GCC library
- C PROGRAMMING CODEVISION AVR
- CPUs with addressable GPR files, address of register variables, and aliasing between memory and registers
- Call const function address passed to gcc inline assembler (avr-gcc)
- AVR C won't run interrupt
- C doesnt parse array first element - AVR GCC
- Can I put a complete namespace in a specific section?
- avr-gcc destructive optimizations
- How to store additional code sections in FLASH memory (AVR, GCC)
- AVR: Relocation truncated to fit
- Is it possible to compile code written for Arduino on iOS?
- avr-gcc array with pointers to functions in program (flash) memory
- atmega16 single port checking in while() loop or if()
Related Questions in HARVARD-ARCHITECTURE
- booting linux on harvard architecture
- Aren't the von Neumann model and the Turing model practically the the same thing?
- How can I tell whether my computer is Harvard or von Neumann architecture?
- Where does code memory in Harvard architecture refers to?
- configuring the overlapping address for code and data in linker script
- How would I take a simple program to multiply two numbers in MARIE assembly and rewrite it in a language readable for a one address VM
- Any advantages of von Neumann architecture?
- Is the Raspberry Pi based on Harvard Architecture?
- Harvard Architecture maps to HLL
- How to make two otherwise identical pointer types incompatible
- Does the Harvard architecture have the von Neumann bottleneck?
- Retargeting gcc/llvm for a new Harvard architecture RISC
- Initialising global variables in C in Harvard CPU
- In the Harvard Architecture, are there two MAR's and MBR/MDR's?
- How is inline assembly possible on AVR 8-bit?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You are mixing up three things:
Inline assembly
Inline assembly is used to pass assembler instructions to the C (or whatever language) compiler. The compiler will add that assembler instructions to the code it produces. In the end the inline assembler instructions are stored the same way as instructions that have been generated by the compiler. If you write the program to the flash memory the inline instructions will also be located in flash memory.
Boot loader
The boot loader typically will read data from some input (such as an USB interface) and write the data into the flash memory. So the program sent to the AVR will later be executed from flash memory, not from RAM.
Executing code from RAM
Many processors support that. Also many boot loaders (for other microcontrollers) allow loading code into the RAM instead of flash and executing the code from there. You are right: At least most (maybe all??) AVR 8-bit microcontrollers do not support this!