Friday, September 26, 2014

Raspberry Pi - BIOS, firmware, and other basic topics

I wanted to take a break from reviewing Raspberry Pi distros and talk about some basics of the Raspberry Pi.  Things I have learned that others might find useful.

First I think it is important to understand I come from a background of Windows.  I know a little bit of Linux, and even less of the specifics of the Raspberry Pi.  So if you are a Linux guru then this will not help you.  But chances are, if you are reading this then you use Windows and will be coming from that background as well.  So below is a list of topics or things I have learned about the Raspberry Pi thus far.

1.  Most, but not all, distros for the Raspberry Pi are "installed" or copied to the SD card in the same way.  You download a single image file (.IMG extension) and then use Win32 Disk Imager to write that image onto the SD card.  This process is straightforward, even for non-technically people.  After this process is complete, it is important to understand what the contents of the SD card look like.  Let's say you have a 16GB SD card.  After writing an image you will have a small (maybe dozens of MB) FAT partition followed by a 3+ GB Linux partition (Windows will call it "unknown").  In total it will use 4GB of the SD card, leaving the remaining 12GB unused.  This is why pretty much all distros for the Raspberry Pi say the minimum SD card size is 4GB.  However, most distros have an option to expand the Linux partition to fill the rest of the SD card.

2.  Every computer I have worked on has a BIOS which is stored in firmware on the motherboard.  The Raspberry Pi does not follow this model.  The BIOS/firmware is stored as a set of files located on the SD card.  As such it is possible for the average user to upgrade the firmware manually.  To do that first download the updated files in the "boot" folder here.  Then copy these files into the FAT partition on your Raspberry Pi SD card.  It is probably a good idea to backup the original files.  Now I believe this process is safe to do, but I am not a Raspberry Pi developer.  I have not found documentation on the web stating you can do this.  But in my experience this does work.  I have had to do this twice on older distros that did not include updated BIOS/firmware to support the model B+.

3.  Because of how and where the Raspberry Pi's BIOS is located, things that you would normally configure inside the BIOS of a computer are configured inside a text file.  The aforementioned FAT partition contains a file called config.txt.  This file contains things like memory allocations, overclocking, USB power, and enabling/disabling hardware.  This page has lots of info about the config.txt file, what settings do what.

4.  Viewing and changing the BIOS/firmware and config.txt files is easiest from a Windows PC.  You can mount and modify this FAT partition from the Pi while the Pi is booted, but this partition is normally mounted as read-only so you have to take extra steps.  It is far easier to shutdown the Raspberry Pi and stick the SD card into a Windows PC.  The FAT partition will show up as a drive letter and you can view and edit the files.  One word of caution, the file config.txt should be a Unix text file which is slightly different from a Windows text file.  So I would not use Notepad to edit this file.  I would recommend a text editor that is Unix-aware, like the excellent and free Notepad++.

5.  During initial set up it is easier to use a monitor, keyboard, and mouse connected to the Raspberry Pi.  But if you remove this Linux is very easy to work with remotely.  For command line administration use SSH, which many distros have enabled by default.  The best Windows SSH client is Putty.  To control the GUI aspect of Linux you can either use xrdp which works with the default Windows Remote Desktop Protocol, or VNC which there are a number of free Windows VNC clients (disclaimer - I never did get VNC working on the Pi).  Lastly, should you want to transfer files to/from the Pi, you might look into SFTP.  I never did use this on the Pi so I cannot tell you how to enable an SFTP server, but I can recommend either WinSCP or Filezilla as great free SFTP clients.

6.  By default Linux does NOT play well with other computers on your local network.  On the Pi I can access other devices (Windows computers, my NAS box, etc.) by IP address but not by name.  The opposite is true also.  From Windows I can access the Pi by IP address, but not by name.  I thought this was a function of DNS, but by default Linux does not interact with DNS in this way.  The solution is a software package called Samba.  Samba is software protocols and services that help Linux to play nicely with Windows and other devices on the network.  Once you install Samba you should be able to access network resources using name as well as IP address.

7.  On my home network I have a Synology NAS box, and I want to be able to access this box to copy files.  To config Linux to mount a network resource every time it boots, you need to edit the file /etc/fstab  Append the following to the end of that file:

//<server>/<share> /mnt/<folder> cifs username=<user>,password=<pwd> 0 0

Where <server> is the name or IP of your NAS box and <share> share name to access.  Note that Linux uses forward slashes whereas Windows uses backslashes for UNC paths.  Next is <folder> which is a local folder on the Pi where to mount the folder for access.  Lastly <user> and <pwd> are the credentials needed to access the NAS.  After you do this you need to manually create the mount folder.  Change to /mnt and create a new folder with the same name as <folder>.  Lastly reboot and you should be able to access your NAS or other network share.

8.  Here are some command commands you might need to run from the command line:

[sudo] nano <file>
Edit a file in a text-only editor.  If you used pine back in the day, nano is the modern version.  You may need to add sudo if you do not have permissions to access the file.

sudo apt-get update
Checks the Internet for newer versions of software and patch upgrades, but does not actually install anything.  This is the first step in updating your computer (think Windows Update).

sudo apt-get upgrade
This step actually downloads and installs the updates found in the previous step.

sudo apt-get dist-upgrade
Think of this as a smarter more powerful version of the above command.  If a newer program supersedes an older one, this will remove the old and install the new.  So the recent release of Epiphany browser, this command will remove Midori and install Epiphany.

sudo apt-get install <package>
This will install new software on your computer.  You need to know the name of the package to install.  All of this apt-get stuff is controlled by the file /etc/apt/sources.list which contains a list of Internet servers where to pull software and updates from.

startx
If your Raspberry Pi boots to command line by default, the command startx will start the graphical environment.

ls -slagFL | more
This displays files and folders similar to the dir command in Windows.

No comments:

Post a Comment