Start systemd service after DRM card0 device - systemd

I have kiosk display running an electron app.
This app needs to be started on boot.
[Unit]
Description=Display Application
After=network.target getty#tty1.service
Conflicts=getty#tty1.service
[Service]
Type=simple
ExecStart=/usr/bin/xinit /usr/bin/electron main.js -- :0 -nocursor -nolisten tcp
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
But for some reason this service ist started to early and xinit complains with no screens found. After the first systemd restart the app is running.
I searchd systemd device which sounded promising. But using dev-dri-card0 as Requires and After results in Missing Dependency in startup.
# ls /dev/dri
by-path card0 renderD128
# dmesg | grep drm
[ 3.609070] systemd[1]: Starting Load Kernel Module drm...
[ 3.672741] systemd[1]: modprobe#drm.service: Succeeded.
[ 3.673192] systemd[1]: Finished Load Kernel Module drm.
[ 4.327074] fb0: switching to inteldrmfb from EFI VGA
[ 4.332654] i915 0000:00:02.0: [drm] Finished loading DMC firmware i915/bxt_dmc_ver1_07.bin (v1.7)
[ 4.356201] i915 0000:00:02.0: [drm] Panel advertises DPCD backlight support, but VBT disagrees. If your backlight controls don't work try booting with i915.enable_dpcd_backlight=1. If your machine needs this, please file a _new_ bug report on drm/i915, see https://gitlab.freedesktop.org/drm/intel/-/wikis/How-to-file-i915-bugs for details.
[ 4.367399] [drm] Initialized i915 1.6.0 20200917 for 0000:00:02.0 on minor 0
[ 4.376167] fbcon: i915drmfb (fb0) is primary device
[ 4.402186] i915 0000:00:02.0: [drm] fb0: i915drmfb frame buffer device
# systemctl list-units -a -t device | grep card0
dev-dri-card0.device loaded inactive dead /dev/dri/card0
I have no glue whats wrong here. Found some posts saying that drm module is loaded to late (after systemd) ... added drm to initramfs ... no luck.

Ok found a solution
[Unit]
Description=Display Application
After=network.target systemd-user-sessions.service
Conflicts=getty#tty1.service
[Service]
TTYPath=/dev/tty1
PAMName=systemd-user
Environment=NODE_ENV=production
ExecStart=/usr/bin/xinit /usr/bin/electron main.js -- :0 -quiet -nocursor -nolisten tcp
Restart=on-failure
RestartSec=5
[Install]
Alias=display-manager.service
WantedBy=multi-user.target
This way the systemd-logind brings up a user session and all the drm stuff is ready.

Related

Qemu: Emulating Raspberry pi with Buster OS on MacOS X (CLI works, but blank screen)

Trying to figure out why I have a blank screen for my Raspberry Pi running Buster OS in Qemu but do have a function CLI? Here's what I run:
$ qemu-system-arm -M versatilepb -cpu arm1176 -m 256 -hda ./raspbian-buster-full.qcow -net nic -net user,hostfwd=tcp::5022-:22 -dtb ./versatile-pb.dtb -kernel ./kernel-qemu-4.19.50-buster -append 'root=/dev/sda2 panic=1 rootfstype=ext4 rw' -no-reboot -serial stdio
And end up with a few failure messages:
vpb_sic_write: Bad register offset 0x2c
...
Welcome to Raspbian GNU/Linux 10 (buster)!
systemd[1]: Set hostname to <raspberrypi>.
systemd-fstab-generator[41]: Mount point file is not a valid path, ignoring.
...
[FAILED] Failed to start Load Kernel Modules.
See 'systemctl status systemd-modules-load.service' for details.
...
[FAILED] Failed to start rng-tools.service.
See 'systemctl status rng-tools.service' for details.
Not sure what vpb_sic_write: Bad register offset 0x2c relates to or the [FAILED] Failed to start Load Kernel Modules. But I'm OK with [FAILED] Failed to start rng-tools.service. because I think rng-tools are related to random number generation, and I don't need that.
At first I thought the lack of display was due to no console specified in the append option, but in the boot script I did see the following, which leads me to believe that was not the problem.
clocksource: arm,sp804: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275 ns
sched_clock: 32 bits at 1000kHz, resolution 1000ns, wraps every 2147483647500ns
Failed to initialize '/amba/timer#101e3000': -22
sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
Console: colour dummy device 80x30
console [tty0] enabled
Any advice? Thanks!

How to disable vmwgfx driver without compiling a new kernel on Ubuntu?

I know I can disable it by compiling a new kernel without setting CONFIG_DRM_VMWGFX in config file. But I don't want build a new kernel, can I achieve it by modify some configurations?
I tried to delete vmwgfx.ko from the lib/modules/XXX/kernel/driver directory, then reboot, but the driver works well On Ubuntu 16.04. Why? Is the file elsewhere?
And I also tried to rmmod,but it's not work.
[root#ubuntu:] lsmod |grep vmwgfx
vmwgfx 235405 4
drm_kms_helper 159169 1 vmwgfx
ttm 99345 1 vmwgfx
drm 370825 7 ttm,drm_kms_helper,vmwgfx
[root#ubuntu:] rmmod -f vmwgfx
rmmod: ERROR: ../libkmod/libkmod-module.c:793 kmod_module_remove_module()
could not remove 'vmwgfx': Resource temporarily unavailable
[root#ubuntu:] modprobe -r vmwgfx
modprobe: FATAL: Module vmwgfx is in use.
Finally, I know how to do it.
The reason for my situation is that the driver's file is stored in initramfs-xxx.img. So we need to rebuild a initramfs-xxx.img.
find file path: modinfo vmwgfx
filename: /lib/modules/4.4.0-21-generic/kernel/drivers/gpu/drm/vmwgfx/vmwgfx.ko
version: 2.9.0.0
license: GPL and additional rights
description: Standalone drm driver for the VMware SVGA device
author: VMware Inc. and others
srcversion: AC179B70460E5C5D32AC416
alias: pci:v000015ADd00000405sv*sd*bc*sc*i*
depends: ttm,drm,drm_kms_helper
intree: Y
vermagic: 4.4.0-21-generic SMP mod_unload modversions
parm: enable_fbdev:Enable vmwgfx fbdev (int)
parm: force_dma_api:Force using the DMA API for TTM pages (int)
parm: restrict_iommu:Try to limit IOMMU usage for TTM pages (int)
parm: force_coherent:Force coherent TTM pages (int)
parm: restrict_dma_mask:Restrict DMA mask to 44 bits with IOMMU (int)
remove the driver file mv /lib/modules/$(uname -r)/kernel/driver/gpu/drm/vmwgfx/vmwgfx.ko /home/$(whoami)/.
backup your boot img: mv /boot/initrd.img-`uname -r` /home/`whoami`/
rebuld boot img: mkinitrd -f /boot/initrd.img-`uname -r` `uname -r`
reboot
If you want to remove other build-in driver file, this method works well.
If your vm is centos, just choose the correct file path and boot img name.

uart-baudrate is changed multiple times during boot

I can not figure out, where the uart, baudrate is changed in the linux kernel.
I am using the adi_uart4.c driver (not in the major 4.14 kernel yet). But it is designed like all the other in driver/tty/serial/
While booting:
CONFIG_BAUDRATE 115200 -> uboot baudrate
earlyprintk=serial,uart0,115200 -> cmdline arg in uboot
console=ttySC0,115200 -> cmdline arg in uboot
??? -> set to 56700
Linux boot output stops, because of baudrate change:
[..]
Freeing unused kernel memory: 1024K
Starting logging: OK
Starting mdev...
Starting watchdog...
Initializing random number generator... done.
Starting network...
/bin/sh: run-parts: not found
Starting inetd: OK
��怘�~3f<��<����f<���3�f��Æ�����`?怘���<f?����`<?����`?<��~<�����������
Thank you #sawdust.
There was an additional userspace change in /etc/inittab
# Put a getty on the serial port
ttySC0::respawn:/sbin/getty -L ttySC0 56700 vt100 # GENERIC_SERIAL

How to set up the Machine Type (arch_id) for Linux Kernel Arm Cross-Compile

I would like to know how to set the correct MACH_TYPE or arch_id for the kernel. I searched and found at least 2 references where the kernel would hang at "Starting Kernel ... ". These came with the same answer. Correctly set your Machine Type. But then neither mentions how to do so. Anyone know how to do this?
Pretty good explanation for the hang. and Another good description.
Both of these are close to what I am experiencing when I try to boot my kernel. It gets stuck on "Starting Kernel..." and won't continue. I have built the kernel several times from .configs that were supposed to be exactly for my model.
Timesys (LinuxLink) provides a .config that is supposed to match the kernel that they provide with their free build service. But that doesn't work either. If I use their pre-built kernel it boots up no problem. So I know it is not my u-boot or how I have configured my SD-card. The problem must come from the kernel build.
I run my make like: make ARCH=arm CROSS_COMPILE=${PATH_TO_TOOLCHAIN}/bin/armv7l-timesys-linux-gnueabi- uImage and make my image as follows: sudo mkimage -A arm -O linux -T kernel -C none -a 0x70800000 -e 0x70800000 -n "Linux-2.6.35-ts-armv7l" -d arch/arm/boot/uImage ../../uImage
I am working with a Freescale i.MX53 Eval Board. When I try to run the kernel:
U-Boot 2009.08-dirty (Aug 02 2013 - 19:57:03)
CPU: Freescale i.MX53 family 2.1V at 800 MHz
mx53 pll1: 800MHz
mx53 pll2: 400MHz
mx53 pll3: 432MHz
mx53 pll4: 455MHz
ipg clock : 66666666Hz
ipg per clock : 33333333Hz
uart clock : 66666666Hz
cspi clock : 108000000Hz
ahb clock : 133333333Hz
axi_a clock : 400000000Hz
axi_b clock : 200000000Hz
emi_slow clock: 133333333Hz
ddr clock : 400000000Hz
esdhc1 clock : 80000000Hz
esdhc2 clock : 80000000Hz
esdhc3 clock : 80000000Hz
esdhc4 clock : 80000000Hz
nfc clock : 26666666Hz
Board: MX53-LOCO 1.0 Rev. B
Boot Reason: [POR]
Boot Device: SD
I2C: ready
DRAM: 1 GB
MMC: FSL_ESDHC: 0,FSL_ESDHC: 1
In: serial
Out: serial
Err: serial
Serial reinitilized!
Net: got MAC address from IIM: 00:04:9f:01:f7:ce
FEC0 [PRIME]
Hit any key to stop autoboot: 0
mmc0 is current device
MMC read: dev # 0, block # 2048, count 8192 ... 8192 blocks read: OK
## Booting kernel from Legacy Image at 70800000 ...
Image Name: Linux-2.6.35-ts-armv7l
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2999932 Bytes = 2.9 MB
Load Address: 70800000
Entry Point: 70800000
Verifying Checksum ... OK
XIP Kernel Image ... OK
OK
Starting kernel ...
u-boot env:
bootdelay=3
baudrate=115200
netdev=eth0
ethprime=FEC0
uboot=u-boot.bin
kernel=uImage
nfsroot=/opt/eldk/arm
bootargs_base=setenv bootargs console=ttymxc0,115200
bootargs_nfs=setenv bootargs ${bootargs} root=/dev/nfs ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp
bootcmd_net=run bootargs_base bootargs_nfs; tftpboot ${loadaddr} ${kernel}; bootm
bootcmd=run bootcmd_mmc
ethact=FEC0
lcd=video=mxcdi0fb:RGB24,SEIKO-WVGA di0_primary
bootargs_mmc=setenv bootargs ${bootargs} gpu_nommu ${lcd} ip=dhcp root=/dev/mmcblk0p1 rootwait rw
bootargs=console=ttymxc0,115200 gpu_nommu video=mxcdi0fb:RGB24,SEIKO-WVGA di0_primary ip=dhcp root=/dev/mmcblk0p1 rootwait rw
bootcmd_mmc=run bootargs_base bootargs_mmc; mmc dev 0; mmc read ${loadaddr} 0x800 0x2000; bootm
loadaddr=0x70800000
stdin=serial
stdout=serial
stderr=serial
The issue is that a double u-boot header has been applied to the image. As per unixsmurf.

xen installation on cent os 6.3

I followed tutorial http://www.howtoforge.com/virtualization-with-xen-on-centos-6.2-x86_64-paravirtualization-and-hardware-virtualization
To install xen on Centos 6.3 everything is going perfect but, after editing /boot/grub/menu.lst
Quote:
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/mapper/vg_xen-LogVol01
# initrd /initrd-[generic-]version.img
#boot=/dev/sdb
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32.57-2.el6xen.x86_64)
root (hd0,0)
kernel /xen.gz dom0_mem=1024M cpufreq=xen dom0_max_vcpus=1 dom0_vcpus_pin
kernel /vmlinuz-2.6.32.57-2.el6xen.x86_64 ro root=/dev/mapper/vg_xen-LogVol01 rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_xen/LogVol01 rd_LVM_LV=vg_xen/lv_swap rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=128M KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32.57-2.el6xen.x86_64.img
title CentOS (2.6.32-279.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-279.el6.x86_64 ro root=/dev/mapper/vg_xen-LogVol01 rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_xen/LogVol01 rd_LVM_LV=vg_xen/lv_swap rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=128M KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-279.el6.x86_64.img
when i reboot it is booted with xen kernel but when i run command
xm info or xm list
showing error
" Error: Unable to connect to xend: No such file or diectory. Is xend running "
when i run command
xend start
showing error
" xc: error: Could not obtain handle on privileged command interface (2 = No such file or directory): Internal error
xend/image.py: Error connecting to hypervisor "
ls /proc/xen
" ls: cannot access /proc/xen: No such file or directory "
added entry in /etc/fstab
Quote:
none /proc/xen xenfs default 0 0
after reboot gives error no such file or directory,
lsmod | grep -i xen output: Nothing...
modprob xen-evtchn
FATAL: Error inserting xen_evtchn (/lib/modules/2.6.32.57-2.el6xen.x86_64/kernel/drivers/xen/xen-evtchn.ko): No such device
modprob xen-gntdev
FATAL: Error inserting xen_gntdev (/lib/modules/2.6.32.57-2.el6xen.x86_64/kernel/drivers/xen/xen-gntdev.ko): No such device
I have enabled hardware virtulization in bios still problem not solved.
I tried another tutorial https://www.crc.id.au/xen-on-rhel6-scientific-linux-6-centos-6-howto/
it seems like nothing is working for me...
Guys... please share your thoughts about this problem...
Thank you.
i ran into this too in booting a Xen dom0 kernel.
i might have spotted one small omission in your grub.conf compared to the instructions.
in the grub config section at this line: "replace the first word initrd with module."
for example, here's my working Xen Dom0 grub.conf.
good luck!
default=0
timeout=2
title CentOS 6.3 Xen dom0
root (hd0,0)
kernel /boot/xen.gz loglvl=all guest_loglvl=all
module /boot/vmlinuz-dom0-kernel ro root=/dev/sda1 nomodeset console=ttyS0,115200 iommu=off earlyprintk=xen initcall_debug debug loglevel=10
module /boot/initrd-dom0-kernel.img
title CentOS 6.3 (No Xen)
root (hd0,0)
kernel /boot/vmlinuz-dom0-kernel ro root=/dev/sda1
initrd /boot/initrd-dom0-kernel.img
title Stock CentOS 6.3
root (hd0,0)
kernel /boot/vmlinuz-centos6.3 ro root=/dev/sda1
initrd /boot/initrd-centos6.3.img
This does the trick!
Check your boot entries in grub. I just upgraded my Centos 6.3 with the kernel-xen-3.5.3-1 to 3.7.1-3 and the new boot entry for this kernel gets wrong because between updates I installed a standard kernel for testing other things.
Fixing the correct boot options for xen brings back my virtualization!
title CentOS (3.7.1-3.el6xen.x86_64)
root (hd0,0)
kernel /xen.gz dom0_mem=1024M cpufreq=xen dom0_max_vcpus=4 dom0_vcpus_pin
module /vmlinuz-3.7.1-3.el6xen.x86_64 ro root=UUID=<longUUID> KEYBOARDTYPE=pc KEYTABLE=us LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 crashkernel=auto rhgb quiet
module /initramfs-3.7.1-3.el6xen.x86_64.img
I had the same issue:
Could not obtain handle on privileged command interface (2 = No such file or directory): Internal error
This was solved by adding the below line in /etc/fstab
none /proc/xen xenfs defaults 0 0
See this post in the Xen Project mailing list for more details.

Resources