Skip to content

Commit

Permalink
Added support for arm qemu run
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoguerri committed Sep 21, 2019
1 parent fb358af commit cefc14f
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 9 deletions.
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@ RUN apt-get update && \
g++ \
gcc \
make \
qemu-system-arm \
qemu-kvm \
texinfo \
vim \
wget \
bridge-utils \
isc-dhcp-client \
libcap2-bin
libcap2-bin \
sudo

ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8

RUN echo "dev ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8
Expand Down
4 changes: 2 additions & 2 deletions build_scripts/build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ set -e
[[ $(whoami) == "dev" ]] || echo "This script should run as user dev!"

virtualenv -p /usr/bin/python2.7 ${HOME}/p27
cd ${HOME}/openembedded/openembedded-core
source ${HOME}/p27/bin/activate
cd ~dev/openembedded/openembedded-core
source ~dev/p27/bin/activate
source oe-init-build-env /home/dev/openembedded/build

build=0
Expand Down
39 changes: 33 additions & 6 deletions build_scripts/run_qemu.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
#!/bin/sh
set -eux
home=~dev
build_root=${home}/openembedded/openembedded-core/build/tmp-glibc/deploy/images/qemux86-64
#!/bin/bash
#set -e


# Docker container must run with NET_ADMIN capabilities, and user inside the container must
platform=${1}

case "$platform" in
x86_64 ) echo "Starting qemu x86_64"; build=1;;
arm ) echo "Starting qemu arm"; build=0;;
* ) echo "Invalid platform"; exit 1;;
esac

# Docker container must run with NET_ADMIN capabilities, and user inside the container must
# be root or have NET_ADMIN capability assigned to /bin/ip

# sudo docker run -u root --cap-add=NET_ADMIN --device /dev/net/tun:/dev/net/tun -ti marcoguerri/oe_env
Expand All @@ -23,8 +29,9 @@ ip link set down dev tap0 && ip link delete tap0 || true
ip tuntap add tap0 mode tap
brctl addif br0 tap0

if [[ ${platform} == "x86_64" ]]; then
(
cd ${build_root}
cd ~dev/openembedded/openembedded-core/build/tmp-glibc/deploy/images/qemux86-64
qemu-system-x86_64 -kernel bzImage \
--append "console=ttyS0 root=/dev/vda" \
-nographic \
Expand All @@ -33,4 +40,24 @@ brctl addif br0 tap0
-net nic,model=virtio,macaddr=00:11:22:33:44:55 \
-net tap,ifname=tap0
)
else
(
deploy_dir=~dev/openembedded/build/tmp-glibc/deploy/images/raspberrypi2/
# Note: all the append kernel command line parameters effectively
# overwrite what is written in cmdline.txt, which is ignored by qemu.

# rootdelay is necessary because there seems to be a race condition between
# the initialization of the partitions from the virtualized sdcard controller
# and the kernel trying to mount the root device.
qemu-system-arm -M raspi2 \
-dtb ${deploy_dir}/bcm2709-rpi-2-b.dtb \
-sd ${deploy_dir}/core-image-minimal-raspberrypi2.rpi-sdimg \
-kernel ${deploy_dir}/zImage \
-m 1G \
-smp 4 \
-serial mon:stdio \
-nographic \
-append "rw earlyprintk loglevel=8 console=ttyAMA0 dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootdelay=5"
)
fi

6 changes: 6 additions & 0 deletions copy_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

set -eu

[[ $(whoami) == "root" ]] || ( echo "Please run this script as root" && exit 1)
docker cp -L oe_build:/home/dev/openembedded/build/tmp-glibc/deploy/images/raspberrypi2/core-image-minimal-raspberrypi2.rpi-sdimg .

0 comments on commit cefc14f

Please sign in to comment.