CE3213. System Programming - Lab I. Building Dev. Env. for ARM ...

76 downloads 1396 Views 142KB Size Report
System Programming. Lab I. Building Dev. Env. for ARM Assembly Programming. Cheolgi Kim. Korea Aerospace University. 2012. 3. 2. Cheolgi Kim. System ...
CE3213. System Programming Lab I. Building Dev. Env. for ARM Assembly Programming

Cheolgi Kim Korea Aerospace University

2012. 3. 2

Cheolgi Kim

System Programming

Target Configuration

ARM Development Environment Virtual Machine: QEMU (ARM virtual machine) Virtual Environment: Versatile Express ARM Development Board Operating System: Linaro-Developer (custom-built Debian-Linux)

Cheolgi Kim

System Programming

Target Configuration

ARM Development Environment Virtual Machine: QEMU (ARM virtual machine) Virtual Environment: Versatile Express ARM Development Board Operating System: Linaro-Developer (custom-built Debian-Linux)

QEMU Execution Environment Virtual Machine: VMware Operating System: Ubuntu Linux

Cheolgi Kim

System Programming

Target Configuration

ARM Development Environment Virtual Machine: QEMU (ARM virtual machine) Virtual Environment: Versatile Express ARM Development Board Operating System: Linaro-Developer (custom-built Debian-Linux)

QEMU Execution Environment Virtual Machine: VMware Operating System: Ubuntu Linux

VMWare Execution Environment Windows

Cheolgi Kim

System Programming

Target Configuration

ARM Development Environment Virtual Machine: QEMU (ARM virtual machine) Virtual Environment: Versatile Express ARM Development Board Operating System: Linaro-Developer (custom-built Debian-Linux)

QEMU Execution Environment Virtual Machine: VMware Operating System: Ubuntu Linux

VMWare Execution Environment Windows

2-level virtualization!

Cheolgi Kim

System Programming

Current Configuration

QEMU Execution Environment Virtual Machine: VMware VM name: KAUCE Ubuntu

Operating System: Ubuntu Linux User ID: KAUCE Password: KAUCE

VMWare Execution Environment Windows

Cheolgi Kim

System Programming

What To Do Today

Use Unix command-line interface Install QEMU (ARM Virtual Machine) in the Ubuntu Install Linaro-Developer in the QEMU

Cheolgi Kim

System Programming

What To Do Today

Use Unix command-line interface Install QEMU (ARM Virtual Machine) in the Ubuntu Install Linaro-Developer in the QEMU Writing ’Hello World’ program in Assembly Language

Cheolgi Kim

System Programming

Unix Command-Line Interface

We barely use GUI for QEMU ARM VM performance. Instead, we use Unix command-line interface pwd: Showing current working directory ls: List flies and directories in working directory cd: Change working directory

Cheolgi Kim

System Programming

Unix Command-Line Interface

We barely use GUI for QEMU ARM VM performance. Instead, we use Unix command-line interface pwd: Showing current working directory ls: List flies and directories in working directory cd: Change working directory

HW #2: Play and be familiar with Unix cat, cp, mv, rm, mkdir, rmdir, chmod, less, tail, grep, find, tar, gzip, gunzip, ‘· · · ‘, |, >, », · · ·

Quiz next week

Cheolgi Kim

System Programming

Ubuntu Package Management

Key of setting up linux environment Most Ubuntu programs and libraries are managed in Debian package system If a package to install has dependencies as prerequisite packages, the manager automatically install them

Cheolgi Kim

System Programming

Ubuntu Package Management

Key of setting up linux environment Most Ubuntu programs and libraries are managed in Debian package system If a package to install has dependencies as prerequisite packages, the manager automatically install them Mostly used package commands apt-get update: make all the packages up-to-date apt-get install : install package

Cheolgi Kim

System Programming

Ubuntu Package Management

Key of setting up linux environment Most Ubuntu programs and libraries are managed in Debian package system If a package to install has dependencies as prerequisite packages, the manager automatically install them Mostly used package commands apt-get update: make all the packages up-to-date apt-get install : install package

Korean proxy DB of Ubuntu packages is sometimes out-of-sync Solution: Change package server list to others (at /etc/apt/sources.list)

Cheolgi Kim

System Programming

QEMU Installation

1

Add personal package archive of Linaro project To install QEMU variation best fit to the OS, Linaro sudo add-apt-repository ppa:linaro-maintainers/tools

Cheolgi Kim

System Programming

QEMU Installation

1

Add personal package archive of Linaro project To install QEMU variation best fit to the OS, Linaro sudo add-apt-repository ppa:linaro-maintainers/tools

2

Make all the packages up-to-date sudo apt-get update

Cheolgi Kim

System Programming

QEMU Installation

1

Add personal package archive of Linaro project To install QEMU variation best fit to the OS, Linaro sudo add-apt-repository ppa:linaro-maintainers/tools

2

Make all the packages up-to-date sudo apt-get update

3

Install required QEMU packages sudo apt-get install qemu-user-static qemu-system

Cheolgi Kim

System Programming

QEMU Installation

1

Add personal package archive of Linaro project To install QEMU variation best fit to the OS, Linaro sudo add-apt-repository ppa:linaro-maintainers/tools

2

Make all the packages up-to-date sudo apt-get update

3

Install required QEMU packages sudo apt-get install qemu-user-static qemu-system

4

Make empty virtual-disk for QEMU

Cheolgi Kim

System Programming

QEMU Installation

1

Add personal package archive of Linaro project To install QEMU variation best fit to the OS, Linaro sudo add-apt-repository ppa:linaro-maintainers/tools

2

Make all the packages up-to-date sudo apt-get update

3

Install required QEMU packages sudo apt-get install qemu-user-static qemu-system

4

Make empty virtual-disk for QEMU qemu-img create -f raw vexpress.img 2G

Cheolgi Kim

System Programming

Linaro Installation File Download

1

Go to www.linaro.org and press Download at the top ≡ http://www.linaro.org/downloads/1202

Cheolgi Kim

System Programming

Linaro Installation File Download

1

Go to www.linaro.org and press Download at the top ≡ http://www.linaro.org/downloads/1202

2

Click Developer × DOWNLOAD FOR . . . at “Developers and Community Builds” section

Cheolgi Kim

System Programming

Linaro Installation File Download

1

Go to www.linaro.org and press Download at the top ≡ http://www.linaro.org/downloads/1202

2

Click Developer × DOWNLOAD FOR . . . at “Developers and Community Builds” section hwpack_XXX.tar.gz’s are hardware configuration file Download hwpack_linaro-lt-vexpress-· · · .tar.gz at the home directory

Cheolgi Kim

System Programming

Linaro Installation File Download

1

Go to www.linaro.org and press Download at the top ≡ http://www.linaro.org/downloads/1202

2

Click Developer × DOWNLOAD FOR . . . at “Developers and Community Builds” section hwpack_XXX.tar.gz’s are hardware configuration file Download hwpack_linaro-lt-vexpress-· · · .tar.gz at the home directory linaro-o-developer-· · · .tar.gz is Linaro OS install file for QEMU; Download it to the home directory, too

Cheolgi Kim

System Programming

Linaro Installation File Download

1

Go to www.linaro.org and press Download at the top ≡ http://www.linaro.org/downloads/1202

2

Click Developer × DOWNLOAD FOR . . . at “Developers and Community Builds” section hwpack_XXX.tar.gz’s are hardware configuration file Download hwpack_linaro-lt-vexpress-· · · .tar.gz at the home directory linaro-o-developer-· · · .tar.gz is Linaro OS install file for QEMU; Download it to the home directory, too

3

Now, we are ready to install Linaro onto virtual disk vexpress.img through QEMU!

Cheolgi Kim

System Programming

First Game: Linaro Installation

Rule No communication between students is allowed No assistance will give you more credit

Cheolgi Kim

System Programming

First Game: Linaro Installation

Rule No communication between students is allowed No assistance will give you more credit

Click Developer × INSTRUCTIONS at http://www.linaro.org/downloads/1202 Game Start!

Cheolgi Kim

System Programming

Solution of First Game: Linaro Installation $ sudo apt-get install linaro-image-tools $ linaro-media-create --help | grep dev $ sudo linaro-media-create --rootfs ext3 --image-file vexpress.img --binary linaro-o-developer-tar-· · · .tar.gz --hwpack hwpack_linaro-lt-vexpress-a9· · · .tar.gz --dev vexpress-a9 Installations MUST be performed WITHOUT VERIFICATION when perform linaro-media-create Options --image-file: the image file made by qemu-img --binary: just downloaded Linaro OS install file --hwpack: just downloaded HW configuration file --dev: board identifier found by the second command

Cheolgi Kim

System Programming

Second Game: Running Linaro

The same rule applied Instruction page 1

2

At the instruction page, click “here” at Section ‘Generating an image for QEMU’ Then, click “Versatile Express”

Game Start!

Cheolgi Kim

System Programming

Solution of Second Game (I)

Make directory to mount Linaro virtual disk $ sudo mkdir /mnt/mnt Mount the virtual disk at /mnt/mnt $ (IMG=vexpress.img ; if [ -e "$IMG" ] ; then sudo mount -o loop,offset="$(file "$IMG" | awk 'BEGIN { RS=";"; } /partition 2/ { print $7*512; }')" -t auto "$IMG" /mnt/mnt; else echo "$IMG not found"; fi ) Copy boot related files in /boot directory of virtual disk to local $ sudo cp -vr /mnt/mnt/boot . $ sudo chown -R kauce:kauce boot $ sudo umount /mnt/mnt

Cheolgi Kim

System Programming

Solution of Second Game (II) Run QEMU virtual machine with extracted kernal, initial ramdisk (initrd), and virtual disk $ qemu-system-arm -kernel boot/vmlinuz-3.2.0-1800-linaro-lt-vexpress-a9 -M vexpress-a9 -cpu cortex-a9 -serial stdio -m 256 -initrd boot/initrd.img-3.2.0-1800-linaro-lt-vexpress-a9 -append 'root=/dev/mmcblk0p2 rw mem=256M raid/noautodetect console=ttyAMA0,38400n8 rootwait vmalloc=256MB devtmpfs.mount=0' -sd vexpress.img Memory is reduced to 256M Options -kernel: OS Kernel image -initrd: Initial ramdisk image

Cheolgi Kim

System Programming

Working on Linaro Store statement of qemu-system-arm in a new file named arm.sh make arm.sh runnable by chmod 755 arm.sh To execute VM, now simply run ./arm.sh

Do not use the window showing Linux Penguin! (low performance) Use terminal console that has run qemu-system-arm Install an editor you want on ARM Linaro vi is recommended if you are familiar with it (already installed) nano is recommended if you are not comfortable with vi sudo apt-get install nano

To finish QEMU VM, run shutdown -h now

Cheolgi Kim

System Programming

To Do at Home

Copy vexpress.img, arm.sh and boot directory to your thumb drive You are going to use them for rest of this semester Installing environment at your computer is HW #3

Cheolgi Kim

System Programming

Hello, World in ARM Assembly Language (hello.s) .text _start: .global _start @ sys_write ( fd, pstr, len ) @ r7=4 r0 r1 r2 mov r0, #1 @ fd