OpenAMP Snippet. march 2025 *** Version 2024.1 *** Notes: - This version creates petalinux in $TRAINING_PATH/OpenAMP/ZCU104 instead of $TRAINING_PATH/OpenAMP/lab/ZCU104 - support folder includes: - SD_content.7z, - Petalinux results (images folder), - vitis classic projects (vits.export_all.ide.zip), - C code for A53 and R5 examples. 0. Copy Zip file and uncompress in $TRAINING_PATH ------------------------------------------------- *** 1-2. Run a provided Python script. Open a terminal. cd $TRAINING_PATH/OpenAMP/support vitis -s OpenAMP_builder.py electra 1-3. Open Vitis and Set the workspace. $TRAINING_PATH/OpenAMP/lab or alternatively vitis -w $TRAINING_PATH/OpenAMP/lab Optional: Create another example from template, step by step. Create a new application project. (File new application project) Select the OpenAMP_plat platform and name as “app_matmul” Select “OpenAMP_dom” Select OpenAMP matrix multiplication Demo Optional+: Repeat for RPC Demo 1-7. Close the Vitis IDE. ------------------------------------------------- *** 2-2. Set up the PetaLinux environment. export PETALINUX_PATH=/opt/amd/PetaLinux/2024.1/tool source $PETALINUX_PATH/settings.sh optionlly: source /opt/amd/PetaLinux/2024.1/tool/settings.sh 2-3. Use the petalinux-create command to create a new embedded Linux platform. cd $TRAINING_PATH/OpenAMP/ petalinux-create -t project --name ZCU104 --template zynqMP 2-4. Import the hardware configuration. cd ZCU104 (full directory $TRAINING_PATH/OpenAMP/lab/ZCU104) 2-4-2. Use the petalinux-config command to import the hardware configuration: -*NO*- petalinux-config --get-hw-description=$TRAINING_PATH/CustEdIP/UED_zcu104.xsa --silentconfig or petalinux-config --get-hw-description=$TRAINING_PATH/data_mov/generated_files/ --silentconfig or petalinux-config --get-hw-description=$TRAINING_PATH/OpenAMP/support/ --silentconfig ------------------------------------------------- -- Optional 2.3 (use BSP instead of XSA) -- Not for this lab Download BSP from XLX petalinux-create -t project --name ZCU104 -s ref_to_BSP -------------------------------------------- *** Including the RPU Firmware Step 3 3-1-1. create an install-only user application for remote firmware: petalinux-create -t apps -n openamp-slave-r5-app --template install --enable 3-2. Copy the bare-metal firmware (openamp-slave-r5-app.elf) cp $TRAINING_PATH/OpenAMP/lab/openamp_slave_r5_app/build/openamp_slave_r5_app.elf $TRAINING_PATH/OpenAMP/ZCU104/project-spec/meta-user/recipes-apps/openamp-slave-r5-app/files/openamp-slave-r5-app 3-2-2. Overwrite the openamp-slave-r5-app.bb file: source $TRAINING_PATH/OpenAMP/support/modifyAppRecipe.sh 3-2-3. Enter the following command to view the modified openamp-slave-r5-app.bb file: gedit $TRAINING_PATH/OpenAMP/ZCU104/project-spec/meta-user/recipes-apps/openamp-slave-r5-app/openamp-slave-r5-app.bb -------------------------------------------- *** Configuring the System for OpenAMP Step 4 cd $TRAINING_PATH/OpenAMP/ZCU104 4-1-2. Launch the top-level system settings petalinux-config - Yocto Settings -> YOCTO_MACHINE_NAME -> to zcu104. optional. in "Image Packaging Configuration" change the tftpboot directory field. or sudo chown amd:amd /tftpboot 4-2-1. Open the rootfs configuration menu: petalinux-config -c rootfs - user Packages -> openamp-slave-r5-app 4-3. Enable the OpenAMP Linux applications and rpmsg modules. - Patalinux Package Groups -> packagegroup-petalinux-openamp -> select: packagegroup-petalinux-openamp. 4-4. Enable the inclusion of the default remote processor firmware images and rpmsg modules. - Filesystem Packages > misc > openamp-fw-echo-testd. - openamp-fw-mat-muld > openamp-fw-mat-muld - openamp-fw-rpc-demo > openamp-fw-rpc-demo - rpmsg-echo-test > rpmsg-echo-test - rpmsg-mat-mul > rpmsg-mat-mul - rpmsg-proxy-app > rpmsg-proxy-app 4-5. Enable the openamp and libmetal libraries: - Filesystem Packages -> libs -> open-amp -> open-amp. - enable open-amp-demos. 4-5-4. Similarly, enable "Filesystem Packages -> libs -> libmetal > libmetal" 4-7. Configure the kernel parameters. petalinux-config -c kernel (takes 5-10 min) 4-7-2.Verify: "loadable module support" is enabled 4-7-3. Verify "remoteproc support" is enabled - Device Drivers -> Remoteproc by 4-8-1. Copy the sample DTSI file into the working directory: cp $TRAINING_PATH/OpenAMP/support/openamp.dtsi $TRAINING_PATH/OpenAMP/ZCU104/project-spec/meta-user/recipes-bsp/device-tree/files Optional_R5_1. Add support for R1_1 cp $TRAINING_PATH/OpenAMP/support/system-user_rpu1.dtsi $TRAINING_PATH/OpenAMP/ZCU104/project-spec/meta-user/recipes-bsp/device-tree/files 4-8-2. Open the system-user.dtsi file: gedit project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi 4-8-3. Add: /include/ "openamp.dtsi" Optional_R5_1. Add support for R5_1 /include/ "system-user_rpu1.dtsi" In petalinux 2024.1 add to system-user.dtsi: / { fclk0:fclk0 { status = "okay"; compatible = "xlnx,fclk"; clocks = <0x04 0x47>; phandle = <0xa5>; }; fclk1 { status = "okay"; compatible = "xlnx,fclk"; clocks = <0x04 0x48>; phandle = <0xa6>; }; fclk2 { status = "okay"; compatible = "xlnx,fclk"; clocks = <0x04 0x49>; phandle = <0xa7>; }; fclk3 { status = "okay"; compatible = "xlnx,fclk"; clocks = <0x04 0x4a>; phandle = <0xa8>; }; }; 4-9. Review the openamp.dtsi gedit project-spec/meta-user/recipes-bsp/device-tree/files/openamp.dtsi 4-10. Add the openamp.dtsi file to the source recipe. gedit project-spec/meta-user/recipes-bsp/device-tree/device-tree.bbappend 4-10-2. Add: SRC_URI:append = " file://openamp.dtsi" Optional_R5_1. if system-user_rpu1.dtsi, add it to device-tree.bbappend SRC_URI:append = " file://system-user_rpu1.dtsi" ---------------------------------------------------------- - Optional (recomended): petalinux-conf -c rootfs image-features -> serial-autologin-root add user electra:electra Petalinux RootFS settings -> Add Extra user add electra to sudoers petalinux-conf - fix IP. subsystem AUTO HW settings - for network support: DTG settings ->(template) Machine Name, change to zcu104-revc Petalinux-build ******************************************* To boot from SD: - Package *Create a boot image (BOOT.BIN) that includes the FSBL, ATF, bitstream, and U-Boot. cd $TRAINING_PATH/OpenAMP/ZCU104/images/linux petalinux-package --boot --fsbl zynqmp_fsbl.elf --u-boot u-boot.elf --pmufw pmufw.elf --fpga system.bit --force Copy to SD: - boot.src - BOOT.bin - image.ub Optional. Include the Prebuilt Image to boot with QEMU 5-2-3. source $TRAINING_PATH/OpenAMP/support/SetupImages.sh ******************************************* 6-1. Boot the project in QEMU. copy image/linux cd $TRAINING_PATH/OpenAMP/ZCU104 petalinux-boot --qemu --kernel petalinux-boot --qemu --prebuilt 3 ---------------------------------------- -- Play with the system lsmod echo image_echo_test > /sys/class/remoteproc/remoteproc0/firmware echo start > /sys/class/remoteproc/remoteproc0/state echo_test echo stop > /sys/class/remoteproc/remoteproc0/state echo image_matrix_multiply > /sys/class/remoteproc/remoteproc0/firmware echo start > /sys/class/remoteproc/remoteproc0/state mat_mul_demo echo stop > /sys/class/remoteproc/remoteproc0/state echo image_rpc_demo > /sys/class/remoteproc/remoteproc0/firmware echo start > /sys/class/remoteproc/remoteproc0/state proxy_app echo stop > /sys/class/remoteproc/remoteproc0/state review the writen file: cat remote.file ls /lib/firmware (dir de apps R5) ls /usr/bin (dir Apps A53) ls /run/media/boot-mmcblk0p1 (SD mount point) TCF agent port: 1534 cp *.elf /lib/firmware echo blinkleds.elf > /sys/class/remoteproc/remoteproc0/firmware echo btn_sw_read_R5_1.elf > /sys/class/remoteproc/remoteproc1/firmware echo mm_AXI_slv_R5_1.elf > /sys/class/remoteproc/remoteproc1/firmware echo app_r5_echo.elf > /sys/class/remoteproc/remoteproc0/firmware echo app_r5_matmul.elf > /sys/class/remoteproc/remoteproc0/firmware echo app_r5_rpc_demo.elf > /sys/class/remoteproc/remoteproc0/firmware ls /sys/bus/rpmsg/devices/ ----------------------- -- Additional notes: ----------------------- -- Add openMP "peta_proj"/build/conf/local.conf add the following line IMAGE_INSTALL:append = " libgomp libgomp-dev libgomp-staticdev" Edit and add: $PROOT/project-spec/meta-user/conf/user-rootfsconfig CONFIG_libgomp CONFIG_libgomp-dev CONFIG_libgomp-staticdev This creates tickboxes in the User Packages area, accessible with petalinux-config -c rootfs ----------------------------------------