Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12748 Discussions

Question about multiprocessor code execution

Altera_Forum
Honored Contributor II
1,324 Views

When I use nios2-download to send an elf file to a multiprocessor system, how does it know which processor to use to execute the code? Is it solely based on the addresses in memory that the code is loaded into?  

 

For instance, Altera's multiprocessor tutorial runs identical C code on each processor. The ELF files are different though, I assume because of the changes you make in the system library properties. Assuming both processors were running identical code though, would I be able to run cpu1's ELF file on cpu2 just by using nios2-elf-objcopy to change the addresses?
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
527 Views

Hi! 

 

 

--- Quote Start ---  

originally posted by bkucera@Dec 22 2005, 11:56 PM 

when i use nios2-download to send an elf file to a multiprocessor system, how does it know which processor to use to execute the code? is it solely based on the addresses in memory that the code is loaded into?  

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=11753) 

--- quote end ---  

 

--- Quote End ---  

 

 

I never used nios2-download directly, (I always debugged from the Nios II IDE)but I guess the parameters --instance and --device of nios2-download should be used for that purpose... 

 

 

--- Quote Start ---  

originally posted by bkucera@Dec 22 2005, 11:56 PM 

for instance, altera&#39;s multiprocessor tutorial runs identical c code on each processor. the elf files are different though, i assume because of the changes you make in the system library properties. assuming both processors were running identical code though, would i be able to run cpu1&#39;s elf file on cpu2 just by using nios2-elf-objcopy to change the addresses? 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=11753) 

--- quote end ---  

 

--- Quote End ---  

 

 

At a first though, I would say "probably not"... 

In general, the code that is contained in the ELF file for each CPU is the code of the application plus the drivers... you need to have the -same- memory map and peripheral map to do that ... also you may end up in problems if some addresses are hardcoded in the binary image (like all the peripheral addresses contained inside system.h ... 

 

...just a curiosity, what is the behavior you would like to implement? 

 

Merry Christmas, 

 

Paolo
0 Kudos
Altera_Forum
Honored Contributor II
527 Views

 

--- Quote Start ---  

originally posted by paolo.gai@Dec 23 2005, 04:51 PM 

at a first though, i would say "probably not"... 

in general, the code that is contained in the elf file for each cpu is the code of the application plus the drivers... you need to have the -same- memory map and peripheral map to do that ... also you may end up in problems if some addresses are hardcoded in the binary image (like all the peripheral addresses contained inside system.h ... 

 

...just a curiosity, what is the behavior you would like to implement? 

 

merry christmas, 

 

paolo 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=11767) 

--- quote end ---  

 

--- Quote End ---  

 

 

You&#39;re probably right about the memory/peripheral map being different. I guess I was actually thinking about some other threads asking about how to load multiple programs into flash, and then use a custom bootloader to selectively load them.  

 

In a multiprocessor system, the extension of that would be, is it possible for one processor to load code from flash into SDRAM and cause it to run on another processor?
0 Kudos
Altera_Forum
Honored Contributor II
527 Views

 

--- Quote Start ---  

originally posted by bkucera@Jan 3 2006, 07:00 PM 

in a multiprocessor system, the extension of that would be, is it possible for one processor to load code from flash into sdram and cause it to run on another processor? 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=11911) 

--- quote end ---  

 

--- Quote End ---  

 

 

I think so, but I never tried it... 

the code should be crafted to be loaded and executed on the other processor, and the memories should be shared between the two CPUs... then you can write the memory from one CPU, then just send a message to the other CPU saying you want to execute some code at some location, and the second CPU could wake up and jump to the appropriate location... 

 

bye 

 

Paolo
0 Kudos
Altera_Forum
Honored Contributor II
527 Views

 

--- Quote Start ---  

originally posted by paolo.gai+jan 3 2006, 12:43 pm--><div class='quotetop'>quote (paolo.gai @ jan 3 2006, 12:43 pm)</div> 

--- quote start ---  

<!--quotebegin-bkucera@Jan 3 2006, 07:00 PM 

in a multiprocessor system, the extension of that would be, is it possible for one processor to load code from flash into sdram and cause it to run on another processor? 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=11911) 

--- quote end ---  

 

--- Quote End ---  

 

 

I think so, but I never tried it... 

the code should be crafted to be loaded and executed on the other processor, and the memories should be shared between the two CPUs... then you can write the memory from one CPU, then just send a message to the other CPU saying you want to execute some code at some location, and the second CPU could wake up and jump to the appropriate location... 

 

bye 

 

Paolo 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=11912)</div> 

[/b] 

--- Quote End ---  

 

 

Ok, but how would sending that message work? Doesn&#39;t that imply that there&#39;s already some code running on that CPU waiting to receive the message?
0 Kudos
Altera_Forum
Honored Contributor II
527 Views

 

--- Quote Start ---  

originally posted by bkucera@Jan 3 2006, 08:48 PM 

ok, but how would sending that message work? doesn&#39;t that imply that there&#39;s already some code running on that cpu waiting to receive the message? 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=11913) 

--- quote end ---  

 

--- Quote End ---  

 

 

Yes... the second CPU have to stay somehow sleeping (e.g., in an onchip memory inside a loop), then when the transfer is completed the CPU recognises it and you have to jump to the right location... there was a thread on a similar topic a few days ago on the forum... 

 

(I looked for it bu I couldn&#39;t find it again, sorry!) 

 

bye 

 

Paolo
0 Kudos
Reply