Monday, December 29, 2014

Fixing Left 4 Dead 2 Mouse Lag in Ubuntu 14.04

Issue

I have noticed a slight lag-like thing while playing Left 4 Dead 2 recently, mainly when turning with the character. It wasn't too obvious, but I felt something was wrong. I couldn't aim properly with the weapons and therefore I often missed shots. It seemed too much of a coincidence. I have tried tweaking some mouse sensitivity, acceleration etc. however the issue persisted.

Solution

Long story short, others have experienced the same problem while gaming on Linux. Luckily, def075 mentioned [1] that this may be a mouse polling issue. I did a quick search and found the solution [2]. Do the following,

  1.     gksudo gedit /etc/modules
  2.     And add the following 2 lines to the end of the file,
        -r usbhid
      usbhid mousepoll=1
  3.     And finally reboot.

Where the "mousepoll" tells the operating system how often to query (read data from) the mouse. The faster it does it, the less lag there is in the input. For reference [3],

1=1000 Hz (1ms)
2=500Hz (2ms)
4=250Hz (4ms)
8=125Hz (8ms)
10=100Hz (default, 10ms)

I have set mine to "mousepoll=1" and it works just fine. Some other posts say to set it to 2, I personally just went for the maximum to be on the safe side. Feel free to experiment with this, however I personally don't think that this would cause a great decrease in CPU time/performance on overall.

References


[1] - http://forums.steampowered.com/forums/showthread.php?t=3147537
[2] - http://ubuntuforums.org/showthread.php?t=392494
[3] - https://wiki.archlinux.org/index.php/Mouse_Polling_Rate

Thursday, December 25, 2014

First Video in Steam Not Playable - Ubuntu 14.04 64bit

After upgrading to Ubuntu 14.04 64bit I noticed that Steam was misbehaving and some features were unavailable. The first video of any game on the store was appearing as a single picture and couldn't be played and any other video wouldn't play normally on full screen.

Issue

  1. The first video of any game from the store in Steam under Ubuntu 14.04 64bit is not playable. This is also mentioned by other members of the community.[1]
    First Video in Steam is Not Playable "0:00/NaN/NaN"
  2. (Possibly) Full screen videos in Steam have a glitch where the top part of the screen is flashing and doesn't display video. Also the sides of the screen might develop the same glitch.

Solution

Flash layer is the issue and causes all the problems. The solution is to  download a 32bit version of libflashplayer.so and add it to a local Steam directory. [2] Do as the following,
  • Close Steam
  • In your browser go to http://get.adobe.com/flashplayer/otherversions/
  • Download a tar.gz of the 32bit flash player for Linux.
    32 bit Flash player in tar.gz
  • tar xzvf install_flash_player_11_linux.i386.tar.gz
  • mkdir ~/.local/share/Steam/ubuntu12_32/plugins/
  • cp libflashplayer.so ~/.local/share/Steam/ubuntu12_32/plugins/libflashplayer.so
  • Start Steam
The first videos should be playable now and the screen glitch should also be gone. Worked as a charm for me.

Note:
By default the Steam directory is ~/.local/share/Steam however if you have changed this, please change it in the above commands.

You can remove the extra "junk" files that were unpacked from the tar.gz file. Untaring creates a "usr" directory in the download location that can be removed with rm -rf usr and the readme.txt with rm readme.txt.

Refrences


[1] - http://www.reddit.com/r/Steam/comments/2lrbp3/steam_linux_first_video_in_store_page_never/
[2] - http://wiki.gentoo.org/wiki/Steam#Flashplayer_on_amd64 

Sunday, December 21, 2014

Xorg High CPU Usage in Ubuntu 14.04

The Issue

I started having some problems recently with xorg using way too much CPU power on my Linux desktop.

I have recently upgraded to Ubuntu 14.04 on this machine ad got stuck after the login screen. I have tracked down the issue with the proprietary ATI/AMD drivers (fglrx). I have managed to get into tty terminal via CTRL+ALT+F2 and I have removed everything to do with proprietary drivers using this guide.

Hence I switched back to open source drivers that were working just fine. The problem being that xorg used a whole core of my dual-core CPU. This is not normal and had to be addressed. I started looking around and found the issue on many forums and posts.

The output of top looks something like this

PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
 1262 root      20   0  267204  56016  15320 R  55.8  1.1  27:37.97 Xorg
 2641 nargren   20   0 1431604 574100  54096 R  35.9 11.5  11:26.71 firefox
 2435 nargren   20   0 1353536  84540  39284 S  12.6  1.7   1:09.57 compiz

The Solution

I have worked on this for the better part of 2 days and tried multiple methods suggested in different forum threads.

First I have overlooked this thread and tried to look elsewhere, however it has turned out that those methods didn't work. I got curious when I saw that QIII was also having the exact same issue and was using conky, just like me. He claimed using conky on 2 other distros as well, without any issues (on the same machine) so he ruled that one out as the source of the issue. In the end he has upgraded his OS and got rid of the issue (thread from 2012).

I have quickly killed my conky session with
sudo killall conky
to see what happens. And voilĂ ! Checking top immediately revealed what the issue was. After the change, this is how it looked like below.

PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
 2435 nargren   20   0 1352980  84544  39288 R   4.3  1.7   1:20.38 compiz
 1262 root      20   0  267440  56024  15328 R   4.0  1.1  33:18.70 Xorg
 2993 nargren   20   0  654880  26736  12656 S   3.0  0.5   0:08.41 gnome-terminal

Conclusion

The issue was conky indeed. Hence I have to sacrifice my cool, real-time system information for now. However, I will keep on troubleshooting and see if by changing some settings I can get back my conky.

So if you are having the same issue with xorg and are running conky, try killing it and see if the CPU usage drops.

Saturday, November 1, 2014

VPN Autoconnect at Startup in Ubuntu

I am using Ubuntu 12.04 with XFCE4 and the VPN Autoconnect option in the network configuration doesn't do any good. As far as I know this is a bug which causes the VPN autoconnect to malfunction if a new network is joined, be that ethernet or WiFi. This is kind of a big problem as one needs to connect to the internet first before the VPN connection can be established.

VPN Configuration - (Autoconnect checkbox does not work)
The solution I found best working is to create a shell script that manually connects to a VPN with a delay of 15 seconds. This delay allows sufficient time for the operating system to establish an internet connection, after which connecting to the VPN should be smooth. If you do not add a delay, the VPN connection may start before you have an internet connection and hence fail.

Tip: You can play around with the delay time, likely on a faster computer an internet connection may as well be established in under 10 seconds. My system takes a bit longer to boot and I found 15 seconds to be acceptable and working just fine.


List Available VPN Connections & Get UUID

Type,
nmcli con

This will give you an output with all your network connections, including the saved VPN profiles.
Copy the UUID of the VPN connection you want to establish. (I will refer to this as <UUID> further on)

Create a Shell Script that Manually Connects

Create a shell script, lets say call it VPNAutoconnect.sh with the following in it

#!/bin/sh
#Script to automatically connect to VPN
sleep 15;nmcli con up uuid <UUID>
(<UUID> here is of course the UUID you copied in the previous step)
make the script executable by
sudo chmod +x VPNAutoconnect.sh

Adding Script to Startup in rc.local

Add script to /etc/rc.local to have it executed at system start. Your rc local file will look something like this,
nano /etc/rc.local

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Set screen backlight to 75%
xbacklight -set 75
#Connect to VPN after 15 seconds (allows connecting to the internet first)
sh /route/to/script/VPNAutoconnect.sh
exit 0
Save the file and you are done. The next time the computer starts up, after the delay of 15 seconds set in the script file a VPN connection will be initiated. 

Of course you can also directly add the command to rc.local, however if you have multiple VPNs and plan to change it in the future, a separate file might be better (little longer script) where you can set which VPN you want to connect to. Also, using a separate script can help you keeping your rc.local file more clean and organized.

Important: Place the VPNAutoconnect.sh script somewhere where you will not delete it accidentally or move it. If the file is moved then at the next startup rc.local won't be able to execute it (clearly). The problem arises when you trust the script and go ahead browse the web and find it out 30 minutes later that you are not using a VPN specifically because the file was moved and hence at boot no connection was made. Yeah. I personally like having a "Scripts" directory under my home that contains such small scripts.


Count the Occurence of All Words in a Number of Text Files

Recently I was given the task to analyse a range of files (around 300) and count the occurrence of all the words in each file. So the aim was to put together a piece of code that goes through all files in a directory, reads in a file, lists all the words occurring in it and counting how many time each word has occurred.

I quickly found out that in case of a single file the process is rather simple, the following code does a fine job,

for w in `cat FILE.txt`; do echo $w;done|sort|uniq -c >> results.out
This code reads in FILE.txt and for each word in it counts its occurrence and the creates a list from it.

However putting this into a recursive script was a little more complicated. So I took another direction and found a piece of code using sed to do the same job on a single file. With this and some scripting knowledge I was able to put together just what I needed.

Additionally, I used the command basename to output the name of the file so I know which file was which.

The final piece of code looks like this,

for file in `ls /PATH/TO/DIRECTORY/`
do
basename /PATH/TO/DIRECTORY/FILE >>
results.out        sed s/' '/\\n/g /PATH/TO/DIRECTORY/FILE | sort | uniq -c | sort -nr >>  results.out
echo "" >>  results.out
done

This does a perfect job and creates a single file with the output containing,
  • File name of each file
  • Occurrence of each word in the file, sorted from high to low
  • Empty line to separate data from each other
If anyone has any other suggestion or comment I am happy to hear it!



Sunday, September 21, 2014

How to Encrypt Files and Directories in Ubuntu - EncFS

After the Truecrypt.org went down recebtly and visitors were informed that Truecrypt contains vulnerabilities and it is discontinued I had to search for an alternative. I have known about EncFS for a good while, however the convenience of Truecrypt's cross-platform property has won me. Now however, I have moved to use EncFS on my linux machine.

Advantages

There are some advantages of using EncFS as per explained at arg0.net/encfsintro. Just to sum it up:
  • Size grows without need of reformatting
  • Backing up is easier (with e.g. rsync or GUI version grsync) as files can be individually backed up
  • Can be layered on other file systems
SO in general, one doesn't need to specify a fixed size for the encrypted file system, which simply means there will be no "unused encrypted space". Also, the fact that files are individually available, allows backing them up one-by-one, which makes it, well possible at least to say. With Truecrypt previously, if one wanted to back up a container, the entire encrypted volume had to be uploaded and re-uploaded any time something was changed in the original document. At the cost of some "anonymity" (described below) this is no linger an issue.

Disadvantages


Again as per explained in the above mentioned link:
  • Meta Data is available in the encrypted directory
    • File size
    • Permissions
    • Number of files
    • Approximate name length (but not the name itself)
Unfortunately, this allows some guessing what the files might be. Not their actual name, or content but definitely what they are. Even though file types are not shown, a couple KB document is probably some sort of text file, whereas a few MB one might be a picture, pdf and so on. Modification dates are also shown in plain text, in some scenarios this might be an issue.

Everyone has t decide, whether or not leaking this kind of information is acceptable or not. It is definitely better than not encrypting the file sin the first place, however it might not be enough in other cases. 

How Does it Work?


Check out the code below. This would create en encrypted directory and mount it to another directory, effectively a mount point.

$ mkdir /tmp/crypt-raw
$ mkdir /tmp/crypt
$ encfs /tmp/crypt-raw /tmp/crypt
Volume key not found, creating new encrypted volume.
Password: [password entered here]
Verify: [password entered here]
 

This would  do the following


mkdir /tmp/crypt-raw - Create a directory at the specified location. This will be the actual directory holding the encrypted files.

mkdir /tmp/crypt - Create a directory at the specified location. This will be the mount point for your encrypted directory. This directory will not contain any actual file, it will simply link to the encrypted directory. If you have it at /tmp it will be deleted on every restart. You can choose it to be at any other location too, of course.

encfs /tmp/crypt-raw /tmp/crypt - Command to mount the encrypted directory (crypt-raw) to the location of the directory crypt. If running the command for the first time it will ask you to give a password and specify the type of encryption.

 

How to use this


You are technically done. Any files you put in the crypt directory will actually be stored in crypt-raw (encrypted). As long as the directory crypt is mounted, the encrypted files are visible. If you unmount it, the files are only visible in crypt-raw and if you check them you only see scrambled text/data, that is ciphertext.

Example of some files stored in the encrypted directory
As you can see in the example above, file size and modification date is shown as clear text, but file names are encrypted.

Unmount


To unmount the directory run
$ fusermount -u /tmp/crypt

After this the both the mount point and encrypted directories will still be present, but crypt will be "empty" while crypt-raw will only contain unreadable ciphertext.

Note: /tmp is flushed on restart hence crypt directory will be removed. This is, however no problem, running the code will recreate and mount this directory again upon new reboot.

Tip


Create a small script that will mount, unmount and open the encrypted directory you use the most! Take a look at http://pastebin.com/CXRPQUsK for what I am using. This way is much faster and more convenient to use encryption, it only takes a few seconds to open and close the container.

Monday, June 30, 2014

Installing Matlab in Ubuntu 32bit Version

First things first. Matlab 32bit is only available as Matlab version R2012a as later releases only come in 64bit versions and hence only work on 64 bit operating systems. The R2012a version of Matlab uses a Java application to download the software on your computer called downloader_agent (as opposing to a tar.gz file for example which you get after the 2012 releases). 

You can download this file from the matching Matlab website, www.matlab.com and run this file in the browser or using the terminal command

javaws /route/to/downloader_agent

which gives the same result.

However if you are getting an error, this article will most likely help you.

If you get an error while trying to download the downloader (yes downloading a downloader to download a software....) which looks like the following the issue can be one of 2 things.



Java is blocked on the Site


The website is not allowed to execute Java applications. Hence the solution can be to add the site to the exceptions. To do this open a command line and type,

jcontrol

This will bring up the following window
Java control GUI Window - Security Settings Tab
Click on "Edit Site List" and add the security exception for necessary site mentioned in your downloader_agent, e.g. http://www.mathworks.com.
Adding a Security Exception

Confirming Security Exception
Confirm and accept the exception you made. After this try to run the downloader file again. If it starts downloading Matlab, proceed with the installation procedure.

Missing Java Security Exceptions


If your jcontrol window doesn't have an "exceptions" part in the security settings, you need to update your Java installation.

Missing Site Exceptions Settings

You can find many guides for this: How to Update Oracle Java 7

Java Versions Interfering


Another problem can be that you have multiple versions of Java installed and this is causing some trouble.
The solution is to remove everything related to Java and then reinstall the basic package. To do this:
  1. Follow this guide to completely remove Java from your system
    http://askubuntu.com/questions/84483/how-to-completely-uninstall-java
  2. Confirm that you have indeed removed everything. Try,

    java -version

    If you get an output, you have not removed something. Go back to the previous step and see what step you have missed.
  3. Reinstall the basic Java package from the terminal with,

    sudo apt-get install default-jre
  4. Run the downloader_agent again from your browser or with,

    javaws /route/to/downloader_agent
If you were successful you should be able to download Matlab and will see the following window popping up. Follow the on-screen instructions to install the software, it should look similar to the process depicted below.

Matlab Downloading

Selecting Installation Method

Install Progress Bar

Additional Configuration Steps

Installation & Activating Product

Running Matlab

After the rocess was completed you can run Matlab from the terminal with the command,

route/to/Matlab-R2012a/bin/./matlab

or you can create a launcher for it on the Desktop. For me for some reason it only worked when I started it from the terminal and not executing the matlab file as a program.

If you have any questions or are stuck anywhere, leave a comment and I'll see if I can help.

Monday, April 7, 2014

Install Raspberry Pi without Monitor, Keyboard or Mouse

This guide walks you through how to set up your Raspberry Pi without connecting a TV or computer monitor to it at all only by the means of using an ssh tunnel and a computer. This guide is tailored for using Ubuntu linux, however other operating systems can do the same in a slightly different way.

This method can be very useful for those who do not have access to a HDMI TV or computer monitor where they could do the initial configuration for their Raspberry Pi.

This guide is based on using Raspbian Wheezy OS version 2013-12-20.

Installing on an SD Card

The steps are described at elinux.org nicely, however I would like to point out a few things here.

  1. Obtain a copy of the latest (or desired) version of raspbian.img from
    http://downloads.raspberrypi.org/raspbian/images/
    In this article I will be referring to 2013-12-20-wheezy-raspbian.zip
  2. wget  http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-12-20/2013-12-20-wheezy-raspbian.zip
  3. unzip 2013-12-20-wheezy-raspbian.zip
  4. Note: for me the SDcard was /dev/sdb. You can check yours by e.g. running gparted with

    sudo gparted

    and checking the devices. Makes absolutely sure you are using the correct one!
  5. WARNING! The command "dd" will be used here that can cause major data loss if used incorrectly. "of=/dev/sdb" must be correctly given as output destination. If you choose the wrong drive, it may overwrite everything on your computer's hard disk. In my case the command was

    sudo dd bs=1M if=2013-12-20-wheezy-raspbian.img of=/dev/sdb

    dd -calls dd file copying formatting tool
    bs=1M - Tells what block size to use. This is important!
    if=xxx - Input file
    of=xxx - Output file (again where the command will write)
  6. Flush write cache with

    sudo sync 

WARNING!
When using "dd" please make sure what you are doing. Selecting an incorrect device will lead to data loss.


Note that I have used the second latest Raspbian image as I had issues with the 2014 version with libc6, so I have decided to downgrade. You may try the latest version of course.

At this point you should be done and read to boot your Raspberry Pi for the first time. However, I would like to show how you can set up internet access right away without the need to connect the Pi to a screen. This will allow you to ssh into the device at first boot and configure from there.

Configuring Internet Access

This part depends on whether you want ethernet or wifi internet access. First, mount the newly formatted SD card's 2'nd partition, sdb2 in my case, so

sudo mkdir -p /mnt/raspberry
sudo mount /dev/sdb2 /mnt/raspberry

Open the network configuration file with

sudo nano /mnt/raspberry/etc/network/interfaces

And make it look similar to this

auto lo

#Wired interface, ethernet connection
iface lo inet loopback
iface eth0 inet static
#address 192.168.0.25
#netmask 255.255.255.0
#gateway 192.168.0.1

#Wireless interface (Wi-Pi)
auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.0.25
netmask 255.255.255.0
gateway 192.168.0.1
wpa-ssid YOURWIFISSID
wpa-psk YOURWIFIPASSWORD

#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface default inet dhcp

Save file with CTRL+O and exit with CTRL+X.

Explanation

These settings give a static local IP address to your Pi both to the ethernet (cable/wired) and wireless interface. A static address is useful as this will let you connect to the device always with the same IP address instead of having to search for it on the local network. If you have your Pi connected to your home router with a cable and do not use WiFi, then you don't need to configure the WiFi configuration part.

Assuming you have WPA2-PSK WiFi encryption the wpa-ssid and wpa-psk fields are correct and should be filled in with your network's credentials [2]. If you have other type of WiFi encryption on your local network, please refer to https://wiki.debian.org/WiFi/HowToUse to find the correct settings.

Of course, if your home network is different then you have to adjust the appropriate fields. The above settings are just a sample that you can use.

You are done with the most important configuration part, now the SD card can be inserted into the Pi and booted for the first time. Remove the card from your computer with

sudo sync
sudo umount /mnt/raspberry

Remove SD card and plug it into the Pi.

First Boot

If you did everything correctly, your Raspberry should boot without a problem. Wait about a minute before you would try to ssh. Then you can

ssh pi@192.168.0.25

(192.168.0.25 based on the interfaces configuration file I posted above)

Now you are presented with the terminal login. Log in with the default username and password:
username: pi
password: raspberry

The first thing you probably want to do is open raspberry config and do a few things. You can do this over an ssh tunnel with

sudo raspi-config

Raspi-config screen over an ssh tunnel

Based on what you want to do with your raspberry you can set up a range of things. What I have set up for mine:
  • Set custom hostname
  • Set GPU memory allocation to 16 as I will use the device without GUI and therefore won't need much RAM for the GPU
  • Expand partition (The image file copied to the SDcard is sized for smaller 2-4 GB card. So if your card is bigger, you should expand the partition on it to make it usable)

Add a new user instead of the default pi with

sudo adduser YOURUSERNAME

Give the password twice and fill out the additional information. Then give root permissions to this user by editing the following file

sudo nano /etc/sudoers

And look at the end of the file and append the line

#includedir /etc/sudoers.d
pi ALL=(ALL) NOPASSWD: ALL
YOURUSERNAME ALL=(ALL) NOPASSWD: ALL
This pretty much sums up the most important steps you should take when installing new a Raspberry Pi. The rest is up to you what you want to do with your device.

I like this method, because it spares me the hassle of connecting my Raspberry to a TV, attaching keyboard etc. to configure it. I also keep a second SD card installed as a backup that is just a clean install with ssh access. I had problems before with file system corruption and a quick SD card swap has saved  a lot fo problems for me.

References

[1] - http://elinux.org/RPi_Easy_SD_Card_Setup
[2] - https://wiki.debian.org/WiFi/HowToUse

Thursday, April 3, 2014

Heat Sinks on the Raspberry Pi



The Raspberry Pi is a credit-card sized computer that plugs into your TV and a keyboard. It is a capable little computer which can be used in electronics projects, and for many of the things that your desktop PC does, like spreadsheets, word-processing and games. It also plays high-definition video. We want to see it being used by kids all over the world to learn programming. [1]

This post will discuss the need and usefulness as well as short installation instructions of heat sinks for the Raspberry Pi. Information is related to the Raspberry Pi Model B (512 MB RAM)

 

Is it necessary?

 

The question often comes up, is it necessary to use some sort of cooling on the Pi or is it fine as it is?

From an engineering perspective it is most likely not necessary to use an additional heat sink. A product for sale should normally work "as is" without any major source of failure or a need from the consumer to do changes to the product. Maybe that is only my perspective in general, but the point has been made.

The ARM11 processor powering the Raspberry Pi Model B is used in a range of mobile devices that do not have any cooling, except for passive cooling heat sinks maybe. Forums and other sources say [2] that heat is not an issue with these chips until about 100 degrees Celsius (212 Fahrenheit). It is very unlikely that one would get to such temperatures under any sort of normal usage.

Why Use a Heat Sink then?


Thermal view of the Raspberry Pi Model B (Source)

It is a personal choice to use a heat sink on the Raspberry, but as mentioned above it is absolutely not necessary. So what might influence you to buying a heat sink for your Raspberry?
  • Hot environments and overclocking
  • The looks of the device and peace of mind, knowing it will not overheat
  • Continuous heavy load and overclocking
  • Because you want to do it

Normal Operating Conditions

During normal usage my Raspberry in its original case is operating in the range of 46-48 C, based on my own measurements. This is slightly less than the temperatures of 51-53 C measured by Thomas [4] for an enclosed idling Raspberry Pi. Possibly due to the fact that I am reading off the values via a software whereas he was using thermal imaging.

Either way, these values are well within the operating limit and shouldn't cause any issue any time soon. However, I would sleep better if I knew that there was some sort of extra heat removal method on my Raspberry when I'm not at home and this little thing is working at full load.

Overclocking

Overclocking is the process of increasing the clock rate of the Raspberry Pi's processor. By default it is running at 700 MHz, however even from the default firmware this can be increased to 800 MHz or even further to 1 GHz.

Overclocking increases the speed of the processor, however it also means a higher energy consumption and therefore more heat generated. The temperature of a processor has nothing to do with the performance of the processor (speed), but rather its lifetime. At higher temperatures a processor is more likely to fail compared to one operating at lower temperatures, refer to image below. 
Semiconductor lifetime with increasing junction temperature (source [3])

Hence it is of best interest to keep CPUs at as low temperatures as possible.

I am still running my Raspberry Pi at the original 700 MHz and do not plan to overclock any time soon. If I will need an increased performance I would look into it, but for now I do not see the point for my usage profile.

Which Heat Sink to Use and Where to Put It?

I went for Aluminium heat sinks (from eBay) which were exactly the right size and made for the Raspberry Pi. For easy application I chose the ones that have some thermal paste sticker on the back, so it is literally as easy as peeling off the back and aligning it properly on the chip.

Aluminium heat sinks ready to be glued onto the chip

Aluminium heat sinks applied to the Raspberry Pi

I would say position or aligning the heat sinks (which way the fins are facing) is barely going to affect the already small efffect they make. If you have an air flow over the Pi then from a heat transfer point of view it is more efficient to have the fins parallel to the air stream so that it moves between the fin and removes more heat. Nevertheless, do not worry about this as it will not make a significant difference, especially if you are using the Pi in a standard room condition without overclocking.

Be careful when position and dropping the glued heat sinks onto the board as they stick fast and removing-reapplying them may reduce the contact surface between the heat sink and the board. Apply pressure gently to make them stick nicely, but avoid damaging the board.

Conclusion

If you want to put some heat sinks on your Raspberry Pi because you are worried about it "burning out", then you probably do not need heat sinks. In some of the above mentioned use scenarios you can consider, but chances are it will not make much of a difference.

If you love tinkering with tech, want to learn a little about the RPi and are curious, then go ahead, It isn't much work nor does it cost a lot of money, but you will have a slightly more customized Raspberry Pi.

References

[1] - http://www.raspberrypi.org/faqs
[2] - http://blog.oscarliang.net/raspberry-pi-heat-sink-do-you-need-it/
[3] - http://www.interfacebus.com/Integrated-Circuit_Derating_Guide.html
[4] - http://www.tooms.dk/?page=http%3A//www.tooms.dk/Tblog/Showblog1.asp%3FY%3D2012%26M%3D9


Wednesday, April 2, 2014

Ubuntu One File Services Shutting Down!

Canonical has announced today shutting down the Ubuntu One cloud storage and music storage system. The company said that they cannot compete any more with other service providers giving away free 25-50 GB of storage. As a consequence further releases of Ubuntu, starting with 14.04 LTS, will not ship with the Ubuntu One file services.

However, as the blog post states
"The shutdown will not affect the Ubuntu One single sign on service, the Ubuntu One payment service, or the backend U1DB database service."

Important Dates to Keep in Mind

April 02 2014: It is no longer possible to buy additional storage or music files
June 01 2014: Services will be unavailable (User data still available for download)
July 31 2014: All files left in the cloud will be deleted


Please read the official blogpost here: http://blog.canonical.com/2014/04/02/shutting-down-ubuntu-one-file-services/ for more information about the details.

Make sure to backup all the data you have in Ubuntu One file storage!

Thursday, January 16, 2014

Raspberry Pi for Block Erupter Bitcoin Mining

Previously I have written about setting up Bitcoin mining with the Block Erupter in Ubuntu, however a more efficient way to mine can be to use of a Raspberry Pi to control the Block Erupter(s). The major benefit to this is the greatly reduced power consumption, provided by the Raspberry Pi compared to a desktop computer or a laptop.

Controlling the mining of a Block Erupter does not require huge amounts of system resources, so the Pi can also be used for other tasks at the same time (ssh tunnelling, small webserver and so on).

Initial Requirements and Expected Outcome

Hardware

  • Raspberry Pi (preferably model B)
  • Block Erupter (as used in this guide, but other miners should also work if connectable)
  • Powered USB hub
  • Small fan (cooling the miner, necessary for Block Erupter)

Software

  • Raspbian Wheezy (OS running on the Raspberry Pi)
  • screen
  • bfgminer 3.9 [1]

Expectation

  • Steady, reliable mining speed of 300-330 MH/s
  • Low HW errors, definitely under 1%, but better in the range of 0.4-0.6%
  • Continuous running without the need of reboot or maintenance of any sort
  • No "hungs" of the Raspberry Pi, mining and configuration to be done without physical access to the hardware after initial setu
  •  Remote access and configuration (reach the Raspberry Pi through ssh)

Installation

Installing bfgminer

I have installed the latest version (as of December 2013) of bfgminer 3.9.0. This will be the reference in this guide. If you choose to install another version, please change the commands accordingly.

  1.  ssh into the Raspberry Pi. You will need root privileges.

    ssh user@raspberrypi
  2. Installing dependencies

    sudo apt-get install build-essential autoconf automake libtool pkg-config libcurl4-gnutls-dev libjansson-dev uthash-dev libncursesw5-dev libudev-dev libusb-1.0-0-dev libevent-dev libmicrohttpd-dev hidapi libmicrohttpd-dev
  3.  Download bfgminer

    wget http://luke.dashjr.org/programs/bitcoin/files/bfgminer/3.9.0/bfgminer-3.9.0.zip
  4. Unzip

    unzip bfgminer-3.9.0.zip
  5. Cd to directory

    cd bfgminer-3.9.0
  6. Configure. Note that by default all miner configuaations are enabled, so no extra argumetns are required if building for Block Erupters. (If you would like to disable some miners because you will not be using them, check out the README file that comes with bfgminer)

    ./configure
  7. And finally make

    sudo make
Technically it is done and bfgminer can be run.Navigate to the directory and

sudo ./bfgminer -o pool:port -u usrname -p password -S erupter:all

Where "-S erupter:all"  is important as it tells bfgminer to search for all connected Block Erupters and use them for mining.

The problem of running bfgminer like this is that it is only running until you have the ssh tunnel open. Once you close it, bfgminer shuts down. Hence one would need to have a computer running 24/7 in order to keep the ssh tunnel open and contiue mining. To overcome this problem, screen will be used. [2]

Running bfgminer "as a service" with screen 

"Screen is a full-screen window manager that multiplexes a physical terminal between several processes." [3] Technically it allows to run a command in a virtual terminal window in the background, which allows running the miner in the background too without the need of a live ssh connection to the Raspberry pi.

Simply install screen with
sudo apt-get install screen

After that, running bfgminer with screen goes as the following.

Start Bfgminer
sudo screen -dmS miner ./bfgminer -o pool:port -u usrname -p password -S erupter:all

Note: that this assumes you are in the directory of bfgminer. If you want to make a general command append the route to before ./bfgminer.

This will start bfgminer in a new screen session, detached, so no output will be shown on the screen, you will be returned to the command line. Here is a short explanation what the parts of the above command do.

  • screen: start a new screen sessions
  • -dm : Start screen in "detached" mode. This creates a new session but doesn’t attach to it. This is useful for system startup scripts.
  • -S: Session name. When creating a new session, this option can be used to specify a meaningful name for the session. As above I named the session "miner", one may choose a more specific name as well.


Switch to the Screen Session 

sudo screen -dR miner

This will switch to the screen session where bfgminer is running. Here you can monitor the miner, accepted shares, stales and so on. Once you checked the miner is running OK, exit the screen session properly, without interrupting the miner!

Stop Screen Sessions

CTRL+A+D

This will properly detach the screen session, without interrupting the miner. Note if you exit the screen session with CTRL+C or exit the miner with "q", the mining will stop.

Observations

Choice of Miner

Originally I tried to make mining work with cgminer as that was more familiar to me and have been using it for quite a while. However, I have encountered several problems that I could not overcome.
I tried virtually every version of cgminer from 2.8 until the latest version to see which one works best, but none could perform reliably. Hardware errors (HW) were in the 10% range (!) which is far above the expected value. First I feared that I bought a somehow faulty chip and this was the reason for getting so many HW errors.
The miner was also somehow unstable and caused the Raspbery Pi to hung after about ~20h of running and required a maanual reboot. This was definitely not what I was looking for.

All this might not be caused by cgminer as I find it a great software for mining (works great on my computer), however I could not get it to work the way I wanted to with he raspberry Pi.

Bfgminer seems to have solved all these issues. The miner runs steady with a low ~0.50% HW error and it did not get hung so far after some extensive testing. Configuration is easy and it works pretty much "out of the box".

Pool

Some pools implement a high stratum difficulty which means that a 330MH/s miner will have a hard time submitting shares at all. I found this issue with quite a few pools. Triplemining on the other hand has a stratum difficulty of 1 and I am submitting a share about every 30-40 seconds.

Cooling and Hardware

As mentioned before in my setting up Bitcoin mining with the Block Erupter in Ubuntu article, the Block Erupter requires some cooling. Initially I wanted to add some small copper heat sinks, however this plan failed due to delayed delivery of the heat sinks. Hence I am only using a small fan directed over the Block Erupter and somewhat creating a slight air movement over the rasoberry Pi as well. See some pictures below. Not a masterpiece for sure, but runs fine and was a nice experiment!

Complete setup contained in a plastic basket

Block Erupter and the USB hub

Small USB fan (partially disassembled)
Bfgminer stats after running for 7 days


References