2013年6月8日 星期六

Raspberry Pi 經驗分享

RPi (Raspberry Pi) 的幾個特點:(1) 比較便宜 (module B + 16G SD + 802.11n WiFi USB ~ NTD$2000) 而且輕巧; (2) 相對方便的 GPIO (含  I2C, SPI, UART) 控制; (3) 相當完整的 python 開發環境; (4) Lots of community resources for hardware and software.

我的 RPi 配備包含 : RPi 主板及壓克力殼, USB mouse/keyboard (later change to wireless mouse/keyboard),  WiFi USB dongle, HDMI monitor.

image

 

設定程序

Step 0:  Create SD OS image.  I used Raspbian from the official website.   Need to use win32diskimager to write the OS image into SD card.  Connect Ethernet cable; and keyboard/mouse via USB.  Not use WiFi at this time since there is NOT enough USB ports.

Step 1:  In the raspi-config remember to set: 

1. 設定 SD 卡 expand_root to use the entire SD space

2. 設定 keyboard layout from UK to US.  If not working, edit the /etc/default/keyboard directly.

   sudo nano /etc/default/keyboard

   edit XKBLAYOUT=’gb’  --> ‘us’

  $sudo reboot  

3. boot_hehaviour: 開機直接進入 X windown 畫面

3. It can always run “sudo raspi-config” later to change the setting

 

Step2:  Download pietty for ssh login.  pietty and putty are similar ssh.

 

Step3:  Do your house cleaning first

I’m loading software via the Linux apt-get utility and you need to make sure its database is up to date. First thing to do is to update apt-get’s local database with server’s pkglist’s files.  Then checks for outdated packages in the system and automatically upgrades them.  Execute the following commands:

$sudo apt-get update

$sudo apt-get upgrade

 

Step 4:  The default shell of RPi is bash.  I install csh and tcsh for convenience.

$sudo apt-get install csh

$sudo apt-get install tcsh

 

Step5: Setup vncserver.  It is important to have vnc since later we don’t need to use USB for keyboard and mouse.

1. $ sudo apt-get install tightvncserver

2. copy the script from  PenguineMentor

3. use pietty to login and do $vncpasswd to setup user “pi” password

4. change the screen size to proper fonts.

5. In pc, use vncviewer to login

Step5a:  setup microsoft remote desktop

$sudo apt-get install xrdp

Step6:  Setup hostname so that Windows can access RPi and RPi can access Windows using name instead of IP address

1. Windows access RPi:  use samba protocol

2. RPi access Windows: use winbind protocol (obsolete but still working)

The limitation is that Windows and RPi need to be at the same sub-net.  If not, need to use DNS and other advance techniques.

$ sudo apt-get install samba

$ sudo apt-get install samba-common-bin (!! important for samba setup)

$ sudo apt-get install winbind

in /etc/samba/smb.conf, edit the workgroup variable to match your home network workgroup (as defined in windows):  workgroup = MSWORK

in /etc/nsswitch.conf, change the following line:

hosts:         files dns   -->   hosts:         files dns wins

Need to set samba to start at default?

Step7:  Setup samba

Make sure install samba and samba-common-bin

edit /etc/samba/smb.conf

$ sudo testparm –s  (to check the smb.conf)

$ sudo smbpasswd –a pi  (to add password for pi)

$ sudo service samba restart

Reference: http://simonthepiman.com/how_to_setup_windows_file_server.php

Step8:  Setup WiFi USB

  1. Connect your USB Wi-Fi Adapter to the Pi.
  2. Open the WiFi Config application on the desktop.
  3. Select your adapter from the drop down list.
  4. Sign into your home network.

Step9:  Install emacs

$ sudo apt-get install emacs

$ sudo apt-get upgrade

Step10:  Install python

reference http://jeffskinnerbox.wordpress.com/linux-python-packages-for-my-raspberry-pi/

$sudo apt-get install python  (already in PRi)
$sudo apt-get install python-dev
$sudo apt-get install libjpeg-dev (useless?)
$sudo apt-get install libfreetype6-dev (already in PRi)
$sudo apt-get install python-setuptools (easy_install for python)
$sudo apt-get install python-pip (pip for python)

$sudo easy_install -U distribute  (get latest update of python)

Then RPi related GPIO and serial port

$sudo pip install RPi.GPIO (already installed in RPi)
$sudo pip install pySerial
$sudo pip install nose  (python test framework)

$sudo pip install cmd2  (cmd is a Python Standard Library module for constructing command-prompt applications.)

Then install matplotlib, scipy, and numpy for scientific computing

$sudo apt-get install python-matplotlib
$sudo apt-get install python-mpltoolkits.basemap
$sudo apt-get install python-numpy
$sudo apt-get install python-scipy
$sudo apt-get install python-pandas

Then install qt4 for GUI

$sudo apt-get install python-qt4

Then install ipython and notebook

$sudo apt-get install ipython ipython-doc ipython-notebook ipython-quconsole

Step10:  Install git

$ sudo apt-get install git

Step 11: Install Chromium

$sudo apt-get install chromimum

追蹤者