Page 1 of 1

A small tool for when hardware is not recognized...

Posted: Thu 22 May 2014, 04:22
by Ibidem
Here's a little tool to make the kernel check for PCI devices and partitions.
Rechecking PCI devices is equivalent to

Code: Select all

echo "1" >/sys/bus/pci/rescan
Usage is "hwrs -p" for PCI rescan,
"hwrs -b" for checking for partitions; "hwrs" and "hwrs -bp" trigger both.
This probably seems silly; it's intended to be a suid tool for multiuser systems.
(Long explanation: I have an Acer Aspire One where PCI hotplug doesn't work OOB, the wireless flakes out if PCI hotplug is enabled, and both SD card readers are powered off until a card is inserted--meaning that they require PCI hotplug or a rescan.
Also, I run into problems with removable devices not getting partitions enumerated until I try mounting them or something like that; this throws off setting up /etc/fstab for user mount.
I didn't want to login as root every time I plugged in an SD card, so I needed some sort of suid helper, which meant writing it in C...)

It's written as a "toy" for toybox (the equivalent of an "applet" in busybox). To build it, get a recent version of the toybox source, then drop hwrs.c in toys/pending/ and type

Code: Select all

CFLAGS="-Os -static" scripts/single.sh hwrs
(You can also set CC, CROSS_COMPILE, or several other variables the same way.)
This build is linked statically with a fairly current musl and sstrip'ed.

Posted: Thu 22 May 2014, 04:36
by starhawk
I'd love to see this for USB. I have this USB to parallel port dongle that uses a weird Chinese chip, and I'd love to know whether there's just no driver for it, or if the reason it's not being picked up is kernel stubbornness...

Posted: Thu 22 May 2014, 06:46
by Ted Dog
what hardware is your acer one. I have had wierd issues with stuff plugged in and not being seen until a different event. mine came with some sad software called win8. :wink:

Posted: Thu 22 May 2014, 22:15
by Ibidem
@starhawk, as far as I know USB devices are always detected via hotplug; there's no rescan file in sysfs.
"If I were troubleshooting it," ;)
I'd do something like this:

Code: Select all

lsusb -v >usb.old
#plug it in, wait a moment
dmesg |tail
lsusb -v >usb.new
diff -U 0 usb.old usb.new
If it's "live", it will show up with a "+" before it in the output of diff; if it isn't, forget trying to get it working.
The next step would be to look in /sys/bus/usb/devices/*/id* for the vendor and product id, cd to the directory that matches, and look at
(1) the contents of "modalias" and "uevent", and (2) the driver, if any (basename `readlink -f driver`)

Speaking of modalias, I'll have to post resolve_modalias...

@Ted Dog: Acer Aspire One AOA150-1786 aka ZG5.
CPU is Intel Atom N270 (hyperthreading single-core).

resolve modalias to module name

Posted: Thu 22 May 2014, 22:34
by Ibidem
resolve_modalias will convert a series of module aliases to module names.
Example (how to view all modules that could be used for all USB devices your computer recognizes):

Code: Select all

cat /sys/bus/usb/devices/*/modalias|xargs ./resolve_modalias
Source is used the same as for hwrs.

Posted: Thu 22 May 2014, 23:20
by starhawk
@Ibidem -- then it's not got a driver in Puppy. It's a weird chip -- usually these are PL2305 chips inside these dongles, but this one is a QinHeng Electronics CH340. What little I can find on it, indicates that it can be configured as USB->RS-232 (COMport serial), USB->IEEE-1284 (LPTport parallel), or USB->I2C (I2C is a very standard serial protocol, sometimes referred to as the Two Wire Interface because that's the number of signal wires it uses... clock, data, and ground.)

Mine is of course configured as IEEE1284 (LPTport parallel). I can find a driver for it that implements the COMport functionality, but that really doesn't help me here... particularly because it ONLY implements the COMport functionality, with no support for either of the other two protocols at all. That (useless to me) driver has source code here --> http://lxr.free-electrons.com/source/dr ... al/ch341.c

Posted: Fri 23 May 2014, 00:06
by Ted Dog
Ibidem wrote:@starhawk, as far as I know USB devices are always detected via hotplug; there's no rescan file in sysfs.
"If I were troubleshooting it," ;)
I'd do something like this:

Code: Select all

lsusb -v >usb.old
#plug it in, wait a moment
dmesg |tail
lsusb -v >usb.new
diff -U 0 usb.old usb.new
If it's "live", it will show up with a "+" before it in the output of diff; if it isn't, forget trying to get it working.
The next step would be to look in /sys/bus/usb/devices/*/id* for the vendor and product id, cd to the directory that matches, and look at
(1) the contents of "modalias" and "uevent", and (2) the driver, if any (basename `readlink -f driver`)

Speaking of modalias, I'll have to post resolve_modalias...

@Ted Dog: Acer Aspire One AOA150-1786 aka ZG5.
CPU is Intel Atom N270 (hyperthreading single-core).
we have same..

Posted: Fri 23 May 2014, 01:20
by Ibidem
@Ted Dog: Not quite the same, I suspect. I doubt that a new Win8 machine came with an Atom N270.
Mine came with XP on a 160gb 5400RPM HDD, Atheros "AR5BXB63"/AR5007(some nonsense I forget...) a/b/g wireless, RTL8102E 10/100 ethernet, and 1 gig of DDR2 ram.
AFAICT, the GPU (945GM) is incapable of OGL 3.x or DirectX 10+.

@starhawk: sounds like junk.
Allegedly, back in 2008 usblp could get some portion of a print job across that gadget/chip, with some mutilation and an eventual crash.
The author of the CH341 serial driver is still in business (Kingswood Consulting), FYI.

Posted: Fri 23 May 2014, 02:07
by Ted Dog
I have three.. win xp win 7 and win 8. different acer one models.. :lol: sorry I have trouble with all three. the xp sdcards are tricky. Mom stole or permanental borrowed my win7 model. and my win 8 is full of little gotchas mostly 9f microsoft doing including boot from usb and disabled hardware stuff.. oh and the usb3 dropping power and usb unmounting under fatdog. :roll:
I just started to play with older 2008 xp model after just missing the one time only trade in by a week. Had to charge it up.

Posted: Fri 23 May 2014, 02:18
by Ibidem
Ted Dog wrote:I have three.. win xp win 7 and win 8. different acer one models.. :lol: sorry I have trouble with all three. the xp sdcards are tricky. Mom stole or permanental borrowed my win7 model. and my win 8 is full of little gotchas mostly 9f microsoft doing including boot from usb and disabled hardware stuff.. oh and the usb3 dropping power and usb unmounting under fatdog. :roll:
I just started to play with older 2008 xp model after just missing the one time only trade in by a week. Had to charge it up.
Well, the sd cards in the xp one are what hwrs was written for.
I haven't bought a new computer since a while after Win7 came out (Thinkpad X100e), and I'm hoping to find a decently priced MIPS laptop come time for the next procurement, which may be several years away. (I'm thinking MIPS because it cannot run Windows.)
Although a build-it-yourself Snapdragon S5+ or Seattle system does sound somewhat fun. Seattle is AMD's ARM64 Opteron.