Running the rpmsg demo sample from Renesas

To understand how the loading of the firmware works, a deeper knowledge of the RZ/G2L memory is necessary:

SRAM (internal RAM)

  • The RZ/G2L processors have two banks of internal RAM with 64 kbyte each.

  • Both memory banks are accessible from the Cortex®-A55 core, as well as the Cortex®-M33 core.

  • The Cortex®-M33 core has different address spaces for Secure- and Non-Secure access.

../../../_images/SRAM1.png

DRAM (external RAM)

  • The DDR address space is different for the Cortex®-A55 and Cortex®-M33.

  • The Cortex®-M33 can access only the lower 256 MByte of the DRAM.

  • The Cortex®-M33 has different address spaces for Secure and Non-Secure accesses.

../../../_images/DRAM1.png

Default RZ/G2L Memory Map in the BSP

There is a reserved area for the CM33 firmware code defined below the Linux area:

../../../_images/memory-map1.png

Deploying the firmware to the target

After building the sample with e² studio, 4 binary files will be generated:

  • rzg2l_cm33_rpmsg_demo_non_secure_code.bin

  • rzg2l_cm33_rpmsg_demo_non_secure_vector.bin

  • rzg2l_cm33_rpmsg_demo_secure_code.bin

  • rzg2l_cm33_rpmsg_demo_secure_vector.bin

To start the firmware, we have to deploy it first to the target’s memory. That could be basicly, the internal emmc device of the SOM or the SD-card of the base board. The following example shows, how to deploy the firmware to the internal emmc device.

After building the yocto Linux and programming it with the uuu-tool to the target, we can examine the programmed partitions inside U-Boot:

mmc dev 0
mmc part
Partition Map for MMC device 0  --   Partition Type: EFI

Part    Start LBA       End LBA         Name
             Attributes
             Type GUID
             Partition GUID
     1     0x00000800      0x000107ff      "boot"
             attrs:  0x0000000000000000
             type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
             guid:   69024680-ec4f-4b41-87af-4d3a351a047b
     2     0x00010800      0x00747bff      "rootfs"
             attrs:  0x0000000000000000
             type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
             guid:   97e9f2b4-97d3-4fd1-a9ef-195cf30d6b5f

The “boot”-partition contains the Linux- image and device trees. To store the firmware binary into that partition we use the USB Mass Storage U-Boot function to mount that partition to our Linux host PC:

ums 0 mmc 0:1

Now you can mount the boot - partition on your local PC and copy the 4 files on it. After unmounting the partition, stop the ums-device with Ctrl-C in the U-Boot.

List the contents of the boot-partition from U-Boot to check it:

ls mmc 0:1
<DIR>       1024 .
<DIR>       1024 ..
<DIR>      12288 lost+found
             15110152 Image
             39041 bl2-txrz-g2l1.bin
             24681 bl31-txrz-g2l1.bin
             37923 r9a07g044l2-txrz-g2l1-cm33.dtb
             42799 r9a07g044l2-txrz-g2l1-mb7.dtb
             37240 r9a07g044l2-txrz-g2l1.dtb
             736214 u-boot.bin
             64 rzg2l_cm33_rpmsg_demo_secure_vector.bin
             392 rzg2l_cm33_rpmsg_demo_secure_code.bin
             1984 rzg2l_cm33_rpmsg_demo_non_secure_vector.bin
             42468 rzg2l_cm33_rpmsg_demo_non_secure_code.bin

Starting the firmware from U-Boot

With the firmware files stored in the boot partition of the eMMC, they can be loaded from U-Boot with the following commands:

dcache off
mmc dev 0
load mmc 0:1 0x0001FF80 rzg2l_cm33_rpmsg_demo_secure_vector.bin
load mmc 0:1 0x42EFF440 rzg2l_cm33_rpmsg_demo_secure_code.bin
load mmc 0:1 0x00010000 rzg2l_cm33_rpmsg_demo_non_secure_vector.bin
load mmc 0:1 0x40010000 rzg2l_cm33_rpmsg_demo_non_secure_code.bin
cm33 start_debug 0x1001FF80 0x00010000
dcache on

please note:

The cm33-command specifies the addresses of the secure- and not-secure vector files in memory. The command stores them into the SYS_CM33_CFG2 and SYS_CM33_CFG3 registers respectively, before the Cortex®-M33 is started. These are the addresses seen from the Cortex®-M33, not the load addresses from U-Boot.

The cm33-command starts the Cortex®-M33 coprozessor firmware. The coprocessor uses the UART SCIF2 to communicate to the outside world. When using a TXRZ board, the SCIF2-UART can be found on pins 67 (TxD) and 68 (RxD). After starting the coprozessor, it will output the following debug messages on SCIF2:

Successfully probed IPI device
Successfully open uio device: 42F00000.rsctbl.
Successfully added memory device 42F00000.rsctbl.
Successfully open uio device: 43000000.vring-ctl0.
Successfully added memory device 43000000.vring-ctl0.
Successfully open uio device: 43200000.vring-shm0.
Successfully added memory device 43200000.vring-shm0.
Initialize remoteproc successfully.
creating remoteproc virtio
initializing rpmsg vdev

Starting the rpmsg_sample from Linux

Renesas provides the rpmsg_sample project to demonstrate communication between the Cortex®-A55 core and the Cortex®-M33 core. After the Cortex®-M33 firmware was loaded and started by U-Boot, or with the help of the J-Link debugger, boot Linux with the boot-command.

In Linux, the rpmsg-sample project is packed into the userfs image. Therefore, first mount the userfs:

mount /usr/local

Then, the sample project can be started:

/usr/local/rpmsg_sample_client 0