-
Notifications
You must be signed in to change notification settings - Fork 19
Add vendor specific build support #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bentheredonethat
wants to merge
1
commit into
OpenAMP:main
Choose a base branch
from
bentheredonethat:add-vendor-specific-build-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_MACHINE}/CMakeLists.txt") | ||
| if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_VENDOR}/CMakeLists.txt") | ||
| add_subdirectory (${PROJECT_VENDOR}) | ||
| elseif (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_MACHINE}/CMakeLists.txt") | ||
| add_subdirectory (${PROJECT_MACHINE}) | ||
| endif (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_MACHINE}/CMakeLists.txt") | ||
| endif (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_VENDOR}/CMakeLists.txt") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| # Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved. | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| # For AMD-Xilinx tooling enable control flow path whereby only target app | ||
| # is configured to build. In the future we can add options for each | ||
| # app but for now enable as a one-shot flow switch | ||
|
|
||
| message("Building for AMD-Xilinx Demos") | ||
|
|
||
| cmake_minimum_required(VERSION 3.24) | ||
|
|
||
| enable_language(C ASM ) | ||
|
|
||
| set_property (GLOBAL PROPERTY OPENAMP_APP_NAME "${OPENAMP_APP_NAME}") | ||
| SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") | ||
|
|
||
| include(CheckSymbolExists) | ||
|
|
||
| # Demos currently target R5 and R52. | ||
| # If the target is not one of these target cores, then surrounding | ||
| # tooling (Yocto or Vitis) will report error. | ||
| #set (MACHINE "zynqmp_r5") | ||
| #set_property (GLOBAL PROPERTY MACHINE ${MACHINE}) | ||
| #set (PROJECT_MACHINE ${MACHINE}) | ||
|
|
||
| get_property (OPENAMP_APP_NAME GLOBAL PROPERTY OPENAMP_APP_NAME) | ||
| if(OPENAMP_APP_NAME STREQUAL "rpc_demo") | ||
| set(_app rpc_demo) | ||
| elseif(OPENAMP_APP_NAME STREQUAL "echo") | ||
| set (_app rpmsg-echo) | ||
| elseif(OPENAMP_APP_NAME STREQUAL "matrix_multiply") | ||
| set (_app matrix_multiplyd) | ||
| else() | ||
| message(FATAL_ERROR "OPENAMP_APP_NAME not picked up") | ||
| endif() | ||
| message("OpenAMP: OPENAMP_APP_NAME: ${OPENAMP_APP_NAME}") | ||
|
|
||
| # Ensure that for Compile step that the _AMD_GENERATED_ symbol is present | ||
| # for app build if it was provided in CMake configure tooling | ||
| if (_AMD_GENERATED_) | ||
| add_definitions(-D_AMD_GENERATED_) | ||
| endif() | ||
|
|
||
| string(TOUPPER "${CMAKE_MACHINE}" _soc) | ||
|
|
||
| if(_soc STREQUAL "ZYNQMP" OR _soc STREQUAL "VERSAL") | ||
| set_property(GLOBAL PROPERTY SOC "${_soc}") | ||
| else() | ||
| message(FATAL_ERROR "Unsupported CMAKE_MACHINE: ${CMAKE_MACHINE}") | ||
| endif() | ||
|
|
||
| get_property (SOC GLOBAL PROPERTY SOC) | ||
| message("OpenAMP: SOC in build is: ${SOC}") | ||
|
|
||
| # Lopper plugin can generate linker meta data in below file | ||
| # This can define RSC_TABLE so include before | ||
| message("CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}") | ||
| file (GLOB LINKER_METADATA_FILE "${CMAKE_SOURCE_DIR}/*Example.cmake") | ||
| if (EXISTS ${LINKER_METADATA_FILE}) | ||
| set_property(GLOBAL PROPERTY LINKER_METADATA_FILE ${LINKER_METADATA_FILE}) | ||
| message("OpenAMP: Linker will be configured using file: ${LINKER_METADATA_FILE}") | ||
| else() | ||
| message("OpenAMP: Linker will be configured using static linker script for ${SOC}") | ||
| endif() | ||
|
|
||
| get_property (OPENAMP_APP_NAME GLOBAL PROPERTY OPENAMP_APP_NAME) | ||
| if (OPENAMP_APP_NAME STREQUAL "") | ||
| message(FATAL_ERROR "AMD-Xilinx: Demos: missing property OPENAMP_APP_NAME.") | ||
| return() | ||
| #else() | ||
| #add_subdirectory (${APPS_ROOT_DIR}/machine ${CMAKE_CURRENT_BINARY_DIR}/machine_build) | ||
| #add_subdirectory (${APPS_ROOT_DIR}/system ${CMAKE_CURRENT_BINARY_DIR}/system_build) | ||
| endif (OPENAMP_APP_NAME STREQUAL "") | ||
|
|
||
| add_subdirectory(${PROJECT_MACHINE}) | ||
|
|
||
| # pull in original legacy app demo logic here | ||
| set (_cflags "${CMAKE_C_FLAGS} ${APP_EXTRA_C_FLAGS} -fdata-sections -ffunction-sections") | ||
| set (_fw_dir "${APPS_SHARE_DIR}") | ||
|
|
||
| collect(APP_INC_DIRS ${APPS_ROOT_DIR}/examples/${OPENAMP_APP_NAME}) | ||
| collect(APP_INC_DIRS ${APPS_ROOT_DIR}/machine/${MACHINE}) | ||
|
|
||
| collector_list (_list PROJECT_INC_DIRS) | ||
| collector_list (_app_list APP_INC_DIRS) | ||
|
|
||
| include_directories (${_list} ${_app_list}) | ||
| include_directories (${APPS_ROOT_DIR}/examples/legacy_apps/include) | ||
| link_directories (${_list} ${_app_list}) | ||
|
|
||
| get_property (_linker_opt GLOBAL PROPERTY APP_LINKER_OPT) | ||
|
|
||
| # below is where demo config and compilation occurs | ||
| collect(PROJECT_LIB_DEPS c) | ||
| collect(PROJECT_LIB_DEPS m) | ||
| collect(PROJECT_LIB_DEPS metal) | ||
| collect(PROJECT_LIB_DEPS open_amp) | ||
|
|
||
| collect (APP_COMMON_SOURCES "${APPS_ROOT_DIR}/examples/${OPENAMP_APP_NAME}/${_app}.c") | ||
| collect (APP_COMMON_SOURCES "${APPS_ROOT_DIR}/examples/${OPENAMP_APP_NAME}/${PROJECT_SYSTEM}/main.c") | ||
| collector_list (_sources APP_COMMON_SOURCES) | ||
|
|
||
| collector_list (_app_list APP_INC_DIRS) | ||
| collector_list (_list PROJECT_INC_DIRS) | ||
| include_directories (${_list} ${_app_list} ${APPS_ROOT_DIR} ${APPS_ROOT_DIR}/system/${PROJECT_SYSTEM}/machine/${PROJECT_MACHINE}/) | ||
| collector_list (_list PROJECT_LIB_DIRS) | ||
| collector_list (_app_list APP_LIB_DIRS) | ||
| link_directories (${_list} ${_app_list} ${APPS_ROOT_DIR}/system/${PROJECT_SYSTEM}/machine/${PROJECT_MACHINE}/) | ||
| # UserConfig.cmake is file generated by Vitis-Unified workspace for applications. | ||
| include(${CMAKE_SOURCE_DIR}/UserConfig.cmake) | ||
| set (executable_name ${CMAKE_PROJECT_NAME}) | ||
| add_executable (${executable_name}.elf ${_sources}) | ||
| set_source_files_properties(${_sources} PROPERTIES COMPILE_FLAGS "${_cflags}") | ||
|
|
||
| get_property (LINKER_METADATA_FILE GLOBAL PROPERTY LINKER_METADATA_FILE) | ||
| get_property (SOC GLOBAL PROPERTY SOC) | ||
| set (SOCS ZYNQMP VERSAL) | ||
| set (LOPPER_CFG_LINKERS lscript_r5.ld.in lscript_versal_r5.ld.in) | ||
|
|
||
| list(FIND SOCS "${SOC}" soc_index) | ||
|
|
||
| # AMD-Xilinx SDT workflow has split up libxil. Below are required libs | ||
| # That were previously in libxil. | ||
| collect(PROJECT_LIB_DEPS xil) | ||
| collect(PROJECT_LIB_DEPS xiltimer) | ||
| collect(PROJECT_LIB_DEPS xilstandalone) | ||
|
|
||
| if (EXISTS ${LINKER_METADATA_FILE}) | ||
| include(${LINKER_METADATA_FILE}) | ||
| list (GET LOPPER_CFG_LINKERS ${soc_index} linker_in) | ||
| configure_file(${CMAKE_CURRENT_SOURCE_DIR}/linker_files/${linker_in} "${CMAKE_CURRENT_SOURCE_DIR}/lscript.ld") | ||
| list(APPEND LINKER_FILE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${linker_in}) | ||
| list(APPEND LINKER_FILE ${linker_in}) | ||
| set (_linker_script "${CMAKE_CURRENT_SOURCE_DIR}/lscript.ld") | ||
| message("Using LINKER_METADATA_FILE: ${LINKER_METADATA_FILE}") | ||
| set (_linker_opt "-Wl,--defsym,_rsc_table=${RSC_TABLE} -T\"${_linker_script}\"") | ||
| else() | ||
| message(FATAL_ERROR "Could not find linker meta data file") | ||
| endif(EXISTS ${LINKER_METADATA_FILE}) | ||
|
|
||
| collector_list (_deps PROJECT_LIB_DEPS) | ||
|
|
||
| # Enable user to pass in extra linker flags | ||
| if (DEFINED DEMO_LINK_FLAGS) | ||
| set (_deps "${_deps} ${DEMO_LINK_FLAGS}") | ||
| endif(DEFINED DEMO_LINK_FLAGS) | ||
|
|
||
| target_link_libraries(${executable_name}.elf -Wl,-Map=${executable_name}.map -L${CMAKE_LIBRARY_PATH} -L${USER_LINK_DIRECTORIES} -Wl,--gc-sections ${_linker_opt} -Wl,--start-group ${OPENAMP_LIB} ${_deps} -Wl,--end-group) | ||
| target_compile_definitions(${executable_name}.elf PUBLIC ${USER_COMPILE_DEFINITIONS}) | ||
| install (TARGETS ${executable_name}.elf RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # Steps to generate inputs for AMD-Xilinx RPU Firmware Demos | ||
|
|
||
| Dependencies: | ||
| 1. Lopper : https://github.com/devicetree-org/lopper.git | ||
| 2. System Device Tree generated from design : https://docs.amd.com/r/en-US/ug1647-porting-embeddedsw-components/Generating-a-System-Device-Tree-Using-SDTGen | ||
|
|
||
| Below is sample run for Versal Gen 1 platform | ||
| ### Generate OpenAMP RPU Device Tree | ||
|
|
||
| SDT is the System Device Tree generated from design | ||
| ```sh | ||
| export LOPPER_DTC_FLAGS="-b 0 -@" | ||
|
|
||
| python3 lopper.py -f --enhanced \ | ||
| -x '*.yaml' \ | ||
| -i $YAML $SDT yaml_applied.dts | ||
|
|
||
| python3 lopper.py -f --enhanced \ | ||
| yaml_applied.dts rpu.dts \ | ||
| -- gen_domain_dts psu_cortexr5_0 --openamp_no_header | ||
| ``` | ||
| The above Device Tree "rpu.dts" will be used for configuration of the app's interrupts, shared memory and linker script. | ||
|
|
||
| ### Generate OpenAMP App config header | ||
|
|
||
| ```sh | ||
| export LOPPER_DTC_FLAGS="-b 0 -@" | ||
| export CONFIG_DTFILE=rpu.dts | ||
|
|
||
| cd openamp-system-reference/examples/legacy_apps/machine/zynqmp_r5 | ||
| python3 lopper.py -O -f -v --enhanced --permissive \ | ||
| -O . ${CONFIG_DTFILE} -- openamp --openamp_header_only \ | ||
| --openamp_output_filename=amd_platform_info.h \ | ||
| --openamp_remote=psv_cortexr5_0 | ||
| cd - | ||
| ``` | ||
| The output amd_platform_info.h needs to be in the location denoted above of "openamp-system-reference/examples/legacy_apps/machine/zynqmp_r5" BEFORE | ||
| cmake configure step. | ||
|
|
||
| ### Generate RPU Application Linker config object | ||
|
|
||
| ```sh | ||
| export LOPPER_DTC_FLAGS="-b 0 -@" | ||
| export CONFIG_DTFILE=rpu.dts | ||
| python3 lopper.py -O ${S} rpu.dts \ | ||
| -- baremetallinker_xlnx psv_cortexr5_0 <output location> openamp | ||
| ``` | ||
| The RPU Application Linker config object needs to be pointed to with cmake variable LINKER_METADATA_FILE at cmake configure step. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.