Thursday, September 17, 2015

Touchpad Sensitivity for Kali 2.0 on an Acer C720 (Chromebook)

So, I didn't play with touchpad too much after installing Kali 2.0 on my Acer C720 Chromebook (see previous post). It turns out that the touchpad sensitivity to fingers is pretty high by default, which means that it doesn't always register finger movements and taps. There is a fix to this in the synaptics settings, and there a few ways to get to it.

First, the command synclient will show all of the related settings. Type it into a command line and see. The settings that control sensitivity are "FingerHigh" and "FingerLow". By default, FingerLow is set to 25 and FingerHigh is set to 30. So, use the command:

root@pc:~# synclient | grep -e 'Finger'

This will a handful of settings, including FingerHigh and FingerLow. To temporarily change them, use the command synclient <variable>=<value>.

root@pc:~# synclient FingerLow=6
root@pc:~# synclient FingerHigh=10


If you try to set FingerHigh=10 before moving FingerLow to 6, then the system will complain. That is because you are trying to set the "high" value (30->10) lower than the "low" value (25). So change low to 6, then high to 10.

Try other values and see if they work better. Once you have found good values, make them permanent by adding them to the /usr/share/X11/xorg.conf.d/50-synaptics.conf file.

Add the following section, or just the missing lines if it is already there:

Section "InputClass"
        Identifier "touchpad catchall"
        Driver "synaptics"
        MatchIsTouchpad "on"
        MatchDevicePath "/dev/input/event*"
        Option "FingerLow" "10"
        Option "FingerHigh" "16"
EndSection


My file already had the first three lines, so I just had to insert:

        MatchDevicePath "/dev/input/event*"
        Option "FingerLow" "10"
        Option "FingerHigh" "16"


After that, restart X11. I just rebooted the system. Don't forget to put the "*" at the end of the MatchDevicePath line!

Thursday, August 13, 2015

Kali 2.0 x64 on Acer c720

Kali 2.0 came out a few days ago, so I wanted to install it and see if the touchpad and suspend quirks had been worked out for the Acer c720. See previous posts to see how to replace the c720 firmware or install an alternate OS.

I downloaded the Kali 2.0 x64 version and created a bootable USB using Rufus 2.2. I then installed it on the Acer by hitting escape at boot to bring up a boot menu. I selected the USB drive and then the install option. I did not use the graphical install.

There was one problem during install where it complained that it could not mount the CDROM (or a similar error). The fix was simply to remove the USB drive, reinsert it, wait a second for it to initialize, and then tell the scrip to try and mount it again. It was clear sailing after that.

The install went smoothly. I was able to suspend using the power button, but closing the lid still does not suspend. Resume worked fine. However, when shutting down, there was an error compaining about ehci-pci port resume error. It just kept going, and I had to shutdown by holding the power button.

I tried the old fixes for sound and ehci with a script in the sleep.d directory, but that didn't seem to do anything. I then modified the grub file in /etc/default/grub.

I changed
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
to
GRUB_CMDLINE_LINUX_DEFAULT="quiet modprobe.blacklist=ehci_hcd,ehci_pci"

Then, I had to rebuild using
# update-grub
# update-grub2

This seemed to resolve the error after suspend, but I haven't tested it with bluetooth or usb devices yet. Also, suspend using the lid seems to work now too. I'm not sure why it didn't before. I might have updated a power setting that got it to work.

Monday, September 1, 2014

Kali 1.09 x64 on Acer c720, Suspend and Touchpad Working!

I finally got both suspend and the touch pad working with kernel 3.14.5, which is in Kali 1.07, 1.08, and 1.09.  Long story short, I compiled a custom kernel to fix suspend.  I also added four patches for the touchpad.  The other patches that have been listed have already been added to the kernel, so they weren't necessary.  These are the steps that I took.  There may be typos.  I tried to capture everything that I did in order.

The kernel patch is here.  The four touchpad patches can be downloaded from: https://patchwork.kernel.org/patch/<patch_number>/raw.  Replace <patch_number> with the patch number.  The patches are:
After getting the five patches, fix the patch to chromeos_laptop.c in the 3074401 and 3074411.  Do a global find and replace for 'x86' and replace with 'chrome'.  Then, download and install linux-source, linux-headers-3.14-kali1-amd64, and kernel-package.

root@kali:~# apt-get install linux-source linux-headers-3.14-kali1-amd64 kernel-package

Unzip the source in /usr/src.
root@kali:/usr/src# tar xpf linux-source-3.14.tar.xz

Go to the source root director and patch the Kali patches.
root@kali:/usr/src/linux-source-3.14# xz -dc ../linux-patch-3.14-rt.patch.xz | patch -p1

Patch the five patches.  Replace <patch> with the path to the patch.  It is easiest if they are copied to the source root directory.
root@kali:/usr/src/linux-source-3.14# patch -p1 <patch> 
   
It's time to build.  This took around 3-4 hours on the chromebook.  Copy in the config from boot and Module.symvers from the linux-headers.  Then compile.  Here are the commands that I used.

root@kali:/usr/src/linux-source-3.14# cp /boot/config-3.14-kali1-amd64 .config
root@kali:/usr/src/linux-source-3.14# cp /usr/src/linux-headers-3.14-kali1-amd64/Module.symvers .
root@kali:/usr/src/linux-source-3.14# make-kpkg clean
root@kali:/usr/src/linux-source-3.14# fakeroot make-kpkg --initrd kernel_image

Wait 3-4 hours...  Once it is done, there will be a new .deb file in /usr/src.  This is the new kernel.  Install it using dpkg.
root@kali:/usr/src# dpkg -install linux-image-3.14.5-rt5_3.14.5-rt5-10.00.Custom_amd64.deb
root@kali:/usr/src/linux-source-3.14# reboot

Ok, now touchpad works, but suspend does not.  Fix grub to add a few commands.  Change /etc/default/grub so that GRUB_CMDLINE_LINUX_DEFAULT is this:

GRUB_CMDLINE_LINUX_DEFAULT="quite splash tpm_tis.force=1 tpm_tis.interrupts=0 modprobe.blacklist=ehci+hcd,ehci_pci nmi_watchdog=0"

Then, rebuild grub with the update-grub command.  Reboot.  Suspend works via power button, but not lid close.

root@kali:~# update-grub
root@kali:~# reboot

Next step is to tweak touchpad settings and try to figure out why lid close doesn't trigger suspend.  It locks the screen, so I know that the lid close event is registered.
 

Sunday, June 1, 2014

Install Kali 1.07 x64 on Acer c720 Chromebook

I was pretty happy with Kali on the chromebook, so I wanted to try with a larger SSD.  First, I made sure development mode was enabled.  This is done by hitting <esc><refresh(F3)><power> at the same time.  I hit <ctrl><d> to enable developer mode.  The system removed cleared all data.  I shut it down and started to take it apart.

I replaced the 16GB SSD with a 64GB SSD following directions here.  The SSD is an M.2 format, previously known as NGFF (Next Generation Form Factor).  It is not the same as an MSATA.  I used this drive.  To replace it, basically, remove 13 screws from the bottom, carefully pry the bottom off, remove screw on SSD, replace.  I put the screw back on for the ssd, put the cover back on, and booted up.

Of course, Chrome OS wasn't installed so the system asked for restore media.  I had created that earlier, so I put in the SD card with the restore image and let Chrome OS install again.  Once that was done, I knew the SSD was working fine, so I modified the bios so that it would always boot SeaBIOS.  That means I won't have to hit <ctrl><l> to boot into linux at the splash screen.

Before you can modify the bios, you have to remove a write-protect screw from the motherboard.  This page has a great picture showing the location of the write-protect screw.  It was on pretty tight on my board.

Once the screw is out, I put the case back on (it won't boot because of a switch and a battery-enable screw) and booted to Chrome OS.  There, I got a terminal (<ctrl><alt><t>), got a shell (typed 'shell'), and elevated privileges (sudo su).  I used a built-in script to modify some flags following the directions here.

I created a Kali usb install drive using unetbootin and the Kali 1.07 x64 iso that I had downloaded.  Then I put the usb stick in the chromebook and booted.  It went to a UNetbootin start screen.  This is where I had to add the boot parameters.  Within 30 seconds, hit <tab> to get the boot parameters, and then add 'mem=1536m' to the end of the kernel parameters.  I had problems getting the first option, install, to work.  Instead, I booted to the live instance and choose "Install Kali Linux" from the "Systems Tools" menu.  I had a problem with my WPA2 router, so I set up a 2nd router with open wireless for the install.

From there, it is pretty standard.  Once Kali was installed, there are several tweaks to make.  Update the system, fix the trackpad, fix suspend, fix sound, maybe others.  I'll address these in a future post.

Thursday, April 17, 2014

Fixing Touchpad on Acer 720p Chromebook for Kali 1.06

I updated my kali 1.05 install to kali 1.06 by using the apt-get dist-upgrade.  I ran into a few problems but was able to follow the error message output to fix it.  Now I'm ready to patch some kernel drivers to support the touchpad.  Specifically
  • drivers/platform/x86/chromeos_laptop.c
  • drivers/i2c/busses/i2c_designware-pci.c
The script also copies i2c_designware-core.ko and tries to copy i2c_designware-platform.ko .  The first file did not seem to be patches, and the second did not exist on my machine.

There are good directions here, which also deal with suspend problems.  I haven't tried to suspend yet, but I can guess that there may be problems.  The script here was set up for Ubuntu 13.10 or newer, so it did not work.  It failed trying to download the linux kernel source.

Here's the script for reference. 

# Create a temp directory for our work
tempbuild=`mktemp -d`
cd $tempbuild

# Determine kernel version (with and without Ubuntu-specific suffix)
mykern=${1:-$(uname -r)}
mykernver=linux-$(echo $mykern | cut -d'-' -f 1)

# Install necessary deps to build a kernel
sudo apt-get build-dep -y --no-install-recommends linux-image-$mykern

# Grab Ubuntu kernel source
apt-get source linux-image-$mykern
cd $mykernver

if [ -f drivers/platform/x86/chromeos_laptop.c ]; then
  platform_folder=x86
elif [ -f drivers/platform/chrome/chromeos_laptop.c ]; then
  platform_folder=chrome
fi

# Use Benson Leung's post-Pixel Chromebook patches:
# https://patchwork.kernel.org/bundle/bleung/chromeos-laptop-deferring-and-haswell/
for patch in 3078491 3078481 3074391 3074441 3074421 3074401 3074431 3074411; do
  wget -O - https://patchwork.kernel.org/patch/$patch/raw/ \
  | sed "s/drivers\/platform\/x86\/chromeos_laptop.c/drivers\/platform\/$platform_folder\/chromeos_laptop.c/g" \
  | patch -p1
done

# Need this
cp /usr/src/linux-headers-$mykern/Module.symvers .

# Prep tree
cp /boot/config-$mykern ./.config
make oldconfig
make prepare
make modules_prepare

# Build only the needed directories
make SUBDIRS=drivers/platform/$platform_folder modules
make SUBDIRS=drivers/i2c/busses modules

# switch to using our new chromeos_laptop.ko module
# preserve old as .orig
sudo mv /lib/modules/$mykern/kernel/drivers/platform/$platform_folder/chromeos_laptop.ko /lib/modules/$mykern/kernel/drivers/platform/$platform_folder/chromeos_laptop.ko.orig
sudo cp drivers/platform/$platform_folder/chromeos_laptop.ko /lib/modules/$mykern/kernel/drivers/platform/$platform_folder/

# switch to using our new designware i2c modules
# preserve old as .orig
sudo mv /lib/modules/$mykern/kernel/drivers/i2c/busses/i2c-designware-core.ko /lib/modules/$mykern/kernel/drivers/i2c/busses/i2c-designware-core.ko.orig
sudo mv /lib/modules/$mykern/kernel/drivers/i2c/busses/i2c-designware-pci.ko /lib/modules/$mykern/kernel/drivers/i2c/busses/i2c-designware-pci.ko.orig
sudo mv /lib/modules/$mykern/kernel/drivers/i2c/busses/i2c-designware-platform.ko /lib/modules/$mykern/kernel/drivers/i2c/busses/i2c-designware-platform.ko.orig
sudo cp drivers/i2c/busses/i2c-designware-*.ko /lib/modules/$mykern/kernel/drivers/i2c/busses/
sudo depmod -a $mykern
echo "Finished building Chromebook modules in $tempbuild. Reboot to use them."
 

I had problems with this, so I basically went through the commands one at a time manually.  The tricky part was patching.  I have never done this before.  When I finished, my chromeos_laptop.c file had some structs inserted inside of other structs.  I copy/pasted them outside the structs and then the make command worked.  After that, I copied chromeos_laptop.ko, i2c_designware-core.ko, and i2c_designware-pci.ko to the right directories, ran depmod -a 3.12-kali1-amd64, and rebooted.

The trackpad worked, but sporadically.  I followed the next part of the directions and had to paste these lines into my  /usr/share/X11/xorg.conf.d/50-synaptics.conf  file in the "InputClass" section.
Section "InputClass"
        Identifier "touchpad catchall"
        Driver "synaptics"
        MatchIsTouchpad "on"
        MatchDevicePath "/dev/input/event*"
        Option "FingerLow" "10"
        Option "FingerHigh" "16"
EndSection

Most of the lines were there, so I just had to add:

        MatchDevicePath "/dev/input/event*"
        Option "FingerLow" "10"
        Option "FingerHigh" "16"
 
Now, I have to figure out how to get tap-to-click to work.  Currently, I have to click the touchpad to get right and left clicks.

Well...that was easy.  Applications | System Tools | Preferences | System Settings.  In that window, click on the Touchpad tab.  Check "Enable mouse clicks with touchpad" to enable tap-to-click.


 

Tuesday, April 15, 2014

Kali Screen Resolution on Acer c720 Chromebook

I installed kali 1.05 on my Chromebook and had two issues.  The first is known: the touchpad drivers aren't installed.  The second was a slightly off screen resolution.  The fix was simply to go to System Tools | Preferences | System Settings.  Select Displays.  My resolution was set to 1368 x 768.  There was another option for 1366 x 768.  I selected that, and the screen was fine.

Next step, try to compile touchpad drivers.

Install Kali 1.05 x64 on Acer Chromebook c720p

I picked up a refurbished Acer c720 Chromebook for $150.  My goal was to install Kali on it.  I heard that it was a fast (relatively) machine and the price was right.  I've always run Kali in virtual machines, and I thought that it would be nice to have it on actual hardware for a change.  This machine is so cheap that I don't mind if it gets trashed.

My first decision was to decide if I was going to use chrouton (runs Ubuntu and some others using a chroot environment) or install it directly.  This (and recent) models of chromebook support a legacy bios that allows you to boot from the usb.  That makes it a lot easier.

I decided to wipe out the 16Gb ssd, but first I made a backup image of chrome.  To do this, use chrome://imageburner in the browser with a 4Gb usb/SD card.

Then I followed the directions here to enable developer mode and boot the usb.  I used kali 1.05 because 1.06 is still downloading, and I didn't feel like waiting.  To create a bootable usb, I used the kali 1.05 iso file with unetbootin. 

I set up developer mode per the directions and booted.  I hit <ctrl-l> at the splash screen (legacy?) and it booted off the usb.  The trick here was to edit the boot options and add the parameter 'mem=1536m' at the end!  Without that, it would fail to boot kali.

I booted the live image and then installed from there.  I had a problem connecting to my wireless network until I unhid the SSID.  After installing, I rebooted.  I didn't hit <ctrl-l> at the developer splash screen, which takes you to a different splash screen saying that the chrome installation is corrupt.

Just reboot and hit <ctrl-l> at the developer mode screen!

There are a couple of issues that I need to sort out.
  1. The touchpad doesn't work.  This is a known issue, and it should be possible to compile the correct drivers.
  2. The screen resolution seems to be a few pixels bigger than the screen, so it pans a little when I get to the edge.  I'll have to look into the display drivers and/or screen resolution.
It's running an apt-get upgrade now and seems to be working fine!