RaspberryPiBoardBeginners

From eLinux.org
Revision as of 12:42, 5 September 2011 by Yoonsikp (talk | contribs) (Wire up your Raspberry Pi and power it up)
Jump to: navigation, search


This is the "community" beginners guide for Raspberry Pi's ARM based ultra-low-cost (~15UKP or 25USD) Linux computer for teaching computer programming to children. If something doesn't work or isn't covered in these guides, please feel free to ask on the Forum. But before you ask there, make sure you read the FAQs.

Please note that the Raspberry Pi isn't released yet - this page is a community work in progress in preperation for the launch

So I got this little board, what do I do now?

Finding all the right hardware

You'll need a keyboard, mouse, TV/Monitor with either composite or HDMI input, and if you are using the Model A, a good quality USB hub.

Checking everything is working

Serial connection

First interaction with the board

Connect the serial cable to the COM port in the Raspberry Pi, and connect the other end to the COM port in the computer.

Super Easy Way Using GNU Screen

As root or sudo do: "screen /dev/ttyS0 115200"

Tedious Old-Fashioned Way Using Minicom

Run minicom setup as root from the host computer:

$ sudo minicom -s

You'll get a screen as follows:

           +-----[configuration]------+                                        
           | Filenames and paths      |                                        
           | File transfer protocols  |                                        
           | Serial port setup        |                                        
           | Modem and dialing        |                                        
           | Screen and keyboard      |                                        
           | Save setup as dfl        |                                        
           | Save setup as..          |                                        
           | Exit                     |                                        
           | Exit from Minicom        |                                        
           +--------------------------+                                        

Select Serial port setup:

   +-----------------------------------------------------------------------+   
   | A -    Serial Device      : /dev/ttyS1                                |   
   | B - Lockfile Location     : /var/lock                                 |   
   | C -   Callin Program      :                                           |   
   | D -  Callout Program      :                                           |   
   | E -    Bps/Par/Bits       : 9600 8N1                                  |   
   | F - Hardware Flow Control : Yes                                       |   
   | G - Software Flow Control : No                                        |   
   |                                                                       |   
   |    Change which setting?                                              |   
   +-----------------------------------------------------------------------+   
           | Screen and keyboard      |                                        
           | Save setup as dfl        |                                        
           | Save setup as..          |                                        
           | Exit                     |                                        
           | Exit from Minicom        |                                        
           +--------------------------+                                        

Now press E to change those settings:

                   +-----------[Comm Parameters]------------+                  
   +---------------|                                        |--------------+   
   | A -    Serial | Current: 115200 8N1                    |              |   
   | B - Lockfile L|                                        |              |   
   | C -   Callin P|   Speed          Parity          Data  |              |   
   | D -  Callout P|                                        |              |   
   | E -    Bps/Par| A: 300           L: None         S: 5  |              |   
   | F - Hardware F| B: 1200          M: Even         T: 6  |              |   
   | G - Software F| C: 2400          N: Odd          U: 7  |              |   
   |               | D: 4800          O: Mark         V: 8  |              |   
   |    Change whic| E: 9600          P: Space              |              |   
   +---------------| F: 19200                      Stopbits |--------------+   
           | Screen| G: 38400                         W: 1  |                  
           | Save s| H: 57600                         X: 2  |                  
           | Save s| I: 115200        Q: 8-N-1              |                  
           | Exit  | J: 230400        R: 7-E-1              |                  
           | Exit f|                                        |                  
           +-------|                                        |                  
                   | Choice, or <Enter> to exit?            |                  
                   +----------------------------------------+                  

You should get 115200 8N1, press keys I, L, V and W. When you're done, press Enter.

Now in the previous screen, press F to set Hardware Flow Control to Off. You should have this now:

   +-----------------------------------------------------------------------+   
   | A -    Serial Device      : /dev/ttyS1                                |   
   | B - Lockfile Location     : /var/lock                                 |   
   | C -   Callin Program      :                                           |   
   | D -  Callout Program      :                                           |   
   | E -    Bps/Par/Bits       : 115200 8N1                                |   
   | F - Hardware Flow Control : No                                        |   
   | G - Software Flow Control : No                                        |   
   |                                                                       |   
   |    Change which setting?                                              |   
   +-----------------------------------------------------------------------+   
           | Screen and keyboard      |                                        
           | Save setup as dfl        |                                        
           | Save setup as..          |                                        
           | Exit                     |                                        
           | Exit from Minicom        |                                        
           +--------------------------+                                        
                                                                               

Press Enter to leave this screen, select Save setup as dfl and finally select Exit from Minicom.

Now run minicom as root:

$ sudo minicom

You should get the following screen:

Welcome to minicom 2.2

OPTIONS:                                                                     
Compiled on Sep  8 2008, 17:03:34.                                           
Port /dev/ttyS0                                                              
                                                                            
              Press CTRL-A Z for help on special keys                       
                                                                            
                                                                            
                                                                            

[insert ASCII art Raspberry Pi boot up serial output here]

If you don't, check the serial port. You'll have to go back to the config (minicom -s) and get to this screen:

   +-----------------------------------------------------------------------+   
   | A -    Serial Device      : /dev/ttyS1                                |   
   | B - Lockfile Location     : /var/lock                                 |   
   | C -   Callin Program      :                                           |   
   | D -  Callout Program      :                                           |   
   | E -    Bps/Par/Bits       : 115200 8N1                                |   
   | F - Hardware Flow Control : No                                        |   
   | G - Software Flow Control : No                                        |   
   |                                                                       |   
   |    Change which setting?                                              |   
   +-----------------------------------------------------------------------+   
           | Screen and keyboard      |                                        
           | Save setup as dfl        |                                        
           | Save setup as..          |                                        
           | Exit                     |                                        
           | Exit from Minicom        |                                        
           +--------------------------+     

Now press A and change /dev/ttyS1 for /dev/ttyS0, or 2 or 3, depending on which port you have it connected. In my case it was 0. If you use a usb to serial adapter it is probably /dev/ttyUSB0 or perhaps /dev/ttyUSB1.

If you still don't get the Raspberry Pi shell, try using other serial terminal program like GtkTerm.

Now we got the Raspberry Pi shell! Congratulations!

First command we wanna try is "help":

prompt> # help

If you get some output, you're happy!

If at some point you cannot enter text any more, verify that you have turned off flow control (F and G should be set to No). Also if after a reboot you do not see anything exit (ctrl-A q) and restart minicom

SD card setup

Now we want to use an SD card to install some GNU/Linux distro in it and get more space for our stuff. You can use either an SD or SDHC card. In the latter case of course take care that your PC card reader also supports SDHC. Be aware that you are not dealing with an x86 processor, but instead a completely different architecture called ARM, so don't forget to install the ARM port for the distro you are planning to use.

(to be completed)

Formatting the SD card via the mkcard.txt script

(to be completed)

  1. Download mkcard.txt from ???.
  2. $ chmod +x mkcard.txt
  3. $ ./mkcard.txt /dev/sdx, Where x is the letter of the card. You can find this by inserting your card and then running dmesg | tail. You should see the messages about the device being mounted in the log. Mine mounts as sdc.

Once run, your card should be formatted.

Formatting the SD card via fdisk "Expert mode"

First, lets clear the partition table:

================================================================================
$ sudo fdisk /dev/sdb

Command (m for help): o
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) 
================================================================================

Print card info:

================================================================================
Command (m for help): p

Disk /dev/sdb: 128 MB, 128450560 bytes
....
================================================================================

Note card size in bytes. Needed later below.

Then go into "Expert mode":

================================================================================
Command (m for help): x
================================================================================

Now we want to set the geometry to 255 heads, 63 sectors and calculate the number of cylinders required for the particular SD/MMC card:

================================================================================
Expert command (m for help): h
Number of heads (1-256, default 4): 255

Expert command (m for help): s
Number of sectors (1-63, default 62): 63
Warning: setting sector offset for DOS compatiblity
================================================================================

NOTE: Be especially careful in the next step. First calculate the number of cylinders as follows:

  • B = Card size in bytes (you got it before, in the second step when you printed the info out)
  • C = Number of cylinders
C=B/255/63/512

When you get the number, you round it DOWN. Thus, if you got 108.8 you'll be using 108 cylinders.

================================================================================
Expert command (m for help): c
Number of cylinders (1-1048576, default 1011): 15
================================================================================

In this case 128MB card is used (reported as 128450560 bytes by fdisk above), thus 128450560 / 255 / 63 / 512 = 15.6 rounded down to 15 cylinders. Numbers there are 255 heads, 63 sectors, 512 bytes per sector.

So far so good, now we wanna create two partitions. One for the boot image, one for our distro.

Create the FAT32 partition for booting and transferring files from Windows. Mark it as bootable.

================================================================================
Expert command (m for help): r
Command (m for help): n
Command action
  e   extended
  p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-245, default 1): (press Enter)
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-245, default 245): +50

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): c
Changed system type of partition 1 to c (W95 FAT32 (LBA))

Command (m for help): a
Partition number (1-4): 1
================================================================================

Create the Linux partition for the root file system.

================================================================================
Command (m for help): n
Command action
  e   extended
  p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (52-245, default 52): (press Enter)
Using default value 52
Last cylinder or +size or +sizeM or +sizeK (52-245, default 245):(press Enter)
Using default value 245
================================================================================

Print and save the new partition records.

================================================================================
Command (m for help): p

Disk /dev/sdc: 2021 MB, 2021654528 bytes
255 heads, 63 sectors/track, 245 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *           1          51      409626    c  W95 FAT32 (LBA)
/dev/sdc2              52         245     1558305   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot.

WARNING: If you have created or modified any DOS 6.x partitions, please see the fdisk manual page for additional information.
Syncing disks.
================================================================================

Now we got both partitions, next step is formatting them.

NOTE: If the partitions (/dev/sdc1 and /dev/sdc2) does not exist, you should unplug the card and plug it back in. Linux will now be able to detect the new partitions.

================================================================================
$ sudo mkfs.msdos -F 32 /dev/sdc1 -n LABEL
mkfs.msdos 2.11 (12 Mar 2005)

$ sudo mkfs.ext3 /dev/sdc2
mke2fs 1.40-WIP (14-Nov-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
195072 inodes, 389576 blocks
19478 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=402653184
12 block groups
32768 blocks per group, 32768 fragments per group
16256 inodes per group
Superblock backups stored on blocks: 
       32768, 98304, 163840, 229376, 294912

Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: 
================================================================================

All done!

NOTE: For convenience, you can add the -L option to the mkfs.ext3 command to assign a volume label to the new ext3 filesystem. If you do that, the new (automatic) mount point under /media when you insert that SD card into some Linux hosts will be based on that label. If there's no label, the new mount point will most likely be a long hex string, so assigning a label makes manual mounting on the host more convenient.

Writing the image into the SDcard and finally booting GNU/Linux

Setting up the boot args

Wire up your Raspberry Pi and power it up

Connect the Raspberry Pi to the screen using either an HDMI or composite video cable. Connect the Keyboard and Mouse and finally the power. Now you've got to be PATIENT, first boot takes an extremely long time (probably - certainly true for most other development boards and distros ;)).

Further reading

The main Raspberry Pi resources are:

Thanks to

  • Nabax, _vlad, jkridner, ds2 and the other BeagleBoard wiki contributors on elinux.org for an excellent BeagleBoardBeginners resource, which we used as the template for this page.