2014年9月17日 星期三

Raspberry Pi notebook

Raspberry Pi Notebooks(continue to maintain)


Raspberry Pi setup

Basic Info
=====
default un/password pi/raspberry
=====

Setup Bluetooth Keyboard/Keypad
=====
sudo apt-get update
sudo apt-get install bluez-utils
sudo apt-get install bluez-compat
sudo hictool scan
(you will see the "Macro Keyboard" mac address here)
sudo hidd --connect dc:2c:26:bd:86:ae

Now, the BT keyboard/keypad can connect to RPi !!!
The following scripts do the connection automatically

two more script
/etc/btkeyboard
=====
#!/bin/sh
while (sleep 10)
do
sudo hidd --connect dc:2c:26:bd:86:ae >/dev/null 2>&1
done
=====

/etc/init.d/bt
=====
#!/bin/sh
### BEGIN INIT INFO
# Provides:          bt
# Required-Start:    $local_fs $remote_fs $syslog bluetooth
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# X-Interactive:     true
# Short-Description: Start BT keyboard
# Description:       This file should be used to construct scripts to be
#                    placed in /etc/init.d.
### END INIT INFO
/etc/btkeyboard &
exit 0
=====
(beware, this script must start after the "bluetooth")

sudo update-rc.d bt defaults

Install telnet server
=====
sudo apt-get install telnetd

Install ftp server
=====
sudo apt-get install vsftpd

edit /etc/vsftpd.conf
===
Search through the file and change the following lines:
anonymous_enable=YES Change To anonymous_enable=NO
#local_enable=Yes Change To local_enable=YES
#write_enable=YES Change To write_enable=YES
add "force_dot_files=YES" at last line

sudo service vsftpd restart

Install tightvncserver
=====
sudo apt-get install tightvncserver
start vncserver as: vncserver

Python and GPIO Installation
=====
sudo apt-get install python-dev
sudo easy_install -U distribute
sudo apt-get install python-pip
sudo pip install rpi.gpio

Play mp3
=====
sudo apt-get update
sudo apt-get install alsa-utils ntpdate mpg123 python-virtualenv libshout3 libshout3-dev pkg-config python-dev

Output from phonejack
===
sudo modprobe snd_bcm2835
sudo amixer cset numid=3 1

Switch back to HDMI
===
sudo amixer cset numid=3 2

aplay police_s.wav
mpg123 "/media/usbstick/Renegades Of Jazz - Go Jazz Not Ape! Vol.2.mp3"
mplayer Renegades Of Jazz - Go Jazz Not Ape! Vol.2.mp3

Image viewer
=====
sudo apt-get install feh

NTP install
=====
sudo apt-get install ntpdate
tzselect

sudo ntpdate ntp.ubuntu.com
ntpdate ntp.ubuntu.com pool.ntp.org
sudo ntpdate clock.stdtime.gov.tw
(/etc/ntp.conf)

Misc soft install
=====
dos2unix, htop

RTL2832U+E4000 TV Stick
=====
sudo apt-get install git
(sudo apt-get install git-core)
sudo apt-get install cmake
sudo apt-get install libusb-1.0-0.dev
sudo apt-get install build-essential
git clone git://git.osmocom.org/rtl-sdr.git
cd rtl-sdr/
mkdir build
cd build
cmake ../
make
sudo make install
sudo ldconfig
=====

Raspberry apt-get sources.list(/etc/apt/sources.list)
=====
reference to: http://www.raspbian.org/RaspbianMirrors
sudo vi /etc/apt/sources.list and add follow line
deb http://mirror.nus.edu.sg/raspbian/raspbian

work as BT server and mount NTFS HD
=====
sudo apt-get update
sudo apt-get install ntfs-g3
sudo apt-get install transmission-daemon
sudo service transmission-daemon (start|stop|restart)
configuration file located over /etc/transmission-daemon/settings.json
connect as http://ip:9091 to manage
check Hd: df -lh
mount NTFS: mount -t ntfs /dev/sda4 /mnt/usb -o nls=utf8,umask=0

Language locale, keyboard map, timezone selection
=====
sudo dpkg-reconfigure locales
(select en_USxxx, zh_TWxxx, zh_CNxxx)
sudo dpkg-reconfigure keyboard-configuration
(select Generic 105 key, keyboard Other and USA/USA, No AltGr Key, No Composer Key)
sudo dpkg-reconfigure tzdata
(Asia/Taipei)

Install deb
=====
sudo dpkg -i vim_7.3.547-6_armhf.deb

Mount USB thumb driver
=====
sudo mount -t vfat -o uid=pi,gid=pi /dev/sda1 /media/usbstick/

Mount SD card, USB stick 2012/12/16
=====
dmesg
then plugin the card reader
then rerun dmesg again to see new device
"sudo fdisk -l" also show the new device as /dev/sda2(system Linux) or /dev/sda1(system W95)
mkdir /media/sd; mount /dev/sda2 /media/sd
mkdir /media/usbstick; mount /dev/sdb1 /media/usbstick

***** dmesg log after mount the SD card and USB stick
[ 5513.143892] usb 1-1.2: new high-speed USB device number 4 using dwc_otg
[ 5513.244305] usb 1-1.2: New USB device found, idVendor=ffee, idProduct=0100
[ 5513.244336] usb 1-1.2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 5513.259489] scsi0 : usb-storage 1-1.2:1.0
[ 5514.254791] scsi 0:0:0:0: Direct-Access     FNK TECH  USB CARD READER 2.33 PQ: 0 ANSI: 2
[ 5514.256707] sd 0:0:0:0: [sda] 7744512 512-byte logical blocks: (3.96 GB/3.69 GiB)
[ 5514.257292] sd 0:0:0:0: [sda] Write Protect is off
[ 5514.257320] sd 0:0:0:0: [sda] Mode Sense: 03 00 00 00
[ 5514.257950] sd 0:0:0:0: [sda] No Caching mode page present
[ 5514.257974] sd 0:0:0:0: [sda] Assuming drive cache: write through
[ 5514.262934] sd 0:0:0:0: [sda] No Caching mode page present
[ 5514.262963] sd 0:0:0:0: [sda] Assuming drive cache: write through
[ 5514.265696]  sda: sda1 sda2
[ 5514.269184] sd 0:0:0:0: [sda] No Caching mode page present
[ 5514.269212] sd 0:0:0:0: [sda] Assuming drive cache: write through
[ 5514.269231] sd 0:0:0:0: [sda] Attached SCSI removable disk
[ 5664.861960] EXT4-fs (sda2): mounted filesystem with ordered data mode. Opts: (null)
[ 6551.351494] usb 1-1.3: new high-speed USB device number 5 using dwc_otg
[ 6551.454844] usb 1-1.3: New USB device found, idVendor=0930, idProduct=6545
[ 6551.454876] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 6551.454893] usb 1-1.3: Product: DataTraveler 2.0
[ 6551.454905] usb 1-1.3: Manufacturer: Kingston
[ 6551.454917] usb 1-1.3: SerialNumber: 001D92AD7804B8C1B328003F
[ 6551.465768] scsi1 : usb-storage 1-1.3:1.0
[ 6552.499409] scsi 1:0:0:0: Direct-Access     Kingston DataTraveler 2.0 PMAP PQ: 0 ANSI: 0 CCS
[ 6554.860602] sd 1:0:0:0: [sdb] 15687680 512-byte logical blocks: (8.03 GB/7.48 GiB)
[ 6554.861325] sd 1:0:0:0: [sdb] Write Protect is off
[ 6554.861467] sd 1:0:0:0: [sdb] Mode Sense: 23 00 00 00
[ 6554.863615] sd 1:0:0:0: [sdb] No Caching mode page present
[ 6554.863645] sd 1:0:0:0: [sdb] Assuming drive cache: write through
[ 6557.882694] sd 1:0:0:0: [sdb] No Caching mode page present
[ 6557.882724] sd 1:0:0:0: [sdb] Assuming drive cache: write through
[ 6557.913794]  sdb: sdb1
[ 6557.921329] sd 1:0:0:0: [sdb] No Caching mode page present
[ 6557.921361] sd 1:0:0:0: [sdb] Assuming drive cache: write through
[ 6557.921379] sd 1:0:0:0: [sdb] Attached SCSI removable disk
***** dmesg log after mount the SD card and USB stick

lsusb also shown the VendorID:0xffee and ProductID:0x0100
***** result of "lsusb" (the VendorID:0xffee and ProductID:0x0100  is for card reader)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID ffee:0100
Bus 001 Device 005: ID 0930:6545 Toshiba Corp. Kingston DataTraveler 102 Flash Drive / HEMA Flash Drive 2 GB / PNY Attache 4GB Stick
***** result of "lsusb"

***** result of "sudo fdisk -l"
Disk /dev/mmcblk0: 16.1 GB, 16134438912 bytes
4 heads, 16 sectors/track, 492384 cylinders, total 31512576 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000f06a6

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1            8192      122879       57344    c  W95 FAT32 (LBA)
/dev/mmcblk0p2          122880    31512575    15694848   83  Linux

Disk /dev/sda: 3965 MB, 3965190144 bytes
122 heads, 62 sectors/track, 1023 cylinders, total 7744512 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000f06a6

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            8192      122879       57344    c  W95 FAT32 (LBA)
/dev/sda2          122880     7744511     3810816   83  Linux

Disk /dev/sdb: 8032 MB, 8032092160 bytes
5 heads, 32 sectors/track, 98048 cylinders, total 15687680 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            8064    15687679     7839808    b  W95 FAT32
***** result of "sudo fdisk -l"

Install and compule gnuradio over RPi 2012/12/17
=====
sudo pt-get install python-cheetah libboost-all-dev python-lxml python-wxgtk2.8 python-numpy python-lxml libfftw3-dev libsdl1.2-dev python-scipy python-matplotlib python-tk octave liboctave-dev libgsl0-dev python-sphinx libcppunit-dev libuhd-dev swig python-qt4-dev libqwt-dev git
cmake -DCMAKE_C_COMPILER:FILEPATH=/usr/lib/distcc/gcc -DCMAKE_CXX_COMPILER:FILEPATH=/usr/lib/distcc/g++ -Dhave_mfpu_neon=0 -DCMAKE_CXX_FLAGS:STRING="-march=armv6 -mfpu=vfp -mfloat-abi=hard" -DCMAKE_C_FLAGS:STRING="-march=armv6 -mfpu=vfp -mfloat-abi=hard" ../
=====

Install subversion
=====
sudo apt-get install subversion

apt-get got error
=====
"E:Encountered a section with no Package: header....."
sudo rm /var/lib/apt/lists/* -vf
sudo apt-get update

WLAN setup
=====
sudo apt-get install wpasupplicant
wpa_passphrase jungle ptc1121wlan
/etc/network/interfaces
*****
.....
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid "jungle"
wpa-psk "ptc1121wlan"
*****
sudo apt-cache search RTL8191
sudo apt-get install firmware-realtek
lsmod
iwlist wlan0 scan
iwconfig
sudo /etc/init.d/networking restart
sudo ifup wlan0

install wicd
=====
sudo apt-get install wicd
sudo apt-get install wicd-curses

remove package
=====
sudo apt-get --purge remove wicd
sudo apt-get autoremove --purge (to remove related package)

DVB250 TV stick
=====
firmware location: http://www.linuxtv.org/downloads/firmware/
firmware name: dvb-usb-wt220u-02.fw
download and place it over /lib/firmware/dvb-usb-wt220u-02.fw

Mirror SVN
=====
svn co https://subversion.assembla.com/svn/sdrsharp/

MONO installed 2012/12/21
=====
sudo apt-get install mono-complete
sudo apt-get install locate
locate libportaudio.so.2

Webcam install and stream-out
=====
svn co https://mjpg-streamer.svn.sourceforge.net/svnroot/mjpg-streamer mjpg-streamer
sudo apt-get install libjpeg8-dev
sudo apt-get install imagemagick

ghpsdr3 install
=====
sudo apt-get install subversion libfftw3-dev libusb-1.0.0-dev
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:andrew-montefusco/ghpsdr3
sudo apt-get install ghpsdr3

Benchmark method
=====
time echo "scale=2000;4*a(1)" | bc -l
(result 18.628sec)

Installing compiler and autotool
=====
sudo apt-get install make gcc g++
sudo apt-get install autoconf automake autotools-dev libtool git subversion

wget https://github.com/downloads/libevent/libevent/libevent-2.0.16-stable.tar.gz;
cd
tar -zxvf libevent-2.0.16-stable.tar.gz
cd libevent-2.0.16-stable
./configure
make
sudo make install
sudo ldconfig

Installing prerequisite packages
=====
sudo apt-get update
sudo apt-get install \
libqt4-opengl-dev \
qtmobility-dev \
libusb-0.1-4 \
libusb-dev \
libfftw3-dev \
portaudio19-dev \
libpulse-dev \
libsamplerate0-dev \
libusb-1.0-0-dev \
libconfig8-dev \
xdg-utils \
libortp-dev

installing codec2 low bit rate audio encoding and decoding(http://www.rowetel.com/blog/?page_id=452)
=====
svn co https://freetel.svn.sourceforge.net/svnroot/freetel/codec2-dev codec2-dev
cd codec2-dev
autoreconf -i
./configure
make
sudo make install
sudo ldconfig
sudo apt-get sox

2014年9月16日 星期二

Raspberry Pi and RTL-SDR

Raspberry Pi and RTL-SDR
1. Installation package
Web: http://www.hamradioscience.com/raspberry-pi-as-remote-server-for-rtl2832u-sdr/

For RTL-SDR(Elonics E4000 or Rafael Micro RT-820 silicon tuner + Realtek RTL2832U IF demodulator), do the following command
=====
sudo apt-get install git 
sudo apt-get install cmake
sudo apt-get install libusb-1.0-0.dev
sudo apt-get install build-essential
git clone git://git.osmocom.org/rtl-sdr.git
cd rtl-sdr/
mkdir build
cd build
cmake ../
make
sudo make install
sudo ldconfig
=====


2. Check and execution
a. insert RTL-SDR dongle into RPi's USB port(SSH connection will be interrupt then reconnect again)
b. run "lsusb" to see RTL2838 DVB-T is shown and supported
c. run "sudo rtl_tcp -a 192.168.1.11", 192.168.1.11 is IP of RPi, default port is 1234
d. open Windows SDRSharp to select RTL-SDR/TCP
e. Configure as Hostname: 192.168.1.11, Port: 1234
f. Play to work





RPi and FunCubeDongle Pro





Raspberry Pi Basic Usage

Raspberry Pi Basic Usage

1. Raspberry Pi(RPi) connect with power and network only
2. use Xshell4(SSH protocol) to connect the RPi in terminal mode
3. start the VNC server in RPi and connect TightVNC in Window mode
4. transfer the data between RPi and computer with Winscp

Step 1 power and network connection

Step 2: Xshell4 connection


(192.168.1.11 is RPi's IP assigned by my DHCP serveri, 5901 is the VNC connection default port)


Step 3: tightVNC connection setup and connected screen picture


Step 4: Winscp connection
















Notes:
a. The router will play as DHCP server and RPi will request an IP address from the DHCP server
b. Use Ws_ping ProPack to scan the network for finding the RPi assigned IP or open the DHCP server UI to assign a fixed IP to RPi
c. RPi will start the SSH server automatically(see /etc/rc2.d/S02ssh). To use the SSH client(Xshell4 or SecureCRT) to connect RPi
d. For X Window access, install tightVNC server as "sudo apt-get install tightvncserver", then start vncserver as "vncserver"
e. tightVNC viewer to connect vncserver(vncserver password need provided)
f. Winscp to work as ftp clinet to upload/download to RPi

Good sides for this connection

a. RPi need connect power and network only,no USB keyboard and mouse, neither to concern about HDMI or Video setting to get high resolution output. SSH connection will use less system resource
b. The desktop PC can connect Internet and Rpi same time. To Google the question and cut-and-paste result to SSH terminal for trying

Raspberry Pi usage log

Raspberry Pi usage log

Booting setup
=====
1. expand_rootfs Expand root partition to fill SD card(*** necessary) 
to use the SD card fully and improve the execution performance

02. configure_keyboard Set keyboard layout(*** necessary, for direct keyboard connection), *option(for SSH connection, the SSH client will handle the keymap)
RPi default with UK keyboard and some character is not match the US keyboard layout. To select the US keymap to solve it














03.change_pass Change password for 'pi' user(*option)
RPI default account and password is "pi" and "raspberry"


04.boot_behaviour Start desktop on boot?(*option)
To save the computing resource, run the terminal mode(SSH login) as default. (Should we boot straight to desktop? No), "startx" restart the X Window





ps. run "sudo raspi_config" to start the menu again later time

Navspark: Arduino compatible GPS module

Navspark: Arduino compatible GPS module

Taiwan GPS chip provider Skytraq is working on an Arduino-like board with additional GNSS, GLONASS, Beidoo position capability.
http://www.indiegogo.com/projects/navspark-arduino-compatible-with-gps-gnss-receiver

If you buy and use the Arduino board(UNO, Nano...), you will feel the GPS function is provided as free!!

Want to get centimeter position accuracy ? there is a carrier-phase raw measurement kit provided. You can do a post-processing with RTKLIB to get that position accuracy.

                                                                     Board picture



Satellite Constellation

Funcube Dongle Plus Pro information

Funcube Dongle Plus Pro information

1. Funcube Dongle Pro+ front-end chip is Mirics's MSi001(or Msi002). Its block diagram show 6-ways LNA to cover different impedance and frequency range. RF signal is down-converted to LIF or ZIF and seperated to I/Q signal. The I/Q signal is filtered and amplified for ADC.
2. Mirics provide IF IC - MSi2500 to get ADC resolution to 10bits. It is better than RTL2832 in 8 bits. The highest sample rate  reach 12Msps. Due to the USB 2.0 HS(480Mbps), the selected sampling rate is about 2 to 3Msps.
3. FCDP use the audio codec with maximum sampling rate to 192Ksps. For Funcube satellite, it is adequate. There is another SDR USB dongle called SDRplay using FE filter+MSi001+MSi2500 to get wider signal bandwidth and better noise immunity.





Msi001 and Msi2500 chipset Block Diagram

Funcube Dongle Plus Block Diagram


BLDC evaluation platform PT2431

Motor IC Evaluation and Demo Platform

Design Concept
The motor control IC PT2431 feature with
PWM input signal for speed control
FG output for speed indication in open-drain configuration
RD output for lock indication in open-drain configuration

We want to build a user interface(UI) in computer or mobile phone to control motor speed with different PWM ratio and get the reading of FG and RD for speed and lock information
In the same time, the evaluation board is also equipped with PWM control and information display in case there is no computer and mobile phone provided.

Free developing toolchain: Arduino, Python and QT





Design project idea - FM Radio and Alarm

Design project idea - FM Radio and Alarm

Feature
1. FM Radio
2. Different device can exchange information
3. Alarm with time accuracy below 1ms daily
4. Alarm to talk hour and specified voice

One time charge to survive 1 month
Time sync with GPS or BLE
Voice sync with BLE thru handset, handset can deliver voice thru network as answer machine
Each device can sync time,  radio station and voice information thru RDS or BLE

Hardware
BLE: nRF51822
GPS: SkyTraq Navspark