文章目錄
- 添加 Domain
- 添加 Application Project
- 配置 Application 的指令空間
- 編寫測試代碼:
-
- a0 代碼
- a1 代碼
- a2 代碼
- a3 代碼
- 測試運作
- SD 卡加載鏡像
具體方法與 SDK 的多核工作實作方法基本一緻,詳細操作可以參考 zcu102 系列文檔。
本文的代碼工程繼承 vitis_zcu102_1 文檔
添加 Domain
打開 Platform Project,輕按兩下 platform.spr 檔案,打開目前工程
在打開的工程界面内選擇目前 Platform Project,在右鍵菜單中選擇 Add Domain
如下圖所示,分别添加 psu_cortexa53_1、psu_cortexa53_2、psu_cortexa53_3 的 Domain。
添加完全部 Domain 之後,在 Explorer 的工程中右鍵選擇 Build Project。
添加 Application Project
在菜單欄選擇 File > New > Application Project
在彈出視窗中選擇 System Project 為同一個 hello_system
按照 vitis_zcu102_1 文檔的說明選擇 Platform Project 和 psu_cortexa53_1、psu_cortexa53_2、psu_cortexa53_3,分别建立 3 個 Application,都使用 Hello World 模闆。
配置 Application 的指令空間
由于 4 個 A53 核使用通路同 1 個 DDR,是以必須将 4 個 Application 的指令空間分開,不能重疊。
輕按兩下打開 4 個 Application 的 lscript.ld 檔案
在 Available Memory Regions 中修改 psu_ddr_0_MEM_0
4 個 Application 的修改數值如下表所示:
配置設定結果如下表:
單核工程 | Base Address | Size |
---|---|---|
a0 | 0x0 | 0x10000000 |
a1 | 0x10000000 | 0x10000000 |
a2 | 0x20000000 | 0x10000000 |
a3 | 0x30000000 | 0x10000000 |
編寫測試代碼:
a0 代碼
#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "sleep.h"
int main()
{
init_platform();
while (1)
{
print("Hello a0\n\r");
sleep(4);
}
cleanup_platform();
return 0;
}
a1 代碼
#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "sleep.h"
int main()
{
init_platform();
sleep(1);
while (1)
{
print("Hello a1\n\r");
sleep(4);
}
cleanup_platform();
return 0;
}
a2 代碼
#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "sleep.h"
int main()
{
init_platform();
sleep(2);
while (1)
{
print("Hello a2\n\r");
sleep(4);
}
cleanup_platform();
return 0;
}
a3 代碼
#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "sleep.h"
int main()
{
init_platform();
sleep(3);
while (1)
{
print("Hello a3\n\r");
sleep(4);
}
cleanup_platform();
return 0;
}
測試運作
在 System Project: hello_system 上右鍵選擇 Build Project
完成後右鍵選擇 Run As > Run Configurations
在彈出視窗的左上角點選 New Configurations 按鈕,添加新的運作配置
在添加的運作配置的 Target Setup 頁,可以看到預設配置
zcu102 闆卡上電後,點選上圖中右下解的 Run 按鈕
程式啟動後在 Vitis Serial Terminal 中可以收到分别來源于 4 個 a53 核的字元串:
SD 卡加載鏡像
在 Vitis 菜單選擇 Xilinx > Create Boot Image
使用與 SDK 相同的辦法生成鏡像檔案(由于 Platform Project 已預設添加了 FSBL 和 PMU 工程,此處不用再單獨添加)
生成的鏡像檔案 BOOT.bin 考入 SD 卡。将 zcu102 開發闆設定為 SD 卡加載後,上電運作與之前的 JTag 加載運作效果一樣。