Pages - Menu

Showing posts with label hardware. Show all posts
Showing posts with label hardware. Show all posts

Thursday, January 16, 2020

Disable Bluetooth on by default in Ubuntu MATE 18.04

I'd like to have my laptop power up, have the Bluetooth system tray app (blueman) start, but not have the actual Bluetooth powered on by default.

This was an easy change in the terminal:

gsettings set org.blueman.plugins.powermanager auto-power-on false

Thanks to Arch Wiki for this: https://wiki.archlinux.org/index.php/Blueman

Tuesday, February 4, 2014

realtek RTL8188CUS slow on Raspberry Pi

I recently had an adventure troubleshooting slow wifi on one of my Raspberry Pi systems. No matter what I did, I could not get more than 57 kilobytes per second transfer speed to it.

Thursday, August 29, 2013

finding the netdev_priv struct

In addition to the net_device struct within the kernel, network drivers also have their own private or device-specific struct which stores stats unique to the individual hardware.

The name of the struct varies for each device type, however the location remains the same, right after net_device:

linux-2.6.32-358.14.1.el6.x86_64/include/linux/netdevice.h
/**
 *      netdev_priv - access network device private data
 *      @dev: network device
 *
 * Get network device private data
 */
static inline void *netdev_priv(const struct net_device *dev)
{
        return (char *)dev + ALIGN(sizeof(struct net_device), NETDEV_ALIGN);
}
A search in cscope for netdev_priv will show you many functions within drivers which update the priv structure via pointers, for example this one in e1000_main.c:
struct e1000_adapter *adapter = netdev_priv(netdev);
So, given that we know what the device-specific struct is called, and where the device-specific private struct is, how do you find it and read it?

We'll need the ability to read kernel memory using crash, either run on a live system, or in a vmcore captured with kdump:
crash /usr/lib/debug/lib/modules/2.6.32-358.14.1.el6.x86_64/vmlinux /var/crash/2013-08-26/vmcore
We'll also need the debugging symbols for the driver in question:
crash> mod -s e1000 /usr/lib/debug/lib/modules/2.6.32-358.14.1.el6.x86_64/kernel/drivers/net/e1000/e1000.ko.debug
     MODULE       NAME                 SIZE  OBJECT FILE
ffffffffa01550e0  e1000              170678  /usr/lib/debug/lib/modules/2.6.32-358.14.1.el6.x86_64/kernel/drivers/net/e1000/e1000.ko.debug 
The net command will show you the network devices in the system:
crash> net
   NET_DEVICE     NAME   IP ADDRESS(ES)
ffff88007e76b820  lo     127.0.0.1
ffff8800372c0020  eth0   192.168.1.126
We can then cast net_device against this to see the in-kernel device struct:
crash> net_device 0xffff8800372c0020
struct net_device {
  name = "eth0\000\000\060:03.0\000\000\000",
...
But we want to get after this struct and cast it against the struct in the driver.

We need to know how big net_device is:
crash> struct -o net_device
struct net_device {
...
}
SIZE: 1728
We then find the net address plus the size of net_device:
crash> px 0xffff8800372c0020+1728
$1 = 0xffff8800372c06e0
We can now cast the device-specific private struct against this new address:
crash> e1000_adapter 0xffff8800372c06e0
struct e1000_adapter {
  vlgrp = 0x0,
  mng_vlan_id = 65535,
  bd_number = 0,
  rx_buffer_len = 1522,
...
and we're done!

Tuesday, July 9, 2013

akg perception 120 usb mic works on linux

I recently bought an AKG Perception 120 USB microphone to do some voiceover work with.

I couldn't find any reliable source which confirmed whether this works on Linux or not, so hopefully this post will help someone out.

This microphone works great on Linux.

Not only that, it works great full stop. I was using a cheap headset before, and the difference in sound quality is incredible. I'm not any sort of audio expert or audiophile, though I can tell you the constant "hiss" that my old headset produced is eliminated with this new microphone.

I tested using Fedora 18 with kernel 3.9.6-200 which worked fine.
I also tried Ubuntu 13.04 with kernel 3.8.0-19 and that worked too.
However, Ubuntu 12.04.3 with kernel 3.8.0-29 didn't work. It recognised the device but would not pick up sound.

If you wonder about any specific distro, preferably one with a LiveCD, just leave a comment and I'll give it a try if I can.

Here is the output of lsusb on F18 with the device connected:

Bus 001 Device 027: ID 074d:3556 Micronas GmbH Composite USB-Device

Here is the output of dmesg on F18 as the device is connected:

usb 1-1.2: new full-speed USB device number 27 using ehci-pci
usb 1-1.2: New USB device found, idVendor=074d, idProduct=3556
usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1.2: Product: AKG Perception 120 USB
usb 1-1.2: Manufacturer: AKG Acoustics
ALSA sound/usb/clock.c:243 current rate 0 is different from the runtime rate 48000
ALSA sound/usb/clock.c:243 current rate 0 is different from the runtime rate 48000
usbcore: registered new interface driver snd-usb-audio
ALSA sound/usb/clock.c:243 current rate 48000 is different from the runtime rate 44100
ALSA sound/usb/clock.c:243 current rate 48000 is different from the runtime rate 44100

Wednesday, June 20, 2012

grub2 usb keyboard not working

I installed the newly released Fedora 17 this week, only to find I could no longer control the GRUB2 screen to get into Windows to play some games. The keyboard and mouse work perfectly in BIOS, and in Linux once USB drivers are loaded, just not at the GRUB2 screen.

Many forum threads exist for this, most pointing towards the "USB Legacy" or similar option in the BIOS. I had this turned on, however turning it off made no difference either.

GRUB2 can load some driver modules, so perhaps it wasn't loading the USB modules. Adding GRUB_PRELOAD_MODULES="usb usb_keyboard ehci ohci uhci" to /etc/default/grub and then rebuilding the config files with grub2-mkconfig -o /boot/grub2/grub.cfg didn't change anything either.

At this point I started coming across articles mentioning UEFI support for GRUB2. UEFI is the "new BIOS" standard coming out on new motherboards. My motherboard is a fairly new model, so it does have EFI firmware.

Turns out the solution is to install a version of GRUB2 with EFI support. This was done with yum install grub2-efi to install the package, then grub2-efi-install /dev/sda to install the EFI-supporting bootloader onto my hard drive. I regenerated a new config with grub2-efi-mkconfig -o /boot/grub2/grub.cfg while I was at it.

Now my USB keyboard works perfectly in GRUB2.

Monday, February 2, 2009

hard drive temperature monitoring

After having a disk recently die due to heat, I bought an Antec P182 case, designed to keep drives cooler. (FYI: it works really well)

I was interested in monitoring my drive temperatures to see how it goes, and found the hddtemp package can do this. A sudo apt-get install hddtemp will install it for you. Say "Yes" to running the daemon on startup.

To get a list of your drives and where they're mounted, you can use the sudo fdisk -l command, along with df -h and mount to see where partitions end up on the filesystem.

To view the temperature of your drives:
sudo hddtemp /dev/sda
/dev/sda: WDC WD800JD-60LSA5: 40°C

hddtemp sensors also have a wrapper into conky, a lightweight system monitoring display program, with the option ${hddtemp /dev/sda}

General forum consensus seems to be as long as your drives are under 50C, you're fine. 50C-60C is a warning area, and over 60C you're cooking your drives and reducing their lifespan by over half!