Execute code from RAM, not Flash

Libraries, utilities, bootloaders...

Execute code from RAM, not Flash

Postby Sorunome » Fri May 15, 2015 3:06 pm

Is it possible to execute certain code from RAM rather than from Flash?
I want to be able to flash a game with some other logic provided in the bootloader, so I thought of copying the flashing code to ram and running it from there. Is that possible with the AVR?
User avatar
Sorunome
 
Posts: 629
Joined: Sun Mar 01, 2015 1:58 pm

Re: Execute code from RAM, not Flash

Postby Myndale » Tue May 19, 2015 5:52 am

Sorunome wrote:Is it possible to execute certain code from RAM rather than from Flash?
I want to be able to flash a game with some other logic provided in the bootloader, so I thought of copying the flashing code to ram and running it from there. Is that possible with the AVR?


Not directly, AVR chips use Harvard architecture which uses separate storage and buses for data vs instructions. It is, however, possible for the bootloader to write code into Flash memory...that is after all what the bootloader is designed to do. If you look at the standard bootloader you'll see there is code that does just that using data it receives over the serial line, the Gamebuino bootloader also has a special function that games can call directly to program blocks of flash memory.
Myndale
 
Posts: 507
Joined: Sat Mar 01, 2014 1:25 am

Re: Execute code from RAM, not Flash

Postby Sorunome » Tue May 19, 2015 11:52 am

Myndale wrote:
Sorunome wrote:Is it possible to execute certain code from RAM rather than from Flash?
I want to be able to flash a game with some other logic provided in the bootloader, so I thought of copying the flashing code to ram and running it from there. Is that possible with the AVR?


Not directly, AVR chips use Harvard architecture which uses separate storage and buses for data vs instructions. It is, however, possible for the bootloader to write code into Flash memory...that is after all what the bootloader is designed to do. If you look at the standard bootloader you'll see there is code that does just that using data it receives over the serial line, the Gamebuino bootloader also has a special function that games can call directly to program blocks of flash memory.

The problem is that if i flash an entire game eventually the loop which calls the bootloader flash block thingy gets over-written, and I can't use load_game() as it only searches in the root directory.
User avatar
Sorunome
 
Posts: 629
Joined: Sun Mar 01, 2015 1:58 pm

Re: Execute code from RAM, not Flash

Postby hannanbd » Thu Jun 04, 2015 8:56 am

This post is very nice and informational also .I have visited this website again and again to learn many things .Thanks to share with us this post .I know ,all answer are very essential for us .Thanks again for reading this post .
hannanbd
 
Posts: 1
Joined: Sat May 30, 2015 9:56 am


Return to Software Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron