Skip to content

Latest commit

 

History

History
446 lines (276 loc) · 15 KB

50_2_raspberry.adoc

File metadata and controls

446 lines (276 loc) · 15 KB

Raspberry

Upgrade firmware

sudo apt-get install rpi-update
sudo rpi-update
sudo reboot

Sequenza installazione SDcard da linux [1]

comando per vedere i devices

df -h

risultato

/dev/sdb1       256M  108M  149M  43% /media/maurizio/F909-367C
/dev/sdb2        15G   26M   15G   1% /media/maurizio/b4732aaf-665c-491f-97c7-8bd3be56a476

smonto l’sdcard

umount /dev/sdb1
umount /dev/sdb2

installo l’immagine (usare dcfldd per vedere il progresso)

sudo dd bs=4M if=2015-11-21-raspbian-jessie.img of=/dev/sdb

assicuriamoci che non ci siano scritture ancora in atto. Se non funziona prova 1M, prenderà di più

sync

ora possiamo smontare la sdcard e partire.

Per fare il backup

dd if=/dev/sdb of=sd.img bs=4M
sudo dd if=/dev/sdb of=~/Downloads/160726_backupPi.img bs=1M

o 1M nel caso l’abbiate

Prima installazione

  • Primo collegameto ed aggiornamento

        se cambiato SDcard devo resettare ssh
    ssh-keygen -f "/home/maurizio/.ssh/known_hosts" -R 192.168.1.55
        collegarsi
    ssh pi@192.168.1.55
        pw base raspberry
        al primo collegamento scrivere yes
        cambio la password
    sudo passwd pi
        aggiorno il sw
    sudo apt-get update && sudo apt-get upgrade
        controllo lo spaziondisponibile su disco
    df
        se poco con il configuratore espando il filesystem e imposto il tipo di tastiera.
    sudo raspi-config
  • installo avconv

    sudo apt-get install libav-tools ntfs-3g minidlna samba samba-common-bin
  • installo il disco esterno

Monto HD esterno

  • installare NTFS

    sudo apt-get install ntfs-3g
  • lista device

    ls -l /dev/disk/by-uuid

Risposta

lrwxrwxrwx 1 root root 15 giu 25 20:55 202638e1-4ce4-45df-9a00-ad725c2537bb -> ../../mmcblk0p2
lrwxrwxrwx 1 root root 15 giu 25 20:55 22E0-C711 -> ../../mmcblk0p1
lrwxrwxrwx 1 root root 10 giu 25 20:55 5292A96F92A9586D -> ../../sda1

impostare la cartella

sudo mkdir /media/raspberry_ext_hd
sudo mount -t ntfs-3g -o uid=pi,gid=pi /dev/sda1 /media/raspberry_ext_hd
sudo nano /etc/fstab
    proc              /proc           proc    defaults          0       0
    /dev/mmcblk0p1    /boot           vfat    defaults          0       2
    /dev/mmcblk0p2    /               ext4    defaults,noatime  0       1
    /dev/sda1        /media/raspberry_ext_hd     ntfs-3g rw,defaults     0       0
sudo reboot
Montare temporaneamente USB drives [1]
sudo mkdir /media/DRIVE_NAME_*
sudo mount -t ntfs-3g -o uid=pi,gid=pi /dev/sda1 /media/raspberry_ext_hd/

Installazione DLNA

sudo apt-get install minidlna
sudo cp /etc/minidlna.conf /etc/backup_minidlna.conf
sudo nano /etc/minidlna.conf

In the configuration file, add

db_dir=/home/pi/minidlna
media_dir=/media/raspberry_ext_hd/dlna_dir/
log_dir=/var/log

Add as many media directories as you need. Change names of drives as needed.

mkdir /var/cache/minidlna
sudo service minidlna force-reload
cat /var/log/minidlna.log

Per testare i files:

Installazione Samba

sudo apt-get install samba samba-common-bin
sudo cp /etc/samba/smb.conf /etc/samba/backup_smb.conf
sudo nano /etc/samba/smb.conf

Find workgroup, and modify its value. This is the workgroup your Windows machine need to be a part of to view the files.

workgroup = WORKGROUP
netbios name = RaspBPi

Remove irrelevant drives, printers if you don’t need them Add your own drive:

[raspberry_ext_hd]
comment = External Raspberry Drive
valid users = pi
path = /media/raspberry_ext_hd
create mask = 0777
directory mask = 0777
read only = No

read only option depends on whether you want your users to change files or not. In my case, I chose yes.

Con il seguente comando abilito ad una PW samba un utente già nel sistema.

sudo smbpasswd -a marco

Se voglio avviungere un utente samba:

sudo useradd -m -g users -p 123456789 marco

Non mi resta che riavviare il servizio

sudo service smbd restart

Setup Wi-Fi On Your Raspberry Pi via the Command Line

You configure

At the prompt, enter the following command:

sudo nano /etc/network/interfaces

In the nano text editor, you’ll see something like this:

auto lo
iface lo inet loopback
iface eth0 inet dhcp

That’s the very basic configuration that governs your Pi’s Ethernet connect (indicated by the eth0 portion). We need to add on a very minor bit to enable the Wi-Fi dongle. Use the arrow keys to move down below the existing entry and add the following lines:

allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Once you’ve annotated the file, press CTRL+X to save the file and exit the nano editor. At the prompt again, enter the following command:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Compare the contents of the file, if it exists, to the following code. If the file is empty, you can use this code to populate it. Take note of the commented lines (indicated by the # marks) to reference which variable you should use based on your current Wi-Fi node configuration.

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="YOURSSID"
psk="YOURPASSWORD"
# Protocol type can be: RSN (for WP2) and WPA (for WPA1)
proto=WPA
# Key management type can be: WPA-PSK or WPA-EAP (Pre-Shared or Enterprise)
key_mgmt=WPA-PSK
# Pairwise can be CCMP or TKIP (for WPA2 or WPA1)
pairwise=TKIP
#Authorization option should be OPEN for both WPA1/WPA2 (in less commonly used are SHARED and LEAP)
auth_alg=OPEN
}

When you’re done editing the file, press CTRL+X to save and exit the document. Now is the time to unplug the Ethernet cable and plug in the Wi-Fi dongle.

At the command prompt, enter the following command:

sudo reboot

When the device finishes rebooting, it should automatically connect to the Wi-Fi node. If for some reason it fails to appear on the network, you can always plug the Ethernet cable back in to double check the two files and the variables you altered.

Fix Video Source

  • OpenELEC: /storage/.xbmc/userdata/

  • Raspbmc: /home/pi/.xbmc/userdata/

  • XBian: /home/xbian/.xbmc/userdata/

Add the following section to your advancedsettings.xml and then tweak them as explained later in this post.

<advancedsettings>
<network>
<buffermode>0</buffermode> <!-- Comment: Default is 1 -->
<cachemembuffersize>20971520</cachemembuffersize> <!-- Comment: Default is 20971520 bytes or 20 MB -->
<readbufferfactor>1.0</readbufferfactor> <!-- Comment: Default is 1.0 -->
</network>
</advancedsettings>

Note that these presets may differ with distro you use and some of the tweaks may not work on XBMC 12.X Frodo and below.

buffermode

Works on XBMC 13 Gotham and above. The buffermode sets what videos XBMC will cache. The default is 0, which will cache all videos from the internet (http, FTP, WebDAV, etc.). Listed below are other options:

1 Buffer all videos, including local videos
2 Buffer only true internet streams (http, strm, etc.)
3 No buffer

If you experience XBMC stuttering while playing videos from your local network storage, then choose 1 as Buffermode. Playing from a USB drive or SD card should almost never cause XBMC buffering issues unless there is some hardware compatibility issue. cachemembuffersize

By default XBMC allocates 20 MB for cache (note that in reality this is require 3 times more free RAM, 60 MB in this case). If you choose to cache videos, then increasing the available cache memory may help. On Raspberry Pi, with OpenELEC, Xbian or Raspbmc, I would not go beyond 40 or 50 MB (note that this requires 120 or 150 MB of free RAM) or else XBMC might crash frequently. To set cachemembuffersize to say 40 MB use 41943040 (40 x 1024 x 1024). If you are on a full-blown HTPC with say 4 GB RAM, you could go higher.

Alternatively, you could set the cachemembuffersize to 0, which would force XBMC to use your local storage (SD Card) for caching videos. In this case, the cache size is only limited by the amount of free space available. Upon stopping the video the cache is automatically cleared to free up space. Note that this will increase the read/write on your SD card, which may reduce its lifespan. But SD cards are cheap and doing this can help low RAM devices such as Raspberry Pi. But a good SD card with higher class rating is definitely recommended. [Read: 10 Tweaks to improve XBMC performance on Raspberry Pi]

Readbufferfactor

Works on XBMC 13 Gotham and above. The default value is 1.0, which will make XBMC cache a little above what is needed to play it back. This setting affects how much of your network bandwidth is hogged to cache the video. In my home, while I am while I am watching a video, it take priority over anything else. So setting a 2.0, 3.0, or 4.0 will that many times higher bandwidth usage. In most cases setting it at 4.0 should not cause any issues. However, if you notice any spikes in CPU usage or network bandwidth unavailability for other devices then reduce the readbufferfactor.

The recommended entry in advancedsettings.xml file to reduce XBMC choppiness, stuttering, and buffering problems on Raspberry Pi is given below:

<advancedsettings>
<network>
<buffermode>1</buffermode> <!-- Comment: Default is 1 -->
<cachemembuffersize>0</cachemembuffersize> <!-- Comment: Default is 20971520 bytes or 20 MB -->
<readbufferfactor>4.0</readbufferfactor> <!-- Comment: Default is 1.0 -->
</network>
</advancedsettings>

Installing Games

Installing MaMe
Installing Quake 2
apt-get install libsdl1.2-dev
wget http://sheasilverman.com/rpi/raspbian/quake2Bin.zip
unzip quake2Bin.zip
cd quake2Bin
./quake2

Kivypie

On Unix systems you can use unzip and dd tools to uncompress and burn the image. Windows and Mac users can follow the flashing SD card instructions at elinux.

You need a 2GB SD card or larger. After bootup login with

user sysop
password posys
Installation on Raspberry

User’s Guide » Installation on Raspberry Pi

You can install Kivy manually, or you can download and boot KivyPie on the Raspberry Pi. Both options are described below.

Note that Kivy has been tested with the original Raspberry Pi Model A/B. No guarantee is made that it will work on a Raspberry Pi 2. Manual installation¶

Add APT sources for Gstreamer 1.0 in /etc/apt/sources.list:
deb http://vontaene.de/raspbian-updates/ . main
Add APT key for vontaene.de:
gpg --recv-keys 0C667A3E
gpg -a --export 0C667A3E | sudo apt-key add -
Install the dependencies:
sudo apt-get update
sudo apt-get install pkg-config libgl1-mesa-dev libgles2-mesa-dev \
   python-pygame python-setuptools libgstreamer1.0-dev git-core \
   gstreamer1.0-plugins-{bad,base,good,ugly} \
   gstreamer1.0-{omx,alsa} python-dev
Install pip from source:
wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
sudo python get-pip.py
Install Cython from sources (debian package are outdated):
sudo pip install cython
Clone and compile Kivy:
git clone https://github.com/kivy/kivy
cd kivy
Build and use kivy inplace (best for development):
make
echo "export PYTHONPATH=$(pwd):\$PYTHONPATH" >> ~/.profile
source ~/.profile
Or install Kivy globally on your system:
python setup.py build
sudo python setup.py install

KivyPie distribution¶

KivyPie is a compact and lightweight Raspbian based distribution that comes with Kivy installed and ready to run. It is the result of applying the manual installation steps described above, with a few more extra tools. You can download the image from http://kivypie.mitako.eu/kivy-download.html and boot it on a Raspberry PI. Running the demo¶

Go to your kivy/examples folder, you’ll have tons of demo you could try.

You could start the showcase:

cd kivy/examples/demo/showcase python main.py

3d monkey demo is also fun too see:

cd kivy/examples/3Drendering python main.py

Where to go ?¶

We made few games using GPIO / physical input we got during Pycon 2013: a button and a tilt. Checkout the https://github.com/kivy/piki. You will need to adapt the GPIO pin in the code.

A video to see what we were doing with it: http://www.youtube.com/watch?v=NVM09gaX6pQ

Make from a raspberryPi a Radio Transmitter

	wget http://www.omattos.com/pifm.tar.gz
	tar xvzf pifm.tar.gz
	sudo ./pifm sound.wav 100.0 (1)

	# then turn off the raspberry
	# plug a USB audio device into the raspberryPi
	# power up

	sudo apt-get install alsa-utils
	lsusb (2)
	alsamixer (3)
	arecord -fS16_LE -r 22050 -Dplughw:1,0 - | sudo ./pifm - 100.1 22050
  1. 100.0 is the frequency

  2. This will display information regarding attached USB devices.

  3. You can adjust the volume of your microphone by this utility

Here are some desription

  • arecord: Program we are using to record audio.

  • -fS16_LE: Output 16-bit data. Needed this way for PiFM to read it.

  • -r 22050: This specifies sampling rate to output recording. 22,050 is a good balance for speed and quality.

  • -Dplughw:1,0: to see all of the audio devices connected.

  • sudo ./pifm - 100.1 22050: Here sudo for root access, ./pifm run the FM module at '100.1' Mhz to transmit and '22050' is the sampling rate of the input. If you did everything right, after you run the command you should be able to tune your radio to 100.1 Mhz and hear yourself talking through the mic!

autostart at boot time

Create a bash script in /etc/init.d

sudo nano /etc/init.d/autostartpifm.sh

and add the following lines

#!/bin/bash
cd /home/pi
arecord -fS16_LE -r 22050 -Dplughw:1,0 - | sudo ./pifm - 100.1 22050

Make script executable and test

	sudo chmod 755 /etc/init.d/autostartpifm.sh
	sudo update-rc.d autostartpifm.sh defaults (1)
	sudo /etc/init.d/autostartpifm.sh start (2)
  1. registering the script

  2. Pressing CTRL+C to exit

To remove the script:

sudo update-rc.d -f  autostartpifm.sh remove

1. ntfs-3g for NTFS drives, vfat for FAT32 drives, ext4 for ext4 drives