Problem with running buildroot generated raspberry image on Qemu - embedded-linux

I have build Linux image using buildroot for raspberryp pi 3, using the instruction (Link).
When I run the image in Qemu I am facing the problem:
Please, advice how i can fix this issue.

Your command line is using qemu-system-x86_64 -M pc, which is telling QEMU to emulate an x86 PC. That is not a Raspberry Pi and it cannot run the Arm code that a Pi needs.
You've also given a URL to a google search, not a set of build instructions, so it's difficult to see what you were trying to follow.
Looking at the instructions in your updated link, they give several possible configs: "Raspberry Pi Zero W", "Raspberry Pi Zero" and "Virtual machine". None of those is a Pi 3, so what config are you actually building ? Unless you've built the "Virtual machine" config (which is an x86-64 one) the QEMU command line you're using won't work. The command line you're using also does not match the one in the blog post, which uses output/images/bzImage for its kernel, not a zImage file.

Related

How to compile the new version of glibc under Raspberry Pi 4 and cross compile a simple project

I am using a raspberry pi 4 to test the cross-compilation and run the code I compiled on a windows machine under eclipse using a cross-compiler.
When I downloaded the latest version of the cross toolchain from the ARM developer, I faced a non-compatibility between the glibc I had in my toolchain and the glibc I have in my Rasberry pi 4 board.
I tired solve this issue I tried to download the glibc 2.34 and compile it into my Rasberry pi 4 board.
I have followed this tutorial (How to build and use glibc for):
http://www.yl.is.s.u-tokyo.ac.jp/~tosh/kml/how_to_build_and_use_glibc.html
After the installation process, I have the following files in my local folder in the Rasberry pi board:
/usr/local/lib/glib-testing/lib/ld-linux-aarch64.so.1
/usr/local/lib/glib-testing/lib/libc.so.6
/usr/local/lib/glib-testing/lib/libc.so
/usr/local/lib/glib-testing/lib/libc.a
In my host machine under Windows 10 I am using eclipse.
I looked at the same example and question in the StackOverflow forum and I tried to inspire by them.
for example this question: Multiple glibc libraries on a single host have a lot of similitude but still have some issues running my application on the PI since I am compiling on Windows.
I added the following lines to my eclipse linker to pointe to the library I installed in my local folder:
-Wl,--rpath="C:\Program Files (x86)\Arm_GNU_Toolchain_aarch64-none-linux-gnu\12.2 rel1\lib" -Wl,--dynamic-linker="/usr/local/lib/glibc-testing/lib/ld-linux-aarch64.so.1"
When I run the code I have this message:
/home/pi/Bookshelf/Software/raspberyPi4TestCrossCompilation: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
I don't want to copy the files in the system because I have seen people saying taht it's dangerous and it can destroy my system. That's why I want to understand before doing bullshit.
Thank you in advance for help

Basic linux kernel development and testing environment using qemu

I want to learn about the linux kernel and this is why I wanted a simple but powerful enough way test kernel changes that I do.
I used the info on this page https://mgalgs.github.io/2015/05/16/how-to-build-a-custom-linux-kernel-for-qemu-2015-edition.html to start.
So now I can start a qemu session with the kernel I choose and also have busybox utilities.
The part I cannot understand is how do I transfer a kernel module .ko on this virtual machine as to load it in my modified kernel ? I tried also transfering a c program by incorporating it in the initramfs but when I try to run the program I receive the following error message:
"/bin/sh: ./proc1: not found" .
Should I use a virtual hdd image ? If so how do I create and use one ? How do I transfer files from host os to the virtual hdd ?
Thnaks in advance.
The created virtual hdd was not discovered because I didn't use mdev -s in the init file.
After that I could mount the sda in qemu session.
The c program that could not be ran I solved by compiling it with the -static flag.

Could not initialize SDL(No available video device), qemu-system, Windows Subsystem for Linux

I'm learning how to write a basic OS kernel with intermezzos.github.io
I'm running in Windows Subsystem for Linux on Windows 10 v1607.
I'm at the point where I want to run my .iso with qemu-systems-x86_64 -cdrom os.iso.
Previously I was able to run the command and QEMU would run a window, which was running into another problem, posted here: QEMU, No bootable device, Windows Subsystem for Linux
Now when running the command, I receive the following error: Could not initialize SDL(No available video device) - exiting
When I ran into this problem before I installed Xming, ran it, and then QEMU successfully ran. But now, when I try to run Xming it no longer solves the problem.
I even tried installing xorg and running startx on WSL but that starts another issue: xf86OpenConsole: Cannot open /dev/tty0 (No such file or directory)
I really don't know what I'm doing and I have so many questions.
I'm under the impression that for QEMU to successfully run, it needs to be able to find a video driver. Is that the purpose of X11?
I am able to get qemu-system-x86_64 -cdrom os.iso to run the expected window after setting: export DISPLAY=:0
Partially solves my problem because I'm still running into QEMU, No bootable device, Windows Subsystem for Linux
I'm wondering if I'm setting the DISPLAY environment variable correctly.
Here's documentation on the DISPLAY variable, for anyone else that wants to learn: http://gerardnico.com/wiki/linux/display
Anyway, this portion is solved!

How do i Cross-compiling Qt for ARM boards like Raspberry Pi 2 & BeagleBoard-xm from Windows 7

I need to compile Qt applications developed in Visual studio on Windows 7 for Embedded boards. I tried to google it but could not find enough documentation.
You have to setup tool chain for arm as RPi and BB-XM has ARM processor. then Download Qt opensource setup .
set
ARCH=arm CROSS_COMPILE=arm_tool_chain- command
run the appropriate command to setup qt in above format.
For binaries
ARCH=arm CROSS_COMPILE=arm_tool_chain- command --prefix=PATH --build=?? --target==?? --host=??
To generate qt-binaries for arm define path in above format , define your build,host,target as per your configuration and run command to generate binaries.
place these binary in your kernel .recompile it and burn it to boards.
That's it ..now you can run qt application in your board.
These all commands you should perform in cygwin or any pre-installed
VM with Linux distro.
Or you can get concepts from
https://konqueror.org/embedded/
It may help you.

How to use qemu to run a non-gui OS on the terminal?

I want to run some programs on the High Performance Computer (With 8-core processor) in my department. Now I use that machine with ssh using terminal. The machine has Red Hat linux installed on it. But my programs need to run on Solaris. I use Nexenta Solaris for x86.
Can qemu be used to run Nexenta Solaris on that machine through terminal. I need to convince the administrator that it can, otherwise he won't install qemu on that machine and therefore allow me to use Solaris through a virtual machine. Also note that I don't use GUI with the Nexenta Solaris, just command line. In my machine, I use VMware to run it.
You can compile qemu for youself and install it into your home directory. There will be no kernel-mode qemu accelerator, but the qemu will work and the speed will be rather high.
Qemu has two options for non-gui start: http://wiki.qemu.org/download/qemu-doc.html
2.3.4 Display options:
-nographic
Normally, QEMU uses SDL to display the VGA output. With this option, you can totally disable graphical output so that QEMU is a simple command line application. The emulated serial port is redirected on the console. Therefore, you can still use QEMU to debug a Linux kernel with a serial console.
-curses
Normally, QEMU uses SDL to display the VGA output. With this option, QEMU can display the VGA output when in text mode using a curses/ncurses interface. Nothing is displayed in graphical mode.
Also it can send graphic output to another machine via VNC protocol (-vnc option)
Linux: -append 'console=ttyS0'
That option was also needed for Linux kernel be besides -nographic mentioned by osgx as in a comment:
qemu-system-x86_64 -append 'console=ttyS0' \
-initrd rootfs.cpio.gz \
-kernel bzImage \
-nographic \
-serial mon:stdio \
Now you can do the following:
Ctrl + A X: exit qemu, see: https://superuser.com/questions/1087859/how-to-quit-the-qemu-monitor-when-not-using-a-gui
Ctrl + C: gets passed to the guest
-append 'console=ttyS0' makes QEMU pass the console=ttyS0 kernel command line option to Linux, which tells the kernel to use a serial port instead of the display. The serial port sends characters between host and guest, instead of pixels on a display, and then QEMU can display those characters on the terminal.
-serial mon:stdio is optional in this minimal command, but it is generally a good idea to have around. E.g., it improves behaviour if you also want to add a handy -monitor telnet later on:
How to run qemu with -nographic and -monitor but still be able to send Ctrl+C to the guest and quit with Ctrl+A X?
https://unix.stackexchange.com/questions/167165/how-to-pass-ctrl-c-to-the-guest-when-running-qemu-with-nographic
This can be easily tested with Buildroot qemu_x86_64_defconfig. I've created this is a highly self-contained and automated setup that allows you to try this out easily
Related but with less OS constraints:
redirect QEMU window output to terminal running qemu
Redirect Qemu console to a file or the host terminal?
Tested on Ubuntu 18.04, QEMU 2.11.1.
FreeBSD
Got it working there too: How to boot FreeBSD image under Qemu
I've struggled this for a while and finally figured out how to get it to work for me:
You need to have SGABIOS installed. Interestingly this BIOS is not included in the debian qemu package, so you need to install it (as the superuser):
apt install sgabios
Then when you run qemu use the -device option to tell the virtural machine to use the sga output
qemu-system-i386 -nographic -device sga discimage.bin
Voila! works perfectly over ssh with both the monitor and text output sent through stdio. You can access the qemu monitor with C-a c.
cheers, ben
os terminal will not working qemu. So you should use putty on windows pc or you should use linux machine terminal.

Resources