Booting Custom 64 bit Kernel for RPI 3 on QEMU - linux-kernel

I have compiled a 64 bit kernel for Raspberry pi 3 to use with raspbian.
I did it following this tutorial
https://devsidestory.com/build-a-64-bit-kernel-for-your-raspberry-pi-3/.
As I finished, I ended up with a raspberry image which supposedly used a 64 bit kernel, and the kernel Image.
However, when I run
> qemu-system-aarch64 -kernel Image -cpu cortex-a53 -m 512 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" -hda raspbian64.img
Nothing happens, its like it cant find the kernel.
Is there a way to debug QEMU ? Should I use versatiblepb or something else?

This is an incorrect command line. The 'versatilepb' board is an old development board for 32-bit ARM -- it has no support at all for 64-bit CPUs, and passing -cpu cortex-a53 with -M versatilepb is like trying to jam a Core2Duo CPU into the socket on an i386 motherboard.
You need to build a kernel which will work with one of the 64-bit ARM boards that QEMU emulates (currently 'virt', 'xlnx-ep108' or 'xlnx-zcu102', but I strongly recommend 'virt') and use that board and kernel together. Mismatching board and kernel will not work.

Related

Golang. Cross Compiling for MIPS

I have tried compiling my simply program:
func main(){fmt.Printf("Hello")}
to MIPS architecture on my PC wit 64 bit Debian Linux according to documentation
https://golang.org/doc/install/source#environment
via using command
GOOS=linux GOARCH=mipsle go build
GOOS=linux GOARCH=mips go build
Every time I get the error:
runtime/internal/sys compile
unknown architecture "mipsle(mips)"
The interesting thing is, if a try using command:
GOOS=linux GOARCH=mipsle64 go build
The program was build.
Is it dependent on system OS on my PC ? How can I build a binary for MIPS or MIPSLE ?
Go 1.6 does not support MIPS or MIPSLE. 1.6 supports MIPS64(LE). 1.8 supports MIPS(LE).
From https://golang.org/doc/install/source:
amd64 (also known as x86-64)
A mature implementation.
386 (x86 or x86-32)
Comparable to the amd64 port.
arm (ARM)
Supports Linux, FreeBSD, NetBSD, OpenBSD and Darwin binaries. Less widely used than the other ports.
arm64 (AArch64)
Supports Linux and Darwin binaries. New in 1.5 and not as well exercised as other ports.
ppc64, ppc64le (64-bit PowerPC big- and little-endian)
Supports Linux binaries. New in 1.5 and not as well exercised as other ports.
mips, mipsle (32-bit MIPS big- and little-endian)
Supports Linux binaries. New in 1.8 and not as well exercised as other ports.
mips64, mips64le (64-bit MIPS big- and little-endian)
Supports Linux binaries. New in 1.6 and not as well exercised as other ports.
s390x (IBM System z)
Supports Linux binaries. New in 1.7 and not as well exercised as other ports.

Booting u-boot in Mac OS X's qemu

I'm trying to build u-boot, and run it in qemu on Mac OS X.
I found this site, and followed the instructions:
http://imvoid.wordpress.com/2013/05/17/booting-uboot-in-qemu/
For cross compilation on Mac OS X, I could build the tools - How to make ARM cross compilation on Mac OS X (error: invalid listing option `r' - cross compiling error)
For u-boot, I tried the newest edition (2014) that causes core dump, and some earlier version (2010) that doesn't compile, so I used the 2013/10 version (https://dl.dropboxusercontent.com/u/1234/2014/u-boot-2013.10.tar.bz2) to get the uboot.bin.
However, when I run the binary with qemu-system-arm -M versatilepb -m 128M -nographic -kernel u-boot.bin;, there is no crash, but I see nothing from the screen.
What might be wrong? I uploaded the binary.
https://dl.dropboxusercontent.com/u/1234/2014/u-boot.bin
And the 2014 version that crashes.
https://dl.dropboxusercontent.com/u/1234/2014/u-boot_2014.bin
Try using the ELF format file u-boot, instead of u-boot.bin.
$ qemu-system-arm -M versatilepb -m 128M -nographic -kernel u-boot
U-Boot 2014.10-rc2-00312-g9169305 (Oct 06 2014 - 20:43:26)
DRAM: 128 MiB
WARNING: Caches not enabled
Flash: Flash protect error at address 37ec0000
Flash protect error at address 37fc0000
64 MiB
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
Net: SMC91111-0
Warning: SMC91111-0 using MAC address from net device
Warning: Your board does not use generic board. Please read
doc/README.generic-board and take action. Boards not
upgraded by the late 2014 may break or be removed.
VersatilePB #
I built u-boot commit 91693055995733e268874ae75568ae316233e116 on my OS X 10.9.5 system. I used the ARM toolchain binaries available here. Untar gcc-arm-none-eabi-4_8-2014q3-20140805-mac.tar.bz2 anywhere (e.g. $HOME)
$ git clone http://git.denx.de/u-boot.git
$ cd u-boot
$ make versatilepb_config
$ make CROSS_COMPILE=~/gcc-arm-none-eabi-4_8-2014q3/bin/arm-none-eabi-
I used Qemu from Homebrew.
$ qemu-system-arm --version
QEMU emulator version 2.1.2, Copyright (c) 2003-2008 Fabrice Bellard

QEMU blank screen issue

I build and flashed mainline kernel using
1)make ARCH=arm distclean
2)make ARCH=arm bcm_defconfig
3)make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- LOADADDR=0x00008000 uImage
4)qemu-system-arm -M versatilepb -m 128M -kernel arch/arm/boot/uImage -initrd rootfs.img -append "root=/dev/ram rdinit=/sbin/init"
QEMU shows a blank screen nothing in it. Could someone please help?
Do I need to change the machine? If yes, please let me know which machine?
To emulate RPI on qemu is not a straight forward as qemu doest not support BCM platform ,its tricky thing to do,anyway it can be done with qemu – vinay hunachyal Mar 19 at 5:15

raspberry x264 compilation issues

for Raspberry pi which is as follows:
cd /my/path/where/i/keep/my/source/code
git clone git://git.videolan.org/x264
cd x264
./configure --host=arm-unknown-linux-gnueabi --enable-static --cross-prefix=${CCPREFIX} --prefix=/my/path/were/i/keep/built/arm/stuff
make
make install
when i did this, i got some message as:
You specified a pre-ARMv6 or Thumb-1 CPU in your CFLAGS.
If you really want to run on such a CPU, configure with --disable-asm.
how to do this .. i am going to use this all on raspberry Pi which uses ARM 11 processor
i am going to use this all on raspberry Pi which uses ARM 11 processor
Note that ARM versioning is not the same as ARM architecture. The ARM11 chip was the first to use ARMv6 architecture.
Anyways, as Ottavio Campana said in that comment, this message is just warning you that you missed a switch. Add --disable-asm to the end of the command you used before and see what happens.

Kernel emulation with Qemu

I'm actually trying to emulate the linux kernel using Qemu and busybox.
So far I made this kernel image:
http://depositfiles.com/files/l9x9veg09
And launched Qemu using these arguments:
qemu-system-x86_64 -m 256 -s -hda rootfs.img -kernel linux-2.6.34.12/arch/x86/boot/bzImage -append "root=/dev/sda \ init=/bin/sh"
But once the kernel is launched I get a message saying:
Kernel Panic. No init found. Try passing init= option to kernel...
I though adding "init=/bin/sh" to the arguments would solve the problem but it didn't. I'm a begginer in this domain. Can someone help me with this? Thank you
When using Busybox, you want to pass -initrd initramfs instead of init=/bin/sh to qemu. Try this
qemu-system-x86_64 -m 256 -s -hda rootfs.img -kernel linux-2.6.34.12/arch/x86/boot/bzImage -initrd initramfs -append "root=/dev/sda"
I finally made it work by using a pre-build version of busybox which was statically linked (found on the website). The old one was dynamically linked and compiling it as a static executable was a real pain (it seems that glibc does not support static linking anymore).

Resources