Sunday 27 May 2012

Raspberry Pi: Basic Configuration

So now I'm settling in with my Pi, there were a few things that needed sorting. Of course, all the usual goes without saying:

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install vim

Create a user for yourself.

$ sudo adduser <username>

You'll want to be able to run sudo:

$ sudo EDITOR=/usr/bin/vim visudo

Add a new line for your new user beneath the pi user's line, e.g.

ace ALL=(ALL) ALL

Login as yourself:

$ su - <username>

Time to change the root password. Don't forget it.

$ sudo passwd

You can either delete the user 'pi' or change its password - your call.

Now to deal with the resolution. The wiki has a good page explaining how to set the resolution of your Pi. In short, for those using HDMI output:

$ /opt/vc/bin/tvservice -m DMT

Find the correct resolution and refresh rate for your monitor and note the mode number. Then edit (if it doesn't exist, then create) the file /boot/config.txt and set the variables hdmi_group and hdmi_mode as appropriate.

What it didn't make quite as clear is how to deal with the big black borders which are liable to malign your display and compress your image to the wrong resolution. We are of course discussing overscan.

For some reason unknown to me, the default is to set an overscan of 48 on top, right, bottom and left. On my AOC 416V (an atrocious monitor I had lying around), I found all it took to correct the resolution & black borders was to set the hdmi_group to 2 (DMT), hdmi_mode to 68 (1920x1200 @ 60Hz) and -48 overscan on all sides - to undo the default 48 overscan. It all looks something like this: (if you haven't installed vim yet, replace vim with vi)

$ sudo vim /boot/config.txt
hdmi_group 2
hdmi_mode 68
overscan_top -48
overscan_left -48
overscan_bottom -48
overscan_right -48

If your Pi refuses to show a display with your custom settings, you'll have to remove the SD card, put it back in another PC, mount the /boot partition (the smallest one), and edit config.txt again.

Of course, the usual applies - whatever you try on your Pi is at your own risk.

An interesting feature of the Pi is that it doesn't have a battery; in other words, it can't know what time it is after it's powered on. Somebody has written a script at /etc/profile.d/set_recent_time.sh which sets the time at logon, based on the last updated logfile's modification time. There's no denying that it's crude. I'd advise making sure that NTP is configured and working, otherwise you'll constantly be typing date --set='2012-05-27 ....'

1 comment:

  1. Great post! The part about moving the overscan that is automatically done was the answer to my monitor woes. Thanks again.

    ReplyDelete