Howto | setup an ARM Linux System for qemu

Source: Internet
Author: User

I 've been playing with qemu lately and found that it's really awesome. To get started all you need is to create a root filesystem and cross compile a kernel
Which is quite easy to set up on a Debian/Ubuntu based system. Here is what I did:


0 prerequisites
Sudo apt-Get install debootstrap qemu-user-static qemu-system git gcc-arm-Linux-gnueabihf


1 create the rootfs
# Create the hard disk file
Fallocate-l 2gib ubuntu-armhf.ext3
Mkfs. ext3 ubuntu-armhf.ext3

# Mount the hard disk file
Mkdir mnt
Sudo Mount-o loop ubuntu-armhf.ext3 mnt

# Create an initial rootfs using debootstrap
Hostname = Ubuntu-armhf sudo debootstrap -- variant = minbase -- foreign -- arch armhf precise./mnt

# Copy the statically linked qemu binary into the rootfs
Sudo CP/usr/bin/qemu-arm-static MNT/usr/bin/

# Chroot into the rootfs and start a Shell Using qemu-arm-static
Lang = C sudo chroot MNT/usr/bin/qemu-arm-static-CPU cortex-a9/bin/sh
# Run the debootstrap second stage from within the chroot:
/Debootstrap -- second-stage

# Create the sources. List Files for apt:
Echo "Deb http://ports.ubuntu.com precise
Main restricted universe
Deb-Src http://ports.ubuntu.com precise
Main restricted universe ">/etc/APT/sources. List
Echo "Deb http://ddebs.ubuntu.com precise
Main restricted universe Multiverse ">/etc/APT/sources. List. d/ddebs. List
Apt-key adv -- keyserver keyserver.ubuntu.com -- Recv-keys
428d7c01

# Install some fundamental packages
Apt-Get update
Apt-Get install sudo apt-utils dialog less wget

# Create configuration for the serial console
CP/etc/init/tty1.conf/etc/init/ttyama0.conf
Sed-I "s/tty1/ttyama0/"/etc/init/ttyama0.conf

# Add a user
Adduser myuser
# Add User to The sudo Group
Usermod-Ag sudo myuser

# Exit the chroot env
Exit

# Unmount the rootfs
Sudo umount mnt
Rmdir mnt


2 cross compile the kernel
# Check out the sources
Git clone-depth = 1 git: // git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Mkdir Linux-build
CD Linux
# Create a. config Based on the versatile express Default Configuration
Make arch = arm o = ../Linux-build vexpress_defconfig
# Compile the kernel
Make arch = arm cross_compile = arm-Linux-gnueabihf-O = ../Linux-Build-J 'getconf _ nprocessors_onln 'zimage
CD ..


3 boot the image using qemu
Qemu-system-Arm \
-M vexpress-a9-M 1024 \
-Serial stdio-no-Reboot \
-Kernel Linux-build/ARCH/ARM/boot/zimage \
-Drive file = ubuntu-armhf.ext3, if = SD, cache = writeback \

-- APPEND "RW console = ttyama0, 38400n8 console = tty root =/dev/mmcblk0"-S

Then you can use GDB or eclipse for debugging.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.