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 answers
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
- Is there some way to use printf to print a horizontal list of decrementing hex digits in NASM assembly on Linux
- How to call a C language function from x86 assembly code?
- Binary Bomb Phase 2 - Decoding Assembly
- AVR Assembly Clock Cycle
- Understanding the differences between mov and lea instructions in x86 assembly
- ARM Assembly code is not executing in Vitis IDE
- Which version of ARM does the M1 chip run on?
- Why would %rbp not be equal to the value of %rsp, which is 0x28?
- Move immediate 8-bit value into RSI, RDI, RSP or RBP
- Unable to run get .exe file from assembly NASM
- DOSbox automatically freezes and crashes without any prompt warnings
- Load function written in amd64 assembly into memory and call it
- link.exe unresolved external symbol _mainCRTStartup
- x86 Wrote a boot loader that prints a message to the screen but the characters are completely different to what I expected
- running an imf file using dosbox in parallel to a game
Related Questions in MICROCONTROLLER
- ESP32 Consequtive Interrupt WDT Timeout Exception
- STM32G030 refuses write to flash
- can't configurate VL53l0x api
- STM32L011K4Tx Compare toggle not working as expected
- How to get PC of first instruction of inline asm block (C)?
- ESP-32 (FreeRTOS): The serial monitor prints unknown symbols (???) instead of a string
- SWO on a Blackpill board
- I2C LCD1602 interfacing with PIC16F877A
- J-Link script to flash program in S32K144 (allow security)
- Design of a function that modifies from 1-4 values of a register
- Is it possible to change values of the zephyr-rtos configuration file prj.conf using CMake arguments?
- Memory Aliasing to a specific Flash Sector
- How to make a proper delay in a microcontroller?
- USART to serial monitor/pc STM32
- How to use a c++ class as wrapper for timer-interrupts on RP2040 (RPPico)
Related Questions in AVR
- AVR Assembly Clock Cycle
- LED matrix incorrectly displays data from structures
- 8-bit AVR: single instruction to put a value of 1, ~1(-2/0xfe) or 4 into one of the registers not eligible for immediate operands (r0...r15)?
- Ultrasonic range finder HC-SR04 using one timer
- C++ optimization comparing inline classes and functions doesn't seem good enough
- Global variable value doesn't change in ISR in C
- ATTiny1606 Timer TCA0 interrupt not triggering
- AVR-GCC (Arduino) - IEEE 754/IEC 559 compliance
- non-restoring division: how to avoid code bloat for divisor MSB set?
- Problems setting up an AVR MCU programmer in Eclipse 2024-03
- "avr/io.h" not found when compiling assembly for ATmega128
- Ugly Triple Indirection: Extensible Buffer Management Struct
- I didn't receive what I'm expecting via UART communication
- drive ws2812b using avr timer, fast pwm and interrupts
- Might there be a bug at the EEPROM write simulator in ATMEL/Microchip Studio?
Related Questions in AVR-GCC
- make a 38 KHz IR-remote control frequency with delay function
- ATmega328P USART Transmit character printed repeatedly
- AVR-GCC (Arduino) - IEEE 754/IEC 559 compliance
- "avr/io.h" not found when compiling assembly for ATmega128
- How do I access the "most official" repository for architecture specific GCC runtime source files&tests?
- Class template with multiple parameters and default parameter
- 2-wire: TWINT is never set in TWCR after start condition is sent
- C compose unsigned 32-bit integer from four 8-bit integers
- ATmega328P EEPROM not writing
- Casting a constant to a pointer increases .data size by 1000 bytes
- Is it possible to store the float type results obtained from the code calculation in FLASH memory?
- Why are functions executed in the order they are defined and not in the order they are called from the int main() in avr-c?
- avr-g++ stores temporary variables for function parameters in memory
- `if constexpr` does't compile with `avr-g++ -std=c++17`
- figure out flash access AVR ATmega2560
Related Questions in HARVARD-ARCHITECTURE
- 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
- configuring the overlapping address for code and data in linker script
- Initialising global variables in C in Harvard CPU
- In the Harvard Architecture, are there two MAR's and MBR/MDR's?
- Aren't the von Neumann model and the Turing model practically the the same thing?
- Does the Harvard architecture have the von Neumann bottleneck?
- Why is von neumann faster than harvard architecture
- How to make two otherwise identical pointer types incompatible
- How is inline assembly possible on AVR 8-bit?
- Where does code memory in Harvard architecture refers to?
- Is the Raspberry Pi based on Harvard Architecture?
- why do we use RAM model of computation for algorithmic analysis when it corresponds to harvard architecture?
- Which architectures are Harvard and which are Von Neumann?
- Retargeting gcc/llvm for a new Harvard architecture RISC
- How can I tell whether my computer is Harvard or von Neumann architecture?
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?
Popular Tags
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)
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!