Saturday, January 11, 2014

Xubuntu on Lenovo Ideapd Z510

Introduction

My wife gifted me a Lenovo Ideapad Z510 for Christmas :-) The laptop has great specifications:
  • Intel(R) Core(TM) i7-4700MQ CPU
  • Integrated Intel(R) HD Graphics 4600
  • 8 GB RAM (I intend to increase this to 16 GB)
  • 1 TB Hard Drive
  • 1920x1080 screen resolution
  • AccuType back-lit keyboard
  • Bluetooth
  • VGA + HDMI out
  • JBL Speakers
  • DVD RW Drive
I usually run Linux on my laptop for my various hobby projects. I installed Xubuntu 13.10 on this laptop with a few tweaks which I want to share with other folks who have been exploring installing Xubuntu (or Ubuntu) on their Ideapads. This information is not a tutorial but lists tweaks and caveats for folks who are familiar with Linux installation steps.

LiveCD

Xubuntu 13.10 boots fine on Ideapad except when X starts you get a blank screen. The reason is the backlight of the screen is turned off for some reason. You can turn it on by increasing the screen brightness by pressing Fn+F12 a few times. Also make sure that Linux has booted in EFI mode by checking that /sys/firmware/efi does exist. If not then check that BIOS has EFI turned on.

Partitions

Make sure gparted has detected the partition as GPT type. If you are not planning to store lots of data on Windows then you can shrink the primary Windows partition labeled as Windows8_OS using gparted to a smaller size like 300 GB. The hard disk comes with many other partitions for windows use which I did not change. I created the usual swap, home and root partitions for Linux. Here is the output of blkid command after partitioning:

/dev/sda1: LABEL="WINRE_DRV" UUID="1E6E08E66E08B893" TYPE="ntfs"
/dev/sda2: LABEL="SYSTEM_DRV" UUID="D60B-686A" TYPE="vfat"
/dev/sda3: LABEL="LRS_ESP" UUID="560B-B719" TYPE="vfat"
/dev/sda5: LABEL="Windows8_OS" UUID="5A560F07560EE39B" TYPE="ntfs"
/dev/sda6: LABEL="NO_LABEL" UUID="DEDC67F9DC67CA7B" TYPE="ntfs"
/dev/sda7: UUID="3cefbe49-3512-4949-919e-0f474d8e7164" TYPE="swap" LABEL="SWAP"
/dev/sda8: LABEL="ROOT" UUID="665aa505-9dae-47fc-885e-a17ad78563aa" TYPE="ext4"
/dev/sda9: LABEL="HOME" UUID="30fc2cad-1abc-4a0a-bd1e-a402a1fa2636" TYPE="ext4"
/dev/sda10: LABEL="ROOT2" UUID="751076e8-41ea-4f43-951c-1799bfa40199" TYPE="ext4"
/dev/sda11: LABEL="LENOVO" UUID="5AC81599C815748B" TYPE="ntfs"
/dev/sda12: LABEL="PBR_DRV" UUID="36B61179B6113AB7" TYPE="ntfs"

Wireless

Wireless will not work in default installation. Z510 has Broadcom BCM43142  which the standard Linux kernel does not seem to support yet. I had to install the DKMS package, bcmwl-kernel-source from the Ubuntu repository to get the wireless to work. This will taint the kernel though.

Bluetooth

The laptop has a built-in Broadcom BCM43142A0 Bluetooth adapter. It is connected to an internal USB port. The vendor/product Id revealed by lsub command is 105b:e065. This Bluetooth adapter requires the correct firmware otherwise you get a flaky behavior. The Linux version of the firmware can be built from the Windows firmware file. Download the hex2hcd tool from https://github.com/jessesung/hex2hcd. The windows firmware for this adapter is here -- C:\Windows\System32\drivers/BCM43142A0_001.001.011.0161.0172.hex. Copy this file to your Linux partition and run:

hex2hcd BCM43142A0_001.001.011.0161.0172.hex fw-105b_e065.hcd

Note that the name of the generated firmware should match the vendor/product Id obtained by lsusb. Copy the generated firmware file, fw-105b_e065.hcd to /lib/firmware. Unload and then reload the kernel module btusb. If this does not work then reboot the laptop.

Display

When X display manger starts, the screen would turn dark because the screen brightness gets reset to zero for some unknown reason. To workaround this problem, add the following to your /etc/rc.local:

echo 50 > /sys/devices/pci0000:00/0000:00:02.0/backlight/acpi_video0/brightness

Touchpad

The laptop has ALPS GlidePoint touchpad which incorrectly gets recognized as a generic PS/2 mouse. The latest Linux kernel does not support this revision of hardware but a patch exists and was discussed here-- http://askubuntu.com/questions/398568/ubuntu-13-10-touchpad-drivers-not-working-synaptics-not-loaded-lenovo-ideapad/417518#417518

Just follow the steps in the weblink and ALPS GlidePoint would start working.

Suspend/Resume

Suspend is fine but resume occasionally has issues. Sometimes, the laptop would re-suspend itself immediately after resume and sometimes it would hang after resume. I haven't investigated this yet. 

Conclusion

Ideapad Z510 makes a great laptop both as a Linux based development and as a entertainment platform. The built-in Intel GPU supports OpenGL 3.0 on Linux and runs openarena well. The feel of the keyboard is excellent. I specially love the full arrow keys which are handy if you are using an editor like emacs.

Monday, September 17, 2012

Dell Latitude Freefall Sensor On Linux

Dell Latitude laptops come with a freefall sensor which is essentially a hidden accelerometer exposed to the system as an ACPI device, SMO8800. In Windows the device shows up as ACPI\SMO8800 for which Dell provides a driver. Unfortunately there is no existing Linux driver for this device until now that is :-)

I have written a Linux driver for this device after reverse engineering the DSDT tables of the laptop. This is how the device shows up in DSDT:

Scope (\_SB.PCI0)
    {
        Device (A_CC)
        {
            Name (_HID, "SMO8800")
            Method (_STA, 0, NotSerialized)
            {
                Return (0x0F)
            }

            Name (_UID, One)
            Name (BUF2, ResourceTemplate ()
            {
                Interrupt (ResourceConsumer, Edge, ActiveHigh, Exclusive, ,, )
                {
                    0x00000017,
                }
            })
            Method (_CRS, 0, Serialized)
            {
                Return (BUF2)
            }

            Method (_SRS, 1, Serialized)
            {
                Return (BUF2)
            }
        }
    } 

Essentially the device uses IRQ 23 to notify the system whenever it detects a free fall. Note that it does not expose any IO ports for more general programming or reading 3 Axes acceleration values.

I started with a basic Linux driver which detected freefall conditions and just did a printk(). I eventually enhanced the driver to add the /dev/freefall interface similar to LIS3LV02DL driver.

Grab the driver source from https://github.com/sonals/SMO8800

Update (June 11, 2014)

Thanks to Pali Rohár. The driver has been upstreamed; it would appear in Linux kernel 3.16.

Thursday, December 30, 2010

Maytag Fire Hazard

Off late, the oven of my 4 year old Maytag Gas Range (Model # MGR4452BDS) has started randomly turning on by itself. This started a couple of months back when, I came back from office in the evening, and found the oven on. I thought I might have accidentally turned it on in the morning while preparing breakfast. Then, about a month back I woke up to a burning smell at about 2 in the morning. I ran to the kitchen to find my range on again. The handles of two cooking pans which had been kept inside the oven at night, had overheated and were releasing smoke. The next night it happened again and thankfully this time the oven was empty. I called Maytag Customer Assistance. They advised me against using the range and disconnecting the power till the range is examined by their representative, AE Factory Service at no cost to me. So far so good.

The technician visited us on December 6, 2010 and after examining the Gas Range explained that the Main Board needs to be replaced. He placed an order for the Main Board immediately and apprised that Maytag will bear the cost of the part and it should arrive within next one week. The part never came. Later that week, we were notified by AE Services that AE Services/Maytag is having trouble finding that part. I subsequently called Maytag which said that the part is on back order and would not be delivered before March 2011. They also suggested that they can search for that part with their dealers, in case one of them has it. In case the part is found, I am required to buy the part and pick it up myself -- Maytag showing how less it cares for its customers.

Subsequently, we did receive a call from Maytag advising that the part has been located with some dealer and that I should get the part myself. I later called Maytag and argued that the part should be replaced free of cost by the company since this is no minor anomaly. The product is failing in a very unsafe manner creating a dangerous situation. When the representative did not budge, I asked for his supervisor. I was told that the supervisor would call us back in 48 hours, needless to say no one called.

Googling for this problem shows several hits:

http://www.homeownershub.com/maintenance/oven-turns-itself-on-385451-.htm
http://forum.appliancepartspros.com/oven-repair-including-ranges-cooktops/105796-maytag-oven-turning-itself.html
http://www.consumeraffairs.com/homeowners/maytag_oven.html

Seems to be a known problem with Maytag Gas Ranges. For record, I have also reported this to the 
U.S. Consumer Product Safety Commission.


Update (July 31, 2011)


Apparently somebody at Maytag paid attention to this life threatening defect in the oven. Out of the blue I found a UPS packet on July 15 at my front-door. The packet contained the replacement Main Board. When I called Maytag to inquire about the shipment, the representative said that they have no record of it. Her advice was that if I have not paid for the part but still had received it, it is most likely a free replacement paid for by Maytag. 
Probably some department in Maytag realized that this is indeed a case of manufacturing defect resulting in a life threatening situation. I scheduled a visit from  AE Factory Service for the installation of the replacement Main Board. They promptly installed the Main Board on July 19. Finally, after a wait of 7 months my oven was repaired free of cost by Maytag. I wonder if I should thank them for relenting or should I thank my patience.

Monday, October 25, 2010

Volume Keys Without Pulseaudio On Ubuntu

I have always wondered the need for pulseaudio on Linux desktops. There are many reasons to think so. One of the most important stated objectives behind pulseaudio, simultaneous access to sound cards, was never a problem in the presence of ALSA plugins dmix and dsnoop. Note that dmix and dsnoop are turned on by default on Ubuntu. This means that in the absence of pulseaudio, multiple applications can still access the sound card at the same time. Other than the misleading motive, pulseaudio suffers from implementation challenges: it is a CPU hog, some applications mysteriously lose their audio with it, and audio stutters under CPU load. In my opinion, Ubuntu should really revisit their decision to ship pulseaudio. 

Unfortunately, on Ubuntu 10.04 and 10.10, if pulseaudio is uninstalled, the volume keys on laptops and or the volume keys/knobs on some fancy keyboards, do not work at all. In this situation there is no way to change the volume except using the ALSA utilities, alsamixer or amixer. To workaround this deficiency and also to learn a bit of DBus programming, I wrote a perl script to enable the use of volume keys when pulseaudio is not installed. The script also displays the changed volume in the notification area. I should point out that the script does not replace the functionality of a sound mixer such as gnome-volume-control or alsamixer. 

Download the script, volumekey.pl from the link below and save it to your ~/bin/volumekey.pl. Note that the script requires the following packages: libnet-dbus-perl, libdesktop-notify-perl, and alsa-utils. Make sure that these packages are installed on your machine.


https://docs.google.com/leaf?id=0B5pBVMJp4F1PMzY3MjMxOGYtYmE1ZS00ZWMzLThjNGMtNGY1ZmQ5ZGFkNzE5&sort=name&layout=list&num=50


Add the script to your System->Preferences->Startup Applications.

Tuesday, October 19, 2010

Fujitsu LifeBook Shock Sensor on Linux

Some Fujitsu Lifebook laptops (for example A6030) come with a so called Shock Sensor technology. The technology is used to protect the hard disk in case of sudden impact to the laptop. Fujitsu provides a Windows Filter Driver, FJGSDisk.sys. They also have an application which uses this driver to read accelerometer values and draw a graph. This feature of the laptop is not supported on Linux– the hardware details of the accelerometer chip used and how the chip is wired to the motherboard, is not publicly available.

I have been spending some time trying to understand how this sensor works in Windows in the hope of enabling this feature on Linux. I used WinDbg over Firewire and monitored the calls to WIN32 kernel functions, WRITE_PORT_UCHAR and READ_PORT_UCHAR made by FJGSDisk.sys. The driver uses two different ports for reading from and writing to the accelerometer sensor. In addition each of the three axes seem to have a unique Id, including an additional Id which apparently is used to reset the axis. Details are in the table below--


WRITE_PORT 0xfd70
READ_PORT0xfd74
X_AXIS0xa6
Y_AXIS0xa7
Z_AXIS0xa8
RESET_AXIS? 0xa9

Reading accelerometer output for a particular axis involves writing the axis Id to the write port. This is followed by a read operation on the read port. On Linux this would translate to something like the following--

outb(X_AXIS, WRITE_PORT);
val = inb(READ_PORT);

I wrote a simple user space application which does the above, but inb always returns 0. Note that my application does call iopl(3) and is run as root. The failure to read any values from inb makes me think that the accelerometer hardware is not getting initialized on Linux. Interestingly, ports 0xfd70 and 0xfd74 also show up in the BIOS ACPI tables. It appears that the ACPI provides routines to read and write to these ports. Possibly digging into the ACPI DSDT will help. Will update the blog if I find something interesting.

In the meanwhile, here are some links to other webpages with reference to the Shock Sensor reverse engineering:

http://www.digriz.org.uk/debian/fujitsu/t2010

http://www.woodmann.com/forum/showthread.php?11772-Fujitsu-3D-Shock-Sensor-Application-Reversing




Thursday, October 14, 2010

Eclipse ADT plugin on Ubuntu 10.10 after upgrade from 10.04

Recently, after upgrading my Ubuntu to 10.10 from 10.04, I found that my Eclipse Android Development Toolkit plugin stopped working. The Eclipse Help->Installation Details Menu would list ADT under Installed Software Tab. However, neither the Features Tab nor the Plug-ins Tab would list ADT. I noticed that my SVN plugin was not showing up after the upgrade too. Forums such as http://forum.xda-developers.com/showthread.php?p=8613858 were not useful either -- they suggested uninstalling Eclipse which came with Ubuntu 10.10 distribution and replacing it with stock Eclipse from eclipse.org website. I solved this without reinstalling eclipse although, plugins need to reinstalled.

An inotifywatch -r on the ~/.eclipse/org.eclipse.platform_3.5.0_155965261/plugins directory, and subsequently starting eclipse revealed that eclipse was not even trying to read any plugins from that directory. Apparently something in Ubuntu 10.10 build of Eclipse has changed which causes it ignore the previously installed plugins. So I moved out my old ~/.eclipse/org.eclipse.platform_3.5.0_155965261/ directory to /tmp. Restarted my Eclipse and reinstalled my ADT and other plugins. Here are the steps:
  1. Exit eclipse if running
  2. Delete ~/.eclipse/org.eclipse.platform_3.5.0_155965261
  3. Start eclipse
  4. Open Help->Install New Software
  5. Install GEF plugin from http://download.eclipse.org/tools/gef/updates/releases. Note that GEF is required for ADT
  6. Install ADT plugin from https://dl-ssl.google.com/android/eclipse

You should have a working ADT in Eclipse on an upgraded Ubuntu 10.10.

Saturday, February 6, 2010

Mazoid updated

Based on the users' feedback, Mazoid has been updated.


  • Mazes are colorful and look vibrant
  • Orientation Sensor data scaling is more precise
  • New Spotlight mode -- have the adventure of solving the maze with limited visibility
Here are the new screen-shots: