Difference between revisions of "Raspberry Pi"

From YobiWiki
Jump to navigation Jump to search
Line 44: Line 44:
 
$ ls /dev/spi*
 
$ ls /dev/spi*
 
/dev/spidev0.0 /dev/spidev0.1
 
/dev/spidev0.0 /dev/spidev0.1
<br>Test:
+
Test:
 
wget "http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob_plain;f=Documentation/spi/spidev_test.c" -O spidev_test.c
 
wget "http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob_plain;f=Documentation/spi/spidev_test.c" -O spidev_test.c
Edit the file to point to /dev/spidev0.0
 
 
gcc -o spidev_test spidev_test.c
 
gcc -o spidev_test spidev_test.c
sudo ./spidev_test
+
sudo ./spidev_test -D /dev/spidev0.0
 
We should get a bunch of zeroes.
 
We should get a bunch of zeroes.
 
<br>Now, be very careful!! Shortcut GPIO9(MISO)(pin21) and GPIO10(MOSI)(pin19). Check on [https://www.modmypi.com/blog/raspberry-pi-gpio-cheat-sheet a pinout diagram] first...
 
<br>Now, be very careful!! Shortcut GPIO9(MISO)(pin21) and GPIO10(MOSI)(pin19). Check on [https://www.modmypi.com/blog/raspberry-pi-gpio-cheat-sheet a pinout diagram] first...
 
<br>And run again the command, now we should get some hex dump about dead beef and bad food ;-)
 
<br>And run again the command, now we should get some hex dump about dead beef and bad food ;-)
  +
sudo ./spidev_test -D /dev/spidev0.0
<br>If test fails, see here for updating stuffs:
+
If test fails, see here for updating stuffs:
 
* http://www.brianhensley.net/2012/07/getting-spi-working-on-raspberry-pi.html
 
* http://www.brianhensley.net/2012/07/getting-spi-working-on-raspberry-pi.html
 
* see also [http://mitchtech.net/wp-content/uploads/2012/08/raspi_arduino_spi.png SPI pinout] example with an Arduino
 
* see also [http://mitchtech.net/wp-content/uploads/2012/08/raspi_arduino_spi.png SPI pinout] example with an Arduino

Revision as of 20:35, 25 March 2013

Links

Startup

Remotely: provide DHCP over Ethernet
Access via ssh, Username: pi Password: raspberry
First time, the device propose to run raspi-config

sudo raspi-config


Then, better to renew SSH server keys, see RPi remote access

sudo rm /etc/ssh/ssh_host_* && sudo dpkg-reconfigure openssh-server

Wi-Fi

Using Wi-Pi
See user manual for Raspbian.
Edit /etc/network/interfaces and add wlan0 section similar to:

auto wlan0
iface wlan0 inet dhcp
wpa-ssid <name of your WiFi network>
wpa-psk <password of your WiFi network>

Then

sudo /etc/init.d/networking restart

NFC

apt-get install git autoconf libtool gcc libusb-dev
apt-get install dpkg-dev debhelper dh-autoreconf
git clone https://code.google.com/p/libnfc/
cd libnfc
dpkg-buildpackage -b -uc -us
cd ..
dpkg -i *deb

For a SCL3711:

modprobe -r pn533
echo blacklist pn533 > /etc/modprobe.d/pn533-blacklist.conf

SPI

Edit /etc/modprobe.d/raspi-blacklist.conf and comment:

#blacklist spi-bcm2708

Reboot
There should now be some /dev/spi*

$ ls /dev/spi*
/dev/spidev0.0 /dev/spidev0.1

Test:

wget "http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob_plain;f=Documentation/spi/spidev_test.c" -O spidev_test.c
gcc -o spidev_test spidev_test.c
sudo ./spidev_test -D /dev/spidev0.0

We should get a bunch of zeroes.
Now, be very careful!! Shortcut GPIO9(MISO)(pin21) and GPIO10(MOSI)(pin19). Check on a pinout diagram first...
And run again the command, now we should get some hex dump about dead beef and bad food ;-)

sudo ./spidev_test -D /dev/spidev0.0

If test fails, see here for updating stuffs:

With Python: