Testing Linux kernel drivers - testing

i am newbie to linux kernel and all, is there any way to check the entry points of linux kernel drivers from command line? say for leds-lp5523?
i have seen this document says we can run some sample LED patterns by running the echo commands by running
cd /sys/class/leds/lp5523:channel2/device echo "load" > engine3_mode echo "9d80400004ff05ff437f0000" > engine3_load echo "111111111" > engine3_leds echo "run" > engine3_mode
But i cant find this /sys/class/leds/lp5523:channel2/device directory in my Ubuntu x86-64 PC.
Can anyone help me on this.
Thanks in advance..

This file will not be created until you actually have an LP5523 connected. I doubt this is the case on your PC as this is an i2c chip.
Else, you found the correct documentation. You can usually find two different interfaces for drivers, either device files (usually found in /dev) that are using the usually syscalls (open, read, write, ioctl) or a sysfs interface (found in /sys), the documentation is then found in Documentation/ABI/.
The best way to find whch interface the driver is using is still to read the source code for that driver.

Related

How can I setup simple-scan on my nixos host for an HP OfficeJet Pro

I have an HP OfficeJet Pro 8610, and a nixos host.
I can easily set up the printer in cups, using hplip and a hp:/net/... address.
But how can I set up scanning with simple-scan? It doesn't recognize the existence of the printer, neither does sane-find-scanner or scanimage -L.
I have tried running hp-setup, but that fails complaining of error: No module named enum. I have tried installing python27Packages.enum in my user environment and also in the system environment, but no dice.
Thanks,
The problem was that the nix derivation was missing a dependency; specifically on the enum package in python. Luckily, somebody else already spotted and fixed this here; one just needs to update one's nix channel to pick it up.
To use scanning in general in NixOS with an OfficeJet Pro 8610, see here.

Access pagemap in gem5 FS mode

I am trying to run an application which uses pagemap in gem5 FS mode.
But I am not able to use pagemap in gem5. It throws below error -
"assert(pagemap>=0) failed"
The line of code is:
int pagemap = open("/proc/self/pagemap", O_RDONLY);
assert(pagemap >= 0);
Also, If I try to run my application on gem5 terminal with sudo ,it throws error-
sudo command not found
How can I use sudo in gem5 ??
These problems are not gem5 specific, but rather image / Linux specific, and would likely happen on any simulator or real hardware. So I recommend that you remove gem5 from the equation completely, and ask a Linux or image specific question next time, saying exactly what image your are using, kernel configs, and provide a minimal C example that reproduces the problem: this will greatly improve the probability that you will get help.
I have just done open("/proc/self/pagemap", O_RDONLY) successfully with: this program and on this fs.py setup on aarch64, see also these comments.
If /proc/<pid>/pagemap is not present for any file, do the following:
ensure that procfs is mounted on /proc. This is normally done with an fstab entry of type:
proc /proc proc defaults 0 0
but your init script needs to use fstab as well.
Alternatively, you can mount proc manually with:
mount -t proc proc proc/
you will likely want to ensure that /sys and /dev are mounted as well.
grep the kernel to see if there is some config controlling the file creation.
These kinds of things are often easy to find without knowing anything about the kernel.
If I do:
git grep '"pagemap'
to find the pagemap string, which is likely the creation point, on v4.18 this leads me to fs/proc/base.c, which contains:
#ifdef CONFIG_PROC_PAGE_MONITOR
REG("pagemap", S_IRUSR, proc_pagemap_operations),
#endif
so make sure CONFIG_PROC_PAGE_MONITOR is set.
sudo: most embedded / simulator images don't have it, you just login as root directly and can do anything by default without it. This can be seen by the conventional # in the prompt instead of $.

install proxmox from usb device error

I try to install Proxmox using a USB, and when I click to install, I see the next error:
testing cdrom /dev/sr0
umount: can't umount /mnt: Invalid argument
testing again in 5 seconds
Finally:
no cdrom found - unable to continue (type exit or CTRL-D to reboot)
I prepare the USB using ImageUSB in Windows, and it does have the previous fail, then I try to prepare in Ubuntu using dd if=pve-cd.iso of=/dev/XYZ bs=1M, I don't know where is the problem.
For someone out there still having similar issue, use below method to create the installation media. That should help.
Instructions for Windows
Download Etcher from https://etcher.io , select the ISO and your USB Drive.
If this doesn’t work, alternatively use the OSForensics USB installer from http://www.osforensics.com/portability.html
Instructions for GNU/Linux
You can simply use dd on UNIX like systems. First download the ISO image, then plug in the USB stick. You need to find out what device name gets assigned to the USB stick (see below). Then run:
dd if=proxmox-ve_*.iso of=/dev/XYZ bs=1M
Note: Be sure to replace /dev/XYZ with the correct device name.
Caution: Be very careful, and do not overwrite the hard disk!
Instructions from: https://pve.proxmox.com/wiki/Install_from_USB_Stick

Kinect / Primesense (Xtion) ROS Ubuntu through Virtual Machine (VMware)

Since it took me quite some time to figure out how to get Xtion (Primesense) to work on VMware I thought to share it here with you. (with Kinect I have a problem to let ROS see the device even though VMware has successfully connected it).
roslaunch openni2_launch openni2.launch
Running the above command gave me the error:
Warning: USB events thread - failed to set priority. This might cause loss of data...
I either got a single frame or no frame when running "rviz" and Add --> Image --> Image topic --> /camera/rgb/image_raw
So how do I get video frames in Ubuntu from a Primesense device while using a Virtual Machine (VMware)?
My specs
Windows 7 running VMware 10.0.4 build-2249910
Ubuntu 12.04.5 Precise in VMware
ROS Hydro
The following question pointed me in the right direction: http://answers.ros.org/question/77651/asus-xtion-on-usb-30-ros-hydro-ubuntu-1210/?answer=143206#post-id-143206
In the answer of blizzardroi (not selected answer) he/she mentions that USBInterface should be 0. I reasoned that since my main Machine is Windows, I should set UsbInterface to 1, which indeed solved it.
Solution
Go to /etc/openni2/ (from system folder, not Home) and open PS1080.ini with administrator rights (e.g. sudo gedit PS1080.ini). Search for UsbInterface, remove the ; and change the value to 1. It should look like below:
; USB interface to be used. 0 - FW Default, 1 - ISO endpoints (default on Windows), 2 - BULK endpoints (default on Linux/Mac/Android machines)
UsbInterface=1
Additional
From previous experience it may also be related that your Windows system may need the kinect drivers as well. If the above not works, try to install the following:
(Kinect SDK) https://www.microsoft.com/en-us/download/details.aspx?id=34808
(OpenNI2 Windows) http://structure.io/openni
p.s. Don't forget your drivers for Ubuntu (replace hydro with your ROS version)
sudo apt-get install ros-hydro-openni*
Important
It doesn't solve the error below, but rviz returns video, which means that we can read the data the Primesense device publishes!
Warning: USB events thread - failed to set priority. This might cause loss of data...
Got the same warning from opennni (issued at start by a binary located at Tools/PSLinkConsole) with another sensor.
Solved by starting process as sudo - my guess: to set priority to USB event threads you need root access. :)

How detect whether running under valgrind in make file or shell script?

I need to detect whether my Makefile is running under valgrind (indirectly, using valgrind --trace-children=yes), I know how to do it from C but I have not found a way to do it from a script,
The earlier answers works on Linux only. For Mac OS X I am an going to grep for VALGRIND_STARTUP_PWD in the environment, unless someone has a better idea.
from a shell:
grep -q '/valgrind' /proc/$$/maps && echo "valgrindage"
This determines if the valgrind preloaded libraries are present in address map of the process. This is reasonably effective, but if you happen to have a non-valgrind related library that shares the '/valgrind' moniker then you will get a false positive (unlikely).
[I changed the grep pattern from vg_preload to /valgrind, as testing on Debian/Ubuntu revealed that the library name was different, while a directory match of valgrind is most likely to succeed.]