Ariaboard Renesas RZ G2L/ RZ V2L Software Guide

From Ariaboard Wiki
Revision as of 21:41, 7 November 2024 by C2h2 (talk | contribs) (→‎Spec)
Jump to navigation Jump to search

Spec

CPU Dual Cortex®[email protected]
GPU Mali G31
RAM 1024M/2048M/4096M DDR4
USB 1xUSB 2.0 OTG, 1xUSB 2.0
Video Output 1xHDMI(From RGB), 1xDSI-MIPI
Ethernet RGMII 1Gbps x2
External port N/A
Storage eMMC 4/16G, SD Card slot

Image Installation

Ubuntu 20.04 pre-install apts

apt install git build-essential flex bison

Fetch RZ/G2L Linux SDK

git clone https://git.g77k.com/supercatexpert/rzg2-linux-sdk.git -b rzg2l
cd rzg2-linux-sdk
git submodule update --init

or from Github

git clone https://github.com/ariaboard-com/renesas_rzg2l_linux_sdk
cd renesas_rzg2l_linux_sdk
git submodule update --init

Prepare Flash Writer and Bootloader

Use pre-built Flash Writer and bootloader

For G2L board with 1GB RAM:

Description URL
Flash Writer Download Link
Loader (BL2) Download Link
Loader (BL31 + U-Boot) Download Link

For G2L board with 2GB RAM:

Description URL
Flash Writer Download Link
Loader (BL2) Download Link
Loader (BL31 + U-Boot) Download Link

For G2L board with 4GB RAM:

Description URL
Flash Writer Download Link
Loader (BL2) Download Link
Loader (BL31 + U-Boot) Download Link

For V2L board with 2GB RAM:

Description URL
Flash Writer Download Link
Loader (BL2) Download Link
Loader (BL31 + U-Boot) Download Link

Build Flash Writer and bootloader

Build RZG2L Flash Writer

For G2L board:

cd rzg2-flash-writer
./build-g2l-emmc.sh
cd ..

For V2L board:

cd rzg2-flash-writer
./build-v2l-emmc.sh
cd ..
Build U-Boot

For G2L with 1GB RAM:

cd renesas-u-boot-cip
./build-g2l.sh
cd ..

For G2L with 2GB RAM:

cd renesas-u-boot-cip
./build-g2l-2g.sh
cd ..

For G2L with 4GB RAM:

cd renesas-u-boot-cip
./build-g2l-4g.sh
cd ..

For V2L with 2GB RAM:

cd renesas-u-boot-cip
./build-v2l-2g.sh
cd ..
Build ARM Trusted Firmware

ARM Trusted Firmware should be built after the u-boot one.

For G2L with 1GB RAM

cd arm-trusted-firmware
./build-1g.sh

For G2L with 2GB RAM

cd arm-trusted-firmware
./build-2g.sh

For G2L with 4GB RAM

cd arm-trusted-firmware
./build-4g.sh

For V2L with 2GB RAM

cd arm-trusted-firmware
./build-v2l-2g.sh

Boot Flash Burner from serial port

Set serial port of PC to 115200bps, 8N1. Set boot mode of board to download mode. Connect Debug port of board to the serial port of PC. Power on the board, then something like "please send !" will be printed on terminal.

Upload file rzg2-flash-writer/AArch64_output/Flash_Writer_SCIF_RZG2L_SMARC_DDR4_2GB.mot (or rzg2-flash-writer/AArch64_output/Flash_Writer_SCIF_RZV2L_SMARC_DDR4_4GB.mot for V2L SoC) with ASCII mode. After uploading, prompt ">" will appear in terminal.

Install ARM Trusted Firmware & U-Boot

For G2L:

Filename Program Top Address eMMC Save Partition eMMC Save Sectors Description
arm-trusted-firmware/deploy/g2l/bl2_bp.srec 00011E00 boot partition1 000001 Loader (BL2)
arm-trusted-firmware/deploy/g2l/fip.srec 00000000 boot partition1 000100 Loader (BL31 + U-Boot)

For V2L:

Filename Program Top Address eMMC Save Partition eMMC Save Sectors Description
arm-trusted-firmware/deploy/v2l/bl2_bp.srec 00011E00 boot partition1 000001 Loader (BL2)
arm-trusted-firmware/deploy/v2l/fip.srec 00000000 boot partition1 000100 Loader (BL31 + U-Boot)

Use EM_W command to write S-record file into eMMC. e.g:

>EM_W
EM_W Start --------------
---------------------------------------------------------
Please select,eMMC Partition Area.
 0:User Partition Area   : 30535680 KBytes
  eMMC Sector Cnt : H'0 - H'03A3DFFF
 1:Boot Partition 1      : 16384 KBytes
  eMMC Sector Cnt : H'0 - H'00007FFF
 2:Boot Partition 2      : 16384 KBytes
  eMMC Sector Cnt : H'0 - H'00007FFF
---------------------------------------------------------
  Select area(0-2)>1                                         <<<< Enter "1" here
-- Boot Partition 1 Program -----------------------------
Please Input Start Address in sector :1                   <<<< Enter "1" here
Please Input Program Start Address : 00011E00                <<<< Enter "00011E00" here
Work RAM(H'50000000-H'50FFFFFF) Clear....
please send ! ('.' & CR stop load)
SAVE -FLASH.......
EM_W Complete!

eMMC Boot Settings

Please note that for eMMC booting, the following EXT_CSD registers need to be modified:

EXT_CSD[B1] = 0x02
EXT_CSD[B3] = 0x08

Use EM_SECSD command to modify EXT CSD registers:

>EM_SECSD
  Please Input EXT_CSD Index(H'00 - H'1FF) :b1
  EXT_CSD[B1] = 0x00
  Please Input Value(H'00 - H'FF) :2
  EXT_CSD[B1] = 0x02

>EM_SECSD
  Please Input EXT_CSD Index(H'00 - H'1FF) :b3
  EXT_CSD[B1] = 0x00
  Please Input Value(H'00 - H'FF) :8
  EXT_CSD[B1] = 0x08

Check Bootloader

Power off the board. Set boot mode to eMMC boot. Then power on. It should be able to boot into u-boot:

NOTICE:  BL2: v2.5(release):v2.5/rzg2l-1.00-15-g9eb221438
NOTICE:  BL2: Built : 17:28:47, Nov  2 2021
NOTICE:  BL2: eMMC boot from partition 1
NOTICE:  BL2: Load dst=0x1c7c0 src=(p:1)0x20000(256) len=0x10(1)
NOTICE:  BL2: eMMC boot from partition 1
NOTICE:  BL2: Load dst=0x1c960 src=(p:1)0x20010(256) len=0x28(1)
NOTICE:  BL2: eMMC boot from partition 1
NOTICE:  BL2: Load dst=0x44000000 src=(p:1)0x20090(256) len=0x6069(49)
NOTICE:  BL2: eMMC boot from partition 1
NOTICE:  BL2: Load dst=0x1c7c0 src=(p:1)0x20000(256) len=0x10(1)
NOTICE:  BL2: eMMC boot from partition 1
NOTICE:  BL2: Load dst=0x1c960 src=(p:1)0x20010(256) len=0x28(1)
NOTICE:  BL2: Load dst=0x1c960 src=(p:1)0x20038(256) len=0x28(1)
NOTICE:  BL2: eMMC boot from partition 1
NOTICE:  BL2: Load dst=0x50000000 src=(p:1)0x26100(304) len=0xa2975(1302)
NOTICE:  BL2: Booting BL31
NOTICE:  BL31: v2.5(release):v2.5/rzg2l-1.00-15-g9eb221438
NOTICE:  BL31: Built : 17:28:50, Nov  2 2021


U-Boot 2020.10-g2579e8a259-dirty (Oct 25 2021 - 12:04:40 +0900)

CPU: Renesas Electronics E rev 16.15
Model: rzg2l-novotech
DRAM:  896 MiB
MMC:   sh-sdhi: 0, sh-sdhi: 1
Loading Environment from MMC... *** Warning - bad CRC, using default environment

In:    serial@1004b800
Out:   serial@1004b800
Err:   serial@1004b800
Net:   
Error: ethernet@11c20000 address not set.
No ethernet found.

Hit any key to stop autoboot:  0

Build Linux Kernel

cd linux-cip
./build-g2l.sh

Create Linux root filesystem

Prepare a SD card with capacity of 16GB or more. Use partition tool like fdisk, create 2 partitions on SD card: first partition should be FAT16/32, with size at least 64MiB, secord partition should be ext4, size should be at least 8GiB. Copy files below into first partition (replace /dev/sdb1 to the first partition of your real SD card device path):

For G2L with 1GB RAM:

sudo -s
mount /dev/sdb1 /mnt
cp -v linux-cip/deploy/g2l/Image /mnt
cp -v linux-cip/deploy/g2l/r9a07g044l2-rzg2l-novotech.dtb /mnt/r9a07g044l2-rzg2l-novotech.dtb
cp -v linux-cip/deploy/g2l/modules.tar.gz /mnt
umount /dev/sdb1
exit

For G2L with 2GB RAM:

sudo -s
mount /dev/sdb1 /mnt
cp -v linux-cip/deploy/g2l/Image /mnt
cp -v linux-cip/deploy/g2l/r9a07g044l2-rzg2l-novotech2.dtb /mnt/r9a07g044l2-rzg2l-novotech.dtb
cp -v linux-cip/deploy/g2l/modules.tar.gz /mnt
umount /dev/sdb1
exit

For G2L with 4GB RAM:

sudo -s
mount /dev/sdb1 /mnt
cp -v linux-cip/deploy/g2l/Image /mnt
cp -v linux-cip/deploy/g2l/r9a07g044l2-rzg2l-novotech4.dtb /mnt/r9a07g044l2-rzg2l-novotech.dtb
cp -v linux-cip/deploy/g2l/modules.tar.gz /mnt
umount /dev/sdb1
exit

For V2L with 2GB RAM:

sudo -s
mount /dev/sdb1 /mnt
cp -v linux-cip/deploy/g2l/Image /mnt
cp -v linux-cip/deploy/g2l/r9a07g054l2-rzv2l-novotech2.dtb /mnt/r9a07g054l2-rzv2l-novotech.dtb
cp -v linux-cip/deploy/g2l/modules.tar.gz /mnt
umount /dev/sdb1
exit

Then create Debian 12 (Bookworm) rootfs:

sudo -s
apt-get install qemu-user-static debootstrap schroot

mkdir debian-rootfs
cd debian-rootfs
export ROOTFS="$(pwd)"
qemu-debootstrap --arch arm64 --variant buildd --include=ca-certificates,apt,wget,sudo,debootstrap,isc-dhcp-client,nano,network-manager bookworm "${ROOTFS}" http://deb.debian.org/debian

chroot "${ROOTFS}"
passwd root
#Input your root password

exit

tar -xf ../linux-cip/deploy/g2l/modules.tar.gz
tar -czpf ../debian-bookworm-rootfs.tar.gz .

exit

Mount and extract rootfs to the second partition of your SD card (replace /dev/sdb2 to your one).

sudo -s
mount /dev/sdb2 /mnt
tar -xpzf debian-bookworm-rootfs.tar.gz -C /mnt

# Copy rootfs to SD card so that you can install it to eMMC (Optional):
cp -v debian-bookworm-rootfs.tar.gz /mnt

umount /dev/sdb2
exit

Using pre-built system image

Debian 12 (Bookworm) pre-built SD card image (need at least 16GB capacity): http://dl.ariaboard.com/renesas_g2l/images/rzg2l-debian-bookworm-sd-20241010.img.gz

on PC:Pre-built system image can be used with both eMMC and SD card. Use commands below on PC to restore disk image to SD card (assume the SD card device is /dev/sdb and image file is emmc.img.gz):

#on a Linux PC:
zcat emmc.img.gz | sudo dd of=/dev/sdb bs=1M status=progress
sync

#on the Linux PC: Copy image to SD card so that you can restore it to eMMC (Optional):
sudo -s
partprobe
mount /dev/sdb2 /mnt
cp -v emmc.img.gz /mnt
umount /mnt

Boot kernel & rootfs from SD card

At u-boot auto booting count down, press Escape twice to break into u-boot command-line. Use commands below to boot from SD card:

run sdboot

The device path of SD card is /dev/mmcblk1, and the path of eMMC is /dev/mmcblk0. Kernel and rootfs can be written into eMMC with the same partition structure as SD card.

If you copied system image to SD card, you can restore it to eMMC with commands below:

zcat emmc.img.gz | sudo dd of=/dev/mmcblk0 bs=1M status=progress
sync

Enable Audio AMP

Set GPIO 43-0 to High:

Kernel 4.19:

echo 464 >/sys/class/gpio/export
echo out >/sys/class/gpio/gpio464/direction
echo 1 >/sys/class/gpio/gpio464/value

Kernel 5.10:

echo 464 >/sys/class/gpio/export
echo out >/sys/class/gpio/P43_0/direction
echo 1 >/sys/class/gpio/P43_0/value

Power Control of Wireless

Set GPIO 4-1 to Low:

Kernel 4.19:

echo 153 >/sys/class/gpio/export
echo out >/sys/class/gpio/gpio153/direction
echo 0 >/sys/class/gpio/gpio153/value

Kernel 5.10:

echo 153 >/sys/class/gpio/export
echo out >/sys/class/gpio/P4_1/direction
echo 0 >/sys/class/gpio/P4_1/value

ALSA Volume Setup

amixer sset "PCM" 100%
amixer sset "Line" 100%
amixer sset "Line DAC" 100%