Skip to content

Commit

Permalink
PFM/D/01-som: Update som tutorial to 2024.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sven2314 authored and GitHub Enterprise committed May 21, 2024
1 parent 38e4dea commit 658bbbf
Show file tree
Hide file tree
Showing 11 changed files with 245 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# Vitis Custom Embedded Platform Creation Example on KV260

***Version: Vitis 2023.2***
***Version: Vitis 2024.1***

The [AMD Kria™ KV260 Vision AI Starter Kit](https://www.xilinx.com/products/som/kria/kv260-vision-starter-kit.html) is the development platform for Kria K26 SOM. The KV260 is built for advanced vision application development without requiring complex hardware design knowledge. It is based on the AMD UltraScale+™ MPSoC technology similar to ZCU104 evaluation board. In this example, you will extend the [ZCU104 custom embedded platform creation example](../02-Edge-AI-ZCU104/README.md) to KV260 Vision AI Starter Kit.

Expand Down Expand Up @@ -81,6 +81,6 @@ The platform creation steps are introduced in the following pages. Each page des
- [Vitis-AI GitHub Repository](https://github.com/Xilinx/Vitis-AI)


<p class="sphinxhide" align="center"><sub>Copyright © 2020–2023 Advanced Micro Devices, Inc</sub></p>
<p class="sphinxhide" align="center"><sub>Copyright © 2020–2024 Advanced Micro Devices, Inc</sub></p>

<p class="sphinxhide" align="center"><sup><a href="https://www.amd.com/en/corporate/copyright">Terms and Conditions</a></sup></p>
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ifeq ($(wildcard $(COMMON_IMAGE_ZYNQMP)/Image),)
endif

all: step1 step2 step3

build_platform: step1 step2
step1:
$(MAKE) -C step1_vivado all

Expand All @@ -41,4 +41,4 @@ clean:
$(MAKE) -C step3_validate clean
ultraclean:clean
$(MAKE) -C step2_pfm ultraclean
$(MAKE) -C step3_validate ultraclean
$(MAKE) -C step3_validate ultraclean
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"disable": "true",
"tasks": {
"build": {
"pre_exec": "./env_setup_zynqmp.sh"
"pre_exec": "./env_setup_zynqmp_notoolchain.sh"
},
"board": {
"pre_exec": "./env_setup_zynqmp.sh"
"pre_exec": "./env_setup_zynqmp_notoolchain.sh"
}
},
"jobs": [
Expand All @@ -30,7 +30,7 @@
],
"custom_build_target":
{
"all": "all"
"all": "build_platform"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved.
#SPDX-License-Identifier: MIT
#*/

################################################################
# This is a generated script based on design: system
#
Expand All @@ -23,7 +24,7 @@ set script_folder [_tcl::get_script_folder]
################################################################
# Check if script is running in correct Vivado version.
################################################################
set scripts_vivado_version 2023.2
set scripts_vivado_version 2024.1
set current_vivado_version [version -short]

if { [string first $scripts_vivado_version $current_vivado_version] == -1 } {
Expand Down Expand Up @@ -54,8 +55,6 @@ set list_projs [get_projects -quiet]
if { $list_projs eq "" } {
create_project project_1 myproj -part xck26-sfvc784-2LV-c
set_property board_part xilinx.com:kv260_som:part0:1.4 [current_project]
set_property board_connections {som240_1_connector xilinx.com:kv260_carrier:som240_1_connector:1.3} [current_project]
set_property platform.extensible true [current_project]
}


Expand Down Expand Up @@ -1063,12 +1062,12 @@ MIO#GPIO0 MIO#GPIO0 MIO#GPIO0 MIO#GPIO0 MIO#GPIO0 MIO#GPIO0 MIO#GPIO0 MIO#GPIO0
CONFIG.PSU__PRESET_APPLIED {1} \
CONFIG.PSU__PROTECTION__DDR_SEGMENTS {NONE} \
CONFIG.PSU__PROTECTION__ENABLE {0} \
CONFIG.PSU__PROTECTION__FPD_SEGMENTS {SA:0xFD1A0000; SIZE:1280; UNIT:KB; RegionTZ:Secure; WrAllowed:Read/Write; subsystemId:PMU Firmware | SA:0xFD000000; SIZE:64; UNIT:KB; RegionTZ:Secure; WrAllowed:Read/Write;\
subsystemId:PMU Firmware | SA:0xFD010000; SIZE:64; UNIT:KB; RegionTZ:Secure; WrAllowed:Read/Write; subsystemId:PMU Firmware | SA:0xFD020000; SIZE:64; UNIT:KB; RegionTZ:Secure; WrAllowed:Read/Write; subsystemId:PMU\
Firmware | SA:0xFD030000; SIZE:64; UNIT:KB; RegionTZ:Secure; WrAllowed:Read/Write; subsystemId:PMU Firmware | SA:0xFD040000; SIZE:64; UNIT:KB; RegionTZ:Secure; WrAllowed:Read/Write; subsystemId:PMU Firmware\
| SA:0xFD050000; SIZE:64; UNIT:KB; RegionTZ:Secure; WrAllowed:Read/Write; subsystemId:PMU Firmware | SA:0xFD610000; SIZE:512; UNIT:KB; RegionTZ:Secure; WrAllowed:Read/Write; subsystemId:PMU Firmware\
| SA:0xFD5D0000; SIZE:64; UNIT:KB; RegionTZ:Secure; WrAllowed:Read/Write; subsystemId:PMU Firmware | SA:0xFD1A0000 ; SIZE:1280; UNIT:KB; RegionTZ:Secure ; WrAllowed:Read/Write; subsystemId:Secure Subsystem}\
\
CONFIG.PSU__PROTECTION__FPD_SEGMENTS {SA:0xFD1A0000; SIZE:1280; UNIT:KB; RegionTZ:Secure; WrAllowed:Read/Write; subsystemId:PMU Firmware | SA:0xFD000000; SIZE:64; UNIT:KB; RegionTZ:Secure; WrAllowed:Read/Write;\
subsystemId:PMU Firmware | SA:0xFD010000; SIZE:64; UNIT:KB; RegionTZ:Secure; WrAllowed:Read/Write; subsystemId:PMU Firmware | SA:0xFD020000; SIZE:64; UNIT:KB; RegionTZ:Secure; WrAllowed:Read/Write;\
subsystemId:PMU Firmware | SA:0xFD030000; SIZE:64; UNIT:KB; RegionTZ:Secure; WrAllowed:Read/Write; subsystemId:PMU Firmware | SA:0xFD040000; SIZE:64; UNIT:KB; RegionTZ:Secure; WrAllowed:Read/Write;\
subsystemId:PMU Firmware | SA:0xFD050000; SIZE:64; UNIT:KB; RegionTZ:Secure; WrAllowed:Read/Write; subsystemId:PMU Firmware | SA:0xFD610000; SIZE:512; UNIT:KB; RegionTZ:Secure; WrAllowed:Read/Write;\
subsystemId:PMU Firmware | SA:0xFD5D0000; SIZE:64; UNIT:KB; RegionTZ:Secure; WrAllowed:Read/Write; subsystemId:PMU Firmware | SA:0xFD1A0000 ; SIZE:1280; UNIT:KB; RegionTZ:Secure ; WrAllowed:Read/Write;\
subsystemId:Secure Subsystem} \
CONFIG.PSU__PROTECTION__LPD_SEGMENTS {SA:0xFF980000; SIZE:64; UNIT:KB; RegionTZ:Secure; WrAllowed:Read/Write; subsystemId:PMU Firmware| SA:0xFF5E0000; SIZE:2560; UNIT:KB; RegionTZ:Secure; WrAllowed:Read/Write;\
subsystemId:PMU Firmware| SA:0xFFCC0000; SIZE:64; UNIT:KB; RegionTZ:Secure; WrAllowed:Read/Write; subsystemId:PMU Firmware| SA:0xFF180000; SIZE:768; UNIT:KB; RegionTZ:Secure; WrAllowed:Read/Write; subsystemId:PMU\
Firmware| SA:0xFF410000; SIZE:640; UNIT:KB; RegionTZ:Secure; WrAllowed:Read/Write; subsystemId:PMU Firmware| SA:0xFFA70000; SIZE:64; UNIT:KB; RegionTZ:Secure; WrAllowed:Read/Write; subsystemId:PMU Firmware|\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@

ROOT_DIR=$(realpath $(dir $(lastword $(MAKEFILE_LIST))))
PLATFORM_NAME=kv260_custom
PLATFORM_NAME_FSBL=kv260_custom_fsbl

XSA_NAME=kv260_hardware_platform
VERSION=2024.1
COMMON_IMAGE_ZYNQMP ?=${PLATFORM_REPO_PATHS}/sw/zynqmp/xilinx-zynqmp-common-v$(VERSION)/
DT_PLAT_NAME=mydeivice
DT_PATH=$(ROOT_DIR)/$(DT_PLAT_NAME)/psu_cortexa53_0/device_tree_domain/bsp
DTB =$(ROOT_DIR)/$(DT_PLAT_NAME)/psu_cortexa53_0/device_tree_domain/bsp/system.dtb

SYSROOT=sysroot
DEVICE_TREE_REPO ?=

#ifndef DEVICE_TREE_REPO
DEVICE_TREE_REPO=https://github.com/Xilinx/device-tree-xlnx.git
#endif


.PHONY: help
Expand All @@ -23,7 +27,7 @@ help:
@echo "make all COMMON_IMAGE_ZYNQMP=<path/to/common_image/> ## Generate platform with pre-built software components"


all: check-common-image dtb dtbo pfm sysroot
all: check-common-image dtb dtbo pfm

#target : check whether the common image is ready
check-common-image:
Expand All @@ -50,22 +54,11 @@ pfm:
@echo "INFO: Creating Platform $(PLATFORM_NAME)"
mkdir -p tmp && export XILINX_VITIS_DATA_DIR="./tmp" && vitis -s platform_creation.py --platform_name $(PLATFORM_NAME) --xsa_path ../step1_vivado/build/vivado/$(XSA_NAME).xsa --boot $(COMMON_IMAGE_ZYNQMP) --dtb $(DTB)
@echo "INFO: Checking created platforms:" && find . -name "*.xpfm"
#install SDK tool
sysroot: $(SYSROOT)

$(SYSROOT): $(COMMON_IMAGE_ZYNQMP)/sdk.sh
mkdir -p $(SYSROOT) && sh $(COMMON_IMAGE_ZYNQMP)/sdk.sh -d $(SYSROOT)/ -y



#install SDK tool
sysroot: $(SYSROOT)

$(SYSROOT): $(COMMON_IMAGE_ZYNQMP)/sdk.sh
mkdir -p $(SYSROOT) && sh $(COMMON_IMAGE_ZYNQMP)/sdk.sh -d $(SYSROOT)/ -y

clean:
$(RM) -r IDE.log $(PLATFORM_NAME) $(PLATFORM_NAME_FSBL) device-tree-xlnx mydevice dt_output dtg dtbo_output
rm -rf IDE.log $(PLATFORM_NAME) $(DT_PLAT_NAME) dt_output dtbo_output

ultraclean: clean
$(RM) -r sysroot
rm -rf device-tree-xlnx tmp logs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
print('args',args)
client = vitis.create_client()
client.set_workspace(path=os.getcwd())
platform = client.create_platform_component(name = platform_name, hw =xsa_path, os = "linux",cpu = "psu_cortexa53" )
platform = client.get_platform_component(name=platform_name)
platform = client.create_platform_component(name = platform_name, hw_design =xsa_path, os = "linux",cpu = "psu_cortexa53" )
platform = client.get_component(name=platform_name)
domain = platform.get_domain(name="linux_psu_cortexa53")
status = domain.update_name(new_name="xrt")
status = domain.generate_bif()
status = domain.add_boot_dir(path=boot)
status = domain.set_boot_dir(path=boot)
status = domain.set_dtb(path=dtb)

status = platform.build()
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
ROOT_DIR=$(realpath $(dir $(lastword $(MAKEFILE_LIST))))
PLATFORM_NAME=kv260_custom
PLATFORM= $(ROOT_DIR)/../step2_pfm/$(PLATFORM_NAME)/export/$(PLATFORM_NAME)/$(PLATFORM_NAME).xpfm
SW_COMP = $(ROOT_DIR)/../step2_pfm/sw_comp/
SYSROOTDIR=$(ROOT_DIR)/../step2_pfm/sysroot/

VERSION=2024.1
COMMON_IMAGE_ZYNQMP ?=${PLATFORM_REPO_PATHS}/sw/zynqmp/xilinx-zynqmp-common-v$(VERSION)/
PL_EXAMPLE_PATH = Vitis_Accel_Examples/cpp_kernels/simple_vadd/
SYSROOT := $(COMMON_IMAGE_ZYNQMP)/sysroots/cortexa72-cortexa53-xilinx-linux
VADD_WORK=$(ROOT_DIR)/vadd_work

.PHONY: help

Expand All @@ -23,44 +23,43 @@ all: getplatforminfo vadd_hw_package

getplatforminfo:
$(MAKE) -C platforminfo/ all


Vitis_Accel_Examples:
git clone https://github.com/Xilinx/Vitis_Accel_Examples.git

# Quick command for generating vadd hw xclbin
vadd_hw: Vitis_Accel_Examples
$(MAKE) -C $(PL_EXAMPLE_PATH) all TARGET=hw PLATFORM=$(PLATFORM) HOST_ARCH=aarch64 DEV_ARCH=zynquplus EDGE_COMMON_SW=$(COMMON_IMAGE_ZYNQMP) SYSROOT=$(SYSROOTDIR)/sysroots/cortexa72-cortexa53-xilinx-linux
cpVaddCode:
mkdir -p vadd_work
cp $(XILINX_VITIS)/examples/vadd/* vadd_work
cp makefile_vadd vadd_work/Makefile

# vadd_hw is a place-holder for manual build and test on hardware
$(VADD_WORK)/simple_vadd: vadd_hw
vadd_hw: cpVaddCode $(PLATFORM)
$(MAKE) -C $(VADD_WORK) sd_card TARGET=hw PLATFORM=$(PLATFORM) DEV_ARCH=versal HOST_ARCH=aarch64 EDGE_COMMON_SW=$(COMMON_IMAGE_ZYNQMP) SYSROOT=$(SYSROOT)/
# vadd_hw generates the files for running on hardware. User needs to pick the files required by KV260, rename thr file and transfer them to the board
# Do not use the generated sd_card.img
$(PL_EXAMPLE_PATH)/simple_vadd: Vitis_Accel_Examples $(PLATFORM)
$(MAKE) -C $(PL_EXAMPLE_PATH) all TARGET=hw PLATFORM=$(PLATFORM) DEV_ARCH=zynquplus HOST_ARCH=aarch64 EDGE_COMMON_SW=$(COMMON_IMAGE_ZYNQMP) SYSROOT=$(SYSROOTDIR)/sysroots/cortexa72-cortexa53-xilinx-linux

$(VADD_WORK)/shell.json:
cd $(VADD_WORK) && printf '{\n "shell_type" : "XRT_FLAT",\n "num_slots": "1"\n}' > shell.json

$(PL_EXAMPLE_PATH)/shell.json:
cd $(PL_EXAMPLE_PATH) && printf '{\n "shell_type" : "XRT_FLAT",\n "num_slots": "1"\n}' > shell.json

vadd_hw_package: $(PL_EXAMPLE_PATH)/simple_vadd $(PL_EXAMPLE_PATH)/shell.json
vadd_hw_package: $(VADD_WORK)/simple_vadd $(VADD_WORK)/shell.json
@echo "INFO: Packaging Completed"
mkdir -p vadd
cp ../step2_pfm/dtbo_output/pl.dtbo vadd/
cp $(PL_EXAMPLE_PATH)/shell.json vadd/
cp $(PL_EXAMPLE_PATH)/build_dir.hw.$(PLATFORM_NAME)/krnl_vadd.link.xclbin vadd/krnl_vadd.bin
cp $(PL_EXAMPLE_PATH)/simple_vadd vadd/
cp $(VADD_WORK)/shell.json vadd/
cp $(VADD_WORK)/build_dir.hw/krnl_vadd.link.xclbin vadd/krnl_vadd.bin
cp $(VADD_WORK)/simple_vadd vadd/
@echo "Please copy vadd to /lib/firmware/xilinx/ on target board"
@echo "then use xmutil to load hardware."
@echo "xmutil unloadapp"
@echo "xmutil loadapp vadd"
@echo "Go to /lib/firmware/xilinx/vadd directory and run application"
@echo "$ ./simple_vadd ./krnl_vadd.bin"


getplatforminfo:
$(MAKE) -C platforminfo/ all


clean:
-$(MAKE) -C $(PL_EXAMPLE_PATH) clean
-$(MAKE) -C $(VADD_WORK) clean
-$(MAKE) -C platforminfo/ clean
rm -rf vadd/

ultraclean:clean
rm -rf Vitis_Accel_Examples
rm -rf $(VADD_WORK)
Loading

0 comments on commit 658bbbf

Please sign in to comment.