R-Car/Ubuntu(J)

From eLinux.org
< R-Car
Revision as of 17:41, 4 August 2020 by Tnx94241 (talk | contribs)
Jump to: navigation, search

R-Car Starter KitでUbuntu18を動かす

R-Car Starter Kit上で、Ubuntu18を動かすための手順を記載する。

用意するもの

  • HW
    • R-Car Starter Kit Pro/Premiere
      容量とM3/H3は問わない。今回の検証では、H3 WS3.0 8GB を使用。
    • microSDカード
      16GB/32GB で検証済み。
  • Yocto3.21でビルドしてできた成果物
    • Image
    • Image-r8a7795-h3ulcb-4x2g.dtb
    • core-image-minimal-h3ulcb.tar.bz2/core-image-weston-h3ulcb.tar.bz2
    • modules-h3ulcb.tgz
  • Ubuntu18のベースイメージ

以降、これらのファイルは ~/ubu ディレクトリ下に保存されている前提で説明を行う。

$ ls ~/ubu
Image
Image-r8a7795-h3ulcb-4x2g.dtb
core-image-minimal-h3ulcb.tar.bz2 ( or core-image-weston-h3ulcb.tar.bz2)
ubuntu-base-18.04.4-base-arm64.tar.gz
modules-h3ulcb.tgz

セットアップ

LinuxPC側の作業

  • microSDカードイメージの構築
  • 挿されたmicroSDカードは、/dev/sdbとして以降説明
    • microSDカードに何か入っている場合は、削除してから作業

1.パーティションの作成
2つのパーティションを作成
1つ目は2GB、2つ目は残りの容量を割り当て

$ sudo fdisk /dev/sdb

コマンド (mでヘルプ):n
Partition type
	p	primary (0 primary, 0 extended, 4 free)
	e	extended (container for logical partitions)
Select (default p):p
パーティション番号 (1-4, default 1):Enter keyを押す
First sector (2048-30375935, default 2048):Enter keyを押す
Last sector, +sectors or +size{K,M,G,T,P} (2048-30375935, default 30375935): +2G

コマンド (mでヘルプ):n
Partition type
	p	primary (1 primary, 0 extended, 3 free)
	e	extended (container for logical partitions)
Select (default p):p
パーティション番号 (2-4, default 1):Enter keyを押す
First sector (2048-30375935, default 2048):Enter keyを押す
Last sector, +sectors or +size{K,M,G,T,P} (2048-30375935, default 30375935):Enter keyを押す(*)
*32GBのmicroSDカード使用時も(*)のときにEnter keyを押す

コマンド (mでヘルプ):w

2.ファイルシステムの作成

$ sudo mkfs.ext4 /dev/sdb1
$ sudo mkfs.ext4 /dev/sdb2

3.microSDカードにファイルを展開
1つ目のパーティションにcore-image-minimal-h3ulcb.tar.bz2/core-image-weston-h3ulcb.tar.bz2、modules-h3ulcb.tgzを展開
2つ目のパーティションにubuntu-baase-18.04.4-base-arm64.tar.gz、modules-h3ulcb.tgzを展開

$ sudo mount /dev/sdb1 /mnt
$ cd /mnt
$ sudo tar -xvf ~/ubu/core-image-minimal-h3ulcb.tar.bz2(core-image-weston-h3ulcb.tar.bz2)
$ sudo tar -xvf ~/ubu/modules-h3ulcb.tgz
$ cd boot
$ sudo rm *
$ cp ~/ubu/Image ~/ubu/Image-r8a7795-h3ulcb-4x2g.dtb .
$ cd ../..
$ sudo umount /mnt
$ sudo mount /dev/sdb2 /mnt
$ cd /mnt
$ sudo tar -xvf ~/ubu/ubuntu-base-18.04.4-base-arm64.tar.gz
$ sudo tar -xvf ~/ubu/modules-h3ulcb.tgz
$ cd /
$ sudo umount /mnt
  • PC側の作業は終了。キャッシュをフラッシュしてmicroSDカードを抜く。

Starter Kit側の作業

  • 前章で作成したmicroSDカードをStarter Kitに挿して、Starter Kitの電源を入れる。
U-Boot 2018.09 (May 26 2020 - 10:27:40 +0000)

CPU:Renesas Electronics R8A7795 rev 3.0
Model:Renesas H3ULCB board based on r8a7795 ES2.0+ with 8GiB (4 x 2 GiB)
DRAM: 7.9 GiB
 ・・・
Hit any key to stop autoboot: 2 0 [Space key]
=> setenv bootargs 'root=/dev/mmcblk1p1 rootwait rw ip=192.168.0.111::192.168.0.1:255.255.255.0::eth0:off'
=> setenv bootcmd 'ext4load mmc 0:1 0x48000000 /boot/Image-r8a7795-h3ulcb-4x2g.dtb; ext4load mmc 0:1 0x48080000 /boot/Image; booti 0x48080000 - 0x48000000'
=> saveenv
Saving Environment to MMC... Writeng to MMC(1)... OK
=> run bootcmd
74202 bytes read in 3 ms (23.6 MiB/s)
18993664 bytes read in 208 ms (87.1 MiB/s)
## Flattened Device Tree blob at 48000000
・・・
Starting kernel ...
・・・
h3ulcb login: root
root@h3ulcb:~# cd /lib/modules/4.14.75-ltsi-yocto-standard/
root@h3ulcb:/lib/modules/4.14.75-ltsi-yocto-standard# depmod -a
root@h3ulcb:/lib/modules/4.14.75-ltsi-yocto-standard# cd /
root@h3ulcb:/# export TZ=JST-9
root@h3ulcb:/# date 0604011920     <-MMDDHHMMYYのフォーマット
Thu Jun 4 01:19:00 JST 2020
root@h3ulcb:/# mount /dev/mmcblk1p2 /mnt
root@h3ulcb:/# mount -t proc none /mnt/proc
root@h3ulcb:/# mount -t sysfs none /mnt/sys
root@h3ulcb:/# mount -t devtmpfs none /mnt/dev
root@h3ulcb:/# chroot /mnt /bin/bash
root@h3ulcb:/# echo nameserver 192.168.0.1 >/etc/resolv.conf
root@h3ulcb:/# apt-get update
root@h3ulcb:/# apt-get install -y apt-utils perl-modules
root@h3ulcb:/# apt-get install -y ubuntu-standard
root@h3ulcb:/# apt-get install -y vim net-tools ssh sudo tzdata rsyslog udev iputils-ping
・・・
Preconfiguring packages ...

Package configuration
Configuring tzdata
Please select the geographic area in which you live. Subsequent configuration questions will narrow
this down x x by presenting a list of cities, representing thee time zones in which they are located.
     「TimeZoneの設定用ウィンドウが開いたらAsia/Tokyoを選択」
root@h3ulcb:/# apt-get upgrade
root@h3ulcb:/# cd /etc/systemd/network
root@h3ulcb:/etc/systemd/network# ls
root@h3ulcb:/etc/systemd/network# cat >01-eth0.network
[Match]
Name=eth0

[Network]
DHCP=ipv4
     「書き終わったらCtrl+D」
root@h3ulcb:/etc/systemd/network# cd /etc
root@h3ulcb:/etc# vi shadow
     「root行を書き換え->PWなし」
root::18295:0:99999:7:::
root@h3ulcb:/etc# vi /etc/ssh/sshd_config
     「yesに書き換える」
permitRootlogin yes
root@h3ulcb:/etc# systemctl enable systemd-networkd
root@h3ulcb:/etc# cp /usr/share/systemd/tmp.mount /etc/systemd/system/tmp.mount
root@h3ulcb:/etc# systemctl enable tmp.mount
root@h3ulcb:/etc# systemctl enable systemd-resolved
root@h3ulcb:/etc# rm /etc/resolv.conf
root@h3ulcb:/etc# ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
root@h3ulcb:/etc# exit
root@h3ulcb:/# umount /mnt/proc
root@h3ulcb:/# umount /mnt/sys
root@h3ulcb:/# umount /mnt/dev
root@h3ulcb:/# umount /mnt
root@h3ulcb:/# reboot
U-Boot 2018.09 (May 26 2020 - 10:27:40 +0000)
・・・
Hit any key to stop autoboot: 2 0 [Space key]
=> setenv bootargs 'root=/dev/mmcblk1p2 rootwait rw'
=> saveenv
=> run bootcmd
Ubuntu 18.04.4 LTS localhost.localdomain ttySC0
localhost login: root
root@localhost:~# passwd root     <- PW設定
Enter new UNIX password : h3ulcb
Retry new UNIX password : h3ulcb
root@localhost:~# dpkg-reconfigure tzdata
     「TimeZoneの設定用ウィンドウが開いたらAsia/Tokyoを選択」
root@localhost:~# apt-get install -y language-pack-ja
root@localhost:~# update-locale LANG=ja_JP.UTF-8
root@localhost:~# poweroff

この後、電源ボタンを押すことで、Ubuntu18が起動する。