From 97eb58431122142a6e3dbbb8417ab46f64e31328 Mon Sep 17 00:00:00 2001 From: Ben Levinsky Date: Mon, 13 Jan 2025 07:44:18 -0800 Subject: [PATCH 1/5] apps: zynqmp_r5: Move App specific variables to platform_info.h Move all app configuration variables to platform_info.h so that all the relevant information that can be configured is in one file. This makes the application easier to configure and debug. Signed-off-by: Ben Levinsky --- .../machine/zynqmp_r5/platform_info.c | 19 +------ .../machine/zynqmp_r5/platform_info.h | 54 ++++++++++++++++++- .../legacy_apps/machine/zynqmp_r5/rsc_table.c | 14 ++--- 3 files changed, 58 insertions(+), 29 deletions(-) diff --git a/examples/legacy_apps/machine/zynqmp_r5/platform_info.c b/examples/legacy_apps/machine/zynqmp_r5/platform_info.c index 93ae8fe..83d68a9 100644 --- a/examples/legacy_apps/machine/zynqmp_r5/platform_info.c +++ b/examples/legacy_apps/machine/zynqmp_r5/platform_info.c @@ -1,7 +1,8 @@ /* * Copyright (c) 2014, Mentor Graphics Corporation * All rights reserved. - * Copyright (c) 2017 Xilinx, Inc. + * Copyright (c) 2017 - 2021 Xilinx, Inc. + * Copyright (c) 2022 - 2025 Advanced Micro Devices, Inc. All Rights Reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -38,22 +39,6 @@ #define NORM_SHARED_NCACHE 0x0000000CU /* Non cacheable shareable */ #define PRIV_RW_USER_RW (0x00000003U<<8U) /* Full Access */ -#ifndef SHARED_MEM_PA -#if XPAR_CPU_ID == 0 -#define SHARED_MEM_PA 0x3ED40000UL -#else -#define SHARED_MEM_PA 0x3EF40000UL -#endif /* XPAR_CPU_ID */ -#endif /* !SHARED_MEM_PA */ - -#ifndef SHARED_MEM_SIZE -#define SHARED_MEM_SIZE 0x100000UL -#endif /* !SHARED_MEM_SIZE */ - -#ifndef SHARED_BUF_OFFSET -#define SHARED_BUF_OFFSET 0x8000UL -#endif /* !SHARED_BUF_OFFSET */ - #ifndef RPMSG_NO_IPI #define _rproc_wait() asm volatile("wfi") #endif /* !RPMSG_NO_IPI */ diff --git a/examples/legacy_apps/machine/zynqmp_r5/platform_info.h b/examples/legacy_apps/machine/zynqmp_r5/platform_info.h index 6e4b7fd..8ff7827 100644 --- a/examples/legacy_apps/machine/zynqmp_r5/platform_info.h +++ b/examples/legacy_apps/machine/zynqmp_r5/platform_info.h @@ -1,7 +1,8 @@ /* * Copyright (c) 2014, Mentor Graphics Corporation * All rights reserved. - * Copyright (c) 2017 Xilinx, Inc. + * Copyright (c) 2017 - 2021 Xilinx, Inc. + * Copyright (c) 2022 - 2025 Advanced Micro Devices, Inc. All Rights Reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -15,6 +16,8 @@ #include "platform_info_common.h" +#include "xparameters.h" + #if defined __cplusplus extern "C" { #endif @@ -26,6 +29,24 @@ extern "C" { #define NORM_SHARED_NCACHE 0x0000000CU /* Non cacheable shareable */ #define PRIV_RW_USER_RW (0x00000003U<<8U) /* Full Access */ +#ifdef _AMD_GENERATED_ +/* + * @file   amd_platform_info.h + * @brief  Generated header that contains OpenAMP IPC information. + * + *        Namely interrupt and shared memory information. If values are + * provided via generated header, then include thus. These values + * are to describe interrupt and shared memory information that + * describes one end of an OpenAMP IPC connection. This application + * is for target AMD RPUs. The file 'amd_platform_info.h' + * is generated via Vitis NG or Yocto-Decoupling flow for + * AMD RPU targets. The channel information is defined in the + * OpenAMP YAML channel description. The generated symbols can be + * changed by editing the OpenAMP YAML channel description. + */ +#include "amd_platform_info.h" +#else + /* Interrupt vectors */ #ifdef versal @@ -64,6 +85,37 @@ extern "C" { #define POLL_STOP 0x1U #endif /* RPMSG_NO_IPI */ +#ifndef RING_TX +#define RING_TX FW_RSC_U32_ADDR_ANY +#endif /* !RING_TX */ + +#ifndef RING_RX +#define RING_RX FW_RSC_U32_ADDR_ANY +#endif /* RING_RX */ + +#define NUM_VRINGS 0x02 +#define VRING_ALIGN 0x1000 +#define VRING_SIZE 256 + +#ifndef SHARED_MEM_PA +#if XPAR_CPU_ID == 0 +#define SHARED_MEM_PA 0x3ED40000UL +#else + +#define SHARED_MEM_PA 0x3EF40000UL +#endif /* XPAR_CPU_ID */ +#endif /* !SHARED_MEM_PA */ + +#ifndef SHARED_MEM_SIZE +#define SHARED_MEM_SIZE 0x100000UL +#endif /* !SHARED_MEM_SIZE */ + +#ifndef SHARED_BUF_OFFSET +#define SHARED_BUF_OFFSET 0x8000UL +#endif /* !SHARED_BUF_OFFSET */ + +#endif /* _AMD_GENERATED_ */ + struct remoteproc_priv { const char *kick_dev_name; const char *kick_dev_bus_name; diff --git a/examples/legacy_apps/machine/zynqmp_r5/rsc_table.c b/examples/legacy_apps/machine/zynqmp_r5/rsc_table.c index 8160c72..da0765c 100644 --- a/examples/legacy_apps/machine/zynqmp_r5/rsc_table.c +++ b/examples/legacy_apps/machine/zynqmp_r5/rsc_table.c @@ -1,7 +1,8 @@ /* * Copyright (c) 2014, Mentor Graphics Corporation * All rights reserved. - * Copyright (c) 2015 Xilinx, Inc. All rights reserved. + * Copyright (c) 2015 - 2021 Xilinx, Inc. All rights reserved. + * Copyright (c) 2022 - 2025 Advanced Micro Devices, Inc. All Rights Reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -13,6 +14,7 @@ #include #include "rsc_table.h" +#include "platform_info.h" /* Place resource table in special ELF section */ #define __section_t(S) __attribute__((__section__(#S))) @@ -23,16 +25,6 @@ /* VirtIO rpmsg device id */ #define VIRTIO_ID_RPMSG_ 7 -#define NUM_VRINGS 0x02 -#define VRING_ALIGN 0x1000 -#ifndef RING_TX -#define RING_TX FW_RSC_U32_ADDR_ANY -#endif /* !RING_TX */ -#ifndef RING_RX -#define RING_RX FW_RSC_U32_ADDR_ANY -#endif /* RING_RX */ -#define VRING_SIZE 256 - #define NUM_TABLE_ENTRIES 1 struct remote_resource_table __resource resources = { From 70598c4dd922534ec693f3455220682889571dde Mon Sep 17 00:00:00 2001 From: Ben Levinsky Date: Tue, 14 Jan 2025 09:27:07 -0800 Subject: [PATCH 2/5] apps: platform_info: add API for vdev reset flag when remote processor is detached or stopped by host, it sets vdev reset flag to 0 via virtio config ops in resource table. Introduce API that will poll on this flag to destroy endpoints and virtio devices. Application should re-create rpmsg devices once coming out of loop from this function, so host can re-attach to this Also use new API platform_poll_on_vdev_reset to poll interrupts from host instead of platform_poll Signed-off-by: Tanmay Shah Signed-off-by: Ben Levinsky --- .../legacy_apps/examples/echo/rpmsg-echo.c | 51 +++++++++++-------- .../include/platform_info_common.h | 2 + .../machine/zynqmp/platform_info.c | 39 ++++++++++++++ .../machine/zynqmp_r5/platform_info.c | 39 ++++++++++++++ .../linux/machine/generic/platform_info.c | 38 ++++++++++++++ 5 files changed, 149 insertions(+), 20 deletions(-) diff --git a/examples/legacy_apps/examples/echo/rpmsg-echo.c b/examples/legacy_apps/examples/echo/rpmsg-echo.c index 8b2e5ad..4328f24 100644 --- a/examples/legacy_apps/examples/echo/rpmsg-echo.c +++ b/examples/legacy_apps/examples/echo/rpmsg-echo.c @@ -78,16 +78,7 @@ int app(struct rpmsg_device *rdev, void *priv) LPRINTF("RPMsg device TX buffer size: %#x\r\n", rpmsg_get_tx_buffer_size(&lept)); LPRINTF("RPMsg device RX buffer size: %#x\r\n", rpmsg_get_rx_buffer_size(&lept)); - while(1) { - platform_poll(priv); - /* we got a shutdown request, exit */ - if (shutdown_req) { - break; - } - } - rpmsg_destroy_ept(&lept); - - return 0; + return platform_poll_on_vdev_reset(rdev, priv); } /*-----------------------------------------------------------------------------* @@ -115,23 +106,43 @@ int main(int argc, char *argv[]) ret = platform_init(argc, argv, &platform); if (ret) { LPERROR("Failed to initialize platform.\r\n"); - ret = -1; - } else { + ML_ERR("Server reboot is required to recover\r\n"); + platform_cleanup(platform); + /* + * If main function is returned in baremetal firmware, + * Server behavior is undefined. It's better to wait in + * an infinite loop instead + */ + while (1); + } + + /* + * If host detach from remoteproc device, then destroy current rpmsg + * device and create new one. + */ + while (1) { rpdev = platform_create_rpmsg_vdev(platform, 0, VIRTIO_DEV_DEVICE, NULL, NULL); if (!rpdev) { - LPERROR("Failed to create rpmsg virtio device.\r\n"); - ret = -1; - } else { - app(rpdev, platform); - platform_release_rpmsg_vdev(rpdev, platform); - ret = 0; + ML_ERR("Failed to create rpmsg virtio device.\r\n"); + ML_ERR("Server reboot is required to recover\r\n"); + platform_cleanup(platform); + + /* + * If main function is returned in baremetal firmware, + * Server behavior is undefined. It's better to wait in + * an infinite loop instead + */ + while (1); } + + app(rpdev, platform); + platform_release_rpmsg_vdev(rpdev, platform); } LPRINTF("Stopping application...\r\n"); - platform_cleanup(platform); - return ret; + /* Never reach here. */ + return -EINVAL; } diff --git a/examples/legacy_apps/include/platform_info_common.h b/examples/legacy_apps/include/platform_info_common.h index c1f5c66..7331454 100644 --- a/examples/legacy_apps/include/platform_info_common.h +++ b/examples/legacy_apps/include/platform_info_common.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2024 Texas Instruments, Inc. + * Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -57,6 +58,7 @@ platform_create_rpmsg_vdev(void *platform, unsigned int vdev_index, * return negative value for errors, otherwise 0. */ int platform_poll(void *platform); +int platform_poll_on_vdev_reset(struct rpmsg_device *rpdev, void *priv); /** * platform_release_rpmsg_vdev - release rpmsg virtio device diff --git a/examples/legacy_apps/machine/zynqmp/platform_info.c b/examples/legacy_apps/machine/zynqmp/platform_info.c index 9125657..b3a1432 100644 --- a/examples/legacy_apps/machine/zynqmp/platform_info.c +++ b/examples/legacy_apps/machine/zynqmp/platform_info.c @@ -273,6 +273,45 @@ int platform_poll(void *priv) return 0; } +int platform_poll_on_vdev_reset(struct rpmsg_device *rpdev, void *priv) +{ + struct rpmsg_virtio_device *rvdev; + struct remoteproc *rproc = priv; + struct remoteproc_priv *prproc; + unsigned int flags; + + if (!priv || !rpdev) + return -EINVAL; + + prproc = rproc->priv; + if (!prproc) + return -EINVAL; + + rvdev = metal_container_of(rpdev, struct rpmsg_virtio_device, rdev); + + /** + * Check virtio status after every interrupt. In case of stop or + * detach, virtio device status will be reset by remote + * processor. In that case, break loop and destroy rvdev + */ + while (rpmsg_virtio_get_status(rvdev)) { +#ifdef RPMSG_NO_IPI + (void)flags; + if (metal_io_read32(prproc->kick_io, 0)) + remoteproc_get_notification(rproc, RSC_NOTIFY_ID_ANY); +#else /* !RPMSG_NO_IPI */ + flags = metal_irq_save_disable(); + if (!(atomic_flag_test_and_set(&prproc->ipi_nokick))) { + metal_irq_restore_enable(flags); + remoteproc_get_notification(rproc, RSC_NOTIFY_ID_ANY); + } + _rproc_wait(); + metal_irq_restore_enable(flags); +#endif /* RPMSG_NO_IPI */ + } + return 0; +} + void platform_release_rpmsg_vdev(struct rpmsg_device *rpdev, void *platform) { struct rpmsg_virtio_device *rpvdev; diff --git a/examples/legacy_apps/machine/zynqmp_r5/platform_info.c b/examples/legacy_apps/machine/zynqmp_r5/platform_info.c index 83d68a9..cd266f2 100644 --- a/examples/legacy_apps/machine/zynqmp_r5/platform_info.c +++ b/examples/legacy_apps/machine/zynqmp_r5/platform_info.c @@ -222,6 +222,45 @@ platform_create_rpmsg_vdev(void *platform, unsigned int vdev_index, return NULL; } +int platform_poll_on_vdev_reset(struct rpmsg_device *rpdev, void *priv) +{ + struct rpmsg_virtio_device *rvdev; + struct remoteproc *rproc = priv; + struct remoteproc_priv *prproc; + unsigned int flags; + + if (!priv || !rpdev) + return -EINVAL; + + prproc = rproc->priv; + if (!prproc) + return -EINVAL; + + rvdev = metal_container_of(rpdev, struct rpmsg_virtio_device, rdev); + + /** + * Check virtio status after every interrupt. In case of stop or + * detach, virtio device status will be reset by remote + * processor. In that case, break loop and destroy rvdev + */ + while (rpmsg_virtio_get_status(rvdev)) { +#ifdef RPMSG_NO_IPI + (void)flags; + if (metal_io_read32(prproc->kick_io, 0)) + remoteproc_get_notification(rproc, RSC_NOTIFY_ID_ANY); +#else /* !RPMSG_NO_IPI */ + flags = metal_irq_save_disable(); + if (!(atomic_flag_test_and_set(&prproc->ipi_nokick))) { + metal_irq_restore_enable(flags); + remoteproc_get_notification(rproc, RSC_NOTIFY_ID_ANY); + } + _rproc_wait(); + metal_irq_restore_enable(flags); +#endif /* RPMSG_NO_IPI */ + } + return 0; +} + int platform_poll(void *priv) { struct remoteproc *rproc = priv; diff --git a/examples/legacy_apps/system/linux/machine/generic/platform_info.c b/examples/legacy_apps/system/linux/machine/generic/platform_info.c index 5f7c8d1..95f5208 100644 --- a/examples/legacy_apps/system/linux/machine/generic/platform_info.c +++ b/examples/legacy_apps/system/linux/machine/generic/platform_info.c @@ -550,6 +550,44 @@ int platform_poll(void *priv) return 0; } +int platform_poll_on_vdev_reset(struct rpmsg_device *rpdev, void *priv) +{ + struct rpmsg_virtio_device *rvdev; + struct remoteproc *rproc = priv; + struct remoteproc_priv *prproc; + struct vring_ipi_info *ipi; + unsigned int flags; + + if (!priv || !rpdev) + return -EINVAL; + + prproc = rproc->priv; + if (!prproc) + return -EINVAL; + + ipi = &prproc->ipi; + if (!ipi) + return -EINVAL; + + rvdev = metal_container_of(rpdev, struct rpmsg_virtio_device, rdev); + + /** + * Check virtio status after every interrupt. In case of stop or + * detach, virtio device status will be reset by remote + * processor. In that case, break loop and destroy rvdev + */ + while (rpmsg_virtio_get_status(rvdev)) { + flags = metal_irq_save_disable(); + if (!(atomic_flag_test_and_set(&ipi->sync))) { + metal_irq_restore_enable(flags); + remoteproc_get_notification(rproc, RSC_NOTIFY_ID_ANY); + } + _rproc_wait(); + metal_irq_restore_enable(flags); + } + return 0; +} + void platform_release_rpmsg_vdev(struct rpmsg_device *rpdev, void *platform) { struct rpmsg_virtio_device *rpvdev; From d5324228e2e08af674e1c3680c680cd871bae1ab Mon Sep 17 00:00:00 2001 From: Ben Levinsky Date: Tue, 14 Jan 2025 10:11:45 -0800 Subject: [PATCH 3/5] apps: zynqmp_r5: Enable build with latest SDT BSP 1. Enable CMake build to pass in linker flags. This will enable Xilinx-AMD System Device Tree Flow BSP-based tooling to pass required linker flags 2. Enable System Device Flow compliant linker script where many sections are placed in DDR for space and entry point provided by BSP is _vector_table instead of _boot 3. Ensure symbols are present for both classic and System Device Flow flow for each of the above SOC's. 4. Remove symbols that are also present in BSP 5. Add Versal NET SDT Linker script Signed-off-by: Ben Levinsky --- .../legacy_apps/examples/echo/CMakeLists.txt | 5 + .../examples/matrix_multiply/CMakeLists.txt | 5 + .../examples/rpc_demo/CMakeLists.txt | 5 + .../machine/zynqmp_r5/platform_info.c | 7 - .../machine/zynqmp_r5/platform_info.h | 44 +-- .../machine/zynqmp_r5/platform_info_versal.h | 28 ++ .../zynqmp_r5/platform_info_versal_net.h | 28 ++ .../machine/zynqmp_r5/platform_info_zynqmp.h | 86 +++++ .../generic/machine/zynqmp_r5/CMakeLists.txt | 10 + .../generic/machine/zynqmp_r5/linker_sdt.ld | 300 +++++++++++++++++ .../zynqmp_r5/linker_sdt_versal_net.ld | 308 ++++++++++++++++++ 11 files changed, 787 insertions(+), 39 deletions(-) create mode 100644 examples/legacy_apps/machine/zynqmp_r5/platform_info_versal.h create mode 100644 examples/legacy_apps/machine/zynqmp_r5/platform_info_versal_net.h create mode 100644 examples/legacy_apps/machine/zynqmp_r5/platform_info_zynqmp.h create mode 100644 examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_sdt.ld create mode 100644 examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_sdt_versal_net.ld diff --git a/examples/legacy_apps/examples/echo/CMakeLists.txt b/examples/legacy_apps/examples/echo/CMakeLists.txt index 894e7fe..f62b449 100644 --- a/examples/legacy_apps/examples/echo/CMakeLists.txt +++ b/examples/legacy_apps/examples/echo/CMakeLists.txt @@ -13,6 +13,11 @@ link_directories (${_list} ${_app_list}) get_property (_linker_opt GLOBAL PROPERTY APP_LINKER_OPT) 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) + set (OPENAMP_LIB open_amp) foreach (_app rpmsg-echo-ping rpmsg-echo) diff --git a/examples/legacy_apps/examples/matrix_multiply/CMakeLists.txt b/examples/legacy_apps/examples/matrix_multiply/CMakeLists.txt index 7ce4ad7..1f052c3 100644 --- a/examples/legacy_apps/examples/matrix_multiply/CMakeLists.txt +++ b/examples/legacy_apps/examples/matrix_multiply/CMakeLists.txt @@ -12,6 +12,11 @@ link_directories (${_list} ${_app_list}) get_property (_linker_opt GLOBAL PROPERTY APP_LINKER_OPT) 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) + set (OPENAMP_LIB open_amp) foreach (_app matrix_multiply matrix_multiplyd) collector_list (_sources APP_COMMON_SOURCES) diff --git a/examples/legacy_apps/examples/rpc_demo/CMakeLists.txt b/examples/legacy_apps/examples/rpc_demo/CMakeLists.txt index a8b486d..cb4169e 100644 --- a/examples/legacy_apps/examples/rpc_demo/CMakeLists.txt +++ b/examples/legacy_apps/examples/rpc_demo/CMakeLists.txt @@ -15,6 +15,11 @@ if (NOT _linker_opt) endif (NOT _linker_opt) 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) + set (OPENAMP_LIB open_amp) if (${PROJECT_SYSTEM} STREQUAL "linux") diff --git a/examples/legacy_apps/machine/zynqmp_r5/platform_info.c b/examples/legacy_apps/machine/zynqmp_r5/platform_info.c index cd266f2..41df650 100644 --- a/examples/legacy_apps/machine/zynqmp_r5/platform_info.c +++ b/examples/legacy_apps/machine/zynqmp_r5/platform_info.c @@ -32,13 +32,6 @@ #define KICK_DEV_NAME "poll_dev" #define KICK_BUS_NAME "generic" -/* Cortex R5 memory attributes */ -#define DEVICE_SHARED 0x00000001U /* device, shareable */ -#define DEVICE_NONSHARED 0x00000010U /* device, non shareable */ -#define NORM_NSHARED_NCACHE 0x00000008U /* Non cacheable non shareable */ -#define NORM_SHARED_NCACHE 0x0000000CU /* Non cacheable shareable */ -#define PRIV_RW_USER_RW (0x00000003U<<8U) /* Full Access */ - #ifndef RPMSG_NO_IPI #define _rproc_wait() asm volatile("wfi") #endif /* !RPMSG_NO_IPI */ diff --git a/examples/legacy_apps/machine/zynqmp_r5/platform_info.h b/examples/legacy_apps/machine/zynqmp_r5/platform_info.h index 8ff7827..422b31f 100644 --- a/examples/legacy_apps/machine/zynqmp_r5/platform_info.h +++ b/examples/legacy_apps/machine/zynqmp_r5/platform_info.h @@ -18,6 +18,10 @@ #include "xparameters.h" +#ifdef SDT +#include "bspconfig.h" /* This provides SOC symbols. */ +#endif + #if defined __cplusplus extern "C" { #endif @@ -46,38 +50,14 @@ extern "C" { */ #include "amd_platform_info.h" #else - -/* Interrupt vectors */ -#ifdef versal - -#ifndef IPI_IRQ_VECT_ID -#define IPI_IRQ_VECT_ID 63 -#endif /* !IPI_IRQ_VECT_ID */ - -#ifndef POLL_BASE_ADDR -#define POLL_BASE_ADDR 0xFF340000 /* IPI base address*/ -#endif /* !POLL_BASE_ADDR */ - -#ifndef IPI_CHN_BITMASK -#define IPI_CHN_BITMASK 0x0000020 /* IPI channel bit mask for IPI from/to - APU */ -#endif /* !IPI_CHN_BITMASK */ - -#else - -#ifndef IPI_IRQ_VECT_ID -#define IPI_IRQ_VECT_ID XPAR_XIPIPSU_0_INT_ID -#endif /* !IPI_IRQ_VECT_ID */ - -#ifndef POLL_BASE_ADDR -#define POLL_BASE_ADDR XPAR_XIPIPSU_0_BASE_ADDRESS -#endif /* !POLL_BASE_ADDR */ - -#ifndef IPI_CHN_BITMASK -#define IPI_CHN_BITMASK 0x01000000 -#endif /* !IPI_CHN_BITMASK */ - -#endif /* versal */ +#ifdef VERSAL_NET +#include "platform_info_versal_net.h" +#elif defined(versal) +#include "platform_info_versal.h" +#elif defined(PLATFORM_ZYNQMP) +#include "platform_info_zynqmp.h" +#error "unknown platform" +#endif #ifdef RPMSG_NO_IPI #undef POLL_BASE_ADDR diff --git a/examples/legacy_apps/machine/zynqmp_r5/platform_info_versal.h b/examples/legacy_apps/machine/zynqmp_r5/platform_info_versal.h new file mode 100644 index 0000000..3262204 --- /dev/null +++ b/examples/legacy_apps/machine/zynqmp_r5/platform_info_versal.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef PLATFORM_INFO_VERSAL_H_ +#define PLATFORM_INFO_VERSAL_H_ + +#include + +#ifndef IPI_IRQ_VECT_ID +#ifdef USE_FREERTOS +#define IPI_IRQ_VECT_ID (IPI_VECT_ID_IPI1 - 32U) +#else /* Default is baremetal */ +#define IPI_IRQ_VECT_ID 63 +#endif /* USE_FREERTOS */ +#endif /* !IPI_IRQ_VECT_ID */ + +#ifndef POLL_BASE_ADDR +#define POLL_BASE_ADDR 0xFF340000 /* IPI base address*/ +#endif /* !POLL_BASE_ADDR */ + +#ifndef IPI_CHN_BITMASK +#define IPI_CHN_BITMASK 0x0000020 +#endif /* !IPI_CHN_BITMASK */ + +#endif /* PLATFORM_INFO_VERSAL_H_ */ \ No newline at end of file diff --git a/examples/legacy_apps/machine/zynqmp_r5/platform_info_versal_net.h b/examples/legacy_apps/machine/zynqmp_r5/platform_info_versal_net.h new file mode 100644 index 0000000..24b9de9 --- /dev/null +++ b/examples/legacy_apps/machine/zynqmp_r5/platform_info_versal_net.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef PLATFORM_INFO_VERSAL_NET_H_ +#define PLATFORM_INFO_VERSAL_NET_H_ + +#include + +#ifndef IPI_IRQ_VECT_ID +#ifdef USE_FREERTOS +#define IPI_IRQ_VECT_ID (IPI_VECT_ID_IPI1 - 32U) +#else /* Default is baremetal */ +#define IPI_IRQ_VECT_ID 90 +#endif /* USE_FREERTOS */ +#endif /* !IPI_IRQ_VECT_ID */ + +#ifndef POLL_BASE_ADDR +#define POLL_BASE_ADDR 0xEB340000 /* IPI base address*/ +#endif /* !POLL_BASE_ADDR */ + +#ifndef IPI_CHN_BITMASK +#define IPI_CHN_BITMASK 0x0000020 +#endif /* !IPI_CHN_BITMASK */ + +#endif /* PLATFORM_INFO_VERSAL_NET_H_ */ diff --git a/examples/legacy_apps/machine/zynqmp_r5/platform_info_zynqmp.h b/examples/legacy_apps/machine/zynqmp_r5/platform_info_zynqmp.h new file mode 100644 index 0000000..7802656 --- /dev/null +++ b/examples/legacy_apps/machine/zynqmp_r5/platform_info_zynqmp.h @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef PLATFORM_INFO_ZYNQMP_H_ +#define PLATFORM_INFO_ZYNQMP_H_ + +#ifdef SDT + +/* In case BSP does not provide symbol */ +#ifndef XPAR_XIPIPSU_0_BASEADDR + +#if XPAR_CPU_ID == 0 +#define XPAR_XIPIPSU_0_BASEADDR 0xff310000 +#else +#define XPAR_XIPIPSU_0_BASEADDR 0xff320000 +#endif /* XPAR_CPU_ID == 0 */ + +#endif /* !XPAR_XIPIPSU_0_BASEADDR */ + +#ifndef POLL_BASE_ADDR +#define POLL_BASE_ADDR XPAR_XIPIPSU_0_BASEADDR +#endif /* !POLL_BASE_ADDR */ + +/* In case BSP does not provide symbol */ +#ifndef XPAR_XIPIPSU_0_INTR + +#if XPAR_CPU_ID == 0 +#define XPAR_XIPIPSU_0_INTR 0x41 +#else +#define XPAR_XIPIPSU_0_INTR 0x42 +#endif /* XPAR_CPU_ID == 0 */ + +#endif /* !XPAR_XIPIPSU_0_INTR */ + +#ifndef IPI_IRQ_VECT_ID +#define IPI_IRQ_VECT_ID XPAR_XIPIPSU_0_INTR +#endif /* !IPI_IRQ_VECT_ID */ + +#if XPAR_CPU_ID == 0 + +#ifndef XPAR_IPI1_7_IPI_BITMASK +#define XPAR_IPI1_7_IPI_BITMASK 0x01000000 +#endif /* !XPAR_IPI1_7_IPI_BITMASK */ + +#ifndef IPI_CHN_BITMASK +#define IPI_CHN_BITMASK XPAR_IPI1_7_IPI_BITMASK +#endif /* !IPI_CHN_BITMASK */ + +#else + +#ifndef XPAR_IPI2_8_IPI_BITMASK +#define XPAR_IPI2_8_IPI_BITMASK 0x02000000 +#endif /* !XPAR_IPI2_8_IPI_BITMASK */ + +#ifndef IPI_CHN_BITMASK +#define IPI_CHN_BITMASK XPAR_IPI2_8_IPI_BITMASK +#endif /* !IPI_CHN_BITMASK */ + +#endif + +#else /* Vitis Classic Case */ + +#ifndef IPI_IRQ_VECT_ID +#define IPI_IRQ_VECT_ID XPAR_XIPIPSU_0_INT_ID +#endif /* !IPI_IRQ_VECT_ID */ + +#ifndef POLL_BASE_ADDR +#define POLL_BASE_ADDR XPAR_XIPIPSU_0_BASE_ADDRESS +#endif /* !POLL_BASE_ADDR */ + +#if XPAR_CPU_ID == 0 +#ifndef IPI_CHN_BITMASK +#define IPI_CHN_BITMASK 0x01000000 +#endif /* !IPI_CHN_BITMASK */ +#else /* RPU1 */ +#ifndef IPI_CHN_BITMASK +#define IPI_CHN_BITMASK 0x02000000 +#endif /* !IPI_CHN_BITMASK */ +#endif /* XPAR_CPU_ID == 0 */ + +#endif /* SDT */ + +#endif /* PLATFORM_INFO_ZYNQMP_H_ */ diff --git a/examples/legacy_apps/system/generic/machine/zynqmp_r5/CMakeLists.txt b/examples/legacy_apps/system/generic/machine/zynqmp_r5/CMakeLists.txt index 91c0caf..9b64f38 100644 --- a/examples/legacy_apps/system/generic/machine/zynqmp_r5/CMakeLists.txt +++ b/examples/legacy_apps/system/generic/machine/zynqmp_r5/CMakeLists.txt @@ -8,6 +8,16 @@ if(NOT DEFINED ${RSC_TABLE}) endif(NOT DEFINED ${RSC_TABLE}) set (_linker_script "${CMAKE_CURRENT_SOURCE_DIR}/linker_remote.ld") +string(REGEX MATCH "SDT" HAS_SYSTEM_DT "${CMAKE_C_FLAGS}") +check_symbol_exists(VERSAL_NET "bspconfig.h" IS_VERSAL_NET) +if (HAS_SYSTEM_DT) + if (IS_VERSAL_NET) + set (_linker_script "${CMAKE_CURRENT_SOURCE_DIR}/linker_sdt_versal_net.ld") + else() + set (_linker_script "${CMAKE_CURRENT_SOURCE_DIR}/linker_sdt.ld") + endif(IS_VERSAL_NET) +endif(HAS_SYSTEM_DT) + set_property (GLOBAL PROPERTY APP_LINKER_OPT "-Wl,--defsym,_rsc_table=${RSC_TABLE} -T\"${_linker_script}\"") set (_linker_large_text_script "${CMAKE_CURRENT_SOURCE_DIR}/linker_large_text.ld") set_property (GLOBAL PROPERTY APP_LINKER_LARGE_TEXT_OPT "-Wl,--defsym,_rsc_table=${RSC_TABLE} -T\"${_linker_large_text_script}\"") diff --git a/examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_sdt.ld b/examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_sdt.ld new file mode 100644 index 0000000..d055ef6 --- /dev/null +++ b/examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_sdt.ld @@ -0,0 +1,300 @@ +/****************************************************************************** +* Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved. +* SPDX-License-Identifier: MIT +******************************************************************************/ + +_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x2000; +_HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x2000; + +_ABORT_STACK_SIZE = DEFINED(_ABORT_STACK_SIZE) ? _ABORT_STACK_SIZE : 1024; +_SUPERVISOR_STACK_SIZE = DEFINED(_SUPERVISOR_STACK_SIZE) ? _SUPERVISOR_STACK_SIZE : 2048; +_IRQ_STACK_SIZE = DEFINED(_IRQ_STACK_SIZE) ? _IRQ_STACK_SIZE : 1024; +_FIQ_STACK_SIZE = DEFINED(_FIQ_STACK_SIZE) ? _FIQ_STACK_SIZE : 1024; +_UNDEF_STACK_SIZE = DEFINED(_UNDEF_STACK_SIZE) ? _UNDEF_STACK_SIZE : 1024; + +MEMORY +{ + psu_ddr_0 : ORIGIN = 0x3ED00000, LENGTH = 0x00040000 + psu_r5_0_atcm_MEM_0 : ORIGIN = 0x0, LENGTH = 0x10000 + psu_r5_0_btcm_MEM_0 : ORIGIN = 0x20000, LENGTH = 0x10000 +} + +ENTRY(_vector_table) + +/* Define the sections, and where they are mapped in memory */ + +SECTIONS +{ +.vectors : { + KEEP (*(.vectors)) + *(.boot) +} > psu_r5_0_atcm_MEM_0 + +.resource_table _rsc_table : { +. = ALIGN(4); +*(.resource_table) +} > psu_ddr_0 + +.text : { + *(.text) + *(.text.*) + *(.gnu.linkonce.t.*) + *(.plt) + *(.gnu_warning) + *(.gcc_execpt_table) + *(.glue_7) + *(.glue_7t) + *(.vfp11_veneer) + *(.ARM.extab) + *(.gnu.linkonce.armextab.*) +} > psu_ddr_0 + +.init : { + KEEP (*(.init)) +} > psu_r5_0_btcm_MEM_0 + +.fini : { + KEEP (*(.fini)) +} > psu_r5_0_btcm_MEM_0 + +.interp : { + KEEP (*(.interp)) +} > psu_r5_0_btcm_MEM_0 +.note-ABI-tag : { + KEEP (*(.note-ABI-tag)) +} > psu_r5_0_btcm_MEM_0 + +.rodata : { + __rodata_start = .; + *(.rodata) + *(.rodata.*) + *(.gnu.linkonce.r.*) + __rodata_end = .; +} > psu_r5_0_btcm_MEM_0 + +.rodata1 : { + __rodata1_start = .; + *(.rodata1) + *(.rodata1.*) + __rodata1_end = .; +} > psu_r5_0_btcm_MEM_0 + +.sdata2 : { + __sdata2_start = .; + *(.sdata2) + *(.sdata2.*) + *(.gnu.linkonce.s2.*) + __sdata2_end = .; +} > psu_r5_0_btcm_MEM_0 + +.sbss2 : { + __sbss2_start = .; + *(.sbss2) + *(.sbss2.*) + *(.gnu.linkonce.sb2.*) + __sbss2_end = .; +} > psu_r5_0_btcm_MEM_0 + +.data : { + __data_start = .; + *(.data) + *(.data.*) + *(.gnu.linkonce.d.*) + *(.jcr) + *(.got) + *(.got.plt) + __data_end = .; +} > psu_r5_0_btcm_MEM_0 + +.data1 : { + __data1_start = .; + *(.data1) + *(.data1.*) + __data1_end = .; +} > psu_r5_0_btcm_MEM_0 + +.got : { + *(.got) +} > psu_r5_0_btcm_MEM_0 + +.ctors : { + __CTOR_LIST__ = .; + ___CTORS_LIST___ = .; + KEEP (*crtbegin.o(.ctors)) + KEEP (*(EXCLUDE_FILE(*crtend.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + __CTOR_END__ = .; + ___CTORS_END___ = .; +} > psu_r5_0_btcm_MEM_0 + +.dtors : { + __DTOR_LIST__ = .; + ___DTORS_LIST___ = .; + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE(*crtend.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + __DTOR_END__ = .; + ___DTORS_END___ = .; +} > psu_r5_0_btcm_MEM_0 + +.fixup : { + __fixup_start = .; + *(.fixup) + __fixup_end = .; +} > psu_r5_0_btcm_MEM_0 + +.eh_frame : { + *(.eh_frame) +} > psu_r5_0_btcm_MEM_0 + +.eh_framehdr : { + __eh_framehdr_start = .; + *(.eh_framehdr) + __eh_framehdr_end = .; +} > psu_r5_0_btcm_MEM_0 + +.gcc_except_table : { + *(.gcc_except_table) +} > psu_r5_0_btcm_MEM_0 + +.mmu_tbl (ALIGN(16384)) : { + __mmu_tbl_start = .; + *(.mmu_tbl) + __mmu_tbl_end = .; +} > psu_r5_0_btcm_MEM_0 + +.ARM.exidx : { + __exidx_start = .; + *(.ARM.exidx*) + *(.gnu.linkonce.armexidix.*.*) + __exidx_end = .; +} > psu_r5_0_btcm_MEM_0 + +.preinit_array : { + __preinit_array_start = .; + KEEP (*(SORT(.preinit_array.*))) + KEEP (*(.preinit_array)) + __preinit_array_end = .; +} > psu_r5_0_btcm_MEM_0 + +.init_array : { + __init_array_start = .; + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + __init_array_end = .; +} > psu_r5_0_btcm_MEM_0 + +.fini_array : { + __fini_array_start = .; + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array)) + __fini_array_end = .; +} > psu_r5_0_btcm_MEM_0 + +.ARM.attributes : { + __ARM.attributes_start = .; + *(.ARM.attributes) + __ARM.attributes_end = .; +} > psu_r5_0_btcm_MEM_0 + +.sdata : { + __sdata_start = .; + *(.sdata) + *(.sdata.*) + *(.gnu.linkonce.s.*) + __sdata_end = .; +} > psu_r5_0_btcm_MEM_0 + +.sbss (NOLOAD) : { + __sbss_start = .; + *(.sbss) + *(.sbss.*) + *(.gnu.linkonce.sb.*) + __sbss_end = .; +} > psu_r5_0_btcm_MEM_0 + +.tdata : { + __tdata_start = .; + *(.tdata) + *(.tdata.*) + *(.gnu.linkonce.td.*) + __tdata_end = .; +} > psu_r5_0_btcm_MEM_0 + +.tbss : { + __tbss_start = .; + *(.tbss) + *(.tbss.*) + *(.gnu.linkonce.tb.*) + __tbss_end = .; +} > psu_r5_0_btcm_MEM_0 + +.bss (NOLOAD) : { + . = ALIGN(4); + __bss_start__ = .; + *(.bss) + *(.bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; +} > psu_r5_0_btcm_MEM_0 + +_SDA_BASE_ = __sdata_start + ((__sbss_end - __sdata_start) / 2 ); + +_SDA2_BASE_ = __sdata2_start + ((__sbss2_end - __sdata2_start) / 2 ); + +/* Generate Stack and Heap definitions */ + + +.heap (NOLOAD) : { + . = ALIGN(16); + _heap = .; + HeapBase = .; + _heap_start = .; + . += _HEAP_SIZE; + _heap_end = .; + HeapLimit = .; +} > psu_r5_0_btcm_MEM_0 + +.stack (NOLOAD) : { + . = ALIGN(16); + _stack_end = .; + . += _STACK_SIZE; + _stack = .; + __stack = _stack; + . = ALIGN(16); + _irq_stack_end = .; + . += _IRQ_STACK_SIZE; + __irq_stack = .; + _supervisor_stack_end = .; + . += _SUPERVISOR_STACK_SIZE; + . = ALIGN(16); + __supervisor_stack = .; + _abort_stack_end = .; + . += _ABORT_STACK_SIZE; + . = ALIGN(16); + __abort_stack = .; + _fiq_stack_end = .; + . += _FIQ_STACK_SIZE; + . = ALIGN(16); + __fiq_stack = .; + _undef_stack_end = .; + . += _UNDEF_STACK_SIZE; + . = ALIGN(16); + __undef_stack = .; +} > psu_r5_0_btcm_MEM_0 + +.drvcfg_sec : { + . = ALIGN(8); + __drvcfgsecdata_start = .; + KEEP (*(.drvcfg_sec)) + __drvcfgsecdata_end = .; + __drvcfgsecdata_size = __drvcfgsecdata_end - __drvcfgsecdata_start; +} > psu_r5_0_btcm_MEM_0 + + +end = .; +} \ No newline at end of file diff --git a/examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_sdt_versal_net.ld b/examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_sdt_versal_net.ld new file mode 100644 index 0000000..7ea7d8e --- /dev/null +++ b/examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_sdt_versal_net.ld @@ -0,0 +1,308 @@ +/****************************************************************************** +* Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved. +* SPDX-License-Identifier: MIT +******************************************************************************/ + +_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x2000; +_HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x2000; + +_ABORT_STACK_SIZE = DEFINED(_ABORT_STACK_SIZE) ? _ABORT_STACK_SIZE : 1024; +_SUPERVISOR_STACK_SIZE = DEFINED(_SUPERVISOR_STACK_SIZE) ? _SUPERVISOR_STACK_SIZE : 2048; +_IRQ_STACK_SIZE = DEFINED(_IRQ_STACK_SIZE) ? _IRQ_STACK_SIZE : 1024; +_FIQ_STACK_SIZE = DEFINED(_FIQ_STACK_SIZE) ? _FIQ_STACK_SIZE : 1024; +_UNDEF_STACK_SIZE = DEFINED(_UNDEF_STACK_SIZE) ? _UNDEF_STACK_SIZE : 1024; + +MEMORY +{ + psx_r52_atcm_MEM_0 : ORIGIN = 0x0, LENGTH = 0x10000 + psx_r52_btcm_MEM_0 : ORIGIN = 0x10000, LENGTH = 0x8000 + psx_r52_ctcm_MEM_0 : ORIGIN = 0x18000, LENGTH = 0x8000 + psx_r52_ddr_0_MEM_0 : ORIGIN = 0x3ed00000, LENGTH = 0x00040000 +} + +ENTRY(_vector_table) + +/* Define the sections, and where they are mapped in memory */ + +SECTIONS +{ +.vectors : { + KEEP (*(.vectors)) + *(.boot) +} > psx_r52_atcm_MEM_0 + +.bootdata : { + _TCM_A_REGION = .; LONG(0x0) + _TCM_B_REGION = .; LONG(0x10001) + _TCM_C_REGION = .; LONG(0x18001) + *(.bootdata) +} > psx_r52_atcm_MEM_0 + +.resource_table _rsc_table : { +. = ALIGN(4); +*(.resource_table) +} > psx_r52_ddr_0_MEM_0 + +.text : { + *(.text) + *(.text.*) + *(.gnu.linkonce.t.*) + *(.plt) + *(.gnu_warning) + *(.gcc_execpt_table) + *(.glue_7) + *(.glue_7t) + *(.vfp11_veneer) + *(.ARM.extab) + *(.gnu.linkonce.armextab.*) +} > psx_r52_ddr_0_MEM_0 + +.init : { + KEEP (*(.init)) +} > psx_r52_btcm_MEM_0 + +.fini : { + KEEP (*(.fini)) +} > psx_r52_btcm_MEM_0 + +.interp : { + KEEP (*(.interp)) +} > psx_r52_btcm_MEM_0 + +.note-ABI-tag : { + KEEP (*(.note-ABI-tag)) +} > psx_r52_btcm_MEM_0 + +.rodata : { + __rodata_start = .; + *(.rodata) + *(.rodata.*) + *(.gnu.linkonce.r.*) + __rodata_end = .; +} > psx_r52_btcm_MEM_0 + +.rodata1 : { + __rodata1_start = .; + *(.rodata1) + *(.rodata1.*) + __rodata1_end = .; +} > psx_r52_btcm_MEM_0 + +.sdata2 : { + __sdata2_start = .; + *(.sdata2) + *(.sdata2.*) + *(.gnu.linkonce.s2.*) + __sdata2_end = .; +} > psx_r52_btcm_MEM_0 + +.sbss2 : { + __sbss2_start = .; + *(.sbss2) + *(.sbss2.*) + *(.gnu.linkonce.sb2.*) + __sbss2_end = .; +} > psx_r52_btcm_MEM_0 + +.data : { + __data_start = .; + *(.data) + *(.data.*) + *(.gnu.linkonce.d.*) + *(.jcr) + *(.got) + *(.got.plt) + __data_end = .; +} > psx_r52_btcm_MEM_0 + +.data1 : { + __data1_start = .; + *(.data1) + *(.data1.*) + __data1_end = .; +} > psx_r52_btcm_MEM_0 + +.got : { + *(.got) +} > psx_r52_btcm_MEM_0 + +.ctors : { + __CTOR_LIST__ = .; + ___CTORS_LIST___ = .; + KEEP (*crtbegin.o(.ctors)) + KEEP (*(EXCLUDE_FILE(*crtend.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + __CTOR_END__ = .; + ___CTORS_END___ = .; +} > psx_r52_btcm_MEM_0 + +.dtors : { + __DTOR_LIST__ = .; + ___DTORS_LIST___ = .; + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE(*crtend.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + __DTOR_END__ = .; + ___DTORS_END___ = .; +} > psx_r52_btcm_MEM_0 + +.fixup : { + __fixup_start = .; + *(.fixup) + __fixup_end = .; +} > psx_r52_btcm_MEM_0 + +.eh_frame : { + *(.eh_frame) +} > psx_r52_btcm_MEM_0 + +.eh_framehdr : { + __eh_framehdr_start = .; + *(.eh_framehdr) + __eh_framehdr_end = .; +} > psx_r52_btcm_MEM_0 + +.gcc_except_table : { + *(.gcc_except_table) +} > psx_r52_btcm_MEM_0 + +.mmu_tbl (ALIGN(16384)) : { + __mmu_tbl_start = .; + *(.mmu_tbl) + __mmu_tbl_end = .; +} > psx_r52_btcm_MEM_0 + +.ARM.exidx : { + __exidx_start = .; + *(.ARM.exidx*) + *(.gnu.linkonce.armexidix.*.*) + __exidx_end = .; +} > psx_r52_btcm_MEM_0 + +.preinit_array : { + __preinit_array_start = .; + KEEP (*(SORT(.preinit_array.*))) + KEEP (*(.preinit_array)) + __preinit_array_end = .; +} > psx_r52_btcm_MEM_0 + +.init_array : { + __init_array_start = .; + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + __init_array_end = .; +} > psx_r52_btcm_MEM_0 + +.fini_array : { + __fini_array_start = .; + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array)) + __fini_array_end = .; +} > psx_r52_btcm_MEM_0 + +.ARM.attributes : { + __ARM.attributes_start = .; + *(.ARM.attributes) + __ARM.attributes_end = .; +} > psx_r52_btcm_MEM_0 + +.sdata : { + __sdata_start = .; + *(.sdata) + *(.sdata.*) + *(.gnu.linkonce.s.*) + __sdata_end = .; +} > psx_r52_btcm_MEM_0 + +.sbss (NOLOAD) : { + __sbss_start = .; + *(.sbss) + *(.sbss.*) + *(.gnu.linkonce.sb.*) + __sbss_end = .; +} > psx_r52_btcm_MEM_0 + +.tdata : { + __tdata_start = .; + *(.tdata) + *(.tdata.*) + *(.gnu.linkonce.td.*) + __tdata_end = .; +} > psx_r52_btcm_MEM_0 + +.tbss : { + __tbss_start = .; + *(.tbss) + *(.tbss.*) + *(.gnu.linkonce.tb.*) + __tbss_end = .; +} > psx_r52_btcm_MEM_0 + +.bss (NOLOAD) : { + . = ALIGN(4); + __bss_start__ = .; + *(.bss) + *(.bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; +} > psx_r52_btcm_MEM_0 + +_SDA_BASE_ = __sdata_start + ((__sbss_end - __sdata_start) / 2 ); + +_SDA2_BASE_ = __sdata2_start + ((__sbss2_end - __sdata2_start) / 2 ); + +/* Generate Stack and Heap definitions */ + + +.heap (NOLOAD) : { + . = ALIGN(16); + _heap = .; + HeapBase = .; + _heap_start = .; + . += _HEAP_SIZE; + _heap_end = .; + HeapLimit = .; +} > psx_r52_btcm_MEM_0 + +.stack (NOLOAD) : { + . = ALIGN(16); + _stack_end = .; + . += _STACK_SIZE; + _stack = .; + __stack = _stack; + . = ALIGN(16); + _irq_stack_end = .; + . += _IRQ_STACK_SIZE; + __irq_stack = .; + _supervisor_stack_end = .; + . += _SUPERVISOR_STACK_SIZE; + . = ALIGN(16); + __supervisor_stack = .; + _abort_stack_end = .; + . += _ABORT_STACK_SIZE; + . = ALIGN(16); + __abort_stack = .; + _fiq_stack_end = .; + . += _FIQ_STACK_SIZE; + . = ALIGN(16); + __fiq_stack = .; + _undef_stack_end = .; + . += _UNDEF_STACK_SIZE; + . = ALIGN(16); + __undef_stack = .; +} > psx_r52_ctcm_MEM_0 + +.drvcfg_sec : { + . = ALIGN(8); + __drvcfgsecdata_start = .; + KEEP (*(.drvcfg_sec)) + __drvcfgsecdata_end = .; + __drvcfgsecdata_size = __drvcfgsecdata_end - __drvcfgsecdata_start; +} > psx_r52_ctcm_MEM_0 + +end = .; +} From 120da988e66eca268352d1d9ee52c6fc6886ad61 Mon Sep 17 00:00:00 2001 From: Ben Levinsky Date: Tue, 14 Jan 2025 10:57:50 -0800 Subject: [PATCH 4/5] apps: zynqmp_r5: Enable linker file generation based off SDT Lopper plugin As System Device Tree flow supports Lopper generated OpenAMP Linker scripts enable the configuration of these for ZynqMP, Versal and Versal-NET SOC's. Signed-off-by: Ben Levinsky --- .../generic/machine/zynqmp_r5/CMakeLists.txt | 39 ++- .../{ => linker_files}/linker_large_text.ld | 0 .../{ => linker_files}/linker_remote.ld | 0 .../{ => linker_files}/linker_sdt.ld | 0 .../linker_sdt_versal_net.ld | 0 .../zynqmp_r5/linker_files/lscript_r5.ld.in | 295 +++++++++++++++++ .../linker_files/lscript_versal_net_r5.ld.in | 302 ++++++++++++++++++ .../linker_files/lscript_versal_r5.ld.in | 295 +++++++++++++++++ 8 files changed, 919 insertions(+), 12 deletions(-) rename examples/legacy_apps/system/generic/machine/zynqmp_r5/{ => linker_files}/linker_large_text.ld (100%) rename examples/legacy_apps/system/generic/machine/zynqmp_r5/{ => linker_files}/linker_remote.ld (100%) rename examples/legacy_apps/system/generic/machine/zynqmp_r5/{ => linker_files}/linker_sdt.ld (100%) rename examples/legacy_apps/system/generic/machine/zynqmp_r5/{ => linker_files}/linker_sdt_versal_net.ld (100%) create mode 100644 examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_files/lscript_r5.ld.in create mode 100644 examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_files/lscript_versal_net_r5.ld.in create mode 100644 examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_files/lscript_versal_r5.ld.in diff --git a/examples/legacy_apps/system/generic/machine/zynqmp_r5/CMakeLists.txt b/examples/legacy_apps/system/generic/machine/zynqmp_r5/CMakeLists.txt index 9b64f38..5bee136 100644 --- a/examples/legacy_apps/system/generic/machine/zynqmp_r5/CMakeLists.txt +++ b/examples/legacy_apps/system/generic/machine/zynqmp_r5/CMakeLists.txt @@ -2,24 +2,39 @@ include(CheckSymbolExists) collect (APP_COMMON_SOURCES helper.c) -# If not provided, add default value for resource table -if(NOT DEFINED ${RSC_TABLE}) - set(RSC_TABLE 0x3ed20000 CACHE STRING "") -endif(NOT DEFINED ${RSC_TABLE}) +set (_linker_large_text_script "${CMAKE_CURRENT_SOURCE_DIR}/linker_large_text.ld") + +get_property (HAS_SYSTEM_DT GLOBAL PROPERTY HAS_SYSTEM_DT) +get_property (LINKER_METADATA_FILE GLOBAL PROPERTY LINKER_METADATA_FILE) +get_property (SOC GLOBAL PROPERTY SOC) + +set (SOCS ZYNQMP VERSAL VERSAL_NET) +set (STATIC_LINKERS linker_sdt.ld linker_sdt.ld linker_sdt_versal_net.ld) +set (LOPPER_CFG_LINKERS lscript_r5.ld.in lscript_versal_r5.ld.in lscript_versal_net_r5.ld.in) -set (_linker_script "${CMAKE_CURRENT_SOURCE_DIR}/linker_remote.ld") -string(REGEX MATCH "SDT" HAS_SYSTEM_DT "${CMAKE_C_FLAGS}") -check_symbol_exists(VERSAL_NET "bspconfig.h" IS_VERSAL_NET) +list(FIND SOCS ${SOC} soc_index) if (HAS_SYSTEM_DT) - if (IS_VERSAL_NET) - set (_linker_script "${CMAKE_CURRENT_SOURCE_DIR}/linker_sdt_versal_net.ld") + 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") else() - set (_linker_script "${CMAKE_CURRENT_SOURCE_DIR}/linker_sdt.ld") - endif(IS_VERSAL_NET) + list (GET STATIC_LINKERS ${soc_index} static_linker) + set (_linker_script "${CMAKE_CURRENT_SOURCE_DIR}/linker_files/${static_linker}") + endif(EXISTS ${LINKER_METADATA_FILE}) + + set (_linker_large_text_script "${_linker_script}") endif(HAS_SYSTEM_DT) +# If not provided, add default value for resource table +if(NOT DEFINED RSC_TABLE) + set(RSC_TABLE 0x3ed20000 CACHE STRING "") +endif(NOT DEFINED RSC_TABLE) + set_property (GLOBAL PROPERTY APP_LINKER_OPT "-Wl,--defsym,_rsc_table=${RSC_TABLE} -T\"${_linker_script}\"") -set (_linker_large_text_script "${CMAKE_CURRENT_SOURCE_DIR}/linker_large_text.ld") set_property (GLOBAL PROPERTY APP_LINKER_LARGE_TEXT_OPT "-Wl,--defsym,_rsc_table=${RSC_TABLE} -T\"${_linker_large_text_script}\"") find_path(XIL_INCLUDE_DIR NAMES xparameters.h PATHS ${CMAKE_FIND_ROOT_PATH}) diff --git a/examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_large_text.ld b/examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_files/linker_large_text.ld similarity index 100% rename from examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_large_text.ld rename to examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_files/linker_large_text.ld diff --git a/examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_remote.ld b/examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_files/linker_remote.ld similarity index 100% rename from examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_remote.ld rename to examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_files/linker_remote.ld diff --git a/examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_sdt.ld b/examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_files/linker_sdt.ld similarity index 100% rename from examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_sdt.ld rename to examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_files/linker_sdt.ld diff --git a/examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_sdt_versal_net.ld b/examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_files/linker_sdt_versal_net.ld similarity index 100% rename from examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_sdt_versal_net.ld rename to examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_files/linker_sdt_versal_net.ld diff --git a/examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_files/lscript_r5.ld.in b/examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_files/lscript_r5.ld.in new file mode 100644 index 0000000..228985b --- /dev/null +++ b/examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_files/lscript_r5.ld.in @@ -0,0 +1,295 @@ +/****************************************************************************** +* Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved. +* SPDX-License-Identifier: MIT +******************************************************************************/ + +_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : @STACK_SIZE@; +_HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : @HEAP_SIZE@; + +_ABORT_STACK_SIZE = DEFINED(_ABORT_STACK_SIZE) ? _ABORT_STACK_SIZE : 1024; +_SUPERVISOR_STACK_SIZE = DEFINED(_SUPERVISOR_STACK_SIZE) ? _SUPERVISOR_STACK_SIZE : 2048; +_IRQ_STACK_SIZE = DEFINED(_IRQ_STACK_SIZE) ? _IRQ_STACK_SIZE : 1024; +_FIQ_STACK_SIZE = DEFINED(_FIQ_STACK_SIZE) ? _FIQ_STACK_SIZE : 1024; +_UNDEF_STACK_SIZE = DEFINED(_UNDEF_STACK_SIZE) ? _UNDEF_STACK_SIZE : 1024; + +@MEMORY_SECTION@ + +ENTRY(_vector_table) + +/* Define the sections, and where they are mapped in memory */ + +SECTIONS +{ +.vectors : { + KEEP (*(.vectors)) + *(.boot) +} > psu_r5_0_atcm_MEM_0 + +.resource_table @RSC_TABLE@ : { +. = ALIGN(4); +*(.resource_table) +} > @DDR@ + +.text @RSC_TABLE@ + 0x100 : { + *(.text) + *(.text.*) + *(.gnu.linkonce.t.*) + *(.plt) + *(.gnu_warning) + *(.gcc_execpt_table) + *(.glue_7) + *(.glue_7t) + *(.vfp11_veneer) + *(.ARM.extab) + *(.gnu.linkonce.armextab.*) +} > @DDR@ + +.init : { + KEEP (*(.init)) +} > psu_r5_0_btcm_MEM_0 + +.fini : { + KEEP (*(.fini)) +} > psu_r5_0_btcm_MEM_0 + +.interp : { + KEEP (*(.interp)) +} > psu_r5_0_btcm_MEM_0 +.note-ABI-tag : { + KEEP (*(.note-ABI-tag)) +} > psu_r5_0_btcm_MEM_0 + +.rodata : { + __rodata_start = .; + *(.rodata) + *(.rodata.*) + *(.gnu.linkonce.r.*) + __rodata_end = .; +} > psu_r5_0_btcm_MEM_0 + +.rodata1 : { + __rodata1_start = .; + *(.rodata1) + *(.rodata1.*) + __rodata1_end = .; +} > psu_r5_0_btcm_MEM_0 + +.sdata2 : { + __sdata2_start = .; + *(.sdata2) + *(.sdata2.*) + *(.gnu.linkonce.s2.*) + __sdata2_end = .; +} > psu_r5_0_btcm_MEM_0 + +.sbss2 : { + __sbss2_start = .; + *(.sbss2) + *(.sbss2.*) + *(.gnu.linkonce.sb2.*) + __sbss2_end = .; +} > psu_r5_0_btcm_MEM_0 + +.data : { + __data_start = .; + *(.data) + *(.data.*) + *(.gnu.linkonce.d.*) + *(.jcr) + *(.got) + *(.got.plt) + __data_end = .; +} > psu_r5_0_btcm_MEM_0 + +.data1 : { + __data1_start = .; + *(.data1) + *(.data1.*) + __data1_end = .; +} > psu_r5_0_btcm_MEM_0 + +.got : { + *(.got) +} > psu_r5_0_btcm_MEM_0 + +.ctors : { + __CTOR_LIST__ = .; + ___CTORS_LIST___ = .; + KEEP (*crtbegin.o(.ctors)) + KEEP (*(EXCLUDE_FILE(*crtend.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + __CTOR_END__ = .; + ___CTORS_END___ = .; +} > psu_r5_0_btcm_MEM_0 + +.dtors : { + __DTOR_LIST__ = .; + ___DTORS_LIST___ = .; + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE(*crtend.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + __DTOR_END__ = .; + ___DTORS_END___ = .; +} > psu_r5_0_btcm_MEM_0 + +.fixup : { + __fixup_start = .; + *(.fixup) + __fixup_end = .; +} > psu_r5_0_btcm_MEM_0 + +.eh_frame : { + *(.eh_frame) +} > psu_r5_0_btcm_MEM_0 + +.eh_framehdr : { + __eh_framehdr_start = .; + *(.eh_framehdr) + __eh_framehdr_end = .; +} > psu_r5_0_btcm_MEM_0 + +.gcc_except_table : { + *(.gcc_except_table) +} > psu_r5_0_btcm_MEM_0 + +.mmu_tbl (ALIGN(16384)) : { + __mmu_tbl_start = .; + *(.mmu_tbl) + __mmu_tbl_end = .; +} > psu_r5_0_btcm_MEM_0 + +.ARM.exidx : { + __exidx_start = .; + *(.ARM.exidx*) + *(.gnu.linkonce.armexidix.*.*) + __exidx_end = .; +} > psu_r5_0_btcm_MEM_0 + +.preinit_array : { + __preinit_array_start = .; + KEEP (*(SORT(.preinit_array.*))) + KEEP (*(.preinit_array)) + __preinit_array_end = .; +} > psu_r5_0_btcm_MEM_0 + +.init_array : { + __init_array_start = .; + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + __init_array_end = .; +} > psu_r5_0_btcm_MEM_0 + +.fini_array : { + __fini_array_start = .; + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array)) + __fini_array_end = .; +} > psu_r5_0_btcm_MEM_0 + +.ARM.attributes : { + __ARM.attributes_start = .; + *(.ARM.attributes) + __ARM.attributes_end = .; +} > psu_r5_0_btcm_MEM_0 + +.sdata : { + __sdata_start = .; + *(.sdata) + *(.sdata.*) + *(.gnu.linkonce.s.*) + __sdata_end = .; +} > psu_r5_0_btcm_MEM_0 + +.sbss (NOLOAD) : { + __sbss_start = .; + *(.sbss) + *(.sbss.*) + *(.gnu.linkonce.sb.*) + __sbss_end = .; +} > psu_r5_0_btcm_MEM_0 + +.tdata : { + __tdata_start = .; + *(.tdata) + *(.tdata.*) + *(.gnu.linkonce.td.*) + __tdata_end = .; +} > psu_r5_0_btcm_MEM_0 + +.tbss : { + __tbss_start = .; + *(.tbss) + *(.tbss.*) + *(.gnu.linkonce.tb.*) + __tbss_end = .; +} > psu_r5_0_btcm_MEM_0 + +.bss (NOLOAD) : { + . = ALIGN(4); + __bss_start__ = .; + *(.bss) + *(.bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; +} > @DDR@ + +_SDA_BASE_ = __sdata_start + ((__sbss_end - __sdata_start) / 2 ); + +_SDA2_BASE_ = __sdata2_start + ((__sbss2_end - __sdata2_start) / 2 ); + +/* Generate Stack and Heap definitions */ + + +.heap (NOLOAD) : { + . = ALIGN(16); + _heap = .; + HeapBase = .; + _heap_start = .; + . += _HEAP_SIZE; + _heap_end = .; + HeapLimit = .; +} > psu_r5_0_btcm_MEM_0 + +.stack (NOLOAD) : { + . = ALIGN(16); + _stack_end = .; + . += _STACK_SIZE; + _stack = .; + __stack = _stack; + . = ALIGN(16); + _irq_stack_end = .; + . += _IRQ_STACK_SIZE; + __irq_stack = .; + _supervisor_stack_end = .; + . += _SUPERVISOR_STACK_SIZE; + . = ALIGN(16); + __supervisor_stack = .; + _abort_stack_end = .; + . += _ABORT_STACK_SIZE; + . = ALIGN(16); + __abort_stack = .; + _fiq_stack_end = .; + . += _FIQ_STACK_SIZE; + . = ALIGN(16); + __fiq_stack = .; + _undef_stack_end = .; + . += _UNDEF_STACK_SIZE; + . = ALIGN(16); + __undef_stack = .; +} > psu_r5_0_btcm_MEM_0 + +.drvcfg_sec : { + . = ALIGN(8); + __drvcfgsecdata_start = .; + KEEP (*(.drvcfg_sec)) + __drvcfgsecdata_end = .; + __drvcfgsecdata_size = __drvcfgsecdata_end - __drvcfgsecdata_start; +} > psu_r5_0_btcm_MEM_0 + + +end = .; +} \ No newline at end of file diff --git a/examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_files/lscript_versal_net_r5.ld.in b/examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_files/lscript_versal_net_r5.ld.in new file mode 100644 index 0000000..ee3568b --- /dev/null +++ b/examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_files/lscript_versal_net_r5.ld.in @@ -0,0 +1,302 @@ +/****************************************************************************** +* Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved. +* SPDX-License-Identifier: MIT +******************************************************************************/ + +_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x2000; +_HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x2000; + +_ABORT_STACK_SIZE = DEFINED(_ABORT_STACK_SIZE) ? _ABORT_STACK_SIZE : 1024; +_SUPERVISOR_STACK_SIZE = DEFINED(_SUPERVISOR_STACK_SIZE) ? _SUPERVISOR_STACK_SIZE : 2048; +_IRQ_STACK_SIZE = DEFINED(_IRQ_STACK_SIZE) ? _IRQ_STACK_SIZE : 1024; +_FIQ_STACK_SIZE = DEFINED(_FIQ_STACK_SIZE) ? _FIQ_STACK_SIZE : 1024; +_UNDEF_STACK_SIZE = DEFINED(_UNDEF_STACK_SIZE) ? _UNDEF_STACK_SIZE : 1024; + +@MEMORY_SECTION@ + +ENTRY(_vector_table) + +/* Define the sections, and where they are mapped in memory */ + +SECTIONS +{ +.vectors : { + KEEP (*(.vectors)) + *(.boot) +} > psx_r52_tcm_alias + +.bootdata : { + _TCM_A_REGION = .; LONG(0x0) + _TCM_B_REGION = .; LONG(0x10001) + _TCM_C_REGION = .; LONG(0x18001) + *(.bootdata) +} > psx_r52_tcm_alias + +.resource_table @RSC_TABLE@ : { +. = ALIGN(4); +*(.resource_table) +} > @DDR@ + +.text : { + *(.text) + *(.text.*) + *(.gnu.linkonce.t.*) + *(.plt) + *(.gnu_warning) + *(.gcc_execpt_table) + *(.glue_7) + *(.glue_7t) + *(.vfp11_veneer) + *(.ARM.extab) + *(.gnu.linkonce.armextab.*) +} > @DDR@ + +.init : { + KEEP (*(.init)) +} > psx_r52_tcm_alias + +.fini : { + KEEP (*(.fini)) +} > psx_r52_tcm_alias + +.interp : { + KEEP (*(.interp)) +} > psx_r52_tcm_alias + +.note-ABI-tag : { + KEEP (*(.note-ABI-tag)) +} > psx_r52_tcm_alias + +.rodata : { + __rodata_start = .; + *(.rodata) + *(.rodata.*) + *(.gnu.linkonce.r.*) + __rodata_end = .; +} > psx_r52_tcm_alias + +.rodata1 : { + __rodata1_start = .; + *(.rodata1) + *(.rodata1.*) + __rodata1_end = .; +} > psx_r52_tcm_alias + +.sdata2 : { + __sdata2_start = .; + *(.sdata2) + *(.sdata2.*) + *(.gnu.linkonce.s2.*) + __sdata2_end = .; +} > psx_r52_tcm_alias + +.sbss2 : { + __sbss2_start = .; + *(.sbss2) + *(.sbss2.*) + *(.gnu.linkonce.sb2.*) + __sbss2_end = .; +} > psx_r52_tcm_alias + +.data : { + __data_start = .; + *(.data) + *(.data.*) + *(.gnu.linkonce.d.*) + *(.jcr) + *(.got) + *(.got.plt) + __data_end = .; +} > psx_r52_tcm_alias + +.data1 : { + __data1_start = .; + *(.data1) + *(.data1.*) + __data1_end = .; +} > psx_r52_tcm_alias + +.got : { + *(.got) +} > psx_r52_tcm_alias + +.ctors : { + __CTOR_LIST__ = .; + ___CTORS_LIST___ = .; + KEEP (*crtbegin.o(.ctors)) + KEEP (*(EXCLUDE_FILE(*crtend.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + __CTOR_END__ = .; + ___CTORS_END___ = .; +} > psx_r52_tcm_alias + +.dtors : { + __DTOR_LIST__ = .; + ___DTORS_LIST___ = .; + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE(*crtend.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + __DTOR_END__ = .; + ___DTORS_END___ = .; +} > psx_r52_tcm_alias + +.fixup : { + __fixup_start = .; + *(.fixup) + __fixup_end = .; +} > psx_r52_tcm_alias + +.eh_frame : { + *(.eh_frame) +} > psx_r52_tcm_alias + +.eh_framehdr : { + __eh_framehdr_start = .; + *(.eh_framehdr) + __eh_framehdr_end = .; +} > psx_r52_tcm_alias + +.gcc_except_table : { + *(.gcc_except_table) +} > psx_r52_tcm_alias + +.mmu_tbl (ALIGN(16384)) : { + __mmu_tbl_start = .; + *(.mmu_tbl) + __mmu_tbl_end = .; +} > psx_r52_tcm_alias + +.ARM.exidx : { + __exidx_start = .; + *(.ARM.exidx*) + *(.gnu.linkonce.armexidix.*.*) + __exidx_end = .; +} > psx_r52_tcm_alias + +.preinit_array : { + __preinit_array_start = .; + KEEP (*(SORT(.preinit_array.*))) + KEEP (*(.preinit_array)) + __preinit_array_end = .; +} > psx_r52_tcm_alias + +.init_array : { + __init_array_start = .; + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + __init_array_end = .; +} > psx_r52_tcm_alias + +.fini_array : { + __fini_array_start = .; + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array)) + __fini_array_end = .; +} > psx_r52_tcm_alias + +.ARM.attributes : { + __ARM.attributes_start = .; + *(.ARM.attributes) + __ARM.attributes_end = .; +} > psx_r52_tcm_alias + +.sdata : { + __sdata_start = .; + *(.sdata) + *(.sdata.*) + *(.gnu.linkonce.s.*) + __sdata_end = .; +} > psx_r52_tcm_alias + +.sbss (NOLOAD) : { + __sbss_start = .; + *(.sbss) + *(.sbss.*) + *(.gnu.linkonce.sb.*) + __sbss_end = .; +} > psx_r52_tcm_alias + +.tdata : { + __tdata_start = .; + *(.tdata) + *(.tdata.*) + *(.gnu.linkonce.td.*) + __tdata_end = .; +} > psx_r52_tcm_alias + +.tbss : { + __tbss_start = .; + *(.tbss) + *(.tbss.*) + *(.gnu.linkonce.tb.*) + __tbss_end = .; +} > psx_r52_tcm_alias + +.bss (NOLOAD) : { + . = ALIGN(4); + __bss_start__ = .; + *(.bss) + *(.bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; +} > @DDR@ + +_SDA_BASE_ = __sdata_start + ((__sbss_end - __sdata_start) / 2 ); + +_SDA2_BASE_ = __sdata2_start + ((__sbss2_end - __sdata2_start) / 2 ); + +/* Generate Stack and Heap definitions */ + + +.heap (NOLOAD) : { + . = ALIGN(16); + _heap = .; + HeapBase = .; + _heap_start = .; + . += _HEAP_SIZE; + _heap_end = .; + HeapLimit = .; +} > psx_r52_tcm_alias + +.stack (NOLOAD) : { + . = ALIGN(16); + _stack_end = .; + . += _STACK_SIZE; + _stack = .; + __stack = _stack; + . = ALIGN(16); + _irq_stack_end = .; + . += _IRQ_STACK_SIZE; + __irq_stack = .; + _supervisor_stack_end = .; + . += _SUPERVISOR_STACK_SIZE; + . = ALIGN(16); + __supervisor_stack = .; + _abort_stack_end = .; + . += _ABORT_STACK_SIZE; + . = ALIGN(16); + __abort_stack = .; + _fiq_stack_end = .; + . += _FIQ_STACK_SIZE; + . = ALIGN(16); + __fiq_stack = .; + _undef_stack_end = .; + . += _UNDEF_STACK_SIZE; + . = ALIGN(16); + __undef_stack = .; +} > psx_r52_tcm_alias + +.drvcfg_sec : { + . = ALIGN(8); + __drvcfgsecdata_start = .; + KEEP (*(.drvcfg_sec)) + __drvcfgsecdata_end = .; + __drvcfgsecdata_size = __drvcfgsecdata_end - __drvcfgsecdata_start; +} > psx_r52_tcm_alias + +end = .; +} \ No newline at end of file diff --git a/examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_files/lscript_versal_r5.ld.in b/examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_files/lscript_versal_r5.ld.in new file mode 100644 index 0000000..a4a07b4 --- /dev/null +++ b/examples/legacy_apps/system/generic/machine/zynqmp_r5/linker_files/lscript_versal_r5.ld.in @@ -0,0 +1,295 @@ +/****************************************************************************** +* Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved. +* SPDX-License-Identifier: MIT +******************************************************************************/ + +_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : @STACK_SIZE@; +_HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : @HEAP_SIZE@; + +_ABORT_STACK_SIZE = DEFINED(_ABORT_STACK_SIZE) ? _ABORT_STACK_SIZE : 1024; +_SUPERVISOR_STACK_SIZE = DEFINED(_SUPERVISOR_STACK_SIZE) ? _SUPERVISOR_STACK_SIZE : 2048; +_IRQ_STACK_SIZE = DEFINED(_IRQ_STACK_SIZE) ? _IRQ_STACK_SIZE : 1024; +_FIQ_STACK_SIZE = DEFINED(_FIQ_STACK_SIZE) ? _FIQ_STACK_SIZE : 1024; +_UNDEF_STACK_SIZE = DEFINED(_UNDEF_STACK_SIZE) ? _UNDEF_STACK_SIZE : 1024; + +@MEMORY_SECTION@ + +ENTRY(_vector_table) + +/* Define the sections, and where they are mapped in memory */ + +SECTIONS +{ +.vectors : { + KEEP (*(.vectors)) + *(.boot) +} > psv_r5_0_atcm_MEM_0 + +.resource_table @RSC_TABLE@ : { +. = ALIGN(4); +*(.resource_table) +} > @DDR@ + +.text @RSC_TABLE@ + 0x100 : { + *(.text) + *(.text.*) + *(.gnu.linkonce.t.*) + *(.plt) + *(.gnu_warning) + *(.gcc_execpt_table) + *(.glue_7) + *(.glue_7t) + *(.vfp11_veneer) + *(.ARM.extab) + *(.gnu.linkonce.armextab.*) +} > @DDR@ + +.init : { + KEEP (*(.init)) +} > psv_r5_0_btcm_MEM_0 + +.fini : { + KEEP (*(.fini)) +} > psv_r5_0_btcm_MEM_0 + +.interp : { + KEEP (*(.interp)) +} > psv_r5_0_btcm_MEM_0 +.note-ABI-tag : { + KEEP (*(.note-ABI-tag)) +} > psv_r5_0_btcm_MEM_0 + +.rodata : { + __rodata_start = .; + *(.rodata) + *(.rodata.*) + *(.gnu.linkonce.r.*) + __rodata_end = .; +} > psv_r5_0_btcm_MEM_0 + +.rodata1 : { + __rodata1_start = .; + *(.rodata1) + *(.rodata1.*) + __rodata1_end = .; +} > psv_r5_0_btcm_MEM_0 + +.sdata2 : { + __sdata2_start = .; + *(.sdata2) + *(.sdata2.*) + *(.gnu.linkonce.s2.*) + __sdata2_end = .; +} > psv_r5_0_btcm_MEM_0 + +.sbss2 : { + __sbss2_start = .; + *(.sbss2) + *(.sbss2.*) + *(.gnu.linkonce.sb2.*) + __sbss2_end = .; +} > psv_r5_0_btcm_MEM_0 + +.data : { + __data_start = .; + *(.data) + *(.data.*) + *(.gnu.linkonce.d.*) + *(.jcr) + *(.got) + *(.got.plt) + __data_end = .; +} > psv_r5_0_btcm_MEM_0 + +.data1 : { + __data1_start = .; + *(.data1) + *(.data1.*) + __data1_end = .; +} > psv_r5_0_btcm_MEM_0 + +.got : { + *(.got) +} > psv_r5_0_btcm_MEM_0 + +.ctors : { + __CTOR_LIST__ = .; + ___CTORS_LIST___ = .; + KEEP (*crtbegin.o(.ctors)) + KEEP (*(EXCLUDE_FILE(*crtend.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + __CTOR_END__ = .; + ___CTORS_END___ = .; +} > psv_r5_0_btcm_MEM_0 + +.dtors : { + __DTOR_LIST__ = .; + ___DTORS_LIST___ = .; + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE(*crtend.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + __DTOR_END__ = .; + ___DTORS_END___ = .; +} > psv_r5_0_btcm_MEM_0 + +.fixup : { + __fixup_start = .; + *(.fixup) + __fixup_end = .; +} > psv_r5_0_btcm_MEM_0 + +.eh_frame : { + *(.eh_frame) +} > psv_r5_0_btcm_MEM_0 + +.eh_framehdr : { + __eh_framehdr_start = .; + *(.eh_framehdr) + __eh_framehdr_end = .; +} > psv_r5_0_btcm_MEM_0 + +.gcc_except_table : { + *(.gcc_except_table) +} > psv_r5_0_btcm_MEM_0 + +.mmu_tbl (ALIGN(16384)) : { + __mmu_tbl_start = .; + *(.mmu_tbl) + __mmu_tbl_end = .; +} > psv_r5_0_btcm_MEM_0 + +.ARM.exidx : { + __exidx_start = .; + *(.ARM.exidx*) + *(.gnu.linkonce.armexidix.*.*) + __exidx_end = .; +} > psv_r5_0_btcm_MEM_0 + +.preinit_array : { + __preinit_array_start = .; + KEEP (*(SORT(.preinit_array.*))) + KEEP (*(.preinit_array)) + __preinit_array_end = .; +} > psv_r5_0_btcm_MEM_0 + +.init_array : { + __init_array_start = .; + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + __init_array_end = .; +} > psv_r5_0_btcm_MEM_0 + +.fini_array : { + __fini_array_start = .; + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array)) + __fini_array_end = .; +} > psv_r5_0_btcm_MEM_0 + +.ARM.attributes : { + __ARM.attributes_start = .; + *(.ARM.attributes) + __ARM.attributes_end = .; +} > psv_r5_0_btcm_MEM_0 + +.sdata : { + __sdata_start = .; + *(.sdata) + *(.sdata.*) + *(.gnu.linkonce.s.*) + __sdata_end = .; +} > psv_r5_0_btcm_MEM_0 + +.sbss (NOLOAD) : { + __sbss_start = .; + *(.sbss) + *(.sbss.*) + *(.gnu.linkonce.sb.*) + __sbss_end = .; +} > psv_r5_0_btcm_MEM_0 + +.tdata : { + __tdata_start = .; + *(.tdata) + *(.tdata.*) + *(.gnu.linkonce.td.*) + __tdata_end = .; +} > psv_r5_0_btcm_MEM_0 + +.tbss : { + __tbss_start = .; + *(.tbss) + *(.tbss.*) + *(.gnu.linkonce.tb.*) + __tbss_end = .; +} > psv_r5_0_btcm_MEM_0 + +.bss (NOLOAD) : { + . = ALIGN(4); + __bss_start__ = .; + *(.bss) + *(.bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; +} > @DDR@ + +_SDA_BASE_ = __sdata_start + ((__sbss_end - __sdata_start) / 2 ); + +_SDA2_BASE_ = __sdata2_start + ((__sbss2_end - __sdata2_start) / 2 ); + +/* Generate Stack and Heap definitions */ + + +.heap (NOLOAD) : { + . = ALIGN(16); + _heap = .; + HeapBase = .; + _heap_start = .; + . += _HEAP_SIZE; + _heap_end = .; + HeapLimit = .; +} > psv_r5_0_btcm_MEM_0 + +.stack (NOLOAD) : { + . = ALIGN(16); + _stack_end = .; + . += _STACK_SIZE; + _stack = .; + __stack = _stack; + . = ALIGN(16); + _irq_stack_end = .; + . += _IRQ_STACK_SIZE; + __irq_stack = .; + _supervisor_stack_end = .; + . += _SUPERVISOR_STACK_SIZE; + . = ALIGN(16); + __supervisor_stack = .; + _abort_stack_end = .; + . += _ABORT_STACK_SIZE; + . = ALIGN(16); + __abort_stack = .; + _fiq_stack_end = .; + . += _FIQ_STACK_SIZE; + . = ALIGN(16); + __fiq_stack = .; + _undef_stack_end = .; + . += _UNDEF_STACK_SIZE; + . = ALIGN(16); + __undef_stack = .; +} > psv_r5_0_btcm_MEM_0 + +.drvcfg_sec : { + . = ALIGN(8); + __drvcfgsecdata_start = .; + KEEP (*(.drvcfg_sec)) + __drvcfgsecdata_end = .; + __drvcfgsecdata_size = __drvcfgsecdata_end - __drvcfgsecdata_start; +} > psv_r5_0_btcm_MEM_0 + + +end = .; +} \ No newline at end of file From 5227f8a2baeb2f4253385409ae2454bc89e2b2a4 Mon Sep 17 00:00:00 2001 From: Ben Levinsky Date: Tue, 14 Jan 2025 21:31:31 +0000 Subject: [PATCH 5/5] apps: remote: Change output to use metal_* routines Signed-off-by: Ben Levinsky --- examples/legacy_apps/examples/echo/rpmsg-echo.c | 10 +++++----- .../examples/matrix_multiply/matrix_multiplyd.c | 5 ++--- examples/legacy_apps/examples/rpc_demo/rpc_demo.c | 5 ++--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/examples/legacy_apps/examples/echo/rpmsg-echo.c b/examples/legacy_apps/examples/echo/rpmsg-echo.c index 4328f24..9bb43dd 100644 --- a/examples/legacy_apps/examples/echo/rpmsg-echo.c +++ b/examples/legacy_apps/examples/echo/rpmsg-echo.c @@ -18,8 +18,8 @@ #define SHUTDOWN_MSG 0xEF56A55A -#define LPRINTF(format, ...) printf(format, ##__VA_ARGS__) -#define LPERROR(format, ...) LPRINTF("ERROR: " format, ##__VA_ARGS__) +#define LPRINTF(format, ...) metal_info("INFO: " format, ##__VA_ARGS__) +#define LPERROR(format, ...) metal_err("ERROR: " format, ##__VA_ARGS__) static struct rpmsg_endpoint lept; static int shutdown_req = 0; @@ -106,7 +106,7 @@ int main(int argc, char *argv[]) ret = platform_init(argc, argv, &platform); if (ret) { LPERROR("Failed to initialize platform.\r\n"); - ML_ERR("Server reboot is required to recover\r\n"); + LPERROR("Server reboot is required to recover\r\n"); platform_cleanup(platform); /* * If main function is returned in baremetal firmware, @@ -125,8 +125,8 @@ int main(int argc, char *argv[]) VIRTIO_DEV_DEVICE, NULL, NULL); if (!rpdev) { - ML_ERR("Failed to create rpmsg virtio device.\r\n"); - ML_ERR("Server reboot is required to recover\r\n"); + LPERROR("Failed to create rpmsg virtio device.\r\n"); + LPERROR("Server reboot is required to recover\r\n"); platform_cleanup(platform); /* diff --git a/examples/legacy_apps/examples/matrix_multiply/matrix_multiplyd.c b/examples/legacy_apps/examples/matrix_multiply/matrix_multiplyd.c index 3045a11..f7c0403 100644 --- a/examples/legacy_apps/examples/matrix_multiply/matrix_multiplyd.c +++ b/examples/legacy_apps/examples/matrix_multiply/matrix_multiplyd.c @@ -21,9 +21,8 @@ #define SHUTDOWN_MSG 0xEF56A55A -#define LPRINTF(format, ...) printf(format, ##__VA_ARGS__) -//#define LPRINTF(format, ...) -#define LPERROR(format, ...) LPRINTF("ERROR: " format, ##__VA_ARGS__) +#define LPRINTF(format, ...) metal_info("INFO: " format, ##__VA_ARGS__) +#define LPERROR(format, ...) metal_err("ERROR: " format, ##__VA_ARGS__) typedef struct _matrix { unsigned int size; diff --git a/examples/legacy_apps/examples/rpc_demo/rpc_demo.c b/examples/legacy_apps/examples/rpc_demo/rpc_demo.c index 8afcf73..6eca7db 100644 --- a/examples/legacy_apps/examples/rpc_demo/rpc_demo.c +++ b/examples/legacy_apps/examples/rpc_demo/rpc_demo.c @@ -28,9 +28,8 @@ #define REDEF_O_APPEND 0002000 #define REDEF_O_ACCMODE 0000003 -#define LPRINTF(format, ...) xil_printf(format, ##__VA_ARGS__) -//#define LPRINTF(format, ...) -#define LPERROR(format, ...) LPRINTF("ERROR: " format, ##__VA_ARGS__) +#define LPRINTF(format, ...) metal_info("INFO: " format, ##__VA_ARGS__) +#define LPERROR(format, ...) metal_err("ERROR: " format, ##__VA_ARGS__) static void rpmsg_rpc_shutdown(struct rpmsg_rpc_data *rpc) {