2015-05-18

Debian on a Dell XPS13: Part 3 - X

With console mode behaving nicely it's time to get X on the XPS13.

I started by installing a minimal X installation with my favourite window manager i3.  As with the console the huge resolution of the laptop rendered the whole screen really rather small!  The first step is to find out if X knows much about the display.  The following command when executed from an x-terminal will determine whether the display resolution has been detected properly:

$ xdpyinfo | grep -B 2 resolution
screen #0:
    dimensions:    3200x1800 pixels (846x476 millimeters)
    resolution:    96x96 dots per inch

Hmmm... good try X, but my screen definitely isn't almost 1 metre x 0.5 metres...  Time to teach X about the actual size of this display.  Modern XOrg installations don't often come with an xorg.conf file to make changes to - most of the configuration is done on the fly.  If you want to customise the configuration I believe the accepted method is with override files in /etc/X11/xorg.conf.d/.  To teach XOrg about the display I put the following into a new file called /etc/X11/xorg.conf.d/10-monitor.conf:

Section "Monitor"
    Identifier "<default monitor>"
    DisplaySize 423 238
EndSection

The DisplaySize option sets the physical size of the display in millimetres.  I just chose values that would give me a final resolution with a multiple of 96dpi.  Restarting X and repeating our previous command gives:

$ xdpyinfo | grep -B 2 resolution
screen #0:
    dimensions:    3200x1800 pixels (423x238 millimeters)
    resolution:    192x192 dots per inch

Looks pretty good!

The next step is to start configuring our apps to respect the resolution:

i3

Edit ~/.i3/config:
...
font pango: Inconsolata 12
...

rxvt

Edit ~/.Xresources:
...
URxvt.font:    xft:Inconsolata-12
...

Other resources

After these tweaks the system is mostly ready to use.  I'll continue to post anything I find useful about this laptop.  Other useful resources are:

2015-05-12

Debian on a Dell XPS13: Part 2 - Console Tweaks

Screen config

Having jumped through some hoops in part 1 to get a working base system the laptop was now in a good, usable state.  On rebooting however it's clear that the standard linux console is a little strained when faced with a 13" 3200x1800 display.  To say the text is a bit on the small side is an understatement.

Initially I thought that this could be fixed by selecting a lower resolution using KMS (Kernel Mode Setting) parameters.  Grub2, the default Debian bootloader, allows these parameters to be set quite easily in the config file.  I changed /etc/default/grub by adding the following lines:

GRUB_GFXMODE=1024x768
GRUB_GFXPAYLOAD_LINUX=keep

Running 'sudo update-grub' will refresh the bootloader configuration with the new parameters.  After rebooting I was presented with a nice, clear (and much larger) grub boot screen.  Success!

This was short-lived however.  By the time the machine had reached a login prompt the framebuffer driver had kicked in and had overridden my attempts at reducing the resolution.  FOILED!

Getting nowhere with the framebuffer documentation meant that I needed an alternative approach... BIGGER FONTS!  In Debian the console font is set by default using the console-setup package.  To get a feel for which font to chose I had a look in /usr/share/consolefonts and used the 'setfont' command to try a few out for size.  In the end I found that TerminusBold16x32 worked very well.  To make this change permanent I reconfigured the console-setup package:

sudo dpkg-reconfigure -plow console-setup

Keyboard config

Now that the screen was usable I decided to fix the keyboard.  I had two niggles.  The first was that the keyboard repeat rate was very slow.  On Linux this can be controlled using the kbdrate command.  I experimented a bit until I found settings that I liked, then transferred the parameters to /etc/kbd/config:

...
KEYBOARD_RATE="30"
KEYBOARD_DELAY="250"
...

The next annoyance was the behaviour of the function keys.  By default these are mapped to various multimedia functions.  I prefer them to be in their standard F1..12 mappings.  To change this a simple option in the BIOS can be used.  Mash F2 on boot and navigate on the settings menu to POST Behaviour->Fn Lock Options.  On this screen just change the setting to "Lock Mode Enable/Secondary" to regain easy access to the function keys.  Apply and reboot.

Debian on a Dell XPS13: Part 1 - Installation

The Hardware

When I needed a new developer laptop I decided that portability and a good display were high priorities.  After some research I decided to opt for Dell's 4th generation XPS13 Developer's Edition.  Cramming a 13" screen into a machine barely bigger than a standard 11" laptop was an appealing concept.  The fact that Dell are actively supporting Linux is also very attractive.

Machine duly ordered.  Obligatory wait as the hardware ships from the other side of the world.  The laptop arrived with Ubuntu 14.04.  Time to clean it up and install my preferred Linux distribution.

The Software

My goal was to install Debian 8.0.  I've been a Debian user for many years - probably going back to the late 90's.  It's a solid and reliable distribution which finds a good compromise between features and stability.  As it was just released I chose to try out the latest version - Jessie 8.0.

Initial installation

My first attempt involved the usual process of downloading a small-ish net install image and writing it out to a bootable USB stick.  Mashing the F2 key and selecting the UEFI USB boot option soon brought up the familiar Debian installation screen.  All went well until it was time to bring up the networking...

... oh dear.  Broadcom BCM4352 isn't supported in the stock installer...

No problem.  I completed the base installation without networking then jumped back to my other machine and downloaded the broadcom-sta-dkms package from the Debian repository.  Installing the package yielded another problem...

... oops broadcom-sta-dkms depends on DKMS which depends on a whole pile of GCC build tools...


At this point I realised I was about to head down a dependency chain I couldn't keep up with by simply downloading packages.  Instead I grabbed a copy of the larger Debian DVD disc 1 ISO and copied the file to a USB stick.  Having mounted up the USB stick on the XPS13 I told apt about the new source as follows:

# sudo mount -o loop /media/rightusb/debian-8.0.0-amd64-DVD-1.iso /media/cdrom
# sudo apt-cdrom add --cdrom=/media/cdrom -m


Once this was done a simple 'sudo aptitude update' followed by an 'sudo aptitude install dkms' allowed me to finally install the broadcom-sta-dkms driver.

Post installation network config

As soon as the driver was installed and working it was a simple process to get the wireless network up and running.  I used the info from https://wiki.debian.org/WiFi/HowToUse#wpa_supplicant as a guide to getting my WPA connection configured.

Tidying up

With the network running I edited the system sources.list to my usual config:
deb http://ftp.uk.debian.org/debian jessie main contrib non-free
deb http://ftp.debian.org/debian/ jessie-updates main contrib non-free
deb http://security.debian.org/debian jessie/updates main contrib non-free
deb http://http.debian.net/debian jessie-backports main

A quick round trip to aptitude brought the base installation up to date with the latest security fixes.  I now had a usable (but basic) system.  Part 2 will describe some of the initial tweaks I made to make the system more usable.

2010-12-06

Winter Cycling III: Riding Tips

Riding in the winter can be a challenge no matter how well prepared you may be.  If riding in icy or snowy conditions I would recommend that you should already be confident on a bike in slippery conditions.  If you don't know what to do when a bike slides out you should probably get some practice in more benign conditions.

That being said, there are a few simple techniques you can use to keep you out of trouble when riding in bad conditions:

Rough ice
When riding on icy back roads you will often find that the surface has been churned up and re-frozen.  The general rule is to stay loose on the bike.  Most of the time if you have reasonable momentum the bike will find its way out of trouble without too much input from the rider.

The exception to this is riding through the ruts left by vehicles (tractors and farm machinery seem particularly bad for creating ruts).  You have two choices.  You try to ride the rut.  If it's wide enough and smooth enough this can be a good thing to do.  Be careful that you don't hit the side of the rut as the bike will try to climb out and may throw you out of control.  The other option is to cross the rut.  I approach this in the same way as crossing tramlines or wet tree roots.  Cross the rut as close to 90 degrees as possible.  While crossing the rut use only minimal input to the bike, no brakes, no steering, no power, stay loose.

Deep snow
Once the snow gets above about 20cm deep my bike starts to struggle.  I can find grip, but the weight of the snow being moved aside becomes too much for forward progress.  If you have ultra-wide tyres you can float across the deeper stuff without the same problems.

When I have no choice but to get through the deep stuff I try to carry as much momentum as possible.  I pick a low gear, get a good spin going and try to maintain speed throughout the deep snow.  Shifting your weight back a little bit also helps.  It will give you a bit more traction on the rear wheel and allow the front to float slightly.

Controlling a slide
Even with the best prepared bike you can find yourself in a slide.  The nemesis for my bike seems to be unconsolidated loose slush - everything else is fine.  Once you're in a slide you have to decide quickly if it's recoverable.  Most of the time you can get control back by shifting your weight to counteract the slide and possibly dropping a foot off the pedal (flat pedals are handy here!).  Again, stay loose and go with the slide.

If the slide is terminal you need to decide how to crash.  If possible lay the bike down flat and push it away from you.  If you're heading for a ditch or hedgerow again try to get the bike away from you and if possible aim for something soft!

Other traffic
When road riding in winter you should be acutely aware that most other road users won't have nearly as much grip as you have with your spiked tyres.  It's all too easy for a car to slide wide on a hill or corner.  My general rule is if I see a car on a piece of road that could possible cause problems I will stop, get off the bike and get off the road.  It's not worth the risk of getting squished by a sliding car.

2010-12-04

Winter Cycling II: Clothing

The correct clothing is just as important as the correct bike when riding in winter.  I've found that the key is to ride with a set of carefully chosen layers.  This will allow you to fine-tune your clothes as your ride progresses.  My typical winter riding gear is:
  • Wicking base layer to remove cold sweat from your skin
  • Wicking thermal mid-layer to provide insulation.  I usually go for a lightweight fleece as a mid-layer.
  • Breathable windproof / showerproof top layer.  I don't ride in a full waterproof as they usually aren't breathable enough for cycling, so a windproof to keep the elements away is better.
  • Full pack-away waterproof.  This is a last resort when it gets really wet.  It will be uncomfortable to ride in but will stop you getting completely soaked.
Different people experience different problems riding in cold weather.  I find my hands and feet can get very cold.  To reduce this problem I wear either fleecy gloves in good, cold conditions or waterproof fleece-lined gloves in wetter conditions.  These reduce the feel you've got for the controls on the bike, but as with everything it's a matter of compromise.

To keep my feet warm I typically wear Sealskinz waterproof socks.  These have a neoprene layer integrated into the fabric which do a reasonable job of keeping your feet dry.  Even when they fail and your feet become wet they do a good job of keeping the water warm!

Finally I will wear some good quality riding shoes.  When riding on the road I typically wear my walking boots.  I figure if my bike goes wrong there's a good chance I will have a long walk ahead of me, so I should be comfortable.  On the mountain bike I favour Five Ten shoes.  They aren't very waterproof, but they are warm and the soft rubber means you've got reasonable grip on frozen ground.

2010-12-02

Winter Cycling I: Bike Preparation

This year I decided not to get caught out by the Scottish winter and to be properly prepared for a winter's worth of cycling.  I am going to post up a few articles that cover the basic of cycling in the winter.  These are all based upon my own experiences of what works and what doesn't.

The bike I will be using over winter is my Cotic Roadrat.  In its usual guise I have it set up as a fast tourer with tough, but fast rolling tyres, racks and panniers.  In this first post I will go through some of the changes I made to the bike in order to get it to work in the winter.
Roadrat in usual fast-touring guise
Tyres
The first thing to address are the tyres.  Normal road-biased tyres will very quickly reach the limit of grip once the roads get icy.  Luckily there are a few options.  MTB style chunky tyres can be found in 700c sizes and will give a lot more grip in slushy and snowy conditions, especially if you choose some with a soft rubber compound.

Unfortunately, even chunky tyres will be useless once the roads get icy.  Once this happens the only option is to use studded tyres.  These are usually a combination of chunky tread for snow and a number of steel studs embedded in the rubber which bite into the ice.  I use Continental Nordic Spike 240 tyres which have 240 spikes in each tyre.  They're quite expensive, but as this is only way I get to cycle at this time of year, they're well worth it.  On sheet ice these tyres feel like you're riding on dry tarmac.

Drivetrain
My Roadrat is equipped with an 8-speed Shimano Alfine gear hub.  So far this winter it has been faultless.  There's a barely perceptible increase in drag, but no more than you get with most hubs at this time of year.

Gear hubs tend to cope a little better than the alternative derailleur system as they are less prone to icing up and jamming.  Some people advocate, how do I phrase this... "micturating" on your rear derailleur once it gets frozen.  I'm sure this would work as a temporary fix, but in most conditions would re-freeze quite quickly.  A better option I use on my mountain bikes is to make sure all the moving parts are very well oiled.  This seems to do a reasonable job of keeping the water, and so the ice, from jamming up the mechanism.  Of course, even this will start to fail after a number of hours in snowy sub-zero conditions.

Other tweaks
A few other minor tweaks can be made to your bike to make it more comfortable in the winter:

  • Fit flat pedals so that you can wear warm boots.
  • Drop your saddle a bit for when the bike starts squirming around in the icy ruts.
  • Make sure you have plenty of lighting.  Winter conditions can change quickly so I run my usual Blackburn lights along with the USE Exposure lights I usually use on the mountain bike.
  • If fitted, raise your mudguards as high as possible.  Your tyres can get clogged with snow and jam under the guards, so try to get as much clearance as possible.
The end result
Once you've made these changes your bike should be in good shape for some winter riding.  I find my setup works well on icy roads, slushy conditions and snow up to about 15-20cm.  If you're riding in deeper snow you probably need to float on top of the snow rather than digging through it.  In which case you probably need something more specialised like the Surly Pugsley.

I'll be adding a few more posts on this topic in the next week or so.

Roadrat with spiked tyres

Winter riding!

2010-10-11

DIY Macro Photography IV: On-Board Flash Diffuser

As I get more into macro photography it has become clear that lighting is absolutely critical for good results   The best way to achieve good lighting appears to be one or two external flashes mounted on a bracket.  This allows you to have loads of control over the light sources.

However, in the truest bodging spirit I decided to see what I could do with just a few bits of rubbish I had lying around.  Obviously this rules out using external flashes and brackets.  Despite this I thought I could probably do a bit better than just using the on-board flash on my camera.  The plan was to build a snoot / diffuser to direct and soften the built-in flash in a way that fitted my macro set up.


Ingredients
  • Cardboard tube
  • Aluminium foil
  • Duct tape
  • Kitchen roll


Construction
The first step is to cut down the tube to size.  I wanted the tube to reach the end of my macro lens, but also to have a bit of a an angle at the end.  I used my mitre saw to chop the tube down to the angle I wanted:



I also decided to cut a small notch in the opposite end of the tube to make it fit slightly better against the built-in flash on my camera:





Once this was done I did a quick test fit to ensure all the dimensions were as I wanted:


I decided that lining the tube with aluminium foil would be a good idea.  I imagine this will help minimise light loss.  As the flash on the 7D is a bit weedy I need all the light output I can manage.  I cut some foil to size allowing enough for double thickness when rolled up and also a good edge for securing the foil to the tube:



Fitting the foil to the inside of the tube proved tricky until I realised that the fuel bottle for my camping stove was a perfect fit inside the cardboard tube.  This allowed me to use it as a blank around which I could wrap the foil and insert it into the cardboard tube:







Once the foil was inside the cardboard tube I cut tabs into the ends to allow it to be folded back and secured to the tube:



To make the diffuser a bit more robust I decided to wrap the whole thing in duct tape (bodge tool #1).  I paid particular attention to the ends of the tube where the foil was folded back.  The foil is not very robust, so some protection here is a good idea:


Once the foil lining was in good shape I fitted a diffusing element to the business end.  I used some kitchen roll, but any translucent material would be suitable:


One final feature I decided to add was a foil-covered cap for the camera end of the tube.  This simply hinges on a piece of duct tape and sits behind the flash head.  Again the idea is to try to direct as much flash energy forwards as possible.  I'm not sure if this makes any difference, but it does reduce the bounce-back you get when using the camera.




Once construction is complete it's a simple matter to fit the tube to your camera with some strategically placed rubber bands:


Results
Overall this modification works very well.  The snoot directs the flash quite nicely and really pours light on the subject.  I still have a few issues in my macro setup with vignetting, but that's a lens issue that I will address some time in the future.  Here's a few test shots:
SD card contacts

Zippo flint

Dead fly