R-Car/Boards/Zephyr-Gen3/2.7

Introduction
This is the Wiki for the Zephyr support for Renesas R-Car Gen3 embedded Cortex-R7. Refer to the R-Car page for information about Renesas’ R-Car SoC family.

This wiki describes the current support of H3ULCB Cortex-R7 on Zephyr from multiple sources. You will also find a step by step tutorial on how to prepare your Ubuntu host then build and test Zephyr OS on an R-Car Gen3 board.

Important: It is important to understand that the Zephyr port has been designed to be executed exclusively on the Cortex-R7 that exists in some of the R-Car Gen3 boards.There is no plan to replace other software such as U-Boot or Linux that are running on the A57/53 cores by Zephyr.

Tutorial
This tutorial is based on the official Zephyr 2.7 guide, commands are appended here to allow you a quick copy and paste. You can also follow the installation steps (1 to 4) directly from the official guide here.

This guide only supports Ubuntu but the official one also describes steps for macOS and windows. This tutorial is based on Zephyr 2.7 version and is using the Iot.bzh’s Renesas 2.7 BSP in order to provide a much more user friendly tutorial.

You can see Zephyr 2.7’s H3ULCB supported features here.

Prepare your bootloaders
In order for Zephyr or any other RTOS running on the H3ULCB’s Cortex-R7 to work well, “ARM Trusted Firmware” needs to be patched and re-flashed. This patch enables access to GIC generated interrupts from the CR7 core on R-Car Gen3 boards.

Warning: By applying this patch and giving secure access to the CR7 core you expose yourself to unintended uses that may compromise the security of your system.

Build “ARM Trusted Firmware” (BL2)
In order to build your “ARM Trusted Firmware” with the needed patch, you have to add a Yocto layer when building your BSP with Yocto. The following instructions are tested in order to be used with the official guide for BSPs 5.9.0 and earlier.

You can apply BL2 patch by adding these lines to the script or manual steps :

  “Clone basic Yocto layers in parallel” section :  “Switch to proper branches/commits” section :   For BSP 5.1.0 and earlier   For BSP 5.5.0 and later    Case 1 : You want to build a complete image Before  :   Case 2 : You only want to rebuild “ARM Trusted Firmware” with the patch Replace  by : 

Flash bootloaders
Once you have built your new “ARM Trusted Firmware” bootloader, you may flash it by following the official flashing guide.

You may choose to only re-flash the “ARM Trusted Firmware” or re-flash all your bootloaders if you are running old versions of these.

Install dependencies
First, update your host:

Then, install the required dependencies:

Please also make sure that your,   and   tools version are matching required minimal version here.

Get Zephyr and install Python dependencies
In order to clone Zephyr, you should first install the West tool, a swiss-army knife command line tool used by the Zephyr project for the whole process from cloning sources to flashing a board.

Clone the complete Zephyr project, use Iot.bzh’s latest Renesas BSP and update all the project:

Export a Zephyr CMake package:

Then, install the Python dependencies:

Install a toolchain
To build Zephyr OS binaries, you need a cross-toolchain. The Zephyr OS project provides all the binary files you need to build your project.

Then, apply the provided udev rule allowing the flash of most Zephyr boards:

Build demos
Now you are ready to build your first Zephyr project programs, we are going to start with a bunch of basic demos:


 * Blinky demo is making a LED blink (LED5 output LED).
 * Button demo is turning on output LED when receiving button input (SW3 input button).

Build a custom app
As an example, we will clone the zephyr-shell demo that we prepared to demonstrate all the currently supported features for R-Car Gen3 H3ULCB on Zephyr.

You can clone your app anywhere on your host, for the clarity of this tutorial, we will store apps near to the Zephyr sources:

Then, you can build it at the same location as demos previously built:

Hardware setup
Now that your binaries are ready, it’s time to prepare your hardware setup allowing you to flash the program you just built.

First, the BSP we are using is currently only supporting the Olimex ARM-USB-OCD-H JTAG probe, we then encourage you to use this probe to flash H3ULCB board.

Depending on the hardware configuration you use, you will not need the same setup:

ULCB: To connect the JTAG probe to a ULCB board, you will need a TET SICA20I2P adapter. You will then be able to connect your probe to the CN3 JTAG connector of the board. Unless your CN10 connector is welded, secondary UART is not available on this board.

ULCB+KF: When connected to a Kingfisher board, you can use JTAG and access secondary UART. You are able to access the secondary UART through KF CN4 connector (be careful, the pinout of the connector depends on your KF revision). See “Know issues” to be sure that your Kingfisher revision let you use the JTAG connector.

If you are able to access the secondary UART (depending on yor hardware setup), you can link your host to it with a USB-TTL adapter with 115200 8N1 settings.

Deploy a Zephyr binary on board
Now that your hardware setup is ready, you are able to flash any of your Zephyr binary:

Blinky demo:

LED5 of H3ULCB should blink.

Button demo:

LED5 of H3ULCB should turn on if SW3 button is pushed.

Zephyr Shell demo:

Zephyr shell prompt should appear on H3ULCB+KF secondary UART (KF CN4/SCIF1). You can then test subsystems support as explained in Zephyr Shell app Readme here.