Monday, February 9, 2015

Raspberry Pi B: HDMI Resolution and Localisation Fixes

Following up from yesterday's post on the Raspberry Pi B, I've played around with it a little more and noticed under Raspbian the screen resolution was running at 1776x952 rather than 1920x1080, and that the keyboard was set up for British layouts.

Resolution Fix

To fix the resolution I got into the /boot/config.txt and made a few changes as per various suggestions from the web. First of all you need to run tvservice -m CEA to find the preferred monitor settings. Mine was 16, but replace the text below with the appropriate number. (May also need to run tvservice -m DMT depending on your screen type. DMT is hdmi_group=2 for the settings. See: difference between CEA and DMT.

The summary of changes to /boot/config.txt:

disable_overscan=1
hdmi_drive=2

#overscan_left 24
#overscan_right 24
#overscan_top 16
#overscan_bottom 16
#disable_overscan=0

hdmi_group=1
hdmi_mode=16

The first two lines were already in the file, and just needed to be uncommented. The commented out lines about were in the NOOBS generated section at the bottom. NOOBS default seemed overly aggressive, so I took them all out. The last two lines are the results of the CEA output from above for the preferred setting.

Keyboard Localisation Fix

Default to British keyboard layout causes problems here in Aust because the # key is turned into £ and the @ and " keys are transposed. To update, run the following:

dpkg-reconfigure locales
dpkg-reconfigure keyboard-configuration

Both bring up little text-based wizards. For locales, select en_AU.UTF-8 or similar. For the keyboard config, I selected a generic match for the keyboard I was using, but I think the main thing is to change the "GB" setting to "US" keyboard layout.

Saturday, February 7, 2015

Raspberry Pi 2B Installation

Having played with a BeagleBone Black a while back, I thought I'd try out the newly released Raspberry Pi 2. Quad core CPU with 1GB of RAM sounds like it should be plenty grunty for SoC computer.

The Raspberry Pi 2B

Here's the process I used to set it up. I tried both Snappy Ubuntu and Raspbian. Since Snappy has no desktop at the moment, and that's the main thing I wanted to try out to start with, I basically satisfied myself it was working and then jumped over to Raspbian.

In addition to the Pi itself, you also need the following:

  • A micro-USB power supply — basically, a phone charger. I got a 2A one from Element14 with the Pi.
  • A microSD flash card. I got a 16GB Patriot that came with a USB adapter to make it easier to copy files to/from. You could also use a card reader if your computer has one.
  • Keyboard/mouse/monitor.

2A microUSB power adapter

Installing Snappy Ubuntu on the Pi

This install is using a Linux desktop computer to set up the Flash card. I'm sure there are guides out there for Windows/OSX if that's how you roll. OSX may be similar enough that the command-line options will work too, I'm not sure.

  • Download Snappy Ubuntu Core from http://www.raspberrypi.org/downloads/
  • Unzip the downloaded zip file to get at the pi-snappy.img.
  • Insert the flash drive into your computer.
  • Find out the device name using something like df if it automounts or fdisk -l if not. It will be called something like "/dev/sdc1". Drop the number at the end for the commands below — you need to flash the entire drive, whereas sdc1 is the first partition on the drive.
  • Unmount the flash drive if you need to.
  • From the command-line, run the following (replacing "sdc" with your device):
      $ sudo dd bs=4M if=pi-snappy.img of=/dev/sdc
    
  • It might take a while to flash the img. Play a game or something while you're waiting.
  • Run sync to flush the drive. (I forgot to do this and it still worked...)
  • Take out the flash drive and put it in the Pi. Connect up keyboard/mouse/monitor, then plug in power.
  • MicroSD flash card installed into the Pi

  • For me a "rainbow screen" popped up, then an image of 4 raspberries. Then it cycled around again and finally got to a login prompt. It took a long time, so I'm not sure whether something went wrong and it rebooted itself, or if that was normal.
  • Default login for Snappy is ubuntu/ubuntu.

Installing Raspbian via NOOBS on the Pi

NOOBS is a helper you can put on the flash drive to more easily install other distros. To setup the flash drive for NOOBS, reformat it as FAT32. I used gparted to do this. The drive had a bunch of existing partitions already on there from the Snappy install. Delete them all and create one single FAT32 partition, then Apply. Once complete, it should look something like this:

gparted after reformatting flash drive as FAT32

Unzip the NOOBS zip file, and copy the content onto the SD card. Once done, the file system should look something like this:

NOOBS unzipped onto flash drive

Put the SD Card back in the Pi. When it boots it will come up with an installation screen. Select Raspbian and optionally the Data Partition if you want it. It will then blat the drive with the Raspbian install, which will take a while.

Once complete, it should reboot and bring up another menu. I selected [1 Expand Filesystem] to make the rest of the SD card storage available, but it told me NOOBS had already done this. Then I selected Finish and it went to the console, selecting 3 (or 4?) to boot to desktop might have been a better option in general because that menu no longer appears on subsequent reboots.

Logging in to the console (username: pi, password: raspberry) you can start the desktop by running startx anyway.

Interestingly, I plugged in my Netgear WNA3100M (cheapy USB wireless adapter), and it connected right away. With the BeagleBone in comparison I got stymied trying to find firmware for that device. Score +1 for Raspbian right there.

Initial play with the Pi 2 shows the desktop to be pretty snappy, feels quite usable. There are few glitches in the rendering and occasionally you see artifacts if you, say, scroll the browser too fast for it to keep up, but overall the "feel" wasn't too bad. Will have to give it a bit more of a go to see what it can do.

Raspberry Pi 2B desktop screenshot (click to enlarge)