R-Car/Boards/Yocto-Gen3/v5.1.0

Introduction
This page contains information on building and running Yocto on: NOTE: USE OFFICIAL DOCUMENTATION provided with R-Car BSPs FOR H3SK/M3SK boards See also:
 * Renesas R-Car-H3 Starter Kit Premier (unofficial name - H3ULCB)
 * Renesas R-Car-M3 Starter Kit Pro (unofficial name - M3ULCB)
 * https://www.renesas.com/us/en/products/automotive-products/automotive-system-chips-socs/r-car-h3-m3-starter-kit
 * Latest version R-Car/Boards/Yocto-Gen3
 * Stable version R-Car/Boards/Yocto-Gen3-stable

Host PC
Ubuntu 16.04/20.04 LTS (64bit) is recommended as OS. 32bit version is not supported.

Required packages

 * 1) Download evaluation version of proprietary graphics and multimedia drivers from Renesas.
 * To download Multimedia and Graphics library and related Linux drivers, please use the following link:
 * https://www.renesas.com/us/en/application/automotive/r-car-h3-m3-h2-m2-e2-documents-software
 * Download two files:
 * R-Car_Gen3_Series_Evaluation_Software_Package_for_Linux-20210428.zip
 * R-Car_Gen3_Series_Evaluation_Software_Package_of_Linux_Drivers-20210428.zip
 * Graphic drivers are required for Wayland. Multimedia drivers are optional.
 * 1) Install required packages
 * Refer to Yocto Project Quick Start for more information.
 * Refer to Yocto Project Quick Start for more information.
 * Refer to Yocto Project Quick Start for more information.

Building the BSP for Renesas H3 Starter Kit, M3 Starter Kit
NOTE: to have ADAS View and HAD Solution kits supported follow instructions: R-Car Yocto Gen3 ADAS

Using build script

 * 1) Directory Structure
 * 2) Build script(build.sh)
 * 3) build
 * If the build completes successfully, all the necessary files are generated in a following directory:
 * 1) build
 * If the build completes successfully, all the necessary files are generated in a following directory:
 * If the build completes successfully, all the necessary files are generated in a following directory:

Manual steps

 * 1) Create a directory and switch to it
 * Warning! Yocto builds require a lot of disk space (up to 100 GB). Make sure you have got enough before starting the build.
 * 1) Clone basic Yocto layers:
 * 2) Switch to proper branches/commits
 * Another versions are not tested for compatibility.
 * Legacy BSP instruction can be found here R-Car Yocto Gen3 legacy
 * 1) Apply patch to update meta-rcar(patch file: [[File:Update-meta-rcar-for-Yv510-20210531.patch.zip]])
 * 2) Create $WORK/../proprietary folder, then download proprietary driver modules to it.
 * See also Required_packages
 * You should see the following files:
 * 1) Populate meta-renesas with proprietary software packages.
 * 2) Setup build environment
 * 3) Prepare default configuration files.
 * 4) Start the build
 * 5) Building image can take up to a few hours depending on your host system performance. After the build has been completed successfully, you should see the output similar to:
 * and the command prompt should return.
 * 1) Bitbake has generated all the necessary files in ./tmp/deploy/images directory. You can verify its content:
 * Image is a Kernel image, *.dtb is a blob file, core-image--.tar.bz2 is the rootfs, modules-.tgz are kernel modules.
 * 1) You can now proceed with Running Yocto images
 * 1) Prepare default configuration files.
 * 2) Start the build
 * 3) Building image can take up to a few hours depending on your host system performance. After the build has been completed successfully, you should see the output similar to:
 * and the command prompt should return.
 * 1) Bitbake has generated all the necessary files in ./tmp/deploy/images directory. You can verify its content:
 * Image is a Kernel image, *.dtb is a blob file, core-image--.tar.bz2 is the rootfs, modules-.tgz are kernel modules.
 * 1) You can now proceed with Running Yocto images
 * 1) Bitbake has generated all the necessary files in ./tmp/deploy/images directory. You can verify its content:
 * Image is a Kernel image, *.dtb is a blob file, core-image--.tar.bz2 is the rootfs, modules-.tgz are kernel modules.
 * 1) You can now proceed with Running Yocto images
 * 1) You can now proceed with Running Yocto images

Build SDK

 * After building BSP you may build SDK:
 * After build finished the SDK installation script may be found in following path:
 * Install SDK by run the following command and follow instructions on the screen:
 * Install SDK by run the following command and follow instructions on the screen:
 * Install SDK by run the following command and follow instructions on the screen:

Running Yocto images
Linux kernel can be booted from microSD card or from TFTP. Root FS can be mounted from micro SD card or via NFS.

Loading kernel via TFTP and rootfs via NFS
Follow these steps to setup working TFTP and NFS server:
 * 1) Setup a TFTP server.
 * Install tftpd-hpa package along with tftp tools:
 * 1) Copy Image and XXXX.dtb from $WORK/build/tmp/deploy/images// to TFTP server root.
 * Which version is my H3SK board?
 * 1) Verify that TFTP server is working.
 * Which version is my H3SK board?
 * 1) Verify that TFTP server is working.


 * 1) Setup NFS server.
 * 2) Install necessary packages:
 * 3) Start NFS server:
 * 4) Export root FS to NFS. (Change IMAGE and MACHINE to fit your build).
 * 5) Unpack rootfs to a dedicated directory:
 * 6) Edit /etc/exports:
 * add
 * Save the file and exit.
 * 1) Force NFS server to re-read /etc/exports
 * 2) Verify that NFS is working.
 * 3) Boot into U-Boot command prompt
 * 4) Connect to serial console over microUSB using minicom or picocom.
 * 5) Switch the board on or reset it. Press any key to stop U-Boot automatic countdown.
 * Refer to H3SK board page, M3SK board page for more information.
 * 1) Configure Ethernet, TFTP, and kernel command line in U-Boot:
 * 1) Verify that NFS is working.
 * 2) Boot into U-Boot command prompt
 * 3) Connect to serial console over microUSB using minicom or picocom.
 * 4) Switch the board on or reset it. Press any key to stop U-Boot automatic countdown.
 * Refer to H3SK board page, M3SK board page for more information.
 * 1) Configure Ethernet, TFTP, and kernel command line in U-Boot:
 * 1) Configure Ethernet, TFTP, and kernel command line in U-Boot:


 * Replace  with the proper IP address for the board. Replace  with the IP address of your computer, where tftp and nfs servers are installed. Replace  with the exported path of the root FS. For example:
 * You can also use
 * command to obtain information from DHCP server.
 * Note: You can always see the environment with printenv command. Refer to U-Boot manual for details.
 * 1) Verify the connection over Ethernet from U-Boot:
 * You should see:
 * 1) Reset the board by pushing reset button
 * Refer to H3SK board page, M3SK board page for more information.
 * 1) The board should boot the kernel:
 * You should see:
 * 1) Reset the board by pushing reset button
 * Refer to H3SK board page, M3SK board page for more information.
 * 1) The board should boot the kernel:
 * 1) The board should boot the kernel:

Loading kernel and rootfs via eMMC/SD card
This section describes steps that are necessary for preparing and booting from SD card.

Preparing eMMC/SD card
WARNING! These steps will erase the SD card completely. In short, all files will be lost. There two methods to prepare SD card. so, please select one of them.

Manual steps
In order to prepare you SD card, follow these instructions on host machine:
 * 1) Partion your SD card to set 1 partition and ID=83 (Linux)
 * Make sure the SD card doesn't contain any important files.
 * 1) Format this partition to ext3 (or ext4)
 * 2) Mount this partition on your host to any directory and upack the core-image-*.tar.bz2 into mounted folder. And Copy Image and XXXX.dtb from $WORK/build/tmp/deploy/images// to sd card /boot.
 * NOTE: probably you need to be a root user, hence use "sudo"
 * 1) Mount this partition on your host to any directory and upack the core-image-*.tar.bz2 into mounted folder. And Copy Image and XXXX.dtb from $WORK/build/tmp/deploy/images// to sd card /boot.
 * NOTE: probably you need to be a root user, hence use "sudo"
 * NOTE: probably you need to be a root user, hence use "sudo"

Using bmaptool
Install bmaptool by following command: ex.) case of '/dev/sdb': Note:
 * Note:
 * It requires to be located both *.wic.xz and *.wic.bmap in same directory.
 * It doesn't required to contain partition number(ex. /dev/sdb1, /dev/mmcblk0p1, and so on), /dev/mmcblk0 or /dev/sdb and so on are correct
 * Log:
 * Log:
 * /dev/XXXX is differnet by host PC environment.
 * It can be checked by using 'fdisk -l'.

Configure U-Boot to boot from SD card

 * Proper U-Boot command to boot from SD:
 * Note from user:
 * When I created my image with mkfs.ext3, and booted with rootfstype=ext3, the kernel could not find mount the filesystem.
 * The kernel boot gave an error message:
 * "EXT4-fs (mmcblk1p1): couldn't mount as ext3 due to feature incompatibilities".
 * I switched to 'rootfstype=ext4' in my bootargs, and the kernel booted OK.
 * Example of U-Boot environment variables:
 * To verify the SD card, type the following in U-Boot prompt:
 * To verify the SD card, type the following in U-Boot prompt:
 * To verify the SD card, type the following in U-Boot prompt:

How do access to USB memory from U-boot(Yocto v3.13.0 or later)

 * 1) Some USB memory may not be recognized.
 * 2) [How to fix] Set the "usb_pgood_delay 2000" variable
 * 1) [How to fix] Set the "usb_pgood_delay 2000" variable

Known issues and limitations

 * 1) [SW limitation] Yocto v3.4.0 or later doesn't support RTP0RC7795SKBX0010SA00(H3 v1.1 Starter Kit).
 * Please use the H3 v2.0 or v3.0 SK
 * 1) [Known issue] If you encounter a kernel hang-up while using Yocto v3.4.0 or later, please refer to the following pages.
 * H3 SK: No.1 of R-Car/Boards/H3SK
 * M3 SK: No.2 of R-Car/Boards/M3SK
 * 1) [Known issue] Optee error
 * console log are displayed from WARN_ON macro while the Linux booting.
 * It does not affect the behavior of the Linux Kernel and OP-TEE.
 * 1) [Known issue] SMCCC error
 * This issue does not affect booting Yocto.
 * 1) [Known issue] The performance is not good compared to previous release.
 * ex.) glmark2 score, eMMC
 * It can be improved by setting cpu governor to 'performance'.
 * See also: R-Car/Default-CPUFreq-governor-from-v5-9.
 * 1) [Known issue] DDR memory size issue
 * On some boards U-boot and the kernel do not output the correct DDR memory size.
 * Please see below to work around this issue.
 * See "Step 4" of https://elinux.org/R-Car/Boards/Yocto-Gen3/v5.1.0#Build_using_manual_steps.
 * On some boards U-boot and the kernel do not output the correct DDR memory size.
 * Please see below to work around this issue.
 * See "Step 4" of https://elinux.org/R-Car/Boards/Yocto-Gen3/v5.1.0#Build_using_manual_steps.
 * See "Step 4" of https://elinux.org/R-Car/Boards/Yocto-Gen3/v5.1.0#Build_using_manual_steps.