MYIR-ZYNQ7000系列-zturn教程(20):在zynq双核上跑不同的工程

开发板环境:vivado 2017.4 ,开发板型号xc7z020clg400-1,这里主要在两个不同的cpu上跑不同的程序,cpu0跑hello_world工程

cpu1跑一个led不断闪烁的程序,并且两个程序能同时运行。

链接:链接:https://pan.baidu.com/s/1_UY1O6umUUfxR0osuqKLzg    提取码:c0sf 

Step1  新建一个vivado 工程

调用一个zynq核

然后按照下面的截图进行设置

我这里配置了UART和SD卡以及gpio_mio,并且设置DDR的型号以及SDIO频率(不同的开发板有所差异请自行调整)

自动连线后如下图所示

Step2  综合、生成顶层文件,生成bit文件

综合

生成顶层文件

生成bit文件

Step3  导出硬件配置,打开SDK

Step4  新建fsbl

Step5  新建工程app_cpu0

使用hello_world模板

工程新建完成后如下图所示

Step6  新建工程app_cpu1_bsp

我们将Value这部分-mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard -nostartfiles -Wall -Wextra改为-mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard -nostartfiles -Wall -Wextra -DUSE_AMP=1

如下图所示

生成完成后如下图所示

Step7  新建工程app_cpu1

选择hello_world模板

新建完成后如下图所示

Step8   添加cpu0和cpu1主程序

cpu0主程序,我这里将hello_world工程改为每隔一秒打印一次,并且一直运行

​
/******************************************************************************
*
* Copyright (C) 2009 - 2014 Xilinx, Inc.  All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* Use of the Software is limited solely to applications:
* (a) running on a Xilinx device, or
* (b) that interact with a Xilinx device through a bus or interconnect.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name of the Xilinx shall not be used
* in advertising or otherwise to promote the sale, use or other dealings in
* this Software without prior written authorization from Xilinx.
*
******************************************************************************/

/*
 * helloworld.c: simple test application
 *
 * This application configures UART 16550 to baud rate 9600.
 * PS7 UART (Zynq) is not initialized by this application, since
 * bootrom/bsp configures it to baud rate 115200
 *
 * ------------------------------------------------
 * | UART TYPE   BAUD RATE                        |
 * ------------------------------------------------
 *   uartns550   9600
 *   uartlite    Configurable only in HW design
 *   ps7_uart    115200 (configured by bootrom/bsp)
 */

#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "sleep.h"


int main()
{

    init_platform();

    while(1)
    {
    print("Hello World\n\r");
    sleep(1);
    }
    cleanup_platform();
    return 0;

}

​

这里是cpu1的主程序

这里主要是对gpio_mio0给0和1控制led灯不断的闪烁

/******************************************************************************
*
* Copyright (C) 2009 - 2014 Xilinx, Inc.  All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* Use of the Software is limited solely to applications:
* (a) running on a Xilinx device, or
* (b) that interact with a Xilinx device through a bus or interconnect.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name of the Xilinx shall not be used
* in advertising or otherwise to promote the sale, use or other dealings in
* this Software without prior written authorization from Xilinx.
*
******************************************************************************/

/*
 * helloworld.c: simple test application
 *
 * This application configures UART 16550 to baud rate 9600.
 * PS7 UART (Zynq) is not initialized by this application, since
 * bootrom/bsp configures it to baud rate 115200
 *
 * ------------------------------------------------
 * | UART TYPE   BAUD RATE                        |
 * ------------------------------------------------
 *   uartns550   9600
 *   uartlite    Configurable only in HW design
 *   ps7_uart    115200 (configured by bootrom/bsp)
 */

#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "sleep.h"

#define  Base_Address  0xE000A000


int main()
{


	Xil_Out32(Base_Address + 0x00000204 , 0xFFFFFFFF);
	Xil_Out32(Base_Address + 0x00000208 , 0x00000001);

while(1)
	{
    	Xil_Out32(Base_Address + 0x00000000 , 0x00000001);
    	sleep(1);
    	Xil_Out32(Base_Address + 0x00000000 , 0x00000000);
    	sleep(1);
	}
}



Step9   更改cpu1的ddr地址(cpu0默认不变)

点击这个lscript.ld文件

将地址改为红色方框中一样的就可以了

Step10   再在fsbl的main.c文件中添加cpu1启动程序

在fsbl下找到这个main.c文件并且打开

然后在main函数前面添加这个红色方框的程序

#define sev() __asm__("sev")
#define CPU1STARTADR 0xFFFFFFF0
#define CPU1STARTMEM 0x02000000

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
}

再在loadBootImage()下添加这个StartCpu1();

StartCpu1();   /*add starting cpu1*/

Step11   生成BOOT.bin文件并放到开发板上运行

在你新建的工程目录下新建一个BOOT文件夹,如下图所示

第一步将fsbl.elf文件复制到BOOT文件里

第二步将bit文件复制到BOOT文件里

第三步将cpu0.elf文件复制到BOOT文件里

第四步将cpu1.elf文件复制到BOOT文件里

xilinx-->Create Boot Image

点击这个Browse选择这个BOOT文件路径

找到BOOT文件,点击保存

如下图所示

点击Add将BOOT文件夹里的四个文件都添加进去

点击Browes

请务必按照截图中数字顺序添加

点击 Create Image 生成BOOT.bin文件

将这个生成的BOOT.bin文件拷贝到TF卡里运行

cpu0串口不断打印hello_world

cpu1工程的这个D29接的是mio0会不停的闪烁

  • 5
    点赞
  • 34
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值