Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Updated the user guide link to point to 2019.2 instead of 2019.1

...

This page is intended to complement  UG1186 "LibMetal and OpenAMP User Guide"  for Zynq-7000 and Zynq UltraScale+ MPSoC.


Quick try!

Here are the basic steps to boot Linux and run an openamp application using pre-built images.

e.g for ZCU102:
The echo-test application sends packets from Linux running on quad-core Cortex-A53 to a single cortex-R5 running FreeRTOS which send them back.
  • Extract files BOOT.BIN, image.ub and openamp.dtb files from a pre-built PetaLinux BSP to sdcard

  • Code Block
    themeMidnight
    host shell$ petalinux-create -s xilinx-zcu102-v2019.2-final.bsp --strip-components=4 --wildcards */BOOT.BIN */image.ub */openamp.dtb
    host shell$ cp BOOT.BIN image.ub openamp.dtb <your sd card>


Note: Alternatively, if you already created a PetaLinux project with a provided BSP for your board, pre-built images can also be found under the <your project>/pre-built/linux/images/ directory.
  • Go to u-boot prompt and boot Linux from sdcard

  • Code Block
    themeMidnight
    ...
    Hit any key to stop autoboot:  0 
    
    > mmcinfo && fatload mmc 0 ${netstart} ${kernel_img} &&  fatload mmc 0 0x14000000 openamp.dtb
    Device: sdhci@ff170000
    ...
    reading image.ub
    31514140 bytes read in 2063 ms (14.6 MiB/s)
    reading openamp.dtb
    38320 bytes read in 18 ms (2 MiB/s)
    > bootm $netstart $netstart 0x14000000
    ...


Note: As an alternative to all steps above to sd-boot, you can jtag-boot the board. For this you need to have connected a jtag cable, installed jtag drivers and created a PetaLinux project using a provided BSP. You would then go into the <your project>/pre-built/linux/images directory and replace file system.dtb by openamp.dtb, then enter: "petalinux-boot --jtag --prebuilt 3"
  • At Linux login prompt enter 'root' for user and 'root' for password and run echo-test demo

  • Code Block
    themeMidnight
    plnx_aarch64 login: root
    Password: 
    root@plnx_aarch64:~# echo image_echo_test > /sys/class/remoteproc/remoteproc0/firmware 
    root@plnx_aarch64:~# echo start > /sys/class/remoteproc/remoteproc0/state   
    [  177.375451] remoteproc remoteproc0: powering up ff9a0100.zynqmp_r5_rproc
    [  177.384705] remoteproc remoteproc0: Booting fw image image_echo_test, size 644144
    [  177.396832] remoteproc remoteproc0: registered virtio0 (type 7)
    [  177.399108] virtio_rpmsg_bus virtio0: rpmsg host is online
    [  177.412370] zynqmp_r5_remoteproc ff9a0100.zynqmp_r5_rproc: RPU boot from TCM.
    [  17Starting application...
    Try to init remoteproc resource
    Init remoteproc resource succeeded
    Waiting for events...
    7.422089] remoteproc remoteproc0: remote processor ff9a0100.zynqmp_r5_rproc is now up
    [  177.442121] virtio_rpmsg_bus virtio0: creating channel rpmsg-openamp-demo-channel addr 0x1
    root@plnx_aarch64:~# modprobe rpmsg_user_dev_driver
    [  188.089835] rpmsg_user_dev_driver virtio0:rpmsg-openamp-demo-channel: rpmsg_user_dev_rpmsg_drv_probe
    [  188.101250] rpmsg_user_dev_driver virtio0:rpmsg-openamp-demo-channel: new channel: 0x400 -> 0x1!
    root@plnx_aarch64:~# echo_test
     Echo test start 
     Open rpmsg dev! 
    [  190.364739] rpmsg_user_dev_driver virtio0:rpmsg-openamp-demo-channel: Sent init_msg to target 0x1.


Docs and source code

Documents

  • The following document describes libmetal APIs:
    View file
    namelibmetal-doc-20170418.pdf

URLs to source code


Xilinx Openamp and Libmetal related code

The following location provide access to the code:

Additional examples

OpenAMP Demos using RPMsg in kernel-space on Versal

  1. Configure PetaLinux to run the demo
    1. Download 2019.2 Versal BSP
    2. petalinux-config -c rootfs
      1. enable the following:
        • libmetal
        • open-amp
        • rpmsg-(demo name)
        • sysfsutils
        • libsysfs
        • openamp-echo-testd
    3. modify system-user.dtsi with the following

      1. Code Block
        /include/ "system-conf.dtsi"
        / {
        reserved-memory {
                #address-cells = <2>;
                #size-cells = <2>;
                ranges;
                rproc_0_dma: rproc@3ed40000 {
                    no-map;
                    compatible = "shared-dma-pool";
                    reg = <0x0 0x3ed40000 0x0 0x100000>;
                };
                rproc_0_reserved: rproc@3ed00000 {
                    no-map;
                    reg = <0x0 0x3ed00000 0x0 0x40000>;
                };
                rproc_1_dma: rproc@3ef40000 {
                    no-map;
                    compatible = "shared-dma-pool";
                    reg = <0x0 0x3ef40000 0x0 0x100000>;
                };
                rproc_1_reserved: rproc@3ef00000 {
                    no-map;
                    reg = <0x0 0x3ef00000 0x0 0x40000>;
                };
            };
         
            zynqmp-rpu {
                compatible = "xlnx,zynqmp-r5-remoteproc-1.0";
                core_conf = "split";
                #address-cells = <2>;
                #size-cells = <2>;
                ranges;
                r5_0: r5@0 {
                    #address-cells = <2>;
                    #size-cells = <2>;
                    ranges;
                    memory-region = <&rproc_0_reserved>, <&rproc_0_dma>;
                    pnode-id = <0x18110005>;
                    mboxes = <&ipi_mailbox_rpu0 0>, <&ipi_mailbox_rpu0 1>;
                    mbox-names = "tx", "rx";
                    tcm_0_a: tcm_0@0 {
                        reg = <0x0 0xFFE00000 0x0 0x10000>;
                        pnode-id = <0x1831800b>;
                    };
                    tcm_0_b: tcm_0@1 {
                        reg = <0x0 0xFFE20000 0x0 0x10000>;
                        pnode-id = <0x1831800c>;
                    };
                };
         
                r5_1: r5@1 {
                    #address-cells = <2>;
                    #size-cells = <2>;
                    ranges;
                    memory-region = <&rproc_1_reserved>, <&rproc_1_dma>;
                    pnode-id = <0x18110006>;
                    mboxes = <&ipi_mailbox_rpu1 0>, <&ipi_mailbox_rpu1 1>;
                    mbox-names = "tx", "rx";
                    tcm_1_a: tcm_1@0 {
                        reg = <0x0 0xFFE90000 0x0 0x10000>;
                        pnode-id = <0x603060d>;
                    };
                    tcm_1_b: tcm_1@1 {
                        reg = <0x0 0xFFEB0000 0x0 0x10000>;
                        pnode-id = <0x603060e>;
                    };
                };
            };
         
         
         zynqmp_ipi1 {
                compatible = "xlnx,zynqmp-ipi-mailbox";
                interrupt-parent = <&gic>;
                interrupts = <0 33 4>;
                xlnx,ipi-id = <5>;
                #address-cells = <1>;
                #size-cells = <1>;
                ranges;
         
                /* APU<->RPU0 IPI mailbox controller */
                ipi_mailbox_rpu0: mailbox@ff990600 {
                    reg = <0xff3f0ac0 0x20>,
                          <0xff3f0ae0 0x20>,
                          <0xff3f0740 0x20>,
                          <0xff3f0760 0x20>;
                    reg-names = "local_request_region",
                            "local_response_region",
                            "remote_request_region",
                            "remote_response_region";
                    #mbox-cells = <1>;
                    xlnx,ipi-id = <3>;
                };
                /* APU<->RPU1 IPI mailbox controller */
        
        		ipi_mailbox_rpu1: mailbox@ff990640 {
        			reg = <0xff3f0b00 0x20>,
        			      <0xff3f0b20 0x20>,
        			      <0xff3f0940 0x20>,
        			      <0xff3f0960 0x20>;
                   xlnx,ipi-id = <2>;
               }
        
                    reg-names = "local_request_region",
                            "local_response_region",
                            "remote_request_region",
                            "remote_response_region";
                    #mbox-cells = <1>;
                    xlnx,ipi-id = <4>;
                };
            };
        };
        


    4. build project with "petalinux-build"
    1. Running the Demo on Target
      1. After starting firmware on target the output from running Linux-side the output is as follows:

        Code Block
        $ echo_test -d <rpmsg channel name>
         Echo test start
         Open rpmsg dev /dev/rpmsg0!
         **************************************


Libmetal Demo on Versal

  1. R5 Baremetal Application
    1. source code can be found here
  2. Configure PetaLinux to run the demo
    1. Download 2019.2 Versal BSP
    2. petalinux-config -c rootfs
      1. enable the following:
        • libmetal
        • libmetal-demo
    3. install the libmetal R5 application into the PetaLinux -generated rootfs on target with the following:
      1. create PetaLinux app to install the firmware
        1. petalinux-create -t apps --template install --name libmetal-fw --enable
        2. modify recipe as follows:
          1. copy firmware into project-spec/meta-user/recipes-apps/libmetal-fw/files/libmetal-fw 
          2. modify libmetal-fw.bb as follows

            1. Code Block
              #
              # This file is the libmetal-fw recipe.
              #
               
              SUMMARY = "Simple libmetal-fw application"
              SECTION = "PETALINUX/apps"
              LICENSE = "MIT"
              LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
               
              SRC_URI = "file://libmetal-fw \
                  "  
              INSANE_SKIP_${PN} = "arch"
              S = "${WORKDIR}"
               
              do_install() {
                       install -d ${D}/lib/firmware/
                       install -m 644 ${S}/libmetal-fw ${D}/lib/firmware/
              }
              FILES_${PN} = " /lib/firmware/libmetal-fw "


    4. modify system-user.dtsi with the following

      1. Code Block
        / {
        
        	reserved-memory {
        		#address-cells = <2>;
        		#size-cells = <2>;
        		ranges;
        		rproc_0_reserved: rproc@3ed00000 {
        			no-map;
        			reg = <0x0 0x3ed00000 0x0 0x2000000>;
        		};
        	};
        	amba {
        		/* Shared memory (APU to RPU) */
        		shm0: shm@0 {
        			compatible = "shm";
        			reg = <0x0 0x3ed80000 0x0 0x01000000>;
        
        
        		};
        		/* IPI device */
        		ipi0: ipi@0 {
        			compatible = "ipi_uio";
        			reg = <0x0 0xff360000 0x0 0x1000>;
        			interrupt-parent = <&gic>;
        			interrupts = <0 33 4>;
        		};
        
        		timer@ff0e0000 {
                                compatible = "ttc-uio";
                                reg = <0x0 0xff0e0000 0x0 0x1000>;
                        };
        	};
        };
        
        &sdhci0 {
        	status = "disabled";
        };
        
        &sdhci1 {
        	status = "disabled";
        };
        
        


    5. build project with "petalinux-build"
  3. Running the Demo on Target
    1. After starting firmware on target the output from running Linux-side the output is as follows:

      1. Code Block
        # <linux libmetal application
        metal: warning: skipped page size 2097152 - invalid args
        CLIENT> ****** libmetal demo: shared memory ******
        metal: info: meta
        SERVER> Demo has started.
        SERVER> Shared memory test finished
        SERVER> ====== libmetal demo: atomic operation over shared memory ======
        SERVER> Starting atomic add on shared memory demo.
        l_uio_dev_open: No IRQ for device 3ed80000.shm.
        CLIENT> Setting up shared memory demo.
        CLIENT> Starting shared memory demo.
        CLIENT> Sending message: Hello World - libmetal shared memory demo
        CLIENT> Message Received: Hello World - libmetal shared memory demo
        CLIENT> Shared memory demo: Passed.



...