SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Downloaden Sie, um offline zu lesen
QEMU
      in
Cross Building


Tetsuyuki Kobayashi

                      1
Who am I?

   20+ years involved in embedded systems
       10 years in real time OS, such as iTRON
       10 years in embedded Java Virtual Machine
       Now Gcc, Linux, QEMU, Android, …
   Blogs
       http://d.hatena.ne.jp/embedded/ (Personal)
       http://blog.kmckk.com/ (Corporate)
   Twitter
       @tetsu_koba
                                                     2
Today's topic

   About QEMU
   Native build vs Cross build
   Easy but too slow: building on
    system emulator
   Fast but too complex:
    Scratchbox
   Just simple : building on user
    mode QEMU

                                     3
Today's topic

   About QEMU
   Native build vs Cross build
   Easy but too slow: building on
    system emulator
   Fast but too complex:
    Scratchbox
   Just simple : building on user
    mode QEMU

                                     4
About QEMU

   http://wiki.qemu.org/
   QEMU is
    a generic and open source
    machine emulator
    and virtualizer.



                                5
QEMU is used …

   As virtualizer,
       KVM
       Xen
       VirtualBox
   Host CPU == Target CPU
       Today I don't focus on this.


                                       6
QEMU is used …

   As a system emulator,
   Host CPU != Target CPU
   Many open source projects such as:
       Android
       Maemo
       Symbian
       ARM port of Open Solaris
        ...
                                         7
QEMU has …

   Virtual disk.
   Many of virtual devices.
   Tiny Code Generator (TCG) to execute fast.
   Port redirector, Virtual network card.
   Bootloader to boot Linux kernel.
   gdbserver to connect gdb.
   …

                                                 8
User mode QEMU

   Emulate only user mode of linux.
   Not all system calls implemented,
    but enough for building.




                                        9
Today's topic

   About QEMU
   Native build vs Cross build
   Easy but too slow: building on
    system emulator
   Fast but too complex:
    Scratchbox
   Just simple : building on user
    mode QEMU

                                     10
Native build vs Cross build

   Native build – compile and run on
    the same machine.
   Cross build – compile and run on
    the different arch machine.
       Embedded system does not have enough
        CPU and memory for native building.


                                               11
Configure problem

   In many open source project
     $ configure
     $ make
     $ make install


    This suppose to be native build.
    Configure generate many small program
    and compile and run to check environment.

    This does not work on cross build.
Today's topic

   About QEMU
   Native build vs Cross build
   Easy but too slow: building on
    system emulator
   Fast but too complex:
    Scratchbox
   Just simple : building on user
    mode QEMU

                                     13
Building on system QEMU

   Apt-get works. Very easy to install
    compilers and libraries
   Too slow to compile
       Emulating the whole system including kernel.
       Cannot take advantage of SMP becase
        QEMU runs on single thread.
Today's topic

   About QEMU
   Native build vs Cross build
   Easy but too slow: building on
    system emulator
   Fast but too complex:
    Scratchbox
   Just simple : building on user
    mode QEMU

                                     15
ScratchBox

   Magical environment for cross
    building
   running ARM executable using user
    mode QEMU
   invoking the cross compiler on native



                                            16
ScratchBox 1

   http://www.scratchbox.org/
   Maemo project on Nokia
   mechanism
       chroot
       binfmt_misc
       scratch-box-aware tool chains




                                        17
ScratchBox 2

   http://www.freedesktop.org/wiki/Software/sbox2
   Another implementation of scratch box
   Tool chain agnostic
   Hosted by Freedesktop.org
   mechanism
       Wrap libc by PRELOAD magic of ld.so
       Hook system calls
       Insert QEMU when exec target binary
       Path name translation by LUA script      18
ScratchBox* is

   Pretty fast to compile
   Very hard to customize and
    troubleshooting




                                 19
Today's topic

   About QEMU
   Native build vs Cross build
   Easy but too slow: building on
    system emulator
   Fast but too complex:
    Scratchbox
   Just simple : building on user
    mode QEMU

                                     20
Let's try simpler way

   Just use user mode QEMU
   Use chroot and binfmt_misc
   Compiler running on QEMU, too




                                    21
binfmt_misc

   Mechanism to execute foreign executable.
   ex) Used in Wine for dos executable.

    $ cat /proc/sys/fs/binfmt_misc/qemu-arm
    enabled
    interpreter /usr/bin/qemu-arm-static
    flags: OC
    offset 0
    magic
    7f454c4601010100000000000000000002002800
    mask
    ffffffffffffff00fffffffffffffffffeffffff
    $

                                               22
Chroot

   Make dedicated directory tree
   Used for public ftp server to make
    sand box




                                         23
Static linked QEMU

   Nice idea to avoid conflict in chrooted target
    root file system
       Dynamically linked QEMU needs so many library
        files, which are likey conflict file names to target
        ones.
       Static linked QEMU is stand alone. Just copy one
        file to target root file system.
   I found this idea in rootstock script in Ubuntu


                                                               24
Just Try

   Make arm root file system by rootstock on
    Ubuntu 10.04
$ sudo apt-get install rootstock
$ mkdir arm-ubuntu
$ cd arm-ubuntu/
$ sudo rootstock --fqdn arm-lucid --login user
--password user
      It takes more than 10 minutes ...
$ mkdir root
$ cd root
$ sudo tar xvf ../armel-rootfs-201005031740.tgz


                                                  25
Just Try

$ ls
bin    dev home   lost+found   mnt   proc   sbin      srv   tmp   var
boot etc lib      media        opt   root   selinux   sys   usr
$ uname -m
x86_64




   $ sudo chroot . /bin/bash
   #
   # uname -m
   armv7l
                                                                        26
Build time comparison

   80min (on system QEMU)
   8min (user mode QEMU, make -j4)
   http://blog.kmckk.com/archives/2342452.html

    Not yet try on scratchbox.
    It would be faster if I could.



                                                  27
/proc

   ps command fails

# ps
Cannot find /proc/version - is /proc mounted?



   Don't worry. Mount /proc
# mount proc /proc -t proc
# ps
  PID TTY          TIME CMD
15434 ?        00:00:00 bash
15440 ?        00:00:00 ps
#

                                                28
Networking

   Failed to resolve name
   OK, just add ip address to /etc/hosts
    # cat /etc/hosts
    127.0.0.1 localhost ubuntu1004
    127.0.1.1 arm-lucid
    91.189.88.36 ports.ubuntu.com


    Then apt-get works. So far, it's enough.



                                               29
Distcc
   http://code.google.com/p/distcc/
   Preprocessing and linking locally.
   Compiling and assembling remotely.
   Invoke cross compiler remotely.
   Distcc will enhance build time.



                                         30
Q&A

   & Demo




      Thank you for listening!
      Any comments to blogs are welcome.
                                           31

Weitere ähnliche Inhalte

Was ist angesagt?

SR-IOV: The Key Enabling Technology for Fully Virtualized HPC Clusters
SR-IOV: The Key Enabling Technology for Fully Virtualized HPC ClustersSR-IOV: The Key Enabling Technology for Fully Virtualized HPC Clusters
SR-IOV: The Key Enabling Technology for Fully Virtualized HPC ClustersGlenn K. Lockwood
 
from Binary to Binary: How Qemu Works
from Binary to Binary: How Qemu Worksfrom Binary to Binary: How Qemu Works
from Binary to Binary: How Qemu WorksZhen Wei
 
XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...
XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...
XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...The Linux Foundation
 
Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)RuggedBoardGroup
 
Virtualization - Kernel Virtual Machine (KVM)
Virtualization - Kernel Virtual Machine (KVM)Virtualization - Kernel Virtual Machine (KVM)
Virtualization - Kernel Virtual Machine (KVM)Wan Leung Wong
 
エンジニアなら知っておきたい「仮想マシン」のしくみ (BPStudy38)
エンジニアなら知っておきたい「仮想マシン」のしくみ (BPStudy38)エンジニアなら知っておきたい「仮想マシン」のしくみ (BPStudy38)
エンジニアなら知っておきたい「仮想マシン」のしくみ (BPStudy38)Takeshi HASEGAWA
 
BKK16-315 Graphics Stack Update
BKK16-315 Graphics Stack UpdateBKK16-315 Graphics Stack Update
BKK16-315 Graphics Stack UpdateLinaro
 
ACRN vMeet-Up EU 2021 - shared memory based inter-vm communication introduction
ACRN vMeet-Up EU 2021 - shared memory based inter-vm communication introductionACRN vMeet-Up EU 2021 - shared memory based inter-vm communication introduction
ACRN vMeet-Up EU 2021 - shared memory based inter-vm communication introductionProject ACRN
 
Linux Kernel Module - For NLKB
Linux Kernel Module - For NLKBLinux Kernel Module - For NLKB
Linux Kernel Module - For NLKBshimosawa
 
Kernel Recipes 2019 - No NMI? No Problem! – Implementing Arm64 Pseudo-NMI
Kernel Recipes 2019 - No NMI? No Problem! – Implementing Arm64 Pseudo-NMIKernel Recipes 2019 - No NMI? No Problem! – Implementing Arm64 Pseudo-NMI
Kernel Recipes 2019 - No NMI? No Problem! – Implementing Arm64 Pseudo-NMIAnne Nicolas
 
Project ACRN hypervisor introduction
Project ACRN hypervisor introduction Project ACRN hypervisor introduction
Project ACRN hypervisor introduction Project ACRN
 
20111015 勉強会 (PCIe / SR-IOV)
20111015 勉強会 (PCIe / SR-IOV)20111015 勉強会 (PCIe / SR-IOV)
20111015 勉強会 (PCIe / SR-IOV)Kentaro Ebisawa
 
QEMU - Binary Translation
QEMU - Binary Translation QEMU - Binary Translation
QEMU - Binary Translation Jiann-Fuh Liaw
 

Was ist angesagt? (20)

SR-IOV: The Key Enabling Technology for Fully Virtualized HPC Clusters
SR-IOV: The Key Enabling Technology for Fully Virtualized HPC ClustersSR-IOV: The Key Enabling Technology for Fully Virtualized HPC Clusters
SR-IOV: The Key Enabling Technology for Fully Virtualized HPC Clusters
 
from Binary to Binary: How Qemu Works
from Binary to Binary: How Qemu Worksfrom Binary to Binary: How Qemu Works
from Binary to Binary: How Qemu Works
 
BusyBox for Embedded Linux
BusyBox for Embedded LinuxBusyBox for Embedded Linux
BusyBox for Embedded Linux
 
XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...
XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...
XPDDS17: Shared Virtual Memory Virtualization Implementation on Xen - Yi Liu,...
 
Embedded Hypervisor for ARM
Embedded Hypervisor for ARMEmbedded Hypervisor for ARM
Embedded Hypervisor for ARM
 
Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)
 
BeagleBone Black Bootloaders
BeagleBone Black BootloadersBeagleBone Black Bootloaders
BeagleBone Black Bootloaders
 
Virtualization - Kernel Virtual Machine (KVM)
Virtualization - Kernel Virtual Machine (KVM)Virtualization - Kernel Virtual Machine (KVM)
Virtualization - Kernel Virtual Machine (KVM)
 
Video Drivers
Video DriversVideo Drivers
Video Drivers
 
エンジニアなら知っておきたい「仮想マシン」のしくみ (BPStudy38)
エンジニアなら知っておきたい「仮想マシン」のしくみ (BPStudy38)エンジニアなら知っておきたい「仮想マシン」のしくみ (BPStudy38)
エンジニアなら知っておきたい「仮想マシン」のしくみ (BPStudy38)
 
BKK16-315 Graphics Stack Update
BKK16-315 Graphics Stack UpdateBKK16-315 Graphics Stack Update
BKK16-315 Graphics Stack Update
 
ACRN vMeet-Up EU 2021 - shared memory based inter-vm communication introduction
ACRN vMeet-Up EU 2021 - shared memory based inter-vm communication introductionACRN vMeet-Up EU 2021 - shared memory based inter-vm communication introduction
ACRN vMeet-Up EU 2021 - shared memory based inter-vm communication introduction
 
Linux Kernel Module - For NLKB
Linux Kernel Module - For NLKBLinux Kernel Module - For NLKB
Linux Kernel Module - For NLKB
 
U boot-boot-flow
U boot-boot-flowU boot-boot-flow
U boot-boot-flow
 
U-Boot - An universal bootloader
U-Boot - An universal bootloader U-Boot - An universal bootloader
U-Boot - An universal bootloader
 
Kernel Recipes 2019 - No NMI? No Problem! – Implementing Arm64 Pseudo-NMI
Kernel Recipes 2019 - No NMI? No Problem! – Implementing Arm64 Pseudo-NMIKernel Recipes 2019 - No NMI? No Problem! – Implementing Arm64 Pseudo-NMI
Kernel Recipes 2019 - No NMI? No Problem! – Implementing Arm64 Pseudo-NMI
 
Android 10
Android 10Android 10
Android 10
 
Project ACRN hypervisor introduction
Project ACRN hypervisor introduction Project ACRN hypervisor introduction
Project ACRN hypervisor introduction
 
20111015 勉強会 (PCIe / SR-IOV)
20111015 勉強会 (PCIe / SR-IOV)20111015 勉強会 (PCIe / SR-IOV)
20111015 勉強会 (PCIe / SR-IOV)
 
QEMU - Binary Translation
QEMU - Binary Translation QEMU - Binary Translation
QEMU - Binary Translation
 

Andere mochten auch

Andere mochten auch (8)

Android On Ubuntu for developer
Android On Ubuntu for developerAndroid On Ubuntu for developer
Android On Ubuntu for developer
 
Logging system of Android
Logging system of AndroidLogging system of Android
Logging system of Android
 
Froyo DalvikVM JIT
Froyo DalvikVM JITFroyo DalvikVM JIT
Froyo DalvikVM JIT
 
Reusing your existing software on Android
Reusing your existing software on AndroidReusing your existing software on Android
Reusing your existing software on Android
 
Using QEMU for cross development
Using QEMU for cross developmentUsing QEMU for cross development
Using QEMU for cross development
 
Android ipm 20110409
Android ipm 20110409Android ipm 20110409
Android ipm 20110409
 
Logging system of Android
Logging system of AndroidLogging system of Android
Logging system of Android
 
Tricky implementation of Go ARM soft float
Tricky implementation of Go ARM soft floatTricky implementation of Go ARM soft float
Tricky implementation of Go ARM soft float
 

Ähnlich wie QEMU in Cross building

Development platform virtualization using qemu
Development platform virtualization using qemuDevelopment platform virtualization using qemu
Development platform virtualization using qemuPremjith Achemveettil
 
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013dotCloud
 
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013Docker, Inc.
 
Rmll Virtualization As Is Tool 20090707 V1.0
Rmll Virtualization As Is Tool 20090707 V1.0Rmll Virtualization As Is Tool 20090707 V1.0
Rmll Virtualization As Is Tool 20090707 V1.0guest72e8c1
 
Unikernel User Summit 2015: Getting started in unikernels using the rump kernel
Unikernel User Summit 2015: Getting started in unikernels using the rump kernelUnikernel User Summit 2015: Getting started in unikernels using the rump kernel
Unikernel User Summit 2015: Getting started in unikernels using the rump kernelThe Linux Foundation
 
Introduction to Docker and Containers
Introduction to Docker and ContainersIntroduction to Docker and Containers
Introduction to Docker and ContainersDocker, Inc.
 
[CNCF TAG-Runtime 2022-10-06] Lima
[CNCF TAG-Runtime 2022-10-06] Lima[CNCF TAG-Runtime 2022-10-06] Lima
[CNCF TAG-Runtime 2022-10-06] LimaAkihiro Suda
 
Virtual Infrastructure
Virtual InfrastructureVirtual Infrastructure
Virtual InfrastructureBryan McLellan
 
the NML project
the NML projectthe NML project
the NML projectLei Yang
 
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo..."Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...Yandex
 
[Podman Special Event] Kubernetes in Rootless Podman
[Podman Special Event] Kubernetes in Rootless Podman[Podman Special Event] Kubernetes in Rootless Podman
[Podman Special Event] Kubernetes in Rootless PodmanAkihiro Suda
 
NFD9 - Matt Peterson, Data Center Operations
NFD9 - Matt Peterson, Data Center OperationsNFD9 - Matt Peterson, Data Center Operations
NFD9 - Matt Peterson, Data Center OperationsCumulus Networks
 
Qemu - Raspberry | while42 Singapore #2
Qemu - Raspberry | while42 Singapore #2Qemu - Raspberry | while42 Singapore #2
Qemu - Raspberry | while42 Singapore #2While42
 
Kvm and libvirt
Kvm and libvirtKvm and libvirt
Kvm and libvirtplarsen67
 
Running Applications on the NetBSD Rump Kernel by Justin Cormack
Running Applications on the NetBSD Rump Kernel by Justin Cormack Running Applications on the NetBSD Rump Kernel by Justin Cormack
Running Applications on the NetBSD Rump Kernel by Justin Cormack eurobsdcon
 
[OpenInfra Days Korea 2018] Day 2 - E4 - 딥다이브: immutable Kubernetes architecture
[OpenInfra Days Korea 2018] Day 2 - E4 - 딥다이브: immutable Kubernetes architecture[OpenInfra Days Korea 2018] Day 2 - E4 - 딥다이브: immutable Kubernetes architecture
[OpenInfra Days Korea 2018] Day 2 - E4 - 딥다이브: immutable Kubernetes architectureOpenStack Korea Community
 

Ähnlich wie QEMU in Cross building (20)

MIPS-X
MIPS-XMIPS-X
MIPS-X
 
Development platform virtualization using qemu
Development platform virtualization using qemuDevelopment platform virtualization using qemu
Development platform virtualization using qemu
 
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
 
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
 
RMLL / LSM 2009
RMLL / LSM 2009RMLL / LSM 2009
RMLL / LSM 2009
 
Rmll Virtualization As Is Tool 20090707 V1.0
Rmll Virtualization As Is Tool 20090707 V1.0Rmll Virtualization As Is Tool 20090707 V1.0
Rmll Virtualization As Is Tool 20090707 V1.0
 
Unikernel User Summit 2015: Getting started in unikernels using the rump kernel
Unikernel User Summit 2015: Getting started in unikernels using the rump kernelUnikernel User Summit 2015: Getting started in unikernels using the rump kernel
Unikernel User Summit 2015: Getting started in unikernels using the rump kernel
 
Introduction to Docker and Containers
Introduction to Docker and ContainersIntroduction to Docker and Containers
Introduction to Docker and Containers
 
.ppt
.ppt.ppt
.ppt
 
[CNCF TAG-Runtime 2022-10-06] Lima
[CNCF TAG-Runtime 2022-10-06] Lima[CNCF TAG-Runtime 2022-10-06] Lima
[CNCF TAG-Runtime 2022-10-06] Lima
 
Virtual Infrastructure
Virtual InfrastructureVirtual Infrastructure
Virtual Infrastructure
 
the NML project
the NML projectthe NML project
the NML project
 
Introducing Docker
Introducing DockerIntroducing Docker
Introducing Docker
 
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo..."Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
 
[Podman Special Event] Kubernetes in Rootless Podman
[Podman Special Event] Kubernetes in Rootless Podman[Podman Special Event] Kubernetes in Rootless Podman
[Podman Special Event] Kubernetes in Rootless Podman
 
NFD9 - Matt Peterson, Data Center Operations
NFD9 - Matt Peterson, Data Center OperationsNFD9 - Matt Peterson, Data Center Operations
NFD9 - Matt Peterson, Data Center Operations
 
Qemu - Raspberry | while42 Singapore #2
Qemu - Raspberry | while42 Singapore #2Qemu - Raspberry | while42 Singapore #2
Qemu - Raspberry | while42 Singapore #2
 
Kvm and libvirt
Kvm and libvirtKvm and libvirt
Kvm and libvirt
 
Running Applications on the NetBSD Rump Kernel by Justin Cormack
Running Applications on the NetBSD Rump Kernel by Justin Cormack Running Applications on the NetBSD Rump Kernel by Justin Cormack
Running Applications on the NetBSD Rump Kernel by Justin Cormack
 
[OpenInfra Days Korea 2018] Day 2 - E4 - 딥다이브: immutable Kubernetes architecture
[OpenInfra Days Korea 2018] Day 2 - E4 - 딥다이브: immutable Kubernetes architecture[OpenInfra Days Korea 2018] Day 2 - E4 - 딥다이브: immutable Kubernetes architecture
[OpenInfra Days Korea 2018] Day 2 - E4 - 딥다이브: immutable Kubernetes architecture
 

Mehr von Tetsuyuki Kobayashi

Try new transport protocol SRT (ver. 2)
Try new transport protocol SRT  (ver. 2)Try new transport protocol SRT  (ver. 2)
Try new transport protocol SRT (ver. 2)Tetsuyuki Kobayashi
 
Raspberry Pi Zero とカメラモジュールで作るライブ配信実験機
Raspberry Pi Zero とカメラモジュールで作るライブ配信実験機Raspberry Pi Zero とカメラモジュールで作るライブ配信実験機
Raspberry Pi Zero とカメラモジュールで作るライブ配信実験機Tetsuyuki Kobayashi
 
WebOS Open Source Edition を試してみた
WebOS Open Source Edition を試してみたWebOS Open Source Edition を試してみた
WebOS Open Source Edition を試してみたTetsuyuki Kobayashi
 
Linuxのユーザーランドをinitから全てまるごとgolangで書く
Linuxのユーザーランドをinitから全てまるごとgolangで書くLinuxのユーザーランドをinitから全てまるごとgolangで書く
Linuxのユーザーランドをinitから全てまるごとgolangで書くTetsuyuki Kobayashi
 
組み込みLinuxでのGolangのススメ(Go con版)
組み込みLinuxでのGolangのススメ(Go con版)組み込みLinuxでのGolangのススメ(Go con版)
組み込みLinuxでのGolangのススメ(Go con版)Tetsuyuki Kobayashi
 
組み込みLinuxでのGolangのススメ
組み込みLinuxでのGolangのススメ組み込みLinuxでのGolangのススメ
組み込みLinuxでのGolangのススメTetsuyuki Kobayashi
 
Simple and efficient way to get the last log using MMAP
Simple and efficient way to get the last log using MMAPSimple and efficient way to get the last log using MMAP
Simple and efficient way to get the last log using MMAPTetsuyuki Kobayashi
 
Basic of virtual memory of Linux
Basic of virtual memory of LinuxBasic of virtual memory of Linux
Basic of virtual memory of LinuxTetsuyuki Kobayashi
 
ADB(Android Debug Bridge): How it works?
ADB(Android Debug Bridge): How it works?ADB(Android Debug Bridge): How it works?
ADB(Android Debug Bridge): How it works?Tetsuyuki Kobayashi
 
Inter-process communication of Android
Inter-process communication of AndroidInter-process communication of Android
Inter-process communication of AndroidTetsuyuki Kobayashi
 
Android is NOT just 'Java on Linux'
Android is NOT just 'Java on Linux'Android is NOT just 'Java on Linux'
Android is NOT just 'Java on Linux'Tetsuyuki Kobayashi
 

Mehr von Tetsuyuki Kobayashi (20)

some topic of ffmpeg
some topic of ffmpeg some topic of ffmpeg
some topic of ffmpeg
 
Try new transport protocol SRT (ver. 2)
Try new transport protocol SRT  (ver. 2)Try new transport protocol SRT  (ver. 2)
Try new transport protocol SRT (ver. 2)
 
Try new transport protocol SRT
Try new transport protocol SRTTry new transport protocol SRT
Try new transport protocol SRT
 
Raspberry Pi Zero とカメラモジュールで作るライブ配信実験機
Raspberry Pi Zero とカメラモジュールで作るライブ配信実験機Raspberry Pi Zero とカメラモジュールで作るライブ配信実験機
Raspberry Pi Zero とカメラモジュールで作るライブ配信実験機
 
WebOS Open Source Edition を試してみた
WebOS Open Source Edition を試してみたWebOS Open Source Edition を試してみた
WebOS Open Source Edition を試してみた
 
Linuxのユーザーランドをinitから全てまるごとgolangで書く
Linuxのユーザーランドをinitから全てまるごとgolangで書くLinuxのユーザーランドをinitから全てまるごとgolangで書く
Linuxのユーザーランドをinitから全てまるごとgolangで書く
 
組み込みLinuxでのGolangのススメ(Go con版)
組み込みLinuxでのGolangのススメ(Go con版)組み込みLinuxでのGolangのススメ(Go con版)
組み込みLinuxでのGolangのススメ(Go con版)
 
組み込みLinuxでのGolangのススメ
組み込みLinuxでのGolangのススメ組み込みLinuxでのGolangのススメ
組み込みLinuxでのGolangのススメ
 
ARM 64bit has come!
ARM 64bit has come!ARM 64bit has come!
ARM 64bit has come!
 
Virtual memory 20070222-en
Virtual memory 20070222-enVirtual memory 20070222-en
Virtual memory 20070222-en
 
Simple and efficient way to get the last log using MMAP
Simple and efficient way to get the last log using MMAPSimple and efficient way to get the last log using MMAP
Simple and efficient way to get the last log using MMAP
 
Tips of Malloc & Free
Tips of Malloc & FreeTips of Malloc & Free
Tips of Malloc & Free
 
Basic of virtual memory of Linux
Basic of virtual memory of LinuxBasic of virtual memory of Linux
Basic of virtual memory of Linux
 
Patch101
Patch101Patch101
Patch101
 
ADB(Android Debug Bridge): How it works?
ADB(Android Debug Bridge): How it works?ADB(Android Debug Bridge): How it works?
ADB(Android Debug Bridge): How it works?
 
Tweaking Google TV emulator
Tweaking Google TV emulatorTweaking Google TV emulator
Tweaking Google TV emulator
 
Inter-process communication of Android
Inter-process communication of AndroidInter-process communication of Android
Inter-process communication of Android
 
Android is NOT just 'Java on Linux'
Android is NOT just 'Java on Linux'Android is NOT just 'Java on Linux'
Android is NOT just 'Java on Linux'
 
Init of Android
Init of AndroidInit of Android
Init of Android
 
Let's play with Goldfish
Let's play with GoldfishLet's play with Goldfish
Let's play with Goldfish
 

QEMU in Cross building

  • 1. QEMU in Cross Building Tetsuyuki Kobayashi 1
  • 2. Who am I?  20+ years involved in embedded systems  10 years in real time OS, such as iTRON  10 years in embedded Java Virtual Machine  Now Gcc, Linux, QEMU, Android, …  Blogs  http://d.hatena.ne.jp/embedded/ (Personal)  http://blog.kmckk.com/ (Corporate)  Twitter  @tetsu_koba 2
  • 3. Today's topic  About QEMU  Native build vs Cross build  Easy but too slow: building on system emulator  Fast but too complex: Scratchbox  Just simple : building on user mode QEMU 3
  • 4. Today's topic  About QEMU  Native build vs Cross build  Easy but too slow: building on system emulator  Fast but too complex: Scratchbox  Just simple : building on user mode QEMU 4
  • 5. About QEMU  http://wiki.qemu.org/  QEMU is a generic and open source machine emulator and virtualizer. 5
  • 6. QEMU is used …  As virtualizer,  KVM  Xen  VirtualBox  Host CPU == Target CPU  Today I don't focus on this. 6
  • 7. QEMU is used …  As a system emulator,  Host CPU != Target CPU  Many open source projects such as:  Android  Maemo  Symbian  ARM port of Open Solaris  ... 7
  • 8. QEMU has …  Virtual disk.  Many of virtual devices.  Tiny Code Generator (TCG) to execute fast.  Port redirector, Virtual network card.  Bootloader to boot Linux kernel.  gdbserver to connect gdb.  … 8
  • 9. User mode QEMU  Emulate only user mode of linux.  Not all system calls implemented, but enough for building. 9
  • 10. Today's topic  About QEMU  Native build vs Cross build  Easy but too slow: building on system emulator  Fast but too complex: Scratchbox  Just simple : building on user mode QEMU 10
  • 11. Native build vs Cross build  Native build – compile and run on the same machine.  Cross build – compile and run on the different arch machine.  Embedded system does not have enough CPU and memory for native building. 11
  • 12. Configure problem  In many open source project $ configure $ make $ make install This suppose to be native build. Configure generate many small program and compile and run to check environment. This does not work on cross build.
  • 13. Today's topic  About QEMU  Native build vs Cross build  Easy but too slow: building on system emulator  Fast but too complex: Scratchbox  Just simple : building on user mode QEMU 13
  • 14. Building on system QEMU  Apt-get works. Very easy to install compilers and libraries  Too slow to compile  Emulating the whole system including kernel.  Cannot take advantage of SMP becase QEMU runs on single thread.
  • 15. Today's topic  About QEMU  Native build vs Cross build  Easy but too slow: building on system emulator  Fast but too complex: Scratchbox  Just simple : building on user mode QEMU 15
  • 16. ScratchBox  Magical environment for cross building  running ARM executable using user mode QEMU  invoking the cross compiler on native 16
  • 17. ScratchBox 1  http://www.scratchbox.org/  Maemo project on Nokia  mechanism  chroot  binfmt_misc  scratch-box-aware tool chains 17
  • 18. ScratchBox 2  http://www.freedesktop.org/wiki/Software/sbox2  Another implementation of scratch box  Tool chain agnostic  Hosted by Freedesktop.org  mechanism  Wrap libc by PRELOAD magic of ld.so  Hook system calls  Insert QEMU when exec target binary  Path name translation by LUA script 18
  • 19. ScratchBox* is  Pretty fast to compile  Very hard to customize and troubleshooting 19
  • 20. Today's topic  About QEMU  Native build vs Cross build  Easy but too slow: building on system emulator  Fast but too complex: Scratchbox  Just simple : building on user mode QEMU 20
  • 21. Let's try simpler way  Just use user mode QEMU  Use chroot and binfmt_misc  Compiler running on QEMU, too 21
  • 22. binfmt_misc  Mechanism to execute foreign executable.  ex) Used in Wine for dos executable.  $ cat /proc/sys/fs/binfmt_misc/qemu-arm enabled interpreter /usr/bin/qemu-arm-static flags: OC offset 0 magic 7f454c4601010100000000000000000002002800 mask ffffffffffffff00fffffffffffffffffeffffff $ 22
  • 23. Chroot  Make dedicated directory tree  Used for public ftp server to make sand box 23
  • 24. Static linked QEMU  Nice idea to avoid conflict in chrooted target root file system  Dynamically linked QEMU needs so many library files, which are likey conflict file names to target ones.  Static linked QEMU is stand alone. Just copy one file to target root file system.  I found this idea in rootstock script in Ubuntu 24
  • 25. Just Try  Make arm root file system by rootstock on Ubuntu 10.04 $ sudo apt-get install rootstock $ mkdir arm-ubuntu $ cd arm-ubuntu/ $ sudo rootstock --fqdn arm-lucid --login user --password user It takes more than 10 minutes ... $ mkdir root $ cd root $ sudo tar xvf ../armel-rootfs-201005031740.tgz 25
  • 26. Just Try $ ls bin dev home lost+found mnt proc sbin srv tmp var boot etc lib media opt root selinux sys usr $ uname -m x86_64 $ sudo chroot . /bin/bash # # uname -m armv7l 26
  • 27. Build time comparison  80min (on system QEMU)  8min (user mode QEMU, make -j4)  http://blog.kmckk.com/archives/2342452.html Not yet try on scratchbox. It would be faster if I could. 27
  • 28. /proc  ps command fails  # ps Cannot find /proc/version - is /proc mounted?   Don't worry. Mount /proc # mount proc /proc -t proc # ps PID TTY TIME CMD 15434 ? 00:00:00 bash 15440 ? 00:00:00 ps # 28
  • 29. Networking  Failed to resolve name  OK, just add ip address to /etc/hosts # cat /etc/hosts 127.0.0.1 localhost ubuntu1004 127.0.1.1 arm-lucid 91.189.88.36 ports.ubuntu.com Then apt-get works. So far, it's enough. 29
  • 30. Distcc  http://code.google.com/p/distcc/  Preprocessing and linking locally.  Compiling and assembling remotely.  Invoke cross compiler remotely.  Distcc will enhance build time. 30
  • 31. Q&A  & Demo Thank you for listening! Any comments to blogs are welcome. 31