diff --git a/Dockerfile b/Dockerfile index 2f8b967..9e8a6c5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/build_scripts/build_image.sh b/build_scripts/build_image.sh index 9c62195..1e54551 100644 --- a/build_scripts/build_image.sh +++ b/build_scripts/build_image.sh @@ -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 diff --git a/build_scripts/run_qemu.sh b/build_scripts/run_qemu.sh old mode 100644 new mode 100755 index c38d3f4..d965212 --- a/build_scripts/run_qemu.sh +++ b/build_scripts/run_qemu.sh @@ -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 @@ -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 \ @@ -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 diff --git a/copy_image.sh b/copy_image.sh new file mode 100755 index 0000000..3035216 --- /dev/null +++ b/copy_image.sh @@ -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 .