31
Kyoto Microcomputer Co., Ltd. 1 Using QEMU for Cross Development Tetsuyuki Kobayashi

Using QEMU for cross development

Embed Size (px)

DESCRIPTION

Developing embedded systems requires physical board. Boost your project using QEMU system emulator.

Citation preview

Page 1: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 1

Using QEMU for

Cross Development

Tetsuyuki Kobayashi

Page 2: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 2

Real system : System emulator =

Atoms : Bits

This is what I impress today.Take advantage of 'bits'!

Let's use QEMU to boost your project

”Being Digital” by Nicholas Negroponte http://archives.obs-us.com/obs/english/books/nn/ch01c01.htm

Page 3: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 3

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

Page 4: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 4

Today's topic

What is QEMU Atoms vs Bits QEMU is NOT good for … QEMU is GOOD for … Practices (from KMC blog)

Page 5: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 5

About QEMU

http://wiki.qemu.org/

QEMU is a generic and open source machine emulatorand virtualizer.

Page 6: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 6

QEMU is used …

As virtualizer, KVM Xen VirtualBox

Host CPU == Target CPU Today I don't focus on this.

Page 7: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 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 ...

Page 8: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 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. ...

Page 9: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 9

QEMU is *NOT* …

Cycle accurate simulator (which is usually used for H/W development).

So QEMU is not good for developing device driver which have to take account of accurate cycles.

Page 10: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 10

License

The whole QEMU is GPL. The QEMU virtual CPU core library (libqemu.a)

is LGPL. TCG is BSD like license. Each virtual hardware has their own license.

Check the source file.

QEMU is a trademark of Fabrice Bellard.

Page 11: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 11

Atoms vs Bits

Developing embedded system require real system (= the physical board). Because the GOAL is there.

System emulator is good complement for it.

System emulator is 'bits', so free from any physical limitation.

I mention QEMU for the system emulator.

Page 12: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 12

How to get

The physical board needs money to buy. Some special board can not buy because of dis-

continue.

QEMU does not need any money to get.

Page 13: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 13

Footprint

The physical board needs space to put. No space for a dozen of boards on your desk.

QEMU does not need any desk space. (but disk space.)

Page 14: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 14

Portability (in Physical)

Bring the physical board and set it up is a work. The board might be crash in trouble.

You are happy to bring QEMU in your USB key. Or you can transfer it via broad band network.

Page 15: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 15

Duplication & Distribution

The physical board can not be duplicate.

You can duplicate your QEMU as many as you like and distribute them. You might ask for experts to take a look your

problem on QEMU.

Page 16: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 16

QEMU is *NOT* good for

Performance evaluation. Especially SMP mode.

SMP is simulated in single thread, not parallel. Deadly slow.

Interesting session about QEMU multi core Japan Technical Jamboree24, Dec 2008 CELF_JTJ24_qemu-multicore_English.pdf http://tree.celinuxforum.org/CelfPubWiki/JapanTechnicalJamboree24

Page 17: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 17

QEMU is *NOT* good for

developing a device driver for a *NEW* device. Before, you need the accurate virtual device for the

device. You have to develop a device driver with REAL

device at first. Then you can develop virtual device with the device driver.

Page 18: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 18

QEMU is *NOT* good for

Compiling a huge mount of source code. Too slow for compiling. It takes more than one night to compile Linux

kernel.

Page 19: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 19

QEMU is GOOD for

Learning. Even if you tweak too much to break, you lose

nothing. Not only for beginners. Experts may examine the

latest Linux kernel except for x86/x86_64, using QEMU.

Page 20: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 20

QEMU is GOOD for

Developing applications. without the real system. Android SDK is a perfect example.

also good for designers to evaluate UI.

Page 21: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 21

QEMU is GOOD for

Testing. Fault injection by the virtual device. You can duplicate as many as you like and test

them in parallel. Still need testing on real system.

Page 22: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 22

Practice #1

Following blog pages are written in Japanese. Try machine translation such as Google. It will work.

Building QEMU from source archive QEMU requires zlib and SDL to build. http://blog.kmckk.com/archives/2223793.html

Net-installing Debian on QEMU Don't use obsolete installer. http://blog.kmckk.com/archives/2233167.html

Page 23: Using QEMU for cross development

Practice #2

Rebuilding kernel from Debian source package Get the source package and extract and patch it on

ARM QEMU. Do compiling on PC Linux. QEMU system emulator is too slow to compile

kernel. http://blog.kmckk.com/archives/2237994.html

Page 24: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 24

Practice #3

How to setup NFS server for QEMU Need ”insecure” option for NFS because QEMU

redirect NFS port. http://blog.kmckk.com/archives/2257952.html

Page 25: Using QEMU for cross development

Practice #4

Booting Debian in NFS root on ARM QEMU Booting from NFS root is good for early-stage

developing. You can read/write target file system any time. You can boot kernel before implementing storage

device. You don't have to care about size of storage.

http://blog.kmckk.com/archives/2257962.html

Page 26: Using QEMU for cross development

Practice #5

Build latest kernel in kernel.org and try SMP mode Finally the latest kernel successfully ran. versatile_defconfig remains old. It need updated. You can try another virtual board easily on QEMU. SMP implementation of QEMU is just simple and

can not run fast.

http://blog.kmckk.com/archives/2333826.html

Page 27: Using QEMU for cross development

Practice #6

Try ARM Ubuntu using QEMU Ubuntu 9.04 is built for ARMv5TE. Ubuntu 9.10, ARMv6. Ubuntu 10.04, ARMv7 Thumb2. Debian, ARMv4T Rootstock script is nice and easy to build Ubuntu

root file system.

http://blog.kmckk.com/archives/2339128.html

Page 28: Using QEMU for cross development

Practice #7

Using debugger with QEMU Dive into QEMU itself using gdb. Connect gdb to target machine of QEMU. Debug both the target and QEMU itself using 2

gdbs. Another debugger for QEMU. http://blog.kmckk.com/archives/2363473.html

Page 29: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 29

Other topics

TCG and QEMU internals http://blog.kmckk.com/archives/2067157.html http://blog.kmckk.com/archives/2067178.html http://blog.kmckk.com/archives/2067210.html

Using user mode emulation of QEMU + binfmt + chroot to self-build http://blog.kmckk.com/archives/2342452.html

Page 30: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 30

Q & A

& Demo

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

Page 31: Using QEMU for cross development

Kyoto Microcomputer Co., Ltd. 31

One more thing ...

KMC PARTNER debugger for QEMUBreaking at do_execve in linux kernel running on Android emulator.