Skip to content

Tinker V

asusiot edited this page Aug 25, 2023 · 2 revisions

1. Build image

  1. Build environment:

    Linux Host PC Used as build/debug environment, 100GB free space on HDD is necessary
    OS Ubuntu 18.04 LTS or 20.04 LTS, 64 bit OS must be used
  2. Download the source code:

    $ repo init -u https://github.com/TinkerBoard/renesas-manifest.git -b linux5.10-rzfive
    $ repo sync
    
  3. Install and set up Docker enviornment

    $ sudo apt-get update
    $ sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent softwareproperties--common
    $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    $ sudo apt-key fingerprint 0EBFCD88
    $ sudo add-apt-repository "deb [arch=amd64] 
    https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
    $ sudo apt-get update
    $ sudo apt-get install docker-ce docker-ce-cli containerd.io
    $ sudo docker run hello-world
    

Reference: https://docs.docker.com/engine/install/ubuntu/

  1. Manage Docker as a non-root user

    $ sudo groupadd docker
    $ sudo usermod -aG docker $USER
    $ newgrp docker
    $ docker run hello-world
    
  2. Before starting the build, run the commands below on the Linux Host PC to install packages used for building the BSP.

    $ sudo apt-get update
    $ sudo apt-get install -y gawk wget git-core diffstat unzip texinfo gcc-multilib \
    build-essential chrpath socat cpio python python3 python3-pip python3-pexpect \
    xz-utils debianutils iputils-ping libsdl1.2-dev xterm p7zip-full sudo \
    libyaml-dev libssl-dev
    
  3. Go to the directory where you have downloaded the code base and execute the script. This will take a while to install the necessary packages on the host and build the Docker image.

    $ ./docker_builder/docker-builder-run.sh

  4. Run the commands below to start a build.
    $ ./build.sh

  5. After the build is successfully completed, it will show a similar output, and the command prompt will return. 圖片1

  6. The image generated will be located in the build/tmp/deploy/images directory.
    Image files for Tinker V

    Item File Name
    Linux Kernel Image-rzfive-tinker-v.bin
    Device tree file Image-r9a07g043f01-tinker-v.dtb
    root file system core-image-bsp-rzfive-tinker-v.tar.bz2
    Bootloader spl-rzfive-tinker-v.srec, fit-rzfive-tinker-v.srec
    Flash Writer Flash_Writer_SCIF_TINKER_V.mot

 

2. Flash image

2.1 Flash bootloader

  1. Booting Flash Writer

    1. Please set the SW1 dipswitches to ‘on-on-on-on’.

      SW1 Dip Switch Status
      SW1-1 ON
      SW1-2 ON
      SW1-3 ON
      SW1-4 ON

      圖片11

    2. Connect the power adapter to the Tinker V, and it’ll print the message of ‘ Load Program to System RAM’ on Tera Term terminal.

      2-1-2

    3. Below is an example using Tera Term. Open a “Send file” dialog by selecting “File” → “Send file” menu.

      圖片3

      Then, select the image Flash_Writer_SCIF_TINKER_V.mot and click “Open”.

      圖片4

      After binary download is completed, Flash Writer starts automatically and shows a message of Flash writer version on the terminal.

      圖片5

  2. Writing Bootloader

    1. Use “XLS2” command of Flash Writer to write boot loader binary files. This command is used for receiving binary data from the serial port and writing the data to a specified address of Flash ROM with information such as where the data should be loaded on the address of the main memory.

      圖片6

      Send the data of “spl-rzfive-tinker-v.srec” from terminal software after the message “please send !” is shown.

      The terminal will print the message of ‘Qspi Save Information’ once the binary is downloaded successfully.

      圖片7

      SPI Data Clear(H'FF) Check : H'00000000-0000FFFF,Clear OK?(y/n)
      

      Please press “y” when a message prompt asks to clear SPI data.

    2. Next, write another loader file by using XLS2 command again.

      圖片8

      Send the data of “fit-rzfive-tinker-v.srec” from terminal software after the message “please send !” is shown.

      The terminal will print the message of ‘Qspi Save Information’ once the binary is downloaded successfully.

      圖片9

      SPI Data Clear(H'FF) Check : H'00000000-0000FFFF,Clear OK?(y/n)
      

      Please press “y” when a message prompt asks to clear SPI data.

    3. After writing two loader files, turn off the power and set the SW1 dipswitches to ‘off-off-on-on’.

      SW1 Dip Switch Status
      SW1-1 OFF
      SW1-2 OFF
      SW1-3 ON
      SW1-4 ON

      圖片10

 

2.2 Create microSD card image

  1. Create a microSD card to boot Linux

    It is necessary to have a microSD card with over 4GB size to create a bootable SD card. You can use a Linux machine as Host PC to expand the kernel and the rootfs, using equipment such as USB card reader. Please format the SD card with the following steps first:

    1. When the microSD card is not connected to Linux Host PC:

      $ lsblk

      圖片2

    2. When the microSD card is connected to Linux Host PC with USB adapter

    3. Check the device name that is associated with the microSD card:

      $ lsblk

      圖片3

      The message above shows the MicroSD card associated with the /dev/sdd. Please be careful not to use the other device names in the following steps.

    4. Change the partition table

      microSD card needs two partitions as listed below:

      Type/Number Size File system Contents
      Primary#1 500MB (minimum 128MB) FAT32 Linux Kernel, Device Tree
      Primary#2 All remaining Ext4 root filesystem

      According to microSD block device, set the partition table using the fdisk command:

      In the example below, the microSD block device is /dev/sdd

      圖片4

      Then, check the partition table with the commands partprobe and fdisk -l /dev/sdd below:

      圖片5

    5. Format partitions with command mkfs.(with device format, in this case it’s mkfs.vfat and mkfs ext4)

      圖片6

    6. Write kernel and device tree

      $ mkdir tmp
      $ sudo mount /dev/sdd1 tmp
      $ sudo cp Image-rzfive-tinker-v.bin tmp/
      $ sudo cp Image-r9a07g043f01-tinker-v.dtb tmp/
      $ sudo umount /dev/sdd1
      
    7. Write root filesystem

      $ sudo mount /dev/sdd2 tmp
      $ sudo tar xf core-image-bsp-rzfive-tinker-v.tar.bz2 -C tmp/
      $ sudo umount /dev/sdd2
      $ rm -rf tmp
      
  2. Setting U-boot boot from microSD card

    Insert the micro SD card to Tinker V, and then plug the power supply. Press any key on the keyboard to stop autoboot from the serial console. If U-Boot is stopped, it displays a command line console.

    圖片7

    Please set these values and save them to the Flash ROM.

    => env default -a
    => saveenv
    => setenv bootargs 'root=/dev/mmcblk1p2 rootwait'
    => setenv bootcmd 'mmc dev 1;fatload mmc 1:1 0x48080000 Image-rzfive-tinker-v.bin;fatload mmc 1:1 0x48000000 Image-r9a07g043f01-tinker-v.dtb;booti 0x48080000 - 0x48000000'
    => saveenv
    

    圖片8

 

2.3 Flash image to eMMC

  1. Create a microSD card to boot linux for eMMC boot.

    Please refer to chapter 2.2. Create microSD card image for creating microSD image.

  2. After creating the microSD card image, copy a kernel image, a device tree file and rootfs to the second partition of the microSD card.

    e.g. microSD block device is /dev/sdd

    $ mkdir tmp
    $ sudo mount /dev/sdd2 tmp
    $ sudo cp Image-rzfive-tinker-v.bin tmp/home/root/
    $ sudo cp Image-r9a07g043f01-tinker-v.dtb tmp/home/root/
    $ sudo cp core-image-bsp-rzfive-tinker-v.tar.bz2 tmp/home/root/
    $ sudo umount /dev/sdd2
    $ rm -rf tmp
    
  3. Set Boot from microSD.

    Insert microSD card to Tinker V, then power on Tinker V. Press any key to stop autoboot from the serial console. If U-Boot is stopped, the terminal will stop show a command line console.

    圖片9

    Please set these values and save them to the Flash ROM.

    => env default -a
    => saveenv
    => setenv bootargs 'root=/dev/mmcblk1p2 rootwait'
    => setenv bootcmd 'mmc dev 1;fatload mmc 1:1 0x48080000 Image-rzfive-tinker-v.bin;fatload mmc 1:1 0x48000000 Image-r9a07g043f01-tinker-v.dtb;booti 0x48080000 - 0x48000000'
    => saveenv
    
    
  4. Power off Tinker V then Power on.

  5. After booting Linux, please login as root and create partitions on eMMC.

    圖片1

    圖片11

    Format eMMC.

    $ mkfs.ext4 /dev/mmcblk0p1
    $ mkfs.ext4 /dev/mmcblk0p2
    

    Write the kernel, the device tree.

    $ mount /dev/mmcblk0p1 /mnt/
    $ cp /home/root/Image-rzfive-tinker-v.bin /mnt/
    $ cp /home/root/Image-r9a07g043f01-tinker-v.dtb /mnt/
    $ umount /dev/mmcblk0p1
    

    Write the root filesystem.

    $ mount /dev/mmcblk0p2 /mnt/
    $ tar xf /home/root/core-image-bsp-rzfive-tinker-v.tar.bz2 -C /mnt/
    $ umount /dev/mmcblk0p2
    
  6. Setting U-boot for eMMC boot.

    Insert microSD card to Tinker V, then power on Tinker V. Press any key to stop autoboot from the serial console. If U-Boot is stopped, the terminal will stop show a command line console.

    圖片12

    Please set these values and save them to the Flash ROM.

    => env default -a
    => saveenv
    => setenv bootargs 'root=/dev/mmcblk0p2 rootwait'
    => setenv bootcmd 'mmc dev 1;ext4load mmc 0:1 0x48080000 Image-rzfive-tinker-v.bin;ext4load mmc 0:1 0x48000000 Image-r9a07g043f01-tinker-v.dtb;booti 0x48080000 - 0x48000000'
    => saveenv
    

    圖片13