0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

NanoPi R5S FriendlyCoreのrootfsイメージをubuntu22.04ベースに更新

Last updated at Posted at 2023-09-23

NanoPi R5Sで動作するUbuntu(friendlycore)がubuntu 20.04(Focal)で、Ubuntu 22.04(Jammy)へはアップデートで可能であるが、初めからUbuntu22.04のイメージとしてインストールをするためにイメージの更新を行う。
(NanoPi R6Sのイメージを使ってみたが、起動時にエラー画面となり使えなかったので自前で作る事にした)

注:xrdpを導入してリモートディスクトップでログインできない問題があります。
  xrdpがカーネルの呼び出しを新機能で呼び出しているためのようです。
  ubuntu 20.04もダメでした。

1. 事前準備

1.1 ubuntuにpodmanのインストールとaarch64のコンテナが動作するように設定

パッケージののインストール
$ sudo apt install podman podman-docker binfmt-support qemu-user-static

podmanの動作環境は「/etc/containers」「/etc/cni」以下のファイルを編集して変更してください。

コンテナ内で別アーキテクチャのバイナリー動作させる設定
$ sudo podman run --rm --privileged docker.io/multiarch/qemu-user-static --reset -p yes -c yes

1.2 rootfsイメージ取得とコンテナ向けに変更

friendlycore-focalのrootfsイメージ取得
$ cd /tmp
$ curl -O http://112.124.9.243/dvdfiles/RK3568/rootfs/rootfs-friendlycore-focal-arm64.tgz
$ tar xvf rootfs-friendlycore-focal-arm64.tgz
rootfsイメージをpodmanコンテナ向けに変更
$ cd friendlycore-focal-arm64/rootfs/
$ tar cvzf ../../rootfs-friendlycore-focal-arm64-new.tgz .
podmanにコンテナイメージをロード
$ cd /tmp
$ sudo cat rootfs-friendlycore-focal-arm64.tgz | podman import - friendlycore_r5s:20.04

2. rootfsイメージの更新

friendlycoreコンテナ起動
$ sudo podman run -i -t -v /usr/bin/qemu-aarch64-static:/usr/bin/qemu-aarch64-static --name friendlycore_r5s friendlycore_r5s:20.04 bash
ubuntu 20.04のパッケージ最新化
$ sudo apt update
$ sudo apt -y upgrade
$ sudo apt -y autopurge

保留されたパッケージがある場合は、手動でインストールする。

ubuntu 22.04へメジャーアップデート
$ sudo  apt install -y update-manager-core
$ sudo do-release-upgrade --frontend=DistUpgradeViewNonInteractive

アップデートが終了したらコンテナを停止する。

$ sudo podman stop friendlycore_r5s
Android版のmke2fs入手
cd /tmp
curl -OL https://dl.google.com/android/repository/platform-tools-latest-linux.zip
unzip platform-tools-latest-linux.zip

ubuntu版のmke2fsでは「-E android_sparse」がエラーとなるため

コンテナイメージのエクスポート
$ mkdir /tmp/rootfs_new
$ cd /tmp/rootfs_new
$ sudo podman export  friendlycore_r5s | tar xvf -
rootfsイメージの作成
$ IMG_SIZE=$((($(du -s -B64M . | cut -f1) + 3) * 1024 * 1024 * 64)) ; \
IMG_BLK=$((${IMG_SIZE} / 4096)) ; \
INODE_SIZE=$(($(find . | wc -l) + 128)) ; \
sudo ../platform-tools/mke2fs -N ${INODE_SIZE} -E android_sparse -t ext4 -L rootfs -M /root -b 4096 -d . ../rootfs.img ${IMG_BLK} ; \
unset IMG_SIZE IMG_BLK INODE_SIZE

3. NanoPi R5Sのインストールイメージ作成

Build用のコンテナ作成
podman run -i -t --privileged -v /dev:/dev --name nanopi-r5s docker.io/ubuntu:jammy bash
コンテナ内 : パッケージインストール
# cd /root
# apt -y update
# apt -y upgrade
# apt-get install -y sudo wget
# wget https://raw.githubusercontent.com/friendlyarm/build-env-on-ubuntu-bionic/master/install.sh
# bash install.sh
# apt -y install imagemagick-6.q16
コンテナ内 : 作業環境をダウンロード
# git clone https://github.com/friendlyarm/sd-fuse_rk3568
コンテナ内 : カーネルソースをダウンロード
# cd sd-fuse_rk3568/
# git clone https://github.com/friendlyarm/kernel-rockchip --depth 1 -b nanopi5-v5.10.y_opt sd-fuse_rk3568/out/kernel-rk3568
コンテナ内 : ロゴイメージを変換
# convert files/logo.jpg -type truecolor /tmp/logo.bmp
# convert files/logo.jpg -type truecolor /tmp/logo_kernel.bmp
コンテナ内 : ビルドツールをダウンロード
# git clone https://github.com/friendlyarm/prebuilts.git -b master --depth 1
# tar xvf prebuilts/gcc-x64/toolchain-11.3-aarch64.tar.xz -C /
コンテナ内 : カーネルのビルド
# LOGO=/tmp/logo.bmp KERNEL_LOGO=/tmp/logo_kernel.bmp ./build-kernel.sh eflasher
コンテナ内 : カーネルモジュールのビルド
# LOGO=/tmp/logo.bmp KERNEL_LOGO=/tmp/logo_kernel.bmp ./build-kernel.sh friendlycore-focal-arm64
rootfsイメージの配置
$ sudo podman cp /tmp/rootfs.img nanopi-r5s:/root/fuse_rk3568/friendlycore-focal-arm64

カーネルビルド時にインストールイメージがダウンロードされるが、手動でダウンロードして展開も可能。

# cd /root/sd-fuse_rk3568
# curl -O http://112.124.9.243/dvdfiles/RK3568/images-for-eflasher/emmc-flasher-images.tgz
# tar xf emmc-flasher-images.tgz
# curl -O http://112.124.9.243/dvdfiles/RK3568/images-for-eflasher/friendlycore-focal-arm64-images.tgz
# tar xf friendlycore-focal-arm64-images.tgz
コンテナ内 : インストールイメージの作成
# ./mk-emmc-image.sh friendlycore-focal-arm64

以降はNanoPiのインストールツールにデータを持って行き書き込みと起動。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?