Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sat 17 Aug 2019, 18:58
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Determining device hardware and "drivers" on your system
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [14 Posts]  
Author Message
wiak

Joined: 11 Dec 2007
Posts: 1567
Location: not Bulgaria

PostPosted: Fri 22 Mar 2019, 04:41    Post subject:  Determining device hardware and "drivers" on your system
Subject description: and removing those unneeded
 

Determining "device drivers" (in kernel, external modules, in conjunction sometimes with firmware for hardware devices) used by your computer and how to remove unneeded ones

See also here:

http://murga-linux.com/puppy/viewtopic.php?p=1031078#1031078

Forum member s243a has started a topic concerned with "Stripping Down a Puppy" with the idea of making a new small pup via scripted remastering (or any other method).

http://www.murga-linux.com/puppy/viewtopic.php?t=115715

I felt that one interesting comment on that thread deserved a thread of its own (which I feel it would be useful if first post of "Stripping Down a Puppy" thread could post a link to this one too (since this is a subtopic really of that thread):

nic007 wrote:
What would really be cool for me is a method whereby one can open all the applications one use on a regular basis and any others one wants to keep in the base sfs/ones specific network and printing connections, take a snapshot of the things running (including the firmware/modules/libs/configurations, etc. currently in use) and then rebuild the base sfs to include ONLY the things currently running and in use.


That desire/comment opens up a can of worms, but coming to an understanding of all the associated bits and pieces could well lead to a script that helps provide what nic007 comments about, and thus directly help with "Stripping Down a Puppy"

Just to start the conversation of, here are some explanations I found relatively easy to understand (from excellent technical but easy lecture in first link below, to hard core technical programming info in the link to the "Linux Device Drivers" book"). I imagine there may be some on here that have some info or links or scripts and various commands that are also relevant to detecting the modules/firmware/hardware your system uses and/or concerning how to decide which modules/firmware etc that can be safely removed from your iso for your particular system:


Relatively easy to understand and very nice brief online written 'lecture' about modules etc (a bit dated, but mainly correct):

http://www.haifux.org/lectures/86-sil/kernel-modules-drivers/kernel-modules-drivers.html

Pretty nice info from Ubuntu wiki about meaning of 'Firmware':
https://wiki.ubuntu.com/Kernel/Firmware

A brief explanation of difference between firmware and driver (where a driver might be part of kernel or implemented as an external module held on disc - and a module can be for anything (for example filesystem encryption), not just hardware drivers):
https://stackoverflow.com/questions/16145322/firmware-and-drivers-in-linux

If you are a system level programmer and you really want to get in deep, or have enough technical understanding to glean detailed information from the "Linux Device Drivers" book:

https://www.xml.com/ldd/chapter/book/index.html

[b]Some commands (a sample only); some of which talked about in above links, which hopefully others will also post details about, and more:


lspci -k
lsusb
usb-devices
lsmod
modinfo
dmesg | grep '...'
less /var/log/syslog
EDIT: yes, I forgot that very important ldd command (thanks rufwoof)
lshw [-short] (very useful since can be used in scripts/pipelines; graphical version below:)
lshw-gtk
similar to above is gui hardinfo (available Ubuntu/Debian repos)
...

_________________
Tiny Linux Blog: http://www.tinylinux.info/
Check Firmware: www.murga-linux.com/puppy/viewtopic.php?p=1022797
tinycore/slitaz: http://www.murga-linux.com/puppy/viewtopic.php?p=990130#990130

Last edited by wiak on Thu 27 Jun 2019, 22:04; edited 7 times in total
Back to top
View user's profile Send private message 
rufwoof


Joined: 24 Feb 2014
Posts: 3323

PostPosted: Fri 22 Mar 2019, 06:00    Post subject:  

If you have a 'full' version of the target smaller setup, then running Menu, System, Hardinfo is potentially useful. For example my ethernet is a sky2 and hardinfo shows details as per the attached image for that. Once inside your mini system then just modprobe sky2 ... or whatever within the init script.
hardinfo.png
 Description   
 Filesize   82.79 KB
 Viewed   331 Time(s)

hardinfo.png


_________________
( ͡° ͜ʖ ͡°) :wq
Fatdog multi-session usb

echo url|sed -e 's/^/(c/' -e 's/$/ hashbang.sh)/'|sh
Back to top
View user's profile Send private message 
rufwoof


Joined: 24 Feb 2014
Posts: 3323

PostPosted: Fri 22 Mar 2019, 06:06    Post subject:  

Don't forget the ldd command as well.

For example I like to have mc running in my mini's and running
Code:
# ldd /usr/bin/mc
   linux-vdso.so.1 (0x00007ffdd19a0000)
   libncursesw.so.5 => /lib/libncursesw.so.5 (0x00007efe8b7e5000)
   libtinfo.so.5 => /lib/libtinfo.so.5 (0x00007efe8b5bc000)
   libgmodule-2.0.so.0 => /usr/lib/libgmodule-2.0.so.0 (0x00007efe8b3b8000)
   libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0x00007efe8b0b0000)
   libpthread.so.0 => /lib/libpthread.so.0 (0x00007efe8ae93000)
   libc.so.6 => /lib/libc.so.6 (0x00007efe8ab00000)
   libdl.so.2 => /lib/libdl.so.2 (0x00007efe8a8fc000)
   libpcre.so.1 => /usr/lib/libpcre.so.1 (0x00007efe8a6b9000)
   /lib/ld-linux-x86-64.so.2 (0x00007efe8ba14000)

reveals the libs that requires i.e. copy mc bin to /bin and cp those libs to the /lib folder (linux-vdso.so.1 can be ignored).

_________________
( ͡° ͜ʖ ͡°) :wq
Fatdog multi-session usb

echo url|sed -e 's/^/(c/' -e 's/$/ hashbang.sh)/'|sh
Back to top
View user's profile Send private message 
rufwoof


Joined: 24 Feb 2014
Posts: 3323

PostPosted: Fri 22 Mar 2019, 06:10    Post subject:  

Firmware/modules do take up considerable space and many might go unused. Wondering if you might touch all timestamps for those, use the system extensively and then copy out only those that had a accessed timestamp that had been updated to a later date/time. I've never investigated that avenue myself, just a thought.
_________________
( ͡° ͜ʖ ͡°) :wq
Fatdog multi-session usb

echo url|sed -e 's/^/(c/' -e 's/$/ hashbang.sh)/'|sh
Back to top
View user's profile Send private message 
musher0

Joined: 04 Jan 2009
Posts: 14264
Location: Gatineau (Qc), Canada

PostPosted: Fri 22 Mar 2019, 06:27    Post subject:  

Useful references. Thanks, wiak.
_________________
musher0
~~~~~~~~~~
Je suis né pour aimer et non pas pour haïr. (Sophocle) /
I was born to love and not to hate. (Sophocles)
Back to top
View user's profile Send private message 
nic007


Joined: 13 Nov 2011
Posts: 2983
Location: Cradle of Humankind

PostPosted: Fri 22 Mar 2019, 06:34    Post subject:  

Hardinfo/PupSysinfo does not quite report everything in use. I remember when using Puppy412 way back I once tried to isolate modules and drivers this way but was not successful. A starting point could be not to boot everything into RAM at startup. What happens with the booting when pfix=nocopy is used, is the core needed still copied to RAM? If so, what is the possibility to capture these bare essentials from RAM plus anything started by the user during the session (which should be in RAM if you have enough memory) or wherever it's being stored? I'm probably smoking something......
Back to top
View user's profile Send private message 
wiak

Joined: 11 Dec 2007
Posts: 1567
Location: not Bulgaria

PostPosted: Fri 22 Mar 2019, 07:17    Post subject:  

I also forgot lshw which is handy since can pipe to grep etc:

https://packages.debian.org/search?keywords=lshw

https://ezix.org/project/wiki/HardwareLiSter

On my XenialDog I install with:

Code:
apt install lshw


also a gui

Code:
apt install lshw-gtk


Can get less verbose with:

Code:
lshw -short

_________________
Tiny Linux Blog: http://www.tinylinux.info/
Check Firmware: www.murga-linux.com/puppy/viewtopic.php?p=1022797
tinycore/slitaz: http://www.murga-linux.com/puppy/viewtopic.php?p=990130#990130

Last edited by wiak on Fri 22 Mar 2019, 07:33; edited 1 time in total
Back to top
View user's profile Send private message 
wiak

Joined: 11 Dec 2007
Posts: 1567
Location: not Bulgaria

PostPosted: Fri 22 Mar 2019, 07:23    Post subject:  

and also hardinfo (fancy, user-friendly gui, but lshw commandline program is more interesting since can be used in build system scripts/pipelines with grep and so on)

Debian/Ubuntu:

Code:
apt install hardinfo

_________________
Tiny Linux Blog: http://www.tinylinux.info/
Check Firmware: www.murga-linux.com/puppy/viewtopic.php?p=1022797
tinycore/slitaz: http://www.murga-linux.com/puppy/viewtopic.php?p=990130#990130
Back to top
View user's profile Send private message 
wiak

Joined: 11 Dec 2007
Posts: 1567
Location: not Bulgaria

PostPosted: Fri 22 Mar 2019, 08:02    Post subject:  

My HP Elitebook 2530p gives:

Code:
dmesg | grep 'iwlwifi.*Intel'
[    8.175943] iwlwifi 0000:02:00.0: Detected Intel(R) WiFi Link 5100 AGN, REV=0x54


In terms of finding firmware, an example for my system, which uses iwlwifi module is usefully described in the following two links:

http://www.mxlinux.org/forum/viewtopic.php?t=35844

https://unix.stackexchange.com/questions/452123/where-can-i-find-the-microcode-ucode-that-is-being-loaded-by-iwlwifi-intel-62

For the kernel I'm using
Code:
# uname -a                     
Linux xenial64 4.4.0-59-generic #80-Ubuntu SMP Fri Jan 6 17:47:47 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux


the correct firmware given by:

https://wireless.wiki.kernel.org/en/users/drivers/iwlwifi#firmware

proved to be (from the table given at above link of firmware to use for particular kernel):

Code:
iwlwifi-5000-ucode-8.83.5.1-1.tgz


You can also find that firmware number 8.83.5.1 via command:

Code:
lshw -class network

Code:
       configuration: broadcast=yes driver=iwlwifi driverversion=4.4.0-59-generic firmware=8.83.5.1 build 33692 ip=192.168.1.4 latency=0 link=yes multicast=yes wireless=IEEE 802.11abgn


or, more simply:

Code:
dmesg | grep firmware

Code:
[19172.714401] iwlwifi 0000:02:00.0: loaded firmware version 8.83.5.1 build 33692 op_mode iwldvm


wiak

_________________
Tiny Linux Blog: http://www.tinylinux.info/
Check Firmware: www.murga-linux.com/puppy/viewtopic.php?p=1022797
tinycore/slitaz: http://www.murga-linux.com/puppy/viewtopic.php?p=990130#990130
Back to top
View user's profile Send private message 
rufwoof


Joined: 24 Feb 2014
Posts: 3323

PostPosted: Fri 22 Mar 2019, 09:08    Post subject:  

Remove unneeded modules and firmware - Zdrv_Cutter
http://murga-linux.com/puppy/viewtopic.php?t=51552

Note in particular http://murga-linux.com/puppy/viewtopic.php?p=964181#964181
Quote:
I don't really use this method now since the kernel's introduction of allmodconfig and allyesconfig.
make allmodconfig rebuilds the kernel without support for unused modules.
make allyesconfig will then build those used modules into the kernel

_________________
( ͡° ͜ʖ ͡°) :wq
Fatdog multi-session usb

echo url|sed -e 's/^/(c/' -e 's/$/ hashbang.sh)/'|sh

Last edited by rufwoof on Fri 22 Mar 2019, 09:22; edited 1 time in total
Back to top
View user's profile Send private message 
rufwoof


Joined: 24 Feb 2014
Posts: 3323

PostPosted: Fri 22 Mar 2019, 09:18    Post subject:  

nic007 wrote:
Hardinfo/PupSysinfo does not quite report everything in use. I remember when using Puppy412 way back I once tried to isolate modules and drivers this way but was not successful.

When I created my mini EasyOS based primarily just vmlinuz and (quite a large/extensive) busybox + some, I just wanted net connected and HardInfo was sufficient for my needs at identifying which modules to drop back in again (after clearing them out). 23MB combined vmlinuz and initrd.gz that boots to net connected, tmux, mc, sc-im, weather report, ssh (using dropbear), lynx, calcurse. That's without sound however. When I tried to use Hardinfo to add in sound 1. it bloated a lot and 2. as you say, didn't report everything (i.e. I couldn't get sound working). Primarily I just use that as a very quick boot predominately to get to my calendar (calcurse) quickly from a powered down state, but also serves as a alternative boot choice if/when the main boot might fail.

_________________
( ͡° ͜ʖ ͡°) :wq
Fatdog multi-session usb

echo url|sed -e 's/^/(c/' -e 's/$/ hashbang.sh)/'|sh
Back to top
View user's profile Send private message 
jamesbond

Joined: 26 Feb 2007
Posts: 3357
Location: The Blue Marble

PostPosted: Fri 22 Mar 2019, 11:00    Post subject:  

Finding running/currently used drivers (=modules): use lsmod.
Finding module dependencies: use /lib/modules/$KVER/modules.dep
Finding firmware: boot up and then do "dmesg | egrep 'firmware|failed'". Using modinfo to find firmware isn't reliable.

_________________
Fatdog64, Slacko and Puppeee user. Puppy user since 2.13.
Contributed Fatdog64 packages thread.
Back to top
View user's profile Send private message 
rufwoof


Joined: 24 Feb 2014
Posts: 3323

PostPosted: Sat 23 Mar 2019, 07:12    Post subject:  

For a smaller initrd filesize using extreme xz compression can work, but you have to include the --check=crc32 xz compression parameter when creating the .xz for the kernel to boot it (otherwise just crashes). Applying that to my mini EasyOS results in a 12MB initrd.xz filesize (alongside a 5MB vmlinuz).

Within that I have support for framebuffer (pdf viewing, video watching etc. (but I've not installed sound modules in mine). I have installed tmux, mc, ssh (dropbear), lynx (browser), sc (spreadsheet) etc. and connecting to sdf.org and using that to browse/gopher/message boards/games works well - and has all external traffic routed through that ssh (secure) link (and with capabilities dropped).

I should really extend the init in that to support the option for a more automated firing up of (chroot or switch-root into) a main.sfs (for X, normal 'Puppy' type additional operation). Could even conceptually pull down that main sfs from a remote server prior to loading it up.
c.png
 Description   
 Filesize   9.55 KB
 Viewed   194 Time(s)

c.png


_________________
( ͡° ͜ʖ ͡°) :wq
Fatdog multi-session usb

echo url|sed -e 's/^/(c/' -e 's/$/ hashbang.sh)/'|sh
Back to top
View user's profile Send private message 
wiak

Joined: 11 Dec 2007
Posts: 1567
Location: not Bulgaria

PostPosted: Sun 24 Mar 2019, 01:27    Post subject:  

rufwoof wrote:
Firmware/modules do take up considerable space and many might go unused. Wondering if you might touch all timestamps for those, use the system extensively and then copy out only those that had a accessed timestamp that had been updated to a later date/time. I've never investigated that avenue myself, just a thought.


I like this idea actually; it's a kind of statistical profiling whose accuracy will increase over time for a specific computer/user combination. For the case of trying to build a minimum system that will boot and work well on a multitude of systems/user combinations the collection/merging/accumulation of such data from many others would also, overtime provide a report that approached ideal optimum I'd surmise. With even limited early data it is amazing how accurate long term predictions can be.

Alas, atime doesn't update for files which are simply read:

https://linuxfreelancer.com/linux-why-isnt-linux-updating-file-access-time-atime

wiak

_________________
Tiny Linux Blog: http://www.tinylinux.info/
Check Firmware: www.murga-linux.com/puppy/viewtopic.php?p=1022797
tinycore/slitaz: http://www.murga-linux.com/puppy/viewtopic.php?p=990130#990130
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [14 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0984s ][ Queries: 13 (0.0200s) ][ GZIP on ]