6678编程时如果实现每个核的任务独立,或者说每个核有对应的一个main函数吗?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
下面是一个简单的多核启动的例子(core0触发core1~core7的执行),你可以作为参考:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BOOT_MAGIC_ADDRESS 0x0087FFFC
#define GLOBAL_ADDR(addr, corenumber) (unsigned int)addr<0x1000000?\
(unsigned int)addr+(0x10000000+corenumber*0x1000000):\
(unsigned int)addr
extern far unsigned int _c_int00;
int a = 1;
int b = 2;
int c;
void main(void) {
int coreNumber;
unsigned int * bootMagicAddr;
unsigned int bootEntryAddr;
//unsigned int entry = 0x0c0095a0; // address of "_c_int00", read from *.map file
char str[256];
// get DSP core number
unsigned int DNUM = ((*((volatile unsigned int *)(0x01840000))) & 0x000F0000) >> 16;
// output
c = a + b;
printf(str); // printf in CCS
// core0 try to wake up other cores
if(DNUM == 0)
{
kicker_unlock();
for(coreNumber = 1; coreNumber < 8; coreNumber++)
{
// set maggic address of core(coreNumber)
bootMagicAddr = (unsigned int *)(GLOBAL_ADDR(BOOT_MAGIC_ADDRESS, coreNumber));
bootEntryAddr = GLOBAL_ADDR((&_c_int00), coreNumber);
*bootMagicAddr = bootEntryAddr;
// generate IPC to core(coreNumber)
*((volatile unsigned int *)(0x02620240 + (coreNumber * 4))) = 1;
delay(10000000);
}
kicker_lock();
}
}
当多核执行同一个程序时,即用DNUM来区分当前执行程序的是哪个核。例如:
switch(DNUM)
{
case 0:
func0();
break;
case 1:
func1();
break;
case 2:
func2();
break;
case 3:
func3();
break;
case 4:
func4();
break;
case 5:
func5();
break;
case 6:
func6();
break;
case 7:
func7();
break;
default;
break;
}
最近就在搞这个,首先非常感谢看到你的回复,还想请问一下您:
上述例子程序是把所有8个核的程序放在一个工程中,然后用核心号分辨是哪个核的对吗?也就是说最终只生成一个.out文件,然后首先boot到核0,由核0用上述代码给其他核加载是吧?
您有没有相关的简单的例子程序能给我发一下吗?