Archive

For the Raspberry PI category

hwclock: ioctl(RTC_RD_TIME) to /dev/rtc to read the time failed: Invalid argument

No Comments

This error occurred on Raspbian Jessie using an ARPI600. I was trying to set up the real-time clock. I could resolve the issue by running the following command:

hwclock --systohc -D --noadjfile --utc

after enabling it with the command

echo pcf8563 0x51 > /sys/class/i2c-adapter/i2c-1/new_device

0x51 may differs on you installation. Run i2cdetect -y 1 to find the right value.

How about a Raspberry PI 2 as a firewall?

No Comments

Raspberry PI 2

A Raspberry PI 2 performs as expected exceptionally well as a firewall. The download throughput achieved was 33 Mbits/sec under the same test conditions as the previous test (see Can A Raspberry PI Be Used As A Firewall? for more details). The CPU usage was about 5% during the download test. The CPU usage was around 2% while performing the upload test.

Can a Raspberry PI be used as a firewall?

1 Comment

Raspberry PI Model B

Can a Raspberry PI be used as a firewall? This question comes back often. Well, I have tested it. The test conditions are:

  • a Raspberry PI Model B (256MB of RAM)
  • a USB to Ethernet wired interface. 100 Mbits/sec.
  • Raspian (May 2015) as the OS.
  • My Internet connection is 30 Mbits/sec. for download, 10 Mbits/sec. for the upload speed.
  • www.speedtest.net has been used to carry the speed tests.

The answer is NO. I got a download speed of about 30 MBits/sec. Using a PC as the firewall with a similar setup, I achieved around 32 MBits/sec. While doing the download test, the CPU usage was 100% while being 20% for the upload test. Memory was not an issue with about 165 MB free.

I would certainly use this Raspberry PI as a firewall for an Internet connection of 20-20 Mbits/sec. or less.

A similar test will soon be performed using a Raspberry PI 2.

Octoprint and Cura Disk Image for the Raspberry Pi (Version 2015-03-15)

1 Comment

Cura integrated with Octoprint brings your 3D printer to the next level. You can download from HERE a fully functional image of Cura integrated with Octoprint. Simply copy this image to an SD-card of 4GB or more. Instruction to copy an image on an SD-card is given on this PAGE. You will need to unzip this file prior copying the image to the SD-card.

A 4 GB SD-card will give you about 1.2 GB of free space to upload your models after expanding the filesystem. Be aware that some folders are hidden. Make sure you display them.

This image is based on the following:

  • http://docstech.net/OctoPiMirror/2015-01-31-octopi-0.11.0.zip
  • https://github.com/foosel/OctoPrint/wiki/Cura-Integration (2015-03-15 version)
  • https://github.com/Ultimaker/CuraEngine.git (2015-03-15 version)

This image is fully functional. Nevertheless, the following might need to be done.

  1. Logon to the Raspberry Pi. Issue the command sudo raspi-config. You may wish to expand the filesystem (Option 1) and change the memory split to 64 (Option 8 > A3).
  2. Modify the settings as needed on another computer with Cura installed. Save them as CuraConfig.ini by going to File > Save Profile. Replace the content of /home/pi/Cura/config/CuraConfig.ini (on the SD-card) with the content of the saved CuraConfig.ini file.
  3. Copy the file preferences.ini located on the computer (located in ~/.cura/[version]/ if using Linux) to /home/pi/.cura/dev/preferences.ini on the SD-car.
  4. Set up a fixed IP address to the Raspberry Pi. Instruction can be found HERE.
  5. Change the default password for the user pi. Instruction can be found HERE.
  6. Enable the access control of Octoprint. To do so, edit /home/pi/.octoprint/config.yaml. Set accessControl: enabled to true and server: firstRun to true and reboot the Raspberry Pi running Octoprint.

Octoprint and Cura Disk Image for the Raspberry Pi

No Comments

A newer version is available HERE

Cura integrated with Octoprint brings your 3D printer to the next level. You can download from HERE a fully functional image of Cura integrated with Octoprint. Simply copy this image to an SD-card of 4GB or more. Instruction to copy an image on an SD-card is given on this PAGE. You will need to unzip this file prior copying the image to the SD-card.

A 4 GB SD-card will give you about 1.2 GB of free space to upload your models after expanding the filesystem. Be aware that some folders are hidden. Make sure you display them.

This image is based on the following:

  • http://docstech.net/OctoPiMirror/2014-09-09-wheezy-octopi-0.10.0.zip
  • https://github.com/foosel/OctoPrint/wiki/Cura-Integration (2015-01-05 version)

This image is fully functional. Nevertheless, the following might need to be done.

  1. Logon to the Raspberry Pi. Issue the command sudo raspi-config. You may wish to expand the filesystem (Option 1) and change the memory split to 64 (Option 8 > A3).
  2. Modify the settings as needed on another computer with Cura installed. Save them as CuraConfig.ini by going to File > Save Profile. Replace the content of /home/pi/Cura/config/CuraConfig.ini (on the SD-card) with the content of the saved CuraConfig.ini file.
  3. Copy the file preferences.ini located on the computer (located in ~/.cura/[version]/ if using Linux) to /home/pi/.cura/dev/preferences.ini on the SD-car.
  4. Set up a fixed IP address to the Raspberry Pi. Instruction can be found HERE.
  5. Change the default password for the user pi. Instruction can be found HERE.
  6. Enable the access control of Octoprint. To do so, edit /home/pi/.octoprint/config.yaml. Set accessControl: enabled to true and server: firstRun to true and reboot the Raspberry Pi running Octoprint.

Accessing a serial port from a web server

No Comments

On most Linux distribution, it is impossible to access a serial port (ex. /dev/ttyS0) from a web server such as Apache or lighttpd using a cgi. Simply add the user under which the web server runs (www-data for example) to the group dialout. To do so, use vigr from the command line and add the user on the dialout group line. Such a line will typically look like:

dialout:x:20:myuser,www-data

Recording a terminal session under Linux

No Comments

It is possible to record a terminal session under Linux with ttyrec. It also records vi, emacs, etc. sessions.

Fisrt, install ttyrec

sudo apt-get install ttyrec

To start recording a session:

ttyrec

To replay a session recording:

ttyplay ttyrecord

A step by step guide to setup a Bluetooth keyboard and mouse on the Raspberry PI

82 Comments

A lot of people is having problem setting up a Bluetooth keyboard and mouse on the Raspberry PI. Things get more complicated when your wired keyboard or mouse does not work or prevent your Bluetooth dongle from working. There is hope. This step by step procedure will let you install them or at a minimum let you know what does not work. It uses only the command line interface. It is targeted for the Wheezy Debian distribution.

    • First of all, if you already tried to set them up and they do not work, start with a fresh install of the OS. This will rule out anything you have done before that would prevent this procedure from working.
    • Plug the Bluetooth dongle directly on the Raspberry PI board.
    • Boot the Raspberry PI and connect to it using SSH from another computer if possible.  Otherwise, use a wired or wireless keyboard. Logon as pi, password raspberry.
    • Switch to root
sudo bash
    • Install all the updates.  It will take a while.
apt-get update
apt-get upgrade
    • Enable dbus
update-rc.d -f dbus defaults
    • Reboot
reboot
    • Reconnect as described above. Logon as pi, password raspberry. Switch to root.
    • Install the required packages.  It will take a while.
apt-get install bluetooth bluez-utils blueman
    • Reboot and reconnect as described above. Logon as pi, password raspberry. Switch to root
    • Make sure that your Bluetooth dongle is recognized. If not, unplug it and re-plug it.
lsusb
    • Make your Bluetooth device discoverable. Refer to the device manual.
    • Make sure that your device is seen by the Raspberry PI. Take note of its MAC address (ex. 75:EF:82:69:D2:83)
hcitool scan
    • Pair the device. When requested, type a pin like 0000 and hit ENTER. If you are pairing a keyboard, type the PIN you have entered and hit ENTER on the keyboard you are pairing. If you are pairing a mouse, you also need to type a PIN of 0000 when requested and hit ENTER. This PIN might depends on the mouse manufacturer.
bluez-simple-agent hci0 75:EF:82:69:D2:83
    • Make the device trusted.
bluez-test-device trusted 75:EF:82:69:D2:83 yes
    • Connect the device. After a few seconds, your device will be usable.
bluez-test-input connect 75:EF:82:69:D2:83
  • Repeat the steps from “Make your Bluetooth device discoverable” if you need to install another device.
  • When you will reboot, the devices will reconnected automatically after a few seconds.

This procedure worked for the following devices:

  • Cambridge Radio Bluetooth dongle
  • Microsoft Bluetooth Mobile Keyboard 6000
  • Apple Bluetooth Keyboard (iPad keyboard)
  • HipStreet mini bluetooth keyboard
  • Merkury iPad keyboard
  • RocketFish Bluetooth Mouse
  • Razer Orochi Mouse
  • iPazzPort Bluetooth (Model KP-810-10BTT)
  • Ultra eXo mini keyboard/touchpad

Initializing A Wireless Connection At Boot Time

No Comments

You can initialize your Raspberry PI wireless connection automatically at boot time if the instructions given in a previous post entitled How To Setup A Protected Wireless Connection Via The Command-Line worked. This is pretty straight forward. You must be root to carry out these instructions.

Save the wpa.conf file created in the previous post somewhere on the SD card you use to boot the system. For example in /root/bin/wpa.conf.

Create the following script and save it in a file called /root/bin/initWiFi for example

#!/bin/bash

/sbin/wpa_supplicant -Dwext -iwlan0 -cwpa.conf -B
/sbin/dhclient wlan0

Protect the files

chmod 700 /root/bin/initWiFi
chmod 600 /root/bin/wpa.conf

Add to the file /etc/rc.local before the last exit statement the following line

bash /root/bin/initWiFi

How To Setup A Protected Wireless Connection Via the Command-Line

1 Comment

Setting up a wireless connection via the command line may vary depending on the USB Wireless Interface you are using. These instructions also work for the Raspberry PI running Wheezy. You must be root in order to carry out these instructions.

Make sure that your wireless interface is recognized.

lsusb

Find your wireless interface name (usually wlan0).

ifconfig

Make sure that your network is visible asssuming the ESSID is broadcasted. Replace wlan0 by you wireless interface name.

iwlist wlan0 scan

or

iwlist wlan0 scan | grep ESSID

Prepare your wireless configuration file. It will wait for you to type in your wireless network password. Enter your wireless network password an hit ENTER.

wpa_passphrase Replace-with-your-ESSID > wpa.conf

Find out which wireless driver you are using. The drivers are listed in the drivers section. The driver you are using is usually labelled “Linux wireless extensions”. The driver name is most of the time wext.

wpa_supplicant --help

Initialize the wireless interface. Make sure you replace wpa.conf, wext and wlan0 with the values related to your environment. Some error messages may be displayed. These errors might not prevent your wireless connection from working.

wpa_supplicant -Dwext -iwlan0 -cwpa.conf -B

You can check if your wireless interface is properly initialized.

iwconfig

Issue this command to get an IP address assuming you are using DHCP.

dhclient wlan0

You can install wpa_passphrase and wpa_supplicant is they are not already on your system by issuing the command

apt-get install wpasupplicant
Blue Taste Theme created by Jabox