Saturday, December 12, 2009

QEMU + U-BOOT

1. Get the U-Boot sources

2. sudo apt-get install qemu-kvm-extras [for qemu-system-arm]
We will compile for ARM (needless to say) target---ARM versatile board (needless again)

[NOTE]: [u-boot-dir]/include/configs contains the default configs for most of the platforms. It almost corresponds to the one in linux kernel sources.

STEPS
=======

1. make versatile_config
2. make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-

make ....make....make...

[NOTE]: Uboot needs the linux with uboot specific headers in order to boot it. This u-boot specific image can be generated using "make uImage".

However this would need mkimage. Where do we get it from---
Easy:)
---- after running make you can find the mkimage in [u-boot-dir]/tools directory.
---- Or get it from sudo apt-get install uboot-mkimage


3. Launch
sudo qemu-system-arm -nographic -m 256 -M versatileab -kernel u-boot.bin

The above command is good if your testing u-boot as a standalone app. However it would be wonderful to have networking between host and target to boot a linux kernel

sudo qemu-system-arm -M versatileab -kernel u-boot -net nic -net tap -nographic -serial stdio

Don't worry about the error message we will get to it.
===================================================
nemesis@nemesis-laptop:~/u-boot-2009.08$ sudo qemu-system-arm -nographic -m 256 -M versatileab -kernel u-boot.bin


U-Boot 2009.08 (Dec 13 2009 - 00:28:50)

DRAM: 0 kB
## Unknown FLASH on Bank 1 - Size = 0x00000000 = 0 MB
Flash: 0 kB
*** Warning - bad CRC, using default environment

In: serial
Out: serial
Err: serial

===================================================

Build linux kernel Image for U-boot



nemesis@nemesis-laptop:~/linux_kernel/linux-2.6.32$ make uImage
CHK include/linux/version.h
make[1]: `include/asm-arm/mach-types.h' is up to date.
CHK include/linux/utsrelease.h
SYMLINK include/asm -> include/asm-arm
CALL scripts/checksyscalls.sh
MKELF scripts/mod/elfconfig.h
HOSTCC scripts/mod/file2alias.o
HOSTCC scripts/mod/modpost.o
scripts/mod/modpost.c: In function ‘get_markers’:
scripts/mod/modpost.c:1562: warning: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result
scripts/mod/modpost.c: In function ‘add_marker’:
scripts/mod/modpost.c:1982: warning: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result
HOSTCC scripts/mod/sumversion.o
HOSTLD scripts/mod/modpost
CHK include/linux/compile.h
GEN lib/crc32table.h
CC lib/crc32.o
LD lib/built-in.o
LD vmlinux.o
MODPOST vmlinux.o
GEN .version
CHK include/linux/compile.h
UPD include/linux/compile.h
CC init/version.o
LD init/built-in.o
LD .tmp_vmlinux1
KSYM .tmp_kallsyms1.S
AS .tmp_kallsyms1.o
LD .tmp_vmlinux2
KSYM .tmp_kallsyms2.S
AS .tmp_kallsyms2.o
LD vmlinux
SYSMAP System.map
SYSMAP .tmp_System.map
OBJCOPY arch/arm/boot/Image
Kernel: arch/arm/boot/Image is ready
GZIP arch/arm/boot/compressed/piggy.gz
AS arch/arm/boot/compressed/piggy.o
LD arch/arm/boot/compressed/vmlinux
OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready
UIMAGE arch/arm/boot/uImage
Image Name: Linux-2.6.32
Created: Sun Dec 13 02:29:45 2009
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1535396 Bytes = 1499.41 kB = 1.46 MB
Load Address: 00008000
Entry Point: 00008000
Image arch/arm/boot/uImage is ready



GET READY TO BOOT YOUR LINUX KERNEL
======================================

VersatilePB # setenv ipaddr 10.0.2.16
VersatilePB # setenv serverip 10.0.2.15
VersatilePB # ping 10.0.2.15
SMC91111: PHY auto-negotiate timed out
Using MAC Address 52:54:00:12:34:56
host 10.0.2.15 is alive
VersatilePB # tftp 8000 uImage
SMC91111: PHY auto-negotiate timed out
Using MAC Address 52:54:00:12:34:56
TFTP from server 10.0.2.15; our IP address is 10.0.2.16
Filename 'uImage'.
Load address: 0x8000
Loading: T T T T T T T #################################################################
###T #####################################
done
Bytes transferred = 1535460 (176de4 hex)


PROBLEM: There seems to be a bug in the sense that DRAM setting are not correct for versatile.

Switching to Integrator platform. [build uboot and linux image for integrator]
(uboot config =====> integratorcp_config)

nemesis@nemesis-laptop:~/u-boot-2009.08$ sudo qemu-system-arm -kernel u-boot -net nic -net tap -nographic -serial stdio
[sudo] password for nemesis:


U-Boot 2009.08 (Dec 13 2009 - 04:00:17)

DRAM: 128 MB
## Unknown FLASH on Bank 1 - Size = 0x00000000 = 0 MB
Flash: 0 kB
*** Warning - bad CRC, using default environment

In: serial
Out: serial
Err: serial
Hit any key to stop autoboot: 0
Integrator-CP # setenv serverip 10.0.2.15
Integrator-CP # setenv ipaddr 10.0.2.16
Integrator-CP # tftp 8000 uImage
SMC91111: PHY auto-negotiate timed out
Using MAC Address 52:54:00:12:34:56
TFTP from server 10.0.2.15; our IP address is 10.0.2.16
Filename 'uImage'.
Load address: 0x8000
Loading: T T #################################################################
################################
done
Bytes transferred = 1411276 (1588cc hex)
Integrator-CP # bootm
## Booting kernel from Legacy Image at 00008000 ...
Image Name: Linux-2.6.32
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1411212 Bytes = 1.3 MB
Load Address: 00008000
Entry Point: 00008000
XIP Kernel Image ... OK
OK

Starting kernel ...

qemu: fatal: Trying to execute code outside RAM or ROM at 0xfffff1c2

R00=00000000 R01=00000107 R02=00000100 R03=00000002
R04=00fddfc0 R05=00000000 R06=00008000 R07=00000113
R08=00fddfdc R09=010172c0 R10=010176ac R11=00fddced
R12=0100f750 R13=00000000 R14=00008008 R15=fffff1c2
PSR=600001db -ZC- A und32
Aborted
nemesis@nemesis-laptop:~/u-boot-2009.08$

============================================

So far so good...Uboot passes control to linux kernel but the kernel boot does a crash and burn. Will need to solve this one now....



No comments: