ZYNQ 双CPU裸机运行例程
作者:互联网
vivado 2014.4
特殊情况:总DDR内存大于512MB,且CPU0已经占用了超过512MB,这时按以下步骤CPU1无法启动。
原因:启动入口地址限制。更改方法如下:
打开cpu1_bsp\ps7_cortexa9_1\libsrc\standalone_v4_2\src\boot.S,注释为以下效果即可
#if USE_AMP==1
// ldr r3, =0x1ff /* 512 entries to cover 512MB DDR */
// ldr r0, =TblBase /* MMU Table address in memory */
// add r0, r0, #0x800 /* Address of entry in MMU table, for 0x20000000 */
// ldr r2, =0x0c02 /* S=b0 TEX=b000 AP=b11, Domain=b0, C=b0, B=b0 */
//mmu_loop:
// str r2, [r0] /* write the entry to MMU table */
// add r0, r0, #0x4 /* next entry in the table */
// add r2, r2, #0x100000 /* next section */
// subs r3, r3, #1
// bge mmu_loop /* loop till 512MB is covered */
#endif
部分所需代码:
#define sev() __asm__("sev")
#define CPU1STARTADR 0xFFFFFFF0 //这个地址是固定的
#define CPU1STARTMEM 0x3D000000 //这个CPU1启动地址是在lscript.ld中设置的
void StartCpu1(void)
{
#if 1
fsbl_printf(DEBUG_GENERAL,"FSBL: Write the address of the application for CPU 1 to 0xFFFFFFF0\n\r");
Xil_Out32(CPU1STARTADR, CPU1STARTMEM);
dmb(); //waits until write has finished
fsbl_printf(DEBUG_GENERAL,"FSBL: Execute the SEV instruction to cause CPU 1 to wake up and jump to the application\n\r");
sev();
#endif
}
-DUSE_AMP=1
#define sev() __asm__("sev")
#define CPU1STARTADR 0xFFFFFFF0
#define CPU1STARTMEM 0x02000000//此处必须与第5步改的cpu1的ddr地址一致
void StartCpu1(void)
{
#if 1
fsbl_printf(DEBUG_GENERAL,"FSBL: Write the address of the application for CPU 1 to 0xFFFFFFF0\n\r");
Xil_Out32(CPU1STARTADR, CPU1STARTMEM);
dmb(); //waits until write has finished
fsbl_printf(DEBUG_GENERAL,"FSBL: Execute the SEV instruction to cause CPU 1 to wake up and jump to the application\n\r");
sev();
#endif
}
//app_cpu0.c为以下代码
#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "sleep.h"
int main()
{
init_platform();
while(1)
{
print("CPU 0 : Hello World\r\n");
sleep(2);
}
cleanup_platform();
return 0;
}
//app_cpu1.c为以下代码
#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "sleep.h"
int main()
{
init_platform();
while(1)
{
print("CPU 1 : New World\r\n");
sleep(3);
}
cleanup_platform();
return 0;
}
标签:sev,r0,例程,裸机,platform,ZYNQ,printf,include,CPU 来源: https://www.cnblogs.com/solo666/p/15953537.html