Why Xorg server fails on system created with Buildroot for Raspberry Pi4? - opengl-es

I am trying to create my own system for Raspberry Pi4 using Buildroot.
Target is to make custom OS with Xorg, Qt5 and OpenGLESv2 HW rendering. I create my custom Buildroot configuration, nothing specific yet. Very similar to default raspberry pi4 buildroot config but enabled Xorg/Mesa/OpenGLES. My config is that:
BR2_arm=y
BR2_cortex_a72=y
BR2_ARM_FPU_NEON_VFPV4=y
BR2_CCACHE=y
BR2_CCACHE_DIR="$(BR2_EXTERNAL_I_TREE_PATH)/../.buildroot-ccache"
BR2_TOOLCHAIN_BUILDROOT_GLIBC=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y
BR2_TARGET_GENERIC_HOSTNAME="MyHost"
BR2_TARGET_GENERIC_ISSUE="Welcome to MyHost"
BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
BR2_TARGET_GENERIC_ROOT_PASSWD="4rt56gbd"
BR2_SYSTEM_DHCP="eth0"
BR2_ROOTFS_USERS_TABLES="$(BR2_EXTERNAL_I_TREE_PATH)/board/rpi4/users.txt"
BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL_I_TREE_PATH)/rootfs_overlay/"
BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL_I_TREE_PATH)/board/rpi4/post-build.sh"
BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL_I_TREE_PATH)/board/rpi4/post-image.sh"
BR2_ROOTFS_POST_SCRIPT_ARGS="--add-miniuart-bt-overlay"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,raspberrypi,linux,967d45b29ca2902f031b867809d72e3b3d623e7a)/linux-967d45b29ca2902f031b867809d72e3b3d623e7a.tar.gz"
BR2_LINUX_KERNEL_DEFCONFIG="bcm2711"
BR2_LINUX_KERNEL_DTS_SUPPORT=y
BR2_LINUX_KERNEL_INTREE_DTS_NAME="b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
BR2_PACKAGE_XFONT_FONT_ADOBE_UTOPIA_TYPE1=y
BR2_PACKAGE_XFONT_FONT_ARABIC_MISC=y
BR2_PACKAGE_XFONT_FONT_BH_100DPI=y
BR2_PACKAGE_XFONT_FONT_BH_75DPI=y
BR2_PACKAGE_XFONT_FONT_BH_LUCIDATYPEWRITER_100DPI=y
BR2_PACKAGE_XFONT_FONT_BH_LUCIDATYPEWRITER_75DPI=y
BR2_PACKAGE_XFONT_FONT_BH_TTF=y
BR2_PACKAGE_XFONT_FONT_BH_TYPE1=y
BR2_PACKAGE_XFONT_FONT_BITSTREAM_100DPI=y
BR2_PACKAGE_XFONT_FONT_BITSTREAM_75DPI=y
BR2_PACKAGE_XFONT_FONT_BITSTREAM_TYPE1=y
BR2_PACKAGE_XFONT_FONT_CRONYX_CYRILLIC=y
BR2_PACKAGE_XFONT_FONT_DAEWOO_MISC=y
BR2_PACKAGE_XFONT_FONT_DEC_MISC=y
BR2_PACKAGE_XFONT_FONT_IBM_TYPE1=y
BR2_PACKAGE_XFONT_FONT_ISAS_MISC=y
BR2_PACKAGE_XFONT_FONT_JIS_MISC=y
BR2_PACKAGE_XFONT_FONT_MICRO_MISC=y
BR2_PACKAGE_XFONT_FONT_MISC_CYRILLIC=y
BR2_PACKAGE_XFONT_FONT_MISC_ETHIOPIC=y
BR2_PACKAGE_XFONT_FONT_MISC_MELTHO=y
BR2_PACKAGE_XFONT_FONT_MUTT_MISC=y
BR2_PACKAGE_XFONT_FONT_SCHUMACHER_MISC=y
BR2_PACKAGE_XFONT_FONT_SCREEN_CYRILLIC=y
BR2_PACKAGE_XFONT_FONT_SONY_MISC=y
BR2_PACKAGE_XFONT_FONT_SUN_MISC=y
BR2_PACKAGE_XFONT_FONT_WINITZKI_CYRILLIC=y
BR2_PACKAGE_XFONT_FONT_XFREE86_TYPE1=y
BR2_PACKAGE_XDATA_XCURSOR_THEMES=y
BR2_PACKAGE_NODM=y
BR2_PACKAGE_XTERM=y
BR2_PACKAGE_OPENBOX=y
BR2_PACKAGE_RPI_FIRMWARE=y
BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI4=y
BR2_PACKAGE_RPI_FIRMWARE_X=y
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_LIBDRI2=y
BR2_PACKAGE_OPENSSH=y
BR2_PACKAGE_SUDO=y
BR2_PACKAGE_S6=y
BR2_PACKAGE_S6_LINUX_UTILS=y
BR2_PACKAGE_S6_PORTABLE_UTILS=y
BR2_PACKAGE_UTIL_LINUX_BINARIES=y
BR2_PACKAGE_UTIL_LINUX_KILL=y
BR2_PACKAGE_UTIL_LINUX_MOUNT=y
BR2_TARGET_ROOTFS_EXT2=y
BR2_TARGET_ROOTFS_EXT2_4=y
BR2_TARGET_ROOTFS_EXT2_SIZE="512M"
# BR2_TARGET_ROOTFS_TAR is not set
BR2_PACKAGE_HOST_DOSFSTOOLS=y
BR2_PACKAGE_HOST_GENIMAGE=y
BR2_PACKAGE_HOST_MTOOLS=y
First issue comes with X server.
It starts working but very strange/ubnormal. Xorg logs show me lines:
(II) xfree86: Adding drm device (/dev/dri/card1)
(II) xfree86: Adding drm device (/dev/dri/card0)
(II) no primary bus or device found falling back to sys/devices/platform/gpu/drm/card1
But on normal Raspbian OS X server first adds card0 then card1. And makes fall back to card0. Why my Xorg starts with card1?
I think this is my main issue, because of that later GLX extension does not start. And so I cannot make OpenGLES working in my system.
In my config.txt i have line
dtoverlay=vc4-fkms-v3d
and I belive vc4 drivers start properly because I see /dev/dri/card0 /dev/dri/card1 and /dev/dri/renderD128 devices
Maybe someone had similar experience?
What I am doing wrong?

My fault in question.
I was wrong that issue was in order of /dev/dri/card? adding by Xorg.
Issue was different. xserver built in buildroot needs libglamor enabled? this should be enabled in buildroot config. If enabled then es2_info reports no issue with OpenGLES.. besides that in my case still glmark2-es2 does not work with error "Failed to open bo 1: Permission denied"

Related

buildroot raspberrypi3_defconfig how to enable SPI?

I'm trying to make a RPI3 buildroot image with CAN interface.
So far I don't see any device in /sys/bus/spi/devices
Please help
What I did are below
At the buildroot terminal "make raspberrypi3_defconfig" then enabled those below via "make xconfig" and "make linux-xconfig"
BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV
BR2_PACKAGE_IPROUTE2
NET
CAN
CAN_DEV
SPI
CAN_MCP251X
After that I flashed sdcard.img to an SD card then I add those two lines below to config.txt
dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=12000000,interrupt=25
I expected to see spi0.0 but I don't see any device in /sys/bus/spi/devices
Can you please help?
Thank you

Terminal input doesn't work in QNX running on VM or x86 hardware

I'm doing a university project on QNX RTOS (using an academic license). I'm following Building a BSP.
So far I've managed to build (using bios_mkusbimage script in the BSP archive) .img file for x86_64 target. Then I converted .img to .vdi file (VBoxManage convertdd input.img output.vdi) and finally loaded it. The result is:
Or, as text:
Loading IFS...decompressing...done
System page at phys:000000000010c000 user:ffff808000003000 kern 808000006000
Starting next program at vffff80000007388b MFLAGS=1 .11 ClockCycles offsets within tolerance elcome to Q. Neutrino SDP 7.0 on x8664 system
Starting slogger2 server ...
Starting PCI server ...
Set PCI device list ...
Starting EIDE block driver ...
unable to access /dev/hd0t179 'ot3Tt11:7.n:nele7i7la:TensleieCted
Starting USD host ...
Starting devb-umass o audio device has been detected
Starting input services ...
Starting serial driver ...
Starting consoles ...
Starting shells ...
#
The OS seems to boot successfully, but I'm unable to type anything.
I'm looking either for a way to fix the keyboard input, or get a SSH/telnet/... connection to the QNX shell.

udevadm to retrieve device attribute

OS: Ubuntu 16.04
Ethernet chip: Intel I210
Ethernet driver: igb
I've looked into my etherent device attribute.
By typing the command
udevadm info -p -a /sys/class/net/eth0
I got the following information:
looking at device '/devices/pci0000:00/0000:00:1c.2/0000:02:00.0/net/eth0':
KERNEL=="eth0"
SUBSYSTEM=="net"
DRIVER==""
ATTR{mtu}=="1500"
ATTR{type}=="1"
ATTR{netdev_group}=="0"
ATTR{flags}=="0x1003"
ATTR{speed}=="1000"
ATTR{dormant}=="0"
ATTR{addr_assign_type}=="0"
ATTR{dev_id}=="0x0"
ATTR{duplex}=="full"
ATTR{gro_flush_timeout}=="0"
ATTR{iflink}=="2"
ATTR{addr_len}=="6"
ATTR{address}=="0c:c4:7a:12:b4:e4"
ATTR{operstate}=="up"
ATTR{carrier_changes}=="2"
ATTR{broadcast}=="ff:ff:ff:ff:ff:ff"
ATTR{tx_queue_len}=="1000"
ATTR{dev_port}=="0"
ATTR{ifalias}==""
ATTR{ifindex}=="2"
ATTR{link_mode}=="0"
ATTR{carrier}=="1"
looking at parent device '/devices/pci0000:00/0000:00:1c.2/0000:02:00.0':
KERNELS=="0000:02:00.0"
SUBSYSTEMS=="pci"
DRIVERS=="igb"
ATTRS{irq}=="18"
ATTRS{subsystem_vendor}=="0x15d9"
ATTRS{broken_parity_status}=="0"
ATTRS{class}=="0x020000"
ATTRS{index}=="1"
ATTRS{label}==" Intel Ethernet controller#1 i210"
ATTRS{driver_override}=="(null)"
ATTRS{consistent_dma_mask_bits}=="64"
ATTRS{dma_mask_bits}=="64"
ATTRS{local_cpus}=="00000000,00000000,00000000,00000000,00000000,00000000,00000000,0000000f"
ATTRS{device}=="0x1533"
ATTRS{enable}=="1"
ATTRS{msi_bus}=="1"
ATTRS{local_cpulist}=="0-3"
ATTRS{vendor}=="0x8086"
ATTRS{subsystem_device}=="0x1533"
ATTRS{numa_node}=="-1"
ATTRS{d3cold_allowed}=="1"
Some questions below:
what is the relationship between "device" and "parent device"
Are these attributes retrieved from firmware ( on device ) or BIOS or driver ?
Is it possible to modify the attribute value ?
I ask this is because as you may know, Ubuntu 15.10 and newer version has taken the rule of predictable network interface names. For the onboard device, it will be recognized as "enox" and x means its index.
Unfortunately, on my host, my two ethernets have the same index and this causes the race condition. If I did not revert back to the original network interface naming rule, the boot is gonna take about 4 mins.
I suspect it's the firmware issue.

ovs2.6: could not create netdev dpdk1 of unknown type dpdk

I am trying to setup OVS2.6 with DPDK16.07. I am following INSTALL.DPDK.md instructions that came under openvswitch-2.6.0.tar.gz. Getting following warning message in ovs-vswitchd.log:
00034|netdev|WARN|could not create netdev dpdk1 of unknown type dpdk
00035|bridge|WARN|could not open network device dpdk1 (Address family not supported by protocol)
Googling little bit shows this issue is faced by earlier ovs version as well, but I didn't find any satisfactory solution.
Any idea what could be rootcause, and how to fix it?
Thanks!
All ports that are to be used by Open vSwitch must be bound to the uio_pci_generic, igb_uio or vfio-pci module before the application is run. Any network ports under Linux control will be ignored by OvS or any DPDK application.
Please check the output of $DPDK_DIR/tools/dpdk-devbind.py scripts with -s parameter. You must see some ports in "Network devices using DPDK-compatible driver" section like below;
$/dpdk-stable-16.07.2/tools$ ./dpdk-devbind.py -s
Network devices using DPDK-compatible driver
============================================
0000:05:00.0 '82571EB Gigabit Ethernet Controller (Copper)' drv=igb_uio unused=e1000e
0000:05:00.1 '82571EB Gigabit Ethernet Controller (Copper)' drv=igb_uio unused=e1000e
I have the same issue as well, and by checking the code I found that before starting ovs-vswitchd, we should use the command below, to initialize dpdk.
ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-init=true

How does Linux Kernel know where to look for driver firmware?

I'm compiling a custom kernel under Ubuntu and I'm running into the problem that my kernel doesn't seem to know where to look for firmware. Under Ubuntu 8.04, firmware is tied to kernel version the same way driver modules are. For example, kernel 2.6.24-24-generic stores its kernel modules in:
/lib/modules/2.6.24-24-generic
and its firmware in:
/lib/firmware/2.6.24-24-generic
When I compile the 2.6.24-24-generic Ubuntu kernel according the "Alternate Build Method: The Old-Fashioned Debian Way" I get the appropriate modules directory and all my devices work except those requiring firmware such as my Intel wireless card (ipw2200 module).
The kernel log shows for example that when ipw2200 tries to load the firmware the kernel subsystem controlling the loading of firmware is unable to locate it:
ipw2200: Detected Intel PRO/Wireless 2200BG Network Connection
ipw2200: ipw2200-bss.fw request_firmware failed: Reason -2
errno-base.h defines this as:
#define ENOENT 2 /* No such file or directory */
(The function returning ENOENT puts a minus in front of it.)
I tried creating a symlink in /lib/firmware where my kernel's name pointed to the 2.6.24-24-generic directory, however this resulted in the same error. This firmware is non-GPL, provided by Intel and packed by Ubuntu. I don't believe it has any actual tie to a particular kernel version. cmp shows that the versions in the various directories are identical.
So how does the kernel know where to look for firmware?
Update
I found this solution to the exact problem I'm having, however it no longer works as Ubuntu has eliminated /etc/hotplug.d and no longer stores its firmware in /usr/lib/hotplug/firmware.
Update2
Some more research turned up some more answers. Up until version 92 of udev, the program firmware_helper was the way firmware got loaded. Starting with udev 93 this program was replaced with a script named firmware.sh providing identical functionality as far as I can tell. Both of these hardcode the firmware path to /lib/firmware. Ubuntu still seems to be using the /lib/udev/firmware_helper binary.
The name of the firmware file is passed to firmware_helper in the environment variable $FIRMWARE which is concatenated to the path /lib/firmware and used to load the firmware.
The actual request to load the firmware is made by the driver (ipw2200 in my case) via the system call:
request_firmware(..., "ipw2200-bss.fw", ...);
Now somewhere in between the driver calling request_firmware and firmware_helper looking at the $FIRMWARE environment variable, the kernel package name is getting prepended to the firmware name.
So who's doing it?
From the kernel's perspective, see /usr/src/linux/Documentation/firmware_class/README:
kernel(driver): calls request_firmware(&fw_entry, $FIRMWARE, device)
userspace:
- /sys/class/firmware/xxx/{loading,data} appear.
- hotplug gets called with a firmware identifier in $FIRMWARE
and the usual hotplug environment.
- hotplug: echo 1 > /sys/class/firmware/xxx/loading
kernel: Discard any previous partial load.
userspace:
- hotplug: cat appropriate_firmware_image > \
/sys/class/firmware/xxx/data
kernel: grows a buffer in PAGE_SIZE increments to hold the image as it
comes in.
userspace:
- hotplug: echo 0 > /sys/class/firmware/xxx/loading
kernel: request_firmware() returns and the driver has the firmware
image in fw_entry->{data,size}. If something went wrong
request_firmware() returns non-zero and fw_entry is set to
NULL.
kernel(driver): Driver code calls release_firmware(fw_entry) releasing
the firmware image and any related resource.
The kernel doesn't actually load any firmware at all. It simply informs userspace, "I want a firmware by the name of xxx", and waits for userspace to pipe the firmware image back to the kernel.
Now, on Ubuntu 8.04,
$ grep firmware /etc/udev/rules.d/80-program.rules
# Load firmware on demand
SUBSYSTEM=="firmware", ACTION=="add", RUN+="firmware_helper"
so as you've discovered, udev is configured to run firmware_helper when the kernel asks for firmware.
$ apt-get source udev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Need to get 312kB of source archives.
Get:1 http://us.archive.ubuntu.com hardy-security/main udev 117-8ubuntu0.2 (dsc) [716B]
Get:2 http://us.archive.ubuntu.com hardy-security/main udev 117-8ubuntu0.2 (tar) [245kB]
Get:3 http://us.archive.ubuntu.com hardy-security/main udev 117-8ubuntu0.2 (diff) [65.7kB]
Fetched 312kB in 1s (223kB/s)
gpg: Signature made Tue 14 Apr 2009 05:31:34 PM EDT using DSA key ID 17063E6D
gpg: Can't check signature: public key not found
dpkg-source: extracting udev in udev-117
dpkg-source: unpacking udev_117.orig.tar.gz
dpkg-source: applying ./udev_117-8ubuntu0.2.diff.gz
$ cd udev-117/
$ cat debian/patches/80-extras-firmware.patch
If you read the source, you'll find that Ubuntu wrote a firmware_helper which is hard-coded to first look for /lib/modules/$(uname -r)/$FIRMWARE, then /lib/modules/$FIRMWARE, and no other locations. Translating it to sh, it does approximately this:
echo -n 1 > /sys/$DEVPATH/loading
cat /lib/firmware/$(uname -r)/$FIRMWARE > /sys/$DEVPATH/data \
|| cat /lib/firmware/$FIRMWARE > /sys/$DEVPATH/data
if [ $? = 0 ]; then
echo -n 1 > /sys/$DEVPATH/loading
echo -n -1 > /sys/$DEVPATH/loading
fi
which is exactly the format the kernel expects.
To make a long story short: Ubuntu's udev package has customizations that always look in /lib/firmware/$(uname -r) first. This policy is being handled in userspace.
Wow this is very useful information and it led me to the solution for my problem when making a custom USB kernel module for a device requiring firmware.
Basically, every Ubuntu brings a new rehash of hal,sysfs,devfs,udev,and so on...and things just change. In fact I read they stopped using hal.
So let's reverse engineer this yet again so it's pertinent to the latest [Ubuntu] systems.
On Ubuntu Lucid (the latest at time of writing), /lib/udev/rules.d/50-firmware.rules is used. This file calls the binary /lib/udev/firmware, where magic happens.
Listing: /lib/udev/rules.d/50-firmware.rules
# firmware-class requests, copies files into the kernel
SUBSYSTEM=="firmware", ACTION=="add", RUN+="firmware --firmware=$env{FIRMWARE} --devpath=$env{DEVPATH}"
The magic should be something along these lines (source: Linux Device Drivers, 3rd Ed., Ch. 14: The Linux Device Model):
echo 1 to loading
copy firmware to data
on failure, echo -1 to loading and halt firmware loading process
echo 0 to loading (signal the kernel)
then, a specific kernel module receives the data and pushes it to the device
If you look at Lucid's source page for udev, in udev-151/extras/firmware/firmware.c, the source for that firmware /lib/udev/firmware binary, that's exactly what goes on.
Excerpt: Lucid source, udev-151/extras/firmware/firmware.c
util_strscpyl(datapath, sizeof(datapath), udev_get_sys_path(udev), devpath, "/data", NULL);
if (!copy_firmware(udev, fwpath, datapath, statbuf.st_size)) {
err(udev, "error sending firmware '%s' to device\n", firmware);
set_loading(udev, loadpath, "-1");
rc = 4;
goto exit;
};
set_loading(udev, loadpath, "0");
Additionally, many devices use an Intel HEX format (textish files containing checksum and other stuff) (wiki it i have no reputation and no ability to link). The kernel program ihex2fw (called from Makefile in kernel_source/lib/firmware on .HEX files) converts these HEX files to an arbitrary-designed binary format that the Linux kernel then picks up with request_ihex_firmware, because they thought reading text files in the kernel was silly (it would slow things down).
On current Linux systems, this is handled via udev and the firmware.agent.
Linux 3.5.7 Gentoo, I have the same issue.
SOLVED:
emerge ipw2200-firmware
Then go to /usr/src/linux
make menucofig
on device driver, remove all wirless drivers don't needed, set Intell 2200 as module and recompile.
make
make modules_install
cp arch/x86/boot/bzImage /boot/kernel-yourdefault

Resources