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).
Related
I was trying to compile my own kernel through clang-13 and run systemtap on that. I have enabled the CONFIG_DEBUG_INFO, CONFIG_DEBUG_KERNEL and all other default debugging configs including CONFIG_KPROBES, CONFIG_UPROBES. Additionally I have disabled CONFIG_RANDOMIZE_BASE. To compile and install I ran make -j8 bindeb-pkg && sudo dpkg -i ../*.deb. As you can see from the screenshot below the dbg package was installed and the sha256 confirms that the vmlinux matches, so systemtap should have access to its symbols. However, that doesn't seem to be the case since systemtap fails.
Additionally I compile the latest systemtap with clang-13 as follows make -j8 CC=clang-13 CXX=clang++-13 CFLAGS="-Wno-error" CXXFLAGS="-Wno-error".
The systemtap version is 4.7/0.170 and it says tested kernel versions: 2.6.32 ... 5.15.0-rc7. I might be missing something here.
Tracepoints in stap are identified by chewing through kernel headers (and sometimes sources). You can check whether stap is finding them with greater verbosity, such as:
stap -k -p2 --poison-cache --vp 04 -e 'probe ....'
If it's working, you'll see a lot of compiler invocations related to "tracequery", and you can see the residue of the searches under $TMPDIR (due to the -k option).
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.
I have been working with some Cortex-M4 (Freescale K60) devices with a compiled by me GCC (v4.7.2), BinUtils (v2.22), Newlib (v1.20) and GDB (v7.5). I have always been annoyed by GDB's inability to unwind from hard exceptions.
recently I had an opportunity to use FreeScale's CodeWarrior, where I loaded my binary for debug (compiled by my tools), and it could unwind the exception. It looks like CodeWarrior is running GDB v7.4.1 under the hood. Is there some patch I missed for GDB, or some configure option?
Here is the script used to build GDB:
TOOLCHAIN=gdb-7.5
mkdir -p BUILD/gdb
cd BUILD/gdb
../../${TOOLCHAIN}/configure --prefix=${PREFIX} --target=${TARGET} --enable-interwork --enable-multilib --with-expat=yes --with-python --without-auto-load-safe-path 2>&1 | tee configure.out
make all install
cd ../../
Thanks!
GDB can do Cortex M profile exception unwinding, once you tell it that the target is actually Cortex M profile using a Target Description XML with correct Feature.
This can be done via the set target tdesc <filename> command, but newer gdb servers (e.g. OpenOCD) should do so already.
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
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.