Here you will find simple explanations and resources to problems encountered with the Raspberry Pi software and hardware. (Also it helps me to remember!)

miércoles, 1 de abril de 2015

Installing Rails on Ruby in the RP+

Only you should follow this tutorial. When it says "Kick off the lonnnnnng lonnnng process with the shell command below:" it's really true. You have to wait a couple of hours.
Later you can install a Dynamic Update Client (like "No-IP") to access your web page from the internet.
But most important thing is that if you run WEBrick server (default for Rails) as your web server you have to specify the listening IP address of your RP+ hardware:
rails server -b 192.168.0.xxx -p 3000
WEBrick by default doesn't listen all interfaces.

martes, 24 de marzo de 2015

Change the swap memory size in Raspeberry

I've been puzzled by a failure in the Rails on Ruby setup inside the Pi. After searching I found this page and it works fine:
Raspbian uses dphys-swapfile, which is a swap-file based solution instead of the "standard" swap-partition based solution. It is much easier to change the size of the swap.

  • The configuration file is:

/etc/dphys-swapfile 
  • The content is very simple. By default my Raspbian has 100MB of swap:
CONF_SWAPSIZE=100
  • If you want to change the size, you need to modify the number and restart dphys-swapfile:
/etc/init.d/dphys-swapfile stop
/etc/init.d/dphys-swapfile start
 

The last step didn't work for me. Instead, I had to restart the Pi.

domingo, 22 de marzo de 2015

Configuring the RPi B+ default serial port

By default Raspbian configures the Raspberry Pi serial port (GPIO14-GPIO15) to provide boot-up information. It also allows you to login via a connected device. If you need to use the Pi’s serial port for something else (i.e. a specific add-on board) you will need to disable this default functionality.

The Broadcom UART appears as /dev/ttyAMA0 under Linux. There are several minor things in the way if you want to have dedicated control of the serial port on a Raspberry Pi. This link describes the process for free the serial port: http://elinux.org/RPi_Serial_Connection. There is a brief script to automate the same steps: https://github.com/lurch/rpi-serial-console.

If you want to test the serial port to send/receive data:
  • First have a look at the permissions on that file, lets assume you are using /dev/ttyAMA0:
ls -l /dev/ttyAMA0
  • You will want read.write access, if this is a shared system then you should consider the security consequences of opening it up for everyone:
chmod o+rw /dev/ttyAMA0
  • You have to setup the baud rate with the next instruction:
 stty 115200 -F /dev/ttyAMA0
  • A very simple crude method to write to the file (send data to the serial port), would use the simple echo command in one terminal:
echo -ne 'ri_07_02' > /dev/ttyAMA0
  • And to read use the minicom command (maybe with another terminal):
minicom -b 115200 -o -D /dev/ttyAMA0



lunes, 19 de enero de 2015

Installing a web server

Hi again,

This time I've installed a web server to my RPi (acronym of "Raspberry Pi").

I've decided to install the "lighttpd" web server due to all the virtues listed in its home page: security, speed, compliance, flexibility and a small memory footprint (this last one ideal for RPi).

I have followed the "5 minutes configuration steps" and I have found the next setback:

If you create a "lighttpd.conf" file in any directory and execute "lighttpd -D -f lighttpd.conf" from this directory, the system doesn't asume the port configured in this file. By default, the listening port is the 80. This is because you have to restart your RPi after software package installation. Also if you don't restart your RPi and you try to execute "lighttpd -D -f /etc/lighttpd/lighttpd.conf" (the default config file created when installing the software), then appears the next message: "(network.c.405) can't bind to port: 80 Address already in use".

If you put a not occupied port in the .conf file you will have the system OK, and you will be able to browse your web page from your RPi (http://127.0.0.1:"port number") or from another computer connected to the same network as your RPi (through the wired ethernet network or through the USB WiFi network).

When copying the executable file "etc/lighttpd/lighttpd" to "etc/init.d/lighttpd", you are saying the system to run the web server in every boot. If you change the file attributes to "non executable" this service is not started at boot.

domingo, 11 de enero de 2015

Configuring wlan0 and eth0

Hi,

Finally I have decided to use the wired ethernet port (eth0 in the RASPIBIAN) as VNC server and "watch" the OS through it. For that I have asigned a static IP to eth0:
  • Edit the next file:
nano /etc/network/interfaces
  • I have edited it and put the static IP in the eth0 config lines:
auto lo

iface lo inet loopback

iface eth0 inet static
        address 192.168.1.160
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255

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

I have removed the next line gateway 192.168.1.1 below the "broadcast" line because there are internet access conflicts between the eth0 and the wlan0 interface. If this line appears in the eth0 config then the wlan0 is unable to connect to internet (only one gateway can be configured in this file) and the system tries to connect through the eth0.

The wlan0 interface tries to connect to a Wi-Fi network configured in the file "wpa_supplicant.conf". This file can be edited manually or can be configured through the wpa_gui application.



First steps. My new Raspberry Pi B+

Hi,

I just unpacked my new hardware and I'm working with it.

This platform works with Linux (various versions of OS are available in the Raspberry Pi official web site, also called "distros").The Micro SD memory card purchased with the hardware comes with the OS pre-installed. Mine was NOOBS. Thats fine if you wants to start "playing" with the system.

But I had a problem: I had no HDMI monitor available. But I had a laptop PC with Windows XP. So the only way to "watch" inside the system was through a VNC sessión. For this, first you have to configure the system entering with a SSH session (Secure SHell session). That is only possible if the OS has started. And this is impossible with the pre-installed NOOBS image card, and without a HDMI monitor and a keyboard.

So, the first of all was to delete the original SD card with the pre-installed NOOBS and install the RASPBIAN image. Follow this steps for that.

Second: the SSH session. Be aware that the RPi has to be connected to a network with router through the wired ethernet port for the first time (remember, you don't have screen and you can't configure the Wifi connection). RASPBIAN has enabled the DHCP in the wired ethernet port by default but you must to find the IP. For this follow this steps. After that, and if you have a Raspbian release before November 2016, follow this, step by step. (¡¡Attention!!:
As of the November 2016 release, Raspbian has the SSH server disabled by default. You will have to enable it manually. This is done using raspi-config:
Enter sudo raspi-config in the terminal, first select Interfacing options, then navigate to ssh, press Enter and select Enable or disable ssh server.
For headless setup, SSH can be enabled by placing a file named 'ssh', without any extension, onto the boot partition of the SD card.)

Third: the VNC session. To install the VNC server in Raspberry Pi (TightVNCserver for example) type the next in the SSH session:
sudo apt-get install tightvncserver
With this you have installed the VNC server software. But you have to run TightVNC Server in order to enter a password and an optional view-only password (you have to execute this step only once): 

tightvncserver
I wanted my system to run the VNC server at boot (every time the RPi started). For this you have the next steps:
  • Log into a terminal on the Pi as root:
sudo su
  • Navigate to the directory /etc/init.d/:
cd /etc/init.d/
  • Create a new file here:
nano vncboot
  • And write the following script inside:
### BEGIN INIT INFO
# Provides: vncboot
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start VNC Server at boot time
# Description: Start VNC Server at boot time.
### END INIT INFO

#! /bin/sh
# /etc/init.d/vncboot

USER=root
HOME=/root

export USER HOME

case "$1" in
 start)
  echo "Starting VNC Server"
  #Insert your favoured settings for a VNC session
  sudo /usr/bin/vncserver :0 -geometry 1280x800 -depth 16 -pixelformat rgb565
  ;;

 stop)
  echo "Stopping VNC Server"
  /usr/bin/vncserver -kill :0
  ;;

 *)
  echo "Usage: /etc/init.d/vncboot {start|stop}"
  exit 1
  ;;
esac

exit 0

  • Save this file as vncboot.
  • Make this file executable:
chmod 755 vncboot
  • Enable dependency-based boot sequencing:
update-rc.d /etc/init.d/vncboot defaults
  • If enabling dependency-based boot sequencing was successful, you will see this:
update-rc.d: using dependency based boot sequencing
  • But if you see this:
update-rc.d: error: unable to read /etc/init.d//etc/init.d/vncboot
  • then try the following command:
update-rc.d vncboot defaults
  • Reboot your Raspberry Pi and you should find a VNC server already started.
  • Install a VNC viewer in your laptop OS.
With this steps you'll have a Raspberry Pi hardware with RASPBIAN installed and the VNC server running from boot.

Remember that if you want to start de RASPBIAN GUI you must run the "startx" command.