/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / Execute code from an SD card

Username:     
Password:     
             

Forum

# 1   2010-05-22 10:54:13 Execute code from an SD card

tkj
Member
Registered: 2009-08-21
Posts: 31

Execute code from an SD card

Hi.
I would like to know if it's possible to save applications (or just code) on an SD, and then execute it?
Maybe if the code is copied into RAM first?

Best Regards
Thomas Jespersen

Offline

 

# 2   2010-05-22 12:37:03 Execute code from an SD card

ntrf.zns
Member
From: Belgorod, Russia
Registered: 2009-11-01
Posts: 134

Re: Execute code from an SD card

You can't run programs from SD card directly. You will have to copy them to RAM first. Then you need the correct linker script for such programs, so they would know the are located in RAM. If you want multiple applications to be loaded, you'll also need a relocation table.
Also remember that you need to fit code, data and stack in less than 64Kb of RAM.

Offline

 

# 3   2010-05-22 13:03:52 Execute code from an SD card

tkj
Member
Registered: 2009-08-21
Posts: 31

Re: Execute code from an SD card

Do you have an example on this?
Or any links where I Can read about this?

Offline

 

# 4   2010-05-22 21:58:47 Execute code from an SD card

diabolo38
Member
Registered: 2010-03-12
Posts: 50

Re: Execute code from an SD card

I'm not a circle/primer2 nor arm stuff expert yet wink but i guess like for most cpu  it is possible to write PIC (Position Independent Code)  that do not not rely on their location in the memory space .  if your sd stored code is prety much standalone and PIC then you may find your way easily.  Take a look at objcopy objdump tools you may also have to build with specific option to skeep standard lib and startup (crt0).

But now if you want to use the circle os service or if your code isn't PIC  then i believe it could be tricky, at least  you would have no choise than relocating the binarie that is  writing a program loader app.  It might not be much complex  it depend on  the binarie format  , if it is a quite simple header with program  entrie + relocation table then you "simply" need to offset all table reference with the load adress (binarie is built to be loaded at address 0) and then call the entry point . I wrote some long time back a relocator for pc  ".exe" format  and it was prety much this ....so not too complicated wink

some info here maybe http://infocenter.arm.com/help/topic/co … 1A_Elf.pdf

anyway good luck wink

Offline

 

# 5   2010-06-03 09:14:27 Execute code from an SD card

tkj
Member
Registered: 2009-08-21
Posts: 31

Re: Execute code from an SD card

Hmm I really don't know how to do this sad
I'm not an expert when it comes to the ELF files...
Any help would be appreciated!

Offline

 

# 6   2010-06-03 14:14:39 Execute code from an SD card

ntrf.zns
Member
From: Belgorod, Russia
Registered: 2009-11-01
Posts: 134

Re: Execute code from an SD card

I think it's pointless. It will be much easier to write some kind of virtual machine. Ofcourse you won't get as much speed as if you had a native code, but you'll get it working in a few days.
Try googling about pascal virtual machines. Maybe BCPL will work as well.
More complicated scenario is to build JIT-compiler.

Well... in a few weeks i'll do it myself anyway.

Last edited by ntrf.zns (2010-06-03 15:45:40)

Offline

 

# 7   2010-06-04 09:19:54 Execute code from an SD card

perz
New member
Registered: 2008-03-04
Posts: 6

Re: Execute code from an SD card

Just out of my head, wouldn't it be nice with an application to circle-OS to be able to load an application from an SD-memory! This would make the OS a bit more of a real OS and make the use of primer a bit more than just a learning platform!

Offline

 

# 8   2010-06-04 11:30:58 Execute code from an SD card

repzak
Member
Registered: 2008-03-05
Posts: 170

Re: Execute code from an SD card

Hello,

But is the primer more than a learning platform?

Kasper

Offline

 

Board footer