sudo password asked when running yocto image for the first time (only) - yocto

I built core-image-sato-dev and after this when I did
runqemu qemux86 core-image-sato-dev
I got
runqemu - INFO - Running MACHINE=qemux86 bitbake -e...
runqemu - INFO - Continuing with the following parameters:
KERNEL: [/opt/yocto/thud_workspace/build/tmp/deploy/images/qemux86/bzImage--4.18.33+git0+865683fc87_1a564c76f4-r0-qemux86-20220121081907.bin]
MACHINE: [qemux86]
FSTYPE: [ext4]
ROOTFS: [/opt/yocto/thud_workspace/build/tmp/deploy/images/qemux86/core-image-sato-dev-qemux86.ext4]
CONFFILE: [/opt/yocto/thud_workspace/build/tmp/deploy/images/qemux86/core-image-sato-dev-qemux86.qemuboot.conf]
runqemu - INFO - Setting up tap interface under sudo
[sudo] password for yocto:
but only the first time
I don't know what password is this.
The second time I run this the password is not asked anymore
What is setting up tap interface??

[sudo] password for yocto:
I don't know what password is this. The second time I run this the password is not asked anymore
This message is from your OS, not from Yocto. The password is likely to be the login password for the yocto user in your OS.
Yocto is calling a sudo command, and so your OS prompts you to enter your sudo password. You only have to do this once, because your OS is probably remembering your sudo login for a short period of time.
What is setting up tap interface??
A TAP interface can be created within Linux's network stack, that acts like real network hardware on your PC, but each packet it receives can be sent to a userspace program (QEMU in this case) for processing. It can also transmit packets passed to it from that same userspace program.
When QEMU runs your Yocto image, it emulates a virtual hardware device. To emulate the network hardware on this virtual device, QEMU needs a way to get network packets from the real network (on your PC) into the QEMU software, so that they can be passed into the virtual device.
So, when QEMU starts to run your Yocto image, it creates a TAP interface on your PC which is then used to pipe network packets in and out of the virtual device it's emulating.
Creating TAP interfaces on Linux requires higher privileges, and so Yocto automatically runs QEMU as sudo. Otherwise, QEMU would fail with a permissions error.

Related

Raspberry Pi SSH Access Denied

I am trying to log into my Raspberry Pi using PuTTY from Windows. However, whenever I try to log into my Raspberry Pi using the default username and password (pi* and raspberry) it says Access Denied.
I have the wpa_supplicant.conf file and ssh file created. This is its first bootup. I am using the latest version of the Raspbian Lite OS.
Recently, the default user setup of Raspbian was significantly changed, rendering most existing online tutorials invalid.
In essence, the default pi user no longer exists, so you have to create it and set its password using either the official Imager tool or by creating a userconf file in the boot partition of your microSD card, which should contain a single line of text: username:hashed-password, replacing username with the name of the user you want (e.g., pi) and hashed-password with the hash of the password you want.
According to the official guide, the easiest way to do this is by running the following in a terminal (Linux or macOS):
echo 'password' | openssl passwd -6 -stdin
Again, you should replace password with the password you want here.
Further reading: An update to Raspberry Pi OS Bullseye (2022-04-07)
The default username and password are no longer valid for Raspberry Pi.
If you are trying to log in headlessly (without a monitor and keyboard), you can do it from Raspberry Pi Imager itself.
On selecting the OS in Raspberry Pi Imager, you get an icon of settings in which you can
create a user
setup Wi-Fi
enable SSH
After configuring, you can continue flashing your memory card.
And on first boot you will be good to go.
I have solved this problem. You can easily input your username and password with Raspberry Pi Imager.
add the user you created when flashing the image to the ssh group.
usermod -a -G ssh YourPiUsername

Buildroot and Qemu

I'm using buildroot to compile a minimalistic linux with a 4.19-rt kernel. It is supposed to run on a raspberry pi 3b (arm processor). Additionally I want to run it on a x86_64 linux computer and found qemu as an emulation solution for that.
Building linux and kernel and running it on the raspi works. It boots, I can login and use it.
To test qemu I followed this instruction [1]. A recent raspbian with 4.19 kernel is booting fine so qemu seems to be installed correctly.
sudo qemu-system-arm -kernel ./qemu-rpi-kernel/kernel-qemu-4.19.50-buster -hda 2019-09-26-raspbian-buster-lite.img -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" -dtb qemu-rpi-kernel/versatile-pb.dtb
Bringing 1. and 2. together fails. When I try to emulate any self build linux, qemu only shows a black screen and one CPU is using 100%.
I used the same sdcard.img that works on the real hardware. I also tried to recompile the whole system with a normal 4.19 kernel (without real time). And I tried to build a versatile system (make qemu_arm_versatile_defconfig && make). None of it works.
Command to start the emulation:
sudo qemu-system-arm -kernel zImage -drive format=raw,file=sdcard.img -cpu arm1176 -m 256 -M versatilepb -no-reboot -append "root=/dev/mmcblk0p2 panic=1 rootfstype=ext4 rw" -serial stdio
My main problem is, that there is absolutly no useful output. The command outputs the following
ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused
sdl: SDL_OpenAudio failed
sdl: Reason: ALSA: Couldn't open audio device: Connection refused
ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused
sdl: SDL_OpenAudio failed
sdl: Reason: ALSA: Couldn't open audio device: Connection refused
audio: Failed to create voice `lm4549.out'
and opens a window for the graphics output (that does not show anything). The message also appears when emulating raspbian so it does not seem to be the reason.
When I run qemu with the prebuild raspbian but without the -dtb argument, I get a message like "Error: invalid dtb and unrecognized/unsupported machine ID". I would at least expect something like this with my self build code. But because there is no output I'm out of ideas what even to google for.
Does someone maybe have an idea what I'm doing wrong or how I get qemu to provide me any useful information on what went wrong?
[1] https://blog.agchapman.com/using-qemu-to-emulate-a-raspberry-pi/
The problem is that a kernel will only boot on a piece of Arm hardware if it is compiled for that hardware. Otherwise it will generally fail, usually by crashing before it is able to output anything useful.
In particular, the QEMU 'versatilepb' machine is completely different to the Raspberry Pi. Any working set of instructions that use that machine type are really running a kernel built to work with the versatilepb board and a raspi userspace/filesystem on top of that. You're trying to build a kernel that has support for only the raspi on a machine that isn't a raspi, which won't work.
It is possible to build a kernel that works on more than one piece of Arm hardware, if you compile in the support for both board types (all the device drivers for both, etc). If you want to go down that path, I would suggest looking at the differences between the kernel config for the kernel that works and your one, and add plausible looking missing things until you find out what is actually required.
Your attempt to boot on QEMU directly from sdcard.img will not work, because QEMU's versatilepb board model does not support direct boot from sdcard (this would require us to run some kind of BIOS/firmware image in the guest, which we don't have). For versatilepb you need to supply directly to QEMU the kernel, possibly an initrd, and definitely the correct dtb for the versatilepb.
You might instead try looking at QEMU's "raspi2" and "raspi3" board models, which really do model the hardware of Raspberry Pis. The disadvantages however are that these models are missing some features and are not very actively developed, so often newer kernels don't boot on them, and also since there is no USB controller model there is no way to get networking. (This is why most blog posts etc suggest using the 'versatilepb' -- userspace doesn't often really care about exactly what hardware it's running on, so unless you're trying to do kernel development you can just run a versatilepb kernel and take advantage of the features like networking that that QEMU model has.)
Advanced Linux Sound Architecture (ALSA) tries to open audio interface device . you must provide audio device in qemu . Because the kernel is compiled with ALSA audio driver and you have compiled sdl library in Buildroot.

kernel module insertion issue

We are running the latest raspibian on the raspberry pi board and have a kernel driver for a USB peripheral which is added externally (sudo insmod driverx.ko) after boot-up by connecting to the hardware using ssh (its a headless system).
The problem is as follows:
If the device is already connected to the system upon power-up then running sudo insmod driverx.ko leads to the terminal getting stuck (no response, Ctrl+C doesn't work). Running lsmod by starting another ssh session shows that the module is in use even though there is no code running that will use it.
If I plug the USB device after the system boots up then sudo insmod driverx.ko works normally, (the terminal is still active). Running lsmod subsequently shows that that module is loaded but not in use by anyone. I can then run my user code and everything is fine. Upon running my user code lsmod shows the kernel module is in use and the number of users is 1.
In our system the USB device will always be plugged in. The kernel version and the driver version are the same.
I can fill in more details but do not wish to bias or make this query un-readble.
Please advise on what could the problem be.
Thank you for your time and help.
Possibility is that, the device is already attached into some other driver during startup. If it’s the case, the device credential of your specific device has to be removed from the startup driver.
Check the USB device list before to insert your driver.

Run commands on Raspberry Pi when external HDD is connected

I am using a Raspberry Pi to provide network access to a Western Digital media player that has no network interface. The player if just an external HDD and automatically mounts when it is connected.
The problem is that it's HFS formatted, so to be able to read and write it I have to unmount and then remount it with these commands:
sudo umount /dev/sda2
sudo mount -o force -t hfsplus /dev/sda2 /media/wdhdd/
Which works fine, but I don't want to have to SSH in via terminal to run these manually every time I reconnect the HDD.
Is there anyway to auto run a script when an external USB device is mounted?
Because this has to be done every time this USB device is plugged in, you should edit the procedures done when it is plugged in. You can find out more about this by visiting this explanation

qemu KVM kernel module no such file or directory

I am currently taking an operating systems class and I need to use qemu to run a small operating system that my professor provided. I am trying to use qemu within an ubuntu 12.04 virtual machine on virtualbox on my macbook air 5.2. I know the problems I am having probably have to do with nested virtualization but the specific error I get when I try to run qemu is:
Could not access the KVM kernel module: No such file or directory
failed to initialize KVM: no such file or directory
Back to tcg accelerator.
qemu does start up the os but the window flickers quite a lot and I would like to fix the KVM problem if possible. I've done research but I can't find a solution I can understand or that works so any help would be greatly appreciated.
Also for the ubuntu virtual machine in virtualbox I have both Enable VT-x/AMD-V and Enable Nested Paging checked under Hardware Virtualization. I've also tried using
modprobe kvm-intel
and I get this error:
FATAL: Error inserting kvm_intel (/lib/modules.3.5.0-22-generic/kernel/arch/x86/kvm/kvm-intel.ko): Operation not permitted.
In my case, the virtualization was disabled.
So sudo modprobe kvm-intel kept giving me the following error
could not insert 'kvm_intel': Operation not supported
I just had to go in the BIOS and enable Virtualization.
Try with sudo modprobe kvm-intel.
In order to have the module automatically loaded at the startup of the virtual machine, do the following:
Edit the corresponding file from the shell with sudo vim /etc/modules.conf
Possibly enter your username password.
Press the key G to go to the end of the document and then o to begin inserting.
Write kvm-intel and press Enter, producing a new line.
Press Esc to return to the Normal mode of vim. "--INSERT--" will disappear from
the bottom.
Save the file and exit vim by writing :wq.
You are done. Try to reboot and load the nested virtual machine.