Raspberry Pi

From Holyheads Wiki
(Difference between revisions)
Jump to: navigation, search
m (Temperature Sensor DS1820)
m (Temperature Sensor DS1820)
Line 212: Line 212:
 
::*Power the sensors with 5 V
 
::*Power the sensors with 5 V
 
:::* I still get disconnects (only 2 out of 6 sensors) when there's some disc activity. Maybe putting the disc on a USB hub?
 
:::* I still get disconnects (only 2 out of 6 sensors) when there's some disc activity. Maybe putting the disc on a USB hub?
::*Implement multiple 1-wire interfaces, see [[#multiplew1]] - not yet tested
+
::*Implement multiple 1-wire interfaces, see [[Raspberry Pi#multiplew1|multiple 1-wire buses below]] - not yet tested
  
  
====Some 1-Wire Stuff===={{anchor|multiplew1}}
+
====Some 1-Wire Stuff====
 +
{{anchor|multiplew1}}
  
 
* Multiple 1-wire buses
 
* Multiple 1-wire buses

Revision as of 01:08, 11 June 2014

Contents

Cookbook

My collection of hints, tips and tricks (supporting my memory and maybe also helping others).

External USB drives

  • Install ntfs-3g if you need write access to ntfs file systems
  • How to increase performance?

udevil

  • example for manual mounting:
udevil mount /dev/sda1
  • my build-steps (maybe there's a simpler way, but this worked...):
    • download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget
    • extract deb-package via ar vx udevil_0.4.3-1_all.deb
    • extract data archive tar xzvf data.tar.gz
    • change to tar usr/share/devil/src
    • untar tar xvfJ udevil-current.tar.xz
    • cd udevil-0.4.3
    • mv distros/debian
    • execute dpkg-buildpackage
    • If all required packages are installed, this results in udevil_0.4.3-1_armhf.deb. If the build fails due to missing packages, install the missing packages, and re-do the dpkg-buildpackage step
    • Install via sudo dpkg -i udevil_0.4.3-1_armhf.deb

Samba server / NAS

  • Slow disc performance?
    • see 'Slow USB drives' above
    • use Raspbian, etc without GUI to get as much CPU power for file-transfer as possible (OpenELEC or RaspBMC constantly use about 10-20% CPU load when idle, use top to check!)
  • I don't need sound:
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf 
# I don't need sound
blacklist snd
blacklist snd_pcm
blacklist snd_soc_core
blacklist snd_soc_bcm2708_i2s

Trying to reduce number of disk writes (SD card)

I'm using RRD with a cron job (currently observing pi's temperature and frequency). I hope that my SD card has proper wear-leveling (and currently my 8 GB card is less than half full), so that the frequent writing should not be a problem. But still, I want to reduce the number of writes to the SD card (in order to not bust it's lifetime).

Here's what I've done:

  • Edit /etc/default/cron and set EXTRA_OPTS="-L 0" to disable logging (I don't need these)
  • Avoid entries like pam_unix(cron:session): session closed for user pi in /var/log/auth.log
    • Edit /etc/pam.d/cron and comment the line @include common-session-noninteractive ([1])
or
$local_fs_orig  +mountall +mountall-bootclean +mountoverflowtmp +umountfs
# we need the sym-link data in /var/log and /var/spool to be available
$local_fs       $local_fs_orig +persist-ramdisk
/etc/init.d/persist-ramdisk depends on $local_fs_orig, and the other init-scripts keep their dependency to $local_fs. This ensures that /var/log and /var/spool are ok when starting & stopping other init scripts.
  • set RAMTMP to yes in /etc/default/tmpfs to get tempfs based /tmp

Before changing /tmp:

But still, iostat shows quite some data written to the SD card, according to iotop its jbd2, the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with noatime).
I need to do more digging...

After changing /tmp:

It looks like the unwanted writes to SD are gone. I'll watch it for some time...

Useful stuff and Q&A

  • Q: Does Raspberry support WOL?
A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)
  • Q: The new password is to short, or too simple
A: Try adjusting the PAM settings in /etc/pam.d/common-password:
  • remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)
 password        [success=1 default=ignore]      pam_unix.so sha512 minlen=2
!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!
But it's nice for testing (if you cannot or do not want to use auto-login.)
  • Q: How to configure static IP?
A: In /etc/network/interfaces:
 iface eth0 inet static
   address 192.168.0.31
   netmask 255.255.255.0
   gateway 192.168.0.1
  • Q: How to read core temperature, etc?
A: vcgencmd:
 vcgencmd measure_temp
 vcgencmd measure_clock arm
  • External USB HDD spin down
    • hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)
    • hd-idle works:
hd-idle -a sda -i 600
for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)
  • Q: How to avoid update of a certain package?
A: Put package on hold ([2] (German)):
echo <packagename> "hold" | dpkg --set-selections
  • Q: How many bytes are written to my (SD) disc?
A: Use iostat http://www.mybinarylife.net/2012/08/linux-iostat-command.html
A: Use iotop http://guichaz.free.fr/iotop/
A: Raw data of the kernel can be found in files /proc/diskstats and /sys/block/DEVNAME/stat https://www.kernel.org/doc/Documentation/iostats.txt

Overclocking

  • I only set overclocking via raspi-config
Luckily, I could recover all my data, see below.
  • Medium: Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [3] and its links).
  • Underclocking to 600 MHz
echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
Raspberry was stable for some hours, but it got frozen later on. I don't now if really related to underclocking. As the temperature did not drop significantly (stayed around 45°C), and the Raspberry CPU has no sleep modes either (for power saving), I did not retry.

Stress test and benchmarks

My SD card data recovery procedure

After my (Turbo-overclocked) Raspberry fried my 8 GB SD card, I had not hoped to to be able to recover any data, but I tried anyway. The card was only 1 week old, I have not written that much data too it (<4 GB, mainly the Raspbian image).

  • Creating a binary image of the SD card with my PC using Win32 Disk Imager resulted in IO errors at about 17%.
  • The partition table of my SD card was still ok. I hoped to at least recover some text data of my ext4 partition, and thus I created an image using dd conv=noerror if=/dev/sdb2 of=rasp-image.img bs=1M on my Linux machine (option conv=noerror ignores any errors). The resulting image could not be mounted using a loop device.
    Example how to mount dd-ed image: [5]
  • Fortunately, fsck.ext4 raspberry-image.bin was able to repair the image, which I then could successfully mount on my Linux machine using mount -o loop rasp-image.img /mnt, and at a first glance, everything looked ok. So, I was at least able to get to my data.
  • I was just about to return the SD card, but for curiosity, I tried what happens if I re-install the (original) Raspbian image. To my surprise, Win32 Disk Imager did not report any error. And even more surprising, after writing the image, I was able to create an image of the whole disk without error. It looks like the card remapped some spare sectors.
  • My Raspberry successfully booted from this new image. I then used raspi-config to expand the root-fs (I've done this on my first installation as well). With Linux I was able to dd my repaired image to the repaired SD. The card booted as if nothing had happened...

Temperature Sensor DS1820

  • I have two DS18B20 and log temperatures using rrdtool.
  • When copying data via samba, I frequently get read-errors (CRC errors), or device-disconnects (/sys/bus/w1/devices/<id>/w1_slave temporarily not available).
    • Q: Is this due to overclocking with using dynamic governor?
    • A: No - also occurs without overclocking
    • Q: Or is this due to voltage-problems?
    • A: No - also occurs without over-voltage
    • Q: Or something else?
    • A: I have the impression that this is connected to electrical problems (e.g. timing, voltage) on my 1-wire when there's a lot of IO (USB, ethernet).
      • When disabling w1 master searches via echo "0" > /sys/bus/w1/devices/w1_bus_master1/w1_master_search there are no more device-disconnects. However, reading the temperature may still fail due to CRC errors.
      • Changing the timeout, e.g. to 20 via wire timeout=20 in /etc/modules seemed to have no effect (other than re-connects possibly taking more time).
    • A:Seems to be an electrical problem. Using 3 sensors works almost all the time, but using 4 or more sensors (2 connected star topologies), almost always fails to read values on most of the sensors.
Workarounds I want to try:
  • Reduce pull-up resistor
  • Add a small capacitor to each end of the wire (VDD to Gnd)
  • Power the sensors with 5 V
  • I still get disconnects (only 2 out of 6 sensors) when there's some disc activity. Maybe putting the disc on a USB hub?


Some 1-Wire Stuff

Template:Anchor

  • Multiple 1-wire buses
More hints on cross-compiling:

What about updates?

As I always forget this

  • <code>apt-get update - update package lists
  • apt-get upgrade - upgrade installed packages
  • rpi-update - update kernel and modules

Kernel Sources

Things I want to (or might) try sometime (e.g. collection if stuff to check)

  • NAS/Samba
  • try adjusting 'socket options' in (/etc/samba/smb.conf) to increase NAS performance: some websites recommend to disable the 'socket options', some recommend to set:
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536

Things done / Miscellaneous

Some links (aka bookmark lists)

Project sites

Blogs, forums, etc

Miscellaneous

Manuals

Personal tools