Cortex-M33 Multi-OS Package Support

From Renesas.info

General Information

Official RZV2L Cortex-M33 Multi-OS Package

Official RZG2L/UL Cortex-M33 Multi-OS Package

Development Environment

The firmware that runs on the CM33 requires the following tools for development. These tools can be hosted on a PC running Windows or Linux.

Renesas e2studio IDE supports application development and debugging for the Cortex-CM33

Renesas e2studio

GNU ARM Embedded 9.2.1 2019q4

Segger J-Link


Please review the RZG2L Getting Started Guide. This document includes information about setting up the IDE for RZG2L/CM33 Development, loading, and running Cortex-CM33 Applications.

NOTE: For Windows user the compiler and Segger J-Link are installed as part of the installation. See Getting Started with Flexible Software Package Document.

NOTE: For Linux users the compiler and J-Link need to be installed separately as directed in the Getting Started with Flexible Software Package Document.

Getting Started with Flexible Software Package

The Cortex-M33 supports the the Reness FSP ( Flexible Software Package ).The documents and FSP package can be found here. For Linux Users, follow the instruction in section 2.2 in the Getting Started with Flexible Software Package Document to install the FSP on the IDE.

RZV2L

RZG2L/UL

Linux FSP Installation

1) Download the FSP Package Archive (see above)

2) Extract the FSP to the e2studio installation directory. (i.e. /home/<user>/.local/share/renesas/e2studio)

3) The Extracted file should look like this

renesas
└── e2_studio
    β”œβ”€β”€ eclipse
    β”œβ”€β”€ fsp_documentation
    β”œβ”€β”€ internal
    β”‚   β”œβ”€β”€ devassist
    β”‚   └── projectgen
    β”‚       β”œβ”€β”€ ra
    β”‚       β”‚   └── packs
    β”‚       └── rz_fsp
    β”‚           β”œβ”€β”€ rzg
    β”‚           └── rzv



CM33 e2studio GDB Debug

  1. Build the BSP and downloaded the latest ARM Trust Zone Loader and Uboot. This is very important because the loaders setup the board and processor hardware ( CM33, DRP, ... ). The preinstalled loaders on the board do not properly setup the processor and board.
  2. Set the SW1 switch to enable the JTAG and SW11 to QSPI Flash or Serial Interface. ( See figure JTAG Connection and SW11 Settings ).
    JTAG Connection and SW11 Settings.
  3. Press the power button on the board. You should see three LEDS. If the USB wire is connected to the Serial Interface you should see the uboot start up.
  4. Create a RZV2L Project.
    1. Set the Board to RZV2L Evaluation Kit (SMARC). This will set the project GPIO pins correctly
    2. Device settings: R9A07G054L23GBG
    3. Debugger: J-Link ARM
    4. Choose either Mare Metal - Blinky or FreeRTOS - Blinky. Theses projects will generate the GPIO code for the LED.
  5. Compile Project
    1. If there are error check the correct compiler is selected or open the FSP perspective and click generate code.
  6. Open the Project Debug Configuration ( Run -> Debug Configuration ). Under Renesas GDB Hardware Debugging, select the configuration with the same name as your project name.
  7. In the Debug Configuration -> Debugger Check the following settings.
    1. Target Device is R9A07G054L_M33
    2. Connection Settings -> Rest on connection is set to No
  8. In the Debug Configuration -> Startup
    1. Reset and Delay is unchecked
    2. Run Commands:
set {int} 0x4102080C=0x1001FF80
set {int} 0x41020810=0x00010000
  1. Press Apply then debug.

Note about e2studio failing connection / code download

When e2studio attempts to connect to the target, it tries to run InitTarget() using the Cortex-A55. This small code gets loaded in the internal SRAM. If for whatever reason (e.g. security) the access to the internal SRAM is blocked, then the connect attempt fails:

Starting target connection
GDB action 'connect to target', has failed with error code, 0xffffffff
force_kill_gdb()
Disconnected from the Target Debugger.

and you may get the following message in the detailed log:

Connecting to target via JTAG
InitTarget() start
ERROR: Clocks could not be enabled.
ERROR: Cortex-M33 could not be enabled / released from reset.
InitTarget() end - Took 209ms
Connect failed. Resetting via Reset pin and trying again.
InitTarget() start
ERROR: Clocks could not be enabled.
ERROR: Cortex-M33 could not be enabled / released from reset.
InitTarget() end - Took 210ms
Cannot connect to target.

If, instead, the DDR is not configured yet or the access is blocked for whatever reason (again for example due to the security settings), then the connection succeeds but the Cortex-M33 code loading fails:

Target connection status - OK
Target connection status - OK
Starting download
GDB action 'write binary data', has failed with error report, Failed to write to memory
Disconnected from the Target Debugger.

Yocto Build

This section describes how to add the Cortex-M33 Multi-OS Package to the yocto build. This package will add a command to uboot to start the CM33 processor and add the OpenAMP Multi Processor Communication Software to the Linux BSP.

OpenAMP

The Open Asymmetric Multi-Processing (OpenAMP) is a framework providing the software components needed to enable the development of software applications for Asymmetric Multiprocessing (AMP) systems. This allows communications between Cortex M33 and Cortex-A cores.

Official OpenAMP Project Page

Getting Started

The Multi-OS Package assume that only the BSP, Video Codec, and GPU are installed. By adding the Multi-OS package, it will overwrite the RZV2L BSP meta-rz_features layer.conf file. This will remove the DRP and/or ISP package configuration. Follow the steps below to add the MultiOS without removing the DRP and/or ISP packages

Multi-OS Package v1.10 Build steps        
### Extract the BSP Linux package
..
### Copy/Move the 'RZV2L Codec Library v1.0.1' Zip file (RTK0EF0045Z15001ZJ-v1.0.1_EN.zip) under the BSP directory.
..
### Copy/Move the 'RZV2L ARM Mali-GPU Library v1.4' Zip file (RTK0EF0045Z13001ZJ-v1.4_EN.zip) under the BSP directory.
..

### Setup the RZV2L MultiOS CM33 under the BSP, Codex and GPU directory.
### Install the and boot commands OpenAMP library
unzip $SRC_DIR/r01an6238ej0110-rzv2l-cm33-multi-os-pkg.zip
tar -zxvf r01an6238ej0110-rzv2l-cm33-multi-os-pkg/meta-rz-features.tar.gz

### Extract the 'DRP-AI Driver Support' package file (meta-rz-features.tar.gz) under the rzv2l_drpai-driver directory.
..
### Copy/Move the ISP Support archive file ( r11an0561ej<version>-rzv2l-isp-sp.zip ) 
..

### Reinsert the MultiOS recipe into the meta-rz-features/conf/layers.conf
cd $WORK_DIR
sed -i '/demos.inc/a include ${LAYERDIR}/include/openamp/openamp.inc' ./meta-rz-features/conf/layer.conf

cd $WORK_DIR
source poky/oe-init-build-env
cp ../meta-renesas/docs/template/conf/smarc-rzv2l/*.conf ./conf/

### Build
bitbake core-image-weston

Verification

If the Cortex-M33 Multi-OS was correctly added the meta-rz-features/conf/layers.conf file show include the following lines located neat the top of the file.

include ${LAYERDIR}/include/demos/demos.inc
include ${LAYERDIR}/include/openamp/openamp.inc

Full file

RZV2L example meta-rz-features/conf/layers.conf,2   

include ${LAYERDIR}/include/graphic/feature.inc include ${LAYERDIR}/include/codec/plugin.inc include ${LAYERDIR}/include/demos/demos.inc include ${LAYERDIR}/include/openamp/openamp.inc

LAYERDEPENDS_rz-features = "rzg2"

BBPATH .= ":${LAYERDIR}"

BBFILE_COLLECTIONS += "rz-features" BBFILE_PATTERN_rz-features := "^${LAYERDIR}/"

  1. We have recipes-* directories, add to BBFILES

BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \

   ${LAYERDIR}/recipes-*/*.bb \
   ${LAYERDIR}/recipes-*/*.bbappend \
   ${LAYERDIR}/recipes-*/*/*.bbappend"

FSP Settings

FreeRTOS Settings

The FreeRTOS Configuration files are generated by the FSP Smart Configurator. Component Settings can only be viewed in the Stack Configuration Window. The FreeRTOS Component Configurations are in the MainTask ( or any Task ) properties. To access this properties do the following.

1) Make sure you have a properties window open Menu Window -> Show View -> Properties

2) Open the configuration.xml file using the default editor. This will open the Smart Configurator.

3) In the Smart Configurator Open the Stack Tab.

Select Stack Tab


4) In the Stack Configuration Window Select the Main Task ( actually any task will work )

Project Stack Configuration Outline

5) The properties window should show the following

Task Stack Properties


6) Expand the General Settings. This is the FreeRTOS settings. Modification to these settings effect all tasks.

General FreeRTOS Configurations


Cortex-M33 Multi-OS Demos

Blinky and Minimal

These demos are created when a new eclipse project is created. The procedure to create the demos is well documented in the Getting Started with Flexible Software Package. The main difference between these two projects is the Minimal Project includes the minimal FSP Driver components to run the OS or Baremetal project. The Blinky adds GPIO and tImer components to blink the leds.

FAQ

Compiler errors:

Renesas Toolchain Management

Make sure that you are using the correct GNU GCC Compiler version. The compiler used for the RZ is not the same as the RA. Refer to Development Environment section of this page to make sure the correct compiler is installed.

  1. To check the available compilers on the IDE menu bar select help -> Renesas Toolchain. Check the compiler version matches there version listed on Development Environment.
  2. If the Compiler is not there but installed Select the Add button an follow the prompts.
  3. If the Compiler is not installed down load the compiler using the links shown in Development Environment. Download and install the compiler. Then follow step 2.
image 2023-03-07 180341219.png


Check the correct Board:

When creating a project be sure to select the EVK board in the Device and Tools Selection Dialog. Once the EVK is selected the Device will automatically be selected. This is important of the Blink Demo.


OpenAMP Demo

This demo is included in the Multi-OS Package Yocto Package. Download this package from the Official Cortex-M33 Multi-OS website listed General Information. This demo requires that the Multi-OS Package was included in the Yocto BSP Build. See Yocto Build Getting Started.

Configure uboot to start the CM33 Code

Step 1) Import the project

Step 2) Compile the project. If there are compiler errors check the FAQ for the Blinky and Minimal Demos.

Step 3) The following are the generated binaries

Step 4) Boot the RZ board but press key when prompted so we are in the bootloader

Step 5) Enter the following commands. These command expect the binaries are on partition 1 (mmc 1:N N=1).

dcache off
mmc dev 1
fatload mmc 1:1 0x0001FF80 rzv2l_cm33_rpmsg_demo_secure_vector.bin
fatload mmc 1:1 0x42EFF440 rzv2l_cm33_rpmsg_demo_secure_code.bin
fatload mmc 1:1 0x00010000 rzv2l_cm33_rpmsg_demo_non_secure_vector.bin
fatload mmc 1:1 0x40010000 rzv2l_cm33_rpmsg_demo_non_secure_code.bin
cm33 start_debug 0x1001FF80 0x00010000
dcache on

This is the expected output. NOTE Except for the filenames, the RZG will be the same.

=> dcache off
=> mmc dev 1
=> fatload mmc 1:1 0x0001FF80 rzv2l_cm33_rpmsg_demo_secure_vector.bin
64 bytes read in 11 ms (4.9 KiB/s)
=> fatload mmc 1:1 0x42EFF440 rzv2l_cm33_rpmsg_demo_secure_code.bin  
400 bytes read in 11 ms (35.2 KiB/s)
=> fatload mmc 1:1 0x00010000 rzv2l_cm33_rpmsg_demo_non_secure_vector.bin
1984 bytes read in 12 ms (161.1 KiB/s)
=> fatload mmc 1:1 0x40010000 rzv2l_cm33_rpmsg_demo_non_secure_code.bin
42352 bytes read in 17 ms (2.4 MiB/s)
=> cm33 start_debug 0x1001FF80 0x00010000
=> dcache on

Step5 ) Enter the boot commad

Start the Linux Application

The OpenAMP Cortex-A Application Yocto recipe is built and added to the RZ Linux file system as part of the Yocto build.

To compile the project with SDK see FAQ below.

Just call the following binary

./rpmsg_sample_client 0

Expected output

root@smarc-rzv2l:~# ./rpmsg_sample_client 0
Successfully probed IPI device
metal: info:      metal_uio_dev_open: No IRQ for device 42f00000.rsctbl.
Successfully open uio device: 42f00000.rsctbl.
Successfully added memory device 42f00000.rsctbl.
metal: info:      metal_uio_dev_open: No IRQ for device 43000000.vring-ctl0.
Successfully open uio device: 43000000.vring-ctl0.
Successfully added memory device 43000000.vring-ctl0.
metal: info:      metal_uio_dev_open: No IRQ for device 43200000.vring-shm0.
Successfully open uio device: 43200000.vring-shm0.
Successfully added memory device 43200000.vring-shm0.
metal: info:      metal_uio_dev_open: No IRQ for device 42f01000.mhu-shm.
Successfully open uio device: 42f01000.mhu-shm.
Successfully added memory device 42f01000.mhu-shm.
Initialize remoteproc successfully.
creating remoteproc virtio
initializing rpmsg shared buffer pool
initializing rpmsg vdev
 1 - Send data to remote core, retrieve the echo and validate its integrity ..
Remote proc init.
RPMSG endpoint has created.
RPMSG service has created.
sending payload number 0 of size 17
echo test: sent : 17
 received payload number 0 of size 17 
sending payload number 1 of size 18
echo test: sent : 18
 received payload number 1 of size 18 
sending payload number 2 of size 19
.
.

FAQ OpenAMP

Compile Cortex-A Application

requirements

The Yocto SDK is required to compile this application. Refer to the RZV and RZG page on how to build the SDK.


Step 1) The Application is located in the following directory. Open terminal in this directory

<yocto buidl directory>/meta-rz-features/recipes-example/rpmsg-sample/rpmsg- sample-0.1/

Step 2) Initialize the Yocto SDK

Step 3) run make

Step 4) When the compilation is complete the binary rpmsg_sample_client is generated. Transfer this to your board.

No Communication between CM33 and CA55 Processors

The message channel defined in the FSP must be the same as the message channel used on the linux side. Below is the method for setting the channels.

On the e2studio Open the FSP Smart Configurator to set the processor channel on the MHU component. TheMHU (Message Handle Unit) is the hardware IP used by OpenAM middleware to send messages. See image.

Open the CM33 OpenAMP Project rz<g/v/>2l_cm33_rpmsg_demo FSP Smart Configuration to set the OpenAMP Processor. This setting must match the chnnel selected on the Linux side.


On Linx Side the first command argument must match the setting on the CM33. The first argument in the command below sets the channel to 0

./rpmsg_sample_client 0