R-Car/Boards/S4SK/Yocto-Linux

From eLinux.org
Jump to: navigation, search


Software revisions

Software Revision
R-Car SDK v3.16.0
R-Car S4 Linux Yocto package Version 5.24.0
Yocto Project 3.1.11
aarch64-poky-linux-gcc (GCC) 9.3
Linux Kernel 5.10.41
Userland 64/32bit 64
U-Boot 2020.10

Host PC

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

Building the BSP for R-Car S4 Starter Kit

Warning! Yocto builds require a lot of disk space (up to 100 GB). Make sure you have got enough before starting the build.

Installation of required tools and libraries

Ubuntu is used as Linux Host PC since Yocto Project Quick Start specifies Ubuntu as one of the distributions. You need to install the required packages as follows.

sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib \
build-essential chrpath socat cpio python3 python3-pip python3-pexpect \
xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa \
libsdl1.2-dev pylint3 xterm libarchive-zip-perl

Using build script

  1. Build script(build.sh)
    #!/bin/bash
    
    POKY_COMMIT=74b22db6879b388d700f61e08cb3f239cf940d18
    META_OE_COMMIT=814eec96c2a29172da57a425a3609f8b6fcc6afe
    META_RENESAS_COMMIT=fb473def5263e910f90c49969415b1fd3f4ac880
    
    mkdir build
    cd build
    export WORK=`pwd`
    cd ${WORK}
    
    # Clone basic Yocto layers in parallel
    git clone git://git.yoctoproject.org/poky &
    git clone git://git.openembedded.org/meta-openembedded &
    git clone https://github.com/renesas-rcar/meta-renesas &
    
    # Wait for all clone operations
    wait
    
    # Switch to proper branches/commits
    cd ${WORK}/poky
    git checkout -b tmp ${POKY_COMMIT}
    cd ${WORK}/meta-openembedded
    git checkout -b tmp ${META_OE_COMMIT}
    cd ${WORK}/meta-renesas
    git checkout -b tmp ${META_RENESAS_COMMIT}
    
    cd ${WORK}
    source poky/oe-init-build-env ${WORK}/build-s4sk-gateway
    
    cp $WORK/meta-renesas/meta-rcar-gateway/docs/sample/conf/s4sk/poky-gcc/bsp/*.conf ./conf/
    
    bitbake rcar-image-gateway
    
  2. build
    ./build.sh
    

Manual steps

  1. Create a directory and switch to it
    mkdir build
    cd build
    export WORK=`pwd`
    
  2. Clone basic Yocto layers:
    cd $WORK
    git clone git://git.yoctoproject.org/poky
    git clone git://git.openembedded.org/meta-openembedded
    git clone https://github.com/renesas-rcar/meta-renesas
    
  3. Switch to proper branches/commits
    cd $WORK/poky
    git checkout -b tmp 74b22db6879b388d700f61e08cb3f239cf940d18
    cd $WORK/meta-openembedded
    git checkout -b tmp 814eec96c2a29172da57a425a3609f8b6fcc6afe
    cd $WORK/meta-renesas
    git checkout -b tmp fb473def5263e910f90c49969415b1fd3f4ac880
    
  4. Setup build environment
    cd $WORK
    source poky/oe-init-build-env $WORK/build-s4sk-gateway
    
  5. Prepare default configuration files.
    cp $WORK/meta-renesas/meta-rcar-gateway/docs/sample/conf/s4sk/poky-gcc/bsp/*.conf ./conf/
    
  6. Start the build
    bitbake rcar-image-gateway
    
  7. 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:
    NOTE: Tasks Summary: Attempted 5076 tasks of which 5 didn't need to be rerun and all succeeded.
    
    and the command prompt should return.

Generated images

Bitbake has generated all the necessary files in ./tmp/deploy/images directory.
You can verify its content:
$ ls -1 `find ./tmp/deploy/images/s4sk/ -maxdepth 1 -type l -print`
./tmp/deploy/images/s4sk/Image
./tmp/deploy/images/s4sk/Image-s4sk.bin
./tmp/deploy/images/s4sk/modules-s4sk.tgz
./tmp/deploy/images/s4sk/r8a779f0-s4sk-s4sk.dtb
./tmp/deploy/images/s4sk/r8a779f0-s4sk.dtb
./tmp/deploy/images/s4sk/rcar-image-gateway-s4sk.manifest
./tmp/deploy/images/s4sk/rcar-image-gateway-s4sk.tar.bz2
./tmp/deploy/images/s4sk/rcar-image-gateway-s4sk.testdata.json
./tmp/deploy/images/s4sk/u-boot-elf-s4sk.srec
./tmp/deploy/images/s4sk/u-boot-elf.srec
./tmp/deploy/images/s4sk/u-boot-initial-env
./tmp/deploy/images/s4sk/u-boot-initial-env-s4sk
./tmp/deploy/images/s4sk/u-boot-s4sk.bin
./tmp/deploy/images/s4sk/u-boot.bin
Image is a Kernel image, *.dtb is a blob file, rcar-image-gateway-s4sk.tar.bz2 is the rootfs.
$ ls -1 tmp/deploy/images/s4sk/*.srec
tmp/deploy/images/s4sk/bl31-s4sk.srec
tmp/deploy/images/s4sk/tee-s4sk.srec
tmp/deploy/images/s4sk/u-boot-elf-s4sk-v2020.10+gitAUTOINC+616f05eb5a-r0.srec
tmp/deploy/images/s4sk/u-boot-elf-s4sk.srec
tmp/deploy/images/s4sk/u-boot-elf.srec
The built Image directory is below.
https://hydrochoerus.com/rcar/s4sk/build/build-s4sk-gateway/tmp/deploy/images/s4sk/
The built directory is below.
https://hydrochoerus.com/rcar/s4sk/

How to flash/update the loader

Write the generated bl31-s4sk.srec, tee-s4sk.srec and u-boot-elf-s4sk.srec binaries to flash
See : R-Car/Boards/S4SK#How_to_flash.2Fupdate_the_loader

How to boot

Micro SD boot

WARNING! These steps will erase the Micro SD card completely. In short, all files will be lost.
In order to prepare you Micro SD card, follow these instructions on host machine:

  1. Partion your Micro SD card to set 1 partition and ID=83 (Linux)
    Make sure the Micro SD card doesn't contain any important files.
    $ fdisk /dev/mmcblk0 or /dev/sdb etc.
    -> d
    -> n
    -> p
    -> 1
    -> t
    -> 83
    
  2. Format this partition to ext4
    $ mkfs.ext4 /dev/mmcblk0p1
    
  3. Mount this partition on your host to any directory and upack the rcar-image-gateway-s4sk.tar.bz2 into mounted folder.
    $ mount /dev/mmcblk0p1 /mnt
    $ cd <your_yocto_build_directory>
    $ tar xjf ${WORK}/build-s4sk-gateway/tmp/deploy/images/s4sk/rcar-image-gateway-s4sk.tar.bz2  -C /mnt
    $ sync
    $ umount /mnt
    
    NOTE: probably you need to be a root user, hence use "sudo"
    Image and r8a779f0-s4sk.dtb are deployed under /mnt/boot/ directory
  4. Insert Micro SD card to S4 SK Mciro SD card slot(CN5)
  5. Set SW3
    SW3.1 : On
    SW3.2 : On
    SW3.3 : Off
    SW3.4 : On
    SW3.5 : Off
    SW3.6 : On
    SW3.7 : Off
    SW3.8 : Off
  6. Power ON (SW5)
    Ex)
    => setenv bootargs rw root=/dev/mmcblk0p1 rootwait ignore_loglevel cma=560M
    => ext4load mmc 0 0x48080000 /boot/Image; ext4load mmc 0 0x48000000 /boot/r8a779f0-s4sk.dtb; booti 0x48080000 - 0x48000000
    

NFS boot

  1. Install some packages for NFS boot on Host PC (See R-Car/Boards/Yocto-Gen3/v5.9.0#Loading_kernel_via_TFTP_and_rootfs_via_NFS)
  2. Decompress the rootfs on Host PC
    $ tar xjf ${WORK}/build-s4sk-gateway/tmp/deploy/images/s4sk/rcar-image-gateway-s4sk.tar.bz2  -C ${NFS_ROOT}
    
    Image and r8a779f0-s4sk.dtb are deployed under /mnt/boot/ directory
  3. Connect the Host PC to the S4SK IC101(TSN0) connector with a LAN cable
  4. Set SW3
    SW3.1 : On
    SW3.2 : On
    SW3.3 : Off
    SW3.4 : On
    SW3.5 : Off
    SW3.6 : On
    SW3.7 : Off
    SW3.8 : Off
  5. Power ON (SW5)
    Ex)
    => setenv ethaddr xx:xx:xx:xx:xx:xx <- MAC address [*]
    => setenv ipaddr 192.168.1.3
    => setenv serverip 192.168.1.2
    => setenv bootargs rw root=/dev/nfs nfsroot=192.168.1.2:/srv/tftp/s4/rootfs,nfsvers=3 ip=192.168.1.3:::::tsn0 ignore_loglevel cma=560M
    => setenv bootcmd 'tftp 0x48080000 {Your path}/boot/Image; tftp 0x48000000 {Your path}/boot/r8a779f0-s4sk.dtb; booti 0x48080000 - 0x48000000'
    => saveenv
    Saving Environment to SPIFlash... Erasing SPI flash...Writing to SPI flash...done
    OK
    => run bootcmd
    Using ethernet@e68c0000 device
    TFTP from server 192.168.1.2; our IP address is 192.168.1.2
    Filename '{Your path}/boot/Image'.
    Load address: 0x48080000
    Loading: ##########################################################
             ######################
    (snip)
             8.7 MiB/s
    done
    Bytes transferred = 33714688 (2027200 hex)
    Using ethernet@e68c0000 device
    TFTP from server 192.168.1.2; our IP address is 192.168.1.3
    Filename '{Your path}/boot/r8a779f0-s4sk.dtb'.
    Load address: 0x48000000
    Loading: ####
             6.6 MiB/s
    done
    Bytes transferred = 55591 (d927 hex)
    Moving Image from 0x48080000 to 0x48200000, end=4a2b0000
    ## Flattened Device Tree blob at 48000000
       Booting using the fdt blob at 0x48000000
       Loading Device Tree to 0000000057fef000, end 0000000057fff926 ... OK
    
    Starting kernel ...
    
[*]
Check the MAC address of the board using S4_StarterKit_Configurator.exe. See R-Car/Boards/S4SK#Tab_of_S4_Starter_Kit.
Please use the MAC address of TSN0

How to test some capabilities

Micro SD (CN5)

root@s4sk:~# dmesg|grep mmcblk
[    0.000000] Kernel command line: rw root=/dev/mmcblk0p1 rootwait ignore_loglevel cma=560M
[    1.934976] Waiting for root device /dev/mmcblk0p1...
[    1.984307] mmcblk0: mmc0:aaaa SL08G 7.40 GiB
[    1.988193]  mmcblk0: p1
[    2.223505] EXT4-fs (mmcblk0p1): recovery complete
[    2.225750] EXT4-fs (mmcblk0p1): mounted filesystem with ordered data mode. Opts: (null)
[    3.806413] EXT4-fs (mmcblk0p1): re-mounted. Opts: (null)
root@s4sk:~#
root@s4sk:~# mount /dev/mmcblk0p1 /mnt/

TSN0/1 (IC101/IC104)

Ex)
root@s4sk:~# ifconfig tsn0 192.168.10.100
[  743.368014] rswitch_get_phy_node PHY interface = sgmii
[  744.372046] libphy: rswitch_mii: probed
[  744.419085] mv88x2110 etha0:01: Firmware version 8.5.0.0
[  744.455718] mv88x2110 etha0:01: attached PHY driver [mv88x2110] (mii_bus:phy_addr=etha0:01, irq=POLL)
[  747.601932] renesas_eth_sw e68c0000.ethernet tsn0: Link is Up - 1Gbps/Full - flow control off
[  747.603126] IPv6: ADDRCONF(NETDEV_CHANGE): tsn0: link becomes ready
root@s4sk:~# ping 192.168.10.116
PING 192.168.10.116 (192.168.10.116): 56 data bytes
64 bytes from 192.168.10.116: seq=0 ttl=128 time=0.904 ms
64 bytes from 192.168.10.116: seq=1 ttl=128 time=0.639 ms
64 bytes from 192.168.10.116: seq=2 ttl=128 time=0.854 ms

UFS

root@s4sk:~# fdisk /dev/sda

Welcome to fdisk (util-linux 2.35.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

[ 2889.819979]  sda:

Command (m for help): n
Partition number (1-128, default 1): 1
First sector (256-31256570, default 256): 256
Last sector, +/-sectors or +/-size{K,M,G,T,P} (256-31256570, default 31256570): +64G

Created a new partition 1 of type 'Linux filesystem' and of size 64 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
[ 2917.736661]  sda: sda1
Syncing disks.

root@s4sk:~# mkfs.ext4 /dev/sda1
mke2fs 1.45.4 (23-Sep-2019)
Discarding device blocks: done
Creating filesystem with 16777216 4k blocks and 4194304 inodes
Filesystem UUID: bdf0481e-52a8-4562-a60c-24721db2ed66
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424

Allocating group tables: done
Writing inode tables: done
Creating journal (131072 blocks): done
Writing superblocks and filesystem accounting information: done

root@s4sk:~# mount /dev/sda1 /mnt/
[ 2940.602149] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null)
root@s4sk:~#

PCIe

See No.3 of Known issues & Restrictions chapter.

PCIe Root Complex(CN30) : SSD

Environment:

1) MZVPV512HDGL-0000
2) U.2 to M.2 M-Key NVME SSD and PCIe
3) Oculink to U.2 Cable
4) SATA/IDE AC Adoperq(Japanese site)
S4sk pcie nvme3.jpg
root@s4sk:~# mount /dev/nvme0n1p1 /mnt/
[   41.822014] EXT4-fs (nvme0n1p1): mounted filesystem with ordered data mode. Opts: (null)
root@s4sk:~# mount -t tmpfs -o size=400M tmpfs /tmp
root@s4sk:~# dd if=/dev/urandom of=/tmp/file bs=1M count=350
350+0 records in
350+0 records out
367001600 bytes (367 MB, 350 MiB) copied, 4.96337 s, 73.9 MB/s
root@s4sk:~# cp /tmp/file /mnt/
root@s4sk:~# cp /tmp/file /mnt/
root@s4sk:~# cmp /mnt/file /tmp/file
root@s4sk:~#

PCIe Root Complex(CN30) : LAN card

Environment:

PCI-e Network Card
root@s4sk:~# dmesg|grep e1000e
[    0.977043] e1000e: Intel(R) PRO/1000 Network Driver
[    0.977678] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[    0.986786] e1000e 0000:01:00.0: enabling device (0000 -> 0002)
[    1.025259] e1000e 0000:01:00.0: Interrupt Throttling Rate (ints/sec) set to dynamic conservative mode
[    1.088330] e1000e 0000:01:00.0 0000:01:00.0 (uninitialized): registered PHC clock
[    1.143115] e1000e 0000:01:00.0 eth0: (PCI Express:2.5GT/s:Width x1) 68:05:ca:30:bf:05
[    1.144182] e1000e 0000:01:00.0 eth0: Intel(R) PRO/1000 Network Connection
[    1.145073] e1000e 0000:01:00.0 eth0: MAC: 3, PHY: 8, PBA No: E46981-008
[    5.370228] e1000e 0000:01:00.0 enp1s0: renamed from eth0
root@s4sk:~#
root@s4sk:~# ifconfig enp1s0 192.168.10.100
root@s4sk:~# ping 192.168.10.101
PING 192.168.10.101 (192.168.10.101): 56 data bytes
64 bytes from 192.168.10.101: seq=0 ttl=128 time=1.095 ms
64 bytes from 192.168.10.101: seq=1 ttl=128 time=1.397 ms

PCIe Endpoint(CN31)

T.B.D

Thermal

root@s4sk:~# cat /sys/class/thermal/thermal_zone*/temp
39500
37500
37500
root@s4sk:~#

CPU Hotplug

root@s4sk:~# cat /sys/devices/system/cpu/online
0-7
root@s4sk:~# echo 0 > /sys/devices/system/cpu/cpu1/online
[  145.337609] IRQ227: set affinity failed(-22).
[  145.337764] CPU1: shutdown
[  145.338704] psci: CPU1 killed (polled 0 ms)
root@s4sk:~# echo 0 > /sys/devices/system/cpu/cpu1/online
root@s4sk:~# cat /sys/devices/system/cpu/offline
1
root@s4sk:~# echo 1 > /sys/devices/system/cpu/cpu1/online
[  169.401119] Detected VIPT I-cache on CPU1
[  169.401189] GICv3: raw_spin_lock_init for SGI
[  169.401202] GICv3: CPU1: found redistributor 100 region 0:0x00000000f1080000
[  169.401303] CPU1: Booted secondary processor 0x0000000100 [0x412fd050]
root@s4sk:~# cat /sys/devices/system/cpu/offline

root@s4sk:~#

Known issues & Restrictions

  1. [Known issue] Bitbake error messages when building SDK first time
    ERROR: When reparsing <build directory>../poky/meta/recipes-core/meta/meta-environment.bb:do_generate_content, the basehash value changed from 64c5dd461f406265715a6af027a37e78b6ea72e63aa576426a354b4becee57fc to af14637c6b64b6b26c9a37492a361cc15a15be8f5ffa7ceb06618ce994035e75. The metadata is not deterministic and this needs to be fixed.
    ERROR: The following commands may help:
    ERROR: $ bitbake meta-environment-s4sk -cdo_generate_content -Snone
    ERROR: Then:
    ERROR: $ bitbake meta-environment-s4sk -cdo_generate_content -Sprintdiff
    
    These error message are Poky 3.1.11 bug, it doesn't affect to build output.
    Ignore error messages.
  2. [Restriction] The "reboot" command is not completed. Therefore, press the power(SW5) or reset(SW4) button.
  3. [Known issue] PCIe 0ch(Root Complex) of SDK v3.16.0 may not work with some connected devices.
    If you see logs like the following, please apply this File:0001-pci-dwc-renesas-Change-to-mdelay-from-msleep.zip patch
    [    0.568766] Call trace:
    [    0.568790]  dump_backtrace+0x0/0x1a0
    [    0.568803]  show_stack+0x18/0x68
    [    0.568819]  dump_stack+0xd0/0x12c
    [    0.568834]  __schedule_bug+0x60/0x78
    [    0.568848]  __schedule+0x5cc/0x630
    [    0.568859]  schedule+0x70/0x108
    [    0.568869]  schedule_timeout+0x178/0x280
    [    0.568884]  msleep+0x30/0x48
    [    0.568900]  renesas_pcie_link_up+0xc8/0xf0
    
    How to apply patch
    Ex)
    $ cd ${WORK}/build-s4sk-gateway/tmp/work-shared/s4sk/kernel-source/
    $ git am <path>0001-pci-dwc-renesas-Change-to-mdelay-from-msleep.patch
    $ cd ${WORK}/build-s4sk-gateway
    $ bitbake linux-renesas -c compile -f; bitbake rcar-image-gateway
    


Q&A site

If you have any questions, feel free to post them here.
https://community.renesas.com/automotive/gateway/

FAQ site