# Renesas RZ/G2L

**URL:** https://hub.mender.io/t/renesas-rz-g2l/5762
**Category:** Yocto Project
**Tags:** dunfell, renesas
**Created:** [April 14, 2023, 10:47pm UTC](https://hub.mender.io/t/renesas-rz-g2l/5762 "2023-04-14T22:47:28Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![estape.nt](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/estape.nt/32/2049_2.png) [@estape.nt](https://hub.mender.io/u/estape.nt)
#### Post date: [April 14, 2023, 10:47pm UTC](https://hub.mender.io/t/renesas-rz-g2l/5762/1 "2023-04-14T22:47:28Z")

</div>

# Board description

The RZ/G2L microprocessor includes a Cortex®-A55 (1.2 GHz) CPU, 16-bit DDR3L / DDR4 interface, 3D graphics engine with Arm Mali-G31 and video codec (H.264). It also has many interfaces such as camera input, display output, USB 2.0, and Gbit-Ether, making it ideal for applications such as entry-class industrial human-machine interfaces (HMIs) and embedded devices with video capabilities.

 ![renesas_rzg2l_carrier](https://canada1.discourse-cdn.com/flex036/uploads/mender/original/2X/9/938c0494a2c648e63c40a8b7d31974392b218e59.jpeg)

- [RZ/G2L](https://www.renesas.com/us/en/products/microcontrollers-microprocessors/rz-mpus/rzg2l-general-purpose-microprocessors-dual-core-arm-cortex-a55-12-ghz-cpus-and-single-core-arm-cortex-m33)
- [Renesas Support](https://community.renesas.com/)

# Test results

The Yocto Project releases in the table below have been tested by the Mender community. Please update it if you have tested this integration on other [Yocto Project releases](https://wiki.yoctoproject.org/wiki/Releases?target=_blank):

| Yocto Project | Build | Runtime |
| --- | --- | --- |
| dunfell (3.1) | :test_works: | :test_works: |

**Build** Means that the Yocto Project build using this Mender integration completes without errors and outputs images.  
**Runtime** Means that Mender has been verified to work on the board. For U-Boot-based boards, the [integration checklist](https://docs.mender.io/system-updates-yocto-project/board-integration/bootloader-support/u-boot/integration-checklist?target=_blank) has been verified.

# Getting started

## Prerequisites

- A supported Linux distribution and dependencies installed on your workstation/laptop as described in the [Yocto Mega Manual](https://www.yoctoproject.org/docs/current/mega-manual/mega-manual.html#detailed-supported-distros)
  - NOTE. Instructions depend on which Yocto version you intend to use.

- Google repo tool [installed](https://hub.mender.io/t/google-repo/58/2) and in your `PATH`.

## Configuring the build

### Setup Yocto environment

Set the Yocto Project branch you are building for:

```auto
# set to your branch, make sure it is supported (see table above)
export BRANCH="dunfell"

```

Create a directory for your `mender-rzg2l` setup to live in and clone the  
meta information.

```auto
mkdir mender-rzg2l && cd mender-rzg2l

```

Initialize repo manifest:

```auto
repo init -u https://github.com/mendersoftware/meta-mender-community \
          -m meta-mender-renesas/scripts/manifest-renesas.xml \
          -b ${BRANCH}

```

Fetch layers in manifest:

```auto
repo sync

```

## Setup build environment

Initialize the build environment:

```auto
source setup-environment renesas

```

### Configure Mender server URL (optional)

This section is not required for a successful build but images that are generated by default are only suitable for usage with the Mender client in [Standalone deployments](https://docs.mender.io/artifact-creation/standalone-deployment?target=_blank), due to lack of server configuration.

You can edit the `conf/local.conf` file to provide your Mender server configuration, ensuring the generated images and Mender Artifacts are connecting to the Mender server that you are using. There should already be a commented section in the generated `conf/local.conf` file and you can simply uncomment the relevant configuration options and assign appropriate values to them.

Build for Hosted Mender:

```auto
# To get your tenant token:
# - log in to https://hosted.mender.io
# - click your email at the top right and then "My organization"
# - press the "COPY TO CLIPBOARD"
# - assign content of clipboard to MENDER_TENANT_TOKEN
#
MENDER_SERVER_URL = "https://hosted.mender.io"
MENDER_TENANT_TOKEN = "<copy token here>"

```

### Building the image

You can now proceed with building an image:

```auto
bitbake core-image-minimal

```

Replace `core-image-minimal` with your desired image target, keep in mind the image `core-image-minimal` is the one tested.

# Setup the board

For flashing and setting up the board, follow the official [Renesas documentation](https://www.renesas.com/us/en/document/gde/smarc-evk-rzg2l-rzg2lc-rzg2ul-rzv2l-and-rzfive-start-gude-rev103?language=en&r=1467981).

The board can boot in different modes, the SW11 switch is responsable to define the boot mode and input voltage mode. SW11[4] = 1, means 5V input and SW11[4] = 0, means 9V as input voltage.

| Boot Mode | SW11[1..4] |
| --- | --- |
| QSPI Mode | 0001 |
| SCIF Download Mode | 0101 |
| eMMC | 1001 |
| eSD | 1101 |

The board also has a debug mode & main boot device selection

| Debug mode | SW1[1] |
| --- | --- |
| JTAG | 0 |
| Normal operation | 1 |

| Boot devie | SW1[2] |
| --- | --- |
| eMMC on the SoM | 0 |
| microSD on the SoM | 1 |

## Power on/off the board

- Press and hold for 1 second the SW9 push button to power on the board. The LED4 should be on.
- To turn it off, press and hold for 2 seconds the SW9 push button.

## Booting the Flash Writer

The following is the serial configuration for the board

| Variable | Value |
| --- | --- |
| Speed | 115200 bauds |
| Data | 8bit |
| Parity | None |
| Stop bit | 1bit |
| Flow control | None |

To enable send files to the board, set the SW11 switch to SCIF Download Mode (0101)

`TeraTerm > File > Send file > Open the Flash Writer file > Send the file.`

## Writing the bootloader

In the device terminal (Tera Term session), run the `XLS2` and send both bootloader files with their repective addresses.

| Variable | Value | Address to RAM | Address to ROM |
| --- | --- | --- | --- |
| Linux kernel | Image-smarc-rzg2l.bin | 0x48080000 | - |
| Device tree file | Image-r9a07g044l2-smarc.dtb | 0x48000000 | - |
| Boot loader | bl2\_bp-smarc-rzg2l\_pmic.srec   
 fip-smarc-rzg2l\_pmic.srec | 11E00   
 0000 | 0000   
 1D200 |
| Flash Writer | Flash\_Writer\_SCIF\_RZG2L\_SMARC\_PMIC\_DDR4\_2GB\_1PCS.mot | - | - |
| Root FS | _IMAGE\_NAME_-smarc-rzg2l.tar.bz2 | - | - |

In case a message to prompt to clear data, enter “y”.

### Using Renesas Macro to flash

There is an available [macro](https://github.com/seebe/rzg_stuff/blob/master/boards/rzg2l_smarc/rzg2l_smarc-rzg2l_flash_writer.ttl) to flash using Tera Term easily.

Create a folder with the following structure:

```bash
renesas_macro
├── Binaries
│ ├── bl2...
│ └── fip...
└── rzg2l_smarc-rzg2l_flash_writer.ttl

```

Copy the binaries files to flash and load the macro:

`TeraTerm > Control > Macro > Open Macro File`

## Preparing the microSD card

The SD layout it is as following

| Type/Number | Size | Filesystem | Contents |
| --- | --- | --- | --- |
| Primary #1 | 500MB (minimum 128MB) | FAT32 | Linux kernel   
 Device tree |
| Primary #2 | 1/2 of remaining | Ext4 | AB Root filesystem |
| Primary #3 | 1/2 of remaining | Ext4 | AB Root filesystem |
| Primary #4 | TBD | Ext4 | Data partition |

### Repartitioning

1. Run `fdisk` command to repartition the microSD card

```auto
# fdisk /dev/SD_DEV

```

1. Enter `o` (new DOS disklabel)

2. Enter `n` (boot partition)

3. Enter `n` (rootfs partition)

4. Enter `p` (review the changes)

5. Enter `t` (change partition type)

6. Enter `w` (save & write the changes)

### Validate the partitions

1. Run the following commands

```auto
$ partprobe
# fdisk -l /dev/SD_DEV

```

_Validate the microSD card has the wanted layout_

### Format the partitions

```auto
# mkfs.vfat -v -c -F 32 /dev/SD_DEV_1
# mkfs.ext4 -L rootfs /dev/SD_DEV_2
# mkfs.ext4 -L rootfs /dev/SD_DEV_3
# mkfs.ext4 -L rootfs /dev/SD_DEV_4

```

### Copying files

1. Create mounting directories

```auto
# mkdir /mnt/sd_boot
# mkdir /mnt/sd_rootfs_a
# mkdir /mnt/sd_rootfs_b
# mkdir /mnt/sd_data

```

1. Mount the partitions

```auto
# mount /dev/SD_DEV_1 /mnt/sd_boot
# mount /dev/SD_DEV_2 /mnt/sd_rootfs_a
# mount /dev/SD_DEV_3 /mnt/sd_rootfs_b
# mount /dev/SD_DEV_4 /mnt/sd_data

```

1. Check the partitions correctly mounted

```auto
$ df

```

1. Copy the boot files

```auto
$ cp $WORK/build/tmp/deploy/images/<board>/<Linux kernel> /mnt/sd_boot/Image-smarc-rzg2l.bin
$ cp $WORK/build/tmp/deploy/images/<board>/<Device tree> /mnt/sd_boot/Image-r9a07g044l2-smarc.dtb

```

1. Expand the rootfs in partition 2 & 3

```auto
$ cd /mnt/sd_rootfs_a
# tar jxvf $WORK/build/tmp/deploy/images/<board>/<root filesystem>
$ cd /mnt/sd_rootfs_b
# tar jxvf $WORK/build/tmp/deploy/images/<board>/<root filesystem>

```

1. Copy the fw\_env.config file

```auto
$ mkdir -p /mnt/sd_data/u-boot
$ cp meta-mender-renesas/misc/fw_env.config /data/u-boot/fw_env.config

```

1. Copy the device\_type file

```auto
$ mkdir -p /mnt/sd_data/mender
$ cp meta-mender-renesas/misc/device_type /data/mender/device_type

```

# Boot and setup U-boot

To use U-boot, set the SW11 switch to QSPI Mode (0001). On first boot, reset the environment:

```auto
env default -a
saveenv

```

Then you can boot the board with `boot` command or reset it.

# References

- The Renesas RZ/G2L template files can be found in [meta-mender-community](https://github.com/mendersoftware/meta-mender-community/tree/dunfell/meta-mender-renesas)
- The official [Mender documentation](https://docs.mender.io/) explains how Mender works. This is simply a board-specific complement to the official documentation.
