Friday, October 23, 2015

Lenovo T440P + Ubuntu = driver hell .. And how I fixed it.

Standard

New laptop and the nasty suprises

I have purchased the Lenovo T440P in order to run Ubuntu for my development environment. I had a lot of initial issues using this laptop with external displays. The laptop display is too small to use on its own for development, so this was kind of a show stopper.

My target environment was:

  1. Lenovo T440P patched to a sensible BIOS level. I think mine is 2.31 or 2.32.
  2. Ubuntu 14.04.3 LTS
  3. 3.19.0-30-generic #34~14.04.1-Ubuntu SMP Fri Oct 2 22:09:39 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
  4. Gnome-Shell / not Unity
  5. Nvidia proprietary drivers
  6. Some sort of util to manage the use of the new daisy chaining of monitors on a single channel.
A lot of people spent many many hours getting this to work. This was what worked for me.

Installation of base system

  1. I started out with a system with no nonsense. That is the server release of Ubuntu. Install it, and you will get a system without any GUI at all.
  2. Install the package gnome-shell. This will give you the most basic gnome-shell install shaved down to the bones. No empathy, no Evolution. The downside is you have to add many of the usual tools by hand.
  3. Install nvidia-331 + Anything above this worked for me.
  4. Replace GDM with LightDM. This is the crucial point. GDM did not work for me on this laptop. I think LightDM is more advanced in managing the session with multiple monitors as of now. done by firstly installing the package lightdm and then dpkg-reconfigure lightdm. Select lightdm over GDM.
  5. See to it that the GRUB boot loader has no hokus pokus in it. You need a plain "quiet splash" no modeset changes unless you are fiddeling around and know what you are doing.
  6. The above should also have installed the package prime. So prime-select query should show you what GPU you are using.

Result

I am able to use both monitors with the Intel or the NVIDIA driver. Of cause the Intel card does not perform as well as the nvidia one. Some people have reported memory leaks / kernel crashes. I have not experienced this with the above setup. I am writing this from the lappie with an external monitor attached using the monitor on the laptop itself. 

It is really nice that the external monitors no longer tie hard to the discrete graphics card.

switching is done with prime-select <query|nvidia|intel>

For now I think I will use the intel card as it seems to be easily fast enough to power a developer workstation. In fact I struggle to see, why Lenovo does not produce a variant of the T440P with ONLY the Intel card. Seems to be more than what an old codegrunt like me need anyway.

Performance wise glxgears give me around 60 fps with the Intel driver and 2000+ fps when using the NVIDIA card. This goes for both screens.

Outstanding issues

I also have the advanced dock. The above setup does not work for me at all using this yet. I am able to get a text console (mirror) on both displays, but cannot get a GUI up and running on either screen using the advanced dock. I have read that the same is the issue with some versions of MS Windows. So in fact Lenovo has made a patch, that I have yet to flash onto the advanced dock.

https://support.lenovo.com/us/en/documents/ht081248)

I think the next step is to flash the firmware of the dock and see, what the outcome of that is. Right now I do not have a windows boot device compatible with the dock, so I probably have to create a boot partition for Windows on the lappie itself (which sucks) or replace the disk with another one and install on that.

What not to do ..

I have read some have had success downgrading to the 1.14 version of the BIOS. If you have a later version of the T440P I cannot emphasize enough how bad an idea that is.

The older BIOS is made for the older versions of the hardware, and even a minor version incompability in a device in your laptop could transform your laptop into the most expensive paperweight you ever owned.

Only do this if the laptop originally shipped with the early version of the BIOS.

Update:

It seems the above is not a problem on Ubuntu 15.10. On that release displays and dock work just as they are supposed to. I think this is mainly due to the major release upgrade of the kernel / 4.*.

For now the above fixes are still needed for the LTS product.



Update 2:

Distributor ID: Ubuntu
Description: Ubuntu 16.04 LTS
Release: 16.04
Codename: xenial

All works on this LTS out of the box. And it occurred to me that Cannonical actually ship a Gnome-Shell only dist now! Hell just froze over apparently. So forget about the steps to get a clean gnome env above. Just fetch the "gubuntu" distro. 

Sunday, March 31, 2013

DJBDNS and Netflix - Outside USA.

Standard

Introduction

In Europe most countries have access to Netflix by now. However the content presented is still lacking much compared to what is available in the USA.

Several services on the net offer DNS + VPN / Proxy solutions to circumvent this. However, if you are like me, you do not really feel ok with giving some service on the net your entire internet traffic for tunneling. In theory they could sniff logins to other services made from a device using their DNS / Tunnel setup.

Background

I was reading this article and decided to do it one better: In place of merely using the host file on a single pc or server I decided to configure it directly on my own DNS server and apply it network wide on my own LAN.

Goal

So the goal here is to *only* use their DNS/Proxy for Netflix specifically. The rest of the DNS lookups will resolve as they have done always.

The end result is a DNS setup that will allow you to use a Proxy Service in the USA for Netflix alone.

Prerequisites 

  1.  A DNS + Proxy / VPN service. I am currently using the excellent service from Unblock US. You could also buy a real VPN solution or even a VPS server in the USA, so that you could do the entire config by yourself.
  2. Your own configured DNS server on your local network. I am using DJBDNS. 
  3. A good understanding of things related to IP networking and DNS configuration.

DNS configuration


dnscache

You need to take over two domains for hosting on your own DNS:
  1. netflix.com
  2. netflix.net
[user@dnsserver /service/dnscache/root]$ ls -la servers/
total 1
drwxr-sr-x  2 root  wheel  512 17 mar 16:47 .
drwxr-sr-x  6 root  wheel  512  4 jan  2008 ..
-rw-r--r--  1 root  wheel   10 12 nov  2003 1.168.192.in-addr.arpa
-rw-r--r--  1 root  wheel  168  4 feb 20:06 @
-rw-r--r--  1 root  wheel   10 13 nov  2003 barnabas.dk
-rw-r--r--  1 root  wheel   10 17 mar 16:47 netflix.com
-rw-r--r--  1 root  wheel   10 17 mar 16:47 netflix.net

You will probably already have the two first files. The first one may be named differently because it is the reverse DNS entry for hosts on your local network. The "@" file contains a list of root nameservers on the net.

The barnabas.dk file contains the IP address of the DNS server hosting that particular domain. The domain resolves differently on my LAN than it does out on the net. This makes it easier to do development of new stuff locally without making DNS changes visible on the net. The DNS server is running on the loopback (127.0.0.1) interface of the DNS server host. So that is the IP put into it. Now edit a similar file to a netflix.com and a netflix.net.

Restart your server nicely with a kill -HUP <pid>.


tinydns

This is where things become a little more tricky, because we now want the netflix.com and netflix.net CNAME domains to point to the correct IP addresses with unblock-us. This is done to send IP traffic via their servers onto the ones with Netflix. So edit the "data" file in your tinydns server or use the DJBDNS tools to do this on the command line.

# Forward zone
Zbarnabas.dk:sauron.barnabas.dk:hostmaster.barnabas.dk::::::::
Znetflix.com:sauron.barnabas.dk:hostmaster.barnabas.dk::::::::
Znetflix.net:sauron.barnabas.dk:hostmaster.barnabas.dk::::::::

# NS records: primary nameservers
&barnabas.dk::sauron.barnabas.dk:::
&netflix.com::sauron.barnabas.dk:::
&netflix.net::sauron.barnabas.dk:::

#netflix aname
=www.netflix.com:54.243.127.15:36000::
=signup.netflix.com:23.21.78.133:36000::
=movies.netflix.com:204.12.200.61:36000:: 
=cbp-us.nccp.netflix.com:204.12.200.65:36000::
=movies.netflix.com:204.12.200.61:36000:: 
=cbp-us.nccp.netflix.com:204.12.200.65:36000::
=movies1.netflix.com:204.12.200.130:36000::
=movies2.netflix.com:204.12.200.104:36000::
=netflix.com:204.12.200.14:36000::
=moviecontrol.netflix.com:204.12.200.7:36000::
=api-global.netflix.com:204.12.200.88:36000::
=api-us.netflix.com:204.12.200.83:36000::
=api.netflix.com:204.12.200.2:36000::
=www2.netflix.com:204.12.200.100:36000::
=redirects-us.nccp.netflix.com:204.12.200.119:36000::
=redirects-eu.nccp.netflix.com:204.12.200.118:36000::
=nccp-nrdp-31.cloud.netflix.net:204.12.200.26:36000::
=ios.nccp.netflix.com:204.12.200.92:36000::
=atv.nccp.netflix.com:204.12.200.14:36000::
=uiboot.netflix.com:204.12.200.11:36000::
=signup.netflix.com:204.12.200.39:36000::
=iphone-api.netflix.com:204.12.200.14:36000::
=nccp-fuji.netflix.com:204.12.200.14:36000::
=nccp-fuji.cloud.netflix.net:204.12.200.27:36000::
=nccp-nato.cloud.netflix.net:204.12.200.22:36000::
=nccp-nato.netflix.com:204.12.200.14:36000::
=mcdn.netflix.com:204.12.200.14:36000::
=secure.netflix.com:204.12.200.12:36000::
=htmltvui-api.netflix.com:204.12.200.13:36000::
=nccp-ps3.netflix.com:204.12.200.14:36000::
=nccp-ps3.cloud.netflix.net:204.12.200.18:36000::
=api-user.netflix.com:204.12.200.17:36000::
=mobile-api.netflix.com:204.12.200.42:36000::
=api-public.netflix.com:204.12.200.14:36000::
=dvd.netflix.com:204.12.200.14:36000::
=android.nccp.netflix.com:204.12.200.93:36000::

If you bother you could setup an an ANAME record for each of the IPs in that list and then CNAME each of the hosts needed. That would be the nicest way to do it but I am lazy and like cut and paste ..

After editing the data file run make. This will produce the actual file for tinydns to use containing your new entries.

You should now restart your tinydns server like you did the dnscache server.


Conclusion

You should now be able to run your Netflix app using Unblock-US Proxy services and your *own* DNS server putting the control back where it belongs - in your own hands.

If you have corrections, improvements or additions to the above feel free to post them here.

FAQ

  1. Q: "What happens if I do this and Netflix or Unblock US changes IPs." A: "You are screwed basically. You asked for full control now you have it. You should proably use a different public DNS to find the correct ip values."
  2. Q: "This makes my xyz device do the two step shuffle instead of showing me Netflix, what should I do" A: "Fix the DNS setup and mail / post your findings here once you have a working solution"

Errata

It seems the later versions of the netflix app also requires:

api.crittercism.com

The list of CNAMES above is severely outdated. The method is, however, still sound.

Sunday, July 24, 2011

Mencoder webcam grab for youtube

Standard
I have been looking for an easy way to grab the signal from a regular USB webcam and get something from it that is usable on youtube. In the newer versions of ubuntu the /dev/audioN has been dropped from the kernel, so you have to use the audio signal from the ALSA layer instead. Here is how:


mencoder tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0:forceaudio:alsa:adevice=hw.1:amode=1:channel=3:fps=30:audiorate=32000 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1500:keyint=25 -oac mp3lame -lameopts cbr:br=128:mode=3 -fps 30 -o webcam.avi


The output will be in mpeg4.

Saturday, July 9, 2011

Google hosting of services and djbdns

Standard
Introduction
I have just completed a clean up of the config on my local dns server running dns service on my local network. The one in my house behind the firewall. I left a lot of configuration residue from many configuration hacks / tweaks and so forth over the time.

I host the barnabas.dk domain internally on the LAN as well as on a public dns server, that lead you to this blog.

The advantage is, that I am able to let services resolve to different things internally and externally.

However, I spent a lot of time finding a solution to making http://blog.barnabas.dk resolve correctly from my internal server onto the Google hosting where it lives. With blogger.com.

Here is how:
I use the djbdns tools (tinydns / dnscache) for hosting dns on my LAN. It has a low footprint and is much much much easier to live with than bind. Also it runs perfectly with the supervise service setup.

This is the config:


#
# REVERSE ZONE
#
# (reverse) dns servers: primary and secondary
Z1.168.192.in-addr.arpa:ns.barnabas.dk:hostmaster.barnabas.dk::::::::

# NS records
&1.168.192.in-addr.arpa::ns.barnabas.dk:::

#
# FORWARD ZONE:
#
# SOA record: primary nameserver is ns.example.net and hostmaster
# mail address is hostmaster@example.net
# (the 'Z' configuration line is the only one that
# allows specifying the hostmaster mail address)
Zbarnabas.dk:bar.barnabas.dk:hostmaster.barnabas.dk::::::::

# NS records: primary nameservers
&barnabas.dk::bar.barnabas.dk:::

# ANAME records
=bar.barnabas.dk:192.168.1.2:3600::

# CNAME records:
Cfoo.barnabas.dk:bar.barnabas.dk:::
Cblog.barnabas.dk:ghs.google.com:::


Just simply add the entry for the Google service as a CNAME. I spent a lot of time trying to make it work with an ANAME record. You can, but you have to refer the IP address of the Google service. That could change if Google configure new setup so refering the ghs.google.com cannonical name is the best way to do it.

Tuesday, June 14, 2011

Spotify, Wimp and TDC Play - a comparison

Standard
Introduction

I am using a Logitech Squeezecenter setup at home for listening to music. My goal is to only store the music locally that i have in lossless format. All the mp3 I have bought online earlier is really only a waste of space on my local server. It is a much better idea to have your lossy music streamed to you through a cloud music service. By now the quality is probably better than the mp3's I have been storing for years, there is a lot of new music for listening.

So in order to describe what my opinion is here is a short description of my setup

Hardware Setup

Old server running FreeBSD 6 with a couple of disks and a Squeezecenter server version 7.5.4. The architecture is i386.

Wimp

Activation of a trial account is very very easy. All you need is an active mobile phone number in order to start your trial period. In Denmark Telenor is a Wimp reseller and if you have two products (eg. phone and internet) through Telenor you will get a 50% discount. The normal price is 99 DKK a month, and you will be able to get it at 49 DKK.

I have neither so for me the price is 99 DKK which I find to be ok for access to 9 million songs online with new added regularly.

The quality of the streamed music is OK, but not fantastic. The format is 256 variable bit rate MP3. I am a bit particular with the quality of my music, so for me it is OK for streaming to a phone / stereo for general listening purposes. There is no DRM on the streams you recieve which is really nice. I still prefer my lossless flac tracks to this any day.

The app for android / iPhone is really really great. Easy to use and everything is cross referenced. If you are a Telenor customer you can stream directly to your phone without an extra cost - otherwise see to it you have a flatrate data plan.

One major drawback of Wimp is the necessity to activate, once your 30 day trial is over, through their Adobe Air application. There is no way at all I am typing in my credit card details in anything Adobe took part in making.

So currently I am hoping they take my advice and produce a simple http/ssl webapp for the customers to supply their billing details sometime soon.

TDC Play

I currently have a TDC mobile phone with data plan. This gives me access to TDC Play without any extra cost. As far as I know you cannot use this service as a non TDC customer.

Unfortunately the format is a windows infected WMA with loads of DRM. Even on a windows pc you cannot move your downloaded tracks to a new folder without invalidating them - making it necessary to fetch them again. The sound quality is also significantly lower that Wimp and especially Spotify Premium. This is really only usable on a mobile device.

From my Squeezecenter TDC play is unusable. Their answer is "buy one of our data lines and use our hardware box". Useless. I already have a hw box thank you.

I have tried the TDC play app on my Android and must say their app is not very good. Difficult to search and very little cross referencing between tracks and artists.

Spotify

Perhaps the most hyped music service out there. But the trees do not grow into the heavens.

Activations is quite difficult in Denmark since Spotify do not support Danish customers. This is not really the fault of the Spotify People, but rather due to some very technology scared people at the Danish music agency KODA. The danish RIAA.

This is easily fixed by creating a Swedish paypal account and then using this creating an account with Spotify. Easy Peasy.

The price is very acceptable at 99 SEK making it comparable in price with Wimp at 99 DKK.

The music library is impressive. Around 12 million songs.

The quality on the Spotify premium is excellent. 384 kbit ogg vorbis. This is the reason I really looked forward to trying this with my Squeeze center setup. However this turned out to be not so easy anyway.

The Squeezecenter today is either one you run on your own server or you can use the one supplied på Logitech "in the cloud". If you add your spotify account to this, then you have to select the cloud server when using spotify. Making it impossible to search your locally stored music. And vice verca.

Wimp handles this beautifully. You use the plugin in your server and you can search, mix and make playlists of your own music and wimp music as you see fit. You cannot with Spotify.

A fix is using the spotify backend on your server enabling this. However this is restricted to a narrow set of platforms and only in 32 bit. This requires a local install of libspotify and perhaps also the spotifyd server executable. I cannot really tell. This can then be accessed though a third party plugin to Squeezecenter and used like Wimp.

This is a list of supported platforms. They state Intel/Arm, but the list is in fact much shorter since they also require specific operating systems.

http://developer.spotify.com/en/libspotify/overview/

On FreeBSD it is not really even an option I am afraid. There is really no need for a binary client at all. Spotify needs to open up its client as open source and let ppl (re)implement it where needed. At least for premium accounts.

So on my setup I can only listen to spotify when using Logitechs cloud service. Not when using my own server. Bummer.

Conclusion

At least seen from a Squeezecenter user on Unix.

To put is short: Wimp 1 - Spotify 0 - TDC Play : No Contest.

Now if only the Wimp People would get rid of that Adobe Air thing.. Even introduce paypal perhaps?

Friday, May 20, 2011

Land Rover - A borrowed car from the shop

Standard
A borrowed set of wheels..
I recently had my brakes done at the Land Rover dealer. After getting my car back I noticed a disturbing use of brake fluid, and I subsequently had to take the car back to have the brakes fixed for both front wheels.



Apparently the dealer got a faulty set of refurbished calipers, and after a short while they started leaking heavily. In fact so much that the car had complete brake failure.

The issue was fixed on the guarantee, so aside from some driving back and forth and time spent on this little was lost.

As a small bonus I got to drive a tricked up Defender for a day.

The car was a 90" soft top van with the new 2.5 TD5 power plant. Additionally the car was equipped with a bull bar, snorkel, lift kit and large wheels with BF Goodrich T/A Mud Terrain.

It was very windy the day I had it and I have to say this car is by far the noisiest thing i have EVER tried. Not even my own Discovery 3.9 EFI v8 with its exhaust broken right after the manifold comes even close.

In fact I think it is about the same amount of db in the cabin at 100 km / h as my dads old Massey Ferguson 165 at 2500 rpm at plowing.

The diesel is quite noisy in itself. But if you add to this that the tires are very noisy on road and that the soft top makes an extreme amount of flapping noise - especially on the highway of cause - It really put me off considering a soft top Defender. It is really only usable on the African savanna.

My suggestion is to buy a hard top or a pickup version.

Aside from that the car has a good engine. It was the first try of the Defender 2.4 for me.

And I have to admit it does look quite nice on my driveway. I really like this car in white.

Thursday, April 21, 2011