LoginSignup
0
1

More than 3 years have passed since last update.

仮想RaspberryPi 64bitとローカルRaspberryPiの相互運用テスト(作業中)

Last updated at Posted at 2019-07-26

1.やりたいこと

RaspberryPi3B+にRaspbian Busterを入れて、外部のリポジトリと接続する。
仮想RPi4とリアルRPiのデータ交換 (2).png

2.なぜ?

直前のエントリーでAWSに仮想RaspberryPi4用の環境を作成した。
Debian Buster armhf のOSイメージをAWSの仮想マシンで作る
クラウドやリモートリポジトリ経由でローカルにコピーして、実環境で動くことを確認したい。

3.RaspberryPi3B+のヘッドレスセットアップ

RaspberryPi4は未だ技適が通らないのか、日本では発売されていない。
3B+とBusterの環境にして実行する。

本家は重いのでミラーからダウンロードする。
http://ftp.jaist.ac.jp/pub/raspberrypi/raspbian/images/
balenaEtcherでSDを書き込んで、ヘッドレスでセットアップします。
SDカードのbootパーティションに以下のファイルを作成。

wpa_supplicant.conf
country=JP
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
  ssid="SSID名"
  psk="暗号キー"
}

空のsshファイルを作って保存。

RaspberryPiにSDカードを入れて再起動。
ssh pi@raspberrypi.local

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@       WARNING: POSSIBLE DNS SPOOFING DETECTED!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The ECDSA host key for raspberrypi.local has changed,
and the key for the corresponding IP address fe80::6740:35ec:8c5e:526c%en3
is unknown. This could either mean that
DNS SPOOFING is happening or the IP address for the host
and its host key have changed at the same time.

再セットアップでホストキーが変更されたときに出るやつですね。

ssh-keygen -R raspberrypi.local
ssh pi@raspberrypi.local

で、復活して接続。
デフォルトのパスワードですので、raspberryで接続できます。

4.Dockerインストールとテスト

$ sudo apt-get update
$ curl -sSL https://get.docker.com | sh
$ sudo usermod -aG docker pi
$ docker -v
Docker version 19.03.1, build 74b1e89

Docker 19.03が入りました。
Docker Hub上のリポジトリに接続するため、ログイン設定します。

$ docker login
Username:_username_
Passwork:_password_

5.OpenCVのDockerイメージを仮想マシンでBuildする

いつも手こずるOpenCVをDockerでインストールすることにします。
こちらを参考にしました。
ラズパイ向けのOpenCVを、x86_64機のDockerでビルド

(Dockerでやってしまうと、仮想マシンまで作った意味はないのですが、Dockerのテストということで)

仮想マシンを起動してdockerとgitをインストール
$qemu-system-arm -M virt -m 4096 -smp 4 \
  -kernel vmlinuz-4.19.0-5-armmp-lpae \
  -initrd initrd.img-4.19.0-5-armmp-lpae \
  -append 'root=/dev/vda2' \
  -drive if=none,file=hda.qcow2,format=qcow2,id=hd \ 
  -device virtio-blk-device,drive=hd \
  -netdev user,id=mynet \
  -device virtio-net-device,netdev=mynet \
  -nographic

$ sudo apt-get update
$ sudo apt-get curl
$ curl -sSL https://get.docker.com | sh
$ sudo usermod -aG docker pi
$ docker -v
$ sudo apt-get install git
$ exit

一度抜けてログインし直し。
Dockerfileをそのままbuildしてみます。

Dockerfileをpullしてbuild
$ git clone https://github.com/mt08xx/opencv-rpi-buildenv-docker
$ cd opencv-rpi-buildenv-docker/
$ docker build . -t mt08/opencv-rpi-buildenv

作業中。
https://qiita.com/mt08/items/51a2187076ddca0db7b0
何か重大な手違いがありそう。
中断して作業中。

ubuntu18仮想マシンで実行してみる

Docker19が入っているマシンがあったので、そこで同様のコマンドを実行してみました。

Dockerfileをpullしてbuild
$ git clone https://github.com/mt08xx/opencv-rpi-buildenv-docker
$ cd opencv-rpi-buildenv-docker/
$ docker build . -t mt08/opencv-rpi-buildenv
Sending build context to Docker daemon  74.24kB
Step 1/2 : FROM resin/rpi-raspbian:buster
buster: Pulling from resin/rpi-raspbian
3d8ce33ab37f: Pull complete 
828760d871d6: Pull complete 
b290b33db697: Pull complete 
fba0d77b4f00: Pull complete 
9f4efec7c2c2: Pull complete 
4a291ed3bea6: Pull complete 
83914dc3ce7f: Pull complete 
8a47a86bb40e: Pull complete 
1251d57a90b8: Pull complete 
0e69c6d495df: Pull complete 
aaf87287f5f3: Pull complete 
93536d0930f5: Pull complete 
Digest: sha256:75a902c9eae972028d7163248934de915a82100152f197a014cbf2fb0981290c
Status: Downloaded newer image for resin/rpi-raspbian:buster
# Executing 1 build trigger
 ---> Running in a8c03d43a75f
standard_init_linux.go:211: exec user process caused "exec format error"
The command '/bin/sh -c cat /.resin/deprecation-warning' returned a non-zero code: 1

ラズパイのイメージが動かない?

docker run --name rpi-raspbian-stretch -ti --privileged resin/rpi-raspbian:stretch /bin/bash

これも同様のエラーが出ますね。

ラズパイのイメージを持ってきてるのがまずいようです。
debianで作れば問題ないので、自分でdocker fileを書いてみます。

FROM debian:buster

だけのものを作って試してみます。

0
1
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
1