https://holyhead.de/api.php?action=feedcontributions&user=Holyhead&feedformat=atomHolyheads Wiki - User contributions [en]2024-03-29T07:03:35ZUser contributionsMediaWiki 1.19.5https://holyhead.de/index.php?title=Raspberry_PiRaspberry Pi2020-02-20T12:52:16Z<p>Holyhead: /* Multiple 1-wire buses */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
===External USB drives===<br />
<br />
* Automount USB-Drives in Raspbian<br />
** One may use [http://selfprogramming.bplaced.net/index.php/2012/10/23/automount-usb-drives-in-raspbian/ USBmount and autofs]<br />
** I prefer [http://ignorantguru.github.io/udevil/ udevil], see below<br />
<br />
* Install ''ntfs-3g'' if you need write access to ntfs file systems<br />
<br />
* How to increase performance?<br />
** Mount with option ''''noatime'''' or ''''relatime''''<br />
** Mount ''without'' option sync (e.g. keep default async)<br />
** If using ntfs-3g (fuse) file system, try mounting with option 'big_writes', see for example http://obihoernchen.net/wordpress/tag/big_writes/<br />
<br />
===[http://ignorantguru.github.io/udevil/ udevil]===<br />
<br />
* example for manual mounting:<br />
<br />
udevil mount /dev/sda1<br />
<br />
* auto-mounting via udev-rule, see for example http://lsdlinux.org/wiki/doku.php?id=auto_mounting#using_udev_rule (I just copied the 95-udevil-mount.rules file from an OpenElec installation (http://www.raspberrypi.org/downloads) )<br />
<br />
* my build-steps (maybe there's a simpler way, but this worked...):<br />
** download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget<br />
** extract deb-package via <code>ar vx udevil_0.4.3-1_all.deb</code><br />
** extract data archive <code>tar xzvf data.tar.gz</code><br />
** change to tar usr/share/devil/src<br />
** untar <code>tar xvfJ udevil-current.tar.xz</code><br />
** <code>cd udevil-0.4.3</code><br />
** <code>mv distros/debian</code><br />
** execute <code>dpkg-buildpackage</code><br />
** 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<br />
** Install via <code>sudo dpkg -i udevil_0.4.3-1_armhf.deb</code><br />
<br />
===Samba server / NAS===<br />
<br />
* How to install?<br />
** [http://jankarres.de/2013/11/raspberry-pi-samba-server-installieren/ | Raspberry Pi: Samba Server installieren] (German)<br />
** [http://www.welzels.de/blog/projekte/raspberry-pi/low-budget-nas-mit-einem-raspberry-pi/ Low Budget NAS mit einem Raspberry PI] (German)<br />
<br />
* Slow disc performance?<br />
** see 'Slow USB drives' above<br />
** 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!)<br />
<br />
* Configuration and tuning<br />
** https://calomel.org/samba.html<br />
** https://calomel.org/samba_optimize.html<br />
<br />
* If your /var/log/samba/log.smbd fills up with ''printing/print_cups.c:110(cups_connect) Unable to connect to CUPS server localhost'' messages, try http://www.sotechdesign.com.au/samba-log-showing-error-failed-to-retrieve-printer-list/<br/>I also created an empty <code>/etc/printcap</code> to avoid ''Unable to open printcap file /etc/printcap for read'' messages.<br />
<br />
* I don't need sound:<br />
<br />
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf <br />
# I don't need sound<br />
blacklist snd<br />
blacklist snd_pcm<br />
blacklist snd_soc_core<br />
blacklist snd_soc_bcm2708_i2s<br />
<br />
===Trying to reduce number of disk writes (SD card)===<br />
<br />
I'm using [http://oss.oetiker.ch/rrdtool/ 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).<br />
<br />
Here's what I've done:<br />
<br />
* Edit <code>/etc/default/cron</code> and set <code>EXTRA_OPTS="-L 0"</code> to disable logging (I don't need these)<br />
* Avoid entries like <code>pam_unix(cron:session): session closed for user pi</code> in <code>/var/log/auth.log</code><br />
** Edit <code>/etc/pam.d/cron</code> and comment the line <code>@include common-session-noninteractive</code> ([http://ubuntuforums.org/showthread.php?t=1256801])<br />
:or<br />
:* Edit <code>/etc/pam.d/common-session-noninteractive</code> as shown here: http://ubuntuforums.org/showthread.php?t=1256801&p=10283830#post10283830<br />
* I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)<br />
** moved all the .rrd files as well as the created images to my persistent-ramdisk location<br />
** moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links<br />
*** <code>/var/spool</code><br />
*** <code>/var/log</code><br />
*** <code>/var/cache/samba</code><br />
** edited <code>/etc/insserv.conf</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:<br />
<br />
$local_fs_orig +mountall +mountall-bootclean +mountoverflowtmp +umountfs<br />
# we need the sym-link data in /var/log and /var/spool to be available<br />
$local_fs $local_fs_orig +persist-ramdisk<br />
<br />
:: <code>/etc/init.d/persist-ramdisk</code> 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.<br />
<br />
:* set ''RAMTMP'' to yes in <code>/etc/default/tmpfs</code> to get tempfs based <code>/tmp</code><br />
<br />
Before changing <code>/tmp</code>:<br />
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').<br />
::I need to do more digging...<br />
<br />
After changing <code>/tmp</code>:<br />
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...<br />
<br />
===Useful stuff and Q&A===<br />
<br />
* Q: Why does my Pi restart when hotplugging a USB drive?<br />
** http://thestuffsido.blogspot.de/2013/05/fixing-raspberry-pi-hotplugging.html<br />
** http://therandomlab.blogspot.de/2013/01/raspberry-pi-mod-to-avoid-shutdown-on.html<br />
<br />
* Q: Does Raspberry support WOL?<br />
: A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)<br />
<br />
* Q: The new password is to short, or too simple<br />
: A: Try adjusting the PAM settings in <code>/etc/pam.d/common-password</code>:<br />
:* remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)<br />
::<code>password [success=1 default=ignore] pam_unix.so sha512 minlen=2</code><br />
<br />
::!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!<br><br />
::But it's nice for testing (if you cannot or do not want to use auto-login.)<br />
<br />
* Q: How to configure static IP?<br />
: A: In /etc/network/interfaces:<br />
::<code>iface eth0 inet static<br>address 192.168.0.31<br>netmask 255.255.255.0<br>gateway 192.168.0.1</code><br />
<br />
* Q: How to read core temperature, etc?<br />
: A: [http://elinux.org/RPI_vcgencmd_usage vcgencmd]:<br />
::<code>vcgencmd measure_temp<br>vcgencmd measure_clock arm</code><br />
<br />
* External USB HDD spin down<br />
** hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)<br />
** hd-idle works:<br />
::<code>hd-idle -a sda -i 600</code><br />
:: for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)<br />
<br />
* Q: How to avoid update of a certain package?<br />
: A: Put package on hold ([http://debiananwenderhandbuch.de/dpkg.html] (German)):<br />
::<code>echo <packagename> "hold" | dpkg --set-selections</code><br />
<br />
* [[wikipedia:Raspcontrol]] with nginx<br />
** http://www.foxplex.com/sites/raspcontrol-webinterface-auf-dem-raspberry-pi/ (German), http://www.foxplex.com/sites/performanter-nginx-webserver-auf-dem-raspberry-pi-mit-php-und-apc/ (German)<br />
** http://menzerath.eu/artikel/raspberry-pi-raspcontrol-installation-funktionen/ (German)<br />
<br />
* Q: How many bytes are written to my (SD) disc?<br />
: A: Use <code>iostat</code> http://www.mybinarylife.net/2012/08/linux-iostat-command.html<br />
: A: Use <code>iotop</code> http://guichaz.free.fr/iotop/<br />
: A: Raw data of the kernel can be found in files <code>/proc/diskstats</code> and <code>/sys/block/DEVNAME/stat</code> https://www.kernel.org/doc/Documentation/iostats.txt<br />
:* http://unix.stackexchange.com/questions/86391/how-to-get-total-number-of-bytes-sectors-blocks-written-to-disk-since-booting<br />
:* http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux<br />
<br />
* Q: How to reduce number of ext-fs checks?<br />
: A: <code>tune2fs -c 60 /dev/sda1</code> Change maximum mount count to 60<br />
: A: <code>tune2fs -i 12m /dev/sda1</code> Change check interval to 12 months<br />
: fore more details: http://wiki.ubuntuusers.de/Dateisystemcheck (German)<br />
<br />
* Q: Fix smsc95xx 1-1.1:1.0: eth0: kevent 2 may have been dropped <br />
: A: http://wood1978.techarea.org/~wood/wordpress/2013/04/03/fix-smsc95xx-1-1-11-0-eth0-kevent-2-may-have-been-dropped-on-raspberry-pi-with-arch-linux<br />
::Modifying the sysctl.conf values reduced the kevent-2 messages; I did not yet set smsc95xx.turbo_mode=N<br />
<br />
===Overclocking===<br />
<br />
* I only set overclocking via <code>raspi-config</code><br />
<br />
* ''Turbo'': (Short) Raspberry stress test were ok. But I got an SD card error/corruption when doing a download and a dd-image of the SD card (according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907 the SD card error could be OC related.)<br />
::Luckily, I could recover all my data, see below.<br />
<br />
* '' Medium'': Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907] and its links).<br />
<br />
* Underclocking to 600 MHz<br />
:<code>echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</code><br />
: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.<br />
<br />
* Adjusting the ondemand-governor<br />
** https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt<br />
** set <code>/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor</code> to 10 [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&start=800]<br />
**: I had hoped this reduces the 1-wire CRC errors/device-disconnects problems, but with heavy (IO-) load (e.g. backup), 1wire sensors still get disconnected.<br />
<br />
* [http://moze.free.fr/blog/index.php?post/2013/02/Underclock-and-Overclock Nice power consumption analysis]<br />
<br />
====Stress test and benchmarks====<br />
<br />
* [http://www.roylongbottom.org.uk/ Roy Longbottom's PC Benchmark Collection]<br />
* [http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm Raspberry Pi Stress Tests]<br />
<br />
===SD card issues===<br />
<br />
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). I could still use this card for some time (see below), but finally I got a corrupted file system and could no longer repair it. That's when I re-installed Raspbian on a new SD card.<br />
<br />
Maybe I should try [http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ running from USB] sometime?<br />
<br />
====Recovery====<br />
* Creating a binary image of the SD card with my PC using [http://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] resulted in IO errors at about 17%.<br />
* 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 <code>dd conv=sync,noerror if=/dev/sdb2 of=rasp-image.img bs=1M</code> on my Linux machine (option <code>conv=noerror</code> ignores any errors, sync pads read-errors with zeros). The resulting image could not be mounted using a loop device. <br />
* Fortunately, <code>fsck.ext4 raspberry-image.bin</code> was able to repair the image, which I then could successfully mount on my Linux machine using <code>mount -o loop rasp-image.img /mnt</code>, and at a first glance, everything looked ok. So, I was at least able to get to my data. <br />
* On a later 'event', I dd-ed the repaired image back to the Raspberry, and could boot again.<br />
* On another a later 'event', I just fsck-ed the /dev/sdb2 using Linux, and could boot again... but I did not have luck this time - some files were gone.<br />
* 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.<br />
* My Raspberry successfully booted from this new image. I then used <code>raspi-config</code> to expand the root-fs (I've done this on my first installation as well). With Linux I was able to <code>dd</code> my repaired image to the repaired SD. The card booted as if nothing had happened...<br />
* But after some weeks, my Raspberry fried the SD card again, and some weeks later again ... And finally I could not get my pi to boot with this card. However, I can still read the data linux. Moving data to a new card... (easier said than done if the new card is slightly smaller... but, see below for resizing... and sometimes a fresh install is even less painful).<br />
<br />
===Reminders: dd, dd_rescue, losetup, mount and others===<br />
* Example partition table printed by fdisk:<br />
<code><br />
/dev/sdb: 7861 MB, 7861174272 bytes, 15353856 sectors<br />
Units = Sektoren of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
<br />
Gerät boot. Anfang Ende Blöcke Id System<br />
[...]<br />
/dev/sdb3 15288320 15353855 32768 83 Linux</code><br />
:Byte-offset of sdb3: 7827619840 = 15288320 * 512<br />
<br />
* Mount partition to /dev/loopN partition for repair, etc.<br />
:<code>losetup -o 7827619840 --find --show /dev/sdb</code><br />
:--show prints the used /dev/loopN device<br />
<br />
* Directly mount partition using loop device:<br />
:<code>mount -o loop,offset=7827619840 /dev/sdb /mnt</code><br />
* http://www.garloff.de/kurt/linux/ddrescue/<br />
* http://softwarebakery.com/shrinking-images-on-linux<br />
* http://www.tehfear.com/2007/10/08/resize-loop-disk-image/<br />
* http://wiki.ubuntuusers.de/dd (German)<br />
* http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device<br />
<br />
===Some 1-Wire Stuff===<br />
<br />
====Temperature Sensor DS1820====<br />
<br />
* How to?<br />
** http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/<br />
** https://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&start=1 (German)<br />
** http://kopfkino.irosaurus.com/tutorial-ds18s20-temperatur-sensor-an-einem-raspberry-pi/ (German)<br />
** http://raspberrywebserver.com/cgiscripting/rpi-temperature-logger/<br />
** http://elinux.org/RPi_Low-level_peripherals<br />
** http://www.sdyoung.com/home/using-1-wire-ds18b20par-sensors-in-parasitic-mode-on-raspi-with-custom-gpio-pin/ (German)<br />
* I have two DS18B20 and log temperatures using rrdtool.<br />
<br />
* 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). <br />
** Q: Is this due to overclocking with using dynamic governor?<br />
** A: No - also occurs without overclocking (but less frequent?)<br />
** Q: Or is this due to voltage-problems?<br />
** A: No - also occurs without over-voltage<br />
** Q: Or something else?<br />
** 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). Using 3 sensors works almost all the time (without overclocking), but using 4 or more sensors (2 connected star topologies, very bad for 1-wire [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]), almost always fails to read values on most of the sensors.<br />
** A:'''Implement multiple 1-wire interfaces''' (see below), using 1 for each star-topology solved the problem. Reading 2x3 works perfect!<br />
** A: If not adding new devices, disabling 1-wire search after module-loading resolves the device-disconnect issue. Simply put<br />
::<code>wire search_count=5</code><br />
:: in your <code>/etc/modules</code> (I'm not using DTB) to allow only 5 (initial) searches.<br />
<br />
====Multiple 1-wire buses====<br />
:* [https://www.raspberrypi.org/forums/viewtopic.php?t=156734 multiple w1 buses with device trees]:<br />
Add the following to /boot/config.txt:<br />
<br />
dtoverlay=w1-gpio,gpiopin=4<br />
dtoverlay=w1-gpio,gpiopin=22<br />
<br />
:* OBSOLETE! Inspired and guided by http://www.raspberrypi.org/forums/viewtopic.php?p=513312#p513312, I've patched my 3.12.y kernel <code>arch/arm/mach-bcm2708/bcm2708.c</code> (patch file http://holyhead.de/RaspberryPi/bcm2708-multiple_w-1.patch-3.12.21.txt). Applying this patch to newer kernel versions is straight forward. (Currently I'm running 4.1.10 without device tree.)<br />
::* Note: Some kernel versions ago, device trees were introduced for Raspbian, see for example http://www.raspberrypi.org/documentation/configuration/device-tree.md<BR>So far, I don't know if this works with device trees.<br />
:* OBSOLETE! I've cross-compiled the kernel on a linux-VM, using the instructions of http://elinux.org/RPi_Kernel_Compilation (compiling on the RaspberryPi takes 6 hours [http://wiki.gentoo.org/wiki/Raspberry_Pi_Kernel_Compilation] or much more [http://elinux.org/RPi_Kernel_Compilation]).<br />
<br />
====Some 1-wire internals====<br />
* https://www.kernel.org/doc/Documentation/w1/w1.generic<br />
* [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]<br />
* http://blog.gegg.us/2013/03/4-different-methods-of-1-wire-access-on-raspberry-pi/<br />
<br />
===Compiling own kernel===<br />
<br />
* Some hints on cross-compiling:<br />
:* http://elinux.org/RPi_Kernel_Compilation<br />
:* https://github.com/raspberrypi/linux/tree/rpi-3.12.y/arch/arm/mach-bcm2708<br />
:* https://github.com/notro/rpi-source/wiki<br />
:* https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489&start=75<br />
:* http://www.bootc.net/projects/raspberry-pi-kernel/<br />
:* http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-recompile.html<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-cross-compile.html<br />
:* http://www.gtkdb.de/index_36_2087.html<br />
<br />
* extract kernel config from image:<br />
::<code>scripts/extract-ikconfig kernel-image</code><br />
::*(extract-ikconfig is part of the kernel sources)<br />
::*newer kernels may store their config in a module: modules/4.*/kernel/kernel/configs.ko<br />
<br />
===Device Trees===<br />
<br />
:* http://www.raspberrypi.org/documentation/configuration/device-tree.md<br />
:* https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt<br />
<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=97216<br />
:* http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f<br />
:* http://www.forum-raspberrypi.de/Thread-tutorial-geraetetreiber-und-device-tree-dt (German)<br />
<br />
:* http://xillybus.com/tutorials/device-tree-zynq-1<br />
<br />
===What about updates?===<br />
<br />
As I always forget this<br />
* <code>apt-get update</code> - update package lists<br />
* <code>apt-get upgrade</code> - upgrade installed packages<br />
* <code>rpi-update</code> - update kernel and modules<br />
::use <code>SKIP_KERNEL=1 rpi-update</code> to update the RPi firmware, but keep the current kernel<br />
::set <code>SKIP_REPODELETE=1</code> to keep downloaded files (by default: <code>/root/.rpi-firmware</code>)<br />
<br />
Kernel Sources<br />
* https://github.com/notro/rpi-source gets the source data from https://github.com/Hexxeh/rpi-firmware and https://github.com/raspberrypi/linux/<br />
<br />
===Hints for reading Kernel Panics===<br />
<br />
* http://ptgmedia.pearsoncmg.com/images/013147751X/downloads/013147751X_book.pdf<br />
: p290:<br />
export CONFIG_DEBUG_INFO=1<br />
make kernel/sysctl.o<br />
objdump -d -S kernel/sysctl.o > kernel/sysctl.dump<br />
<br />
or, with my in cross-compiling setup:<br />
<br />
DOMAKE drivers/w1/slave/w1_therm.o<br />
${CCPREFIX}objdump -d -S w1_therm.o <br />
<br />
* http://www.opensourceforu.com/2011/01/understanding-a-kernel-oops/<br />
<br />
* http://www.lowlevel.eu/wiki/ARM-OS-Dev_Teil_2_%E2%80%93_Assembler_101<br />
<br />
==Attaching a LCD display (HD44780 controller)==<br />
<br />
===Wiring and Specs===<br />
<br />
* Specs<br />
** ftp://imall.iteadstudio.com/IM120424018_EONE_2004_Characters_LCD/SPE_IM120424018_EONE_2004_Characters_LCD.pdf<br />
** http://www.adafruit.com/datasheets/HD44780.pdf<br />
<br />
* http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display (German)<br />
<br />
* http://www.pro-linux.de/artikel/2/1624/5,die-anzeige-hardware-und-software.html<br />
<br />
* https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring<br />
<br />
* https://github.com/perryflynn/raspberrypi-misc/tree/master/charlcd_4x20_cmd<br />
<br />
* http://obrazki.elektroda.pl/5028699400_1384164963.jpg<br />
<br />
===Misc===<br />
<br />
* http://www.makerspaceuk.com/lcd-temp-sensor/<br />
<br />
* http://anwendungsentwickler.ws/blog/kategorien/raspberry-pi/4x20-lcd-screen-mit-dem-raspberry-pi.html (German)<br />
<br />
==Controlling the display==<br />
<br />
* Python [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO]<br />
<br />
===LCDProc hints===<br />
<br />
* Pi & GPIO powered HD44780 LCD: http://www.boeeerb.co.uk/pi-lcd/<br />
<br />
* https://metacpan.org/pod/Net::LCDproc<br />
<br />
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=63412<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-user.html<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-dev.html<br />
<br />
* http://tuxgraphics.org/electronics/200504/article375.shtml<br />
<br />
==Todo and Miscellaneous==<br />
<br />
===OpenELEC===<br />
<br />
* http://wiki.openelec.tv/index.php/Guide_to_add_your_own_remote<br />
<br />
===Lirc===<br />
* http://powerpi.de/jede-infrarot-fernbedienung-am-raspberry-pi-2-nutzen-so-installierst-du-guenstig-einen-ir-empfaenger-teil-1/ (German)<br />
<br />
===Backports===<br />
<br />
* https://gist.github.com/martijnvermaat/7864115<br />
* http://superuser.com/questions/644586/how-to-upgrade-to-latest-git-on-debian-7<br />
<br />
===Collection of misc stuff to check - things I might) try sometime===<br />
<br />
* http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/<br />
<br />
* [http://en.wikipedia.org/wiki/F2FS f2fs]<br />
:* [http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=65330 F2fs, Ext4, FAT USB Benchmark]<br />
:* [http://forum.xda-developers.com/showthread.php?t=2697069 File System Performance: F2FS vs EXT4]<br />
<br />
* https://github.com/yuraa/Raspberry-Pi-Heartbeat<br />
<br />
* http://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html<br />
<br />
* [http://www.raspberrypi.org/archives/5282 Mathematica on Raspberry Pi, for free]<br />
:* also works in RasPi emulator, e.g. http://www.heise.de/ct/inhalt/2014/7/160/ (German, teaser to article)<br />
<br />
* NAS/Samba<br />
:* 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:<br />
:<code>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536</code><br />
<br />
* http://linuxtortures.blogspot.fr/2012/06/cross-compiling-and-cross-debugging-c.html<br />
<br />
===Things done===<br />
<br />
* Adjust swap file (size, location -> (ext4) HDD - too slow?): http://manpages.ubuntu.com/manpages/hardy/man8/dphys-swapfile.8.html<br />
<br />
* http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/<br />
* https://wiki.archlinux.org/index.php/SSMTP<br />
<br />
==Some links (aka bookmark lists)==<br />
<br />
Project sites<br />
<br />
* [http://www.cl.cam.ac.uk/projects/raspberrypi/ University of Cambridge / Raspberry Pi Computer Laboratory]<br />
* [https://www.raspiprojekt.de/ raspiprojek] (German)<br />
* http://www.vanheusden.com/misc/rpi.php<br />
<br />
Blogs, forums, etc<br />
* http://www.raspberrypi.org/phpBB3/<br />
* [http://forum.stmlabs.com/forumdisplay.php?fid=6 Stm Labs Forum / Raspbmc]<br />
* [http://www.welzels.de/blog/projekte/raspberry-pi/ Wel!s Blog] (German)<br />
* [http://jankarres.de/category/raspberry-pi/ Raspberry Pi Blog of Jan Karres] (German)<br />
* http://www.forum-raspberrypi.de/ /(German)<br />
* http://raspberrycenter.de/ (German)<br />
* http://archlinuxarm.org/forum/viewforum.php?f=31&sid=57987232ca9177c35eb3ef7fdf6b3341<br />
<br />
* [[wikipedia:Raspberry_Pi Raspberry Pi in Wikipedia]]<br />
<br />
Miscellaneous<br />
<br />
* [http://www.raspberrypi.org/downloads New Out Of Box Software (Recommended)]<br />
* [http://elinux.org/R-Pi_Hub R-Pi_Hub]<br />
* [https://github.com/prasmussen/gdrive Google Drive CLI]<br />
<br />
Manuals<br />
<br />
* https://github.com/raspberrypi/documentation<br />
<br />
* [http://debian-handbook.info/browse/stable/ The Debian Administrator's Handbook]</div>Holyheadhttps://holyhead.de/index.php?title=Raspberry_PiRaspberry Pi2020-02-20T12:51:48Z<p>Holyhead: /* Multiple 1-wire buses */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
===External USB drives===<br />
<br />
* Automount USB-Drives in Raspbian<br />
** One may use [http://selfprogramming.bplaced.net/index.php/2012/10/23/automount-usb-drives-in-raspbian/ USBmount and autofs]<br />
** I prefer [http://ignorantguru.github.io/udevil/ udevil], see below<br />
<br />
* Install ''ntfs-3g'' if you need write access to ntfs file systems<br />
<br />
* How to increase performance?<br />
** Mount with option ''''noatime'''' or ''''relatime''''<br />
** Mount ''without'' option sync (e.g. keep default async)<br />
** If using ntfs-3g (fuse) file system, try mounting with option 'big_writes', see for example http://obihoernchen.net/wordpress/tag/big_writes/<br />
<br />
===[http://ignorantguru.github.io/udevil/ udevil]===<br />
<br />
* example for manual mounting:<br />
<br />
udevil mount /dev/sda1<br />
<br />
* auto-mounting via udev-rule, see for example http://lsdlinux.org/wiki/doku.php?id=auto_mounting#using_udev_rule (I just copied the 95-udevil-mount.rules file from an OpenElec installation (http://www.raspberrypi.org/downloads) )<br />
<br />
* my build-steps (maybe there's a simpler way, but this worked...):<br />
** download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget<br />
** extract deb-package via <code>ar vx udevil_0.4.3-1_all.deb</code><br />
** extract data archive <code>tar xzvf data.tar.gz</code><br />
** change to tar usr/share/devil/src<br />
** untar <code>tar xvfJ udevil-current.tar.xz</code><br />
** <code>cd udevil-0.4.3</code><br />
** <code>mv distros/debian</code><br />
** execute <code>dpkg-buildpackage</code><br />
** 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<br />
** Install via <code>sudo dpkg -i udevil_0.4.3-1_armhf.deb</code><br />
<br />
===Samba server / NAS===<br />
<br />
* How to install?<br />
** [http://jankarres.de/2013/11/raspberry-pi-samba-server-installieren/ | Raspberry Pi: Samba Server installieren] (German)<br />
** [http://www.welzels.de/blog/projekte/raspberry-pi/low-budget-nas-mit-einem-raspberry-pi/ Low Budget NAS mit einem Raspberry PI] (German)<br />
<br />
* Slow disc performance?<br />
** see 'Slow USB drives' above<br />
** 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!)<br />
<br />
* Configuration and tuning<br />
** https://calomel.org/samba.html<br />
** https://calomel.org/samba_optimize.html<br />
<br />
* If your /var/log/samba/log.smbd fills up with ''printing/print_cups.c:110(cups_connect) Unable to connect to CUPS server localhost'' messages, try http://www.sotechdesign.com.au/samba-log-showing-error-failed-to-retrieve-printer-list/<br/>I also created an empty <code>/etc/printcap</code> to avoid ''Unable to open printcap file /etc/printcap for read'' messages.<br />
<br />
* I don't need sound:<br />
<br />
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf <br />
# I don't need sound<br />
blacklist snd<br />
blacklist snd_pcm<br />
blacklist snd_soc_core<br />
blacklist snd_soc_bcm2708_i2s<br />
<br />
===Trying to reduce number of disk writes (SD card)===<br />
<br />
I'm using [http://oss.oetiker.ch/rrdtool/ 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).<br />
<br />
Here's what I've done:<br />
<br />
* Edit <code>/etc/default/cron</code> and set <code>EXTRA_OPTS="-L 0"</code> to disable logging (I don't need these)<br />
* Avoid entries like <code>pam_unix(cron:session): session closed for user pi</code> in <code>/var/log/auth.log</code><br />
** Edit <code>/etc/pam.d/cron</code> and comment the line <code>@include common-session-noninteractive</code> ([http://ubuntuforums.org/showthread.php?t=1256801])<br />
:or<br />
:* Edit <code>/etc/pam.d/common-session-noninteractive</code> as shown here: http://ubuntuforums.org/showthread.php?t=1256801&p=10283830#post10283830<br />
* I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)<br />
** moved all the .rrd files as well as the created images to my persistent-ramdisk location<br />
** moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links<br />
*** <code>/var/spool</code><br />
*** <code>/var/log</code><br />
*** <code>/var/cache/samba</code><br />
** edited <code>/etc/insserv.conf</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:<br />
<br />
$local_fs_orig +mountall +mountall-bootclean +mountoverflowtmp +umountfs<br />
# we need the sym-link data in /var/log and /var/spool to be available<br />
$local_fs $local_fs_orig +persist-ramdisk<br />
<br />
:: <code>/etc/init.d/persist-ramdisk</code> 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.<br />
<br />
:* set ''RAMTMP'' to yes in <code>/etc/default/tmpfs</code> to get tempfs based <code>/tmp</code><br />
<br />
Before changing <code>/tmp</code>:<br />
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').<br />
::I need to do more digging...<br />
<br />
After changing <code>/tmp</code>:<br />
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...<br />
<br />
===Useful stuff and Q&A===<br />
<br />
* Q: Why does my Pi restart when hotplugging a USB drive?<br />
** http://thestuffsido.blogspot.de/2013/05/fixing-raspberry-pi-hotplugging.html<br />
** http://therandomlab.blogspot.de/2013/01/raspberry-pi-mod-to-avoid-shutdown-on.html<br />
<br />
* Q: Does Raspberry support WOL?<br />
: A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)<br />
<br />
* Q: The new password is to short, or too simple<br />
: A: Try adjusting the PAM settings in <code>/etc/pam.d/common-password</code>:<br />
:* remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)<br />
::<code>password [success=1 default=ignore] pam_unix.so sha512 minlen=2</code><br />
<br />
::!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!<br><br />
::But it's nice for testing (if you cannot or do not want to use auto-login.)<br />
<br />
* Q: How to configure static IP?<br />
: A: In /etc/network/interfaces:<br />
::<code>iface eth0 inet static<br>address 192.168.0.31<br>netmask 255.255.255.0<br>gateway 192.168.0.1</code><br />
<br />
* Q: How to read core temperature, etc?<br />
: A: [http://elinux.org/RPI_vcgencmd_usage vcgencmd]:<br />
::<code>vcgencmd measure_temp<br>vcgencmd measure_clock arm</code><br />
<br />
* External USB HDD spin down<br />
** hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)<br />
** hd-idle works:<br />
::<code>hd-idle -a sda -i 600</code><br />
:: for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)<br />
<br />
* Q: How to avoid update of a certain package?<br />
: A: Put package on hold ([http://debiananwenderhandbuch.de/dpkg.html] (German)):<br />
::<code>echo <packagename> "hold" | dpkg --set-selections</code><br />
<br />
* [[wikipedia:Raspcontrol]] with nginx<br />
** http://www.foxplex.com/sites/raspcontrol-webinterface-auf-dem-raspberry-pi/ (German), http://www.foxplex.com/sites/performanter-nginx-webserver-auf-dem-raspberry-pi-mit-php-und-apc/ (German)<br />
** http://menzerath.eu/artikel/raspberry-pi-raspcontrol-installation-funktionen/ (German)<br />
<br />
* Q: How many bytes are written to my (SD) disc?<br />
: A: Use <code>iostat</code> http://www.mybinarylife.net/2012/08/linux-iostat-command.html<br />
: A: Use <code>iotop</code> http://guichaz.free.fr/iotop/<br />
: A: Raw data of the kernel can be found in files <code>/proc/diskstats</code> and <code>/sys/block/DEVNAME/stat</code> https://www.kernel.org/doc/Documentation/iostats.txt<br />
:* http://unix.stackexchange.com/questions/86391/how-to-get-total-number-of-bytes-sectors-blocks-written-to-disk-since-booting<br />
:* http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux<br />
<br />
* Q: How to reduce number of ext-fs checks?<br />
: A: <code>tune2fs -c 60 /dev/sda1</code> Change maximum mount count to 60<br />
: A: <code>tune2fs -i 12m /dev/sda1</code> Change check interval to 12 months<br />
: fore more details: http://wiki.ubuntuusers.de/Dateisystemcheck (German)<br />
<br />
* Q: Fix smsc95xx 1-1.1:1.0: eth0: kevent 2 may have been dropped <br />
: A: http://wood1978.techarea.org/~wood/wordpress/2013/04/03/fix-smsc95xx-1-1-11-0-eth0-kevent-2-may-have-been-dropped-on-raspberry-pi-with-arch-linux<br />
::Modifying the sysctl.conf values reduced the kevent-2 messages; I did not yet set smsc95xx.turbo_mode=N<br />
<br />
===Overclocking===<br />
<br />
* I only set overclocking via <code>raspi-config</code><br />
<br />
* ''Turbo'': (Short) Raspberry stress test were ok. But I got an SD card error/corruption when doing a download and a dd-image of the SD card (according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907 the SD card error could be OC related.)<br />
::Luckily, I could recover all my data, see below.<br />
<br />
* '' Medium'': Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907] and its links).<br />
<br />
* Underclocking to 600 MHz<br />
:<code>echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</code><br />
: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.<br />
<br />
* Adjusting the ondemand-governor<br />
** https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt<br />
** set <code>/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor</code> to 10 [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&start=800]<br />
**: I had hoped this reduces the 1-wire CRC errors/device-disconnects problems, but with heavy (IO-) load (e.g. backup), 1wire sensors still get disconnected.<br />
<br />
* [http://moze.free.fr/blog/index.php?post/2013/02/Underclock-and-Overclock Nice power consumption analysis]<br />
<br />
====Stress test and benchmarks====<br />
<br />
* [http://www.roylongbottom.org.uk/ Roy Longbottom's PC Benchmark Collection]<br />
* [http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm Raspberry Pi Stress Tests]<br />
<br />
===SD card issues===<br />
<br />
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). I could still use this card for some time (see below), but finally I got a corrupted file system and could no longer repair it. That's when I re-installed Raspbian on a new SD card.<br />
<br />
Maybe I should try [http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ running from USB] sometime?<br />
<br />
====Recovery====<br />
* Creating a binary image of the SD card with my PC using [http://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] resulted in IO errors at about 17%.<br />
* 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 <code>dd conv=sync,noerror if=/dev/sdb2 of=rasp-image.img bs=1M</code> on my Linux machine (option <code>conv=noerror</code> ignores any errors, sync pads read-errors with zeros). The resulting image could not be mounted using a loop device. <br />
* Fortunately, <code>fsck.ext4 raspberry-image.bin</code> was able to repair the image, which I then could successfully mount on my Linux machine using <code>mount -o loop rasp-image.img /mnt</code>, and at a first glance, everything looked ok. So, I was at least able to get to my data. <br />
* On a later 'event', I dd-ed the repaired image back to the Raspberry, and could boot again.<br />
* On another a later 'event', I just fsck-ed the /dev/sdb2 using Linux, and could boot again... but I did not have luck this time - some files were gone.<br />
* 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.<br />
* My Raspberry successfully booted from this new image. I then used <code>raspi-config</code> to expand the root-fs (I've done this on my first installation as well). With Linux I was able to <code>dd</code> my repaired image to the repaired SD. The card booted as if nothing had happened...<br />
* But after some weeks, my Raspberry fried the SD card again, and some weeks later again ... And finally I could not get my pi to boot with this card. However, I can still read the data linux. Moving data to a new card... (easier said than done if the new card is slightly smaller... but, see below for resizing... and sometimes a fresh install is even less painful).<br />
<br />
===Reminders: dd, dd_rescue, losetup, mount and others===<br />
* Example partition table printed by fdisk:<br />
<code><br />
/dev/sdb: 7861 MB, 7861174272 bytes, 15353856 sectors<br />
Units = Sektoren of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
<br />
Gerät boot. Anfang Ende Blöcke Id System<br />
[...]<br />
/dev/sdb3 15288320 15353855 32768 83 Linux</code><br />
:Byte-offset of sdb3: 7827619840 = 15288320 * 512<br />
<br />
* Mount partition to /dev/loopN partition for repair, etc.<br />
:<code>losetup -o 7827619840 --find --show /dev/sdb</code><br />
:--show prints the used /dev/loopN device<br />
<br />
* Directly mount partition using loop device:<br />
:<code>mount -o loop,offset=7827619840 /dev/sdb /mnt</code><br />
* http://www.garloff.de/kurt/linux/ddrescue/<br />
* http://softwarebakery.com/shrinking-images-on-linux<br />
* http://www.tehfear.com/2007/10/08/resize-loop-disk-image/<br />
* http://wiki.ubuntuusers.de/dd (German)<br />
* http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device<br />
<br />
===Some 1-Wire Stuff===<br />
<br />
====Temperature Sensor DS1820====<br />
<br />
* How to?<br />
** http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/<br />
** https://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&start=1 (German)<br />
** http://kopfkino.irosaurus.com/tutorial-ds18s20-temperatur-sensor-an-einem-raspberry-pi/ (German)<br />
** http://raspberrywebserver.com/cgiscripting/rpi-temperature-logger/<br />
** http://elinux.org/RPi_Low-level_peripherals<br />
** http://www.sdyoung.com/home/using-1-wire-ds18b20par-sensors-in-parasitic-mode-on-raspi-with-custom-gpio-pin/ (German)<br />
* I have two DS18B20 and log temperatures using rrdtool.<br />
<br />
* 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). <br />
** Q: Is this due to overclocking with using dynamic governor?<br />
** A: No - also occurs without overclocking (but less frequent?)<br />
** Q: Or is this due to voltage-problems?<br />
** A: No - also occurs without over-voltage<br />
** Q: Or something else?<br />
** 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). Using 3 sensors works almost all the time (without overclocking), but using 4 or more sensors (2 connected star topologies, very bad for 1-wire [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]), almost always fails to read values on most of the sensors.<br />
** A:'''Implement multiple 1-wire interfaces''' (see below), using 1 for each star-topology solved the problem. Reading 2x3 works perfect!<br />
** A: If not adding new devices, disabling 1-wire search after module-loading resolves the device-disconnect issue. Simply put<br />
::<code>wire search_count=5</code><br />
:: in your <code>/etc/modules</code> (I'm not using DTB) to allow only 5 (initial) searches.<br />
<br />
====Multiple 1-wire buses====<br />
:* Inspired and guided by http://www.raspberrypi.org/forums/viewtopic.php?p=513312#p513312, I've patched my 3.12.y kernel <code>arch/arm/mach-bcm2708/bcm2708.c</code> (patch file http://holyhead.de/RaspberryPi/bcm2708-multiple_w-1.patch-3.12.21.txt). Applying this patch to newer kernel versions is straight forward. (Currently I'm running 4.1.10 without device tree.)<br />
::* Note: Some kernel versions ago, device trees were introduced for Raspbian, see for example http://www.raspberrypi.org/documentation/configuration/device-tree.md<BR>So far, I don't know if this works with device trees.<br />
:* I've cross-compiled the kernel on a linux-VM, using the instructions of http://elinux.org/RPi_Kernel_Compilation (compiling on the RaspberryPi takes 6 hours [http://wiki.gentoo.org/wiki/Raspberry_Pi_Kernel_Compilation] or much more [http://elinux.org/RPi_Kernel_Compilation]).<br />
:* [https://www.raspberrypi.org/forums/viewtopic.php?t=156734 multiple w1 buses with device trees]:<br />
Add the following to /boot/config.txt:<br />
<br />
dtoverlay=w1-gpio,gpiopin=4<br />
dtoverlay=w1-gpio,gpiopin=22<br />
<br />
====Some 1-wire internals====<br />
* https://www.kernel.org/doc/Documentation/w1/w1.generic<br />
* [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]<br />
* http://blog.gegg.us/2013/03/4-different-methods-of-1-wire-access-on-raspberry-pi/<br />
<br />
===Compiling own kernel===<br />
<br />
* Some hints on cross-compiling:<br />
:* http://elinux.org/RPi_Kernel_Compilation<br />
:* https://github.com/raspberrypi/linux/tree/rpi-3.12.y/arch/arm/mach-bcm2708<br />
:* https://github.com/notro/rpi-source/wiki<br />
:* https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489&start=75<br />
:* http://www.bootc.net/projects/raspberry-pi-kernel/<br />
:* http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-recompile.html<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-cross-compile.html<br />
:* http://www.gtkdb.de/index_36_2087.html<br />
<br />
* extract kernel config from image:<br />
::<code>scripts/extract-ikconfig kernel-image</code><br />
::*(extract-ikconfig is part of the kernel sources)<br />
::*newer kernels may store their config in a module: modules/4.*/kernel/kernel/configs.ko<br />
<br />
===Device Trees===<br />
<br />
:* http://www.raspberrypi.org/documentation/configuration/device-tree.md<br />
:* https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt<br />
<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=97216<br />
:* http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f<br />
:* http://www.forum-raspberrypi.de/Thread-tutorial-geraetetreiber-und-device-tree-dt (German)<br />
<br />
:* http://xillybus.com/tutorials/device-tree-zynq-1<br />
<br />
===What about updates?===<br />
<br />
As I always forget this<br />
* <code>apt-get update</code> - update package lists<br />
* <code>apt-get upgrade</code> - upgrade installed packages<br />
* <code>rpi-update</code> - update kernel and modules<br />
::use <code>SKIP_KERNEL=1 rpi-update</code> to update the RPi firmware, but keep the current kernel<br />
::set <code>SKIP_REPODELETE=1</code> to keep downloaded files (by default: <code>/root/.rpi-firmware</code>)<br />
<br />
Kernel Sources<br />
* https://github.com/notro/rpi-source gets the source data from https://github.com/Hexxeh/rpi-firmware and https://github.com/raspberrypi/linux/<br />
<br />
===Hints for reading Kernel Panics===<br />
<br />
* http://ptgmedia.pearsoncmg.com/images/013147751X/downloads/013147751X_book.pdf<br />
: p290:<br />
export CONFIG_DEBUG_INFO=1<br />
make kernel/sysctl.o<br />
objdump -d -S kernel/sysctl.o > kernel/sysctl.dump<br />
<br />
or, with my in cross-compiling setup:<br />
<br />
DOMAKE drivers/w1/slave/w1_therm.o<br />
${CCPREFIX}objdump -d -S w1_therm.o <br />
<br />
* http://www.opensourceforu.com/2011/01/understanding-a-kernel-oops/<br />
<br />
* http://www.lowlevel.eu/wiki/ARM-OS-Dev_Teil_2_%E2%80%93_Assembler_101<br />
<br />
==Attaching a LCD display (HD44780 controller)==<br />
<br />
===Wiring and Specs===<br />
<br />
* Specs<br />
** ftp://imall.iteadstudio.com/IM120424018_EONE_2004_Characters_LCD/SPE_IM120424018_EONE_2004_Characters_LCD.pdf<br />
** http://www.adafruit.com/datasheets/HD44780.pdf<br />
<br />
* http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display (German)<br />
<br />
* http://www.pro-linux.de/artikel/2/1624/5,die-anzeige-hardware-und-software.html<br />
<br />
* https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring<br />
<br />
* https://github.com/perryflynn/raspberrypi-misc/tree/master/charlcd_4x20_cmd<br />
<br />
* http://obrazki.elektroda.pl/5028699400_1384164963.jpg<br />
<br />
===Misc===<br />
<br />
* http://www.makerspaceuk.com/lcd-temp-sensor/<br />
<br />
* http://anwendungsentwickler.ws/blog/kategorien/raspberry-pi/4x20-lcd-screen-mit-dem-raspberry-pi.html (German)<br />
<br />
==Controlling the display==<br />
<br />
* Python [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO]<br />
<br />
===LCDProc hints===<br />
<br />
* Pi & GPIO powered HD44780 LCD: http://www.boeeerb.co.uk/pi-lcd/<br />
<br />
* https://metacpan.org/pod/Net::LCDproc<br />
<br />
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=63412<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-user.html<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-dev.html<br />
<br />
* http://tuxgraphics.org/electronics/200504/article375.shtml<br />
<br />
==Todo and Miscellaneous==<br />
<br />
===OpenELEC===<br />
<br />
* http://wiki.openelec.tv/index.php/Guide_to_add_your_own_remote<br />
<br />
===Lirc===<br />
* http://powerpi.de/jede-infrarot-fernbedienung-am-raspberry-pi-2-nutzen-so-installierst-du-guenstig-einen-ir-empfaenger-teil-1/ (German)<br />
<br />
===Backports===<br />
<br />
* https://gist.github.com/martijnvermaat/7864115<br />
* http://superuser.com/questions/644586/how-to-upgrade-to-latest-git-on-debian-7<br />
<br />
===Collection of misc stuff to check - things I might) try sometime===<br />
<br />
* http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/<br />
<br />
* [http://en.wikipedia.org/wiki/F2FS f2fs]<br />
:* [http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=65330 F2fs, Ext4, FAT USB Benchmark]<br />
:* [http://forum.xda-developers.com/showthread.php?t=2697069 File System Performance: F2FS vs EXT4]<br />
<br />
* https://github.com/yuraa/Raspberry-Pi-Heartbeat<br />
<br />
* http://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html<br />
<br />
* [http://www.raspberrypi.org/archives/5282 Mathematica on Raspberry Pi, for free]<br />
:* also works in RasPi emulator, e.g. http://www.heise.de/ct/inhalt/2014/7/160/ (German, teaser to article)<br />
<br />
* NAS/Samba<br />
:* 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:<br />
:<code>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536</code><br />
<br />
* http://linuxtortures.blogspot.fr/2012/06/cross-compiling-and-cross-debugging-c.html<br />
<br />
===Things done===<br />
<br />
* Adjust swap file (size, location -> (ext4) HDD - too slow?): http://manpages.ubuntu.com/manpages/hardy/man8/dphys-swapfile.8.html<br />
<br />
* http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/<br />
* https://wiki.archlinux.org/index.php/SSMTP<br />
<br />
==Some links (aka bookmark lists)==<br />
<br />
Project sites<br />
<br />
* [http://www.cl.cam.ac.uk/projects/raspberrypi/ University of Cambridge / Raspberry Pi Computer Laboratory]<br />
* [https://www.raspiprojekt.de/ raspiprojek] (German)<br />
* http://www.vanheusden.com/misc/rpi.php<br />
<br />
Blogs, forums, etc<br />
* http://www.raspberrypi.org/phpBB3/<br />
* [http://forum.stmlabs.com/forumdisplay.php?fid=6 Stm Labs Forum / Raspbmc]<br />
* [http://www.welzels.de/blog/projekte/raspberry-pi/ Wel!s Blog] (German)<br />
* [http://jankarres.de/category/raspberry-pi/ Raspberry Pi Blog of Jan Karres] (German)<br />
* http://www.forum-raspberrypi.de/ /(German)<br />
* http://raspberrycenter.de/ (German)<br />
* http://archlinuxarm.org/forum/viewforum.php?f=31&sid=57987232ca9177c35eb3ef7fdf6b3341<br />
<br />
* [[wikipedia:Raspberry_Pi Raspberry Pi in Wikipedia]]<br />
<br />
Miscellaneous<br />
<br />
* [http://www.raspberrypi.org/downloads New Out Of Box Software (Recommended)]<br />
* [http://elinux.org/R-Pi_Hub R-Pi_Hub]<br />
* [https://github.com/prasmussen/gdrive Google Drive CLI]<br />
<br />
Manuals<br />
<br />
* https://github.com/raspberrypi/documentation<br />
<br />
* [http://debian-handbook.info/browse/stable/ The Debian Administrator's Handbook]</div>Holyheadhttps://holyhead.de/index.php?title=QNAP_(431p)QNAP (431p)2018-05-02T23:51:49Z<p>Holyhead: /* Firmware downgrade */</p>
<hr />
<div>=Cookbook=<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others) - some links are in German, some in English<br />
<br />
== Entware ==<br />
<br />
* https://forum.qnapclub.de/thread/37886-howto-entware-ng-und-linux-pakete-installieren/?f=80&t=37886#p215810<br />
<br />
=== autorun ===<br />
<br />
* a manual autorun.sh should not be necessary - /etc/rcS.d/QS109Entware-ng should start Entware-ng, and /opt/etc/init.d/rc.unslung starts all /opt/etc/init.d/S* scripts<br />
<br />
* autorun.sh: based on http://www.welzels.de/blog/projekte/qnap-mods-tricks-und-projekte/optware-init-skripte-nach-booten-starten/<br />
* installation for my 431p: (copy from https://wiki.qnap.com/wiki/Running_Your_Own_Application_at_Startup)<br />
<br />
ubiattach -m 6 -d 2<br />
/bin/mount -t ubifs ubi2:config /tmp/config<br />
vi /tmp/config/autorun.sh<br />
chmod +x /tmp/config/autorun.sh<br />
echo .<br />
echo "unmounting /tmp/config..."<br />
umount /tmp/config<br />
ubidetach -m 6<br />
<br />
* enable auto-start (re-do after FW update): http://www.welzels.de/blog/projekte/qnap-mods-tricks-und-projekte/optware-init-skripte-nach-booten-starten/<br />
<br />
* manual start (if auto-start does not work):<br />
** SSH: /share/CACHEDEV1_DATA/.qpkg/Entware-ng/Entware-ng.sh start<br />
** Desktop: open Entware-ng App in QNAP<br />
<br />
== Raid sync speed ==<br />
<br />
https://forum.qnap.com/viewtopic.php?t=10268<br />
<br />
cat /proc/mdstat<br />
<br />
cat /proc/sys/dev/raid/speed_limit_max<br />
200000<br />
cat /proc/sys/dev/raid/speed_limit_min<br />
5000<br />
<br />
== HDD spin down issues ==<br />
<br />
* [https://www.qnap.com/en-us/qa/con_show.php?op=showone&cid=58 Why the hard drive of NAS does not go to standby mode?]<br />
<br />
* [https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=1 Probleme mit Festplatten-Standby]<br />
<br />
* Qnap QTS 4.3.3.0154 write to disk at least every ~30 minutes ( setcfg -> dirtied inode ... qid_persistent.conf) on md9 )<br />
: Qnap seems to known this problem - see https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=12<br />
<br />
=== Move Samba tdb_path to ramdisk ===<br />
<br />
(Permanently) move samba's tdb_path to ram disk -> avoid hdd spin up due to .tdb file update<br />
<br />
[/] # /sbin/setcfg "Samba" "tdb_path" "/" <br />
[/] # /etc/init.d/smb.sh restart <br />
Restarting SMB services:<br />
Shutting down SMB services: smbd nmbd.<br />
Shutting down winbindd services: winbindd.<br />
locks path was set to /share/CACHEDEV1_DATA/.locks<br />
Shutting down winbindd services: winbindd.<br />
Starting winbindd services:Starting SMB services:.<br />
done.<br />
[/] # la /.samba/<br />
drwxr-xr-x 5 admin administ 100 Mar 23 07:33 ./<br />
drwxr-xr-x 23 admin administ 520 Mar 23 07:33 ../<br />
drwxr-xr-x 3 admin administ 60 Mar 23 07:33 cache/<br />
drwxr-xr-x 2 admin administ 320 Mar 23 07:33 lock/<br />
drwxr-xr-x 2 admin administ 120 Mar 23 07:33 state/<br />
<br />
== Cron ==<br />
<br />
* https://www.techandme.se/qnap-and-cron/</div>Holyheadhttps://holyhead.de/index.php?title=QNAP_(431p)QNAP (431p)2017-05-04T00:41:10Z<p>Holyhead: /* autorun */</p>
<hr />
<div>=Cookbook=<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others) - some links are in German, some in English<br />
<br />
== Entware ==<br />
<br />
* https://forum.qnapclub.de/thread/37886-howto-entware-ng-und-linux-pakete-installieren/?f=80&t=37886#p215810<br />
<br />
=== autorun ===<br />
<br />
* a manual autorun.sh should not be necessary - /etc/rcS.d/QS109Entware-ng should start Entware-ng, and /opt/etc/init.d/rc.unslung starts all /opt/etc/init.d/S* scripts<br />
<br />
* autorun.sh: based on http://www.welzels.de/blog/projekte/qnap-mods-tricks-und-projekte/optware-init-skripte-nach-booten-starten/<br />
* installation for my 431p: (copy from https://wiki.qnap.com/wiki/Running_Your_Own_Application_at_Startup)<br />
<br />
ubiattach -m 6 -d 2<br />
/bin/mount -t ubifs ubi2:config /tmp/config<br />
vi /tmp/config/autorun.sh<br />
chmod +x /tmp/config/autorun.sh<br />
echo .<br />
echo "unmounting /tmp/config..."<br />
umount /tmp/config<br />
ubidetach -m 6<br />
<br />
* enable auto-start (re-do after FW update): http://www.welzels.de/blog/projekte/qnap-mods-tricks-und-projekte/optware-init-skripte-nach-booten-starten/<br />
<br />
* manual start (if auto-start does not work):<br />
** SSH: /share/CACHEDEV1_DATA/.qpkg/Entware-ng/Entware-ng.sh start<br />
** Desktop: open Entware-ng App in QNAP<br />
<br />
== Raid sync speed ==<br />
<br />
https://forum.qnap.com/viewtopic.php?t=10268<br />
<br />
cat /proc/mdstat<br />
<br />
cat /proc/sys/dev/raid/speed_limit_max<br />
200000<br />
cat /proc/sys/dev/raid/speed_limit_min<br />
5000<br />
<br />
== HDD spin down issues ==<br />
<br />
* [https://www.qnap.com/en-us/qa/con_show.php?op=showone&cid=58 Why the hard drive of NAS does not go to standby mode?]<br />
<br />
* [https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=1 Probleme mit Festplatten-Standby]<br />
<br />
* Qnap QTS 4.3.3.0154 write to disk at least every ~30 minutes ( setcfg -> dirtied inode ... qid_persistent.conf) on md9 )<br />
: Qnap seems to known this problem - see https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=12<br />
<br />
=== Move Samba tdb_path to ramdisk ===<br />
<br />
(Permanently) move samba's tdb_path to ram disk -> avoid hdd spin up due to .tdb file update<br />
<br />
[/] # /sbin/setcfg "Samba" "tdb_path" "/" <br />
[/] # /etc/init.d/smb.sh restart <br />
Restarting SMB services:<br />
Shutting down SMB services: smbd nmbd.<br />
Shutting down winbindd services: winbindd.<br />
locks path was set to /share/CACHEDEV1_DATA/.locks<br />
Shutting down winbindd services: winbindd.<br />
Starting winbindd services:Starting SMB services:.<br />
done.<br />
[/] # la /.samba/<br />
drwxr-xr-x 5 admin administ 100 Mar 23 07:33 ./<br />
drwxr-xr-x 23 admin administ 520 Mar 23 07:33 ../<br />
drwxr-xr-x 3 admin administ 60 Mar 23 07:33 cache/<br />
drwxr-xr-x 2 admin administ 320 Mar 23 07:33 lock/<br />
drwxr-xr-x 2 admin administ 120 Mar 23 07:33 state/<br />
<br />
== Cron ==<br />
<br />
* https://www.techandme.se/qnap-and-cron/<br />
<br />
== Firmware downgrade ==<br />
<br />
4.3.3 caused too many problems for me , so I downgraded to 4.2.5 (http://qnapsupport.net/qnap-firmware-downgrade/):<br />
* HDD did not spin down - at least not for long (setcfg wrote to disk every ~30 minutes)<br />
* LAN conenction frequently lost (less frequently after disabling cloudlink, but still happened...)</div>Holyheadhttps://holyhead.de/index.php?title=QNAP_(431p)QNAP (431p)2017-05-04T00:33:28Z<p>Holyhead: /* autorun */</p>
<hr />
<div>=Cookbook=<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others) - some links are in German, some in English<br />
<br />
== Entware ==<br />
<br />
* https://forum.qnapclub.de/thread/37886-howto-entware-ng-und-linux-pakete-installieren/?f=80&t=37886#p215810<br />
<br />
=== autorun ===<br />
<br />
* autorun.sh: based on http://www.welzels.de/blog/projekte/qnap-mods-tricks-und-projekte/optware-init-skripte-nach-booten-starten/<br />
* installation for my 431p: (copy from https://wiki.qnap.com/wiki/Running_Your_Own_Application_at_Startup)<br />
<br />
ubiattach -m 6 -d 2<br />
/bin/mount -t ubifs ubi2:config /tmp/config<br />
vi /tmp/config/autorun.sh<br />
chmod +x /tmp/config/autorun.sh<br />
echo .<br />
echo "unmounting /tmp/config..."<br />
umount /tmp/config<br />
ubidetach -m 6<br />
<br />
* enable auto-start (re-do after FW update): http://www.welzels.de/blog/projekte/qnap-mods-tricks-und-projekte/optware-init-skripte-nach-booten-starten/<br />
<br />
* manual start (if auto-start does not work):<br />
** SSH: /share/CACHEDEV1_DATA/.qpkg/Entware-ng/Entware-ng.sh start<br />
** Desktop: open Entware-ng App in QNAP<br />
<br />
== Raid sync speed ==<br />
<br />
https://forum.qnap.com/viewtopic.php?t=10268<br />
<br />
cat /proc/mdstat<br />
<br />
cat /proc/sys/dev/raid/speed_limit_max<br />
200000<br />
cat /proc/sys/dev/raid/speed_limit_min<br />
5000<br />
<br />
== HDD spin down issues ==<br />
<br />
* [https://www.qnap.com/en-us/qa/con_show.php?op=showone&cid=58 Why the hard drive of NAS does not go to standby mode?]<br />
<br />
* [https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=1 Probleme mit Festplatten-Standby]<br />
<br />
* Qnap QTS 4.3.3.0154 write to disk at least every ~30 minutes ( setcfg -> dirtied inode ... qid_persistent.conf) on md9 )<br />
: Qnap seems to known this problem - see https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=12<br />
<br />
=== Move Samba tdb_path to ramdisk ===<br />
<br />
(Permanently) move samba's tdb_path to ram disk -> avoid hdd spin up due to .tdb file update<br />
<br />
[/] # /sbin/setcfg "Samba" "tdb_path" "/" <br />
[/] # /etc/init.d/smb.sh restart <br />
Restarting SMB services:<br />
Shutting down SMB services: smbd nmbd.<br />
Shutting down winbindd services: winbindd.<br />
locks path was set to /share/CACHEDEV1_DATA/.locks<br />
Shutting down winbindd services: winbindd.<br />
Starting winbindd services:Starting SMB services:.<br />
done.<br />
[/] # la /.samba/<br />
drwxr-xr-x 5 admin administ 100 Mar 23 07:33 ./<br />
drwxr-xr-x 23 admin administ 520 Mar 23 07:33 ../<br />
drwxr-xr-x 3 admin administ 60 Mar 23 07:33 cache/<br />
drwxr-xr-x 2 admin administ 320 Mar 23 07:33 lock/<br />
drwxr-xr-x 2 admin administ 120 Mar 23 07:33 state/<br />
<br />
== Cron ==<br />
<br />
* https://www.techandme.se/qnap-and-cron/<br />
<br />
== Firmware downgrade ==<br />
<br />
4.3.3 caused too many problems for me , so I downgraded to 4.2.5 (http://qnapsupport.net/qnap-firmware-downgrade/):<br />
* HDD did not spin down - at least not for long (setcfg wrote to disk every ~30 minutes)<br />
* LAN conenction frequently lost (less frequently after disabling cloudlink, but still happened...)</div>Holyheadhttps://holyhead.de/index.php?title=QNAP_(431p)QNAP (431p)2017-05-04T00:30:14Z<p>Holyhead: /* autorun */</p>
<hr />
<div>=Cookbook=<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others) - some links are in German, some in English<br />
<br />
== Entware ==<br />
<br />
* https://forum.qnapclub.de/thread/37886-howto-entware-ng-und-linux-pakete-installieren/?f=80&t=37886#p215810<br />
<br />
=== autorun ===<br />
<br />
deprecated - /opt/etc/init.d/rc.unslung should do the trick - started by /share/CACHEDEV1_DATA/.qpkg/Entware-ng/Entware-ng.s start !<br />
<br />
* autorun.sh: see http://www.welzels.de/blog/projekte/qnap-mods-tricks-und-projekte/optware-init-skripte-nach-booten-starten/<br />
* installation for my 431p: (copy from https://wiki.qnap.com/wiki/Running_Your_Own_Application_at_Startup)<br />
<br />
ubiattach -m 6 -d 2<br />
/bin/mount -t ubifs ubi2:config /tmp/config<br />
vi /tmp/config/autorun.sh<br />
chmod +x /tmp/config/autorun.sh<br />
echo .<br />
echo "unmounting /tmp/config..."<br />
umount /tmp/config<br />
ubidetach -m 6<br />
<br />
* enable auto-start (re-do after FW update): http://www.welzels.de/blog/projekte/qnap-mods-tricks-und-projekte/optware-init-skripte-nach-booten-starten/<br />
<br />
* manual start (if auto-start does not work):<br />
** SSH: [/share/CACHEDEV1_DATA/.qpkg/Entware-ng] # ./Entware-ng.sh start<br />
** Desktop: open Entware-ng App in QNAP<br />
<br />
== Raid sync speed ==<br />
<br />
https://forum.qnap.com/viewtopic.php?t=10268<br />
<br />
cat /proc/mdstat<br />
<br />
cat /proc/sys/dev/raid/speed_limit_max<br />
200000<br />
cat /proc/sys/dev/raid/speed_limit_min<br />
5000<br />
<br />
== HDD spin down issues ==<br />
<br />
* [https://www.qnap.com/en-us/qa/con_show.php?op=showone&cid=58 Why the hard drive of NAS does not go to standby mode?]<br />
<br />
* [https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=1 Probleme mit Festplatten-Standby]<br />
<br />
* Qnap QTS 4.3.3.0154 write to disk at least every ~30 minutes ( setcfg -> dirtied inode ... qid_persistent.conf) on md9 )<br />
: Qnap seems to known this problem - see https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=12<br />
<br />
=== Move Samba tdb_path to ramdisk ===<br />
<br />
(Permanently) move samba's tdb_path to ram disk -> avoid hdd spin up due to .tdb file update<br />
<br />
[/] # /sbin/setcfg "Samba" "tdb_path" "/" <br />
[/] # /etc/init.d/smb.sh restart <br />
Restarting SMB services:<br />
Shutting down SMB services: smbd nmbd.<br />
Shutting down winbindd services: winbindd.<br />
locks path was set to /share/CACHEDEV1_DATA/.locks<br />
Shutting down winbindd services: winbindd.<br />
Starting winbindd services:Starting SMB services:.<br />
done.<br />
[/] # la /.samba/<br />
drwxr-xr-x 5 admin administ 100 Mar 23 07:33 ./<br />
drwxr-xr-x 23 admin administ 520 Mar 23 07:33 ../<br />
drwxr-xr-x 3 admin administ 60 Mar 23 07:33 cache/<br />
drwxr-xr-x 2 admin administ 320 Mar 23 07:33 lock/<br />
drwxr-xr-x 2 admin administ 120 Mar 23 07:33 state/<br />
<br />
== Cron ==<br />
<br />
* https://www.techandme.se/qnap-and-cron/<br />
<br />
== Firmware downgrade ==<br />
<br />
4.3.3 caused too many problems for me , so I downgraded to 4.2.5 (http://qnapsupport.net/qnap-firmware-downgrade/):<br />
* HDD did not spin down - at least not for long (setcfg wrote to disk every ~30 minutes)<br />
* LAN conenction frequently lost (less frequently after disabling cloudlink, but still happened...)</div>Holyheadhttps://holyhead.de/index.php?title=QNAP_(431p)QNAP (431p)2017-05-04T00:28:53Z<p>Holyhead: /* Entware */</p>
<hr />
<div>=Cookbook=<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others) - some links are in German, some in English<br />
<br />
== Entware ==<br />
<br />
* https://forum.qnapclub.de/thread/37886-howto-entware-ng-und-linux-pakete-installieren/?f=80&t=37886#p215810<br />
<br />
=== autorun ===<br />
<br />
deprecated - /opt/etc/init.d/rc.unslung should do the trick!!!<br />
<br />
* autorun.sh: see http://www.welzels.de/blog/projekte/qnap-mods-tricks-und-projekte/optware-init-skripte-nach-booten-starten/<br />
* installation for my 431p: (copy from https://wiki.qnap.com/wiki/Running_Your_Own_Application_at_Startup)<br />
<br />
ubiattach -m 6 -d 2<br />
/bin/mount -t ubifs ubi2:config /tmp/config<br />
vi /tmp/config/autorun.sh<br />
chmod +x /tmp/config/autorun.sh<br />
echo .<br />
echo "unmounting /tmp/config..."<br />
umount /tmp/config<br />
ubidetach -m 6<br />
<br />
* enable auto-start (re-do after FW update): http://www.welzels.de/blog/projekte/qnap-mods-tricks-und-projekte/optware-init-skripte-nach-booten-starten/<br />
<br />
* manual start (if auto-start does not work):<br />
** SSH: [/share/CACHEDEV1_DATA/.qpkg/Entware-ng] # ./Entware-ng.sh start<br />
** Desktop: open Entware-ng App in QNAP<br />
<br />
== Raid sync speed ==<br />
<br />
https://forum.qnap.com/viewtopic.php?t=10268<br />
<br />
cat /proc/mdstat<br />
<br />
cat /proc/sys/dev/raid/speed_limit_max<br />
200000<br />
cat /proc/sys/dev/raid/speed_limit_min<br />
5000<br />
<br />
== HDD spin down issues ==<br />
<br />
* [https://www.qnap.com/en-us/qa/con_show.php?op=showone&cid=58 Why the hard drive of NAS does not go to standby mode?]<br />
<br />
* [https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=1 Probleme mit Festplatten-Standby]<br />
<br />
* Qnap QTS 4.3.3.0154 write to disk at least every ~30 minutes ( setcfg -> dirtied inode ... qid_persistent.conf) on md9 )<br />
: Qnap seems to known this problem - see https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=12<br />
<br />
=== Move Samba tdb_path to ramdisk ===<br />
<br />
(Permanently) move samba's tdb_path to ram disk -> avoid hdd spin up due to .tdb file update<br />
<br />
[/] # /sbin/setcfg "Samba" "tdb_path" "/" <br />
[/] # /etc/init.d/smb.sh restart <br />
Restarting SMB services:<br />
Shutting down SMB services: smbd nmbd.<br />
Shutting down winbindd services: winbindd.<br />
locks path was set to /share/CACHEDEV1_DATA/.locks<br />
Shutting down winbindd services: winbindd.<br />
Starting winbindd services:Starting SMB services:.<br />
done.<br />
[/] # la /.samba/<br />
drwxr-xr-x 5 admin administ 100 Mar 23 07:33 ./<br />
drwxr-xr-x 23 admin administ 520 Mar 23 07:33 ../<br />
drwxr-xr-x 3 admin administ 60 Mar 23 07:33 cache/<br />
drwxr-xr-x 2 admin administ 320 Mar 23 07:33 lock/<br />
drwxr-xr-x 2 admin administ 120 Mar 23 07:33 state/<br />
<br />
== Cron ==<br />
<br />
* https://www.techandme.se/qnap-and-cron/<br />
<br />
== Firmware downgrade ==<br />
<br />
4.3.3 caused too many problems for me , so I downgraded to 4.2.5 (http://qnapsupport.net/qnap-firmware-downgrade/):<br />
* HDD did not spin down - at least not for long (setcfg wrote to disk every ~30 minutes)<br />
* LAN conenction frequently lost (less frequently after disabling cloudlink, but still happened...)</div>Holyheadhttps://holyhead.de/index.php?title=QNAP_(431p)QNAP (431p)2017-05-04T00:15:40Z<p>Holyhead: /* Entware */</p>
<hr />
<div>=Cookbook=<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others) - some links are in German, some in English<br />
<br />
== Entware ==<br />
<br />
* https://forum.qnapclub.de/thread/37886-howto-entware-ng-und-linux-pakete-installieren/?f=80&t=37886#p215810<br />
* autorun.sh: see http://www.welzels.de/blog/projekte/qnap-mods-tricks-und-projekte/optware-init-skripte-nach-booten-starten/<br />
* installation for my 431p: (copy from https://wiki.qnap.com/wiki/Running_Your_Own_Application_at_Startup)<br />
<br />
ubiattach -m 6 -d 2<br />
/bin/mount -t ubifs ubi2:config /tmp/config<br />
vi /tmp/config/autorun.sh<br />
chmod +x /tmp/config/autorun.sh<br />
echo .<br />
echo "unmounting /tmp/config..."<br />
umount /tmp/config<br />
ubidetach -m 6<br />
<br />
* enable auto-start (re-do after FW update): http://www.welzels.de/blog/projekte/qnap-mods-tricks-und-projekte/optware-init-skripte-nach-booten-starten/<br />
<br />
* manual start (if auto-start does not work):<br />
** SSH: [/share/CACHEDEV1_DATA/.qpkg/Entware-ng] # ./Entware-ng.sh start<br />
** Desktop: open Entware-ng App in QNAP<br />
<br />
== Raid sync speed ==<br />
<br />
https://forum.qnap.com/viewtopic.php?t=10268<br />
<br />
cat /proc/mdstat<br />
<br />
cat /proc/sys/dev/raid/speed_limit_max<br />
200000<br />
cat /proc/sys/dev/raid/speed_limit_min<br />
5000<br />
<br />
== HDD spin down issues ==<br />
<br />
* [https://www.qnap.com/en-us/qa/con_show.php?op=showone&cid=58 Why the hard drive of NAS does not go to standby mode?]<br />
<br />
* [https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=1 Probleme mit Festplatten-Standby]<br />
<br />
* Qnap QTS 4.3.3.0154 write to disk at least every ~30 minutes ( setcfg -> dirtied inode ... qid_persistent.conf) on md9 )<br />
: Qnap seems to known this problem - see https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=12<br />
<br />
=== Move Samba tdb_path to ramdisk ===<br />
<br />
(Permanently) move samba's tdb_path to ram disk -> avoid hdd spin up due to .tdb file update<br />
<br />
[/] # /sbin/setcfg "Samba" "tdb_path" "/" <br />
[/] # /etc/init.d/smb.sh restart <br />
Restarting SMB services:<br />
Shutting down SMB services: smbd nmbd.<br />
Shutting down winbindd services: winbindd.<br />
locks path was set to /share/CACHEDEV1_DATA/.locks<br />
Shutting down winbindd services: winbindd.<br />
Starting winbindd services:Starting SMB services:.<br />
done.<br />
[/] # la /.samba/<br />
drwxr-xr-x 5 admin administ 100 Mar 23 07:33 ./<br />
drwxr-xr-x 23 admin administ 520 Mar 23 07:33 ../<br />
drwxr-xr-x 3 admin administ 60 Mar 23 07:33 cache/<br />
drwxr-xr-x 2 admin administ 320 Mar 23 07:33 lock/<br />
drwxr-xr-x 2 admin administ 120 Mar 23 07:33 state/<br />
<br />
== Cron ==<br />
<br />
* https://www.techandme.se/qnap-and-cron/<br />
<br />
== Firmware downgrade ==<br />
<br />
4.3.3 caused too many problems for me , so I downgraded to 4.2.5 (http://qnapsupport.net/qnap-firmware-downgrade/):<br />
* HDD did not spin down - at least not for long (setcfg wrote to disk every ~30 minutes)<br />
* LAN conenction frequently lost (less frequently after disabling cloudlink, but still happened...)</div>Holyheadhttps://holyhead.de/index.php?title=QNAP_(431p)QNAP (431p)2017-05-03T22:11:31Z<p>Holyhead: /* Entware */</p>
<hr />
<div>=Cookbook=<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others) - some links are in German, some in English<br />
<br />
== Entware ==<br />
<br />
* https://forum.qnapclub.de/thread/37886-howto-entware-ng-und-linux-pakete-installieren/?f=80&t=37886#p215810<br />
* autorun.sh: see https://forum.qnapclub.de/thread/37886-howto-entware-ng-und-linux-pakete-installieren/?f=80&t=37886#p215810<br />
* installation for my 431p: (copy from https://wiki.qnap.com/wiki/Running_Your_Own_Application_at_Startup)<br />
<br />
ubiattach -m 6 -d 2<br />
/bin/mount -t ubifs ubi2:config /tmp/config<br />
vi /tmp/config/autorun.sh<br />
chmod +x /tmp/config/autorun.sh<br />
echo .<br />
echo "unmounting /tmp/config..."<br />
umount /tmp/config<br />
ubidetach -m 6<br />
<br />
* enable auto-start (re-do after FW update): http://www.welzels.de/blog/projekte/qnap-mods-tricks-und-projekte/optware-init-skripte-nach-booten-starten/<br />
<br />
* manual start (if auto-start does not work):<br />
** SSH: [/share/CACHEDEV1_DATA/.qpkg/Entware-ng] # ./Entware-ng.sh start<br />
** Desktop: open Entware-ng App in QNAP<br />
<br />
== Raid sync speed ==<br />
<br />
https://forum.qnap.com/viewtopic.php?t=10268<br />
<br />
cat /proc/mdstat<br />
<br />
cat /proc/sys/dev/raid/speed_limit_max<br />
200000<br />
cat /proc/sys/dev/raid/speed_limit_min<br />
5000<br />
<br />
== HDD spin down issues ==<br />
<br />
* [https://www.qnap.com/en-us/qa/con_show.php?op=showone&cid=58 Why the hard drive of NAS does not go to standby mode?]<br />
<br />
* [https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=1 Probleme mit Festplatten-Standby]<br />
<br />
* Qnap QTS 4.3.3.0154 write to disk at least every ~30 minutes ( setcfg -> dirtied inode ... qid_persistent.conf) on md9 )<br />
: Qnap seems to known this problem - see https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=12<br />
<br />
=== Move Samba tdb_path to ramdisk ===<br />
<br />
(Permanently) move samba's tdb_path to ram disk -> avoid hdd spin up due to .tdb file update<br />
<br />
[/] # /sbin/setcfg "Samba" "tdb_path" "/" <br />
[/] # /etc/init.d/smb.sh restart <br />
Restarting SMB services:<br />
Shutting down SMB services: smbd nmbd.<br />
Shutting down winbindd services: winbindd.<br />
locks path was set to /share/CACHEDEV1_DATA/.locks<br />
Shutting down winbindd services: winbindd.<br />
Starting winbindd services:Starting SMB services:.<br />
done.<br />
[/] # la /.samba/<br />
drwxr-xr-x 5 admin administ 100 Mar 23 07:33 ./<br />
drwxr-xr-x 23 admin administ 520 Mar 23 07:33 ../<br />
drwxr-xr-x 3 admin administ 60 Mar 23 07:33 cache/<br />
drwxr-xr-x 2 admin administ 320 Mar 23 07:33 lock/<br />
drwxr-xr-x 2 admin administ 120 Mar 23 07:33 state/<br />
<br />
== Cron ==<br />
<br />
* https://www.techandme.se/qnap-and-cron/<br />
<br />
== Firmware downgrade ==<br />
<br />
4.3.3 caused too many problems for me , so I downgraded to 4.2.5 (http://qnapsupport.net/qnap-firmware-downgrade/):<br />
* HDD did not spin down - at least not for long (setcfg wrote to disk every ~30 minutes)<br />
* LAN conenction frequently lost (less frequently after disabling cloudlink, but still happened...)</div>Holyheadhttps://holyhead.de/index.php?title=QNAP_(431p)QNAP (431p)2017-05-03T21:56:43Z<p>Holyhead: /* Entware */</p>
<hr />
<div>=Cookbook=<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others) - some links are in German, some in English<br />
<br />
== Entware ==<br />
<br />
* https://forum.qnapclub.de/thread/37886-howto-entware-ng-und-linux-pakete-installieren/?f=80&t=37886#p215810<br />
* autorun.sh: see https://forum.qnapclub.de/thread/37886-howto-entware-ng-und-linux-pakete-installieren/?f=80&t=37886#p215810<br />
* installation for my 431p: (copy from https://wiki.qnap.com/wiki/Running_Your_Own_Application_at_Startup)<br />
<br />
ubiattach -m 6 -d 2<br />
/bin/mount -t ubifs ubi2:config /tmp/config<br />
vi /tmp/config/autorun.sh<br />
chmod +x /tmp/config/autorun.sh<br />
echo .<br />
echo "unmounting /tmp/config..."<br />
umount /tmp/config<br />
ubidetach -m 6<br />
<br />
* enable auto-start (re-do after FW update): http://www.welzels.de/blog/projekte/qnap-mods-tricks-und-projekte/optware-init-skripte-nach-booten-starten/<br />
<br />
* manual start (if auto-start does not work):<br />
** SSH: [/share/CACHEDEV1_DATA/.qpkg/Entware-ng] # ./Entware-ng.sh start<br />
** Desktop: open Entware-ng App in QNAP<br />
<br />
* re-install after FW update to reinstall auto-start<br />
<br />
== Raid sync speed ==<br />
<br />
https://forum.qnap.com/viewtopic.php?t=10268<br />
<br />
cat /proc/mdstat<br />
<br />
cat /proc/sys/dev/raid/speed_limit_max<br />
200000<br />
cat /proc/sys/dev/raid/speed_limit_min<br />
5000<br />
<br />
== HDD spin down issues ==<br />
<br />
* [https://www.qnap.com/en-us/qa/con_show.php?op=showone&cid=58 Why the hard drive of NAS does not go to standby mode?]<br />
<br />
* [https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=1 Probleme mit Festplatten-Standby]<br />
<br />
* Qnap QTS 4.3.3.0154 write to disk at least every ~30 minutes ( setcfg -> dirtied inode ... qid_persistent.conf) on md9 )<br />
: Qnap seems to known this problem - see https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=12<br />
<br />
=== Move Samba tdb_path to ramdisk ===<br />
<br />
(Permanently) move samba's tdb_path to ram disk -> avoid hdd spin up due to .tdb file update<br />
<br />
[/] # /sbin/setcfg "Samba" "tdb_path" "/" <br />
[/] # /etc/init.d/smb.sh restart <br />
Restarting SMB services:<br />
Shutting down SMB services: smbd nmbd.<br />
Shutting down winbindd services: winbindd.<br />
locks path was set to /share/CACHEDEV1_DATA/.locks<br />
Shutting down winbindd services: winbindd.<br />
Starting winbindd services:Starting SMB services:.<br />
done.<br />
[/] # la /.samba/<br />
drwxr-xr-x 5 admin administ 100 Mar 23 07:33 ./<br />
drwxr-xr-x 23 admin administ 520 Mar 23 07:33 ../<br />
drwxr-xr-x 3 admin administ 60 Mar 23 07:33 cache/<br />
drwxr-xr-x 2 admin administ 320 Mar 23 07:33 lock/<br />
drwxr-xr-x 2 admin administ 120 Mar 23 07:33 state/<br />
<br />
== Cron ==<br />
<br />
* https://www.techandme.se/qnap-and-cron/<br />
<br />
== Firmware downgrade ==<br />
<br />
4.3.3 caused too many problems for me , so I downgraded to 4.2.5 (http://qnapsupport.net/qnap-firmware-downgrade/):<br />
* HDD did not spin down - at least not for long (setcfg wrote to disk every ~30 minutes)<br />
* LAN conenction frequently lost (less frequently after disabling cloudlink, but still happened...)</div>Holyheadhttps://holyhead.de/index.php?title=QNAP_(431p)QNAP (431p)2017-05-03T21:54:02Z<p>Holyhead: /* Entware */</p>
<hr />
<div>=Cookbook=<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others) - some links are in German, some in English<br />
<br />
== Entware ==<br />
<br />
* https://forum.qnapclub.de/thread/37886-howto-entware-ng-und-linux-pakete-installieren/?f=80&t=37886#p215810<br />
* autorun.sh: see https://forum.qnapclub.de/thread/37886-howto-entware-ng-und-linux-pakete-installieren/?f=80&t=37886#p215810<br />
* installation for my 431p: (copy from https://wiki.qnap.com/wiki/Running_Your_Own_Application_at_Startup)<br />
<br />
ubiattach -m 6 -d 2<br />
/bin/mount -t ubifs ubi2:config /tmp/config<br />
vi /tmp/config/autorun.sh<br />
chmod +x /tmp/config/autorun.sh<br />
echo .<br />
echo "unmounting /tmp/config..."<br />
umount /tmp/config<br />
ubidetach -m 6<br />
<br />
* enable auto-start (re-do after FW update): http://www.welzels.de/blog/projekte/qnap-mods-tricks-und-projekte/optware-init-skripte-nach-booten-starten/<br />
<br />
* manual start:<br />
** SSH: [/share/CACHEDEV1_DATA/.qpkg/Entware-ng] # ./Entware-ng.sh start<br />
** Desktop: open Entware-ng App in QNAP<br />
<br />
== Raid sync speed ==<br />
<br />
https://forum.qnap.com/viewtopic.php?t=10268<br />
<br />
cat /proc/mdstat<br />
<br />
cat /proc/sys/dev/raid/speed_limit_max<br />
200000<br />
cat /proc/sys/dev/raid/speed_limit_min<br />
5000<br />
<br />
== HDD spin down issues ==<br />
<br />
* [https://www.qnap.com/en-us/qa/con_show.php?op=showone&cid=58 Why the hard drive of NAS does not go to standby mode?]<br />
<br />
* [https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=1 Probleme mit Festplatten-Standby]<br />
<br />
* Qnap QTS 4.3.3.0154 write to disk at least every ~30 minutes ( setcfg -> dirtied inode ... qid_persistent.conf) on md9 )<br />
: Qnap seems to known this problem - see https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=12<br />
<br />
=== Move Samba tdb_path to ramdisk ===<br />
<br />
(Permanently) move samba's tdb_path to ram disk -> avoid hdd spin up due to .tdb file update<br />
<br />
[/] # /sbin/setcfg "Samba" "tdb_path" "/" <br />
[/] # /etc/init.d/smb.sh restart <br />
Restarting SMB services:<br />
Shutting down SMB services: smbd nmbd.<br />
Shutting down winbindd services: winbindd.<br />
locks path was set to /share/CACHEDEV1_DATA/.locks<br />
Shutting down winbindd services: winbindd.<br />
Starting winbindd services:Starting SMB services:.<br />
done.<br />
[/] # la /.samba/<br />
drwxr-xr-x 5 admin administ 100 Mar 23 07:33 ./<br />
drwxr-xr-x 23 admin administ 520 Mar 23 07:33 ../<br />
drwxr-xr-x 3 admin administ 60 Mar 23 07:33 cache/<br />
drwxr-xr-x 2 admin administ 320 Mar 23 07:33 lock/<br />
drwxr-xr-x 2 admin administ 120 Mar 23 07:33 state/<br />
<br />
== Cron ==<br />
<br />
* https://www.techandme.se/qnap-and-cron/<br />
<br />
== Firmware downgrade ==<br />
<br />
4.3.3 caused too many problems for me , so I downgraded to 4.2.5 (http://qnapsupport.net/qnap-firmware-downgrade/):<br />
* HDD did not spin down - at least not for long (setcfg wrote to disk every ~30 minutes)<br />
* LAN conenction frequently lost (less frequently after disabling cloudlink, but still happened...)</div>Holyheadhttps://holyhead.de/index.php?title=QNAP_(431p)QNAP (431p)2017-05-03T21:53:46Z<p>Holyhead: /* Entware */</p>
<hr />
<div>=Cookbook=<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others) - some links are in German, some in English<br />
<br />
== Entware ==<br />
<br />
* autorun.sh: see https://forum.qnapclub.de/thread/37886-howto-entware-ng-und-linux-pakete-installieren/?f=80&t=37886#p215810<br />
* installation for my 431p: (copy from https://wiki.qnap.com/wiki/Running_Your_Own_Application_at_Startup)<br />
<br />
ubiattach -m 6 -d 2<br />
/bin/mount -t ubifs ubi2:config /tmp/config<br />
vi /tmp/config/autorun.sh<br />
chmod +x /tmp/config/autorun.sh<br />
echo .<br />
echo "unmounting /tmp/config..."<br />
umount /tmp/config<br />
ubidetach -m 6<br />
<br />
* enable auto-start (re-do after FW update): http://www.welzels.de/blog/projekte/qnap-mods-tricks-und-projekte/optware-init-skripte-nach-booten-starten/<br />
<br />
* manual start:<br />
** SSH: [/share/CACHEDEV1_DATA/.qpkg/Entware-ng] # ./Entware-ng.sh start<br />
** Desktop: open Entware-ng App in QNAP<br />
<br />
== Raid sync speed ==<br />
<br />
https://forum.qnap.com/viewtopic.php?t=10268<br />
<br />
cat /proc/mdstat<br />
<br />
cat /proc/sys/dev/raid/speed_limit_max<br />
200000<br />
cat /proc/sys/dev/raid/speed_limit_min<br />
5000<br />
<br />
== HDD spin down issues ==<br />
<br />
* [https://www.qnap.com/en-us/qa/con_show.php?op=showone&cid=58 Why the hard drive of NAS does not go to standby mode?]<br />
<br />
* [https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=1 Probleme mit Festplatten-Standby]<br />
<br />
* Qnap QTS 4.3.3.0154 write to disk at least every ~30 minutes ( setcfg -> dirtied inode ... qid_persistent.conf) on md9 )<br />
: Qnap seems to known this problem - see https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=12<br />
<br />
=== Move Samba tdb_path to ramdisk ===<br />
<br />
(Permanently) move samba's tdb_path to ram disk -> avoid hdd spin up due to .tdb file update<br />
<br />
[/] # /sbin/setcfg "Samba" "tdb_path" "/" <br />
[/] # /etc/init.d/smb.sh restart <br />
Restarting SMB services:<br />
Shutting down SMB services: smbd nmbd.<br />
Shutting down winbindd services: winbindd.<br />
locks path was set to /share/CACHEDEV1_DATA/.locks<br />
Shutting down winbindd services: winbindd.<br />
Starting winbindd services:Starting SMB services:.<br />
done.<br />
[/] # la /.samba/<br />
drwxr-xr-x 5 admin administ 100 Mar 23 07:33 ./<br />
drwxr-xr-x 23 admin administ 520 Mar 23 07:33 ../<br />
drwxr-xr-x 3 admin administ 60 Mar 23 07:33 cache/<br />
drwxr-xr-x 2 admin administ 320 Mar 23 07:33 lock/<br />
drwxr-xr-x 2 admin administ 120 Mar 23 07:33 state/<br />
<br />
== Cron ==<br />
<br />
* https://www.techandme.se/qnap-and-cron/<br />
<br />
== Firmware downgrade ==<br />
<br />
4.3.3 caused too many problems for me , so I downgraded to 4.2.5 (http://qnapsupport.net/qnap-firmware-downgrade/):<br />
* HDD did not spin down - at least not for long (setcfg wrote to disk every ~30 minutes)<br />
* LAN conenction frequently lost (less frequently after disabling cloudlink, but still happened...)</div>Holyheadhttps://holyhead.de/index.php?title=QNAP_(431p)QNAP (431p)2017-05-03T21:45:58Z<p>Holyhead: /* Misc */</p>
<hr />
<div>=Cookbook=<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others) - some links are in German, some in English<br />
<br />
== Entware ==<br />
<br />
* autorun.sh: see https://forum.qnapclub.de/thread/37886-howto-entware-ng-und-linux-pakete-installieren/?f=80&t=37886#p215810<br />
* installation for my 431p: (copy from https://wiki.qnap.com/wiki/Running_Your_Own_Application_at_Startup)<br />
<br />
ubiattach -m 6 -d 2<br />
/bin/mount -t ubifs ubi2:config /tmp/config<br />
vi /tmp/config/autorun.sh<br />
chmod +x /tmp/config/autorun.sh<br />
echo .<br />
echo "unmounting /tmp/config..."<br />
umount /tmp/config<br />
ubidetach -m 6<br />
<br />
* enable auto-start (re-do after FW update): http://www.welzels.de/blog/projekte/qnap-mods-tricks-und-projekte/optware-init-skripte-nach-booten-starten/<br />
<br />
* re-enable after FW update:<br />
** Desktop: open Entware-ng App in QNAP <br />
** SSH: [/share/CACHEDEV1_DATA/.qpkg/Entware-ng] # ./Entware-ng.sh start<br />
<br />
== Raid sync speed ==<br />
<br />
https://forum.qnap.com/viewtopic.php?t=10268<br />
<br />
cat /proc/mdstat<br />
<br />
cat /proc/sys/dev/raid/speed_limit_max<br />
200000<br />
cat /proc/sys/dev/raid/speed_limit_min<br />
5000<br />
<br />
== HDD spin down issues ==<br />
<br />
* [https://www.qnap.com/en-us/qa/con_show.php?op=showone&cid=58 Why the hard drive of NAS does not go to standby mode?]<br />
<br />
* [https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=1 Probleme mit Festplatten-Standby]<br />
<br />
* Qnap QTS 4.3.3.0154 write to disk at least every ~30 minutes ( setcfg -> dirtied inode ... qid_persistent.conf) on md9 )<br />
: Qnap seems to known this problem - see https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=12<br />
<br />
=== Move Samba tdb_path to ramdisk ===<br />
<br />
(Permanently) move samba's tdb_path to ram disk -> avoid hdd spin up due to .tdb file update<br />
<br />
[/] # /sbin/setcfg "Samba" "tdb_path" "/" <br />
[/] # /etc/init.d/smb.sh restart <br />
Restarting SMB services:<br />
Shutting down SMB services: smbd nmbd.<br />
Shutting down winbindd services: winbindd.<br />
locks path was set to /share/CACHEDEV1_DATA/.locks<br />
Shutting down winbindd services: winbindd.<br />
Starting winbindd services:Starting SMB services:.<br />
done.<br />
[/] # la /.samba/<br />
drwxr-xr-x 5 admin administ 100 Mar 23 07:33 ./<br />
drwxr-xr-x 23 admin administ 520 Mar 23 07:33 ../<br />
drwxr-xr-x 3 admin administ 60 Mar 23 07:33 cache/<br />
drwxr-xr-x 2 admin administ 320 Mar 23 07:33 lock/<br />
drwxr-xr-x 2 admin administ 120 Mar 23 07:33 state/<br />
<br />
== Cron ==<br />
<br />
* https://www.techandme.se/qnap-and-cron/<br />
<br />
== Firmware downgrade ==<br />
<br />
4.3.3 caused too many problems for me , so I downgraded to 4.2.5 (http://qnapsupport.net/qnap-firmware-downgrade/):<br />
* HDD did not spin down - at least not for long (setcfg wrote to disk every ~30 minutes)<br />
* LAN conenction frequently lost (less frequently after disabling cloudlink, but still happened...)</div>Holyheadhttps://holyhead.de/index.php?title=QNAP_(431p)QNAP (431p)2017-05-03T21:37:40Z<p>Holyhead: /* Entware */</p>
<hr />
<div>=Cookbook=<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others) - some links are in German, some in English<br />
<br />
== Entware ==<br />
<br />
* autorun.sh: see https://forum.qnapclub.de/thread/37886-howto-entware-ng-und-linux-pakete-installieren/?f=80&t=37886#p215810<br />
* installation for my 431p: (copy from https://wiki.qnap.com/wiki/Running_Your_Own_Application_at_Startup)<br />
<br />
ubiattach -m 6 -d 2<br />
/bin/mount -t ubifs ubi2:config /tmp/config<br />
vi /tmp/config/autorun.sh<br />
chmod +x /tmp/config/autorun.sh<br />
echo .<br />
echo "unmounting /tmp/config..."<br />
umount /tmp/config<br />
ubidetach -m 6<br />
<br />
* enable auto-start (re-do after FW update): http://www.welzels.de/blog/projekte/qnap-mods-tricks-und-projekte/optware-init-skripte-nach-booten-starten/<br />
<br />
* re-enable after FW update:<br />
** Desktop: open Entware-ng App in QNAP <br />
** SSH: [/share/CACHEDEV1_DATA/.qpkg/Entware-ng] # ./Entware-ng.sh start<br />
<br />
== Raid sync speed ==<br />
<br />
https://forum.qnap.com/viewtopic.php?t=10268<br />
<br />
cat /proc/mdstat<br />
<br />
cat /proc/sys/dev/raid/speed_limit_max<br />
200000<br />
cat /proc/sys/dev/raid/speed_limit_min<br />
5000<br />
<br />
== HDD spin down issues ==<br />
<br />
* [https://www.qnap.com/en-us/qa/con_show.php?op=showone&cid=58 Why the hard drive of NAS does not go to standby mode?]<br />
<br />
* [https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=1 Probleme mit Festplatten-Standby]<br />
<br />
* Qnap QTS 4.3.3.0154 write to disk at least every ~30 minutes ( setcfg -> dirtied inode ... qid_persistent.conf) on md9 )<br />
: Qnap seems to known this problem - see https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=12<br />
<br />
=== Move Samba tdb_path to ramdisk ===<br />
<br />
(Permanently) move samba's tdb_path to ram disk -> avoid hdd spin up due to .tdb file update<br />
<br />
[/] # /sbin/setcfg "Samba" "tdb_path" "/" <br />
[/] # /etc/init.d/smb.sh restart <br />
Restarting SMB services:<br />
Shutting down SMB services: smbd nmbd.<br />
Shutting down winbindd services: winbindd.<br />
locks path was set to /share/CACHEDEV1_DATA/.locks<br />
Shutting down winbindd services: winbindd.<br />
Starting winbindd services:Starting SMB services:.<br />
done.<br />
[/] # la /.samba/<br />
drwxr-xr-x 5 admin administ 100 Mar 23 07:33 ./<br />
drwxr-xr-x 23 admin administ 520 Mar 23 07:33 ../<br />
drwxr-xr-x 3 admin administ 60 Mar 23 07:33 cache/<br />
drwxr-xr-x 2 admin administ 320 Mar 23 07:33 lock/<br />
drwxr-xr-x 2 admin administ 120 Mar 23 07:33 state/<br />
<br />
== Cron ==<br />
<br />
* https://www.techandme.se/qnap-and-cron/<br />
<br />
== Misc ==<br />
<br />
* http://qnapsupport.net/qnap-firmware-downgrade/</div>Holyheadhttps://holyhead.de/index.php?title=QNAP_(431p)QNAP (431p)2017-05-03T21:34:57Z<p>Holyhead: /* Entware */</p>
<hr />
<div>=Cookbook=<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others) - some links are in German, some in English<br />
<br />
== Entware ==<br />
<br />
* https://forum.qnapclub.de/thread/37886-howto-entware-ng-und-linux-pakete-installieren/?f=80&t=37886#p215810<br />
* for my 431p: (copy from https://wiki.qnap.com/wiki/Running_Your_Own_Application_at_Startup)<br />
<br />
ubiattach -m 6 -d 2<br />
/bin/mount -t ubifs ubi2:config /tmp/config<br />
vi /tmp/config/autorun.sh<br />
chmod +x /tmp/config/autorun.sh<br />
echo .<br />
echo "unmounting /tmp/config..."<br />
umount /tmp/config<br />
ubidetach -m 6<br />
<br />
* enable auto-start (re-do after FW update): http://www.welzels.de/blog/projekte/qnap-mods-tricks-und-projekte/optware-init-skripte-nach-booten-starten/<br />
<br />
* re-enable after FW update:<br />
** Desktop: open Entware-ng App in QNAP <br />
** SSH: [/share/CACHEDEV1_DATA/.qpkg/Entware-ng] # ./Entware-ng.sh start<br />
<br />
== Raid sync speed ==<br />
<br />
https://forum.qnap.com/viewtopic.php?t=10268<br />
<br />
cat /proc/mdstat<br />
<br />
cat /proc/sys/dev/raid/speed_limit_max<br />
200000<br />
cat /proc/sys/dev/raid/speed_limit_min<br />
5000<br />
<br />
== HDD spin down issues ==<br />
<br />
* [https://www.qnap.com/en-us/qa/con_show.php?op=showone&cid=58 Why the hard drive of NAS does not go to standby mode?]<br />
<br />
* [https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=1 Probleme mit Festplatten-Standby]<br />
<br />
* Qnap QTS 4.3.3.0154 write to disk at least every ~30 minutes ( setcfg -> dirtied inode ... qid_persistent.conf) on md9 )<br />
: Qnap seems to known this problem - see https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=12<br />
<br />
=== Move Samba tdb_path to ramdisk ===<br />
<br />
(Permanently) move samba's tdb_path to ram disk -> avoid hdd spin up due to .tdb file update<br />
<br />
[/] # /sbin/setcfg "Samba" "tdb_path" "/" <br />
[/] # /etc/init.d/smb.sh restart <br />
Restarting SMB services:<br />
Shutting down SMB services: smbd nmbd.<br />
Shutting down winbindd services: winbindd.<br />
locks path was set to /share/CACHEDEV1_DATA/.locks<br />
Shutting down winbindd services: winbindd.<br />
Starting winbindd services:Starting SMB services:.<br />
done.<br />
[/] # la /.samba/<br />
drwxr-xr-x 5 admin administ 100 Mar 23 07:33 ./<br />
drwxr-xr-x 23 admin administ 520 Mar 23 07:33 ../<br />
drwxr-xr-x 3 admin administ 60 Mar 23 07:33 cache/<br />
drwxr-xr-x 2 admin administ 320 Mar 23 07:33 lock/<br />
drwxr-xr-x 2 admin administ 120 Mar 23 07:33 state/<br />
<br />
== Cron ==<br />
<br />
* https://www.techandme.se/qnap-and-cron/<br />
<br />
== Misc ==<br />
<br />
* http://qnapsupport.net/qnap-firmware-downgrade/</div>Holyheadhttps://holyhead.de/index.php?title=QNAP_(431p)QNAP (431p)2017-05-03T21:26:29Z<p>Holyhead: /* Entware */</p>
<hr />
<div>=Cookbook=<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others) - some links are in German, some in English<br />
<br />
== Entware ==<br />
<br />
* https://forum.qnapclub.de/thread/37886-howto-entware-ng-und-linux-pakete-installieren/?f=80&t=37886#p215810<br />
<br />
* enable auto-start (re-do after FW update): http://www.welzels.de/blog/projekte/qnap-mods-tricks-und-projekte/optware-init-skripte-nach-booten-starten/<br />
<br />
* re-enable after FW update:<br />
** Desktop: open Entware-ng App in QNAP <br />
** SSH: [/share/CACHEDEV1_DATA/.qpkg/Entware-ng] # ./Entware-ng.sh start<br />
<br />
== Raid sync speed ==<br />
<br />
https://forum.qnap.com/viewtopic.php?t=10268<br />
<br />
cat /proc/mdstat<br />
<br />
cat /proc/sys/dev/raid/speed_limit_max<br />
200000<br />
cat /proc/sys/dev/raid/speed_limit_min<br />
5000<br />
<br />
== HDD spin down issues ==<br />
<br />
* [https://www.qnap.com/en-us/qa/con_show.php?op=showone&cid=58 Why the hard drive of NAS does not go to standby mode?]<br />
<br />
* [https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=1 Probleme mit Festplatten-Standby]<br />
<br />
* Qnap QTS 4.3.3.0154 write to disk at least every ~30 minutes ( setcfg -> dirtied inode ... qid_persistent.conf) on md9 )<br />
: Qnap seems to known this problem - see https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=12<br />
<br />
=== Move Samba tdb_path to ramdisk ===<br />
<br />
(Permanently) move samba's tdb_path to ram disk -> avoid hdd spin up due to .tdb file update<br />
<br />
[/] # /sbin/setcfg "Samba" "tdb_path" "/" <br />
[/] # /etc/init.d/smb.sh restart <br />
Restarting SMB services:<br />
Shutting down SMB services: smbd nmbd.<br />
Shutting down winbindd services: winbindd.<br />
locks path was set to /share/CACHEDEV1_DATA/.locks<br />
Shutting down winbindd services: winbindd.<br />
Starting winbindd services:Starting SMB services:.<br />
done.<br />
[/] # la /.samba/<br />
drwxr-xr-x 5 admin administ 100 Mar 23 07:33 ./<br />
drwxr-xr-x 23 admin administ 520 Mar 23 07:33 ../<br />
drwxr-xr-x 3 admin administ 60 Mar 23 07:33 cache/<br />
drwxr-xr-x 2 admin administ 320 Mar 23 07:33 lock/<br />
drwxr-xr-x 2 admin administ 120 Mar 23 07:33 state/<br />
<br />
== Cron ==<br />
<br />
* https://www.techandme.se/qnap-and-cron/<br />
<br />
== Misc ==<br />
<br />
* http://qnapsupport.net/qnap-firmware-downgrade/</div>Holyheadhttps://holyhead.de/index.php?title=QNAP_(431p)QNAP (431p)2017-05-03T21:20:40Z<p>Holyhead: /* Cron */</p>
<hr />
<div>=Cookbook=<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others) - some links are in German, some in English<br />
<br />
== Entware ==<br />
<br />
* https://forum.qnapclub.de/thread/37886-howto-entware-ng-und-linux-pakete-installieren/?f=80&t=37886#p215810<br />
<br />
* enable auto-start (re-do after FW update): http://www.welzels.de/blog/projekte/qnap-mods-tricks-und-projekte/optware-init-skripte-nach-booten-starten/<br />
<br />
* re-enable after FW update:<br />
[/share/CACHEDEV1_DATA/.qpkg/Entware-ng] # ./Entware-ng.sh start<br />
<br />
== Raid sync speed ==<br />
<br />
https://forum.qnap.com/viewtopic.php?t=10268<br />
<br />
cat /proc/mdstat<br />
<br />
cat /proc/sys/dev/raid/speed_limit_max<br />
200000<br />
cat /proc/sys/dev/raid/speed_limit_min<br />
5000<br />
<br />
== HDD spin down issues ==<br />
<br />
* [https://www.qnap.com/en-us/qa/con_show.php?op=showone&cid=58 Why the hard drive of NAS does not go to standby mode?]<br />
<br />
* [https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=1 Probleme mit Festplatten-Standby]<br />
<br />
* Qnap QTS 4.3.3.0154 write to disk at least every ~30 minutes ( setcfg -> dirtied inode ... qid_persistent.conf) on md9 )<br />
: Qnap seems to known this problem - see https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=12<br />
<br />
=== Move Samba tdb_path to ramdisk ===<br />
<br />
(Permanently) move samba's tdb_path to ram disk -> avoid hdd spin up due to .tdb file update<br />
<br />
[/] # /sbin/setcfg "Samba" "tdb_path" "/" <br />
[/] # /etc/init.d/smb.sh restart <br />
Restarting SMB services:<br />
Shutting down SMB services: smbd nmbd.<br />
Shutting down winbindd services: winbindd.<br />
locks path was set to /share/CACHEDEV1_DATA/.locks<br />
Shutting down winbindd services: winbindd.<br />
Starting winbindd services:Starting SMB services:.<br />
done.<br />
[/] # la /.samba/<br />
drwxr-xr-x 5 admin administ 100 Mar 23 07:33 ./<br />
drwxr-xr-x 23 admin administ 520 Mar 23 07:33 ../<br />
drwxr-xr-x 3 admin administ 60 Mar 23 07:33 cache/<br />
drwxr-xr-x 2 admin administ 320 Mar 23 07:33 lock/<br />
drwxr-xr-x 2 admin administ 120 Mar 23 07:33 state/<br />
<br />
== Cron ==<br />
<br />
* https://www.techandme.se/qnap-and-cron/<br />
<br />
== Misc ==<br />
<br />
* http://qnapsupport.net/qnap-firmware-downgrade/</div>Holyheadhttps://holyhead.de/index.php?title=QNAP_(431p)QNAP (431p)2017-05-03T21:19:00Z<p>Holyhead: /* HDD spin down issues */</p>
<hr />
<div>=Cookbook=<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others) - some links are in German, some in English<br />
<br />
== Entware ==<br />
<br />
* https://forum.qnapclub.de/thread/37886-howto-entware-ng-und-linux-pakete-installieren/?f=80&t=37886#p215810<br />
<br />
* enable auto-start (re-do after FW update): http://www.welzels.de/blog/projekte/qnap-mods-tricks-und-projekte/optware-init-skripte-nach-booten-starten/<br />
<br />
* re-enable after FW update:<br />
[/share/CACHEDEV1_DATA/.qpkg/Entware-ng] # ./Entware-ng.sh start<br />
<br />
== Raid sync speed ==<br />
<br />
https://forum.qnap.com/viewtopic.php?t=10268<br />
<br />
cat /proc/mdstat<br />
<br />
cat /proc/sys/dev/raid/speed_limit_max<br />
200000<br />
cat /proc/sys/dev/raid/speed_limit_min<br />
5000<br />
<br />
== HDD spin down issues ==<br />
<br />
* [https://www.qnap.com/en-us/qa/con_show.php?op=showone&cid=58 Why the hard drive of NAS does not go to standby mode?]<br />
<br />
* [https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=1 Probleme mit Festplatten-Standby]<br />
<br />
* Qnap QTS 4.3.3.0154 write to disk at least every ~30 minutes ( setcfg -> dirtied inode ... qid_persistent.conf) on md9 )<br />
: Qnap seems to known this problem - see https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=12<br />
<br />
=== Move Samba tdb_path to ramdisk ===<br />
<br />
(Permanently) move samba's tdb_path to ram disk -> avoid hdd spin up due to .tdb file update<br />
<br />
[/] # /sbin/setcfg "Samba" "tdb_path" "/" <br />
[/] # /etc/init.d/smb.sh restart <br />
Restarting SMB services:<br />
Shutting down SMB services: smbd nmbd.<br />
Shutting down winbindd services: winbindd.<br />
locks path was set to /share/CACHEDEV1_DATA/.locks<br />
Shutting down winbindd services: winbindd.<br />
Starting winbindd services:Starting SMB services:.<br />
done.<br />
[/] # la /.samba/<br />
drwxr-xr-x 5 admin administ 100 Mar 23 07:33 ./<br />
drwxr-xr-x 23 admin administ 520 Mar 23 07:33 ../<br />
drwxr-xr-x 3 admin administ 60 Mar 23 07:33 cache/<br />
drwxr-xr-x 2 admin administ 320 Mar 23 07:33 lock/<br />
drwxr-xr-x 2 admin administ 120 Mar 23 07:33 state/<br />
<br />
== Cron ==<br />
<br />
* https://www.techandme.se/qnap-and-cron/</div>Holyheadhttps://holyhead.de/index.php?title=QNAP_(431p)QNAP (431p)2017-05-03T21:06:31Z<p>Holyhead: </p>
<hr />
<div>=Cookbook=<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others) - some links are in German, some in English<br />
<br />
== Entware ==<br />
<br />
* https://forum.qnapclub.de/thread/37886-howto-entware-ng-und-linux-pakete-installieren/?f=80&t=37886#p215810<br />
<br />
* enable auto-start (re-do after FW update): http://www.welzels.de/blog/projekte/qnap-mods-tricks-und-projekte/optware-init-skripte-nach-booten-starten/<br />
<br />
* re-enable after FW update:<br />
[/share/CACHEDEV1_DATA/.qpkg/Entware-ng] # ./Entware-ng.sh start<br />
<br />
== Raid sync speed ==<br />
<br />
https://forum.qnap.com/viewtopic.php?t=10268<br />
<br />
cat /proc/mdstat<br />
<br />
cat /proc/sys/dev/raid/speed_limit_max<br />
200000<br />
cat /proc/sys/dev/raid/speed_limit_min<br />
5000<br />
<br />
== HDD spin down issues ==<br />
<br />
* [https://www.qnap.com/en-us/qa/con_show.php?op=showone&cid=58 Why the hard drive of NAS does not go to standby mode?]<br />
<br />
* [https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=1 Probleme mit Festplatten-Standby]<br />
<br />
* Qnap QTS 4.3.3.0154 write to disk at least every ~30 minutes ( setcfg -> dirtied inode ... qid_persistent.conf) on md9 )<br />
Seems to be known issue - see https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=12<br />
<br />
=== Move Samba tdb_path to ramdisk ===<br />
<br />
(Permanently) move samba's tdb_path to ram disk -> avoid hdd spin up due to .tdb file update<br />
<br />
[/] # /sbin/setcfg "Samba" "tdb_path" "/" <br />
[/] # /etc/init.d/smb.sh restart <br />
Restarting SMB services:<br />
Shutting down SMB services: smbd nmbd.<br />
Shutting down winbindd services: winbindd.<br />
locks path was set to /share/CACHEDEV1_DATA/.locks<br />
Shutting down winbindd services: winbindd.<br />
Starting winbindd services:Starting SMB services:.<br />
done.<br />
[/] # la /.samba/<br />
drwxr-xr-x 5 admin administ 100 Mar 23 07:33 ./<br />
drwxr-xr-x 23 admin administ 520 Mar 23 07:33 ../<br />
drwxr-xr-x 3 admin administ 60 Mar 23 07:33 cache/<br />
drwxr-xr-x 2 admin administ 320 Mar 23 07:33 lock/<br />
drwxr-xr-x 2 admin administ 120 Mar 23 07:33 state/<br />
<br />
== Cron ==<br />
<br />
* https://www.techandme.se/qnap-and-cron/</div>Holyheadhttps://holyhead.de/index.php?title=QNAP_(431p)QNAP (431p)2017-03-07T23:40:14Z<p>Holyhead: /* HDD spin down issues */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
=== Raid sync speed ===<br />
<br />
https://forum.qnap.com/viewtopic.php?t=10268<br />
<br />
cat /proc/mdstat<br />
<br />
cat /proc/sys/dev/raid/speed_limit_max<br />
200000<br />
cat /proc/sys/dev/raid/speed_limit_min<br />
5000<br />
<br />
=== HDD spin down issues ===<br />
<br />
* [https://www.qnap.com/en-us/qa/con_show.php?op=showone&cid=58 Why the hard drive of NAS does not go to standby mode?]<br />
<br />
* [https://forum.qnapclub.de/thread/40517-3-sammelthema-probleme-mit-festplatten-standby-1-beitrag-beachten/?pageNo=1 Probleme mit Festplatten-Standby]<br />
<br />
=== Cron ===<br />
<br />
* https://www.techandme.se/qnap-and-cron/</div>Holyheadhttps://holyhead.de/index.php?title=QNAP_(431p)QNAP (431p)2017-03-07T23:34:16Z<p>Holyhead: </p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
=== Raid sync speed ===<br />
<br />
https://forum.qnap.com/viewtopic.php?t=10268<br />
<br />
cat /proc/mdstat<br />
<br />
cat /proc/sys/dev/raid/speed_limit_max<br />
200000<br />
cat /proc/sys/dev/raid/speed_limit_min<br />
5000<br />
<br />
=== HDD spin down issues ===<br />
<br />
* [https://www.qnap.com/en-us/qa/con_show.php?op=showone&cid=58 Why the hard drive of NAS does not go to standby mode?]<br />
<br />
=== Cron ===<br />
<br />
* https://www.techandme.se/qnap-and-cron/</div>Holyheadhttps://holyhead.de/index.php?title=QNAP_(431p)QNAP (431p)2017-03-07T22:59:23Z<p>Holyhead: /* HDD spin down issues */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
=== Raid sync speed ===<br />
<br />
https://forum.qnap.com/viewtopic.php?t=10268<br />
<br />
cat /proc/mdstat<br />
<br />
cat /proc/sys/dev/raid/speed_limit_max<br />
200000<br />
cat /proc/sys/dev/raid/speed_limit_min<br />
5000<br />
<br />
=== HDD spin down issues ===<br />
<br />
* [https://www.qnap.com/en-us/qa/con_show.php?op=showone&cid=58 Why the hard drive of NAS does not go to standby mode?]</div>Holyheadhttps://holyhead.de/index.php?title=QNAP_(431p)QNAP (431p)2017-03-07T22:57:15Z<p>Holyhead: </p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
=== Raid sync speed ===<br />
<br />
https://forum.qnap.com/viewtopic.php?t=10268<br />
<br />
cat /proc/mdstat<br />
<br />
cat /proc/sys/dev/raid/speed_limit_max<br />
200000<br />
cat /proc/sys/dev/raid/speed_limit_min<br />
5000<br />
<br />
=== HDD spin down issues ===<br />
<br />
* [https://www.qnap.com/de-de/qa/con_show.php?op=showone&cid=58 Warum wechseln Sie Turbo NAS-Festplatten nicht in den Bereitschaftsmodus?]</div>Holyheadhttps://holyhead.de/index.php?title=QNAP_(431p)QNAP (431p)2017-03-06T23:15:01Z<p>Holyhead: Holyhead moved page QNAP431p to QNAP (431p)</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
=== Raid sync speed ===<br />
<br />
https://forum.qnap.com/viewtopic.php?t=10268<br />
<br />
cat /proc/mdstat<br />
<br />
cat /proc/sys/dev/raid/speed_limit_max<br />
200000<br />
cat /proc/sys/dev/raid/speed_limit_min<br />
5000</div>Holyheadhttps://holyhead.de/index.php?title=QNAP431pQNAP431p2017-03-06T23:15:01Z<p>Holyhead: Holyhead moved page QNAP431p to QNAP (431p)</p>
<hr />
<div>#REDIRECT [[QNAP (431p)]]</div>Holyheadhttps://holyhead.de/index.php?title=QNAP_(431p)QNAP (431p)2017-03-06T23:14:34Z<p>Holyhead: /* Raid sync speed */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
=== Raid sync speed ===<br />
<br />
https://forum.qnap.com/viewtopic.php?t=10268<br />
<br />
cat /proc/mdstat<br />
<br />
cat /proc/sys/dev/raid/speed_limit_max<br />
200000<br />
cat /proc/sys/dev/raid/speed_limit_min<br />
5000</div>Holyheadhttps://holyhead.de/index.php?title=QNAP_(431p)QNAP (431p)2017-03-06T23:13:07Z<p>Holyhead: Created page with "== Raid sync speed == https://forum.qnap.com/viewtopic.php?t=10268 cat /proc/mdstat cat /proc/sys/dev/raid/speed_limit_max 200000 cat /proc/sys/dev/raid/speed_limit_min..."</p>
<hr />
<div>== Raid sync speed ==<br />
<br />
https://forum.qnap.com/viewtopic.php?t=10268<br />
<br />
cat /proc/mdstat<br />
<br />
cat /proc/sys/dev/raid/speed_limit_max<br />
200000<br />
cat /proc/sys/dev/raid/speed_limit_min<br />
5000</div>Holyheadhttps://holyhead.de/index.php?title=Main_PageMain Page2017-03-06T23:11:06Z<p>Holyhead: /* QNAP 431p = */</p>
<hr />
<div>=== QNAP 431p ===<br />
<br />
My personal links, hints, tips and programs collection for my [[QNAP431p]].<br />
<br />
===Raspberry Pi===<br />
<br />
My personal links, hints, tips and programs collection for my [[Raspberry Pi]].<br />
<br />
===Networked Media Tank Popcorn Hour A-110===<br />
<br />
My personal links, hints, tips and programs collection for the [[NetworkedMediaTank|Networked Media Tank Popcorn Hour A-110]].<br />
<br/>Note: some items may be outdated...<br />
<br />
===Why Holyhead?===<br />
<br />
Holyhead is the nickname I used in my [http://www.irc.org/ IRC] days.<br />
I ''borrowed'' it from a German folk rock band called [http://www.paddy.de/ Paddy Goes To Holyhead].</div>Holyheadhttps://holyhead.de/index.php?title=Main_PageMain Page2017-03-06T23:10:55Z<p>Holyhead: </p>
<hr />
<div>== QNAP 431p ===<br />
<br />
My personal links, hints, tips and programs collection for my [[QNAP431p]].<br />
<br />
===Raspberry Pi===<br />
<br />
My personal links, hints, tips and programs collection for my [[Raspberry Pi]].<br />
<br />
===Networked Media Tank Popcorn Hour A-110===<br />
<br />
My personal links, hints, tips and programs collection for the [[NetworkedMediaTank|Networked Media Tank Popcorn Hour A-110]].<br />
<br/>Note: some items may be outdated...<br />
<br />
===Why Holyhead?===<br />
<br />
Holyhead is the nickname I used in my [http://www.irc.org/ IRC] days.<br />
I ''borrowed'' it from a German folk rock band called [http://www.paddy.de/ Paddy Goes To Holyhead].</div>Holyheadhttps://holyhead.de/index.php?title=Raspberry_PiRaspberry Pi2016-10-24T05:07:18Z<p>Holyhead: /* Some links (aka bookmark lists) */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
===External USB drives===<br />
<br />
* Automount USB-Drives in Raspbian<br />
** One may use [http://selfprogramming.bplaced.net/index.php/2012/10/23/automount-usb-drives-in-raspbian/ USBmount and autofs]<br />
** I prefer [http://ignorantguru.github.io/udevil/ udevil], see below<br />
<br />
* Install ''ntfs-3g'' if you need write access to ntfs file systems<br />
<br />
* How to increase performance?<br />
** Mount with option ''''noatime'''' or ''''relatime''''<br />
** Mount ''without'' option sync (e.g. keep default async)<br />
** If using ntfs-3g (fuse) file system, try mounting with option 'big_writes', see for example http://obihoernchen.net/wordpress/tag/big_writes/<br />
<br />
===[http://ignorantguru.github.io/udevil/ udevil]===<br />
<br />
* example for manual mounting:<br />
<br />
udevil mount /dev/sda1<br />
<br />
* auto-mounting via udev-rule, see for example http://lsdlinux.org/wiki/doku.php?id=auto_mounting#using_udev_rule (I just copied the 95-udevil-mount.rules file from an OpenElec installation (http://www.raspberrypi.org/downloads) )<br />
<br />
* my build-steps (maybe there's a simpler way, but this worked...):<br />
** download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget<br />
** extract deb-package via <code>ar vx udevil_0.4.3-1_all.deb</code><br />
** extract data archive <code>tar xzvf data.tar.gz</code><br />
** change to tar usr/share/devil/src<br />
** untar <code>tar xvfJ udevil-current.tar.xz</code><br />
** <code>cd udevil-0.4.3</code><br />
** <code>mv distros/debian</code><br />
** execute <code>dpkg-buildpackage</code><br />
** 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<br />
** Install via <code>sudo dpkg -i udevil_0.4.3-1_armhf.deb</code><br />
<br />
===Samba server / NAS===<br />
<br />
* How to install?<br />
** [http://jankarres.de/2013/11/raspberry-pi-samba-server-installieren/ | Raspberry Pi: Samba Server installieren] (German)<br />
** [http://www.welzels.de/blog/projekte/raspberry-pi/low-budget-nas-mit-einem-raspberry-pi/ Low Budget NAS mit einem Raspberry PI] (German)<br />
<br />
* Slow disc performance?<br />
** see 'Slow USB drives' above<br />
** 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!)<br />
<br />
* Configuration and tuning<br />
** https://calomel.org/samba.html<br />
** https://calomel.org/samba_optimize.html<br />
<br />
* If your /var/log/samba/log.smbd fills up with ''printing/print_cups.c:110(cups_connect) Unable to connect to CUPS server localhost'' messages, try http://www.sotechdesign.com.au/samba-log-showing-error-failed-to-retrieve-printer-list/<br/>I also created an empty <code>/etc/printcap</code> to avoid ''Unable to open printcap file /etc/printcap for read'' messages.<br />
<br />
* I don't need sound:<br />
<br />
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf <br />
# I don't need sound<br />
blacklist snd<br />
blacklist snd_pcm<br />
blacklist snd_soc_core<br />
blacklist snd_soc_bcm2708_i2s<br />
<br />
===Trying to reduce number of disk writes (SD card)===<br />
<br />
I'm using [http://oss.oetiker.ch/rrdtool/ 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).<br />
<br />
Here's what I've done:<br />
<br />
* Edit <code>/etc/default/cron</code> and set <code>EXTRA_OPTS="-L 0"</code> to disable logging (I don't need these)<br />
* Avoid entries like <code>pam_unix(cron:session): session closed for user pi</code> in <code>/var/log/auth.log</code><br />
** Edit <code>/etc/pam.d/cron</code> and comment the line <code>@include common-session-noninteractive</code> ([http://ubuntuforums.org/showthread.php?t=1256801])<br />
:or<br />
:* Edit <code>/etc/pam.d/common-session-noninteractive</code> as shown here: http://ubuntuforums.org/showthread.php?t=1256801&p=10283830#post10283830<br />
* I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)<br />
** moved all the .rrd files as well as the created images to my persistent-ramdisk location<br />
** moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links<br />
*** <code>/var/spool</code><br />
*** <code>/var/log</code><br />
*** <code>/var/cache/samba</code><br />
** edited <code>/etc/insserv.conf</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:<br />
<br />
$local_fs_orig +mountall +mountall-bootclean +mountoverflowtmp +umountfs<br />
# we need the sym-link data in /var/log and /var/spool to be available<br />
$local_fs $local_fs_orig +persist-ramdisk<br />
<br />
:: <code>/etc/init.d/persist-ramdisk</code> 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.<br />
<br />
:* set ''RAMTMP'' to yes in <code>/etc/default/tmpfs</code> to get tempfs based <code>/tmp</code><br />
<br />
Before changing <code>/tmp</code>:<br />
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').<br />
::I need to do more digging...<br />
<br />
After changing <code>/tmp</code>:<br />
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...<br />
<br />
===Useful stuff and Q&A===<br />
<br />
* Q: Why does my Pi restart when hotplugging a USB drive?<br />
** http://thestuffsido.blogspot.de/2013/05/fixing-raspberry-pi-hotplugging.html<br />
** http://therandomlab.blogspot.de/2013/01/raspberry-pi-mod-to-avoid-shutdown-on.html<br />
<br />
* Q: Does Raspberry support WOL?<br />
: A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)<br />
<br />
* Q: The new password is to short, or too simple<br />
: A: Try adjusting the PAM settings in <code>/etc/pam.d/common-password</code>:<br />
:* remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)<br />
::<code>password [success=1 default=ignore] pam_unix.so sha512 minlen=2</code><br />
<br />
::!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!<br><br />
::But it's nice for testing (if you cannot or do not want to use auto-login.)<br />
<br />
* Q: How to configure static IP?<br />
: A: In /etc/network/interfaces:<br />
::<code>iface eth0 inet static<br>address 192.168.0.31<br>netmask 255.255.255.0<br>gateway 192.168.0.1</code><br />
<br />
* Q: How to read core temperature, etc?<br />
: A: [http://elinux.org/RPI_vcgencmd_usage vcgencmd]:<br />
::<code>vcgencmd measure_temp<br>vcgencmd measure_clock arm</code><br />
<br />
* External USB HDD spin down<br />
** hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)<br />
** hd-idle works:<br />
::<code>hd-idle -a sda -i 600</code><br />
:: for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)<br />
<br />
* Q: How to avoid update of a certain package?<br />
: A: Put package on hold ([http://debiananwenderhandbuch.de/dpkg.html] (German)):<br />
::<code>echo <packagename> "hold" | dpkg --set-selections</code><br />
<br />
* [[wikipedia:Raspcontrol]] with nginx<br />
** http://www.foxplex.com/sites/raspcontrol-webinterface-auf-dem-raspberry-pi/ (German), http://www.foxplex.com/sites/performanter-nginx-webserver-auf-dem-raspberry-pi-mit-php-und-apc/ (German)<br />
** http://menzerath.eu/artikel/raspberry-pi-raspcontrol-installation-funktionen/ (German)<br />
<br />
* Q: How many bytes are written to my (SD) disc?<br />
: A: Use <code>iostat</code> http://www.mybinarylife.net/2012/08/linux-iostat-command.html<br />
: A: Use <code>iotop</code> http://guichaz.free.fr/iotop/<br />
: A: Raw data of the kernel can be found in files <code>/proc/diskstats</code> and <code>/sys/block/DEVNAME/stat</code> https://www.kernel.org/doc/Documentation/iostats.txt<br />
:* http://unix.stackexchange.com/questions/86391/how-to-get-total-number-of-bytes-sectors-blocks-written-to-disk-since-booting<br />
:* http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux<br />
<br />
* Q: How to reduce number of ext-fs checks?<br />
: A: <code>tune2fs -c 60 /dev/sda1</code> Change maximum mount count to 60<br />
: A: <code>tune2fs -i 12m /dev/sda1</code> Change check interval to 12 months<br />
: fore more details: http://wiki.ubuntuusers.de/Dateisystemcheck (German)<br />
<br />
* Q: Fix smsc95xx 1-1.1:1.0: eth0: kevent 2 may have been dropped <br />
: A: http://wood1978.techarea.org/~wood/wordpress/2013/04/03/fix-smsc95xx-1-1-11-0-eth0-kevent-2-may-have-been-dropped-on-raspberry-pi-with-arch-linux<br />
::Modifying the sysctl.conf values reduced the kevent-2 messages; I did not yet set smsc95xx.turbo_mode=N<br />
<br />
===Overclocking===<br />
<br />
* I only set overclocking via <code>raspi-config</code><br />
<br />
* ''Turbo'': (Short) Raspberry stress test were ok. But I got an SD card error/corruption when doing a download and a dd-image of the SD card (according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907 the SD card error could be OC related.)<br />
::Luckily, I could recover all my data, see below.<br />
<br />
* '' Medium'': Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907] and its links).<br />
<br />
* Underclocking to 600 MHz<br />
:<code>echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</code><br />
: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.<br />
<br />
* Adjusting the ondemand-governor<br />
** https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt<br />
** set <code>/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor</code> to 10 [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&start=800]<br />
**: I had hoped this reduces the 1-wire CRC errors/device-disconnects problems, but with heavy (IO-) load (e.g. backup), 1wire sensors still get disconnected.<br />
<br />
* [http://moze.free.fr/blog/index.php?post/2013/02/Underclock-and-Overclock Nice power consumption analysis]<br />
<br />
====Stress test and benchmarks====<br />
<br />
* [http://www.roylongbottom.org.uk/ Roy Longbottom's PC Benchmark Collection]<br />
* [http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm Raspberry Pi Stress Tests]<br />
<br />
===SD card issues===<br />
<br />
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). I could still use this card for some time (see below), but finally I got a corrupted file system and could no longer repair it. That's when I re-installed Raspbian on a new SD card.<br />
<br />
Maybe I should try [http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ running from USB] sometime?<br />
<br />
====Recovery====<br />
* Creating a binary image of the SD card with my PC using [http://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] resulted in IO errors at about 17%.<br />
* 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 <code>dd conv=sync,noerror if=/dev/sdb2 of=rasp-image.img bs=1M</code> on my Linux machine (option <code>conv=noerror</code> ignores any errors, sync pads read-errors with zeros). The resulting image could not be mounted using a loop device. <br />
* Fortunately, <code>fsck.ext4 raspberry-image.bin</code> was able to repair the image, which I then could successfully mount on my Linux machine using <code>mount -o loop rasp-image.img /mnt</code>, and at a first glance, everything looked ok. So, I was at least able to get to my data. <br />
* On a later 'event', I dd-ed the repaired image back to the Raspberry, and could boot again.<br />
* On another a later 'event', I just fsck-ed the /dev/sdb2 using Linux, and could boot again... but I did not have luck this time - some files were gone.<br />
* 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.<br />
* My Raspberry successfully booted from this new image. I then used <code>raspi-config</code> to expand the root-fs (I've done this on my first installation as well). With Linux I was able to <code>dd</code> my repaired image to the repaired SD. The card booted as if nothing had happened...<br />
* But after some weeks, my Raspberry fried the SD card again, and some weeks later again ... And finally I could not get my pi to boot with this card. However, I can still read the data linux. Moving data to a new card... (easier said than done if the new card is slightly smaller... but, see below for resizing... and sometimes a fresh install is even less painful).<br />
<br />
===Reminders: dd, dd_rescue, losetup, mount and others===<br />
* Example partition table printed by fdisk:<br />
<code><br />
/dev/sdb: 7861 MB, 7861174272 bytes, 15353856 sectors<br />
Units = Sektoren of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
<br />
Gerät boot. Anfang Ende Blöcke Id System<br />
[...]<br />
/dev/sdb3 15288320 15353855 32768 83 Linux</code><br />
:Byte-offset of sdb3: 7827619840 = 15288320 * 512<br />
<br />
* Mount partition to /dev/loopN partition for repair, etc.<br />
:<code>losetup -o 7827619840 --find --show /dev/sdb</code><br />
:--show prints the used /dev/loopN device<br />
<br />
* Directly mount partition using loop device:<br />
:<code>mount -o loop,offset=7827619840 /dev/sdb /mnt</code><br />
* http://www.garloff.de/kurt/linux/ddrescue/<br />
* http://softwarebakery.com/shrinking-images-on-linux<br />
* http://www.tehfear.com/2007/10/08/resize-loop-disk-image/<br />
* http://wiki.ubuntuusers.de/dd (German)<br />
* http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device<br />
<br />
===Some 1-Wire Stuff===<br />
<br />
====Temperature Sensor DS1820====<br />
<br />
* How to?<br />
** http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/<br />
** https://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&start=1 (German)<br />
** http://kopfkino.irosaurus.com/tutorial-ds18s20-temperatur-sensor-an-einem-raspberry-pi/ (German)<br />
** http://raspberrywebserver.com/cgiscripting/rpi-temperature-logger/<br />
** http://elinux.org/RPi_Low-level_peripherals<br />
** http://www.sdyoung.com/home/using-1-wire-ds18b20par-sensors-in-parasitic-mode-on-raspi-with-custom-gpio-pin/ (German)<br />
* I have two DS18B20 and log temperatures using rrdtool.<br />
<br />
* 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). <br />
** Q: Is this due to overclocking with using dynamic governor?<br />
** A: No - also occurs without overclocking (but less frequent?)<br />
** Q: Or is this due to voltage-problems?<br />
** A: No - also occurs without over-voltage<br />
** Q: Or something else?<br />
** 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). Using 3 sensors works almost all the time (without overclocking), but using 4 or more sensors (2 connected star topologies, very bad for 1-wire [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]), almost always fails to read values on most of the sensors.<br />
** A:'''Implement multiple 1-wire interfaces''' (see below), using 1 for each star-topology solved the problem. Reading 2x3 works perfect!<br />
** A: If not adding new devices, disabling 1-wire search after module-loading resolves the device-disconnect issue. Simply put<br />
::<code>wire search_count=5</code><br />
:: in your <code>/etc/modules</code> (I'm not using DTB) to allow only 5 (initial) searches.<br />
<br />
====Multiple 1-wire buses====<br />
:* Inspired and guided by http://www.raspberrypi.org/forums/viewtopic.php?p=513312#p513312, I've patched my 3.12.y kernel <code>arch/arm/mach-bcm2708/bcm2708.c</code> (patch file http://holyhead.de/RaspberryPi/bcm2708-multiple_w-1.patch-3.12.21.txt). Applying this patch to newer kernel versions is straight forward. (Currently I'm running 4.1.10 without device tree.)<br />
::* Note: Some kernel versions ago, device trees were introduced for Raspbian, see for example http://www.raspberrypi.org/documentation/configuration/device-tree.md<BR>So far, I don't know if this works with device trees.<br />
:* I've cross-compiled the kernel on a linux-VM, using the instructions of http://elinux.org/RPi_Kernel_Compilation (compiling on the RaspberryPi takes 6 hours [http://wiki.gentoo.org/wiki/Raspberry_Pi_Kernel_Compilation] or much more [http://elinux.org/RPi_Kernel_Compilation]).<br />
<br />
====Some 1-wire internals====<br />
* https://www.kernel.org/doc/Documentation/w1/w1.generic<br />
* [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]<br />
* http://blog.gegg.us/2013/03/4-different-methods-of-1-wire-access-on-raspberry-pi/<br />
<br />
===Compiling own kernel===<br />
<br />
* Some hints on cross-compiling:<br />
:* http://elinux.org/RPi_Kernel_Compilation<br />
:* https://github.com/raspberrypi/linux/tree/rpi-3.12.y/arch/arm/mach-bcm2708<br />
:* https://github.com/notro/rpi-source/wiki<br />
:* https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489&start=75<br />
:* http://www.bootc.net/projects/raspberry-pi-kernel/<br />
:* http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-recompile.html<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-cross-compile.html<br />
:* http://www.gtkdb.de/index_36_2087.html<br />
<br />
* extract kernel config from image:<br />
::<code>scripts/extract-ikconfig kernel-image</code><br />
::*(extract-ikconfig is part of the kernel sources)<br />
::*newer kernels may store their config in a module: modules/4.*/kernel/kernel/configs.ko<br />
<br />
===Device Trees===<br />
<br />
:* http://www.raspberrypi.org/documentation/configuration/device-tree.md<br />
:* https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt<br />
<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=97216<br />
:* http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f<br />
:* http://www.forum-raspberrypi.de/Thread-tutorial-geraetetreiber-und-device-tree-dt (German)<br />
<br />
:* http://xillybus.com/tutorials/device-tree-zynq-1<br />
<br />
===What about updates?===<br />
<br />
As I always forget this<br />
* <code>apt-get update</code> - update package lists<br />
* <code>apt-get upgrade</code> - upgrade installed packages<br />
* <code>rpi-update</code> - update kernel and modules<br />
::use <code>SKIP_KERNEL=1 rpi-update</code> to update the RPi firmware, but keep the current kernel<br />
::set <code>SKIP_REPODELETE=1</code> to keep downloaded files (by default: <code>/root/.rpi-firmware</code>)<br />
<br />
Kernel Sources<br />
* https://github.com/notro/rpi-source gets the source data from https://github.com/Hexxeh/rpi-firmware and https://github.com/raspberrypi/linux/<br />
<br />
===Hints for reading Kernel Panics===<br />
<br />
* http://ptgmedia.pearsoncmg.com/images/013147751X/downloads/013147751X_book.pdf<br />
: p290:<br />
export CONFIG_DEBUG_INFO=1<br />
make kernel/sysctl.o<br />
objdump -d -S kernel/sysctl.o > kernel/sysctl.dump<br />
<br />
or, with my in cross-compiling setup:<br />
<br />
DOMAKE drivers/w1/slave/w1_therm.o<br />
${CCPREFIX}objdump -d -S w1_therm.o <br />
<br />
* http://www.opensourceforu.com/2011/01/understanding-a-kernel-oops/<br />
<br />
* http://www.lowlevel.eu/wiki/ARM-OS-Dev_Teil_2_%E2%80%93_Assembler_101<br />
<br />
==Attaching a LCD display (HD44780 controller)==<br />
<br />
===Wiring and Specs===<br />
<br />
* Specs<br />
** ftp://imall.iteadstudio.com/IM120424018_EONE_2004_Characters_LCD/SPE_IM120424018_EONE_2004_Characters_LCD.pdf<br />
** http://www.adafruit.com/datasheets/HD44780.pdf<br />
<br />
* http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display (German)<br />
<br />
* http://www.pro-linux.de/artikel/2/1624/5,die-anzeige-hardware-und-software.html<br />
<br />
* https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring<br />
<br />
* https://github.com/perryflynn/raspberrypi-misc/tree/master/charlcd_4x20_cmd<br />
<br />
* http://obrazki.elektroda.pl/5028699400_1384164963.jpg<br />
<br />
===Misc===<br />
<br />
* http://www.makerspaceuk.com/lcd-temp-sensor/<br />
<br />
* http://anwendungsentwickler.ws/blog/kategorien/raspberry-pi/4x20-lcd-screen-mit-dem-raspberry-pi.html (German)<br />
<br />
==Controlling the display==<br />
<br />
* Python [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO]<br />
<br />
===LCDProc hints===<br />
<br />
* Pi & GPIO powered HD44780 LCD: http://www.boeeerb.co.uk/pi-lcd/<br />
<br />
* https://metacpan.org/pod/Net::LCDproc<br />
<br />
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=63412<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-user.html<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-dev.html<br />
<br />
* http://tuxgraphics.org/electronics/200504/article375.shtml<br />
<br />
==Todo and Miscellaneous==<br />
<br />
===OpenELEC===<br />
<br />
* http://wiki.openelec.tv/index.php/Guide_to_add_your_own_remote<br />
<br />
===Lirc===<br />
* http://powerpi.de/jede-infrarot-fernbedienung-am-raspberry-pi-2-nutzen-so-installierst-du-guenstig-einen-ir-empfaenger-teil-1/ (German)<br />
<br />
===Backports===<br />
<br />
* https://gist.github.com/martijnvermaat/7864115<br />
* http://superuser.com/questions/644586/how-to-upgrade-to-latest-git-on-debian-7<br />
<br />
===Collection of misc stuff to check - things I might) try sometime===<br />
<br />
* http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/<br />
<br />
* [http://en.wikipedia.org/wiki/F2FS f2fs]<br />
:* [http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=65330 F2fs, Ext4, FAT USB Benchmark]<br />
:* [http://forum.xda-developers.com/showthread.php?t=2697069 File System Performance: F2FS vs EXT4]<br />
<br />
* https://github.com/yuraa/Raspberry-Pi-Heartbeat<br />
<br />
* http://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html<br />
<br />
* [http://www.raspberrypi.org/archives/5282 Mathematica on Raspberry Pi, for free]<br />
:* also works in RasPi emulator, e.g. http://www.heise.de/ct/inhalt/2014/7/160/ (German, teaser to article)<br />
<br />
* NAS/Samba<br />
:* 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:<br />
:<code>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536</code><br />
<br />
* http://linuxtortures.blogspot.fr/2012/06/cross-compiling-and-cross-debugging-c.html<br />
<br />
===Things done===<br />
<br />
* Adjust swap file (size, location -> (ext4) HDD - too slow?): http://manpages.ubuntu.com/manpages/hardy/man8/dphys-swapfile.8.html<br />
<br />
* http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/<br />
* https://wiki.archlinux.org/index.php/SSMTP<br />
<br />
==Some links (aka bookmark lists)==<br />
<br />
Project sites<br />
<br />
* [http://www.cl.cam.ac.uk/projects/raspberrypi/ University of Cambridge / Raspberry Pi Computer Laboratory]<br />
* [https://www.raspiprojekt.de/ raspiprojek] (German)<br />
* http://www.vanheusden.com/misc/rpi.php<br />
<br />
Blogs, forums, etc<br />
* http://www.raspberrypi.org/phpBB3/<br />
* [http://forum.stmlabs.com/forumdisplay.php?fid=6 Stm Labs Forum / Raspbmc]<br />
* [http://www.welzels.de/blog/projekte/raspberry-pi/ Wel!s Blog] (German)<br />
* [http://jankarres.de/category/raspberry-pi/ Raspberry Pi Blog of Jan Karres] (German)<br />
* http://www.forum-raspberrypi.de/ /(German)<br />
* http://raspberrycenter.de/ (German)<br />
* http://archlinuxarm.org/forum/viewforum.php?f=31&sid=57987232ca9177c35eb3ef7fdf6b3341<br />
<br />
* [[wikipedia:Raspberry_Pi Raspberry Pi in Wikipedia]]<br />
<br />
Miscellaneous<br />
<br />
* [http://www.raspberrypi.org/downloads New Out Of Box Software (Recommended)]<br />
* [http://elinux.org/R-Pi_Hub R-Pi_Hub]<br />
* [https://github.com/prasmussen/gdrive Google Drive CLI]<br />
<br />
Manuals<br />
<br />
* https://github.com/raspberrypi/documentation<br />
<br />
* [http://debian-handbook.info/browse/stable/ The Debian Administrator's Handbook]</div>Holyheadhttps://holyhead.de/index.php?title=Raspberry_PiRaspberry Pi2016-10-10T21:44:34Z<p>Holyhead: /* Compiling own kernel */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
===External USB drives===<br />
<br />
* Automount USB-Drives in Raspbian<br />
** One may use [http://selfprogramming.bplaced.net/index.php/2012/10/23/automount-usb-drives-in-raspbian/ USBmount and autofs]<br />
** I prefer [http://ignorantguru.github.io/udevil/ udevil], see below<br />
<br />
* Install ''ntfs-3g'' if you need write access to ntfs file systems<br />
<br />
* How to increase performance?<br />
** Mount with option ''''noatime'''' or ''''relatime''''<br />
** Mount ''without'' option sync (e.g. keep default async)<br />
** If using ntfs-3g (fuse) file system, try mounting with option 'big_writes', see for example http://obihoernchen.net/wordpress/tag/big_writes/<br />
<br />
===[http://ignorantguru.github.io/udevil/ udevil]===<br />
<br />
* example for manual mounting:<br />
<br />
udevil mount /dev/sda1<br />
<br />
* auto-mounting via udev-rule, see for example http://lsdlinux.org/wiki/doku.php?id=auto_mounting#using_udev_rule (I just copied the 95-udevil-mount.rules file from an OpenElec installation (http://www.raspberrypi.org/downloads) )<br />
<br />
* my build-steps (maybe there's a simpler way, but this worked...):<br />
** download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget<br />
** extract deb-package via <code>ar vx udevil_0.4.3-1_all.deb</code><br />
** extract data archive <code>tar xzvf data.tar.gz</code><br />
** change to tar usr/share/devil/src<br />
** untar <code>tar xvfJ udevil-current.tar.xz</code><br />
** <code>cd udevil-0.4.3</code><br />
** <code>mv distros/debian</code><br />
** execute <code>dpkg-buildpackage</code><br />
** 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<br />
** Install via <code>sudo dpkg -i udevil_0.4.3-1_armhf.deb</code><br />
<br />
===Samba server / NAS===<br />
<br />
* How to install?<br />
** [http://jankarres.de/2013/11/raspberry-pi-samba-server-installieren/ | Raspberry Pi: Samba Server installieren] (German)<br />
** [http://www.welzels.de/blog/projekte/raspberry-pi/low-budget-nas-mit-einem-raspberry-pi/ Low Budget NAS mit einem Raspberry PI] (German)<br />
<br />
* Slow disc performance?<br />
** see 'Slow USB drives' above<br />
** 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!)<br />
<br />
* Configuration and tuning<br />
** https://calomel.org/samba.html<br />
** https://calomel.org/samba_optimize.html<br />
<br />
* If your /var/log/samba/log.smbd fills up with ''printing/print_cups.c:110(cups_connect) Unable to connect to CUPS server localhost'' messages, try http://www.sotechdesign.com.au/samba-log-showing-error-failed-to-retrieve-printer-list/<br/>I also created an empty <code>/etc/printcap</code> to avoid ''Unable to open printcap file /etc/printcap for read'' messages.<br />
<br />
* I don't need sound:<br />
<br />
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf <br />
# I don't need sound<br />
blacklist snd<br />
blacklist snd_pcm<br />
blacklist snd_soc_core<br />
blacklist snd_soc_bcm2708_i2s<br />
<br />
===Trying to reduce number of disk writes (SD card)===<br />
<br />
I'm using [http://oss.oetiker.ch/rrdtool/ 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).<br />
<br />
Here's what I've done:<br />
<br />
* Edit <code>/etc/default/cron</code> and set <code>EXTRA_OPTS="-L 0"</code> to disable logging (I don't need these)<br />
* Avoid entries like <code>pam_unix(cron:session): session closed for user pi</code> in <code>/var/log/auth.log</code><br />
** Edit <code>/etc/pam.d/cron</code> and comment the line <code>@include common-session-noninteractive</code> ([http://ubuntuforums.org/showthread.php?t=1256801])<br />
:or<br />
:* Edit <code>/etc/pam.d/common-session-noninteractive</code> as shown here: http://ubuntuforums.org/showthread.php?t=1256801&p=10283830#post10283830<br />
* I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)<br />
** moved all the .rrd files as well as the created images to my persistent-ramdisk location<br />
** moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links<br />
*** <code>/var/spool</code><br />
*** <code>/var/log</code><br />
*** <code>/var/cache/samba</code><br />
** edited <code>/etc/insserv.conf</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:<br />
<br />
$local_fs_orig +mountall +mountall-bootclean +mountoverflowtmp +umountfs<br />
# we need the sym-link data in /var/log and /var/spool to be available<br />
$local_fs $local_fs_orig +persist-ramdisk<br />
<br />
:: <code>/etc/init.d/persist-ramdisk</code> 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.<br />
<br />
:* set ''RAMTMP'' to yes in <code>/etc/default/tmpfs</code> to get tempfs based <code>/tmp</code><br />
<br />
Before changing <code>/tmp</code>:<br />
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').<br />
::I need to do more digging...<br />
<br />
After changing <code>/tmp</code>:<br />
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...<br />
<br />
===Useful stuff and Q&A===<br />
<br />
* Q: Why does my Pi restart when hotplugging a USB drive?<br />
** http://thestuffsido.blogspot.de/2013/05/fixing-raspberry-pi-hotplugging.html<br />
** http://therandomlab.blogspot.de/2013/01/raspberry-pi-mod-to-avoid-shutdown-on.html<br />
<br />
* Q: Does Raspberry support WOL?<br />
: A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)<br />
<br />
* Q: The new password is to short, or too simple<br />
: A: Try adjusting the PAM settings in <code>/etc/pam.d/common-password</code>:<br />
:* remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)<br />
::<code>password [success=1 default=ignore] pam_unix.so sha512 minlen=2</code><br />
<br />
::!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!<br><br />
::But it's nice for testing (if you cannot or do not want to use auto-login.)<br />
<br />
* Q: How to configure static IP?<br />
: A: In /etc/network/interfaces:<br />
::<code>iface eth0 inet static<br>address 192.168.0.31<br>netmask 255.255.255.0<br>gateway 192.168.0.1</code><br />
<br />
* Q: How to read core temperature, etc?<br />
: A: [http://elinux.org/RPI_vcgencmd_usage vcgencmd]:<br />
::<code>vcgencmd measure_temp<br>vcgencmd measure_clock arm</code><br />
<br />
* External USB HDD spin down<br />
** hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)<br />
** hd-idle works:<br />
::<code>hd-idle -a sda -i 600</code><br />
:: for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)<br />
<br />
* Q: How to avoid update of a certain package?<br />
: A: Put package on hold ([http://debiananwenderhandbuch.de/dpkg.html] (German)):<br />
::<code>echo <packagename> "hold" | dpkg --set-selections</code><br />
<br />
* [[wikipedia:Raspcontrol]] with nginx<br />
** http://www.foxplex.com/sites/raspcontrol-webinterface-auf-dem-raspberry-pi/ (German), http://www.foxplex.com/sites/performanter-nginx-webserver-auf-dem-raspberry-pi-mit-php-und-apc/ (German)<br />
** http://menzerath.eu/artikel/raspberry-pi-raspcontrol-installation-funktionen/ (German)<br />
<br />
* Q: How many bytes are written to my (SD) disc?<br />
: A: Use <code>iostat</code> http://www.mybinarylife.net/2012/08/linux-iostat-command.html<br />
: A: Use <code>iotop</code> http://guichaz.free.fr/iotop/<br />
: A: Raw data of the kernel can be found in files <code>/proc/diskstats</code> and <code>/sys/block/DEVNAME/stat</code> https://www.kernel.org/doc/Documentation/iostats.txt<br />
:* http://unix.stackexchange.com/questions/86391/how-to-get-total-number-of-bytes-sectors-blocks-written-to-disk-since-booting<br />
:* http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux<br />
<br />
* Q: How to reduce number of ext-fs checks?<br />
: A: <code>tune2fs -c 60 /dev/sda1</code> Change maximum mount count to 60<br />
: A: <code>tune2fs -i 12m /dev/sda1</code> Change check interval to 12 months<br />
: fore more details: http://wiki.ubuntuusers.de/Dateisystemcheck (German)<br />
<br />
* Q: Fix smsc95xx 1-1.1:1.0: eth0: kevent 2 may have been dropped <br />
: A: http://wood1978.techarea.org/~wood/wordpress/2013/04/03/fix-smsc95xx-1-1-11-0-eth0-kevent-2-may-have-been-dropped-on-raspberry-pi-with-arch-linux<br />
::Modifying the sysctl.conf values reduced the kevent-2 messages; I did not yet set smsc95xx.turbo_mode=N<br />
<br />
===Overclocking===<br />
<br />
* I only set overclocking via <code>raspi-config</code><br />
<br />
* ''Turbo'': (Short) Raspberry stress test were ok. But I got an SD card error/corruption when doing a download and a dd-image of the SD card (according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907 the SD card error could be OC related.)<br />
::Luckily, I could recover all my data, see below.<br />
<br />
* '' Medium'': Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907] and its links).<br />
<br />
* Underclocking to 600 MHz<br />
:<code>echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</code><br />
: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.<br />
<br />
* Adjusting the ondemand-governor<br />
** https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt<br />
** set <code>/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor</code> to 10 [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&start=800]<br />
**: I had hoped this reduces the 1-wire CRC errors/device-disconnects problems, but with heavy (IO-) load (e.g. backup), 1wire sensors still get disconnected.<br />
<br />
* [http://moze.free.fr/blog/index.php?post/2013/02/Underclock-and-Overclock Nice power consumption analysis]<br />
<br />
====Stress test and benchmarks====<br />
<br />
* [http://www.roylongbottom.org.uk/ Roy Longbottom's PC Benchmark Collection]<br />
* [http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm Raspberry Pi Stress Tests]<br />
<br />
===SD card issues===<br />
<br />
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). I could still use this card for some time (see below), but finally I got a corrupted file system and could no longer repair it. That's when I re-installed Raspbian on a new SD card.<br />
<br />
Maybe I should try [http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ running from USB] sometime?<br />
<br />
====Recovery====<br />
* Creating a binary image of the SD card with my PC using [http://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] resulted in IO errors at about 17%.<br />
* 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 <code>dd conv=sync,noerror if=/dev/sdb2 of=rasp-image.img bs=1M</code> on my Linux machine (option <code>conv=noerror</code> ignores any errors, sync pads read-errors with zeros). The resulting image could not be mounted using a loop device. <br />
* Fortunately, <code>fsck.ext4 raspberry-image.bin</code> was able to repair the image, which I then could successfully mount on my Linux machine using <code>mount -o loop rasp-image.img /mnt</code>, and at a first glance, everything looked ok. So, I was at least able to get to my data. <br />
* On a later 'event', I dd-ed the repaired image back to the Raspberry, and could boot again.<br />
* On another a later 'event', I just fsck-ed the /dev/sdb2 using Linux, and could boot again... but I did not have luck this time - some files were gone.<br />
* 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.<br />
* My Raspberry successfully booted from this new image. I then used <code>raspi-config</code> to expand the root-fs (I've done this on my first installation as well). With Linux I was able to <code>dd</code> my repaired image to the repaired SD. The card booted as if nothing had happened...<br />
* But after some weeks, my Raspberry fried the SD card again, and some weeks later again ... And finally I could not get my pi to boot with this card. However, I can still read the data linux. Moving data to a new card... (easier said than done if the new card is slightly smaller... but, see below for resizing... and sometimes a fresh install is even less painful).<br />
<br />
===Reminders: dd, dd_rescue, losetup, mount and others===<br />
* Example partition table printed by fdisk:<br />
<code><br />
/dev/sdb: 7861 MB, 7861174272 bytes, 15353856 sectors<br />
Units = Sektoren of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
<br />
Gerät boot. Anfang Ende Blöcke Id System<br />
[...]<br />
/dev/sdb3 15288320 15353855 32768 83 Linux</code><br />
:Byte-offset of sdb3: 7827619840 = 15288320 * 512<br />
<br />
* Mount partition to /dev/loopN partition for repair, etc.<br />
:<code>losetup -o 7827619840 --find --show /dev/sdb</code><br />
:--show prints the used /dev/loopN device<br />
<br />
* Directly mount partition using loop device:<br />
:<code>mount -o loop,offset=7827619840 /dev/sdb /mnt</code><br />
* http://www.garloff.de/kurt/linux/ddrescue/<br />
* http://softwarebakery.com/shrinking-images-on-linux<br />
* http://www.tehfear.com/2007/10/08/resize-loop-disk-image/<br />
* http://wiki.ubuntuusers.de/dd (German)<br />
* http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device<br />
<br />
===Some 1-Wire Stuff===<br />
<br />
====Temperature Sensor DS1820====<br />
<br />
* How to?<br />
** http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/<br />
** https://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&start=1 (German)<br />
** http://kopfkino.irosaurus.com/tutorial-ds18s20-temperatur-sensor-an-einem-raspberry-pi/ (German)<br />
** http://raspberrywebserver.com/cgiscripting/rpi-temperature-logger/<br />
** http://elinux.org/RPi_Low-level_peripherals<br />
** http://www.sdyoung.com/home/using-1-wire-ds18b20par-sensors-in-parasitic-mode-on-raspi-with-custom-gpio-pin/ (German)<br />
* I have two DS18B20 and log temperatures using rrdtool.<br />
<br />
* 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). <br />
** Q: Is this due to overclocking with using dynamic governor?<br />
** A: No - also occurs without overclocking (but less frequent?)<br />
** Q: Or is this due to voltage-problems?<br />
** A: No - also occurs without over-voltage<br />
** Q: Or something else?<br />
** 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). Using 3 sensors works almost all the time (without overclocking), but using 4 or more sensors (2 connected star topologies, very bad for 1-wire [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]), almost always fails to read values on most of the sensors.<br />
** A:'''Implement multiple 1-wire interfaces''' (see below), using 1 for each star-topology solved the problem. Reading 2x3 works perfect!<br />
** A: If not adding new devices, disabling 1-wire search after module-loading resolves the device-disconnect issue. Simply put<br />
::<code>wire search_count=5</code><br />
:: in your <code>/etc/modules</code> (I'm not using DTB) to allow only 5 (initial) searches.<br />
<br />
====Multiple 1-wire buses====<br />
:* Inspired and guided by http://www.raspberrypi.org/forums/viewtopic.php?p=513312#p513312, I've patched my 3.12.y kernel <code>arch/arm/mach-bcm2708/bcm2708.c</code> (patch file http://holyhead.de/RaspberryPi/bcm2708-multiple_w-1.patch-3.12.21.txt). Applying this patch to newer kernel versions is straight forward. (Currently I'm running 4.1.10 without device tree.)<br />
::* Note: Some kernel versions ago, device trees were introduced for Raspbian, see for example http://www.raspberrypi.org/documentation/configuration/device-tree.md<BR>So far, I don't know if this works with device trees.<br />
:* I've cross-compiled the kernel on a linux-VM, using the instructions of http://elinux.org/RPi_Kernel_Compilation (compiling on the RaspberryPi takes 6 hours [http://wiki.gentoo.org/wiki/Raspberry_Pi_Kernel_Compilation] or much more [http://elinux.org/RPi_Kernel_Compilation]).<br />
<br />
====Some 1-wire internals====<br />
* https://www.kernel.org/doc/Documentation/w1/w1.generic<br />
* [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]<br />
* http://blog.gegg.us/2013/03/4-different-methods-of-1-wire-access-on-raspberry-pi/<br />
<br />
===Compiling own kernel===<br />
<br />
* Some hints on cross-compiling:<br />
:* http://elinux.org/RPi_Kernel_Compilation<br />
:* https://github.com/raspberrypi/linux/tree/rpi-3.12.y/arch/arm/mach-bcm2708<br />
:* https://github.com/notro/rpi-source/wiki<br />
:* https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489&start=75<br />
:* http://www.bootc.net/projects/raspberry-pi-kernel/<br />
:* http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-recompile.html<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-cross-compile.html<br />
:* http://www.gtkdb.de/index_36_2087.html<br />
<br />
* extract kernel config from image:<br />
::<code>scripts/extract-ikconfig kernel-image</code><br />
::*(extract-ikconfig is part of the kernel sources)<br />
::*newer kernels may store their config in a module: modules/4.*/kernel/kernel/configs.ko<br />
<br />
===Device Trees===<br />
<br />
:* http://www.raspberrypi.org/documentation/configuration/device-tree.md<br />
:* https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt<br />
<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=97216<br />
:* http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f<br />
:* http://www.forum-raspberrypi.de/Thread-tutorial-geraetetreiber-und-device-tree-dt (German)<br />
<br />
:* http://xillybus.com/tutorials/device-tree-zynq-1<br />
<br />
===What about updates?===<br />
<br />
As I always forget this<br />
* <code>apt-get update</code> - update package lists<br />
* <code>apt-get upgrade</code> - upgrade installed packages<br />
* <code>rpi-update</code> - update kernel and modules<br />
::use <code>SKIP_KERNEL=1 rpi-update</code> to update the RPi firmware, but keep the current kernel<br />
::set <code>SKIP_REPODELETE=1</code> to keep downloaded files (by default: <code>/root/.rpi-firmware</code>)<br />
<br />
Kernel Sources<br />
* https://github.com/notro/rpi-source gets the source data from https://github.com/Hexxeh/rpi-firmware and https://github.com/raspberrypi/linux/<br />
<br />
===Hints for reading Kernel Panics===<br />
<br />
* http://ptgmedia.pearsoncmg.com/images/013147751X/downloads/013147751X_book.pdf<br />
: p290:<br />
export CONFIG_DEBUG_INFO=1<br />
make kernel/sysctl.o<br />
objdump -d -S kernel/sysctl.o > kernel/sysctl.dump<br />
<br />
or, with my in cross-compiling setup:<br />
<br />
DOMAKE drivers/w1/slave/w1_therm.o<br />
${CCPREFIX}objdump -d -S w1_therm.o <br />
<br />
* http://www.opensourceforu.com/2011/01/understanding-a-kernel-oops/<br />
<br />
* http://www.lowlevel.eu/wiki/ARM-OS-Dev_Teil_2_%E2%80%93_Assembler_101<br />
<br />
==Attaching a LCD display (HD44780 controller)==<br />
<br />
===Wiring and Specs===<br />
<br />
* Specs<br />
** ftp://imall.iteadstudio.com/IM120424018_EONE_2004_Characters_LCD/SPE_IM120424018_EONE_2004_Characters_LCD.pdf<br />
** http://www.adafruit.com/datasheets/HD44780.pdf<br />
<br />
* http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display (German)<br />
<br />
* http://www.pro-linux.de/artikel/2/1624/5,die-anzeige-hardware-und-software.html<br />
<br />
* https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring<br />
<br />
* https://github.com/perryflynn/raspberrypi-misc/tree/master/charlcd_4x20_cmd<br />
<br />
* http://obrazki.elektroda.pl/5028699400_1384164963.jpg<br />
<br />
===Misc===<br />
<br />
* http://www.makerspaceuk.com/lcd-temp-sensor/<br />
<br />
* http://anwendungsentwickler.ws/blog/kategorien/raspberry-pi/4x20-lcd-screen-mit-dem-raspberry-pi.html (German)<br />
<br />
==Controlling the display==<br />
<br />
* Python [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO]<br />
<br />
===LCDProc hints===<br />
<br />
* Pi & GPIO powered HD44780 LCD: http://www.boeeerb.co.uk/pi-lcd/<br />
<br />
* https://metacpan.org/pod/Net::LCDproc<br />
<br />
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=63412<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-user.html<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-dev.html<br />
<br />
* http://tuxgraphics.org/electronics/200504/article375.shtml<br />
<br />
==Todo and Miscellaneous==<br />
<br />
===OpenELEC===<br />
<br />
* http://wiki.openelec.tv/index.php/Guide_to_add_your_own_remote<br />
<br />
===Lirc===<br />
* http://powerpi.de/jede-infrarot-fernbedienung-am-raspberry-pi-2-nutzen-so-installierst-du-guenstig-einen-ir-empfaenger-teil-1/ (German)<br />
<br />
===Backports===<br />
<br />
* https://gist.github.com/martijnvermaat/7864115<br />
* http://superuser.com/questions/644586/how-to-upgrade-to-latest-git-on-debian-7<br />
<br />
===Collection of misc stuff to check - things I might) try sometime===<br />
<br />
* http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/<br />
<br />
* [http://en.wikipedia.org/wiki/F2FS f2fs]<br />
:* [http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=65330 F2fs, Ext4, FAT USB Benchmark]<br />
:* [http://forum.xda-developers.com/showthread.php?t=2697069 File System Performance: F2FS vs EXT4]<br />
<br />
* https://github.com/yuraa/Raspberry-Pi-Heartbeat<br />
<br />
* http://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html<br />
<br />
* [http://www.raspberrypi.org/archives/5282 Mathematica on Raspberry Pi, for free]<br />
:* also works in RasPi emulator, e.g. http://www.heise.de/ct/inhalt/2014/7/160/ (German, teaser to article)<br />
<br />
* NAS/Samba<br />
:* 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:<br />
:<code>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536</code><br />
<br />
* http://linuxtortures.blogspot.fr/2012/06/cross-compiling-and-cross-debugging-c.html<br />
<br />
===Things done===<br />
<br />
* Adjust swap file (size, location -> (ext4) HDD - too slow?): http://manpages.ubuntu.com/manpages/hardy/man8/dphys-swapfile.8.html<br />
<br />
* http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/<br />
* https://wiki.archlinux.org/index.php/SSMTP<br />
<br />
==Some links (aka bookmark lists)==<br />
<br />
Project sites<br />
<br />
* [http://www.cl.cam.ac.uk/projects/raspberrypi/ University of Cambridge / Raspberry Pi Computer Laboratory]<br />
* [https://www.raspiprojekt.de/ raspiprojek] (German)<br />
* http://www.vanheusden.com/misc/rpi.php<br />
<br />
Blogs, forums, etc<br />
* http://www.raspberrypi.org/phpBB3/<br />
* [http://forum.stmlabs.com/forumdisplay.php?fid=6 Stm Labs Forum / Raspbmc]<br />
* [http://www.welzels.de/blog/projekte/raspberry-pi/ Wel!s Blog] (German)<br />
* [http://jankarres.de/category/raspberry-pi/ Raspberry Pi Blog of Jan Karres] (German)<br />
* http://www.forum-raspberrypi.de/ /(German)<br />
* http://raspberrycenter.de/ (German)<br />
* http://archlinuxarm.org/forum/viewforum.php?f=31&sid=57987232ca9177c35eb3ef7fdf6b3341<br />
<br />
* [[wikipedia:Raspberry_Pi Raspberry Pi in Wikipedia]]<br />
<br />
Miscellaneous<br />
<br />
* [http://www.raspberrypi.org/downloads New Out Of Box Software (Recommended)]<br />
* [http://elinux.org/R-Pi_Hub R-Pi_Hub]<br />
<br />
Manuals<br />
<br />
* https://github.com/raspberrypi/documentation<br />
<br />
* [http://debian-handbook.info/browse/stable/ The Debian Administrator's Handbook]</div>Holyheadhttps://holyhead.de/index.php?title=Raspberry_PiRaspberry Pi2016-10-10T05:56:22Z<p>Holyhead: </p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
===External USB drives===<br />
<br />
* Automount USB-Drives in Raspbian<br />
** One may use [http://selfprogramming.bplaced.net/index.php/2012/10/23/automount-usb-drives-in-raspbian/ USBmount and autofs]<br />
** I prefer [http://ignorantguru.github.io/udevil/ udevil], see below<br />
<br />
* Install ''ntfs-3g'' if you need write access to ntfs file systems<br />
<br />
* How to increase performance?<br />
** Mount with option ''''noatime'''' or ''''relatime''''<br />
** Mount ''without'' option sync (e.g. keep default async)<br />
** If using ntfs-3g (fuse) file system, try mounting with option 'big_writes', see for example http://obihoernchen.net/wordpress/tag/big_writes/<br />
<br />
===[http://ignorantguru.github.io/udevil/ udevil]===<br />
<br />
* example for manual mounting:<br />
<br />
udevil mount /dev/sda1<br />
<br />
* auto-mounting via udev-rule, see for example http://lsdlinux.org/wiki/doku.php?id=auto_mounting#using_udev_rule (I just copied the 95-udevil-mount.rules file from an OpenElec installation (http://www.raspberrypi.org/downloads) )<br />
<br />
* my build-steps (maybe there's a simpler way, but this worked...):<br />
** download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget<br />
** extract deb-package via <code>ar vx udevil_0.4.3-1_all.deb</code><br />
** extract data archive <code>tar xzvf data.tar.gz</code><br />
** change to tar usr/share/devil/src<br />
** untar <code>tar xvfJ udevil-current.tar.xz</code><br />
** <code>cd udevil-0.4.3</code><br />
** <code>mv distros/debian</code><br />
** execute <code>dpkg-buildpackage</code><br />
** 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<br />
** Install via <code>sudo dpkg -i udevil_0.4.3-1_armhf.deb</code><br />
<br />
===Samba server / NAS===<br />
<br />
* How to install?<br />
** [http://jankarres.de/2013/11/raspberry-pi-samba-server-installieren/ | Raspberry Pi: Samba Server installieren] (German)<br />
** [http://www.welzels.de/blog/projekte/raspberry-pi/low-budget-nas-mit-einem-raspberry-pi/ Low Budget NAS mit einem Raspberry PI] (German)<br />
<br />
* Slow disc performance?<br />
** see 'Slow USB drives' above<br />
** 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!)<br />
<br />
* Configuration and tuning<br />
** https://calomel.org/samba.html<br />
** https://calomel.org/samba_optimize.html<br />
<br />
* If your /var/log/samba/log.smbd fills up with ''printing/print_cups.c:110(cups_connect) Unable to connect to CUPS server localhost'' messages, try http://www.sotechdesign.com.au/samba-log-showing-error-failed-to-retrieve-printer-list/<br/>I also created an empty <code>/etc/printcap</code> to avoid ''Unable to open printcap file /etc/printcap for read'' messages.<br />
<br />
* I don't need sound:<br />
<br />
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf <br />
# I don't need sound<br />
blacklist snd<br />
blacklist snd_pcm<br />
blacklist snd_soc_core<br />
blacklist snd_soc_bcm2708_i2s<br />
<br />
===Trying to reduce number of disk writes (SD card)===<br />
<br />
I'm using [http://oss.oetiker.ch/rrdtool/ 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).<br />
<br />
Here's what I've done:<br />
<br />
* Edit <code>/etc/default/cron</code> and set <code>EXTRA_OPTS="-L 0"</code> to disable logging (I don't need these)<br />
* Avoid entries like <code>pam_unix(cron:session): session closed for user pi</code> in <code>/var/log/auth.log</code><br />
** Edit <code>/etc/pam.d/cron</code> and comment the line <code>@include common-session-noninteractive</code> ([http://ubuntuforums.org/showthread.php?t=1256801])<br />
:or<br />
:* Edit <code>/etc/pam.d/common-session-noninteractive</code> as shown here: http://ubuntuforums.org/showthread.php?t=1256801&p=10283830#post10283830<br />
* I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)<br />
** moved all the .rrd files as well as the created images to my persistent-ramdisk location<br />
** moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links<br />
*** <code>/var/spool</code><br />
*** <code>/var/log</code><br />
*** <code>/var/cache/samba</code><br />
** edited <code>/etc/insserv.conf</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:<br />
<br />
$local_fs_orig +mountall +mountall-bootclean +mountoverflowtmp +umountfs<br />
# we need the sym-link data in /var/log and /var/spool to be available<br />
$local_fs $local_fs_orig +persist-ramdisk<br />
<br />
:: <code>/etc/init.d/persist-ramdisk</code> 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.<br />
<br />
:* set ''RAMTMP'' to yes in <code>/etc/default/tmpfs</code> to get tempfs based <code>/tmp</code><br />
<br />
Before changing <code>/tmp</code>:<br />
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').<br />
::I need to do more digging...<br />
<br />
After changing <code>/tmp</code>:<br />
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...<br />
<br />
===Useful stuff and Q&A===<br />
<br />
* Q: Why does my Pi restart when hotplugging a USB drive?<br />
** http://thestuffsido.blogspot.de/2013/05/fixing-raspberry-pi-hotplugging.html<br />
** http://therandomlab.blogspot.de/2013/01/raspberry-pi-mod-to-avoid-shutdown-on.html<br />
<br />
* Q: Does Raspberry support WOL?<br />
: A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)<br />
<br />
* Q: The new password is to short, or too simple<br />
: A: Try adjusting the PAM settings in <code>/etc/pam.d/common-password</code>:<br />
:* remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)<br />
::<code>password [success=1 default=ignore] pam_unix.so sha512 minlen=2</code><br />
<br />
::!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!<br><br />
::But it's nice for testing (if you cannot or do not want to use auto-login.)<br />
<br />
* Q: How to configure static IP?<br />
: A: In /etc/network/interfaces:<br />
::<code>iface eth0 inet static<br>address 192.168.0.31<br>netmask 255.255.255.0<br>gateway 192.168.0.1</code><br />
<br />
* Q: How to read core temperature, etc?<br />
: A: [http://elinux.org/RPI_vcgencmd_usage vcgencmd]:<br />
::<code>vcgencmd measure_temp<br>vcgencmd measure_clock arm</code><br />
<br />
* External USB HDD spin down<br />
** hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)<br />
** hd-idle works:<br />
::<code>hd-idle -a sda -i 600</code><br />
:: for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)<br />
<br />
* Q: How to avoid update of a certain package?<br />
: A: Put package on hold ([http://debiananwenderhandbuch.de/dpkg.html] (German)):<br />
::<code>echo <packagename> "hold" | dpkg --set-selections</code><br />
<br />
* [[wikipedia:Raspcontrol]] with nginx<br />
** http://www.foxplex.com/sites/raspcontrol-webinterface-auf-dem-raspberry-pi/ (German), http://www.foxplex.com/sites/performanter-nginx-webserver-auf-dem-raspberry-pi-mit-php-und-apc/ (German)<br />
** http://menzerath.eu/artikel/raspberry-pi-raspcontrol-installation-funktionen/ (German)<br />
<br />
* Q: How many bytes are written to my (SD) disc?<br />
: A: Use <code>iostat</code> http://www.mybinarylife.net/2012/08/linux-iostat-command.html<br />
: A: Use <code>iotop</code> http://guichaz.free.fr/iotop/<br />
: A: Raw data of the kernel can be found in files <code>/proc/diskstats</code> and <code>/sys/block/DEVNAME/stat</code> https://www.kernel.org/doc/Documentation/iostats.txt<br />
:* http://unix.stackexchange.com/questions/86391/how-to-get-total-number-of-bytes-sectors-blocks-written-to-disk-since-booting<br />
:* http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux<br />
<br />
* Q: How to reduce number of ext-fs checks?<br />
: A: <code>tune2fs -c 60 /dev/sda1</code> Change maximum mount count to 60<br />
: A: <code>tune2fs -i 12m /dev/sda1</code> Change check interval to 12 months<br />
: fore more details: http://wiki.ubuntuusers.de/Dateisystemcheck (German)<br />
<br />
* Q: Fix smsc95xx 1-1.1:1.0: eth0: kevent 2 may have been dropped <br />
: A: http://wood1978.techarea.org/~wood/wordpress/2013/04/03/fix-smsc95xx-1-1-11-0-eth0-kevent-2-may-have-been-dropped-on-raspberry-pi-with-arch-linux<br />
::Modifying the sysctl.conf values reduced the kevent-2 messages; I did not yet set smsc95xx.turbo_mode=N<br />
<br />
===Overclocking===<br />
<br />
* I only set overclocking via <code>raspi-config</code><br />
<br />
* ''Turbo'': (Short) Raspberry stress test were ok. But I got an SD card error/corruption when doing a download and a dd-image of the SD card (according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907 the SD card error could be OC related.)<br />
::Luckily, I could recover all my data, see below.<br />
<br />
* '' Medium'': Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907] and its links).<br />
<br />
* Underclocking to 600 MHz<br />
:<code>echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</code><br />
: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.<br />
<br />
* Adjusting the ondemand-governor<br />
** https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt<br />
** set <code>/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor</code> to 10 [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&start=800]<br />
**: I had hoped this reduces the 1-wire CRC errors/device-disconnects problems, but with heavy (IO-) load (e.g. backup), 1wire sensors still get disconnected.<br />
<br />
* [http://moze.free.fr/blog/index.php?post/2013/02/Underclock-and-Overclock Nice power consumption analysis]<br />
<br />
====Stress test and benchmarks====<br />
<br />
* [http://www.roylongbottom.org.uk/ Roy Longbottom's PC Benchmark Collection]<br />
* [http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm Raspberry Pi Stress Tests]<br />
<br />
===SD card issues===<br />
<br />
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). I could still use this card for some time (see below), but finally I got a corrupted file system and could no longer repair it. That's when I re-installed Raspbian on a new SD card.<br />
<br />
Maybe I should try [http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ running from USB] sometime?<br />
<br />
====Recovery====<br />
* Creating a binary image of the SD card with my PC using [http://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] resulted in IO errors at about 17%.<br />
* 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 <code>dd conv=sync,noerror if=/dev/sdb2 of=rasp-image.img bs=1M</code> on my Linux machine (option <code>conv=noerror</code> ignores any errors, sync pads read-errors with zeros). The resulting image could not be mounted using a loop device. <br />
* Fortunately, <code>fsck.ext4 raspberry-image.bin</code> was able to repair the image, which I then could successfully mount on my Linux machine using <code>mount -o loop rasp-image.img /mnt</code>, and at a first glance, everything looked ok. So, I was at least able to get to my data. <br />
* On a later 'event', I dd-ed the repaired image back to the Raspberry, and could boot again.<br />
* On another a later 'event', I just fsck-ed the /dev/sdb2 using Linux, and could boot again... but I did not have luck this time - some files were gone.<br />
* 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.<br />
* My Raspberry successfully booted from this new image. I then used <code>raspi-config</code> to expand the root-fs (I've done this on my first installation as well). With Linux I was able to <code>dd</code> my repaired image to the repaired SD. The card booted as if nothing had happened...<br />
* But after some weeks, my Raspberry fried the SD card again, and some weeks later again ... And finally I could not get my pi to boot with this card. However, I can still read the data linux. Moving data to a new card... (easier said than done if the new card is slightly smaller... but, see below for resizing... and sometimes a fresh install is even less painful).<br />
<br />
===Reminders: dd, dd_rescue, losetup, mount and others===<br />
* Example partition table printed by fdisk:<br />
<code><br />
/dev/sdb: 7861 MB, 7861174272 bytes, 15353856 sectors<br />
Units = Sektoren of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
<br />
Gerät boot. Anfang Ende Blöcke Id System<br />
[...]<br />
/dev/sdb3 15288320 15353855 32768 83 Linux</code><br />
:Byte-offset of sdb3: 7827619840 = 15288320 * 512<br />
<br />
* Mount partition to /dev/loopN partition for repair, etc.<br />
:<code>losetup -o 7827619840 --find --show /dev/sdb</code><br />
:--show prints the used /dev/loopN device<br />
<br />
* Directly mount partition using loop device:<br />
:<code>mount -o loop,offset=7827619840 /dev/sdb /mnt</code><br />
* http://www.garloff.de/kurt/linux/ddrescue/<br />
* http://softwarebakery.com/shrinking-images-on-linux<br />
* http://www.tehfear.com/2007/10/08/resize-loop-disk-image/<br />
* http://wiki.ubuntuusers.de/dd (German)<br />
* http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device<br />
<br />
===Some 1-Wire Stuff===<br />
<br />
====Temperature Sensor DS1820====<br />
<br />
* How to?<br />
** http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/<br />
** https://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&start=1 (German)<br />
** http://kopfkino.irosaurus.com/tutorial-ds18s20-temperatur-sensor-an-einem-raspberry-pi/ (German)<br />
** http://raspberrywebserver.com/cgiscripting/rpi-temperature-logger/<br />
** http://elinux.org/RPi_Low-level_peripherals<br />
** http://www.sdyoung.com/home/using-1-wire-ds18b20par-sensors-in-parasitic-mode-on-raspi-with-custom-gpio-pin/ (German)<br />
* I have two DS18B20 and log temperatures using rrdtool.<br />
<br />
* 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). <br />
** Q: Is this due to overclocking with using dynamic governor?<br />
** A: No - also occurs without overclocking (but less frequent?)<br />
** Q: Or is this due to voltage-problems?<br />
** A: No - also occurs without over-voltage<br />
** Q: Or something else?<br />
** 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). Using 3 sensors works almost all the time (without overclocking), but using 4 or more sensors (2 connected star topologies, very bad for 1-wire [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]), almost always fails to read values on most of the sensors.<br />
** A:'''Implement multiple 1-wire interfaces''' (see below), using 1 for each star-topology solved the problem. Reading 2x3 works perfect!<br />
** A: If not adding new devices, disabling 1-wire search after module-loading resolves the device-disconnect issue. Simply put<br />
::<code>wire search_count=5</code><br />
:: in your <code>/etc/modules</code> (I'm not using DTB) to allow only 5 (initial) searches.<br />
<br />
====Multiple 1-wire buses====<br />
:* Inspired and guided by http://www.raspberrypi.org/forums/viewtopic.php?p=513312#p513312, I've patched my 3.12.y kernel <code>arch/arm/mach-bcm2708/bcm2708.c</code> (patch file http://holyhead.de/RaspberryPi/bcm2708-multiple_w-1.patch-3.12.21.txt). Applying this patch to newer kernel versions is straight forward. (Currently I'm running 4.1.10 without device tree.)<br />
::* Note: Some kernel versions ago, device trees were introduced for Raspbian, see for example http://www.raspberrypi.org/documentation/configuration/device-tree.md<BR>So far, I don't know if this works with device trees.<br />
:* I've cross-compiled the kernel on a linux-VM, using the instructions of http://elinux.org/RPi_Kernel_Compilation (compiling on the RaspberryPi takes 6 hours [http://wiki.gentoo.org/wiki/Raspberry_Pi_Kernel_Compilation] or much more [http://elinux.org/RPi_Kernel_Compilation]).<br />
<br />
====Some 1-wire internals====<br />
* https://www.kernel.org/doc/Documentation/w1/w1.generic<br />
* [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]<br />
* http://blog.gegg.us/2013/03/4-different-methods-of-1-wire-access-on-raspberry-pi/<br />
<br />
===Compiling own kernel===<br />
<br />
* Some hints on cross-compiling:<br />
:* http://elinux.org/RPi_Kernel_Compilation<br />
:* https://github.com/raspberrypi/linux/tree/rpi-3.12.y/arch/arm/mach-bcm2708<br />
:* https://github.com/notro/rpi-source/wiki<br />
:* https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489&start=75<br />
:* http://www.bootc.net/projects/raspberry-pi-kernel/<br />
:* http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-recompile.html<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-cross-compile.html<br />
:* http://www.gtkdb.de/index_36_2087.html<br />
<br />
* extract kernel config from image:<br />
::<code>scripts/extract-ikconfig kernel-image</code><br />
::(extract-ikconfig is part of the kernel sources)<br />
<br />
===Device Trees===<br />
<br />
:* http://www.raspberrypi.org/documentation/configuration/device-tree.md<br />
:* https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt<br />
<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=97216<br />
:* http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f<br />
:* http://www.forum-raspberrypi.de/Thread-tutorial-geraetetreiber-und-device-tree-dt (German)<br />
<br />
:* http://xillybus.com/tutorials/device-tree-zynq-1<br />
<br />
===What about updates?===<br />
<br />
As I always forget this<br />
* <code>apt-get update</code> - update package lists<br />
* <code>apt-get upgrade</code> - upgrade installed packages<br />
* <code>rpi-update</code> - update kernel and modules<br />
::use <code>SKIP_KERNEL=1 rpi-update</code> to update the RPi firmware, but keep the current kernel<br />
::set <code>SKIP_REPODELETE=1</code> to keep downloaded files (by default: <code>/root/.rpi-firmware</code>)<br />
<br />
Kernel Sources<br />
* https://github.com/notro/rpi-source gets the source data from https://github.com/Hexxeh/rpi-firmware and https://github.com/raspberrypi/linux/<br />
<br />
===Hints for reading Kernel Panics===<br />
<br />
* http://ptgmedia.pearsoncmg.com/images/013147751X/downloads/013147751X_book.pdf<br />
: p290:<br />
export CONFIG_DEBUG_INFO=1<br />
make kernel/sysctl.o<br />
objdump -d -S kernel/sysctl.o > kernel/sysctl.dump<br />
<br />
or, with my in cross-compiling setup:<br />
<br />
DOMAKE drivers/w1/slave/w1_therm.o<br />
${CCPREFIX}objdump -d -S w1_therm.o <br />
<br />
* http://www.opensourceforu.com/2011/01/understanding-a-kernel-oops/<br />
<br />
* http://www.lowlevel.eu/wiki/ARM-OS-Dev_Teil_2_%E2%80%93_Assembler_101<br />
<br />
==Attaching a LCD display (HD44780 controller)==<br />
<br />
===Wiring and Specs===<br />
<br />
* Specs<br />
** ftp://imall.iteadstudio.com/IM120424018_EONE_2004_Characters_LCD/SPE_IM120424018_EONE_2004_Characters_LCD.pdf<br />
** http://www.adafruit.com/datasheets/HD44780.pdf<br />
<br />
* http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display (German)<br />
<br />
* http://www.pro-linux.de/artikel/2/1624/5,die-anzeige-hardware-und-software.html<br />
<br />
* https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring<br />
<br />
* https://github.com/perryflynn/raspberrypi-misc/tree/master/charlcd_4x20_cmd<br />
<br />
* http://obrazki.elektroda.pl/5028699400_1384164963.jpg<br />
<br />
===Misc===<br />
<br />
* http://www.makerspaceuk.com/lcd-temp-sensor/<br />
<br />
* http://anwendungsentwickler.ws/blog/kategorien/raspberry-pi/4x20-lcd-screen-mit-dem-raspberry-pi.html (German)<br />
<br />
==Controlling the display==<br />
<br />
* Python [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO]<br />
<br />
===LCDProc hints===<br />
<br />
* Pi & GPIO powered HD44780 LCD: http://www.boeeerb.co.uk/pi-lcd/<br />
<br />
* https://metacpan.org/pod/Net::LCDproc<br />
<br />
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=63412<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-user.html<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-dev.html<br />
<br />
* http://tuxgraphics.org/electronics/200504/article375.shtml<br />
<br />
==Todo and Miscellaneous==<br />
<br />
===OpenELEC===<br />
<br />
* http://wiki.openelec.tv/index.php/Guide_to_add_your_own_remote<br />
<br />
===Lirc===<br />
* http://powerpi.de/jede-infrarot-fernbedienung-am-raspberry-pi-2-nutzen-so-installierst-du-guenstig-einen-ir-empfaenger-teil-1/ (German)<br />
<br />
===Backports===<br />
<br />
* https://gist.github.com/martijnvermaat/7864115<br />
* http://superuser.com/questions/644586/how-to-upgrade-to-latest-git-on-debian-7<br />
<br />
===Collection of misc stuff to check - things I might) try sometime===<br />
<br />
* http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/<br />
<br />
* [http://en.wikipedia.org/wiki/F2FS f2fs]<br />
:* [http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=65330 F2fs, Ext4, FAT USB Benchmark]<br />
:* [http://forum.xda-developers.com/showthread.php?t=2697069 File System Performance: F2FS vs EXT4]<br />
<br />
* https://github.com/yuraa/Raspberry-Pi-Heartbeat<br />
<br />
* http://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html<br />
<br />
* [http://www.raspberrypi.org/archives/5282 Mathematica on Raspberry Pi, for free]<br />
:* also works in RasPi emulator, e.g. http://www.heise.de/ct/inhalt/2014/7/160/ (German, teaser to article)<br />
<br />
* NAS/Samba<br />
:* 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:<br />
:<code>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536</code><br />
<br />
* http://linuxtortures.blogspot.fr/2012/06/cross-compiling-and-cross-debugging-c.html<br />
<br />
===Things done===<br />
<br />
* Adjust swap file (size, location -> (ext4) HDD - too slow?): http://manpages.ubuntu.com/manpages/hardy/man8/dphys-swapfile.8.html<br />
<br />
* http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/<br />
* https://wiki.archlinux.org/index.php/SSMTP<br />
<br />
==Some links (aka bookmark lists)==<br />
<br />
Project sites<br />
<br />
* [http://www.cl.cam.ac.uk/projects/raspberrypi/ University of Cambridge / Raspberry Pi Computer Laboratory]<br />
* [https://www.raspiprojekt.de/ raspiprojek] (German)<br />
* http://www.vanheusden.com/misc/rpi.php<br />
<br />
Blogs, forums, etc<br />
* http://www.raspberrypi.org/phpBB3/<br />
* [http://forum.stmlabs.com/forumdisplay.php?fid=6 Stm Labs Forum / Raspbmc]<br />
* [http://www.welzels.de/blog/projekte/raspberry-pi/ Wel!s Blog] (German)<br />
* [http://jankarres.de/category/raspberry-pi/ Raspberry Pi Blog of Jan Karres] (German)<br />
* http://www.forum-raspberrypi.de/ /(German)<br />
* http://raspberrycenter.de/ (German)<br />
* http://archlinuxarm.org/forum/viewforum.php?f=31&sid=57987232ca9177c35eb3ef7fdf6b3341<br />
<br />
* [[wikipedia:Raspberry_Pi Raspberry Pi in Wikipedia]]<br />
<br />
Miscellaneous<br />
<br />
* [http://www.raspberrypi.org/downloads New Out Of Box Software (Recommended)]<br />
* [http://elinux.org/R-Pi_Hub R-Pi_Hub]<br />
<br />
Manuals<br />
<br />
* https://github.com/raspberrypi/documentation<br />
<br />
* [http://debian-handbook.info/browse/stable/ The Debian Administrator's Handbook]</div>Holyheadhttps://holyhead.de/index.php?title=Raspberry_PiRaspberry Pi2016-01-03T11:33:20Z<p>Holyhead: /* Todo and Miscellaneous */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
===External USB drives===<br />
<br />
* Automount USB-Drives in Raspbian<br />
** One may use [http://selfprogramming.bplaced.net/index.php/2012/10/23/automount-usb-drives-in-raspbian/ USBmount and autofs]<br />
** I prefer [http://ignorantguru.github.io/udevil/ udevil], see below<br />
<br />
* Install ''ntfs-3g'' if you need write access to ntfs file systems<br />
<br />
* How to increase performance?<br />
** Mount with option ''''noatime'''' or ''''relatime''''<br />
** Mount ''without'' option sync (e.g. keep default async)<br />
** If using ntfs-3g (fuse) file system, try mounting with option 'big_writes', see for example http://obihoernchen.net/wordpress/tag/big_writes/<br />
<br />
===[http://ignorantguru.github.io/udevil/ udevil]===<br />
<br />
* example for manual mounting:<br />
<br />
udevil mount /dev/sda1<br />
<br />
* auto-mounting via udev-rule, see for example http://lsdlinux.org/wiki/doku.php?id=auto_mounting#using_udev_rule (I just copied the 95-udevil-mount.rules file from an OpenElec installation (http://www.raspberrypi.org/downloads) )<br />
<br />
* my build-steps (maybe there's a simpler way, but this worked...):<br />
** download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget<br />
** extract deb-package via <code>ar vx udevil_0.4.3-1_all.deb</code><br />
** extract data archive <code>tar xzvf data.tar.gz</code><br />
** change to tar usr/share/devil/src<br />
** untar <code>tar xvfJ udevil-current.tar.xz</code><br />
** <code>cd udevil-0.4.3</code><br />
** <code>mv distros/debian</code><br />
** execute <code>dpkg-buildpackage</code><br />
** 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<br />
** Install via <code>sudo dpkg -i udevil_0.4.3-1_armhf.deb</code><br />
<br />
===Samba server / NAS===<br />
<br />
* How to install?<br />
** [http://jankarres.de/2013/11/raspberry-pi-samba-server-installieren/ | Raspberry Pi: Samba Server installieren] (German)<br />
** [http://www.welzels.de/blog/projekte/raspberry-pi/low-budget-nas-mit-einem-raspberry-pi/ Low Budget NAS mit einem Raspberry PI] (German)<br />
<br />
* Slow disc performance?<br />
** see 'Slow USB drives' above<br />
** 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!)<br />
<br />
* Configuration and tuning<br />
** https://calomel.org/samba.html<br />
** https://calomel.org/samba_optimize.html<br />
<br />
* If your /var/log/samba/log.smbd fills up with ''printing/print_cups.c:110(cups_connect) Unable to connect to CUPS server localhost'' messages, try http://www.sotechdesign.com.au/samba-log-showing-error-failed-to-retrieve-printer-list/<br/>I also created an empty <code>/etc/printcap</code> to avoid ''Unable to open printcap file /etc/printcap for read'' messages.<br />
<br />
* I don't need sound:<br />
<br />
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf <br />
# I don't need sound<br />
blacklist snd<br />
blacklist snd_pcm<br />
blacklist snd_soc_core<br />
blacklist snd_soc_bcm2708_i2s<br />
<br />
===Trying to reduce number of disk writes (SD card)===<br />
<br />
I'm using [http://oss.oetiker.ch/rrdtool/ 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).<br />
<br />
Here's what I've done:<br />
<br />
* Edit <code>/etc/default/cron</code> and set <code>EXTRA_OPTS="-L 0"</code> to disable logging (I don't need these)<br />
* Avoid entries like <code>pam_unix(cron:session): session closed for user pi</code> in <code>/var/log/auth.log</code><br />
** Edit <code>/etc/pam.d/cron</code> and comment the line <code>@include common-session-noninteractive</code> ([http://ubuntuforums.org/showthread.php?t=1256801])<br />
:or<br />
:* Edit <code>/etc/pam.d/common-session-noninteractive</code> as shown here: http://ubuntuforums.org/showthread.php?t=1256801&p=10283830#post10283830<br />
* I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)<br />
** moved all the .rrd files as well as the created images to my persistent-ramdisk location<br />
** moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links<br />
*** <code>/var/spool</code><br />
*** <code>/var/log</code><br />
*** <code>/var/cache/samba</code><br />
** edited <code>/etc/insserv.conf</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:<br />
<br />
$local_fs_orig +mountall +mountall-bootclean +mountoverflowtmp +umountfs<br />
# we need the sym-link data in /var/log and /var/spool to be available<br />
$local_fs $local_fs_orig +persist-ramdisk<br />
<br />
:: <code>/etc/init.d/persist-ramdisk</code> 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.<br />
<br />
:* set ''RAMTMP'' to yes in <code>/etc/default/tmpfs</code> to get tempfs based <code>/tmp</code><br />
<br />
Before changing <code>/tmp</code>:<br />
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').<br />
::I need to do more digging...<br />
<br />
After changing <code>/tmp</code>:<br />
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...<br />
<br />
===Useful stuff and Q&A===<br />
<br />
* Q: Why does my Pi restart when hotplugging a USB drive?<br />
** http://thestuffsido.blogspot.de/2013/05/fixing-raspberry-pi-hotplugging.html<br />
** http://therandomlab.blogspot.de/2013/01/raspberry-pi-mod-to-avoid-shutdown-on.html<br />
<br />
* Q: Does Raspberry support WOL?<br />
: A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)<br />
<br />
* Q: The new password is to short, or too simple<br />
: A: Try adjusting the PAM settings in <code>/etc/pam.d/common-password</code>:<br />
:* remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)<br />
::<code>password [success=1 default=ignore] pam_unix.so sha512 minlen=2</code><br />
<br />
::!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!<br><br />
::But it's nice for testing (if you cannot or do not want to use auto-login.)<br />
<br />
* Q: How to configure static IP?<br />
: A: In /etc/network/interfaces:<br />
::<code>iface eth0 inet static<br>address 192.168.0.31<br>netmask 255.255.255.0<br>gateway 192.168.0.1</code><br />
<br />
* Q: How to read core temperature, etc?<br />
: A: [http://elinux.org/RPI_vcgencmd_usage vcgencmd]:<br />
::<code>vcgencmd measure_temp<br>vcgencmd measure_clock arm</code><br />
<br />
* External USB HDD spin down<br />
** hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)<br />
** hd-idle works:<br />
::<code>hd-idle -a sda -i 600</code><br />
:: for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)<br />
<br />
* Q: How to avoid update of a certain package?<br />
: A: Put package on hold ([http://debiananwenderhandbuch.de/dpkg.html] (German)):<br />
::<code>echo <packagename> "hold" | dpkg --set-selections</code><br />
<br />
* [[wikipedia:Raspcontrol]] with nginx<br />
** http://www.foxplex.com/sites/raspcontrol-webinterface-auf-dem-raspberry-pi/ (German), http://www.foxplex.com/sites/performanter-nginx-webserver-auf-dem-raspberry-pi-mit-php-und-apc/ (German)<br />
** http://menzerath.eu/artikel/raspberry-pi-raspcontrol-installation-funktionen/ (German)<br />
<br />
* Q: How many bytes are written to my (SD) disc?<br />
: A: Use <code>iostat</code> http://www.mybinarylife.net/2012/08/linux-iostat-command.html<br />
: A: Use <code>iotop</code> http://guichaz.free.fr/iotop/<br />
: A: Raw data of the kernel can be found in files <code>/proc/diskstats</code> and <code>/sys/block/DEVNAME/stat</code> https://www.kernel.org/doc/Documentation/iostats.txt<br />
:* http://unix.stackexchange.com/questions/86391/how-to-get-total-number-of-bytes-sectors-blocks-written-to-disk-since-booting<br />
:* http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux<br />
<br />
* Q: How to reduce number of ext-fs checks?<br />
: A: <code>tune2fs -c 60 /dev/sda1</code> Change maximum mount count to 60<br />
: A: <code>tune2fs -i 12m /dev/sda1</code> Change check interval to 12 months<br />
: fore more details: http://wiki.ubuntuusers.de/Dateisystemcheck (German)<br />
<br />
* Q: Fix smsc95xx 1-1.1:1.0: eth0: kevent 2 may have been dropped <br />
: A: http://wood1978.techarea.org/~wood/wordpress/2013/04/03/fix-smsc95xx-1-1-11-0-eth0-kevent-2-may-have-been-dropped-on-raspberry-pi-with-arch-linux<br />
::Modifying the sysctl.conf values reduced the kevent-2 messages; I did not yet set smsc95xx.turbo_mode=N<br />
<br />
===Overclocking===<br />
<br />
* I only set overclocking via <code>raspi-config</code><br />
<br />
* ''Turbo'': (Short) Raspberry stress test were ok. But I got an SD card error/corruption when doing a download and a dd-image of the SD card (according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907 the SD card error could be OC related.)<br />
::Luckily, I could recover all my data, see below.<br />
<br />
* '' Medium'': Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907] and its links).<br />
<br />
* Underclocking to 600 MHz<br />
:<code>echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</code><br />
: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.<br />
<br />
* Adjusting the ondemand-governor<br />
** https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt<br />
** set <code>/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor</code> to 10 [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&start=800]<br />
**: I had hoped this reduces the 1-wire CRC errors/device-disconnects problems, but with heavy (IO-) load (e.g. backup), 1wire sensors still get disconnected.<br />
<br />
* [http://moze.free.fr/blog/index.php?post/2013/02/Underclock-and-Overclock Nice power consumption analysis]<br />
<br />
====Stress test and benchmarks====<br />
<br />
* [http://www.roylongbottom.org.uk/ Roy Longbottom's PC Benchmark Collection]<br />
* [http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm Raspberry Pi Stress Tests]<br />
<br />
===SD card issues===<br />
<br />
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). I could still use this card for some time (see below), but finally I got a corrupted file system and could no longer repair it. That's when I re-installed Raspbian on a new SD card.<br />
<br />
Maybe I should try [http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ running from USB] sometime?<br />
<br />
====Recovery====<br />
* Creating a binary image of the SD card with my PC using [http://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] resulted in IO errors at about 17%.<br />
* 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 <code>dd conv=sync,noerror if=/dev/sdb2 of=rasp-image.img bs=1M</code> on my Linux machine (option <code>conv=noerror</code> ignores any errors, sync pads read-errors with zeros). The resulting image could not be mounted using a loop device. <br />
* Fortunately, <code>fsck.ext4 raspberry-image.bin</code> was able to repair the image, which I then could successfully mount on my Linux machine using <code>mount -o loop rasp-image.img /mnt</code>, and at a first glance, everything looked ok. So, I was at least able to get to my data. <br />
* On a later 'event', I dd-ed the repaired image back to the Raspberry, and could boot again.<br />
* On another a later 'event', I just fsck-ed the /dev/sdb2 using Linux, and could boot again... but I did not have luck this time - some files were gone.<br />
* 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.<br />
* My Raspberry successfully booted from this new image. I then used <code>raspi-config</code> to expand the root-fs (I've done this on my first installation as well). With Linux I was able to <code>dd</code> my repaired image to the repaired SD. The card booted as if nothing had happened...<br />
* But after some weeks, my Raspberry fried the SD card again, and some weeks later again ... And finally I could not get my pi to boot with this card. However, I can still read the data linux. Moving data to a new card... (easier said than done if the new card is slightly smaller... but, see below for resizing... and sometimes a fresh install is even less painful).<br />
<br />
===Reminders: dd, dd_rescue, losetup, mount and others===<br />
* Example partition table printed by fdisk:<br />
<code><br />
/dev/sdb: 7861 MB, 7861174272 bytes, 15353856 sectors<br />
Units = Sektoren of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
<br />
Gerät boot. Anfang Ende Blöcke Id System<br />
[...]<br />
/dev/sdb3 15288320 15353855 32768 83 Linux</code><br />
:Byte-offset of sdb3: 7827619840 = 15288320 * 512<br />
<br />
* Mount partition to /dev/loopN partition for repair, etc.<br />
:<code>losetup -o 7827619840 --find --show /dev/sdb</code><br />
:--show prints the used /dev/loopN device<br />
<br />
* Directly mount partition using loop device:<br />
:<code>mount -o loop,offset=7827619840 /dev/sdb /mnt</code><br />
* http://www.garloff.de/kurt/linux/ddrescue/<br />
* http://softwarebakery.com/shrinking-images-on-linux<br />
* http://www.tehfear.com/2007/10/08/resize-loop-disk-image/<br />
* http://wiki.ubuntuusers.de/dd (German)<br />
* http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device<br />
<br />
===Some 1-Wire Stuff===<br />
<br />
====Temperature Sensor DS1820====<br />
<br />
* How to?<br />
** http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/<br />
** https://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&start=1 (German)<br />
** http://kopfkino.irosaurus.com/tutorial-ds18s20-temperatur-sensor-an-einem-raspberry-pi/ (German)<br />
** http://raspberrywebserver.com/cgiscripting/rpi-temperature-logger/<br />
** http://elinux.org/RPi_Low-level_peripherals<br />
** http://www.sdyoung.com/home/using-1-wire-ds18b20par-sensors-in-parasitic-mode-on-raspi-with-custom-gpio-pin/ (German)<br />
* I have two DS18B20 and log temperatures using rrdtool.<br />
<br />
* 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). <br />
** Q: Is this due to overclocking with using dynamic governor?<br />
** A: No - also occurs without overclocking (but less frequent?)<br />
** Q: Or is this due to voltage-problems?<br />
** A: No - also occurs without over-voltage<br />
** Q: Or something else?<br />
** 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). Using 3 sensors works almost all the time (without overclocking), but using 4 or more sensors (2 connected star topologies, very bad for 1-wire [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]), almost always fails to read values on most of the sensors.<br />
** A:'''Implement multiple 1-wire interfaces''' (see below), using 1 for each star-topology solved the problem. Reading 2x3 works perfect!<br />
** A: If not adding new devices, disabling 1-wire search after module-loading resolves the device-disconnect issue. Simply put<br />
::<code>wire search_count=5</code><br />
:: in your <code>/etc/modules</code> (I'm not using DTB) to allow only 5 (initial) searches.<br />
<br />
====Multiple 1-wire buses====<br />
:* Inspired and guided by http://www.raspberrypi.org/forums/viewtopic.php?p=513312#p513312, I've patched my 3.12.y kernel <code>arch/arm/mach-bcm2708/bcm2708.c</code> (patch file http://holyhead.de/RaspberryPi/bcm2708-multiple_w-1.patch-3.12.21.txt). Applying this patch to newer kernel versions is straight forward. (Currently I'm running 4.1.10 without device tree.)<br />
::* Note: Some kernel versions ago, device trees were introduced for Raspbian, see for example http://www.raspberrypi.org/documentation/configuration/device-tree.md<BR>So far, I don't know if this works with device trees.<br />
:* I've cross-compiled the kernel on a linux-VM, using the instructions of http://elinux.org/RPi_Kernel_Compilation (compiling on the RaspberryPi takes 6 hours [http://wiki.gentoo.org/wiki/Raspberry_Pi_Kernel_Compilation] or much more [http://elinux.org/RPi_Kernel_Compilation]).<br />
<br />
====Some 1-wire internals====<br />
* https://www.kernel.org/doc/Documentation/w1/w1.generic<br />
* [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]<br />
* http://blog.gegg.us/2013/03/4-different-methods-of-1-wire-access-on-raspberry-pi/<br />
<br />
===Compiling own kernel===<br />
<br />
* Some hints on cross-compiling:<br />
:* http://elinux.org/RPi_Kernel_Compilation<br />
:* https://github.com/raspberrypi/linux/tree/rpi-3.12.y/arch/arm/mach-bcm2708<br />
:* https://github.com/notro/rpi-source/wiki<br />
:* https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489&start=75<br />
:* http://www.bootc.net/projects/raspberry-pi-kernel/<br />
:* http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-recompile.html<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-cross-compile.html<br />
:* http://www.gtkdb.de/index_36_2087.html<br />
<br />
* extract kernel config from image:<br />
::<code>scripts/extract-ikconfig kernel-image</code><br />
::(extract-ikconfig is part of the kernel sources)<br />
<br />
===Device Trees===<br />
<br />
:* http://www.raspberrypi.org/documentation/configuration/device-tree.md<br />
:* https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt<br />
<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=97216<br />
:* http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f<br />
:* http://www.forum-raspberrypi.de/Thread-tutorial-geraetetreiber-und-device-tree-dt (German)<br />
<br />
:* http://xillybus.com/tutorials/device-tree-zynq-1<br />
<br />
===What about updates?===<br />
<br />
As I always forget this<br />
* <code>apt-get update</code> - update package lists<br />
* <code>apt-get upgrade</code> - upgrade installed packages<br />
* <code>rpi-update</code> - update kernel and modules<br />
::use <code>SKIP_KERNEL=1 rpi-update</code> to update the RPi firmware, but keep the current kernel<br />
::set <code>SKIP_REPODELETE=1</code> to keep downloaded files (by default: <code>/root/.rpi-firmware</code>)<br />
<br />
Kernel Sources<br />
* https://github.com/notro/rpi-source gets the source data from https://github.com/Hexxeh/rpi-firmware and https://github.com/raspberrypi/linux/<br />
<br />
===Hints for reading Kernel Panics===<br />
<br />
* http://ptgmedia.pearsoncmg.com/images/013147751X/downloads/013147751X_book.pdf<br />
: p290:<br />
export CONFIG_DEBUG_INFO=1<br />
make kernel/sysctl.o<br />
objdump -d -S kernel/sysctl.o > kernel/sysctl.dump<br />
<br />
or, with my in cross-compiling setup:<br />
<br />
DOMAKE drivers/w1/slave/w1_therm.o<br />
${CCPREFIX}objdump -d -S w1_therm.o <br />
<br />
* http://www.opensourceforu.com/2011/01/understanding-a-kernel-oops/<br />
<br />
* http://www.lowlevel.eu/wiki/ARM-OS-Dev_Teil_2_%E2%80%93_Assembler_101<br />
<br />
==Attaching a LCD display (HD44780 controller)==<br />
<br />
===Wiring and Specs===<br />
<br />
* Specs<br />
** ftp://imall.iteadstudio.com/IM120424018_EONE_2004_Characters_LCD/SPE_IM120424018_EONE_2004_Characters_LCD.pdf<br />
** http://www.adafruit.com/datasheets/HD44780.pdf<br />
<br />
* http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display (German)<br />
<br />
* http://www.pro-linux.de/artikel/2/1624/5,die-anzeige-hardware-und-software.html<br />
<br />
* https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring<br />
<br />
* https://github.com/perryflynn/raspberrypi-misc/tree/master/charlcd_4x20_cmd<br />
<br />
* http://obrazki.elektroda.pl/5028699400_1384164963.jpg<br />
<br />
===Misc===<br />
<br />
* http://www.makerspaceuk.com/lcd-temp-sensor/<br />
<br />
* http://anwendungsentwickler.ws/blog/kategorien/raspberry-pi/4x20-lcd-screen-mit-dem-raspberry-pi.html (German)<br />
<br />
==Controlling the display==<br />
<br />
* Python [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO]<br />
<br />
===LCDProc hints===<br />
<br />
* Pi & GPIO powered HD44780 LCD: http://www.boeeerb.co.uk/pi-lcd/<br />
<br />
* https://metacpan.org/pod/Net::LCDproc<br />
<br />
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=63412<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-user.html<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-dev.html<br />
<br />
* http://tuxgraphics.org/electronics/200504/article375.shtml<br />
<br />
==Todo and Miscellaneous==<br />
<br />
===OpenELEC===<br />
<br />
* http://wiki.openelec.tv/index.php/Guide_to_add_your_own_remote<br />
<br />
===Lirc===<br />
* http://powerpi.de/jede-infrarot-fernbedienung-am-raspberry-pi-2-nutzen-so-installierst-du-guenstig-einen-ir-empfaenger-teil-1/ (German)<br />
<br />
===Backports===<br />
<br />
* https://gist.github.com/martijnvermaat/7864115<br />
* http://superuser.com/questions/644586/how-to-upgrade-to-latest-git-on-debian-7<br />
<br />
===Collection of misc stuff to check - things I might) try sometime===<br />
<br />
* http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/<br />
<br />
* [http://en.wikipedia.org/wiki/F2FS f2fs]<br />
:* [http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=65330 F2fs, Ext4, FAT USB Benchmark]<br />
:* [http://forum.xda-developers.com/showthread.php?t=2697069 File System Performance: F2FS vs EXT4]<br />
<br />
* https://github.com/yuraa/Raspberry-Pi-Heartbeat<br />
<br />
* http://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html<br />
<br />
* [http://www.raspberrypi.org/archives/5282 Mathematica on Raspberry Pi, for free]<br />
:* also works in RasPi emulator, e.g. http://www.heise.de/ct/inhalt/2014/7/160/ (German, teaser to article)<br />
<br />
* NAS/Samba<br />
:* 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:<br />
:<code>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536</code><br />
<br />
* http://linuxtortures.blogspot.fr/2012/06/cross-compiling-and-cross-debugging-c.html<br />
<br />
===Things done===<br />
<br />
* Adjust swap file (size, location -> (ext4) HDD - too slow?): http://manpages.ubuntu.com/manpages/hardy/man8/dphys-swapfile.8.html<br />
<br />
* http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/<br />
<br />
==Some links (aka bookmark lists)==<br />
<br />
Project sites<br />
<br />
* [http://www.cl.cam.ac.uk/projects/raspberrypi/ University of Cambridge / Raspberry Pi Computer Laboratory]<br />
* [https://www.raspiprojekt.de/ raspiprojek] (German)<br />
* http://www.vanheusden.com/misc/rpi.php<br />
<br />
Blogs, forums, etc<br />
* http://www.raspberrypi.org/phpBB3/<br />
* [http://forum.stmlabs.com/forumdisplay.php?fid=6 Stm Labs Forum / Raspbmc]<br />
* [http://www.welzels.de/blog/projekte/raspberry-pi/ Wel!s Blog] (German)<br />
* [http://jankarres.de/category/raspberry-pi/ Raspberry Pi Blog of Jan Karres] (German)<br />
* http://www.forum-raspberrypi.de/ /(German)<br />
* http://raspberrycenter.de/ (German)<br />
* http://archlinuxarm.org/forum/viewforum.php?f=31&sid=57987232ca9177c35eb3ef7fdf6b3341<br />
<br />
* [[wikipedia:Raspberry_Pi Raspberry Pi in Wikipedia]]<br />
<br />
Miscellaneous<br />
<br />
* [http://www.raspberrypi.org/downloads New Out Of Box Software (Recommended)]<br />
* [http://elinux.org/R-Pi_Hub R-Pi_Hub]<br />
<br />
Manuals<br />
<br />
* https://github.com/raspberrypi/documentation<br />
<br />
* [http://debian-handbook.info/browse/stable/ The Debian Administrator's Handbook]</div>Holyheadhttps://holyhead.de/index.php?title=Raspberry_PiRaspberry Pi2015-12-29T23:05:22Z<p>Holyhead: /* Backports */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
===External USB drives===<br />
<br />
* Automount USB-Drives in Raspbian<br />
** One may use [http://selfprogramming.bplaced.net/index.php/2012/10/23/automount-usb-drives-in-raspbian/ USBmount and autofs]<br />
** I prefer [http://ignorantguru.github.io/udevil/ udevil], see below<br />
<br />
* Install ''ntfs-3g'' if you need write access to ntfs file systems<br />
<br />
* How to increase performance?<br />
** Mount with option ''''noatime'''' or ''''relatime''''<br />
** Mount ''without'' option sync (e.g. keep default async)<br />
** If using ntfs-3g (fuse) file system, try mounting with option 'big_writes', see for example http://obihoernchen.net/wordpress/tag/big_writes/<br />
<br />
===[http://ignorantguru.github.io/udevil/ udevil]===<br />
<br />
* example for manual mounting:<br />
<br />
udevil mount /dev/sda1<br />
<br />
* auto-mounting via udev-rule, see for example http://lsdlinux.org/wiki/doku.php?id=auto_mounting#using_udev_rule (I just copied the 95-udevil-mount.rules file from an OpenElec installation (http://www.raspberrypi.org/downloads) )<br />
<br />
* my build-steps (maybe there's a simpler way, but this worked...):<br />
** download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget<br />
** extract deb-package via <code>ar vx udevil_0.4.3-1_all.deb</code><br />
** extract data archive <code>tar xzvf data.tar.gz</code><br />
** change to tar usr/share/devil/src<br />
** untar <code>tar xvfJ udevil-current.tar.xz</code><br />
** <code>cd udevil-0.4.3</code><br />
** <code>mv distros/debian</code><br />
** execute <code>dpkg-buildpackage</code><br />
** 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<br />
** Install via <code>sudo dpkg -i udevil_0.4.3-1_armhf.deb</code><br />
<br />
===Samba server / NAS===<br />
<br />
* How to install?<br />
** [http://jankarres.de/2013/11/raspberry-pi-samba-server-installieren/ | Raspberry Pi: Samba Server installieren] (German)<br />
** [http://www.welzels.de/blog/projekte/raspberry-pi/low-budget-nas-mit-einem-raspberry-pi/ Low Budget NAS mit einem Raspberry PI] (German)<br />
<br />
* Slow disc performance?<br />
** see 'Slow USB drives' above<br />
** 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!)<br />
<br />
* Configuration and tuning<br />
** https://calomel.org/samba.html<br />
** https://calomel.org/samba_optimize.html<br />
<br />
* If your /var/log/samba/log.smbd fills up with ''printing/print_cups.c:110(cups_connect) Unable to connect to CUPS server localhost'' messages, try http://www.sotechdesign.com.au/samba-log-showing-error-failed-to-retrieve-printer-list/<br/>I also created an empty <code>/etc/printcap</code> to avoid ''Unable to open printcap file /etc/printcap for read'' messages.<br />
<br />
* I don't need sound:<br />
<br />
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf <br />
# I don't need sound<br />
blacklist snd<br />
blacklist snd_pcm<br />
blacklist snd_soc_core<br />
blacklist snd_soc_bcm2708_i2s<br />
<br />
===Trying to reduce number of disk writes (SD card)===<br />
<br />
I'm using [http://oss.oetiker.ch/rrdtool/ 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).<br />
<br />
Here's what I've done:<br />
<br />
* Edit <code>/etc/default/cron</code> and set <code>EXTRA_OPTS="-L 0"</code> to disable logging (I don't need these)<br />
* Avoid entries like <code>pam_unix(cron:session): session closed for user pi</code> in <code>/var/log/auth.log</code><br />
** Edit <code>/etc/pam.d/cron</code> and comment the line <code>@include common-session-noninteractive</code> ([http://ubuntuforums.org/showthread.php?t=1256801])<br />
:or<br />
:* Edit <code>/etc/pam.d/common-session-noninteractive</code> as shown here: http://ubuntuforums.org/showthread.php?t=1256801&p=10283830#post10283830<br />
* I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)<br />
** moved all the .rrd files as well as the created images to my persistent-ramdisk location<br />
** moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links<br />
*** <code>/var/spool</code><br />
*** <code>/var/log</code><br />
*** <code>/var/cache/samba</code><br />
** edited <code>/etc/insserv.conf</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:<br />
<br />
$local_fs_orig +mountall +mountall-bootclean +mountoverflowtmp +umountfs<br />
# we need the sym-link data in /var/log and /var/spool to be available<br />
$local_fs $local_fs_orig +persist-ramdisk<br />
<br />
:: <code>/etc/init.d/persist-ramdisk</code> 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.<br />
<br />
:* set ''RAMTMP'' to yes in <code>/etc/default/tmpfs</code> to get tempfs based <code>/tmp</code><br />
<br />
Before changing <code>/tmp</code>:<br />
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').<br />
::I need to do more digging...<br />
<br />
After changing <code>/tmp</code>:<br />
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...<br />
<br />
===Useful stuff and Q&A===<br />
<br />
* Q: Why does my Pi restart when hotplugging a USB drive?<br />
** http://thestuffsido.blogspot.de/2013/05/fixing-raspberry-pi-hotplugging.html<br />
** http://therandomlab.blogspot.de/2013/01/raspberry-pi-mod-to-avoid-shutdown-on.html<br />
<br />
* Q: Does Raspberry support WOL?<br />
: A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)<br />
<br />
* Q: The new password is to short, or too simple<br />
: A: Try adjusting the PAM settings in <code>/etc/pam.d/common-password</code>:<br />
:* remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)<br />
::<code>password [success=1 default=ignore] pam_unix.so sha512 minlen=2</code><br />
<br />
::!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!<br><br />
::But it's nice for testing (if you cannot or do not want to use auto-login.)<br />
<br />
* Q: How to configure static IP?<br />
: A: In /etc/network/interfaces:<br />
::<code>iface eth0 inet static<br>address 192.168.0.31<br>netmask 255.255.255.0<br>gateway 192.168.0.1</code><br />
<br />
* Q: How to read core temperature, etc?<br />
: A: [http://elinux.org/RPI_vcgencmd_usage vcgencmd]:<br />
::<code>vcgencmd measure_temp<br>vcgencmd measure_clock arm</code><br />
<br />
* External USB HDD spin down<br />
** hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)<br />
** hd-idle works:<br />
::<code>hd-idle -a sda -i 600</code><br />
:: for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)<br />
<br />
* Q: How to avoid update of a certain package?<br />
: A: Put package on hold ([http://debiananwenderhandbuch.de/dpkg.html] (German)):<br />
::<code>echo <packagename> "hold" | dpkg --set-selections</code><br />
<br />
* [[wikipedia:Raspcontrol]] with nginx<br />
** http://www.foxplex.com/sites/raspcontrol-webinterface-auf-dem-raspberry-pi/ (German), http://www.foxplex.com/sites/performanter-nginx-webserver-auf-dem-raspberry-pi-mit-php-und-apc/ (German)<br />
** http://menzerath.eu/artikel/raspberry-pi-raspcontrol-installation-funktionen/ (German)<br />
<br />
* Q: How many bytes are written to my (SD) disc?<br />
: A: Use <code>iostat</code> http://www.mybinarylife.net/2012/08/linux-iostat-command.html<br />
: A: Use <code>iotop</code> http://guichaz.free.fr/iotop/<br />
: A: Raw data of the kernel can be found in files <code>/proc/diskstats</code> and <code>/sys/block/DEVNAME/stat</code> https://www.kernel.org/doc/Documentation/iostats.txt<br />
:* http://unix.stackexchange.com/questions/86391/how-to-get-total-number-of-bytes-sectors-blocks-written-to-disk-since-booting<br />
:* http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux<br />
<br />
* Q: How to reduce number of ext-fs checks?<br />
: A: <code>tune2fs -c 60 /dev/sda1</code> Change maximum mount count to 60<br />
: A: <code>tune2fs -i 12m /dev/sda1</code> Change check interval to 12 months<br />
: fore more details: http://wiki.ubuntuusers.de/Dateisystemcheck (German)<br />
<br />
* Q: Fix smsc95xx 1-1.1:1.0: eth0: kevent 2 may have been dropped <br />
: A: http://wood1978.techarea.org/~wood/wordpress/2013/04/03/fix-smsc95xx-1-1-11-0-eth0-kevent-2-may-have-been-dropped-on-raspberry-pi-with-arch-linux<br />
::Modifying the sysctl.conf values reduced the kevent-2 messages; I did not yet set smsc95xx.turbo_mode=N<br />
<br />
===Overclocking===<br />
<br />
* I only set overclocking via <code>raspi-config</code><br />
<br />
* ''Turbo'': (Short) Raspberry stress test were ok. But I got an SD card error/corruption when doing a download and a dd-image of the SD card (according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907 the SD card error could be OC related.)<br />
::Luckily, I could recover all my data, see below.<br />
<br />
* '' Medium'': Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907] and its links).<br />
<br />
* Underclocking to 600 MHz<br />
:<code>echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</code><br />
: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.<br />
<br />
* Adjusting the ondemand-governor<br />
** https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt<br />
** set <code>/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor</code> to 10 [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&start=800]<br />
**: I had hoped this reduces the 1-wire CRC errors/device-disconnects problems, but with heavy (IO-) load (e.g. backup), 1wire sensors still get disconnected.<br />
<br />
* [http://moze.free.fr/blog/index.php?post/2013/02/Underclock-and-Overclock Nice power consumption analysis]<br />
<br />
====Stress test and benchmarks====<br />
<br />
* [http://www.roylongbottom.org.uk/ Roy Longbottom's PC Benchmark Collection]<br />
* [http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm Raspberry Pi Stress Tests]<br />
<br />
===SD card issues===<br />
<br />
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). I could still use this card for some time (see below), but finally I got a corrupted file system and could no longer repair it. That's when I re-installed Raspbian on a new SD card.<br />
<br />
Maybe I should try [http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ running from USB] sometime?<br />
<br />
====Recovery====<br />
* Creating a binary image of the SD card with my PC using [http://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] resulted in IO errors at about 17%.<br />
* 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 <code>dd conv=sync,noerror if=/dev/sdb2 of=rasp-image.img bs=1M</code> on my Linux machine (option <code>conv=noerror</code> ignores any errors, sync pads read-errors with zeros). The resulting image could not be mounted using a loop device. <br />
* Fortunately, <code>fsck.ext4 raspberry-image.bin</code> was able to repair the image, which I then could successfully mount on my Linux machine using <code>mount -o loop rasp-image.img /mnt</code>, and at a first glance, everything looked ok. So, I was at least able to get to my data. <br />
* On a later 'event', I dd-ed the repaired image back to the Raspberry, and could boot again.<br />
* On another a later 'event', I just fsck-ed the /dev/sdb2 using Linux, and could boot again... but I did not have luck this time - some files were gone.<br />
* 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.<br />
* My Raspberry successfully booted from this new image. I then used <code>raspi-config</code> to expand the root-fs (I've done this on my first installation as well). With Linux I was able to <code>dd</code> my repaired image to the repaired SD. The card booted as if nothing had happened...<br />
* But after some weeks, my Raspberry fried the SD card again, and some weeks later again ... And finally I could not get my pi to boot with this card. However, I can still read the data linux. Moving data to a new card... (easier said than done if the new card is slightly smaller... but, see below for resizing... and sometimes a fresh install is even less painful).<br />
<br />
===Reminders: dd, dd_rescue, losetup, mount and others===<br />
* Example partition table printed by fdisk:<br />
<code><br />
/dev/sdb: 7861 MB, 7861174272 bytes, 15353856 sectors<br />
Units = Sektoren of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
<br />
Gerät boot. Anfang Ende Blöcke Id System<br />
[...]<br />
/dev/sdb3 15288320 15353855 32768 83 Linux</code><br />
:Byte-offset of sdb3: 7827619840 = 15288320 * 512<br />
<br />
* Mount partition to /dev/loopN partition for repair, etc.<br />
:<code>losetup -o 7827619840 --find --show /dev/sdb</code><br />
:--show prints the used /dev/loopN device<br />
<br />
* Directly mount partition using loop device:<br />
:<code>mount -o loop,offset=7827619840 /dev/sdb /mnt</code><br />
* http://www.garloff.de/kurt/linux/ddrescue/<br />
* http://softwarebakery.com/shrinking-images-on-linux<br />
* http://www.tehfear.com/2007/10/08/resize-loop-disk-image/<br />
* http://wiki.ubuntuusers.de/dd (German)<br />
* http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device<br />
<br />
===Some 1-Wire Stuff===<br />
<br />
====Temperature Sensor DS1820====<br />
<br />
* How to?<br />
** http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/<br />
** https://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&start=1 (German)<br />
** http://kopfkino.irosaurus.com/tutorial-ds18s20-temperatur-sensor-an-einem-raspberry-pi/ (German)<br />
** http://raspberrywebserver.com/cgiscripting/rpi-temperature-logger/<br />
** http://elinux.org/RPi_Low-level_peripherals<br />
** http://www.sdyoung.com/home/using-1-wire-ds18b20par-sensors-in-parasitic-mode-on-raspi-with-custom-gpio-pin/ (German)<br />
* I have two DS18B20 and log temperatures using rrdtool.<br />
<br />
* 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). <br />
** Q: Is this due to overclocking with using dynamic governor?<br />
** A: No - also occurs without overclocking (but less frequent?)<br />
** Q: Or is this due to voltage-problems?<br />
** A: No - also occurs without over-voltage<br />
** Q: Or something else?<br />
** 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). Using 3 sensors works almost all the time (without overclocking), but using 4 or more sensors (2 connected star topologies, very bad for 1-wire [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]), almost always fails to read values on most of the sensors.<br />
** A:'''Implement multiple 1-wire interfaces''' (see below), using 1 for each star-topology solved the problem. Reading 2x3 works perfect!<br />
** A: If not adding new devices, disabling 1-wire search after module-loading resolves the device-disconnect issue. Simply put<br />
::<code>wire search_count=5</code><br />
:: in your <code>/etc/modules</code> (I'm not using DTB) to allow only 5 (initial) searches.<br />
<br />
====Multiple 1-wire buses====<br />
:* Inspired and guided by http://www.raspberrypi.org/forums/viewtopic.php?p=513312#p513312, I've patched my 3.12.y kernel <code>arch/arm/mach-bcm2708/bcm2708.c</code> (patch file http://holyhead.de/RaspberryPi/bcm2708-multiple_w-1.patch-3.12.21.txt). Applying this patch to newer kernel versions is straight forward. (Currently I'm running 4.1.10 without device tree.)<br />
::* Note: Some kernel versions ago, device trees were introduced for Raspbian, see for example http://www.raspberrypi.org/documentation/configuration/device-tree.md<BR>So far, I don't know if this works with device trees.<br />
:* I've cross-compiled the kernel on a linux-VM, using the instructions of http://elinux.org/RPi_Kernel_Compilation (compiling on the RaspberryPi takes 6 hours [http://wiki.gentoo.org/wiki/Raspberry_Pi_Kernel_Compilation] or much more [http://elinux.org/RPi_Kernel_Compilation]).<br />
<br />
====Some 1-wire internals====<br />
* https://www.kernel.org/doc/Documentation/w1/w1.generic<br />
* [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]<br />
* http://blog.gegg.us/2013/03/4-different-methods-of-1-wire-access-on-raspberry-pi/<br />
<br />
===Compiling own kernel===<br />
<br />
* Some hints on cross-compiling:<br />
:* http://elinux.org/RPi_Kernel_Compilation<br />
:* https://github.com/raspberrypi/linux/tree/rpi-3.12.y/arch/arm/mach-bcm2708<br />
:* https://github.com/notro/rpi-source/wiki<br />
:* https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489&start=75<br />
:* http://www.bootc.net/projects/raspberry-pi-kernel/<br />
:* http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-recompile.html<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-cross-compile.html<br />
:* http://www.gtkdb.de/index_36_2087.html<br />
<br />
* extract kernel config from image:<br />
::<code>scripts/extract-ikconfig kernel-image</code><br />
::(extract-ikconfig is part of the kernel sources)<br />
<br />
===Device Trees===<br />
<br />
:* http://www.raspberrypi.org/documentation/configuration/device-tree.md<br />
:* https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt<br />
<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=97216<br />
:* http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f<br />
:* http://www.forum-raspberrypi.de/Thread-tutorial-geraetetreiber-und-device-tree-dt (German)<br />
<br />
:* http://xillybus.com/tutorials/device-tree-zynq-1<br />
<br />
===What about updates?===<br />
<br />
As I always forget this<br />
* <code>apt-get update</code> - update package lists<br />
* <code>apt-get upgrade</code> - upgrade installed packages<br />
* <code>rpi-update</code> - update kernel and modules<br />
::use <code>SKIP_KERNEL=1 rpi-update</code> to update the RPi firmware, but keep the current kernel<br />
::set <code>SKIP_REPODELETE=1</code> to keep downloaded files (by default: <code>/root/.rpi-firmware</code>)<br />
<br />
Kernel Sources<br />
* https://github.com/notro/rpi-source gets the source data from https://github.com/Hexxeh/rpi-firmware and https://github.com/raspberrypi/linux/<br />
<br />
===Hints for reading Kernel Panics===<br />
<br />
* http://ptgmedia.pearsoncmg.com/images/013147751X/downloads/013147751X_book.pdf<br />
: p290:<br />
export CONFIG_DEBUG_INFO=1<br />
make kernel/sysctl.o<br />
objdump -d -S kernel/sysctl.o > kernel/sysctl.dump<br />
<br />
or, with my in cross-compiling setup:<br />
<br />
DOMAKE drivers/w1/slave/w1_therm.o<br />
${CCPREFIX}objdump -d -S w1_therm.o <br />
<br />
* http://www.opensourceforu.com/2011/01/understanding-a-kernel-oops/<br />
<br />
* http://www.lowlevel.eu/wiki/ARM-OS-Dev_Teil_2_%E2%80%93_Assembler_101<br />
<br />
==Attaching a LCD display (HD44780 controller)==<br />
<br />
===Wiring and Specs===<br />
<br />
* Specs<br />
** ftp://imall.iteadstudio.com/IM120424018_EONE_2004_Characters_LCD/SPE_IM120424018_EONE_2004_Characters_LCD.pdf<br />
** http://www.adafruit.com/datasheets/HD44780.pdf<br />
<br />
* http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display (German)<br />
<br />
* http://www.pro-linux.de/artikel/2/1624/5,die-anzeige-hardware-und-software.html<br />
<br />
* https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring<br />
<br />
* https://github.com/perryflynn/raspberrypi-misc/tree/master/charlcd_4x20_cmd<br />
<br />
* http://obrazki.elektroda.pl/5028699400_1384164963.jpg<br />
<br />
===Misc===<br />
<br />
* http://www.makerspaceuk.com/lcd-temp-sensor/<br />
<br />
* http://anwendungsentwickler.ws/blog/kategorien/raspberry-pi/4x20-lcd-screen-mit-dem-raspberry-pi.html (German)<br />
<br />
==Controlling the display==<br />
<br />
* Python [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO]<br />
<br />
===LCDProc hints===<br />
<br />
* Pi & GPIO powered HD44780 LCD: http://www.boeeerb.co.uk/pi-lcd/<br />
<br />
* https://metacpan.org/pod/Net::LCDproc<br />
<br />
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=63412<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-user.html<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-dev.html<br />
<br />
* http://tuxgraphics.org/electronics/200504/article375.shtml<br />
<br />
==Todo and Miscellaneous==<br />
<br />
===Lirc===<br />
* http://powerpi.de/jede-infrarot-fernbedienung-am-raspberry-pi-2-nutzen-so-installierst-du-guenstig-einen-ir-empfaenger-teil-1/ (German)<br />
<br />
===Backports===<br />
<br />
* https://gist.github.com/martijnvermaat/7864115<br />
* http://superuser.com/questions/644586/how-to-upgrade-to-latest-git-on-debian-7<br />
<br />
===Collection of misc stuff to check - things I might) try sometime===<br />
<br />
* http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/<br />
<br />
* [http://en.wikipedia.org/wiki/F2FS f2fs]<br />
:* [http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=65330 F2fs, Ext4, FAT USB Benchmark]<br />
:* [http://forum.xda-developers.com/showthread.php?t=2697069 File System Performance: F2FS vs EXT4]<br />
<br />
* https://github.com/yuraa/Raspberry-Pi-Heartbeat<br />
<br />
* http://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html<br />
<br />
* [http://www.raspberrypi.org/archives/5282 Mathematica on Raspberry Pi, for free]<br />
:* also works in RasPi emulator, e.g. http://www.heise.de/ct/inhalt/2014/7/160/ (German, teaser to article)<br />
<br />
* NAS/Samba<br />
:* 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:<br />
:<code>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536</code><br />
<br />
* http://linuxtortures.blogspot.fr/2012/06/cross-compiling-and-cross-debugging-c.html<br />
<br />
===Things done===<br />
<br />
* Adjust swap file (size, location -> (ext4) HDD - too slow?): http://manpages.ubuntu.com/manpages/hardy/man8/dphys-swapfile.8.html<br />
<br />
* http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/<br />
<br />
==Some links (aka bookmark lists)==<br />
<br />
Project sites<br />
<br />
* [http://www.cl.cam.ac.uk/projects/raspberrypi/ University of Cambridge / Raspberry Pi Computer Laboratory]<br />
* [https://www.raspiprojekt.de/ raspiprojek] (German)<br />
* http://www.vanheusden.com/misc/rpi.php<br />
<br />
Blogs, forums, etc<br />
* http://www.raspberrypi.org/phpBB3/<br />
* [http://forum.stmlabs.com/forumdisplay.php?fid=6 Stm Labs Forum / Raspbmc]<br />
* [http://www.welzels.de/blog/projekte/raspberry-pi/ Wel!s Blog] (German)<br />
* [http://jankarres.de/category/raspberry-pi/ Raspberry Pi Blog of Jan Karres] (German)<br />
* http://www.forum-raspberrypi.de/ /(German)<br />
* http://raspberrycenter.de/ (German)<br />
* http://archlinuxarm.org/forum/viewforum.php?f=31&sid=57987232ca9177c35eb3ef7fdf6b3341<br />
<br />
* [[wikipedia:Raspberry_Pi Raspberry Pi in Wikipedia]]<br />
<br />
Miscellaneous<br />
<br />
* [http://www.raspberrypi.org/downloads New Out Of Box Software (Recommended)]<br />
* [http://elinux.org/R-Pi_Hub R-Pi_Hub]<br />
<br />
Manuals<br />
<br />
* https://github.com/raspberrypi/documentation<br />
<br />
* [http://debian-handbook.info/browse/stable/ The Debian Administrator's Handbook]</div>Holyheadhttps://holyhead.de/index.php?title=Raspberry_PiRaspberry Pi2015-12-29T22:57:24Z<p>Holyhead: /* Todo and Miscellaneous */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
===External USB drives===<br />
<br />
* Automount USB-Drives in Raspbian<br />
** One may use [http://selfprogramming.bplaced.net/index.php/2012/10/23/automount-usb-drives-in-raspbian/ USBmount and autofs]<br />
** I prefer [http://ignorantguru.github.io/udevil/ udevil], see below<br />
<br />
* Install ''ntfs-3g'' if you need write access to ntfs file systems<br />
<br />
* How to increase performance?<br />
** Mount with option ''''noatime'''' or ''''relatime''''<br />
** Mount ''without'' option sync (e.g. keep default async)<br />
** If using ntfs-3g (fuse) file system, try mounting with option 'big_writes', see for example http://obihoernchen.net/wordpress/tag/big_writes/<br />
<br />
===[http://ignorantguru.github.io/udevil/ udevil]===<br />
<br />
* example for manual mounting:<br />
<br />
udevil mount /dev/sda1<br />
<br />
* auto-mounting via udev-rule, see for example http://lsdlinux.org/wiki/doku.php?id=auto_mounting#using_udev_rule (I just copied the 95-udevil-mount.rules file from an OpenElec installation (http://www.raspberrypi.org/downloads) )<br />
<br />
* my build-steps (maybe there's a simpler way, but this worked...):<br />
** download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget<br />
** extract deb-package via <code>ar vx udevil_0.4.3-1_all.deb</code><br />
** extract data archive <code>tar xzvf data.tar.gz</code><br />
** change to tar usr/share/devil/src<br />
** untar <code>tar xvfJ udevil-current.tar.xz</code><br />
** <code>cd udevil-0.4.3</code><br />
** <code>mv distros/debian</code><br />
** execute <code>dpkg-buildpackage</code><br />
** 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<br />
** Install via <code>sudo dpkg -i udevil_0.4.3-1_armhf.deb</code><br />
<br />
===Samba server / NAS===<br />
<br />
* How to install?<br />
** [http://jankarres.de/2013/11/raspberry-pi-samba-server-installieren/ | Raspberry Pi: Samba Server installieren] (German)<br />
** [http://www.welzels.de/blog/projekte/raspberry-pi/low-budget-nas-mit-einem-raspberry-pi/ Low Budget NAS mit einem Raspberry PI] (German)<br />
<br />
* Slow disc performance?<br />
** see 'Slow USB drives' above<br />
** 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!)<br />
<br />
* Configuration and tuning<br />
** https://calomel.org/samba.html<br />
** https://calomel.org/samba_optimize.html<br />
<br />
* If your /var/log/samba/log.smbd fills up with ''printing/print_cups.c:110(cups_connect) Unable to connect to CUPS server localhost'' messages, try http://www.sotechdesign.com.au/samba-log-showing-error-failed-to-retrieve-printer-list/<br/>I also created an empty <code>/etc/printcap</code> to avoid ''Unable to open printcap file /etc/printcap for read'' messages.<br />
<br />
* I don't need sound:<br />
<br />
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf <br />
# I don't need sound<br />
blacklist snd<br />
blacklist snd_pcm<br />
blacklist snd_soc_core<br />
blacklist snd_soc_bcm2708_i2s<br />
<br />
===Trying to reduce number of disk writes (SD card)===<br />
<br />
I'm using [http://oss.oetiker.ch/rrdtool/ 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).<br />
<br />
Here's what I've done:<br />
<br />
* Edit <code>/etc/default/cron</code> and set <code>EXTRA_OPTS="-L 0"</code> to disable logging (I don't need these)<br />
* Avoid entries like <code>pam_unix(cron:session): session closed for user pi</code> in <code>/var/log/auth.log</code><br />
** Edit <code>/etc/pam.d/cron</code> and comment the line <code>@include common-session-noninteractive</code> ([http://ubuntuforums.org/showthread.php?t=1256801])<br />
:or<br />
:* Edit <code>/etc/pam.d/common-session-noninteractive</code> as shown here: http://ubuntuforums.org/showthread.php?t=1256801&p=10283830#post10283830<br />
* I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)<br />
** moved all the .rrd files as well as the created images to my persistent-ramdisk location<br />
** moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links<br />
*** <code>/var/spool</code><br />
*** <code>/var/log</code><br />
*** <code>/var/cache/samba</code><br />
** edited <code>/etc/insserv.conf</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:<br />
<br />
$local_fs_orig +mountall +mountall-bootclean +mountoverflowtmp +umountfs<br />
# we need the sym-link data in /var/log and /var/spool to be available<br />
$local_fs $local_fs_orig +persist-ramdisk<br />
<br />
:: <code>/etc/init.d/persist-ramdisk</code> 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.<br />
<br />
:* set ''RAMTMP'' to yes in <code>/etc/default/tmpfs</code> to get tempfs based <code>/tmp</code><br />
<br />
Before changing <code>/tmp</code>:<br />
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').<br />
::I need to do more digging...<br />
<br />
After changing <code>/tmp</code>:<br />
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...<br />
<br />
===Useful stuff and Q&A===<br />
<br />
* Q: Why does my Pi restart when hotplugging a USB drive?<br />
** http://thestuffsido.blogspot.de/2013/05/fixing-raspberry-pi-hotplugging.html<br />
** http://therandomlab.blogspot.de/2013/01/raspberry-pi-mod-to-avoid-shutdown-on.html<br />
<br />
* Q: Does Raspberry support WOL?<br />
: A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)<br />
<br />
* Q: The new password is to short, or too simple<br />
: A: Try adjusting the PAM settings in <code>/etc/pam.d/common-password</code>:<br />
:* remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)<br />
::<code>password [success=1 default=ignore] pam_unix.so sha512 minlen=2</code><br />
<br />
::!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!<br><br />
::But it's nice for testing (if you cannot or do not want to use auto-login.)<br />
<br />
* Q: How to configure static IP?<br />
: A: In /etc/network/interfaces:<br />
::<code>iface eth0 inet static<br>address 192.168.0.31<br>netmask 255.255.255.0<br>gateway 192.168.0.1</code><br />
<br />
* Q: How to read core temperature, etc?<br />
: A: [http://elinux.org/RPI_vcgencmd_usage vcgencmd]:<br />
::<code>vcgencmd measure_temp<br>vcgencmd measure_clock arm</code><br />
<br />
* External USB HDD spin down<br />
** hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)<br />
** hd-idle works:<br />
::<code>hd-idle -a sda -i 600</code><br />
:: for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)<br />
<br />
* Q: How to avoid update of a certain package?<br />
: A: Put package on hold ([http://debiananwenderhandbuch.de/dpkg.html] (German)):<br />
::<code>echo <packagename> "hold" | dpkg --set-selections</code><br />
<br />
* [[wikipedia:Raspcontrol]] with nginx<br />
** http://www.foxplex.com/sites/raspcontrol-webinterface-auf-dem-raspberry-pi/ (German), http://www.foxplex.com/sites/performanter-nginx-webserver-auf-dem-raspberry-pi-mit-php-und-apc/ (German)<br />
** http://menzerath.eu/artikel/raspberry-pi-raspcontrol-installation-funktionen/ (German)<br />
<br />
* Q: How many bytes are written to my (SD) disc?<br />
: A: Use <code>iostat</code> http://www.mybinarylife.net/2012/08/linux-iostat-command.html<br />
: A: Use <code>iotop</code> http://guichaz.free.fr/iotop/<br />
: A: Raw data of the kernel can be found in files <code>/proc/diskstats</code> and <code>/sys/block/DEVNAME/stat</code> https://www.kernel.org/doc/Documentation/iostats.txt<br />
:* http://unix.stackexchange.com/questions/86391/how-to-get-total-number-of-bytes-sectors-blocks-written-to-disk-since-booting<br />
:* http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux<br />
<br />
* Q: How to reduce number of ext-fs checks?<br />
: A: <code>tune2fs -c 60 /dev/sda1</code> Change maximum mount count to 60<br />
: A: <code>tune2fs -i 12m /dev/sda1</code> Change check interval to 12 months<br />
: fore more details: http://wiki.ubuntuusers.de/Dateisystemcheck (German)<br />
<br />
* Q: Fix smsc95xx 1-1.1:1.0: eth0: kevent 2 may have been dropped <br />
: A: http://wood1978.techarea.org/~wood/wordpress/2013/04/03/fix-smsc95xx-1-1-11-0-eth0-kevent-2-may-have-been-dropped-on-raspberry-pi-with-arch-linux<br />
::Modifying the sysctl.conf values reduced the kevent-2 messages; I did not yet set smsc95xx.turbo_mode=N<br />
<br />
===Overclocking===<br />
<br />
* I only set overclocking via <code>raspi-config</code><br />
<br />
* ''Turbo'': (Short) Raspberry stress test were ok. But I got an SD card error/corruption when doing a download and a dd-image of the SD card (according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907 the SD card error could be OC related.)<br />
::Luckily, I could recover all my data, see below.<br />
<br />
* '' Medium'': Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907] and its links).<br />
<br />
* Underclocking to 600 MHz<br />
:<code>echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</code><br />
: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.<br />
<br />
* Adjusting the ondemand-governor<br />
** https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt<br />
** set <code>/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor</code> to 10 [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&start=800]<br />
**: I had hoped this reduces the 1-wire CRC errors/device-disconnects problems, but with heavy (IO-) load (e.g. backup), 1wire sensors still get disconnected.<br />
<br />
* [http://moze.free.fr/blog/index.php?post/2013/02/Underclock-and-Overclock Nice power consumption analysis]<br />
<br />
====Stress test and benchmarks====<br />
<br />
* [http://www.roylongbottom.org.uk/ Roy Longbottom's PC Benchmark Collection]<br />
* [http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm Raspberry Pi Stress Tests]<br />
<br />
===SD card issues===<br />
<br />
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). I could still use this card for some time (see below), but finally I got a corrupted file system and could no longer repair it. That's when I re-installed Raspbian on a new SD card.<br />
<br />
Maybe I should try [http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ running from USB] sometime?<br />
<br />
====Recovery====<br />
* Creating a binary image of the SD card with my PC using [http://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] resulted in IO errors at about 17%.<br />
* 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 <code>dd conv=sync,noerror if=/dev/sdb2 of=rasp-image.img bs=1M</code> on my Linux machine (option <code>conv=noerror</code> ignores any errors, sync pads read-errors with zeros). The resulting image could not be mounted using a loop device. <br />
* Fortunately, <code>fsck.ext4 raspberry-image.bin</code> was able to repair the image, which I then could successfully mount on my Linux machine using <code>mount -o loop rasp-image.img /mnt</code>, and at a first glance, everything looked ok. So, I was at least able to get to my data. <br />
* On a later 'event', I dd-ed the repaired image back to the Raspberry, and could boot again.<br />
* On another a later 'event', I just fsck-ed the /dev/sdb2 using Linux, and could boot again... but I did not have luck this time - some files were gone.<br />
* 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.<br />
* My Raspberry successfully booted from this new image. I then used <code>raspi-config</code> to expand the root-fs (I've done this on my first installation as well). With Linux I was able to <code>dd</code> my repaired image to the repaired SD. The card booted as if nothing had happened...<br />
* But after some weeks, my Raspberry fried the SD card again, and some weeks later again ... And finally I could not get my pi to boot with this card. However, I can still read the data linux. Moving data to a new card... (easier said than done if the new card is slightly smaller... but, see below for resizing... and sometimes a fresh install is even less painful).<br />
<br />
===Reminders: dd, dd_rescue, losetup, mount and others===<br />
* Example partition table printed by fdisk:<br />
<code><br />
/dev/sdb: 7861 MB, 7861174272 bytes, 15353856 sectors<br />
Units = Sektoren of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
<br />
Gerät boot. Anfang Ende Blöcke Id System<br />
[...]<br />
/dev/sdb3 15288320 15353855 32768 83 Linux</code><br />
:Byte-offset of sdb3: 7827619840 = 15288320 * 512<br />
<br />
* Mount partition to /dev/loopN partition for repair, etc.<br />
:<code>losetup -o 7827619840 --find --show /dev/sdb</code><br />
:--show prints the used /dev/loopN device<br />
<br />
* Directly mount partition using loop device:<br />
:<code>mount -o loop,offset=7827619840 /dev/sdb /mnt</code><br />
* http://www.garloff.de/kurt/linux/ddrescue/<br />
* http://softwarebakery.com/shrinking-images-on-linux<br />
* http://www.tehfear.com/2007/10/08/resize-loop-disk-image/<br />
* http://wiki.ubuntuusers.de/dd (German)<br />
* http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device<br />
<br />
===Some 1-Wire Stuff===<br />
<br />
====Temperature Sensor DS1820====<br />
<br />
* How to?<br />
** http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/<br />
** https://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&start=1 (German)<br />
** http://kopfkino.irosaurus.com/tutorial-ds18s20-temperatur-sensor-an-einem-raspberry-pi/ (German)<br />
** http://raspberrywebserver.com/cgiscripting/rpi-temperature-logger/<br />
** http://elinux.org/RPi_Low-level_peripherals<br />
** http://www.sdyoung.com/home/using-1-wire-ds18b20par-sensors-in-parasitic-mode-on-raspi-with-custom-gpio-pin/ (German)<br />
* I have two DS18B20 and log temperatures using rrdtool.<br />
<br />
* 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). <br />
** Q: Is this due to overclocking with using dynamic governor?<br />
** A: No - also occurs without overclocking (but less frequent?)<br />
** Q: Or is this due to voltage-problems?<br />
** A: No - also occurs without over-voltage<br />
** Q: Or something else?<br />
** 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). Using 3 sensors works almost all the time (without overclocking), but using 4 or more sensors (2 connected star topologies, very bad for 1-wire [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]), almost always fails to read values on most of the sensors.<br />
** A:'''Implement multiple 1-wire interfaces''' (see below), using 1 for each star-topology solved the problem. Reading 2x3 works perfect!<br />
** A: If not adding new devices, disabling 1-wire search after module-loading resolves the device-disconnect issue. Simply put<br />
::<code>wire search_count=5</code><br />
:: in your <code>/etc/modules</code> (I'm not using DTB) to allow only 5 (initial) searches.<br />
<br />
====Multiple 1-wire buses====<br />
:* Inspired and guided by http://www.raspberrypi.org/forums/viewtopic.php?p=513312#p513312, I've patched my 3.12.y kernel <code>arch/arm/mach-bcm2708/bcm2708.c</code> (patch file http://holyhead.de/RaspberryPi/bcm2708-multiple_w-1.patch-3.12.21.txt). Applying this patch to newer kernel versions is straight forward. (Currently I'm running 4.1.10 without device tree.)<br />
::* Note: Some kernel versions ago, device trees were introduced for Raspbian, see for example http://www.raspberrypi.org/documentation/configuration/device-tree.md<BR>So far, I don't know if this works with device trees.<br />
:* I've cross-compiled the kernel on a linux-VM, using the instructions of http://elinux.org/RPi_Kernel_Compilation (compiling on the RaspberryPi takes 6 hours [http://wiki.gentoo.org/wiki/Raspberry_Pi_Kernel_Compilation] or much more [http://elinux.org/RPi_Kernel_Compilation]).<br />
<br />
====Some 1-wire internals====<br />
* https://www.kernel.org/doc/Documentation/w1/w1.generic<br />
* [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]<br />
* http://blog.gegg.us/2013/03/4-different-methods-of-1-wire-access-on-raspberry-pi/<br />
<br />
===Compiling own kernel===<br />
<br />
* Some hints on cross-compiling:<br />
:* http://elinux.org/RPi_Kernel_Compilation<br />
:* https://github.com/raspberrypi/linux/tree/rpi-3.12.y/arch/arm/mach-bcm2708<br />
:* https://github.com/notro/rpi-source/wiki<br />
:* https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489&start=75<br />
:* http://www.bootc.net/projects/raspberry-pi-kernel/<br />
:* http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-recompile.html<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-cross-compile.html<br />
:* http://www.gtkdb.de/index_36_2087.html<br />
<br />
* extract kernel config from image:<br />
::<code>scripts/extract-ikconfig kernel-image</code><br />
::(extract-ikconfig is part of the kernel sources)<br />
<br />
===Device Trees===<br />
<br />
:* http://www.raspberrypi.org/documentation/configuration/device-tree.md<br />
:* https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt<br />
<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=97216<br />
:* http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f<br />
:* http://www.forum-raspberrypi.de/Thread-tutorial-geraetetreiber-und-device-tree-dt (German)<br />
<br />
:* http://xillybus.com/tutorials/device-tree-zynq-1<br />
<br />
===What about updates?===<br />
<br />
As I always forget this<br />
* <code>apt-get update</code> - update package lists<br />
* <code>apt-get upgrade</code> - upgrade installed packages<br />
* <code>rpi-update</code> - update kernel and modules<br />
::use <code>SKIP_KERNEL=1 rpi-update</code> to update the RPi firmware, but keep the current kernel<br />
::set <code>SKIP_REPODELETE=1</code> to keep downloaded files (by default: <code>/root/.rpi-firmware</code>)<br />
<br />
Kernel Sources<br />
* https://github.com/notro/rpi-source gets the source data from https://github.com/Hexxeh/rpi-firmware and https://github.com/raspberrypi/linux/<br />
<br />
===Hints for reading Kernel Panics===<br />
<br />
* http://ptgmedia.pearsoncmg.com/images/013147751X/downloads/013147751X_book.pdf<br />
: p290:<br />
export CONFIG_DEBUG_INFO=1<br />
make kernel/sysctl.o<br />
objdump -d -S kernel/sysctl.o > kernel/sysctl.dump<br />
<br />
or, with my in cross-compiling setup:<br />
<br />
DOMAKE drivers/w1/slave/w1_therm.o<br />
${CCPREFIX}objdump -d -S w1_therm.o <br />
<br />
* http://www.opensourceforu.com/2011/01/understanding-a-kernel-oops/<br />
<br />
* http://www.lowlevel.eu/wiki/ARM-OS-Dev_Teil_2_%E2%80%93_Assembler_101<br />
<br />
==Attaching a LCD display (HD44780 controller)==<br />
<br />
===Wiring and Specs===<br />
<br />
* Specs<br />
** ftp://imall.iteadstudio.com/IM120424018_EONE_2004_Characters_LCD/SPE_IM120424018_EONE_2004_Characters_LCD.pdf<br />
** http://www.adafruit.com/datasheets/HD44780.pdf<br />
<br />
* http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display (German)<br />
<br />
* http://www.pro-linux.de/artikel/2/1624/5,die-anzeige-hardware-und-software.html<br />
<br />
* https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring<br />
<br />
* https://github.com/perryflynn/raspberrypi-misc/tree/master/charlcd_4x20_cmd<br />
<br />
* http://obrazki.elektroda.pl/5028699400_1384164963.jpg<br />
<br />
===Misc===<br />
<br />
* http://www.makerspaceuk.com/lcd-temp-sensor/<br />
<br />
* http://anwendungsentwickler.ws/blog/kategorien/raspberry-pi/4x20-lcd-screen-mit-dem-raspberry-pi.html (German)<br />
<br />
==Controlling the display==<br />
<br />
* Python [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO]<br />
<br />
===LCDProc hints===<br />
<br />
* Pi & GPIO powered HD44780 LCD: http://www.boeeerb.co.uk/pi-lcd/<br />
<br />
* https://metacpan.org/pod/Net::LCDproc<br />
<br />
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=63412<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-user.html<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-dev.html<br />
<br />
* http://tuxgraphics.org/electronics/200504/article375.shtml<br />
<br />
==Todo and Miscellaneous==<br />
<br />
===Lirc===<br />
* http://powerpi.de/jede-infrarot-fernbedienung-am-raspberry-pi-2-nutzen-so-installierst-du-guenstig-einen-ir-empfaenger-teil-1/ (German)<br />
<br />
===Backports===<br />
<br />
* https://gist.github.com/martijnvermaat/7864115<br />
<br />
===Collection of misc stuff to check - things I might) try sometime===<br />
<br />
* http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/<br />
<br />
* [http://en.wikipedia.org/wiki/F2FS f2fs]<br />
:* [http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=65330 F2fs, Ext4, FAT USB Benchmark]<br />
:* [http://forum.xda-developers.com/showthread.php?t=2697069 File System Performance: F2FS vs EXT4]<br />
<br />
* https://github.com/yuraa/Raspberry-Pi-Heartbeat<br />
<br />
* http://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html<br />
<br />
* [http://www.raspberrypi.org/archives/5282 Mathematica on Raspberry Pi, for free]<br />
:* also works in RasPi emulator, e.g. http://www.heise.de/ct/inhalt/2014/7/160/ (German, teaser to article)<br />
<br />
* NAS/Samba<br />
:* 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:<br />
:<code>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536</code><br />
<br />
* http://linuxtortures.blogspot.fr/2012/06/cross-compiling-and-cross-debugging-c.html<br />
<br />
===Things done===<br />
<br />
* Adjust swap file (size, location -> (ext4) HDD - too slow?): http://manpages.ubuntu.com/manpages/hardy/man8/dphys-swapfile.8.html<br />
<br />
* http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/<br />
<br />
==Some links (aka bookmark lists)==<br />
<br />
Project sites<br />
<br />
* [http://www.cl.cam.ac.uk/projects/raspberrypi/ University of Cambridge / Raspberry Pi Computer Laboratory]<br />
* [https://www.raspiprojekt.de/ raspiprojek] (German)<br />
* http://www.vanheusden.com/misc/rpi.php<br />
<br />
Blogs, forums, etc<br />
* http://www.raspberrypi.org/phpBB3/<br />
* [http://forum.stmlabs.com/forumdisplay.php?fid=6 Stm Labs Forum / Raspbmc]<br />
* [http://www.welzels.de/blog/projekte/raspberry-pi/ Wel!s Blog] (German)<br />
* [http://jankarres.de/category/raspberry-pi/ Raspberry Pi Blog of Jan Karres] (German)<br />
* http://www.forum-raspberrypi.de/ /(German)<br />
* http://raspberrycenter.de/ (German)<br />
* http://archlinuxarm.org/forum/viewforum.php?f=31&sid=57987232ca9177c35eb3ef7fdf6b3341<br />
<br />
* [[wikipedia:Raspberry_Pi Raspberry Pi in Wikipedia]]<br />
<br />
Miscellaneous<br />
<br />
* [http://www.raspberrypi.org/downloads New Out Of Box Software (Recommended)]<br />
* [http://elinux.org/R-Pi_Hub R-Pi_Hub]<br />
<br />
Manuals<br />
<br />
* https://github.com/raspberrypi/documentation<br />
<br />
* [http://debian-handbook.info/browse/stable/ The Debian Administrator's Handbook]</div>Holyheadhttps://holyhead.de/index.php?title=Raspberry_PiRaspberry Pi2015-12-29T21:02:52Z<p>Holyhead: /* Todo and Miscellaneous */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
===External USB drives===<br />
<br />
* Automount USB-Drives in Raspbian<br />
** One may use [http://selfprogramming.bplaced.net/index.php/2012/10/23/automount-usb-drives-in-raspbian/ USBmount and autofs]<br />
** I prefer [http://ignorantguru.github.io/udevil/ udevil], see below<br />
<br />
* Install ''ntfs-3g'' if you need write access to ntfs file systems<br />
<br />
* How to increase performance?<br />
** Mount with option ''''noatime'''' or ''''relatime''''<br />
** Mount ''without'' option sync (e.g. keep default async)<br />
** If using ntfs-3g (fuse) file system, try mounting with option 'big_writes', see for example http://obihoernchen.net/wordpress/tag/big_writes/<br />
<br />
===[http://ignorantguru.github.io/udevil/ udevil]===<br />
<br />
* example for manual mounting:<br />
<br />
udevil mount /dev/sda1<br />
<br />
* auto-mounting via udev-rule, see for example http://lsdlinux.org/wiki/doku.php?id=auto_mounting#using_udev_rule (I just copied the 95-udevil-mount.rules file from an OpenElec installation (http://www.raspberrypi.org/downloads) )<br />
<br />
* my build-steps (maybe there's a simpler way, but this worked...):<br />
** download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget<br />
** extract deb-package via <code>ar vx udevil_0.4.3-1_all.deb</code><br />
** extract data archive <code>tar xzvf data.tar.gz</code><br />
** change to tar usr/share/devil/src<br />
** untar <code>tar xvfJ udevil-current.tar.xz</code><br />
** <code>cd udevil-0.4.3</code><br />
** <code>mv distros/debian</code><br />
** execute <code>dpkg-buildpackage</code><br />
** 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<br />
** Install via <code>sudo dpkg -i udevil_0.4.3-1_armhf.deb</code><br />
<br />
===Samba server / NAS===<br />
<br />
* How to install?<br />
** [http://jankarres.de/2013/11/raspberry-pi-samba-server-installieren/ | Raspberry Pi: Samba Server installieren] (German)<br />
** [http://www.welzels.de/blog/projekte/raspberry-pi/low-budget-nas-mit-einem-raspberry-pi/ Low Budget NAS mit einem Raspberry PI] (German)<br />
<br />
* Slow disc performance?<br />
** see 'Slow USB drives' above<br />
** 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!)<br />
<br />
* Configuration and tuning<br />
** https://calomel.org/samba.html<br />
** https://calomel.org/samba_optimize.html<br />
<br />
* If your /var/log/samba/log.smbd fills up with ''printing/print_cups.c:110(cups_connect) Unable to connect to CUPS server localhost'' messages, try http://www.sotechdesign.com.au/samba-log-showing-error-failed-to-retrieve-printer-list/<br/>I also created an empty <code>/etc/printcap</code> to avoid ''Unable to open printcap file /etc/printcap for read'' messages.<br />
<br />
* I don't need sound:<br />
<br />
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf <br />
# I don't need sound<br />
blacklist snd<br />
blacklist snd_pcm<br />
blacklist snd_soc_core<br />
blacklist snd_soc_bcm2708_i2s<br />
<br />
===Trying to reduce number of disk writes (SD card)===<br />
<br />
I'm using [http://oss.oetiker.ch/rrdtool/ 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).<br />
<br />
Here's what I've done:<br />
<br />
* Edit <code>/etc/default/cron</code> and set <code>EXTRA_OPTS="-L 0"</code> to disable logging (I don't need these)<br />
* Avoid entries like <code>pam_unix(cron:session): session closed for user pi</code> in <code>/var/log/auth.log</code><br />
** Edit <code>/etc/pam.d/cron</code> and comment the line <code>@include common-session-noninteractive</code> ([http://ubuntuforums.org/showthread.php?t=1256801])<br />
:or<br />
:* Edit <code>/etc/pam.d/common-session-noninteractive</code> as shown here: http://ubuntuforums.org/showthread.php?t=1256801&p=10283830#post10283830<br />
* I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)<br />
** moved all the .rrd files as well as the created images to my persistent-ramdisk location<br />
** moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links<br />
*** <code>/var/spool</code><br />
*** <code>/var/log</code><br />
*** <code>/var/cache/samba</code><br />
** edited <code>/etc/insserv.conf</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:<br />
<br />
$local_fs_orig +mountall +mountall-bootclean +mountoverflowtmp +umountfs<br />
# we need the sym-link data in /var/log and /var/spool to be available<br />
$local_fs $local_fs_orig +persist-ramdisk<br />
<br />
:: <code>/etc/init.d/persist-ramdisk</code> 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.<br />
<br />
:* set ''RAMTMP'' to yes in <code>/etc/default/tmpfs</code> to get tempfs based <code>/tmp</code><br />
<br />
Before changing <code>/tmp</code>:<br />
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').<br />
::I need to do more digging...<br />
<br />
After changing <code>/tmp</code>:<br />
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...<br />
<br />
===Useful stuff and Q&A===<br />
<br />
* Q: Why does my Pi restart when hotplugging a USB drive?<br />
** http://thestuffsido.blogspot.de/2013/05/fixing-raspberry-pi-hotplugging.html<br />
** http://therandomlab.blogspot.de/2013/01/raspberry-pi-mod-to-avoid-shutdown-on.html<br />
<br />
* Q: Does Raspberry support WOL?<br />
: A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)<br />
<br />
* Q: The new password is to short, or too simple<br />
: A: Try adjusting the PAM settings in <code>/etc/pam.d/common-password</code>:<br />
:* remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)<br />
::<code>password [success=1 default=ignore] pam_unix.so sha512 minlen=2</code><br />
<br />
::!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!<br><br />
::But it's nice for testing (if you cannot or do not want to use auto-login.)<br />
<br />
* Q: How to configure static IP?<br />
: A: In /etc/network/interfaces:<br />
::<code>iface eth0 inet static<br>address 192.168.0.31<br>netmask 255.255.255.0<br>gateway 192.168.0.1</code><br />
<br />
* Q: How to read core temperature, etc?<br />
: A: [http://elinux.org/RPI_vcgencmd_usage vcgencmd]:<br />
::<code>vcgencmd measure_temp<br>vcgencmd measure_clock arm</code><br />
<br />
* External USB HDD spin down<br />
** hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)<br />
** hd-idle works:<br />
::<code>hd-idle -a sda -i 600</code><br />
:: for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)<br />
<br />
* Q: How to avoid update of a certain package?<br />
: A: Put package on hold ([http://debiananwenderhandbuch.de/dpkg.html] (German)):<br />
::<code>echo <packagename> "hold" | dpkg --set-selections</code><br />
<br />
* [[wikipedia:Raspcontrol]] with nginx<br />
** http://www.foxplex.com/sites/raspcontrol-webinterface-auf-dem-raspberry-pi/ (German), http://www.foxplex.com/sites/performanter-nginx-webserver-auf-dem-raspberry-pi-mit-php-und-apc/ (German)<br />
** http://menzerath.eu/artikel/raspberry-pi-raspcontrol-installation-funktionen/ (German)<br />
<br />
* Q: How many bytes are written to my (SD) disc?<br />
: A: Use <code>iostat</code> http://www.mybinarylife.net/2012/08/linux-iostat-command.html<br />
: A: Use <code>iotop</code> http://guichaz.free.fr/iotop/<br />
: A: Raw data of the kernel can be found in files <code>/proc/diskstats</code> and <code>/sys/block/DEVNAME/stat</code> https://www.kernel.org/doc/Documentation/iostats.txt<br />
:* http://unix.stackexchange.com/questions/86391/how-to-get-total-number-of-bytes-sectors-blocks-written-to-disk-since-booting<br />
:* http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux<br />
<br />
* Q: How to reduce number of ext-fs checks?<br />
: A: <code>tune2fs -c 60 /dev/sda1</code> Change maximum mount count to 60<br />
: A: <code>tune2fs -i 12m /dev/sda1</code> Change check interval to 12 months<br />
: fore more details: http://wiki.ubuntuusers.de/Dateisystemcheck (German)<br />
<br />
* Q: Fix smsc95xx 1-1.1:1.0: eth0: kevent 2 may have been dropped <br />
: A: http://wood1978.techarea.org/~wood/wordpress/2013/04/03/fix-smsc95xx-1-1-11-0-eth0-kevent-2-may-have-been-dropped-on-raspberry-pi-with-arch-linux<br />
::Modifying the sysctl.conf values reduced the kevent-2 messages; I did not yet set smsc95xx.turbo_mode=N<br />
<br />
===Overclocking===<br />
<br />
* I only set overclocking via <code>raspi-config</code><br />
<br />
* ''Turbo'': (Short) Raspberry stress test were ok. But I got an SD card error/corruption when doing a download and a dd-image of the SD card (according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907 the SD card error could be OC related.)<br />
::Luckily, I could recover all my data, see below.<br />
<br />
* '' Medium'': Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907] and its links).<br />
<br />
* Underclocking to 600 MHz<br />
:<code>echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</code><br />
: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.<br />
<br />
* Adjusting the ondemand-governor<br />
** https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt<br />
** set <code>/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor</code> to 10 [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&start=800]<br />
**: I had hoped this reduces the 1-wire CRC errors/device-disconnects problems, but with heavy (IO-) load (e.g. backup), 1wire sensors still get disconnected.<br />
<br />
* [http://moze.free.fr/blog/index.php?post/2013/02/Underclock-and-Overclock Nice power consumption analysis]<br />
<br />
====Stress test and benchmarks====<br />
<br />
* [http://www.roylongbottom.org.uk/ Roy Longbottom's PC Benchmark Collection]<br />
* [http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm Raspberry Pi Stress Tests]<br />
<br />
===SD card issues===<br />
<br />
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). I could still use this card for some time (see below), but finally I got a corrupted file system and could no longer repair it. That's when I re-installed Raspbian on a new SD card.<br />
<br />
Maybe I should try [http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ running from USB] sometime?<br />
<br />
====Recovery====<br />
* Creating a binary image of the SD card with my PC using [http://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] resulted in IO errors at about 17%.<br />
* 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 <code>dd conv=sync,noerror if=/dev/sdb2 of=rasp-image.img bs=1M</code> on my Linux machine (option <code>conv=noerror</code> ignores any errors, sync pads read-errors with zeros). The resulting image could not be mounted using a loop device. <br />
* Fortunately, <code>fsck.ext4 raspberry-image.bin</code> was able to repair the image, which I then could successfully mount on my Linux machine using <code>mount -o loop rasp-image.img /mnt</code>, and at a first glance, everything looked ok. So, I was at least able to get to my data. <br />
* On a later 'event', I dd-ed the repaired image back to the Raspberry, and could boot again.<br />
* On another a later 'event', I just fsck-ed the /dev/sdb2 using Linux, and could boot again... but I did not have luck this time - some files were gone.<br />
* 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.<br />
* My Raspberry successfully booted from this new image. I then used <code>raspi-config</code> to expand the root-fs (I've done this on my first installation as well). With Linux I was able to <code>dd</code> my repaired image to the repaired SD. The card booted as if nothing had happened...<br />
* But after some weeks, my Raspberry fried the SD card again, and some weeks later again ... And finally I could not get my pi to boot with this card. However, I can still read the data linux. Moving data to a new card... (easier said than done if the new card is slightly smaller... but, see below for resizing... and sometimes a fresh install is even less painful).<br />
<br />
===Reminders: dd, dd_rescue, losetup, mount and others===<br />
* Example partition table printed by fdisk:<br />
<code><br />
/dev/sdb: 7861 MB, 7861174272 bytes, 15353856 sectors<br />
Units = Sektoren of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
<br />
Gerät boot. Anfang Ende Blöcke Id System<br />
[...]<br />
/dev/sdb3 15288320 15353855 32768 83 Linux</code><br />
:Byte-offset of sdb3: 7827619840 = 15288320 * 512<br />
<br />
* Mount partition to /dev/loopN partition for repair, etc.<br />
:<code>losetup -o 7827619840 --find --show /dev/sdb</code><br />
:--show prints the used /dev/loopN device<br />
<br />
* Directly mount partition using loop device:<br />
:<code>mount -o loop,offset=7827619840 /dev/sdb /mnt</code><br />
* http://www.garloff.de/kurt/linux/ddrescue/<br />
* http://softwarebakery.com/shrinking-images-on-linux<br />
* http://www.tehfear.com/2007/10/08/resize-loop-disk-image/<br />
* http://wiki.ubuntuusers.de/dd (German)<br />
* http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device<br />
<br />
===Some 1-Wire Stuff===<br />
<br />
====Temperature Sensor DS1820====<br />
<br />
* How to?<br />
** http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/<br />
** https://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&start=1 (German)<br />
** http://kopfkino.irosaurus.com/tutorial-ds18s20-temperatur-sensor-an-einem-raspberry-pi/ (German)<br />
** http://raspberrywebserver.com/cgiscripting/rpi-temperature-logger/<br />
** http://elinux.org/RPi_Low-level_peripherals<br />
** http://www.sdyoung.com/home/using-1-wire-ds18b20par-sensors-in-parasitic-mode-on-raspi-with-custom-gpio-pin/ (German)<br />
* I have two DS18B20 and log temperatures using rrdtool.<br />
<br />
* 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). <br />
** Q: Is this due to overclocking with using dynamic governor?<br />
** A: No - also occurs without overclocking (but less frequent?)<br />
** Q: Or is this due to voltage-problems?<br />
** A: No - also occurs without over-voltage<br />
** Q: Or something else?<br />
** 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). Using 3 sensors works almost all the time (without overclocking), but using 4 or more sensors (2 connected star topologies, very bad for 1-wire [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]), almost always fails to read values on most of the sensors.<br />
** A:'''Implement multiple 1-wire interfaces''' (see below), using 1 for each star-topology solved the problem. Reading 2x3 works perfect!<br />
** A: If not adding new devices, disabling 1-wire search after module-loading resolves the device-disconnect issue. Simply put<br />
::<code>wire search_count=5</code><br />
:: in your <code>/etc/modules</code> (I'm not using DTB) to allow only 5 (initial) searches.<br />
<br />
====Multiple 1-wire buses====<br />
:* Inspired and guided by http://www.raspberrypi.org/forums/viewtopic.php?p=513312#p513312, I've patched my 3.12.y kernel <code>arch/arm/mach-bcm2708/bcm2708.c</code> (patch file http://holyhead.de/RaspberryPi/bcm2708-multiple_w-1.patch-3.12.21.txt). Applying this patch to newer kernel versions is straight forward. (Currently I'm running 4.1.10 without device tree.)<br />
::* Note: Some kernel versions ago, device trees were introduced for Raspbian, see for example http://www.raspberrypi.org/documentation/configuration/device-tree.md<BR>So far, I don't know if this works with device trees.<br />
:* I've cross-compiled the kernel on a linux-VM, using the instructions of http://elinux.org/RPi_Kernel_Compilation (compiling on the RaspberryPi takes 6 hours [http://wiki.gentoo.org/wiki/Raspberry_Pi_Kernel_Compilation] or much more [http://elinux.org/RPi_Kernel_Compilation]).<br />
<br />
====Some 1-wire internals====<br />
* https://www.kernel.org/doc/Documentation/w1/w1.generic<br />
* [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]<br />
* http://blog.gegg.us/2013/03/4-different-methods-of-1-wire-access-on-raspberry-pi/<br />
<br />
===Compiling own kernel===<br />
<br />
* Some hints on cross-compiling:<br />
:* http://elinux.org/RPi_Kernel_Compilation<br />
:* https://github.com/raspberrypi/linux/tree/rpi-3.12.y/arch/arm/mach-bcm2708<br />
:* https://github.com/notro/rpi-source/wiki<br />
:* https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489&start=75<br />
:* http://www.bootc.net/projects/raspberry-pi-kernel/<br />
:* http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-recompile.html<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-cross-compile.html<br />
:* http://www.gtkdb.de/index_36_2087.html<br />
<br />
* extract kernel config from image:<br />
::<code>scripts/extract-ikconfig kernel-image</code><br />
::(extract-ikconfig is part of the kernel sources)<br />
<br />
===Device Trees===<br />
<br />
:* http://www.raspberrypi.org/documentation/configuration/device-tree.md<br />
:* https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt<br />
<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=97216<br />
:* http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f<br />
:* http://www.forum-raspberrypi.de/Thread-tutorial-geraetetreiber-und-device-tree-dt (German)<br />
<br />
:* http://xillybus.com/tutorials/device-tree-zynq-1<br />
<br />
===What about updates?===<br />
<br />
As I always forget this<br />
* <code>apt-get update</code> - update package lists<br />
* <code>apt-get upgrade</code> - upgrade installed packages<br />
* <code>rpi-update</code> - update kernel and modules<br />
::use <code>SKIP_KERNEL=1 rpi-update</code> to update the RPi firmware, but keep the current kernel<br />
::set <code>SKIP_REPODELETE=1</code> to keep downloaded files (by default: <code>/root/.rpi-firmware</code>)<br />
<br />
Kernel Sources<br />
* https://github.com/notro/rpi-source gets the source data from https://github.com/Hexxeh/rpi-firmware and https://github.com/raspberrypi/linux/<br />
<br />
===Hints for reading Kernel Panics===<br />
<br />
* http://ptgmedia.pearsoncmg.com/images/013147751X/downloads/013147751X_book.pdf<br />
: p290:<br />
export CONFIG_DEBUG_INFO=1<br />
make kernel/sysctl.o<br />
objdump -d -S kernel/sysctl.o > kernel/sysctl.dump<br />
<br />
or, with my in cross-compiling setup:<br />
<br />
DOMAKE drivers/w1/slave/w1_therm.o<br />
${CCPREFIX}objdump -d -S w1_therm.o <br />
<br />
* http://www.opensourceforu.com/2011/01/understanding-a-kernel-oops/<br />
<br />
* http://www.lowlevel.eu/wiki/ARM-OS-Dev_Teil_2_%E2%80%93_Assembler_101<br />
<br />
==Attaching a LCD display (HD44780 controller)==<br />
<br />
===Wiring and Specs===<br />
<br />
* Specs<br />
** ftp://imall.iteadstudio.com/IM120424018_EONE_2004_Characters_LCD/SPE_IM120424018_EONE_2004_Characters_LCD.pdf<br />
** http://www.adafruit.com/datasheets/HD44780.pdf<br />
<br />
* http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display (German)<br />
<br />
* http://www.pro-linux.de/artikel/2/1624/5,die-anzeige-hardware-und-software.html<br />
<br />
* https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring<br />
<br />
* https://github.com/perryflynn/raspberrypi-misc/tree/master/charlcd_4x20_cmd<br />
<br />
* http://obrazki.elektroda.pl/5028699400_1384164963.jpg<br />
<br />
===Misc===<br />
<br />
* http://www.makerspaceuk.com/lcd-temp-sensor/<br />
<br />
* http://anwendungsentwickler.ws/blog/kategorien/raspberry-pi/4x20-lcd-screen-mit-dem-raspberry-pi.html (German)<br />
<br />
==Controlling the display==<br />
<br />
* Python [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO]<br />
<br />
===LCDProc hints===<br />
<br />
* Pi & GPIO powered HD44780 LCD: http://www.boeeerb.co.uk/pi-lcd/<br />
<br />
* https://metacpan.org/pod/Net::LCDproc<br />
<br />
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=63412<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-user.html<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-dev.html<br />
<br />
* http://tuxgraphics.org/electronics/200504/article375.shtml<br />
<br />
==Todo and Miscellaneous==<br />
<br />
===Lirc===<br />
* http://powerpi.de/jede-infrarot-fernbedienung-am-raspberry-pi-2-nutzen-so-installierst-du-guenstig-einen-ir-empfaenger-teil-1/ (German)<br />
<br />
===Collection of misc stuff to check - things I might) try sometime===<br />
<br />
* http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/<br />
<br />
* [http://en.wikipedia.org/wiki/F2FS f2fs]<br />
:* [http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=65330 F2fs, Ext4, FAT USB Benchmark]<br />
:* [http://forum.xda-developers.com/showthread.php?t=2697069 File System Performance: F2FS vs EXT4]<br />
<br />
* https://github.com/yuraa/Raspberry-Pi-Heartbeat<br />
<br />
* http://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html<br />
<br />
* [http://www.raspberrypi.org/archives/5282 Mathematica on Raspberry Pi, for free]<br />
:* also works in RasPi emulator, e.g. http://www.heise.de/ct/inhalt/2014/7/160/ (German, teaser to article)<br />
<br />
* NAS/Samba<br />
:* 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:<br />
:<code>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536</code><br />
<br />
* http://linuxtortures.blogspot.fr/2012/06/cross-compiling-and-cross-debugging-c.html<br />
<br />
===Things done===<br />
<br />
* Adjust swap file (size, location -> (ext4) HDD - too slow?): http://manpages.ubuntu.com/manpages/hardy/man8/dphys-swapfile.8.html<br />
<br />
* http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/<br />
<br />
==Some links (aka bookmark lists)==<br />
<br />
Project sites<br />
<br />
* [http://www.cl.cam.ac.uk/projects/raspberrypi/ University of Cambridge / Raspberry Pi Computer Laboratory]<br />
* [https://www.raspiprojekt.de/ raspiprojek] (German)<br />
* http://www.vanheusden.com/misc/rpi.php<br />
<br />
Blogs, forums, etc<br />
* http://www.raspberrypi.org/phpBB3/<br />
* [http://forum.stmlabs.com/forumdisplay.php?fid=6 Stm Labs Forum / Raspbmc]<br />
* [http://www.welzels.de/blog/projekte/raspberry-pi/ Wel!s Blog] (German)<br />
* [http://jankarres.de/category/raspberry-pi/ Raspberry Pi Blog of Jan Karres] (German)<br />
* http://www.forum-raspberrypi.de/ /(German)<br />
* http://raspberrycenter.de/ (German)<br />
* http://archlinuxarm.org/forum/viewforum.php?f=31&sid=57987232ca9177c35eb3ef7fdf6b3341<br />
<br />
* [[wikipedia:Raspberry_Pi Raspberry Pi in Wikipedia]]<br />
<br />
Miscellaneous<br />
<br />
* [http://www.raspberrypi.org/downloads New Out Of Box Software (Recommended)]<br />
* [http://elinux.org/R-Pi_Hub R-Pi_Hub]<br />
<br />
Manuals<br />
<br />
* https://github.com/raspberrypi/documentation<br />
<br />
* [http://debian-handbook.info/browse/stable/ The Debian Administrator's Handbook]</div>Holyheadhttps://holyhead.de/index.php?title=Raspberry_PiRaspberry Pi2015-10-12T15:08:28Z<p>Holyhead: /* Multiple 1-wire buses */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
===External USB drives===<br />
<br />
* Automount USB-Drives in Raspbian<br />
** One may use [http://selfprogramming.bplaced.net/index.php/2012/10/23/automount-usb-drives-in-raspbian/ USBmount and autofs]<br />
** I prefer [http://ignorantguru.github.io/udevil/ udevil], see below<br />
<br />
* Install ''ntfs-3g'' if you need write access to ntfs file systems<br />
<br />
* How to increase performance?<br />
** Mount with option ''''noatime'''' or ''''relatime''''<br />
** Mount ''without'' option sync (e.g. keep default async)<br />
** If using ntfs-3g (fuse) file system, try mounting with option 'big_writes', see for example http://obihoernchen.net/wordpress/tag/big_writes/<br />
<br />
===[http://ignorantguru.github.io/udevil/ udevil]===<br />
<br />
* example for manual mounting:<br />
<br />
udevil mount /dev/sda1<br />
<br />
* auto-mounting via udev-rule, see for example http://lsdlinux.org/wiki/doku.php?id=auto_mounting#using_udev_rule (I just copied the 95-udevil-mount.rules file from an OpenElec installation (http://www.raspberrypi.org/downloads) )<br />
<br />
* my build-steps (maybe there's a simpler way, but this worked...):<br />
** download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget<br />
** extract deb-package via <code>ar vx udevil_0.4.3-1_all.deb</code><br />
** extract data archive <code>tar xzvf data.tar.gz</code><br />
** change to tar usr/share/devil/src<br />
** untar <code>tar xvfJ udevil-current.tar.xz</code><br />
** <code>cd udevil-0.4.3</code><br />
** <code>mv distros/debian</code><br />
** execute <code>dpkg-buildpackage</code><br />
** 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<br />
** Install via <code>sudo dpkg -i udevil_0.4.3-1_armhf.deb</code><br />
<br />
===Samba server / NAS===<br />
<br />
* How to install?<br />
** [http://jankarres.de/2013/11/raspberry-pi-samba-server-installieren/ | Raspberry Pi: Samba Server installieren] (German)<br />
** [http://www.welzels.de/blog/projekte/raspberry-pi/low-budget-nas-mit-einem-raspberry-pi/ Low Budget NAS mit einem Raspberry PI] (German)<br />
<br />
* Slow disc performance?<br />
** see 'Slow USB drives' above<br />
** 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!)<br />
<br />
* Configuration and tuning<br />
** https://calomel.org/samba.html<br />
** https://calomel.org/samba_optimize.html<br />
<br />
* If your /var/log/samba/log.smbd fills up with ''printing/print_cups.c:110(cups_connect) Unable to connect to CUPS server localhost'' messages, try http://www.sotechdesign.com.au/samba-log-showing-error-failed-to-retrieve-printer-list/<br/>I also created an empty <code>/etc/printcap</code> to avoid ''Unable to open printcap file /etc/printcap for read'' messages.<br />
<br />
* I don't need sound:<br />
<br />
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf <br />
# I don't need sound<br />
blacklist snd<br />
blacklist snd_pcm<br />
blacklist snd_soc_core<br />
blacklist snd_soc_bcm2708_i2s<br />
<br />
===Trying to reduce number of disk writes (SD card)===<br />
<br />
I'm using [http://oss.oetiker.ch/rrdtool/ 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).<br />
<br />
Here's what I've done:<br />
<br />
* Edit <code>/etc/default/cron</code> and set <code>EXTRA_OPTS="-L 0"</code> to disable logging (I don't need these)<br />
* Avoid entries like <code>pam_unix(cron:session): session closed for user pi</code> in <code>/var/log/auth.log</code><br />
** Edit <code>/etc/pam.d/cron</code> and comment the line <code>@include common-session-noninteractive</code> ([http://ubuntuforums.org/showthread.php?t=1256801])<br />
:or<br />
:* Edit <code>/etc/pam.d/common-session-noninteractive</code> as shown here: http://ubuntuforums.org/showthread.php?t=1256801&p=10283830#post10283830<br />
* I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)<br />
** moved all the .rrd files as well as the created images to my persistent-ramdisk location<br />
** moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links<br />
*** <code>/var/spool</code><br />
*** <code>/var/log</code><br />
*** <code>/var/cache/samba</code><br />
** edited <code>/etc/insserv.conf</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:<br />
<br />
$local_fs_orig +mountall +mountall-bootclean +mountoverflowtmp +umountfs<br />
# we need the sym-link data in /var/log and /var/spool to be available<br />
$local_fs $local_fs_orig +persist-ramdisk<br />
<br />
:: <code>/etc/init.d/persist-ramdisk</code> 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.<br />
<br />
:* set ''RAMTMP'' to yes in <code>/etc/default/tmpfs</code> to get tempfs based <code>/tmp</code><br />
<br />
Before changing <code>/tmp</code>:<br />
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').<br />
::I need to do more digging...<br />
<br />
After changing <code>/tmp</code>:<br />
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...<br />
<br />
===Useful stuff and Q&A===<br />
<br />
* Q: Why does my Pi restart when hotplugging a USB drive?<br />
** http://thestuffsido.blogspot.de/2013/05/fixing-raspberry-pi-hotplugging.html<br />
** http://therandomlab.blogspot.de/2013/01/raspberry-pi-mod-to-avoid-shutdown-on.html<br />
<br />
* Q: Does Raspberry support WOL?<br />
: A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)<br />
<br />
* Q: The new password is to short, or too simple<br />
: A: Try adjusting the PAM settings in <code>/etc/pam.d/common-password</code>:<br />
:* remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)<br />
::<code>password [success=1 default=ignore] pam_unix.so sha512 minlen=2</code><br />
<br />
::!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!<br><br />
::But it's nice for testing (if you cannot or do not want to use auto-login.)<br />
<br />
* Q: How to configure static IP?<br />
: A: In /etc/network/interfaces:<br />
::<code>iface eth0 inet static<br>address 192.168.0.31<br>netmask 255.255.255.0<br>gateway 192.168.0.1</code><br />
<br />
* Q: How to read core temperature, etc?<br />
: A: [http://elinux.org/RPI_vcgencmd_usage vcgencmd]:<br />
::<code>vcgencmd measure_temp<br>vcgencmd measure_clock arm</code><br />
<br />
* External USB HDD spin down<br />
** hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)<br />
** hd-idle works:<br />
::<code>hd-idle -a sda -i 600</code><br />
:: for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)<br />
<br />
* Q: How to avoid update of a certain package?<br />
: A: Put package on hold ([http://debiananwenderhandbuch.de/dpkg.html] (German)):<br />
::<code>echo <packagename> "hold" | dpkg --set-selections</code><br />
<br />
* [[wikipedia:Raspcontrol]] with nginx<br />
** http://www.foxplex.com/sites/raspcontrol-webinterface-auf-dem-raspberry-pi/ (German), http://www.foxplex.com/sites/performanter-nginx-webserver-auf-dem-raspberry-pi-mit-php-und-apc/ (German)<br />
** http://menzerath.eu/artikel/raspberry-pi-raspcontrol-installation-funktionen/ (German)<br />
<br />
* Q: How many bytes are written to my (SD) disc?<br />
: A: Use <code>iostat</code> http://www.mybinarylife.net/2012/08/linux-iostat-command.html<br />
: A: Use <code>iotop</code> http://guichaz.free.fr/iotop/<br />
: A: Raw data of the kernel can be found in files <code>/proc/diskstats</code> and <code>/sys/block/DEVNAME/stat</code> https://www.kernel.org/doc/Documentation/iostats.txt<br />
:* http://unix.stackexchange.com/questions/86391/how-to-get-total-number-of-bytes-sectors-blocks-written-to-disk-since-booting<br />
:* http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux<br />
<br />
* Q: How to reduce number of ext-fs checks?<br />
: A: <code>tune2fs -c 60 /dev/sda1</code> Change maximum mount count to 60<br />
: A: <code>tune2fs -i 12m /dev/sda1</code> Change check interval to 12 months<br />
: fore more details: http://wiki.ubuntuusers.de/Dateisystemcheck (German)<br />
<br />
* Q: Fix smsc95xx 1-1.1:1.0: eth0: kevent 2 may have been dropped <br />
: A: http://wood1978.techarea.org/~wood/wordpress/2013/04/03/fix-smsc95xx-1-1-11-0-eth0-kevent-2-may-have-been-dropped-on-raspberry-pi-with-arch-linux<br />
::Modifying the sysctl.conf values reduced the kevent-2 messages; I did not yet set smsc95xx.turbo_mode=N<br />
<br />
===Overclocking===<br />
<br />
* I only set overclocking via <code>raspi-config</code><br />
<br />
* ''Turbo'': (Short) Raspberry stress test were ok. But I got an SD card error/corruption when doing a download and a dd-image of the SD card (according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907 the SD card error could be OC related.)<br />
::Luckily, I could recover all my data, see below.<br />
<br />
* '' Medium'': Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907] and its links).<br />
<br />
* Underclocking to 600 MHz<br />
:<code>echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</code><br />
: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.<br />
<br />
* Adjusting the ondemand-governor<br />
** https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt<br />
** set <code>/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor</code> to 10 [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&start=800]<br />
**: I had hoped this reduces the 1-wire CRC errors/device-disconnects problems, but with heavy (IO-) load (e.g. backup), 1wire sensors still get disconnected.<br />
<br />
* [http://moze.free.fr/blog/index.php?post/2013/02/Underclock-and-Overclock Nice power consumption analysis]<br />
<br />
====Stress test and benchmarks====<br />
<br />
* [http://www.roylongbottom.org.uk/ Roy Longbottom's PC Benchmark Collection]<br />
* [http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm Raspberry Pi Stress Tests]<br />
<br />
===SD card issues===<br />
<br />
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). I could still use this card for some time (see below), but finally I got a corrupted file system and could no longer repair it. That's when I re-installed Raspbian on a new SD card.<br />
<br />
Maybe I should try [http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ running from USB] sometime?<br />
<br />
====Recovery====<br />
* Creating a binary image of the SD card with my PC using [http://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] resulted in IO errors at about 17%.<br />
* 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 <code>dd conv=sync,noerror if=/dev/sdb2 of=rasp-image.img bs=1M</code> on my Linux machine (option <code>conv=noerror</code> ignores any errors, sync pads read-errors with zeros). The resulting image could not be mounted using a loop device. <br />
* Fortunately, <code>fsck.ext4 raspberry-image.bin</code> was able to repair the image, which I then could successfully mount on my Linux machine using <code>mount -o loop rasp-image.img /mnt</code>, and at a first glance, everything looked ok. So, I was at least able to get to my data. <br />
* On a later 'event', I dd-ed the repaired image back to the Raspberry, and could boot again.<br />
* On another a later 'event', I just fsck-ed the /dev/sdb2 using Linux, and could boot again... but I did not have luck this time - some files were gone.<br />
* 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.<br />
* My Raspberry successfully booted from this new image. I then used <code>raspi-config</code> to expand the root-fs (I've done this on my first installation as well). With Linux I was able to <code>dd</code> my repaired image to the repaired SD. The card booted as if nothing had happened...<br />
* But after some weeks, my Raspberry fried the SD card again, and some weeks later again ... And finally I could not get my pi to boot with this card. However, I can still read the data linux. Moving data to a new card... (easier said than done if the new card is slightly smaller... but, see below for resizing... and sometimes a fresh install is even less painful).<br />
<br />
===Reminders: dd, dd_rescue, losetup, mount and others===<br />
* Example partition table printed by fdisk:<br />
<code><br />
/dev/sdb: 7861 MB, 7861174272 bytes, 15353856 sectors<br />
Units = Sektoren of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
<br />
Gerät boot. Anfang Ende Blöcke Id System<br />
[...]<br />
/dev/sdb3 15288320 15353855 32768 83 Linux</code><br />
:Byte-offset of sdb3: 7827619840 = 15288320 * 512<br />
<br />
* Mount partition to /dev/loopN partition for repair, etc.<br />
:<code>losetup -o 7827619840 --find --show /dev/sdb</code><br />
:--show prints the used /dev/loopN device<br />
<br />
* Directly mount partition using loop device:<br />
:<code>mount -o loop,offset=7827619840 /dev/sdb /mnt</code><br />
* http://www.garloff.de/kurt/linux/ddrescue/<br />
* http://softwarebakery.com/shrinking-images-on-linux<br />
* http://www.tehfear.com/2007/10/08/resize-loop-disk-image/<br />
* http://wiki.ubuntuusers.de/dd (German)<br />
* http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device<br />
<br />
===Some 1-Wire Stuff===<br />
<br />
====Temperature Sensor DS1820====<br />
<br />
* How to?<br />
** http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/<br />
** https://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&start=1 (German)<br />
** http://kopfkino.irosaurus.com/tutorial-ds18s20-temperatur-sensor-an-einem-raspberry-pi/ (German)<br />
** http://raspberrywebserver.com/cgiscripting/rpi-temperature-logger/<br />
** http://elinux.org/RPi_Low-level_peripherals<br />
** http://www.sdyoung.com/home/using-1-wire-ds18b20par-sensors-in-parasitic-mode-on-raspi-with-custom-gpio-pin/ (German)<br />
* I have two DS18B20 and log temperatures using rrdtool.<br />
<br />
* 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). <br />
** Q: Is this due to overclocking with using dynamic governor?<br />
** A: No - also occurs without overclocking (but less frequent?)<br />
** Q: Or is this due to voltage-problems?<br />
** A: No - also occurs without over-voltage<br />
** Q: Or something else?<br />
** 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). Using 3 sensors works almost all the time (without overclocking), but using 4 or more sensors (2 connected star topologies, very bad for 1-wire [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]), almost always fails to read values on most of the sensors.<br />
** A:'''Implement multiple 1-wire interfaces''' (see below), using 1 for each star-topology solved the problem. Reading 2x3 works perfect!<br />
** A: If not adding new devices, disabling 1-wire search after module-loading resolves the device-disconnect issue. Simply put<br />
::<code>wire search_count=5</code><br />
:: in your <code>/etc/modules</code> (I'm not using DTB) to allow only 5 (initial) searches.<br />
<br />
====Multiple 1-wire buses====<br />
:* Inspired and guided by http://www.raspberrypi.org/forums/viewtopic.php?p=513312#p513312, I've patched my 3.12.y kernel <code>arch/arm/mach-bcm2708/bcm2708.c</code> (patch file http://holyhead.de/RaspberryPi/bcm2708-multiple_w-1.patch-3.12.21.txt). Applying this patch to newer kernel versions is straight forward. (Currently I'm running 4.1.10 without device tree.)<br />
::* Note: Some kernel versions ago, device trees were introduced for Raspbian, see for example http://www.raspberrypi.org/documentation/configuration/device-tree.md<BR>So far, I don't know if this works with device trees.<br />
:* I've cross-compiled the kernel on a linux-VM, using the instructions of http://elinux.org/RPi_Kernel_Compilation (compiling on the RaspberryPi takes 6 hours [http://wiki.gentoo.org/wiki/Raspberry_Pi_Kernel_Compilation] or much more [http://elinux.org/RPi_Kernel_Compilation]).<br />
<br />
====Some 1-wire internals====<br />
* https://www.kernel.org/doc/Documentation/w1/w1.generic<br />
* [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]<br />
* http://blog.gegg.us/2013/03/4-different-methods-of-1-wire-access-on-raspberry-pi/<br />
<br />
===Compiling own kernel===<br />
<br />
* Some hints on cross-compiling:<br />
:* http://elinux.org/RPi_Kernel_Compilation<br />
:* https://github.com/raspberrypi/linux/tree/rpi-3.12.y/arch/arm/mach-bcm2708<br />
:* https://github.com/notro/rpi-source/wiki<br />
:* https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489&start=75<br />
:* http://www.bootc.net/projects/raspberry-pi-kernel/<br />
:* http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-recompile.html<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-cross-compile.html<br />
:* http://www.gtkdb.de/index_36_2087.html<br />
<br />
* extract kernel config from image:<br />
::<code>scripts/extract-ikconfig kernel-image</code><br />
::(extract-ikconfig is part of the kernel sources)<br />
<br />
===Device Trees===<br />
<br />
:* http://www.raspberrypi.org/documentation/configuration/device-tree.md<br />
:* https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt<br />
<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=97216<br />
:* http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f<br />
:* http://www.forum-raspberrypi.de/Thread-tutorial-geraetetreiber-und-device-tree-dt (German)<br />
<br />
:* http://xillybus.com/tutorials/device-tree-zynq-1<br />
<br />
===What about updates?===<br />
<br />
As I always forget this<br />
* <code>apt-get update</code> - update package lists<br />
* <code>apt-get upgrade</code> - upgrade installed packages<br />
* <code>rpi-update</code> - update kernel and modules<br />
::use <code>SKIP_KERNEL=1 rpi-update</code> to update the RPi firmware, but keep the current kernel<br />
::set <code>SKIP_REPODELETE=1</code> to keep downloaded files (by default: <code>/root/.rpi-firmware</code>)<br />
<br />
Kernel Sources<br />
* https://github.com/notro/rpi-source gets the source data from https://github.com/Hexxeh/rpi-firmware and https://github.com/raspberrypi/linux/<br />
<br />
===Hints for reading Kernel Panics===<br />
<br />
* http://ptgmedia.pearsoncmg.com/images/013147751X/downloads/013147751X_book.pdf<br />
: p290:<br />
export CONFIG_DEBUG_INFO=1<br />
make kernel/sysctl.o<br />
objdump -d -S kernel/sysctl.o > kernel/sysctl.dump<br />
<br />
or, with my in cross-compiling setup:<br />
<br />
DOMAKE drivers/w1/slave/w1_therm.o<br />
${CCPREFIX}objdump -d -S w1_therm.o <br />
<br />
* http://www.opensourceforu.com/2011/01/understanding-a-kernel-oops/<br />
<br />
* http://www.lowlevel.eu/wiki/ARM-OS-Dev_Teil_2_%E2%80%93_Assembler_101<br />
<br />
==Attaching a LCD display (HD44780 controller)==<br />
<br />
===Wiring and Specs===<br />
<br />
* Specs<br />
** ftp://imall.iteadstudio.com/IM120424018_EONE_2004_Characters_LCD/SPE_IM120424018_EONE_2004_Characters_LCD.pdf<br />
** http://www.adafruit.com/datasheets/HD44780.pdf<br />
<br />
* http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display (German)<br />
<br />
* http://www.pro-linux.de/artikel/2/1624/5,die-anzeige-hardware-und-software.html<br />
<br />
* https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring<br />
<br />
* https://github.com/perryflynn/raspberrypi-misc/tree/master/charlcd_4x20_cmd<br />
<br />
* http://obrazki.elektroda.pl/5028699400_1384164963.jpg<br />
<br />
===Misc===<br />
<br />
* http://www.makerspaceuk.com/lcd-temp-sensor/<br />
<br />
* http://anwendungsentwickler.ws/blog/kategorien/raspberry-pi/4x20-lcd-screen-mit-dem-raspberry-pi.html (German)<br />
<br />
==Controlling the display==<br />
<br />
* Python [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO]<br />
<br />
===LCDProc hints===<br />
<br />
* Pi & GPIO powered HD44780 LCD: http://www.boeeerb.co.uk/pi-lcd/<br />
<br />
* https://metacpan.org/pod/Net::LCDproc<br />
<br />
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=63412<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-user.html<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-dev.html<br />
<br />
* http://tuxgraphics.org/electronics/200504/article375.shtml<br />
<br />
==Todo and Miscellaneous==<br />
<br />
<br />
===Collection of stuff to check - things I might) try sometime===<br />
<br />
* http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/<br />
<br />
* [http://en.wikipedia.org/wiki/F2FS f2fs]<br />
:* [http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=65330 F2fs, Ext4, FAT USB Benchmark]<br />
:* [http://forum.xda-developers.com/showthread.php?t=2697069 File System Performance: F2FS vs EXT4]<br />
<br />
* https://github.com/yuraa/Raspberry-Pi-Heartbeat<br />
<br />
* http://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html<br />
<br />
* [http://www.raspberrypi.org/archives/5282 Mathematica on Raspberry Pi, for free]<br />
:* also works in RasPi emulator, e.g. http://www.heise.de/ct/inhalt/2014/7/160/ (German, teaser to article)<br />
<br />
* NAS/Samba<br />
:* 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:<br />
:<code>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536</code><br />
<br />
* http://linuxtortures.blogspot.fr/2012/06/cross-compiling-and-cross-debugging-c.html<br />
<br />
===Things done===<br />
<br />
* Adjust swap file (size, location -> (ext4) HDD - too slow?): http://manpages.ubuntu.com/manpages/hardy/man8/dphys-swapfile.8.html<br />
<br />
* http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/<br />
<br />
==Some links (aka bookmark lists)==<br />
<br />
Project sites<br />
<br />
* [http://www.cl.cam.ac.uk/projects/raspberrypi/ University of Cambridge / Raspberry Pi Computer Laboratory]<br />
* [https://www.raspiprojekt.de/ raspiprojek] (German)<br />
* http://www.vanheusden.com/misc/rpi.php<br />
<br />
Blogs, forums, etc<br />
* http://www.raspberrypi.org/phpBB3/<br />
* [http://forum.stmlabs.com/forumdisplay.php?fid=6 Stm Labs Forum / Raspbmc]<br />
* [http://www.welzels.de/blog/projekte/raspberry-pi/ Wel!s Blog] (German)<br />
* [http://jankarres.de/category/raspberry-pi/ Raspberry Pi Blog of Jan Karres] (German)<br />
* http://www.forum-raspberrypi.de/ /(German)<br />
* http://raspberrycenter.de/ (German)<br />
* http://archlinuxarm.org/forum/viewforum.php?f=31&sid=57987232ca9177c35eb3ef7fdf6b3341<br />
<br />
* [[wikipedia:Raspberry_Pi Raspberry Pi in Wikipedia]]<br />
<br />
Miscellaneous<br />
<br />
* [http://www.raspberrypi.org/downloads New Out Of Box Software (Recommended)]<br />
* [http://elinux.org/R-Pi_Hub R-Pi_Hub]<br />
<br />
Manuals<br />
<br />
* https://github.com/raspberrypi/documentation<br />
<br />
* [http://debian-handbook.info/browse/stable/ The Debian Administrator's Handbook]</div>Holyheadhttps://holyhead.de/index.php?title=Raspberry_PiRaspberry Pi2015-10-12T14:56:06Z<p>Holyhead: /* Multiple 1-wire buses */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
===External USB drives===<br />
<br />
* Automount USB-Drives in Raspbian<br />
** One may use [http://selfprogramming.bplaced.net/index.php/2012/10/23/automount-usb-drives-in-raspbian/ USBmount and autofs]<br />
** I prefer [http://ignorantguru.github.io/udevil/ udevil], see below<br />
<br />
* Install ''ntfs-3g'' if you need write access to ntfs file systems<br />
<br />
* How to increase performance?<br />
** Mount with option ''''noatime'''' or ''''relatime''''<br />
** Mount ''without'' option sync (e.g. keep default async)<br />
** If using ntfs-3g (fuse) file system, try mounting with option 'big_writes', see for example http://obihoernchen.net/wordpress/tag/big_writes/<br />
<br />
===[http://ignorantguru.github.io/udevil/ udevil]===<br />
<br />
* example for manual mounting:<br />
<br />
udevil mount /dev/sda1<br />
<br />
* auto-mounting via udev-rule, see for example http://lsdlinux.org/wiki/doku.php?id=auto_mounting#using_udev_rule (I just copied the 95-udevil-mount.rules file from an OpenElec installation (http://www.raspberrypi.org/downloads) )<br />
<br />
* my build-steps (maybe there's a simpler way, but this worked...):<br />
** download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget<br />
** extract deb-package via <code>ar vx udevil_0.4.3-1_all.deb</code><br />
** extract data archive <code>tar xzvf data.tar.gz</code><br />
** change to tar usr/share/devil/src<br />
** untar <code>tar xvfJ udevil-current.tar.xz</code><br />
** <code>cd udevil-0.4.3</code><br />
** <code>mv distros/debian</code><br />
** execute <code>dpkg-buildpackage</code><br />
** 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<br />
** Install via <code>sudo dpkg -i udevil_0.4.3-1_armhf.deb</code><br />
<br />
===Samba server / NAS===<br />
<br />
* How to install?<br />
** [http://jankarres.de/2013/11/raspberry-pi-samba-server-installieren/ | Raspberry Pi: Samba Server installieren] (German)<br />
** [http://www.welzels.de/blog/projekte/raspberry-pi/low-budget-nas-mit-einem-raspberry-pi/ Low Budget NAS mit einem Raspberry PI] (German)<br />
<br />
* Slow disc performance?<br />
** see 'Slow USB drives' above<br />
** 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!)<br />
<br />
* Configuration and tuning<br />
** https://calomel.org/samba.html<br />
** https://calomel.org/samba_optimize.html<br />
<br />
* If your /var/log/samba/log.smbd fills up with ''printing/print_cups.c:110(cups_connect) Unable to connect to CUPS server localhost'' messages, try http://www.sotechdesign.com.au/samba-log-showing-error-failed-to-retrieve-printer-list/<br/>I also created an empty <code>/etc/printcap</code> to avoid ''Unable to open printcap file /etc/printcap for read'' messages.<br />
<br />
* I don't need sound:<br />
<br />
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf <br />
# I don't need sound<br />
blacklist snd<br />
blacklist snd_pcm<br />
blacklist snd_soc_core<br />
blacklist snd_soc_bcm2708_i2s<br />
<br />
===Trying to reduce number of disk writes (SD card)===<br />
<br />
I'm using [http://oss.oetiker.ch/rrdtool/ 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).<br />
<br />
Here's what I've done:<br />
<br />
* Edit <code>/etc/default/cron</code> and set <code>EXTRA_OPTS="-L 0"</code> to disable logging (I don't need these)<br />
* Avoid entries like <code>pam_unix(cron:session): session closed for user pi</code> in <code>/var/log/auth.log</code><br />
** Edit <code>/etc/pam.d/cron</code> and comment the line <code>@include common-session-noninteractive</code> ([http://ubuntuforums.org/showthread.php?t=1256801])<br />
:or<br />
:* Edit <code>/etc/pam.d/common-session-noninteractive</code> as shown here: http://ubuntuforums.org/showthread.php?t=1256801&p=10283830#post10283830<br />
* I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)<br />
** moved all the .rrd files as well as the created images to my persistent-ramdisk location<br />
** moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links<br />
*** <code>/var/spool</code><br />
*** <code>/var/log</code><br />
*** <code>/var/cache/samba</code><br />
** edited <code>/etc/insserv.conf</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:<br />
<br />
$local_fs_orig +mountall +mountall-bootclean +mountoverflowtmp +umountfs<br />
# we need the sym-link data in /var/log and /var/spool to be available<br />
$local_fs $local_fs_orig +persist-ramdisk<br />
<br />
:: <code>/etc/init.d/persist-ramdisk</code> 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.<br />
<br />
:* set ''RAMTMP'' to yes in <code>/etc/default/tmpfs</code> to get tempfs based <code>/tmp</code><br />
<br />
Before changing <code>/tmp</code>:<br />
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').<br />
::I need to do more digging...<br />
<br />
After changing <code>/tmp</code>:<br />
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...<br />
<br />
===Useful stuff and Q&A===<br />
<br />
* Q: Why does my Pi restart when hotplugging a USB drive?<br />
** http://thestuffsido.blogspot.de/2013/05/fixing-raspberry-pi-hotplugging.html<br />
** http://therandomlab.blogspot.de/2013/01/raspberry-pi-mod-to-avoid-shutdown-on.html<br />
<br />
* Q: Does Raspberry support WOL?<br />
: A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)<br />
<br />
* Q: The new password is to short, or too simple<br />
: A: Try adjusting the PAM settings in <code>/etc/pam.d/common-password</code>:<br />
:* remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)<br />
::<code>password [success=1 default=ignore] pam_unix.so sha512 minlen=2</code><br />
<br />
::!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!<br><br />
::But it's nice for testing (if you cannot or do not want to use auto-login.)<br />
<br />
* Q: How to configure static IP?<br />
: A: In /etc/network/interfaces:<br />
::<code>iface eth0 inet static<br>address 192.168.0.31<br>netmask 255.255.255.0<br>gateway 192.168.0.1</code><br />
<br />
* Q: How to read core temperature, etc?<br />
: A: [http://elinux.org/RPI_vcgencmd_usage vcgencmd]:<br />
::<code>vcgencmd measure_temp<br>vcgencmd measure_clock arm</code><br />
<br />
* External USB HDD spin down<br />
** hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)<br />
** hd-idle works:<br />
::<code>hd-idle -a sda -i 600</code><br />
:: for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)<br />
<br />
* Q: How to avoid update of a certain package?<br />
: A: Put package on hold ([http://debiananwenderhandbuch.de/dpkg.html] (German)):<br />
::<code>echo <packagename> "hold" | dpkg --set-selections</code><br />
<br />
* [[wikipedia:Raspcontrol]] with nginx<br />
** http://www.foxplex.com/sites/raspcontrol-webinterface-auf-dem-raspberry-pi/ (German), http://www.foxplex.com/sites/performanter-nginx-webserver-auf-dem-raspberry-pi-mit-php-und-apc/ (German)<br />
** http://menzerath.eu/artikel/raspberry-pi-raspcontrol-installation-funktionen/ (German)<br />
<br />
* Q: How many bytes are written to my (SD) disc?<br />
: A: Use <code>iostat</code> http://www.mybinarylife.net/2012/08/linux-iostat-command.html<br />
: A: Use <code>iotop</code> http://guichaz.free.fr/iotop/<br />
: A: Raw data of the kernel can be found in files <code>/proc/diskstats</code> and <code>/sys/block/DEVNAME/stat</code> https://www.kernel.org/doc/Documentation/iostats.txt<br />
:* http://unix.stackexchange.com/questions/86391/how-to-get-total-number-of-bytes-sectors-blocks-written-to-disk-since-booting<br />
:* http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux<br />
<br />
* Q: How to reduce number of ext-fs checks?<br />
: A: <code>tune2fs -c 60 /dev/sda1</code> Change maximum mount count to 60<br />
: A: <code>tune2fs -i 12m /dev/sda1</code> Change check interval to 12 months<br />
: fore more details: http://wiki.ubuntuusers.de/Dateisystemcheck (German)<br />
<br />
* Q: Fix smsc95xx 1-1.1:1.0: eth0: kevent 2 may have been dropped <br />
: A: http://wood1978.techarea.org/~wood/wordpress/2013/04/03/fix-smsc95xx-1-1-11-0-eth0-kevent-2-may-have-been-dropped-on-raspberry-pi-with-arch-linux<br />
::Modifying the sysctl.conf values reduced the kevent-2 messages; I did not yet set smsc95xx.turbo_mode=N<br />
<br />
===Overclocking===<br />
<br />
* I only set overclocking via <code>raspi-config</code><br />
<br />
* ''Turbo'': (Short) Raspberry stress test were ok. But I got an SD card error/corruption when doing a download and a dd-image of the SD card (according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907 the SD card error could be OC related.)<br />
::Luckily, I could recover all my data, see below.<br />
<br />
* '' Medium'': Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907] and its links).<br />
<br />
* Underclocking to 600 MHz<br />
:<code>echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</code><br />
: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.<br />
<br />
* Adjusting the ondemand-governor<br />
** https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt<br />
** set <code>/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor</code> to 10 [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&start=800]<br />
**: I had hoped this reduces the 1-wire CRC errors/device-disconnects problems, but with heavy (IO-) load (e.g. backup), 1wire sensors still get disconnected.<br />
<br />
* [http://moze.free.fr/blog/index.php?post/2013/02/Underclock-and-Overclock Nice power consumption analysis]<br />
<br />
====Stress test and benchmarks====<br />
<br />
* [http://www.roylongbottom.org.uk/ Roy Longbottom's PC Benchmark Collection]<br />
* [http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm Raspberry Pi Stress Tests]<br />
<br />
===SD card issues===<br />
<br />
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). I could still use this card for some time (see below), but finally I got a corrupted file system and could no longer repair it. That's when I re-installed Raspbian on a new SD card.<br />
<br />
Maybe I should try [http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ running from USB] sometime?<br />
<br />
====Recovery====<br />
* Creating a binary image of the SD card with my PC using [http://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] resulted in IO errors at about 17%.<br />
* 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 <code>dd conv=sync,noerror if=/dev/sdb2 of=rasp-image.img bs=1M</code> on my Linux machine (option <code>conv=noerror</code> ignores any errors, sync pads read-errors with zeros). The resulting image could not be mounted using a loop device. <br />
* Fortunately, <code>fsck.ext4 raspberry-image.bin</code> was able to repair the image, which I then could successfully mount on my Linux machine using <code>mount -o loop rasp-image.img /mnt</code>, and at a first glance, everything looked ok. So, I was at least able to get to my data. <br />
* On a later 'event', I dd-ed the repaired image back to the Raspberry, and could boot again.<br />
* On another a later 'event', I just fsck-ed the /dev/sdb2 using Linux, and could boot again... but I did not have luck this time - some files were gone.<br />
* 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.<br />
* My Raspberry successfully booted from this new image. I then used <code>raspi-config</code> to expand the root-fs (I've done this on my first installation as well). With Linux I was able to <code>dd</code> my repaired image to the repaired SD. The card booted as if nothing had happened...<br />
* But after some weeks, my Raspberry fried the SD card again, and some weeks later again ... And finally I could not get my pi to boot with this card. However, I can still read the data linux. Moving data to a new card... (easier said than done if the new card is slightly smaller... but, see below for resizing... and sometimes a fresh install is even less painful).<br />
<br />
===Reminders: dd, dd_rescue, losetup, mount and others===<br />
* Example partition table printed by fdisk:<br />
<code><br />
/dev/sdb: 7861 MB, 7861174272 bytes, 15353856 sectors<br />
Units = Sektoren of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
<br />
Gerät boot. Anfang Ende Blöcke Id System<br />
[...]<br />
/dev/sdb3 15288320 15353855 32768 83 Linux</code><br />
:Byte-offset of sdb3: 7827619840 = 15288320 * 512<br />
<br />
* Mount partition to /dev/loopN partition for repair, etc.<br />
:<code>losetup -o 7827619840 --find --show /dev/sdb</code><br />
:--show prints the used /dev/loopN device<br />
<br />
* Directly mount partition using loop device:<br />
:<code>mount -o loop,offset=7827619840 /dev/sdb /mnt</code><br />
* http://www.garloff.de/kurt/linux/ddrescue/<br />
* http://softwarebakery.com/shrinking-images-on-linux<br />
* http://www.tehfear.com/2007/10/08/resize-loop-disk-image/<br />
* http://wiki.ubuntuusers.de/dd (German)<br />
* http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device<br />
<br />
===Some 1-Wire Stuff===<br />
<br />
====Temperature Sensor DS1820====<br />
<br />
* How to?<br />
** http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/<br />
** https://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&start=1 (German)<br />
** http://kopfkino.irosaurus.com/tutorial-ds18s20-temperatur-sensor-an-einem-raspberry-pi/ (German)<br />
** http://raspberrywebserver.com/cgiscripting/rpi-temperature-logger/<br />
** http://elinux.org/RPi_Low-level_peripherals<br />
** http://www.sdyoung.com/home/using-1-wire-ds18b20par-sensors-in-parasitic-mode-on-raspi-with-custom-gpio-pin/ (German)<br />
* I have two DS18B20 and log temperatures using rrdtool.<br />
<br />
* 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). <br />
** Q: Is this due to overclocking with using dynamic governor?<br />
** A: No - also occurs without overclocking (but less frequent?)<br />
** Q: Or is this due to voltage-problems?<br />
** A: No - also occurs without over-voltage<br />
** Q: Or something else?<br />
** 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). Using 3 sensors works almost all the time (without overclocking), but using 4 or more sensors (2 connected star topologies, very bad for 1-wire [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]), almost always fails to read values on most of the sensors.<br />
** A:'''Implement multiple 1-wire interfaces''' (see below), using 1 for each star-topology solved the problem. Reading 2x3 works perfect!<br />
** A: If not adding new devices, disabling 1-wire search after module-loading resolves the device-disconnect issue. Simply put<br />
::<code>wire search_count=5</code><br />
:: in your <code>/etc/modules</code> (I'm not using DTB) to allow only 5 (initial) searches.<br />
<br />
====Multiple 1-wire buses====<br />
:* Inspired and guided by http://www.raspberrypi.org/forums/viewtopic.php?p=513312#p513312, I've patched my 3.12.y kernel <code>arch/arm/mach-bcm2708/bcm2708.c</code> (patch file http://holyhead.de/RaspberryPi/bcm2708-multiple_w-1.patch-3.12.21.txt). Applying this patch to newer kernel versions is straight forward (currently I'm running 4.1.10).<br />
::* Note: With kernel version, device tree were introduced, see for example http://www.raspberrypi.org/documentation/configuration/device-tree.md<BR>But somehow 1-wire works for my 3.18.5+ without specifying any dtoverlays... And all tries to configure w1-gpio-overlay.dtb via config.txt resulted in my Raspberry not booting (I also tried a modified w1.dtb which should also handle my second w1-bus).<br />
:* I've cross-compiled the kernel on a linux-VM, using the instructions of http://elinux.org/RPi_Kernel_Compilation (compiling on the RaspberryPi takes 6 hours [http://wiki.gentoo.org/wiki/Raspberry_Pi_Kernel_Compilation] or much more [http://elinux.org/RPi_Kernel_Compilation]).<br />
<br />
====Some 1-wire internals====<br />
* https://www.kernel.org/doc/Documentation/w1/w1.generic<br />
* [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]<br />
* http://blog.gegg.us/2013/03/4-different-methods-of-1-wire-access-on-raspberry-pi/<br />
<br />
===Compiling own kernel===<br />
<br />
* Some hints on cross-compiling:<br />
:* http://elinux.org/RPi_Kernel_Compilation<br />
:* https://github.com/raspberrypi/linux/tree/rpi-3.12.y/arch/arm/mach-bcm2708<br />
:* https://github.com/notro/rpi-source/wiki<br />
:* https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489&start=75<br />
:* http://www.bootc.net/projects/raspberry-pi-kernel/<br />
:* http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-recompile.html<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-cross-compile.html<br />
:* http://www.gtkdb.de/index_36_2087.html<br />
<br />
* extract kernel config from image:<br />
::<code>scripts/extract-ikconfig kernel-image</code><br />
::(extract-ikconfig is part of the kernel sources)<br />
<br />
===Device Trees===<br />
<br />
:* http://www.raspberrypi.org/documentation/configuration/device-tree.md<br />
:* https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt<br />
<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=97216<br />
:* http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f<br />
:* http://www.forum-raspberrypi.de/Thread-tutorial-geraetetreiber-und-device-tree-dt (German)<br />
<br />
:* http://xillybus.com/tutorials/device-tree-zynq-1<br />
<br />
===What about updates?===<br />
<br />
As I always forget this<br />
* <code>apt-get update</code> - update package lists<br />
* <code>apt-get upgrade</code> - upgrade installed packages<br />
* <code>rpi-update</code> - update kernel and modules<br />
::use <code>SKIP_KERNEL=1 rpi-update</code> to update the RPi firmware, but keep the current kernel<br />
::set <code>SKIP_REPODELETE=1</code> to keep downloaded files (by default: <code>/root/.rpi-firmware</code>)<br />
<br />
Kernel Sources<br />
* https://github.com/notro/rpi-source gets the source data from https://github.com/Hexxeh/rpi-firmware and https://github.com/raspberrypi/linux/<br />
<br />
===Hints for reading Kernel Panics===<br />
<br />
* http://ptgmedia.pearsoncmg.com/images/013147751X/downloads/013147751X_book.pdf<br />
: p290:<br />
export CONFIG_DEBUG_INFO=1<br />
make kernel/sysctl.o<br />
objdump -d -S kernel/sysctl.o > kernel/sysctl.dump<br />
<br />
or, with my in cross-compiling setup:<br />
<br />
DOMAKE drivers/w1/slave/w1_therm.o<br />
${CCPREFIX}objdump -d -S w1_therm.o <br />
<br />
* http://www.opensourceforu.com/2011/01/understanding-a-kernel-oops/<br />
<br />
* http://www.lowlevel.eu/wiki/ARM-OS-Dev_Teil_2_%E2%80%93_Assembler_101<br />
<br />
==Attaching a LCD display (HD44780 controller)==<br />
<br />
===Wiring and Specs===<br />
<br />
* Specs<br />
** ftp://imall.iteadstudio.com/IM120424018_EONE_2004_Characters_LCD/SPE_IM120424018_EONE_2004_Characters_LCD.pdf<br />
** http://www.adafruit.com/datasheets/HD44780.pdf<br />
<br />
* http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display (German)<br />
<br />
* http://www.pro-linux.de/artikel/2/1624/5,die-anzeige-hardware-und-software.html<br />
<br />
* https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring<br />
<br />
* https://github.com/perryflynn/raspberrypi-misc/tree/master/charlcd_4x20_cmd<br />
<br />
* http://obrazki.elektroda.pl/5028699400_1384164963.jpg<br />
<br />
===Misc===<br />
<br />
* http://www.makerspaceuk.com/lcd-temp-sensor/<br />
<br />
* http://anwendungsentwickler.ws/blog/kategorien/raspberry-pi/4x20-lcd-screen-mit-dem-raspberry-pi.html (German)<br />
<br />
==Controlling the display==<br />
<br />
* Python [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO]<br />
<br />
===LCDProc hints===<br />
<br />
* Pi & GPIO powered HD44780 LCD: http://www.boeeerb.co.uk/pi-lcd/<br />
<br />
* https://metacpan.org/pod/Net::LCDproc<br />
<br />
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=63412<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-user.html<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-dev.html<br />
<br />
* http://tuxgraphics.org/electronics/200504/article375.shtml<br />
<br />
==Todo and Miscellaneous==<br />
<br />
<br />
===Collection of stuff to check - things I might) try sometime===<br />
<br />
* http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/<br />
<br />
* [http://en.wikipedia.org/wiki/F2FS f2fs]<br />
:* [http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=65330 F2fs, Ext4, FAT USB Benchmark]<br />
:* [http://forum.xda-developers.com/showthread.php?t=2697069 File System Performance: F2FS vs EXT4]<br />
<br />
* https://github.com/yuraa/Raspberry-Pi-Heartbeat<br />
<br />
* http://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html<br />
<br />
* [http://www.raspberrypi.org/archives/5282 Mathematica on Raspberry Pi, for free]<br />
:* also works in RasPi emulator, e.g. http://www.heise.de/ct/inhalt/2014/7/160/ (German, teaser to article)<br />
<br />
* NAS/Samba<br />
:* 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:<br />
:<code>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536</code><br />
<br />
* http://linuxtortures.blogspot.fr/2012/06/cross-compiling-and-cross-debugging-c.html<br />
<br />
===Things done===<br />
<br />
* Adjust swap file (size, location -> (ext4) HDD - too slow?): http://manpages.ubuntu.com/manpages/hardy/man8/dphys-swapfile.8.html<br />
<br />
* http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/<br />
<br />
==Some links (aka bookmark lists)==<br />
<br />
Project sites<br />
<br />
* [http://www.cl.cam.ac.uk/projects/raspberrypi/ University of Cambridge / Raspberry Pi Computer Laboratory]<br />
* [https://www.raspiprojekt.de/ raspiprojek] (German)<br />
* http://www.vanheusden.com/misc/rpi.php<br />
<br />
Blogs, forums, etc<br />
* http://www.raspberrypi.org/phpBB3/<br />
* [http://forum.stmlabs.com/forumdisplay.php?fid=6 Stm Labs Forum / Raspbmc]<br />
* [http://www.welzels.de/blog/projekte/raspberry-pi/ Wel!s Blog] (German)<br />
* [http://jankarres.de/category/raspberry-pi/ Raspberry Pi Blog of Jan Karres] (German)<br />
* http://www.forum-raspberrypi.de/ /(German)<br />
* http://raspberrycenter.de/ (German)<br />
* http://archlinuxarm.org/forum/viewforum.php?f=31&sid=57987232ca9177c35eb3ef7fdf6b3341<br />
<br />
* [[wikipedia:Raspberry_Pi Raspberry Pi in Wikipedia]]<br />
<br />
Miscellaneous<br />
<br />
* [http://www.raspberrypi.org/downloads New Out Of Box Software (Recommended)]<br />
* [http://elinux.org/R-Pi_Hub R-Pi_Hub]<br />
<br />
Manuals<br />
<br />
* https://github.com/raspberrypi/documentation<br />
<br />
* [http://debian-handbook.info/browse/stable/ The Debian Administrator's Handbook]</div>Holyheadhttps://holyhead.de/index.php?title=Raspberry_PiRaspberry Pi2015-10-12T14:54:14Z<p>Holyhead: /* Temperature Sensor DS1820 */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
===External USB drives===<br />
<br />
* Automount USB-Drives in Raspbian<br />
** One may use [http://selfprogramming.bplaced.net/index.php/2012/10/23/automount-usb-drives-in-raspbian/ USBmount and autofs]<br />
** I prefer [http://ignorantguru.github.io/udevil/ udevil], see below<br />
<br />
* Install ''ntfs-3g'' if you need write access to ntfs file systems<br />
<br />
* How to increase performance?<br />
** Mount with option ''''noatime'''' or ''''relatime''''<br />
** Mount ''without'' option sync (e.g. keep default async)<br />
** If using ntfs-3g (fuse) file system, try mounting with option 'big_writes', see for example http://obihoernchen.net/wordpress/tag/big_writes/<br />
<br />
===[http://ignorantguru.github.io/udevil/ udevil]===<br />
<br />
* example for manual mounting:<br />
<br />
udevil mount /dev/sda1<br />
<br />
* auto-mounting via udev-rule, see for example http://lsdlinux.org/wiki/doku.php?id=auto_mounting#using_udev_rule (I just copied the 95-udevil-mount.rules file from an OpenElec installation (http://www.raspberrypi.org/downloads) )<br />
<br />
* my build-steps (maybe there's a simpler way, but this worked...):<br />
** download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget<br />
** extract deb-package via <code>ar vx udevil_0.4.3-1_all.deb</code><br />
** extract data archive <code>tar xzvf data.tar.gz</code><br />
** change to tar usr/share/devil/src<br />
** untar <code>tar xvfJ udevil-current.tar.xz</code><br />
** <code>cd udevil-0.4.3</code><br />
** <code>mv distros/debian</code><br />
** execute <code>dpkg-buildpackage</code><br />
** 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<br />
** Install via <code>sudo dpkg -i udevil_0.4.3-1_armhf.deb</code><br />
<br />
===Samba server / NAS===<br />
<br />
* How to install?<br />
** [http://jankarres.de/2013/11/raspberry-pi-samba-server-installieren/ | Raspberry Pi: Samba Server installieren] (German)<br />
** [http://www.welzels.de/blog/projekte/raspberry-pi/low-budget-nas-mit-einem-raspberry-pi/ Low Budget NAS mit einem Raspberry PI] (German)<br />
<br />
* Slow disc performance?<br />
** see 'Slow USB drives' above<br />
** 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!)<br />
<br />
* Configuration and tuning<br />
** https://calomel.org/samba.html<br />
** https://calomel.org/samba_optimize.html<br />
<br />
* If your /var/log/samba/log.smbd fills up with ''printing/print_cups.c:110(cups_connect) Unable to connect to CUPS server localhost'' messages, try http://www.sotechdesign.com.au/samba-log-showing-error-failed-to-retrieve-printer-list/<br/>I also created an empty <code>/etc/printcap</code> to avoid ''Unable to open printcap file /etc/printcap for read'' messages.<br />
<br />
* I don't need sound:<br />
<br />
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf <br />
# I don't need sound<br />
blacklist snd<br />
blacklist snd_pcm<br />
blacklist snd_soc_core<br />
blacklist snd_soc_bcm2708_i2s<br />
<br />
===Trying to reduce number of disk writes (SD card)===<br />
<br />
I'm using [http://oss.oetiker.ch/rrdtool/ 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).<br />
<br />
Here's what I've done:<br />
<br />
* Edit <code>/etc/default/cron</code> and set <code>EXTRA_OPTS="-L 0"</code> to disable logging (I don't need these)<br />
* Avoid entries like <code>pam_unix(cron:session): session closed for user pi</code> in <code>/var/log/auth.log</code><br />
** Edit <code>/etc/pam.d/cron</code> and comment the line <code>@include common-session-noninteractive</code> ([http://ubuntuforums.org/showthread.php?t=1256801])<br />
:or<br />
:* Edit <code>/etc/pam.d/common-session-noninteractive</code> as shown here: http://ubuntuforums.org/showthread.php?t=1256801&p=10283830#post10283830<br />
* I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)<br />
** moved all the .rrd files as well as the created images to my persistent-ramdisk location<br />
** moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links<br />
*** <code>/var/spool</code><br />
*** <code>/var/log</code><br />
*** <code>/var/cache/samba</code><br />
** edited <code>/etc/insserv.conf</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:<br />
<br />
$local_fs_orig +mountall +mountall-bootclean +mountoverflowtmp +umountfs<br />
# we need the sym-link data in /var/log and /var/spool to be available<br />
$local_fs $local_fs_orig +persist-ramdisk<br />
<br />
:: <code>/etc/init.d/persist-ramdisk</code> 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.<br />
<br />
:* set ''RAMTMP'' to yes in <code>/etc/default/tmpfs</code> to get tempfs based <code>/tmp</code><br />
<br />
Before changing <code>/tmp</code>:<br />
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').<br />
::I need to do more digging...<br />
<br />
After changing <code>/tmp</code>:<br />
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...<br />
<br />
===Useful stuff and Q&A===<br />
<br />
* Q: Why does my Pi restart when hotplugging a USB drive?<br />
** http://thestuffsido.blogspot.de/2013/05/fixing-raspberry-pi-hotplugging.html<br />
** http://therandomlab.blogspot.de/2013/01/raspberry-pi-mod-to-avoid-shutdown-on.html<br />
<br />
* Q: Does Raspberry support WOL?<br />
: A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)<br />
<br />
* Q: The new password is to short, or too simple<br />
: A: Try adjusting the PAM settings in <code>/etc/pam.d/common-password</code>:<br />
:* remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)<br />
::<code>password [success=1 default=ignore] pam_unix.so sha512 minlen=2</code><br />
<br />
::!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!<br><br />
::But it's nice for testing (if you cannot or do not want to use auto-login.)<br />
<br />
* Q: How to configure static IP?<br />
: A: In /etc/network/interfaces:<br />
::<code>iface eth0 inet static<br>address 192.168.0.31<br>netmask 255.255.255.0<br>gateway 192.168.0.1</code><br />
<br />
* Q: How to read core temperature, etc?<br />
: A: [http://elinux.org/RPI_vcgencmd_usage vcgencmd]:<br />
::<code>vcgencmd measure_temp<br>vcgencmd measure_clock arm</code><br />
<br />
* External USB HDD spin down<br />
** hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)<br />
** hd-idle works:<br />
::<code>hd-idle -a sda -i 600</code><br />
:: for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)<br />
<br />
* Q: How to avoid update of a certain package?<br />
: A: Put package on hold ([http://debiananwenderhandbuch.de/dpkg.html] (German)):<br />
::<code>echo <packagename> "hold" | dpkg --set-selections</code><br />
<br />
* [[wikipedia:Raspcontrol]] with nginx<br />
** http://www.foxplex.com/sites/raspcontrol-webinterface-auf-dem-raspberry-pi/ (German), http://www.foxplex.com/sites/performanter-nginx-webserver-auf-dem-raspberry-pi-mit-php-und-apc/ (German)<br />
** http://menzerath.eu/artikel/raspberry-pi-raspcontrol-installation-funktionen/ (German)<br />
<br />
* Q: How many bytes are written to my (SD) disc?<br />
: A: Use <code>iostat</code> http://www.mybinarylife.net/2012/08/linux-iostat-command.html<br />
: A: Use <code>iotop</code> http://guichaz.free.fr/iotop/<br />
: A: Raw data of the kernel can be found in files <code>/proc/diskstats</code> and <code>/sys/block/DEVNAME/stat</code> https://www.kernel.org/doc/Documentation/iostats.txt<br />
:* http://unix.stackexchange.com/questions/86391/how-to-get-total-number-of-bytes-sectors-blocks-written-to-disk-since-booting<br />
:* http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux<br />
<br />
* Q: How to reduce number of ext-fs checks?<br />
: A: <code>tune2fs -c 60 /dev/sda1</code> Change maximum mount count to 60<br />
: A: <code>tune2fs -i 12m /dev/sda1</code> Change check interval to 12 months<br />
: fore more details: http://wiki.ubuntuusers.de/Dateisystemcheck (German)<br />
<br />
* Q: Fix smsc95xx 1-1.1:1.0: eth0: kevent 2 may have been dropped <br />
: A: http://wood1978.techarea.org/~wood/wordpress/2013/04/03/fix-smsc95xx-1-1-11-0-eth0-kevent-2-may-have-been-dropped-on-raspberry-pi-with-arch-linux<br />
::Modifying the sysctl.conf values reduced the kevent-2 messages; I did not yet set smsc95xx.turbo_mode=N<br />
<br />
===Overclocking===<br />
<br />
* I only set overclocking via <code>raspi-config</code><br />
<br />
* ''Turbo'': (Short) Raspberry stress test were ok. But I got an SD card error/corruption when doing a download and a dd-image of the SD card (according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907 the SD card error could be OC related.)<br />
::Luckily, I could recover all my data, see below.<br />
<br />
* '' Medium'': Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907] and its links).<br />
<br />
* Underclocking to 600 MHz<br />
:<code>echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</code><br />
: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.<br />
<br />
* Adjusting the ondemand-governor<br />
** https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt<br />
** set <code>/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor</code> to 10 [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&start=800]<br />
**: I had hoped this reduces the 1-wire CRC errors/device-disconnects problems, but with heavy (IO-) load (e.g. backup), 1wire sensors still get disconnected.<br />
<br />
* [http://moze.free.fr/blog/index.php?post/2013/02/Underclock-and-Overclock Nice power consumption analysis]<br />
<br />
====Stress test and benchmarks====<br />
<br />
* [http://www.roylongbottom.org.uk/ Roy Longbottom's PC Benchmark Collection]<br />
* [http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm Raspberry Pi Stress Tests]<br />
<br />
===SD card issues===<br />
<br />
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). I could still use this card for some time (see below), but finally I got a corrupted file system and could no longer repair it. That's when I re-installed Raspbian on a new SD card.<br />
<br />
Maybe I should try [http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ running from USB] sometime?<br />
<br />
====Recovery====<br />
* Creating a binary image of the SD card with my PC using [http://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] resulted in IO errors at about 17%.<br />
* 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 <code>dd conv=sync,noerror if=/dev/sdb2 of=rasp-image.img bs=1M</code> on my Linux machine (option <code>conv=noerror</code> ignores any errors, sync pads read-errors with zeros). The resulting image could not be mounted using a loop device. <br />
* Fortunately, <code>fsck.ext4 raspberry-image.bin</code> was able to repair the image, which I then could successfully mount on my Linux machine using <code>mount -o loop rasp-image.img /mnt</code>, and at a first glance, everything looked ok. So, I was at least able to get to my data. <br />
* On a later 'event', I dd-ed the repaired image back to the Raspberry, and could boot again.<br />
* On another a later 'event', I just fsck-ed the /dev/sdb2 using Linux, and could boot again... but I did not have luck this time - some files were gone.<br />
* 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.<br />
* My Raspberry successfully booted from this new image. I then used <code>raspi-config</code> to expand the root-fs (I've done this on my first installation as well). With Linux I was able to <code>dd</code> my repaired image to the repaired SD. The card booted as if nothing had happened...<br />
* But after some weeks, my Raspberry fried the SD card again, and some weeks later again ... And finally I could not get my pi to boot with this card. However, I can still read the data linux. Moving data to a new card... (easier said than done if the new card is slightly smaller... but, see below for resizing... and sometimes a fresh install is even less painful).<br />
<br />
===Reminders: dd, dd_rescue, losetup, mount and others===<br />
* Example partition table printed by fdisk:<br />
<code><br />
/dev/sdb: 7861 MB, 7861174272 bytes, 15353856 sectors<br />
Units = Sektoren of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
<br />
Gerät boot. Anfang Ende Blöcke Id System<br />
[...]<br />
/dev/sdb3 15288320 15353855 32768 83 Linux</code><br />
:Byte-offset of sdb3: 7827619840 = 15288320 * 512<br />
<br />
* Mount partition to /dev/loopN partition for repair, etc.<br />
:<code>losetup -o 7827619840 --find --show /dev/sdb</code><br />
:--show prints the used /dev/loopN device<br />
<br />
* Directly mount partition using loop device:<br />
:<code>mount -o loop,offset=7827619840 /dev/sdb /mnt</code><br />
* http://www.garloff.de/kurt/linux/ddrescue/<br />
* http://softwarebakery.com/shrinking-images-on-linux<br />
* http://www.tehfear.com/2007/10/08/resize-loop-disk-image/<br />
* http://wiki.ubuntuusers.de/dd (German)<br />
* http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device<br />
<br />
===Some 1-Wire Stuff===<br />
<br />
====Temperature Sensor DS1820====<br />
<br />
* How to?<br />
** http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/<br />
** https://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&start=1 (German)<br />
** http://kopfkino.irosaurus.com/tutorial-ds18s20-temperatur-sensor-an-einem-raspberry-pi/ (German)<br />
** http://raspberrywebserver.com/cgiscripting/rpi-temperature-logger/<br />
** http://elinux.org/RPi_Low-level_peripherals<br />
** http://www.sdyoung.com/home/using-1-wire-ds18b20par-sensors-in-parasitic-mode-on-raspi-with-custom-gpio-pin/ (German)<br />
* I have two DS18B20 and log temperatures using rrdtool.<br />
<br />
* 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). <br />
** Q: Is this due to overclocking with using dynamic governor?<br />
** A: No - also occurs without overclocking (but less frequent?)<br />
** Q: Or is this due to voltage-problems?<br />
** A: No - also occurs without over-voltage<br />
** Q: Or something else?<br />
** 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). Using 3 sensors works almost all the time (without overclocking), but using 4 or more sensors (2 connected star topologies, very bad for 1-wire [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]), almost always fails to read values on most of the sensors.<br />
** A:'''Implement multiple 1-wire interfaces''' (see below), using 1 for each star-topology solved the problem. Reading 2x3 works perfect!<br />
** A: If not adding new devices, disabling 1-wire search after module-loading resolves the device-disconnect issue. Simply put<br />
::<code>wire search_count=5</code><br />
:: in your <code>/etc/modules</code> (I'm not using DTB) to allow only 5 (initial) searches.<br />
<br />
====Multiple 1-wire buses====<br />
:* Inspired and guided by http://www.raspberrypi.org/forums/viewtopic.php?p=513312#p513312, I've patched my 3.12.y kernel <code>arch/arm/mach-bcm2708/bcm2708.c</code> (patch file http://holyhead.de/RaspberryPi/bcm2708-multiple_w-1.patch-3.12.21.txt).<br />
::* Note: With kernel version, device tree were introduced, see for example http://www.raspberrypi.org/documentation/configuration/device-tree.md<BR>But somehow 1-wire works for my 3.18.5+ without specifying any dtoverlays... And all tries to configure w1-gpio-overlay.dtb via config.txt resulted in my Raspberry not booting (I also tried a modified w1.dtb which should also handle my second w1-bus).<br />
:* I've cross-compiled the kernel on a linux-VM, using the instructions of http://elinux.org/RPi_Kernel_Compilation (compiling on the RaspberryPi takes 6 hours [http://wiki.gentoo.org/wiki/Raspberry_Pi_Kernel_Compilation] or much more [http://elinux.org/RPi_Kernel_Compilation]).<br />
<br />
====Some 1-wire internals====<br />
* https://www.kernel.org/doc/Documentation/w1/w1.generic<br />
* [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]<br />
* http://blog.gegg.us/2013/03/4-different-methods-of-1-wire-access-on-raspberry-pi/<br />
<br />
===Compiling own kernel===<br />
<br />
* Some hints on cross-compiling:<br />
:* http://elinux.org/RPi_Kernel_Compilation<br />
:* https://github.com/raspberrypi/linux/tree/rpi-3.12.y/arch/arm/mach-bcm2708<br />
:* https://github.com/notro/rpi-source/wiki<br />
:* https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489&start=75<br />
:* http://www.bootc.net/projects/raspberry-pi-kernel/<br />
:* http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-recompile.html<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-cross-compile.html<br />
:* http://www.gtkdb.de/index_36_2087.html<br />
<br />
* extract kernel config from image:<br />
::<code>scripts/extract-ikconfig kernel-image</code><br />
::(extract-ikconfig is part of the kernel sources)<br />
<br />
===Device Trees===<br />
<br />
:* http://www.raspberrypi.org/documentation/configuration/device-tree.md<br />
:* https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt<br />
<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=97216<br />
:* http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f<br />
:* http://www.forum-raspberrypi.de/Thread-tutorial-geraetetreiber-und-device-tree-dt (German)<br />
<br />
:* http://xillybus.com/tutorials/device-tree-zynq-1<br />
<br />
===What about updates?===<br />
<br />
As I always forget this<br />
* <code>apt-get update</code> - update package lists<br />
* <code>apt-get upgrade</code> - upgrade installed packages<br />
* <code>rpi-update</code> - update kernel and modules<br />
::use <code>SKIP_KERNEL=1 rpi-update</code> to update the RPi firmware, but keep the current kernel<br />
::set <code>SKIP_REPODELETE=1</code> to keep downloaded files (by default: <code>/root/.rpi-firmware</code>)<br />
<br />
Kernel Sources<br />
* https://github.com/notro/rpi-source gets the source data from https://github.com/Hexxeh/rpi-firmware and https://github.com/raspberrypi/linux/<br />
<br />
===Hints for reading Kernel Panics===<br />
<br />
* http://ptgmedia.pearsoncmg.com/images/013147751X/downloads/013147751X_book.pdf<br />
: p290:<br />
export CONFIG_DEBUG_INFO=1<br />
make kernel/sysctl.o<br />
objdump -d -S kernel/sysctl.o > kernel/sysctl.dump<br />
<br />
or, with my in cross-compiling setup:<br />
<br />
DOMAKE drivers/w1/slave/w1_therm.o<br />
${CCPREFIX}objdump -d -S w1_therm.o <br />
<br />
* http://www.opensourceforu.com/2011/01/understanding-a-kernel-oops/<br />
<br />
* http://www.lowlevel.eu/wiki/ARM-OS-Dev_Teil_2_%E2%80%93_Assembler_101<br />
<br />
==Attaching a LCD display (HD44780 controller)==<br />
<br />
===Wiring and Specs===<br />
<br />
* Specs<br />
** ftp://imall.iteadstudio.com/IM120424018_EONE_2004_Characters_LCD/SPE_IM120424018_EONE_2004_Characters_LCD.pdf<br />
** http://www.adafruit.com/datasheets/HD44780.pdf<br />
<br />
* http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display (German)<br />
<br />
* http://www.pro-linux.de/artikel/2/1624/5,die-anzeige-hardware-und-software.html<br />
<br />
* https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring<br />
<br />
* https://github.com/perryflynn/raspberrypi-misc/tree/master/charlcd_4x20_cmd<br />
<br />
* http://obrazki.elektroda.pl/5028699400_1384164963.jpg<br />
<br />
===Misc===<br />
<br />
* http://www.makerspaceuk.com/lcd-temp-sensor/<br />
<br />
* http://anwendungsentwickler.ws/blog/kategorien/raspberry-pi/4x20-lcd-screen-mit-dem-raspberry-pi.html (German)<br />
<br />
==Controlling the display==<br />
<br />
* Python [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO]<br />
<br />
===LCDProc hints===<br />
<br />
* Pi & GPIO powered HD44780 LCD: http://www.boeeerb.co.uk/pi-lcd/<br />
<br />
* https://metacpan.org/pod/Net::LCDproc<br />
<br />
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=63412<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-user.html<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-dev.html<br />
<br />
* http://tuxgraphics.org/electronics/200504/article375.shtml<br />
<br />
==Todo and Miscellaneous==<br />
<br />
<br />
===Collection of stuff to check - things I might) try sometime===<br />
<br />
* http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/<br />
<br />
* [http://en.wikipedia.org/wiki/F2FS f2fs]<br />
:* [http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=65330 F2fs, Ext4, FAT USB Benchmark]<br />
:* [http://forum.xda-developers.com/showthread.php?t=2697069 File System Performance: F2FS vs EXT4]<br />
<br />
* https://github.com/yuraa/Raspberry-Pi-Heartbeat<br />
<br />
* http://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html<br />
<br />
* [http://www.raspberrypi.org/archives/5282 Mathematica on Raspberry Pi, for free]<br />
:* also works in RasPi emulator, e.g. http://www.heise.de/ct/inhalt/2014/7/160/ (German, teaser to article)<br />
<br />
* NAS/Samba<br />
:* 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:<br />
:<code>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536</code><br />
<br />
* http://linuxtortures.blogspot.fr/2012/06/cross-compiling-and-cross-debugging-c.html<br />
<br />
===Things done===<br />
<br />
* Adjust swap file (size, location -> (ext4) HDD - too slow?): http://manpages.ubuntu.com/manpages/hardy/man8/dphys-swapfile.8.html<br />
<br />
* http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/<br />
<br />
==Some links (aka bookmark lists)==<br />
<br />
Project sites<br />
<br />
* [http://www.cl.cam.ac.uk/projects/raspberrypi/ University of Cambridge / Raspberry Pi Computer Laboratory]<br />
* [https://www.raspiprojekt.de/ raspiprojek] (German)<br />
* http://www.vanheusden.com/misc/rpi.php<br />
<br />
Blogs, forums, etc<br />
* http://www.raspberrypi.org/phpBB3/<br />
* [http://forum.stmlabs.com/forumdisplay.php?fid=6 Stm Labs Forum / Raspbmc]<br />
* [http://www.welzels.de/blog/projekte/raspberry-pi/ Wel!s Blog] (German)<br />
* [http://jankarres.de/category/raspberry-pi/ Raspberry Pi Blog of Jan Karres] (German)<br />
* http://www.forum-raspberrypi.de/ /(German)<br />
* http://raspberrycenter.de/ (German)<br />
* http://archlinuxarm.org/forum/viewforum.php?f=31&sid=57987232ca9177c35eb3ef7fdf6b3341<br />
<br />
* [[wikipedia:Raspberry_Pi Raspberry Pi in Wikipedia]]<br />
<br />
Miscellaneous<br />
<br />
* [http://www.raspberrypi.org/downloads New Out Of Box Software (Recommended)]<br />
* [http://elinux.org/R-Pi_Hub R-Pi_Hub]<br />
<br />
Manuals<br />
<br />
* https://github.com/raspberrypi/documentation<br />
<br />
* [http://debian-handbook.info/browse/stable/ The Debian Administrator's Handbook]</div>Holyheadhttps://holyhead.de/index.php?title=Raspberry_PiRaspberry Pi2015-02-13T05:59:26Z<p>Holyhead: /* Hints for reading Kernel Panics */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
===External USB drives===<br />
<br />
* Automount USB-Drives in Raspbian<br />
** One may use [http://selfprogramming.bplaced.net/index.php/2012/10/23/automount-usb-drives-in-raspbian/ USBmount and autofs]<br />
** I prefer [http://ignorantguru.github.io/udevil/ udevil], see below<br />
<br />
* Install ''ntfs-3g'' if you need write access to ntfs file systems<br />
<br />
* How to increase performance?<br />
** Mount with option ''''noatime'''' or ''''relatime''''<br />
** Mount ''without'' option sync (e.g. keep default async)<br />
** If using ntfs-3g (fuse) file system, try mounting with option 'big_writes', see for example http://obihoernchen.net/wordpress/tag/big_writes/<br />
<br />
===[http://ignorantguru.github.io/udevil/ udevil]===<br />
<br />
* example for manual mounting:<br />
<br />
udevil mount /dev/sda1<br />
<br />
* auto-mounting via udev-rule, see for example http://lsdlinux.org/wiki/doku.php?id=auto_mounting#using_udev_rule (I just copied the 95-udevil-mount.rules file from an OpenElec installation (http://www.raspberrypi.org/downloads) )<br />
<br />
* my build-steps (maybe there's a simpler way, but this worked...):<br />
** download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget<br />
** extract deb-package via <code>ar vx udevil_0.4.3-1_all.deb</code><br />
** extract data archive <code>tar xzvf data.tar.gz</code><br />
** change to tar usr/share/devil/src<br />
** untar <code>tar xvfJ udevil-current.tar.xz</code><br />
** <code>cd udevil-0.4.3</code><br />
** <code>mv distros/debian</code><br />
** execute <code>dpkg-buildpackage</code><br />
** 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<br />
** Install via <code>sudo dpkg -i udevil_0.4.3-1_armhf.deb</code><br />
<br />
===Samba server / NAS===<br />
<br />
* How to install?<br />
** [http://jankarres.de/2013/11/raspberry-pi-samba-server-installieren/ | Raspberry Pi: Samba Server installieren] (German)<br />
** [http://www.welzels.de/blog/projekte/raspberry-pi/low-budget-nas-mit-einem-raspberry-pi/ Low Budget NAS mit einem Raspberry PI] (German)<br />
<br />
* Slow disc performance?<br />
** see 'Slow USB drives' above<br />
** 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!)<br />
<br />
* Configuration and tuning<br />
** https://calomel.org/samba.html<br />
** https://calomel.org/samba_optimize.html<br />
<br />
* If your /var/log/samba/log.smbd fills up with ''printing/print_cups.c:110(cups_connect) Unable to connect to CUPS server localhost'' messages, try http://www.sotechdesign.com.au/samba-log-showing-error-failed-to-retrieve-printer-list/<br/>I also created an empty <code>/etc/printcap</code> to avoid ''Unable to open printcap file /etc/printcap for read'' messages.<br />
<br />
* I don't need sound:<br />
<br />
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf <br />
# I don't need sound<br />
blacklist snd<br />
blacklist snd_pcm<br />
blacklist snd_soc_core<br />
blacklist snd_soc_bcm2708_i2s<br />
<br />
===Trying to reduce number of disk writes (SD card)===<br />
<br />
I'm using [http://oss.oetiker.ch/rrdtool/ 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).<br />
<br />
Here's what I've done:<br />
<br />
* Edit <code>/etc/default/cron</code> and set <code>EXTRA_OPTS="-L 0"</code> to disable logging (I don't need these)<br />
* Avoid entries like <code>pam_unix(cron:session): session closed for user pi</code> in <code>/var/log/auth.log</code><br />
** Edit <code>/etc/pam.d/cron</code> and comment the line <code>@include common-session-noninteractive</code> ([http://ubuntuforums.org/showthread.php?t=1256801])<br />
:or<br />
:* Edit <code>/etc/pam.d/common-session-noninteractive</code> as shown here: http://ubuntuforums.org/showthread.php?t=1256801&p=10283830#post10283830<br />
* I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)<br />
** moved all the .rrd files as well as the created images to my persistent-ramdisk location<br />
** moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links<br />
*** <code>/var/spool</code><br />
*** <code>/var/log</code><br />
*** <code>/var/cache/samba</code><br />
** edited <code>/etc/insserv.conf</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:<br />
<br />
$local_fs_orig +mountall +mountall-bootclean +mountoverflowtmp +umountfs<br />
# we need the sym-link data in /var/log and /var/spool to be available<br />
$local_fs $local_fs_orig +persist-ramdisk<br />
<br />
:: <code>/etc/init.d/persist-ramdisk</code> 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.<br />
<br />
:* set ''RAMTMP'' to yes in <code>/etc/default/tmpfs</code> to get tempfs based <code>/tmp</code><br />
<br />
Before changing <code>/tmp</code>:<br />
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').<br />
::I need to do more digging...<br />
<br />
After changing <code>/tmp</code>:<br />
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...<br />
<br />
===Useful stuff and Q&A===<br />
<br />
* Q: Why does my Pi restart when hotplugging a USB drive?<br />
** http://thestuffsido.blogspot.de/2013/05/fixing-raspberry-pi-hotplugging.html<br />
** http://therandomlab.blogspot.de/2013/01/raspberry-pi-mod-to-avoid-shutdown-on.html<br />
<br />
* Q: Does Raspberry support WOL?<br />
: A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)<br />
<br />
* Q: The new password is to short, or too simple<br />
: A: Try adjusting the PAM settings in <code>/etc/pam.d/common-password</code>:<br />
:* remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)<br />
::<code>password [success=1 default=ignore] pam_unix.so sha512 minlen=2</code><br />
<br />
::!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!<br><br />
::But it's nice for testing (if you cannot or do not want to use auto-login.)<br />
<br />
* Q: How to configure static IP?<br />
: A: In /etc/network/interfaces:<br />
::<code>iface eth0 inet static<br>address 192.168.0.31<br>netmask 255.255.255.0<br>gateway 192.168.0.1</code><br />
<br />
* Q: How to read core temperature, etc?<br />
: A: [http://elinux.org/RPI_vcgencmd_usage vcgencmd]:<br />
::<code>vcgencmd measure_temp<br>vcgencmd measure_clock arm</code><br />
<br />
* External USB HDD spin down<br />
** hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)<br />
** hd-idle works:<br />
::<code>hd-idle -a sda -i 600</code><br />
:: for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)<br />
<br />
* Q: How to avoid update of a certain package?<br />
: A: Put package on hold ([http://debiananwenderhandbuch.de/dpkg.html] (German)):<br />
::<code>echo <packagename> "hold" | dpkg --set-selections</code><br />
<br />
* [[wikipedia:Raspcontrol]] with nginx<br />
** http://www.foxplex.com/sites/raspcontrol-webinterface-auf-dem-raspberry-pi/ (German), http://www.foxplex.com/sites/performanter-nginx-webserver-auf-dem-raspberry-pi-mit-php-und-apc/ (German)<br />
** http://menzerath.eu/artikel/raspberry-pi-raspcontrol-installation-funktionen/ (German)<br />
<br />
* Q: How many bytes are written to my (SD) disc?<br />
: A: Use <code>iostat</code> http://www.mybinarylife.net/2012/08/linux-iostat-command.html<br />
: A: Use <code>iotop</code> http://guichaz.free.fr/iotop/<br />
: A: Raw data of the kernel can be found in files <code>/proc/diskstats</code> and <code>/sys/block/DEVNAME/stat</code> https://www.kernel.org/doc/Documentation/iostats.txt<br />
:* http://unix.stackexchange.com/questions/86391/how-to-get-total-number-of-bytes-sectors-blocks-written-to-disk-since-booting<br />
:* http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux<br />
<br />
* Q: How to reduce number of ext-fs checks?<br />
: A: <code>tune2fs -c 60 /dev/sda1</code> Change maximum mount count to 60<br />
: A: <code>tune2fs -i 12m /dev/sda1</code> Change check interval to 12 months<br />
: fore more details: http://wiki.ubuntuusers.de/Dateisystemcheck (German)<br />
<br />
* Q: Fix smsc95xx 1-1.1:1.0: eth0: kevent 2 may have been dropped <br />
: A: http://wood1978.techarea.org/~wood/wordpress/2013/04/03/fix-smsc95xx-1-1-11-0-eth0-kevent-2-may-have-been-dropped-on-raspberry-pi-with-arch-linux<br />
::Modifying the sysctl.conf values reduced the kevent-2 messages; I did not yet set smsc95xx.turbo_mode=N<br />
<br />
===Overclocking===<br />
<br />
* I only set overclocking via <code>raspi-config</code><br />
<br />
* ''Turbo'': (Short) Raspberry stress test were ok. But I got an SD card error/corruption when doing a download and a dd-image of the SD card (according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907 the SD card error could be OC related.)<br />
::Luckily, I could recover all my data, see below.<br />
<br />
* '' Medium'': Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907] and its links).<br />
<br />
* Underclocking to 600 MHz<br />
:<code>echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</code><br />
: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.<br />
<br />
* Adjusting the ondemand-governor<br />
** https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt<br />
** set <code>/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor</code> to 10 [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&start=800]<br />
**: I had hoped this reduces the 1-wire CRC errors/device-disconnects problems, but with heavy (IO-) load (e.g. backup), 1wire sensors still get disconnected.<br />
<br />
* [http://moze.free.fr/blog/index.php?post/2013/02/Underclock-and-Overclock Nice power consumption analysis]<br />
<br />
====Stress test and benchmarks====<br />
<br />
* [http://www.roylongbottom.org.uk/ Roy Longbottom's PC Benchmark Collection]<br />
* [http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm Raspberry Pi Stress Tests]<br />
<br />
===SD card issues===<br />
<br />
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). I could still use this card for some time (see below), but finally I got a corrupted file system and could no longer repair it. That's when I re-installed Raspbian on a new SD card.<br />
<br />
Maybe I should try [http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ running from USB] sometime?<br />
<br />
====Recovery====<br />
* Creating a binary image of the SD card with my PC using [http://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] resulted in IO errors at about 17%.<br />
* 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 <code>dd conv=sync,noerror if=/dev/sdb2 of=rasp-image.img bs=1M</code> on my Linux machine (option <code>conv=noerror</code> ignores any errors, sync pads read-errors with zeros). The resulting image could not be mounted using a loop device. <br />
* Fortunately, <code>fsck.ext4 raspberry-image.bin</code> was able to repair the image, which I then could successfully mount on my Linux machine using <code>mount -o loop rasp-image.img /mnt</code>, and at a first glance, everything looked ok. So, I was at least able to get to my data. <br />
* On a later 'event', I dd-ed the repaired image back to the Raspberry, and could boot again.<br />
* On another a later 'event', I just fsck-ed the /dev/sdb2 using Linux, and could boot again... but I did not have luck this time - some files were gone.<br />
* 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.<br />
* My Raspberry successfully booted from this new image. I then used <code>raspi-config</code> to expand the root-fs (I've done this on my first installation as well). With Linux I was able to <code>dd</code> my repaired image to the repaired SD. The card booted as if nothing had happened...<br />
* But after some weeks, my Raspberry fried the SD card again, and some weeks later again ... And finally I could not get my pi to boot with this card. However, I can still read the data linux. Moving data to a new card... (easier said than done if the new card is slightly smaller... but, see below for resizing... and sometimes a fresh install is even less painful).<br />
<br />
===Reminders: dd, dd_rescue, losetup, mount and others===<br />
* Example partition table printed by fdisk:<br />
<code><br />
/dev/sdb: 7861 MB, 7861174272 bytes, 15353856 sectors<br />
Units = Sektoren of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
<br />
Gerät boot. Anfang Ende Blöcke Id System<br />
[...]<br />
/dev/sdb3 15288320 15353855 32768 83 Linux</code><br />
:Byte-offset of sdb3: 7827619840 = 15288320 * 512<br />
<br />
* Mount partition to /dev/loopN partition for repair, etc.<br />
:<code>losetup -o 7827619840 --find --show /dev/sdb</code><br />
:--show prints the used /dev/loopN device<br />
<br />
* Directly mount partition using loop device:<br />
:<code>mount -o loop,offset=7827619840 /dev/sdb /mnt</code><br />
* http://www.garloff.de/kurt/linux/ddrescue/<br />
* http://softwarebakery.com/shrinking-images-on-linux<br />
* http://www.tehfear.com/2007/10/08/resize-loop-disk-image/<br />
* http://wiki.ubuntuusers.de/dd (German)<br />
* http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device<br />
<br />
===Some 1-Wire Stuff===<br />
<br />
====Temperature Sensor DS1820====<br />
<br />
* How to?<br />
** http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/<br />
** https://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&start=1 (German)<br />
** http://kopfkino.irosaurus.com/tutorial-ds18s20-temperatur-sensor-an-einem-raspberry-pi/ (German)<br />
** http://raspberrywebserver.com/cgiscripting/rpi-temperature-logger/<br />
** http://elinux.org/RPi_Low-level_peripherals<br />
<br />
* I have two DS18B20 and log temperatures using rrdtool.<br />
<br />
* 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). <br />
** Q: Is this due to overclocking with using dynamic governor?<br />
** A: No - also occurs without overclocking (but less frequent?)<br />
** Q: Or is this due to voltage-problems?<br />
** A: No - also occurs without over-voltage<br />
** Q: Or something else?<br />
** 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). Using 3 sensors works almost all the time (without overclocking), but using 4 or more sensors (2 connected star topologies, very bad for 1-wire [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]), almost always fails to read values on most of the sensors.<br />
** A:'''Implement multiple 1-wire interfaces''' (see below), using 1 for each star-topology solved the problem. Reading 2x3 works perfect!<br />
<br />
====Multiple 1-wire buses====<br />
:* Inspired and guided by http://www.raspberrypi.org/forums/viewtopic.php?p=513312#p513312, I've patched my 3.12.y kernel <code>arch/arm/mach-bcm2708/bcm2708.c</code> (patch file http://holyhead.de/RaspberryPi/bcm2708-multiple_w-1.patch-3.12.21.txt).<br />
::* Note: With kernel version, device tree were introduced, see for example http://www.raspberrypi.org/documentation/configuration/device-tree.md<BR>But somehow 1-wire works for my 3.18.5+ without specifying any dtoverlays... And all tries to configure w1-gpio-overlay.dtb via config.txt resulted in my Raspberry not booting (I also tried a modified w1.dtb which should also handle my second w1-bus).<br />
:* I've cross-compiled the kernel on a linux-VM, using the instructions of http://elinux.org/RPi_Kernel_Compilation (compiling on the RaspberryPi takes 6 hours [http://wiki.gentoo.org/wiki/Raspberry_Pi_Kernel_Compilation] or much more [http://elinux.org/RPi_Kernel_Compilation]).<br />
<br />
====Some 1-wire internals====<br />
* https://www.kernel.org/doc/Documentation/w1/w1.generic<br />
* [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]<br />
* http://blog.gegg.us/2013/03/4-different-methods-of-1-wire-access-on-raspberry-pi/<br />
<br />
===Compiling own kernel===<br />
<br />
* Some hints on cross-compiling:<br />
:* http://elinux.org/RPi_Kernel_Compilation<br />
:* https://github.com/raspberrypi/linux/tree/rpi-3.12.y/arch/arm/mach-bcm2708<br />
:* https://github.com/notro/rpi-source/wiki<br />
:* https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489&start=75<br />
:* http://www.bootc.net/projects/raspberry-pi-kernel/<br />
:* http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-recompile.html<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-cross-compile.html<br />
:* http://www.gtkdb.de/index_36_2087.html<br />
<br />
* extract kernel config from image:<br />
::<code>scripts/extract-ikconfig kernel-image</code><br />
::(extract-ikconfig is part of the kernel sources)<br />
<br />
===Device Trees===<br />
<br />
:* http://www.raspberrypi.org/documentation/configuration/device-tree.md<br />
:* https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt<br />
<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=97216<br />
:* http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f<br />
:* http://www.forum-raspberrypi.de/Thread-tutorial-geraetetreiber-und-device-tree-dt (German)<br />
<br />
:* http://xillybus.com/tutorials/device-tree-zynq-1<br />
<br />
===What about updates?===<br />
<br />
As I always forget this<br />
* <code>apt-get update</code> - update package lists<br />
* <code>apt-get upgrade</code> - upgrade installed packages<br />
* <code>rpi-update</code> - update kernel and modules<br />
::use <code>SKIP_KERNEL=1 rpi-update</code> to update the RPi firmware, but keep the current kernel<br />
::set <code>SKIP_REPODELETE=1</code> to keep downloaded files (by default: <code>/root/.rpi-firmware</code>)<br />
<br />
Kernel Sources<br />
* https://github.com/notro/rpi-source gets the source data from https://github.com/Hexxeh/rpi-firmware and https://github.com/raspberrypi/linux/<br />
<br />
===Hints for reading Kernel Panics===<br />
<br />
* http://ptgmedia.pearsoncmg.com/images/013147751X/downloads/013147751X_book.pdf<br />
: p290:<br />
export CONFIG_DEBUG_INFO=1<br />
make kernel/sysctl.o<br />
objdump -d -S kernel/sysctl.o > kernel/sysctl.dump<br />
<br />
or, with my in cross-compiling setup:<br />
<br />
DOMAKE drivers/w1/slave/w1_therm.o<br />
${CCPREFIX}objdump -d -S w1_therm.o <br />
<br />
* http://www.opensourceforu.com/2011/01/understanding-a-kernel-oops/<br />
<br />
* http://www.lowlevel.eu/wiki/ARM-OS-Dev_Teil_2_%E2%80%93_Assembler_101<br />
<br />
==Attaching a LCD display (HD44780 controller)==<br />
<br />
===Wiring and Specs===<br />
<br />
* Specs<br />
** ftp://imall.iteadstudio.com/IM120424018_EONE_2004_Characters_LCD/SPE_IM120424018_EONE_2004_Characters_LCD.pdf<br />
** http://www.adafruit.com/datasheets/HD44780.pdf<br />
<br />
* http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display (German)<br />
<br />
* http://www.pro-linux.de/artikel/2/1624/5,die-anzeige-hardware-und-software.html<br />
<br />
* https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring<br />
<br />
* https://github.com/perryflynn/raspberrypi-misc/tree/master/charlcd_4x20_cmd<br />
<br />
* http://obrazki.elektroda.pl/5028699400_1384164963.jpg<br />
<br />
===Misc===<br />
<br />
* http://www.makerspaceuk.com/lcd-temp-sensor/<br />
<br />
* http://anwendungsentwickler.ws/blog/kategorien/raspberry-pi/4x20-lcd-screen-mit-dem-raspberry-pi.html (German)<br />
<br />
==Controlling the display==<br />
<br />
* Python [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO]<br />
<br />
===LCDProc hints===<br />
<br />
* Pi & GPIO powered HD44780 LCD: http://www.boeeerb.co.uk/pi-lcd/<br />
<br />
* https://metacpan.org/pod/Net::LCDproc<br />
<br />
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=63412<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-user.html<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-dev.html<br />
<br />
* http://tuxgraphics.org/electronics/200504/article375.shtml<br />
<br />
==Todo and Miscellaneous==<br />
<br />
<br />
===Collection of stuff to check - things I might) try sometime===<br />
<br />
* http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/<br />
<br />
* [http://en.wikipedia.org/wiki/F2FS f2fs]<br />
:* [http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=65330 F2fs, Ext4, FAT USB Benchmark]<br />
:* [http://forum.xda-developers.com/showthread.php?t=2697069 File System Performance: F2FS vs EXT4]<br />
<br />
* https://github.com/yuraa/Raspberry-Pi-Heartbeat<br />
<br />
* http://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html<br />
<br />
* [http://www.raspberrypi.org/archives/5282 Mathematica on Raspberry Pi, for free]<br />
:* also works in RasPi emulator, e.g. http://www.heise.de/ct/inhalt/2014/7/160/ (German, teaser to article)<br />
<br />
* NAS/Samba<br />
:* 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:<br />
:<code>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536</code><br />
<br />
* http://linuxtortures.blogspot.fr/2012/06/cross-compiling-and-cross-debugging-c.html<br />
<br />
===Things done===<br />
<br />
* Adjust swap file (size, location -> (ext4) HDD - too slow?): http://manpages.ubuntu.com/manpages/hardy/man8/dphys-swapfile.8.html<br />
<br />
* http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/<br />
<br />
==Some links (aka bookmark lists)==<br />
<br />
Project sites<br />
<br />
* [http://www.cl.cam.ac.uk/projects/raspberrypi/ University of Cambridge / Raspberry Pi Computer Laboratory]<br />
* [https://www.raspiprojekt.de/ raspiprojek] (German)<br />
* http://www.vanheusden.com/misc/rpi.php<br />
<br />
Blogs, forums, etc<br />
* http://www.raspberrypi.org/phpBB3/<br />
* [http://forum.stmlabs.com/forumdisplay.php?fid=6 Stm Labs Forum / Raspbmc]<br />
* [http://www.welzels.de/blog/projekte/raspberry-pi/ Wel!s Blog] (German)<br />
* [http://jankarres.de/category/raspberry-pi/ Raspberry Pi Blog of Jan Karres] (German)<br />
* http://www.forum-raspberrypi.de/ /(German)<br />
* http://raspberrycenter.de/ (German)<br />
* http://archlinuxarm.org/forum/viewforum.php?f=31&sid=57987232ca9177c35eb3ef7fdf6b3341<br />
<br />
* [[wikipedia:Raspberry_Pi Raspberry Pi in Wikipedia]]<br />
<br />
Miscellaneous<br />
<br />
* [http://www.raspberrypi.org/downloads New Out Of Box Software (Recommended)]<br />
* [http://elinux.org/R-Pi_Hub R-Pi_Hub]<br />
<br />
Manuals<br />
<br />
* https://github.com/raspberrypi/documentation<br />
<br />
* [http://debian-handbook.info/browse/stable/ The Debian Administrator's Handbook]</div>Holyheadhttps://holyhead.de/index.php?title=Raspberry_PiRaspberry Pi2015-02-12T17:53:45Z<p>Holyhead: /* Useful stuff and Q&A */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
===External USB drives===<br />
<br />
* Automount USB-Drives in Raspbian<br />
** One may use [http://selfprogramming.bplaced.net/index.php/2012/10/23/automount-usb-drives-in-raspbian/ USBmount and autofs]<br />
** I prefer [http://ignorantguru.github.io/udevil/ udevil], see below<br />
<br />
* Install ''ntfs-3g'' if you need write access to ntfs file systems<br />
<br />
* How to increase performance?<br />
** Mount with option ''''noatime'''' or ''''relatime''''<br />
** Mount ''without'' option sync (e.g. keep default async)<br />
** If using ntfs-3g (fuse) file system, try mounting with option 'big_writes', see for example http://obihoernchen.net/wordpress/tag/big_writes/<br />
<br />
===[http://ignorantguru.github.io/udevil/ udevil]===<br />
<br />
* example for manual mounting:<br />
<br />
udevil mount /dev/sda1<br />
<br />
* auto-mounting via udev-rule, see for example http://lsdlinux.org/wiki/doku.php?id=auto_mounting#using_udev_rule (I just copied the 95-udevil-mount.rules file from an OpenElec installation (http://www.raspberrypi.org/downloads) )<br />
<br />
* my build-steps (maybe there's a simpler way, but this worked...):<br />
** download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget<br />
** extract deb-package via <code>ar vx udevil_0.4.3-1_all.deb</code><br />
** extract data archive <code>tar xzvf data.tar.gz</code><br />
** change to tar usr/share/devil/src<br />
** untar <code>tar xvfJ udevil-current.tar.xz</code><br />
** <code>cd udevil-0.4.3</code><br />
** <code>mv distros/debian</code><br />
** execute <code>dpkg-buildpackage</code><br />
** 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<br />
** Install via <code>sudo dpkg -i udevil_0.4.3-1_armhf.deb</code><br />
<br />
===Samba server / NAS===<br />
<br />
* How to install?<br />
** [http://jankarres.de/2013/11/raspberry-pi-samba-server-installieren/ | Raspberry Pi: Samba Server installieren] (German)<br />
** [http://www.welzels.de/blog/projekte/raspberry-pi/low-budget-nas-mit-einem-raspberry-pi/ Low Budget NAS mit einem Raspberry PI] (German)<br />
<br />
* Slow disc performance?<br />
** see 'Slow USB drives' above<br />
** 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!)<br />
<br />
* Configuration and tuning<br />
** https://calomel.org/samba.html<br />
** https://calomel.org/samba_optimize.html<br />
<br />
* If your /var/log/samba/log.smbd fills up with ''printing/print_cups.c:110(cups_connect) Unable to connect to CUPS server localhost'' messages, try http://www.sotechdesign.com.au/samba-log-showing-error-failed-to-retrieve-printer-list/<br/>I also created an empty <code>/etc/printcap</code> to avoid ''Unable to open printcap file /etc/printcap for read'' messages.<br />
<br />
* I don't need sound:<br />
<br />
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf <br />
# I don't need sound<br />
blacklist snd<br />
blacklist snd_pcm<br />
blacklist snd_soc_core<br />
blacklist snd_soc_bcm2708_i2s<br />
<br />
===Trying to reduce number of disk writes (SD card)===<br />
<br />
I'm using [http://oss.oetiker.ch/rrdtool/ 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).<br />
<br />
Here's what I've done:<br />
<br />
* Edit <code>/etc/default/cron</code> and set <code>EXTRA_OPTS="-L 0"</code> to disable logging (I don't need these)<br />
* Avoid entries like <code>pam_unix(cron:session): session closed for user pi</code> in <code>/var/log/auth.log</code><br />
** Edit <code>/etc/pam.d/cron</code> and comment the line <code>@include common-session-noninteractive</code> ([http://ubuntuforums.org/showthread.php?t=1256801])<br />
:or<br />
:* Edit <code>/etc/pam.d/common-session-noninteractive</code> as shown here: http://ubuntuforums.org/showthread.php?t=1256801&p=10283830#post10283830<br />
* I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)<br />
** moved all the .rrd files as well as the created images to my persistent-ramdisk location<br />
** moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links<br />
*** <code>/var/spool</code><br />
*** <code>/var/log</code><br />
*** <code>/var/cache/samba</code><br />
** edited <code>/etc/insserv.conf</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:<br />
<br />
$local_fs_orig +mountall +mountall-bootclean +mountoverflowtmp +umountfs<br />
# we need the sym-link data in /var/log and /var/spool to be available<br />
$local_fs $local_fs_orig +persist-ramdisk<br />
<br />
:: <code>/etc/init.d/persist-ramdisk</code> 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.<br />
<br />
:* set ''RAMTMP'' to yes in <code>/etc/default/tmpfs</code> to get tempfs based <code>/tmp</code><br />
<br />
Before changing <code>/tmp</code>:<br />
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').<br />
::I need to do more digging...<br />
<br />
After changing <code>/tmp</code>:<br />
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...<br />
<br />
===Useful stuff and Q&A===<br />
<br />
* Q: Why does my Pi restart when hotplugging a USB drive?<br />
** http://thestuffsido.blogspot.de/2013/05/fixing-raspberry-pi-hotplugging.html<br />
** http://therandomlab.blogspot.de/2013/01/raspberry-pi-mod-to-avoid-shutdown-on.html<br />
<br />
* Q: Does Raspberry support WOL?<br />
: A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)<br />
<br />
* Q: The new password is to short, or too simple<br />
: A: Try adjusting the PAM settings in <code>/etc/pam.d/common-password</code>:<br />
:* remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)<br />
::<code>password [success=1 default=ignore] pam_unix.so sha512 minlen=2</code><br />
<br />
::!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!<br><br />
::But it's nice for testing (if you cannot or do not want to use auto-login.)<br />
<br />
* Q: How to configure static IP?<br />
: A: In /etc/network/interfaces:<br />
::<code>iface eth0 inet static<br>address 192.168.0.31<br>netmask 255.255.255.0<br>gateway 192.168.0.1</code><br />
<br />
* Q: How to read core temperature, etc?<br />
: A: [http://elinux.org/RPI_vcgencmd_usage vcgencmd]:<br />
::<code>vcgencmd measure_temp<br>vcgencmd measure_clock arm</code><br />
<br />
* External USB HDD spin down<br />
** hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)<br />
** hd-idle works:<br />
::<code>hd-idle -a sda -i 600</code><br />
:: for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)<br />
<br />
* Q: How to avoid update of a certain package?<br />
: A: Put package on hold ([http://debiananwenderhandbuch.de/dpkg.html] (German)):<br />
::<code>echo <packagename> "hold" | dpkg --set-selections</code><br />
<br />
* [[wikipedia:Raspcontrol]] with nginx<br />
** http://www.foxplex.com/sites/raspcontrol-webinterface-auf-dem-raspberry-pi/ (German), http://www.foxplex.com/sites/performanter-nginx-webserver-auf-dem-raspberry-pi-mit-php-und-apc/ (German)<br />
** http://menzerath.eu/artikel/raspberry-pi-raspcontrol-installation-funktionen/ (German)<br />
<br />
* Q: How many bytes are written to my (SD) disc?<br />
: A: Use <code>iostat</code> http://www.mybinarylife.net/2012/08/linux-iostat-command.html<br />
: A: Use <code>iotop</code> http://guichaz.free.fr/iotop/<br />
: A: Raw data of the kernel can be found in files <code>/proc/diskstats</code> and <code>/sys/block/DEVNAME/stat</code> https://www.kernel.org/doc/Documentation/iostats.txt<br />
:* http://unix.stackexchange.com/questions/86391/how-to-get-total-number-of-bytes-sectors-blocks-written-to-disk-since-booting<br />
:* http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux<br />
<br />
* Q: How to reduce number of ext-fs checks?<br />
: A: <code>tune2fs -c 60 /dev/sda1</code> Change maximum mount count to 60<br />
: A: <code>tune2fs -i 12m /dev/sda1</code> Change check interval to 12 months<br />
: fore more details: http://wiki.ubuntuusers.de/Dateisystemcheck (German)<br />
<br />
* Q: Fix smsc95xx 1-1.1:1.0: eth0: kevent 2 may have been dropped <br />
: A: http://wood1978.techarea.org/~wood/wordpress/2013/04/03/fix-smsc95xx-1-1-11-0-eth0-kevent-2-may-have-been-dropped-on-raspberry-pi-with-arch-linux<br />
::Modifying the sysctl.conf values reduced the kevent-2 messages; I did not yet set smsc95xx.turbo_mode=N<br />
<br />
===Overclocking===<br />
<br />
* I only set overclocking via <code>raspi-config</code><br />
<br />
* ''Turbo'': (Short) Raspberry stress test were ok. But I got an SD card error/corruption when doing a download and a dd-image of the SD card (according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907 the SD card error could be OC related.)<br />
::Luckily, I could recover all my data, see below.<br />
<br />
* '' Medium'': Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907] and its links).<br />
<br />
* Underclocking to 600 MHz<br />
:<code>echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</code><br />
: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.<br />
<br />
* Adjusting the ondemand-governor<br />
** https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt<br />
** set <code>/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor</code> to 10 [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&start=800]<br />
**: I had hoped this reduces the 1-wire CRC errors/device-disconnects problems, but with heavy (IO-) load (e.g. backup), 1wire sensors still get disconnected.<br />
<br />
* [http://moze.free.fr/blog/index.php?post/2013/02/Underclock-and-Overclock Nice power consumption analysis]<br />
<br />
====Stress test and benchmarks====<br />
<br />
* [http://www.roylongbottom.org.uk/ Roy Longbottom's PC Benchmark Collection]<br />
* [http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm Raspberry Pi Stress Tests]<br />
<br />
===SD card issues===<br />
<br />
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). I could still use this card for some time (see below), but finally I got a corrupted file system and could no longer repair it. That's when I re-installed Raspbian on a new SD card.<br />
<br />
Maybe I should try [http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ running from USB] sometime?<br />
<br />
====Recovery====<br />
* Creating a binary image of the SD card with my PC using [http://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] resulted in IO errors at about 17%.<br />
* 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 <code>dd conv=sync,noerror if=/dev/sdb2 of=rasp-image.img bs=1M</code> on my Linux machine (option <code>conv=noerror</code> ignores any errors, sync pads read-errors with zeros). The resulting image could not be mounted using a loop device. <br />
* Fortunately, <code>fsck.ext4 raspberry-image.bin</code> was able to repair the image, which I then could successfully mount on my Linux machine using <code>mount -o loop rasp-image.img /mnt</code>, and at a first glance, everything looked ok. So, I was at least able to get to my data. <br />
* On a later 'event', I dd-ed the repaired image back to the Raspberry, and could boot again.<br />
* On another a later 'event', I just fsck-ed the /dev/sdb2 using Linux, and could boot again... but I did not have luck this time - some files were gone.<br />
* 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.<br />
* My Raspberry successfully booted from this new image. I then used <code>raspi-config</code> to expand the root-fs (I've done this on my first installation as well). With Linux I was able to <code>dd</code> my repaired image to the repaired SD. The card booted as if nothing had happened...<br />
* But after some weeks, my Raspberry fried the SD card again, and some weeks later again ... And finally I could not get my pi to boot with this card. However, I can still read the data linux. Moving data to a new card... (easier said than done if the new card is slightly smaller... but, see below for resizing... and sometimes a fresh install is even less painful).<br />
<br />
===Reminders: dd, dd_rescue, losetup, mount and others===<br />
* Example partition table printed by fdisk:<br />
<code><br />
/dev/sdb: 7861 MB, 7861174272 bytes, 15353856 sectors<br />
Units = Sektoren of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
<br />
Gerät boot. Anfang Ende Blöcke Id System<br />
[...]<br />
/dev/sdb3 15288320 15353855 32768 83 Linux</code><br />
:Byte-offset of sdb3: 7827619840 = 15288320 * 512<br />
<br />
* Mount partition to /dev/loopN partition for repair, etc.<br />
:<code>losetup -o 7827619840 --find --show /dev/sdb</code><br />
:--show prints the used /dev/loopN device<br />
<br />
* Directly mount partition using loop device:<br />
:<code>mount -o loop,offset=7827619840 /dev/sdb /mnt</code><br />
* http://www.garloff.de/kurt/linux/ddrescue/<br />
* http://softwarebakery.com/shrinking-images-on-linux<br />
* http://www.tehfear.com/2007/10/08/resize-loop-disk-image/<br />
* http://wiki.ubuntuusers.de/dd (German)<br />
* http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device<br />
<br />
===Some 1-Wire Stuff===<br />
<br />
====Temperature Sensor DS1820====<br />
<br />
* How to?<br />
** http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/<br />
** https://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&start=1 (German)<br />
** http://kopfkino.irosaurus.com/tutorial-ds18s20-temperatur-sensor-an-einem-raspberry-pi/ (German)<br />
** http://raspberrywebserver.com/cgiscripting/rpi-temperature-logger/<br />
** http://elinux.org/RPi_Low-level_peripherals<br />
<br />
* I have two DS18B20 and log temperatures using rrdtool.<br />
<br />
* 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). <br />
** Q: Is this due to overclocking with using dynamic governor?<br />
** A: No - also occurs without overclocking (but less frequent?)<br />
** Q: Or is this due to voltage-problems?<br />
** A: No - also occurs without over-voltage<br />
** Q: Or something else?<br />
** 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). Using 3 sensors works almost all the time (without overclocking), but using 4 or more sensors (2 connected star topologies, very bad for 1-wire [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]), almost always fails to read values on most of the sensors.<br />
** A:'''Implement multiple 1-wire interfaces''' (see below), using 1 for each star-topology solved the problem. Reading 2x3 works perfect!<br />
<br />
====Multiple 1-wire buses====<br />
:* Inspired and guided by http://www.raspberrypi.org/forums/viewtopic.php?p=513312#p513312, I've patched my 3.12.y kernel <code>arch/arm/mach-bcm2708/bcm2708.c</code> (patch file http://holyhead.de/RaspberryPi/bcm2708-multiple_w-1.patch-3.12.21.txt).<br />
::* Note: With kernel version, device tree were introduced, see for example http://www.raspberrypi.org/documentation/configuration/device-tree.md<BR>But somehow 1-wire works for my 3.18.5+ without specifying any dtoverlays... And all tries to configure w1-gpio-overlay.dtb via config.txt resulted in my Raspberry not booting (I also tried a modified w1.dtb which should also handle my second w1-bus).<br />
:* I've cross-compiled the kernel on a linux-VM, using the instructions of http://elinux.org/RPi_Kernel_Compilation (compiling on the RaspberryPi takes 6 hours [http://wiki.gentoo.org/wiki/Raspberry_Pi_Kernel_Compilation] or much more [http://elinux.org/RPi_Kernel_Compilation]).<br />
<br />
====Some 1-wire internals====<br />
* https://www.kernel.org/doc/Documentation/w1/w1.generic<br />
* [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]<br />
* http://blog.gegg.us/2013/03/4-different-methods-of-1-wire-access-on-raspberry-pi/<br />
<br />
===Compiling own kernel===<br />
<br />
* Some hints on cross-compiling:<br />
:* http://elinux.org/RPi_Kernel_Compilation<br />
:* https://github.com/raspberrypi/linux/tree/rpi-3.12.y/arch/arm/mach-bcm2708<br />
:* https://github.com/notro/rpi-source/wiki<br />
:* https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489&start=75<br />
:* http://www.bootc.net/projects/raspberry-pi-kernel/<br />
:* http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-recompile.html<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-cross-compile.html<br />
:* http://www.gtkdb.de/index_36_2087.html<br />
<br />
* extract kernel config from image:<br />
::<code>scripts/extract-ikconfig kernel-image</code><br />
::(extract-ikconfig is part of the kernel sources)<br />
<br />
===Device Trees===<br />
<br />
:* http://www.raspberrypi.org/documentation/configuration/device-tree.md<br />
:* https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt<br />
<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=97216<br />
:* http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f<br />
:* http://www.forum-raspberrypi.de/Thread-tutorial-geraetetreiber-und-device-tree-dt (German)<br />
<br />
:* http://xillybus.com/tutorials/device-tree-zynq-1<br />
<br />
===What about updates?===<br />
<br />
As I always forget this<br />
* <code>apt-get update</code> - update package lists<br />
* <code>apt-get upgrade</code> - upgrade installed packages<br />
* <code>rpi-update</code> - update kernel and modules<br />
::use <code>SKIP_KERNEL=1 rpi-update</code> to update the RPi firmware, but keep the current kernel<br />
::set <code>SKIP_REPODELETE=1</code> to keep downloaded files (by default: <code>/root/.rpi-firmware</code>)<br />
<br />
Kernel Sources<br />
* https://github.com/notro/rpi-source gets the source data from https://github.com/Hexxeh/rpi-firmware and https://github.com/raspberrypi/linux/<br />
<br />
===Hints for reading Kernel Panics===<br />
<br />
* http://ptgmedia.pearsoncmg.com/images/013147751X/downloads/013147751X_book.pdf<br />
: p290:<br />
export CONFIG_DEBUG_INFO=1<br />
make kernel/sysctl.o<br />
objdump -d -S kernel/sysctl.o > kernel/sysctl.dump<br />
<br />
* http://www.opensourceforu.com/2011/01/understanding-a-kernel-oops/<br />
<br />
* http://www.lowlevel.eu/wiki/ARM-OS-Dev_Teil_2_%E2%80%93_Assembler_101<br />
<br />
==Attaching a LCD display (HD44780 controller)==<br />
<br />
===Wiring and Specs===<br />
<br />
* Specs<br />
** ftp://imall.iteadstudio.com/IM120424018_EONE_2004_Characters_LCD/SPE_IM120424018_EONE_2004_Characters_LCD.pdf<br />
** http://www.adafruit.com/datasheets/HD44780.pdf<br />
<br />
* http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display (German)<br />
<br />
* http://www.pro-linux.de/artikel/2/1624/5,die-anzeige-hardware-und-software.html<br />
<br />
* https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring<br />
<br />
* https://github.com/perryflynn/raspberrypi-misc/tree/master/charlcd_4x20_cmd<br />
<br />
* http://obrazki.elektroda.pl/5028699400_1384164963.jpg<br />
<br />
===Misc===<br />
<br />
* http://www.makerspaceuk.com/lcd-temp-sensor/<br />
<br />
* http://anwendungsentwickler.ws/blog/kategorien/raspberry-pi/4x20-lcd-screen-mit-dem-raspberry-pi.html (German)<br />
<br />
==Controlling the display==<br />
<br />
* Python [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO]<br />
<br />
===LCDProc hints===<br />
<br />
* Pi & GPIO powered HD44780 LCD: http://www.boeeerb.co.uk/pi-lcd/<br />
<br />
* https://metacpan.org/pod/Net::LCDproc<br />
<br />
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=63412<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-user.html<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-dev.html<br />
<br />
* http://tuxgraphics.org/electronics/200504/article375.shtml<br />
<br />
==Todo and Miscellaneous==<br />
<br />
<br />
===Collection of stuff to check - things I might) try sometime===<br />
<br />
* http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/<br />
<br />
* [http://en.wikipedia.org/wiki/F2FS f2fs]<br />
:* [http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=65330 F2fs, Ext4, FAT USB Benchmark]<br />
:* [http://forum.xda-developers.com/showthread.php?t=2697069 File System Performance: F2FS vs EXT4]<br />
<br />
* https://github.com/yuraa/Raspberry-Pi-Heartbeat<br />
<br />
* http://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html<br />
<br />
* [http://www.raspberrypi.org/archives/5282 Mathematica on Raspberry Pi, for free]<br />
:* also works in RasPi emulator, e.g. http://www.heise.de/ct/inhalt/2014/7/160/ (German, teaser to article)<br />
<br />
* NAS/Samba<br />
:* 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:<br />
:<code>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536</code><br />
<br />
* http://linuxtortures.blogspot.fr/2012/06/cross-compiling-and-cross-debugging-c.html<br />
<br />
===Things done===<br />
<br />
* Adjust swap file (size, location -> (ext4) HDD - too slow?): http://manpages.ubuntu.com/manpages/hardy/man8/dphys-swapfile.8.html<br />
<br />
* http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/<br />
<br />
==Some links (aka bookmark lists)==<br />
<br />
Project sites<br />
<br />
* [http://www.cl.cam.ac.uk/projects/raspberrypi/ University of Cambridge / Raspberry Pi Computer Laboratory]<br />
* [https://www.raspiprojekt.de/ raspiprojek] (German)<br />
* http://www.vanheusden.com/misc/rpi.php<br />
<br />
Blogs, forums, etc<br />
* http://www.raspberrypi.org/phpBB3/<br />
* [http://forum.stmlabs.com/forumdisplay.php?fid=6 Stm Labs Forum / Raspbmc]<br />
* [http://www.welzels.de/blog/projekte/raspberry-pi/ Wel!s Blog] (German)<br />
* [http://jankarres.de/category/raspberry-pi/ Raspberry Pi Blog of Jan Karres] (German)<br />
* http://www.forum-raspberrypi.de/ /(German)<br />
* http://raspberrycenter.de/ (German)<br />
* http://archlinuxarm.org/forum/viewforum.php?f=31&sid=57987232ca9177c35eb3ef7fdf6b3341<br />
<br />
* [[wikipedia:Raspberry_Pi Raspberry Pi in Wikipedia]]<br />
<br />
Miscellaneous<br />
<br />
* [http://www.raspberrypi.org/downloads New Out Of Box Software (Recommended)]<br />
* [http://elinux.org/R-Pi_Hub R-Pi_Hub]<br />
<br />
Manuals<br />
<br />
* https://github.com/raspberrypi/documentation<br />
<br />
* [http://debian-handbook.info/browse/stable/ The Debian Administrator's Handbook]</div>Holyheadhttps://holyhead.de/index.php?title=Raspberry_PiRaspberry Pi2015-02-12T16:43:39Z<p>Holyhead: /* Useful stuff and Q&A */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
===External USB drives===<br />
<br />
* Automount USB-Drives in Raspbian<br />
** One may use [http://selfprogramming.bplaced.net/index.php/2012/10/23/automount-usb-drives-in-raspbian/ USBmount and autofs]<br />
** I prefer [http://ignorantguru.github.io/udevil/ udevil], see below<br />
<br />
* Install ''ntfs-3g'' if you need write access to ntfs file systems<br />
<br />
* How to increase performance?<br />
** Mount with option ''''noatime'''' or ''''relatime''''<br />
** Mount ''without'' option sync (e.g. keep default async)<br />
** If using ntfs-3g (fuse) file system, try mounting with option 'big_writes', see for example http://obihoernchen.net/wordpress/tag/big_writes/<br />
<br />
===[http://ignorantguru.github.io/udevil/ udevil]===<br />
<br />
* example for manual mounting:<br />
<br />
udevil mount /dev/sda1<br />
<br />
* auto-mounting via udev-rule, see for example http://lsdlinux.org/wiki/doku.php?id=auto_mounting#using_udev_rule (I just copied the 95-udevil-mount.rules file from an OpenElec installation (http://www.raspberrypi.org/downloads) )<br />
<br />
* my build-steps (maybe there's a simpler way, but this worked...):<br />
** download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget<br />
** extract deb-package via <code>ar vx udevil_0.4.3-1_all.deb</code><br />
** extract data archive <code>tar xzvf data.tar.gz</code><br />
** change to tar usr/share/devil/src<br />
** untar <code>tar xvfJ udevil-current.tar.xz</code><br />
** <code>cd udevil-0.4.3</code><br />
** <code>mv distros/debian</code><br />
** execute <code>dpkg-buildpackage</code><br />
** 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<br />
** Install via <code>sudo dpkg -i udevil_0.4.3-1_armhf.deb</code><br />
<br />
===Samba server / NAS===<br />
<br />
* How to install?<br />
** [http://jankarres.de/2013/11/raspberry-pi-samba-server-installieren/ | Raspberry Pi: Samba Server installieren] (German)<br />
** [http://www.welzels.de/blog/projekte/raspberry-pi/low-budget-nas-mit-einem-raspberry-pi/ Low Budget NAS mit einem Raspberry PI] (German)<br />
<br />
* Slow disc performance?<br />
** see 'Slow USB drives' above<br />
** 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!)<br />
<br />
* Configuration and tuning<br />
** https://calomel.org/samba.html<br />
** https://calomel.org/samba_optimize.html<br />
<br />
* If your /var/log/samba/log.smbd fills up with ''printing/print_cups.c:110(cups_connect) Unable to connect to CUPS server localhost'' messages, try http://www.sotechdesign.com.au/samba-log-showing-error-failed-to-retrieve-printer-list/<br/>I also created an empty <code>/etc/printcap</code> to avoid ''Unable to open printcap file /etc/printcap for read'' messages.<br />
<br />
* I don't need sound:<br />
<br />
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf <br />
# I don't need sound<br />
blacklist snd<br />
blacklist snd_pcm<br />
blacklist snd_soc_core<br />
blacklist snd_soc_bcm2708_i2s<br />
<br />
===Trying to reduce number of disk writes (SD card)===<br />
<br />
I'm using [http://oss.oetiker.ch/rrdtool/ 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).<br />
<br />
Here's what I've done:<br />
<br />
* Edit <code>/etc/default/cron</code> and set <code>EXTRA_OPTS="-L 0"</code> to disable logging (I don't need these)<br />
* Avoid entries like <code>pam_unix(cron:session): session closed for user pi</code> in <code>/var/log/auth.log</code><br />
** Edit <code>/etc/pam.d/cron</code> and comment the line <code>@include common-session-noninteractive</code> ([http://ubuntuforums.org/showthread.php?t=1256801])<br />
:or<br />
:* Edit <code>/etc/pam.d/common-session-noninteractive</code> as shown here: http://ubuntuforums.org/showthread.php?t=1256801&p=10283830#post10283830<br />
* I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)<br />
** moved all the .rrd files as well as the created images to my persistent-ramdisk location<br />
** moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links<br />
*** <code>/var/spool</code><br />
*** <code>/var/log</code><br />
*** <code>/var/cache/samba</code><br />
** edited <code>/etc/insserv.conf</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:<br />
<br />
$local_fs_orig +mountall +mountall-bootclean +mountoverflowtmp +umountfs<br />
# we need the sym-link data in /var/log and /var/spool to be available<br />
$local_fs $local_fs_orig +persist-ramdisk<br />
<br />
:: <code>/etc/init.d/persist-ramdisk</code> 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.<br />
<br />
:* set ''RAMTMP'' to yes in <code>/etc/default/tmpfs</code> to get tempfs based <code>/tmp</code><br />
<br />
Before changing <code>/tmp</code>:<br />
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').<br />
::I need to do more digging...<br />
<br />
After changing <code>/tmp</code>:<br />
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...<br />
<br />
===Useful stuff and Q&A===<br />
<br />
* Q: Why does my Pi restart when hotplugging a USB drive?<br />
** http://thestuffsido.blogspot.de/2013/05/fixing-raspberry-pi-hotplugging.html<br />
** http://therandomlab.blogspot.de/2013/01/raspberry-pi-mod-to-avoid-shutdown-on.html<br />
<br />
* Q: Does Raspberry support WOL?<br />
: A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)<br />
<br />
* Q: The new password is to short, or too simple<br />
: A: Try adjusting the PAM settings in <code>/etc/pam.d/common-password</code>:<br />
:* remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)<br />
::<code>password [success=1 default=ignore] pam_unix.so sha512 minlen=2</code><br />
<br />
::!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!<br><br />
::But it's nice for testing (if you cannot or do not want to use auto-login.)<br />
<br />
* Q: How to configure static IP?<br />
: A: In /etc/network/interfaces:<br />
::<code>iface eth0 inet static<br>address 192.168.0.31<br>netmask 255.255.255.0<br>gateway 192.168.0.1</code><br />
<br />
* Q: How to read core temperature, etc?<br />
: A: [http://elinux.org/RPI_vcgencmd_usage vcgencmd]:<br />
::<code>vcgencmd measure_temp<br>vcgencmd measure_clock arm</code><br />
<br />
* External USB HDD spin down<br />
** hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)<br />
** hd-idle works:<br />
::<code>hd-idle -a sda -i 600</code><br />
:: for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)<br />
<br />
* Q: How to avoid update of a certain package?<br />
: A: Put package on hold ([http://debiananwenderhandbuch.de/dpkg.html] (German)):<br />
::<code>echo <packagename> "hold" | dpkg --set-selections</code><br />
<br />
* [[wikipedia:Raspcontrol]] with nginx<br />
** http://www.foxplex.com/sites/raspcontrol-webinterface-auf-dem-raspberry-pi/ (German), http://www.foxplex.com/sites/performanter-nginx-webserver-auf-dem-raspberry-pi-mit-php-und-apc/ (German)<br />
** http://menzerath.eu/artikel/raspberry-pi-raspcontrol-installation-funktionen/ (German)<br />
<br />
* Q: How many bytes are written to my (SD) disc?<br />
: A: Use <code>iostat</code> http://www.mybinarylife.net/2012/08/linux-iostat-command.html<br />
: A: Use <code>iotop</code> http://guichaz.free.fr/iotop/<br />
: A: Raw data of the kernel can be found in files <code>/proc/diskstats</code> and <code>/sys/block/DEVNAME/stat</code> https://www.kernel.org/doc/Documentation/iostats.txt<br />
:* http://unix.stackexchange.com/questions/86391/how-to-get-total-number-of-bytes-sectors-blocks-written-to-disk-since-booting<br />
:* http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux<br />
<br />
* Q: How to reduce number of ext-fs checks?<br />
: A: <code>tune2fs -c 60 /dev/sda1</code> Change maximum mount count to 60<br />
: A: <code>tune2fs -i 12m /dev/sda1</code> Change check interval to 12 months<br />
: fore more details: http://wiki.ubuntuusers.de/Dateisystemcheck (German)<br />
<br />
* Q: Fix smsc95xx 1-1.1:1.0: eth0: kevent 2 may have been dropped <br />
: A: http://wood1978.techarea.org/~wood/wordpress/2013/04/03/fix-smsc95xx-1-1-11-0-eth0-kevent-2-may-have-been-dropped-on-raspberry-pi-with-arch-linux<br />
<br />
===Overclocking===<br />
<br />
* I only set overclocking via <code>raspi-config</code><br />
<br />
* ''Turbo'': (Short) Raspberry stress test were ok. But I got an SD card error/corruption when doing a download and a dd-image of the SD card (according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907 the SD card error could be OC related.)<br />
::Luckily, I could recover all my data, see below.<br />
<br />
* '' Medium'': Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907] and its links).<br />
<br />
* Underclocking to 600 MHz<br />
:<code>echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</code><br />
: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.<br />
<br />
* Adjusting the ondemand-governor<br />
** https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt<br />
** set <code>/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor</code> to 10 [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&start=800]<br />
**: I had hoped this reduces the 1-wire CRC errors/device-disconnects problems, but with heavy (IO-) load (e.g. backup), 1wire sensors still get disconnected.<br />
<br />
* [http://moze.free.fr/blog/index.php?post/2013/02/Underclock-and-Overclock Nice power consumption analysis]<br />
<br />
====Stress test and benchmarks====<br />
<br />
* [http://www.roylongbottom.org.uk/ Roy Longbottom's PC Benchmark Collection]<br />
* [http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm Raspberry Pi Stress Tests]<br />
<br />
===SD card issues===<br />
<br />
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). I could still use this card for some time (see below), but finally I got a corrupted file system and could no longer repair it. That's when I re-installed Raspbian on a new SD card.<br />
<br />
Maybe I should try [http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ running from USB] sometime?<br />
<br />
====Recovery====<br />
* Creating a binary image of the SD card with my PC using [http://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] resulted in IO errors at about 17%.<br />
* 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 <code>dd conv=sync,noerror if=/dev/sdb2 of=rasp-image.img bs=1M</code> on my Linux machine (option <code>conv=noerror</code> ignores any errors, sync pads read-errors with zeros). The resulting image could not be mounted using a loop device. <br />
* Fortunately, <code>fsck.ext4 raspberry-image.bin</code> was able to repair the image, which I then could successfully mount on my Linux machine using <code>mount -o loop rasp-image.img /mnt</code>, and at a first glance, everything looked ok. So, I was at least able to get to my data. <br />
* On a later 'event', I dd-ed the repaired image back to the Raspberry, and could boot again.<br />
* On another a later 'event', I just fsck-ed the /dev/sdb2 using Linux, and could boot again... but I did not have luck this time - some files were gone.<br />
* 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.<br />
* My Raspberry successfully booted from this new image. I then used <code>raspi-config</code> to expand the root-fs (I've done this on my first installation as well). With Linux I was able to <code>dd</code> my repaired image to the repaired SD. The card booted as if nothing had happened...<br />
* But after some weeks, my Raspberry fried the SD card again, and some weeks later again ... And finally I could not get my pi to boot with this card. However, I can still read the data linux. Moving data to a new card... (easier said than done if the new card is slightly smaller... but, see below for resizing... and sometimes a fresh install is even less painful).<br />
<br />
===Reminders: dd, dd_rescue, losetup, mount and others===<br />
* Example partition table printed by fdisk:<br />
<code><br />
/dev/sdb: 7861 MB, 7861174272 bytes, 15353856 sectors<br />
Units = Sektoren of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
<br />
Gerät boot. Anfang Ende Blöcke Id System<br />
[...]<br />
/dev/sdb3 15288320 15353855 32768 83 Linux</code><br />
:Byte-offset of sdb3: 7827619840 = 15288320 * 512<br />
<br />
* Mount partition to /dev/loopN partition for repair, etc.<br />
:<code>losetup -o 7827619840 --find --show /dev/sdb</code><br />
:--show prints the used /dev/loopN device<br />
<br />
* Directly mount partition using loop device:<br />
:<code>mount -o loop,offset=7827619840 /dev/sdb /mnt</code><br />
* http://www.garloff.de/kurt/linux/ddrescue/<br />
* http://softwarebakery.com/shrinking-images-on-linux<br />
* http://www.tehfear.com/2007/10/08/resize-loop-disk-image/<br />
* http://wiki.ubuntuusers.de/dd (German)<br />
* http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device<br />
<br />
===Some 1-Wire Stuff===<br />
<br />
====Temperature Sensor DS1820====<br />
<br />
* How to?<br />
** http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/<br />
** https://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&start=1 (German)<br />
** http://kopfkino.irosaurus.com/tutorial-ds18s20-temperatur-sensor-an-einem-raspberry-pi/ (German)<br />
** http://raspberrywebserver.com/cgiscripting/rpi-temperature-logger/<br />
** http://elinux.org/RPi_Low-level_peripherals<br />
<br />
* I have two DS18B20 and log temperatures using rrdtool.<br />
<br />
* 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). <br />
** Q: Is this due to overclocking with using dynamic governor?<br />
** A: No - also occurs without overclocking (but less frequent?)<br />
** Q: Or is this due to voltage-problems?<br />
** A: No - also occurs without over-voltage<br />
** Q: Or something else?<br />
** 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). Using 3 sensors works almost all the time (without overclocking), but using 4 or more sensors (2 connected star topologies, very bad for 1-wire [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]), almost always fails to read values on most of the sensors.<br />
** A:'''Implement multiple 1-wire interfaces''' (see below), using 1 for each star-topology solved the problem. Reading 2x3 works perfect!<br />
<br />
====Multiple 1-wire buses====<br />
:* Inspired and guided by http://www.raspberrypi.org/forums/viewtopic.php?p=513312#p513312, I've patched my 3.12.y kernel <code>arch/arm/mach-bcm2708/bcm2708.c</code> (patch file http://holyhead.de/RaspberryPi/bcm2708-multiple_w-1.patch-3.12.21.txt).<br />
::* Note: With kernel version, device tree were introduced, see for example http://www.raspberrypi.org/documentation/configuration/device-tree.md<BR>But somehow 1-wire works for my 3.18.5+ without specifying any dtoverlays... And all tries to configure w1-gpio-overlay.dtb via config.txt resulted in my Raspberry not booting (I also tried a modified w1.dtb which should also handle my second w1-bus).<br />
:* I've cross-compiled the kernel on a linux-VM, using the instructions of http://elinux.org/RPi_Kernel_Compilation (compiling on the RaspberryPi takes 6 hours [http://wiki.gentoo.org/wiki/Raspberry_Pi_Kernel_Compilation] or much more [http://elinux.org/RPi_Kernel_Compilation]).<br />
<br />
====Some 1-wire internals====<br />
* https://www.kernel.org/doc/Documentation/w1/w1.generic<br />
* [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]<br />
* http://blog.gegg.us/2013/03/4-different-methods-of-1-wire-access-on-raspberry-pi/<br />
<br />
===Compiling own kernel===<br />
<br />
* Some hints on cross-compiling:<br />
:* http://elinux.org/RPi_Kernel_Compilation<br />
:* https://github.com/raspberrypi/linux/tree/rpi-3.12.y/arch/arm/mach-bcm2708<br />
:* https://github.com/notro/rpi-source/wiki<br />
:* https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489&start=75<br />
:* http://www.bootc.net/projects/raspberry-pi-kernel/<br />
:* http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-recompile.html<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-cross-compile.html<br />
:* http://www.gtkdb.de/index_36_2087.html<br />
<br />
* extract kernel config from image:<br />
::<code>scripts/extract-ikconfig kernel-image</code><br />
::(extract-ikconfig is part of the kernel sources)<br />
<br />
===Device Trees===<br />
<br />
:* http://www.raspberrypi.org/documentation/configuration/device-tree.md<br />
:* https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt<br />
<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=97216<br />
:* http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f<br />
:* http://www.forum-raspberrypi.de/Thread-tutorial-geraetetreiber-und-device-tree-dt (German)<br />
<br />
:* http://xillybus.com/tutorials/device-tree-zynq-1<br />
<br />
===What about updates?===<br />
<br />
As I always forget this<br />
* <code>apt-get update</code> - update package lists<br />
* <code>apt-get upgrade</code> - upgrade installed packages<br />
* <code>rpi-update</code> - update kernel and modules<br />
::use <code>SKIP_KERNEL=1 rpi-update</code> to update the RPi firmware, but keep the current kernel<br />
::set <code>SKIP_REPODELETE=1</code> to keep downloaded files (by default: <code>/root/.rpi-firmware</code>)<br />
<br />
Kernel Sources<br />
* https://github.com/notro/rpi-source gets the source data from https://github.com/Hexxeh/rpi-firmware and https://github.com/raspberrypi/linux/<br />
<br />
===Hints for reading Kernel Panics===<br />
<br />
* http://ptgmedia.pearsoncmg.com/images/013147751X/downloads/013147751X_book.pdf<br />
: p290:<br />
export CONFIG_DEBUG_INFO=1<br />
make kernel/sysctl.o<br />
objdump -d -S kernel/sysctl.o > kernel/sysctl.dump<br />
<br />
* http://www.opensourceforu.com/2011/01/understanding-a-kernel-oops/<br />
<br />
* http://www.lowlevel.eu/wiki/ARM-OS-Dev_Teil_2_%E2%80%93_Assembler_101<br />
<br />
==Attaching a LCD display (HD44780 controller)==<br />
<br />
===Wiring and Specs===<br />
<br />
* Specs<br />
** ftp://imall.iteadstudio.com/IM120424018_EONE_2004_Characters_LCD/SPE_IM120424018_EONE_2004_Characters_LCD.pdf<br />
** http://www.adafruit.com/datasheets/HD44780.pdf<br />
<br />
* http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display (German)<br />
<br />
* http://www.pro-linux.de/artikel/2/1624/5,die-anzeige-hardware-und-software.html<br />
<br />
* https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring<br />
<br />
* https://github.com/perryflynn/raspberrypi-misc/tree/master/charlcd_4x20_cmd<br />
<br />
* http://obrazki.elektroda.pl/5028699400_1384164963.jpg<br />
<br />
===Misc===<br />
<br />
* http://www.makerspaceuk.com/lcd-temp-sensor/<br />
<br />
* http://anwendungsentwickler.ws/blog/kategorien/raspberry-pi/4x20-lcd-screen-mit-dem-raspberry-pi.html (German)<br />
<br />
==Controlling the display==<br />
<br />
* Python [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO]<br />
<br />
===LCDProc hints===<br />
<br />
* Pi & GPIO powered HD44780 LCD: http://www.boeeerb.co.uk/pi-lcd/<br />
<br />
* https://metacpan.org/pod/Net::LCDproc<br />
<br />
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=63412<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-user.html<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-dev.html<br />
<br />
* http://tuxgraphics.org/electronics/200504/article375.shtml<br />
<br />
==Todo and Miscellaneous==<br />
<br />
<br />
===Collection of stuff to check - things I might) try sometime===<br />
<br />
* http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/<br />
<br />
* [http://en.wikipedia.org/wiki/F2FS f2fs]<br />
:* [http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=65330 F2fs, Ext4, FAT USB Benchmark]<br />
:* [http://forum.xda-developers.com/showthread.php?t=2697069 File System Performance: F2FS vs EXT4]<br />
<br />
* https://github.com/yuraa/Raspberry-Pi-Heartbeat<br />
<br />
* http://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html<br />
<br />
* [http://www.raspberrypi.org/archives/5282 Mathematica on Raspberry Pi, for free]<br />
:* also works in RasPi emulator, e.g. http://www.heise.de/ct/inhalt/2014/7/160/ (German, teaser to article)<br />
<br />
* NAS/Samba<br />
:* 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:<br />
:<code>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536</code><br />
<br />
* http://linuxtortures.blogspot.fr/2012/06/cross-compiling-and-cross-debugging-c.html<br />
<br />
===Things done===<br />
<br />
* Adjust swap file (size, location -> (ext4) HDD - too slow?): http://manpages.ubuntu.com/manpages/hardy/man8/dphys-swapfile.8.html<br />
<br />
* http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/<br />
<br />
==Some links (aka bookmark lists)==<br />
<br />
Project sites<br />
<br />
* [http://www.cl.cam.ac.uk/projects/raspberrypi/ University of Cambridge / Raspberry Pi Computer Laboratory]<br />
* [https://www.raspiprojekt.de/ raspiprojek] (German)<br />
* http://www.vanheusden.com/misc/rpi.php<br />
<br />
Blogs, forums, etc<br />
* http://www.raspberrypi.org/phpBB3/<br />
* [http://forum.stmlabs.com/forumdisplay.php?fid=6 Stm Labs Forum / Raspbmc]<br />
* [http://www.welzels.de/blog/projekte/raspberry-pi/ Wel!s Blog] (German)<br />
* [http://jankarres.de/category/raspberry-pi/ Raspberry Pi Blog of Jan Karres] (German)<br />
* http://www.forum-raspberrypi.de/ /(German)<br />
* http://raspberrycenter.de/ (German)<br />
* http://archlinuxarm.org/forum/viewforum.php?f=31&sid=57987232ca9177c35eb3ef7fdf6b3341<br />
<br />
* [[wikipedia:Raspberry_Pi Raspberry Pi in Wikipedia]]<br />
<br />
Miscellaneous<br />
<br />
* [http://www.raspberrypi.org/downloads New Out Of Box Software (Recommended)]<br />
* [http://elinux.org/R-Pi_Hub R-Pi_Hub]<br />
<br />
Manuals<br />
<br />
* https://github.com/raspberrypi/documentation<br />
<br />
* [http://debian-handbook.info/browse/stable/ The Debian Administrator's Handbook]</div>Holyheadhttps://holyhead.de/index.php?title=Raspberry_PiRaspberry Pi2015-02-12T16:43:21Z<p>Holyhead: /* Useful stuff and Q&A */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
===External USB drives===<br />
<br />
* Automount USB-Drives in Raspbian<br />
** One may use [http://selfprogramming.bplaced.net/index.php/2012/10/23/automount-usb-drives-in-raspbian/ USBmount and autofs]<br />
** I prefer [http://ignorantguru.github.io/udevil/ udevil], see below<br />
<br />
* Install ''ntfs-3g'' if you need write access to ntfs file systems<br />
<br />
* How to increase performance?<br />
** Mount with option ''''noatime'''' or ''''relatime''''<br />
** Mount ''without'' option sync (e.g. keep default async)<br />
** If using ntfs-3g (fuse) file system, try mounting with option 'big_writes', see for example http://obihoernchen.net/wordpress/tag/big_writes/<br />
<br />
===[http://ignorantguru.github.io/udevil/ udevil]===<br />
<br />
* example for manual mounting:<br />
<br />
udevil mount /dev/sda1<br />
<br />
* auto-mounting via udev-rule, see for example http://lsdlinux.org/wiki/doku.php?id=auto_mounting#using_udev_rule (I just copied the 95-udevil-mount.rules file from an OpenElec installation (http://www.raspberrypi.org/downloads) )<br />
<br />
* my build-steps (maybe there's a simpler way, but this worked...):<br />
** download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget<br />
** extract deb-package via <code>ar vx udevil_0.4.3-1_all.deb</code><br />
** extract data archive <code>tar xzvf data.tar.gz</code><br />
** change to tar usr/share/devil/src<br />
** untar <code>tar xvfJ udevil-current.tar.xz</code><br />
** <code>cd udevil-0.4.3</code><br />
** <code>mv distros/debian</code><br />
** execute <code>dpkg-buildpackage</code><br />
** 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<br />
** Install via <code>sudo dpkg -i udevil_0.4.3-1_armhf.deb</code><br />
<br />
===Samba server / NAS===<br />
<br />
* How to install?<br />
** [http://jankarres.de/2013/11/raspberry-pi-samba-server-installieren/ | Raspberry Pi: Samba Server installieren] (German)<br />
** [http://www.welzels.de/blog/projekte/raspberry-pi/low-budget-nas-mit-einem-raspberry-pi/ Low Budget NAS mit einem Raspberry PI] (German)<br />
<br />
* Slow disc performance?<br />
** see 'Slow USB drives' above<br />
** 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!)<br />
<br />
* Configuration and tuning<br />
** https://calomel.org/samba.html<br />
** https://calomel.org/samba_optimize.html<br />
<br />
* If your /var/log/samba/log.smbd fills up with ''printing/print_cups.c:110(cups_connect) Unable to connect to CUPS server localhost'' messages, try http://www.sotechdesign.com.au/samba-log-showing-error-failed-to-retrieve-printer-list/<br/>I also created an empty <code>/etc/printcap</code> to avoid ''Unable to open printcap file /etc/printcap for read'' messages.<br />
<br />
* I don't need sound:<br />
<br />
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf <br />
# I don't need sound<br />
blacklist snd<br />
blacklist snd_pcm<br />
blacklist snd_soc_core<br />
blacklist snd_soc_bcm2708_i2s<br />
<br />
===Trying to reduce number of disk writes (SD card)===<br />
<br />
I'm using [http://oss.oetiker.ch/rrdtool/ 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).<br />
<br />
Here's what I've done:<br />
<br />
* Edit <code>/etc/default/cron</code> and set <code>EXTRA_OPTS="-L 0"</code> to disable logging (I don't need these)<br />
* Avoid entries like <code>pam_unix(cron:session): session closed for user pi</code> in <code>/var/log/auth.log</code><br />
** Edit <code>/etc/pam.d/cron</code> and comment the line <code>@include common-session-noninteractive</code> ([http://ubuntuforums.org/showthread.php?t=1256801])<br />
:or<br />
:* Edit <code>/etc/pam.d/common-session-noninteractive</code> as shown here: http://ubuntuforums.org/showthread.php?t=1256801&p=10283830#post10283830<br />
* I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)<br />
** moved all the .rrd files as well as the created images to my persistent-ramdisk location<br />
** moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links<br />
*** <code>/var/spool</code><br />
*** <code>/var/log</code><br />
*** <code>/var/cache/samba</code><br />
** edited <code>/etc/insserv.conf</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:<br />
<br />
$local_fs_orig +mountall +mountall-bootclean +mountoverflowtmp +umountfs<br />
# we need the sym-link data in /var/log and /var/spool to be available<br />
$local_fs $local_fs_orig +persist-ramdisk<br />
<br />
:: <code>/etc/init.d/persist-ramdisk</code> 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.<br />
<br />
:* set ''RAMTMP'' to yes in <code>/etc/default/tmpfs</code> to get tempfs based <code>/tmp</code><br />
<br />
Before changing <code>/tmp</code>:<br />
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').<br />
::I need to do more digging...<br />
<br />
After changing <code>/tmp</code>:<br />
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...<br />
<br />
===Useful stuff and Q&A===<br />
<br />
* Q: Why does my Pi restart when hotplugging a USB drive?<br />
** http://thestuffsido.blogspot.de/2013/05/fixing-raspberry-pi-hotplugging.html<br />
** http://therandomlab.blogspot.de/2013/01/raspberry-pi-mod-to-avoid-shutdown-on.html<br />
<br />
* Q: Does Raspberry support WOL?<br />
: A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)<br />
<br />
* Q: The new password is to short, or too simple<br />
: A: Try adjusting the PAM settings in <code>/etc/pam.d/common-password</code>:<br />
:* remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)<br />
::<code>password [success=1 default=ignore] pam_unix.so sha512 minlen=2</code><br />
<br />
::!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!<br><br />
::But it's nice for testing (if you cannot or do not want to use auto-login.)<br />
<br />
* Q: How to configure static IP?<br />
: A: In /etc/network/interfaces:<br />
::<code>iface eth0 inet static<br>address 192.168.0.31<br>netmask 255.255.255.0<br>gateway 192.168.0.1</code><br />
<br />
* Q: How to read core temperature, etc?<br />
: A: [http://elinux.org/RPI_vcgencmd_usage vcgencmd]:<br />
::<code>vcgencmd measure_temp<br>vcgencmd measure_clock arm</code><br />
<br />
* External USB HDD spin down<br />
** hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)<br />
** hd-idle works:<br />
::<code>hd-idle -a sda -i 600</code><br />
:: for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)<br />
<br />
* Q: How to avoid update of a certain package?<br />
: A: Put package on hold ([http://debiananwenderhandbuch.de/dpkg.html] (German)):<br />
::<code>echo <packagename> "hold" | dpkg --set-selections</code><br />
<br />
* [[wikipedia:Raspcontrol]] with nginx<br />
** http://www.foxplex.com/sites/raspcontrol-webinterface-auf-dem-raspberry-pi/ (German), http://www.foxplex.com/sites/performanter-nginx-webserver-auf-dem-raspberry-pi-mit-php-und-apc/ (German)<br />
** http://menzerath.eu/artikel/raspberry-pi-raspcontrol-installation-funktionen/ (German)<br />
<br />
* Q: How many bytes are written to my (SD) disc?<br />
: A: Use <code>iostat</code> http://www.mybinarylife.net/2012/08/linux-iostat-command.html<br />
: A: Use <code>iotop</code> http://guichaz.free.fr/iotop/<br />
: A: Raw data of the kernel can be found in files <code>/proc/diskstats</code> and <code>/sys/block/DEVNAME/stat</code> https://www.kernel.org/doc/Documentation/iostats.txt<br />
:* http://unix.stackexchange.com/questions/86391/how-to-get-total-number-of-bytes-sectors-blocks-written-to-disk-since-booting<br />
:* http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux<br />
<br />
* Q: How to reduce number of ext-fs checks?<br />
: A: <code>tune2fs -c 60 /dev/sda1</code> Change maximum mount count to 60<br />
: A: <code>tune2fs -i 12m /dev/sda1</code> Change check interval to 12 months<br />
: fore more details: http://wiki.ubuntuusers.de/Dateisystemcheck (German)<br />
<br />
: Q: Fix smsc95xx 1-1.1:1.0: eth0: kevent 2 may have been dropped <br />
: A: http://wood1978.techarea.org/~wood/wordpress/2013/04/03/fix-smsc95xx-1-1-11-0-eth0-kevent-2-may-have-been-dropped-on-raspberry-pi-with-arch-linux<br />
<br />
===Overclocking===<br />
<br />
* I only set overclocking via <code>raspi-config</code><br />
<br />
* ''Turbo'': (Short) Raspberry stress test were ok. But I got an SD card error/corruption when doing a download and a dd-image of the SD card (according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907 the SD card error could be OC related.)<br />
::Luckily, I could recover all my data, see below.<br />
<br />
* '' Medium'': Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907] and its links).<br />
<br />
* Underclocking to 600 MHz<br />
:<code>echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</code><br />
: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.<br />
<br />
* Adjusting the ondemand-governor<br />
** https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt<br />
** set <code>/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor</code> to 10 [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&start=800]<br />
**: I had hoped this reduces the 1-wire CRC errors/device-disconnects problems, but with heavy (IO-) load (e.g. backup), 1wire sensors still get disconnected.<br />
<br />
* [http://moze.free.fr/blog/index.php?post/2013/02/Underclock-and-Overclock Nice power consumption analysis]<br />
<br />
====Stress test and benchmarks====<br />
<br />
* [http://www.roylongbottom.org.uk/ Roy Longbottom's PC Benchmark Collection]<br />
* [http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm Raspberry Pi Stress Tests]<br />
<br />
===SD card issues===<br />
<br />
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). I could still use this card for some time (see below), but finally I got a corrupted file system and could no longer repair it. That's when I re-installed Raspbian on a new SD card.<br />
<br />
Maybe I should try [http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ running from USB] sometime?<br />
<br />
====Recovery====<br />
* Creating a binary image of the SD card with my PC using [http://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] resulted in IO errors at about 17%.<br />
* 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 <code>dd conv=sync,noerror if=/dev/sdb2 of=rasp-image.img bs=1M</code> on my Linux machine (option <code>conv=noerror</code> ignores any errors, sync pads read-errors with zeros). The resulting image could not be mounted using a loop device. <br />
* Fortunately, <code>fsck.ext4 raspberry-image.bin</code> was able to repair the image, which I then could successfully mount on my Linux machine using <code>mount -o loop rasp-image.img /mnt</code>, and at a first glance, everything looked ok. So, I was at least able to get to my data. <br />
* On a later 'event', I dd-ed the repaired image back to the Raspberry, and could boot again.<br />
* On another a later 'event', I just fsck-ed the /dev/sdb2 using Linux, and could boot again... but I did not have luck this time - some files were gone.<br />
* 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.<br />
* My Raspberry successfully booted from this new image. I then used <code>raspi-config</code> to expand the root-fs (I've done this on my first installation as well). With Linux I was able to <code>dd</code> my repaired image to the repaired SD. The card booted as if nothing had happened...<br />
* But after some weeks, my Raspberry fried the SD card again, and some weeks later again ... And finally I could not get my pi to boot with this card. However, I can still read the data linux. Moving data to a new card... (easier said than done if the new card is slightly smaller... but, see below for resizing... and sometimes a fresh install is even less painful).<br />
<br />
===Reminders: dd, dd_rescue, losetup, mount and others===<br />
* Example partition table printed by fdisk:<br />
<code><br />
/dev/sdb: 7861 MB, 7861174272 bytes, 15353856 sectors<br />
Units = Sektoren of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
<br />
Gerät boot. Anfang Ende Blöcke Id System<br />
[...]<br />
/dev/sdb3 15288320 15353855 32768 83 Linux</code><br />
:Byte-offset of sdb3: 7827619840 = 15288320 * 512<br />
<br />
* Mount partition to /dev/loopN partition for repair, etc.<br />
:<code>losetup -o 7827619840 --find --show /dev/sdb</code><br />
:--show prints the used /dev/loopN device<br />
<br />
* Directly mount partition using loop device:<br />
:<code>mount -o loop,offset=7827619840 /dev/sdb /mnt</code><br />
* http://www.garloff.de/kurt/linux/ddrescue/<br />
* http://softwarebakery.com/shrinking-images-on-linux<br />
* http://www.tehfear.com/2007/10/08/resize-loop-disk-image/<br />
* http://wiki.ubuntuusers.de/dd (German)<br />
* http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device<br />
<br />
===Some 1-Wire Stuff===<br />
<br />
====Temperature Sensor DS1820====<br />
<br />
* How to?<br />
** http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/<br />
** https://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&start=1 (German)<br />
** http://kopfkino.irosaurus.com/tutorial-ds18s20-temperatur-sensor-an-einem-raspberry-pi/ (German)<br />
** http://raspberrywebserver.com/cgiscripting/rpi-temperature-logger/<br />
** http://elinux.org/RPi_Low-level_peripherals<br />
<br />
* I have two DS18B20 and log temperatures using rrdtool.<br />
<br />
* 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). <br />
** Q: Is this due to overclocking with using dynamic governor?<br />
** A: No - also occurs without overclocking (but less frequent?)<br />
** Q: Or is this due to voltage-problems?<br />
** A: No - also occurs without over-voltage<br />
** Q: Or something else?<br />
** 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). Using 3 sensors works almost all the time (without overclocking), but using 4 or more sensors (2 connected star topologies, very bad for 1-wire [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]), almost always fails to read values on most of the sensors.<br />
** A:'''Implement multiple 1-wire interfaces''' (see below), using 1 for each star-topology solved the problem. Reading 2x3 works perfect!<br />
<br />
====Multiple 1-wire buses====<br />
:* Inspired and guided by http://www.raspberrypi.org/forums/viewtopic.php?p=513312#p513312, I've patched my 3.12.y kernel <code>arch/arm/mach-bcm2708/bcm2708.c</code> (patch file http://holyhead.de/RaspberryPi/bcm2708-multiple_w-1.patch-3.12.21.txt).<br />
::* Note: With kernel version, device tree were introduced, see for example http://www.raspberrypi.org/documentation/configuration/device-tree.md<BR>But somehow 1-wire works for my 3.18.5+ without specifying any dtoverlays... And all tries to configure w1-gpio-overlay.dtb via config.txt resulted in my Raspberry not booting (I also tried a modified w1.dtb which should also handle my second w1-bus).<br />
:* I've cross-compiled the kernel on a linux-VM, using the instructions of http://elinux.org/RPi_Kernel_Compilation (compiling on the RaspberryPi takes 6 hours [http://wiki.gentoo.org/wiki/Raspberry_Pi_Kernel_Compilation] or much more [http://elinux.org/RPi_Kernel_Compilation]).<br />
<br />
====Some 1-wire internals====<br />
* https://www.kernel.org/doc/Documentation/w1/w1.generic<br />
* [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]<br />
* http://blog.gegg.us/2013/03/4-different-methods-of-1-wire-access-on-raspberry-pi/<br />
<br />
===Compiling own kernel===<br />
<br />
* Some hints on cross-compiling:<br />
:* http://elinux.org/RPi_Kernel_Compilation<br />
:* https://github.com/raspberrypi/linux/tree/rpi-3.12.y/arch/arm/mach-bcm2708<br />
:* https://github.com/notro/rpi-source/wiki<br />
:* https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489&start=75<br />
:* http://www.bootc.net/projects/raspberry-pi-kernel/<br />
:* http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-recompile.html<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-cross-compile.html<br />
:* http://www.gtkdb.de/index_36_2087.html<br />
<br />
* extract kernel config from image:<br />
::<code>scripts/extract-ikconfig kernel-image</code><br />
::(extract-ikconfig is part of the kernel sources)<br />
<br />
===Device Trees===<br />
<br />
:* http://www.raspberrypi.org/documentation/configuration/device-tree.md<br />
:* https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt<br />
<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=97216<br />
:* http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f<br />
:* http://www.forum-raspberrypi.de/Thread-tutorial-geraetetreiber-und-device-tree-dt (German)<br />
<br />
:* http://xillybus.com/tutorials/device-tree-zynq-1<br />
<br />
===What about updates?===<br />
<br />
As I always forget this<br />
* <code>apt-get update</code> - update package lists<br />
* <code>apt-get upgrade</code> - upgrade installed packages<br />
* <code>rpi-update</code> - update kernel and modules<br />
::use <code>SKIP_KERNEL=1 rpi-update</code> to update the RPi firmware, but keep the current kernel<br />
::set <code>SKIP_REPODELETE=1</code> to keep downloaded files (by default: <code>/root/.rpi-firmware</code>)<br />
<br />
Kernel Sources<br />
* https://github.com/notro/rpi-source gets the source data from https://github.com/Hexxeh/rpi-firmware and https://github.com/raspberrypi/linux/<br />
<br />
===Hints for reading Kernel Panics===<br />
<br />
* http://ptgmedia.pearsoncmg.com/images/013147751X/downloads/013147751X_book.pdf<br />
: p290:<br />
export CONFIG_DEBUG_INFO=1<br />
make kernel/sysctl.o<br />
objdump -d -S kernel/sysctl.o > kernel/sysctl.dump<br />
<br />
* http://www.opensourceforu.com/2011/01/understanding-a-kernel-oops/<br />
<br />
* http://www.lowlevel.eu/wiki/ARM-OS-Dev_Teil_2_%E2%80%93_Assembler_101<br />
<br />
==Attaching a LCD display (HD44780 controller)==<br />
<br />
===Wiring and Specs===<br />
<br />
* Specs<br />
** ftp://imall.iteadstudio.com/IM120424018_EONE_2004_Characters_LCD/SPE_IM120424018_EONE_2004_Characters_LCD.pdf<br />
** http://www.adafruit.com/datasheets/HD44780.pdf<br />
<br />
* http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display (German)<br />
<br />
* http://www.pro-linux.de/artikel/2/1624/5,die-anzeige-hardware-und-software.html<br />
<br />
* https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring<br />
<br />
* https://github.com/perryflynn/raspberrypi-misc/tree/master/charlcd_4x20_cmd<br />
<br />
* http://obrazki.elektroda.pl/5028699400_1384164963.jpg<br />
<br />
===Misc===<br />
<br />
* http://www.makerspaceuk.com/lcd-temp-sensor/<br />
<br />
* http://anwendungsentwickler.ws/blog/kategorien/raspberry-pi/4x20-lcd-screen-mit-dem-raspberry-pi.html (German)<br />
<br />
==Controlling the display==<br />
<br />
* Python [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO]<br />
<br />
===LCDProc hints===<br />
<br />
* Pi & GPIO powered HD44780 LCD: http://www.boeeerb.co.uk/pi-lcd/<br />
<br />
* https://metacpan.org/pod/Net::LCDproc<br />
<br />
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=63412<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-user.html<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-dev.html<br />
<br />
* http://tuxgraphics.org/electronics/200504/article375.shtml<br />
<br />
==Todo and Miscellaneous==<br />
<br />
<br />
===Collection of stuff to check - things I might) try sometime===<br />
<br />
* http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/<br />
<br />
* [http://en.wikipedia.org/wiki/F2FS f2fs]<br />
:* [http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=65330 F2fs, Ext4, FAT USB Benchmark]<br />
:* [http://forum.xda-developers.com/showthread.php?t=2697069 File System Performance: F2FS vs EXT4]<br />
<br />
* https://github.com/yuraa/Raspberry-Pi-Heartbeat<br />
<br />
* http://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html<br />
<br />
* [http://www.raspberrypi.org/archives/5282 Mathematica on Raspberry Pi, for free]<br />
:* also works in RasPi emulator, e.g. http://www.heise.de/ct/inhalt/2014/7/160/ (German, teaser to article)<br />
<br />
* NAS/Samba<br />
:* 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:<br />
:<code>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536</code><br />
<br />
* http://linuxtortures.blogspot.fr/2012/06/cross-compiling-and-cross-debugging-c.html<br />
<br />
===Things done===<br />
<br />
* Adjust swap file (size, location -> (ext4) HDD - too slow?): http://manpages.ubuntu.com/manpages/hardy/man8/dphys-swapfile.8.html<br />
<br />
* http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/<br />
<br />
==Some links (aka bookmark lists)==<br />
<br />
Project sites<br />
<br />
* [http://www.cl.cam.ac.uk/projects/raspberrypi/ University of Cambridge / Raspberry Pi Computer Laboratory]<br />
* [https://www.raspiprojekt.de/ raspiprojek] (German)<br />
* http://www.vanheusden.com/misc/rpi.php<br />
<br />
Blogs, forums, etc<br />
* http://www.raspberrypi.org/phpBB3/<br />
* [http://forum.stmlabs.com/forumdisplay.php?fid=6 Stm Labs Forum / Raspbmc]<br />
* [http://www.welzels.de/blog/projekte/raspberry-pi/ Wel!s Blog] (German)<br />
* [http://jankarres.de/category/raspberry-pi/ Raspberry Pi Blog of Jan Karres] (German)<br />
* http://www.forum-raspberrypi.de/ /(German)<br />
* http://raspberrycenter.de/ (German)<br />
* http://archlinuxarm.org/forum/viewforum.php?f=31&sid=57987232ca9177c35eb3ef7fdf6b3341<br />
<br />
* [[wikipedia:Raspberry_Pi Raspberry Pi in Wikipedia]]<br />
<br />
Miscellaneous<br />
<br />
* [http://www.raspberrypi.org/downloads New Out Of Box Software (Recommended)]<br />
* [http://elinux.org/R-Pi_Hub R-Pi_Hub]<br />
<br />
Manuals<br />
<br />
* https://github.com/raspberrypi/documentation<br />
<br />
* [http://debian-handbook.info/browse/stable/ The Debian Administrator's Handbook]</div>Holyheadhttps://holyhead.de/index.php?title=Raspberry_PiRaspberry Pi2015-02-11T23:06:38Z<p>Holyhead: /* Wiring and Specs */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
===External USB drives===<br />
<br />
* Automount USB-Drives in Raspbian<br />
** One may use [http://selfprogramming.bplaced.net/index.php/2012/10/23/automount-usb-drives-in-raspbian/ USBmount and autofs]<br />
** I prefer [http://ignorantguru.github.io/udevil/ udevil], see below<br />
<br />
* Install ''ntfs-3g'' if you need write access to ntfs file systems<br />
<br />
* How to increase performance?<br />
** Mount with option ''''noatime'''' or ''''relatime''''<br />
** Mount ''without'' option sync (e.g. keep default async)<br />
** If using ntfs-3g (fuse) file system, try mounting with option 'big_writes', see for example http://obihoernchen.net/wordpress/tag/big_writes/<br />
<br />
===[http://ignorantguru.github.io/udevil/ udevil]===<br />
<br />
* example for manual mounting:<br />
<br />
udevil mount /dev/sda1<br />
<br />
* auto-mounting via udev-rule, see for example http://lsdlinux.org/wiki/doku.php?id=auto_mounting#using_udev_rule (I just copied the 95-udevil-mount.rules file from an OpenElec installation (http://www.raspberrypi.org/downloads) )<br />
<br />
* my build-steps (maybe there's a simpler way, but this worked...):<br />
** download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget<br />
** extract deb-package via <code>ar vx udevil_0.4.3-1_all.deb</code><br />
** extract data archive <code>tar xzvf data.tar.gz</code><br />
** change to tar usr/share/devil/src<br />
** untar <code>tar xvfJ udevil-current.tar.xz</code><br />
** <code>cd udevil-0.4.3</code><br />
** <code>mv distros/debian</code><br />
** execute <code>dpkg-buildpackage</code><br />
** 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<br />
** Install via <code>sudo dpkg -i udevil_0.4.3-1_armhf.deb</code><br />
<br />
===Samba server / NAS===<br />
<br />
* How to install?<br />
** [http://jankarres.de/2013/11/raspberry-pi-samba-server-installieren/ | Raspberry Pi: Samba Server installieren] (German)<br />
** [http://www.welzels.de/blog/projekte/raspberry-pi/low-budget-nas-mit-einem-raspberry-pi/ Low Budget NAS mit einem Raspberry PI] (German)<br />
<br />
* Slow disc performance?<br />
** see 'Slow USB drives' above<br />
** 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!)<br />
<br />
* Configuration and tuning<br />
** https://calomel.org/samba.html<br />
** https://calomel.org/samba_optimize.html<br />
<br />
* If your /var/log/samba/log.smbd fills up with ''printing/print_cups.c:110(cups_connect) Unable to connect to CUPS server localhost'' messages, try http://www.sotechdesign.com.au/samba-log-showing-error-failed-to-retrieve-printer-list/<br/>I also created an empty <code>/etc/printcap</code> to avoid ''Unable to open printcap file /etc/printcap for read'' messages.<br />
<br />
* I don't need sound:<br />
<br />
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf <br />
# I don't need sound<br />
blacklist snd<br />
blacklist snd_pcm<br />
blacklist snd_soc_core<br />
blacklist snd_soc_bcm2708_i2s<br />
<br />
===Trying to reduce number of disk writes (SD card)===<br />
<br />
I'm using [http://oss.oetiker.ch/rrdtool/ 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).<br />
<br />
Here's what I've done:<br />
<br />
* Edit <code>/etc/default/cron</code> and set <code>EXTRA_OPTS="-L 0"</code> to disable logging (I don't need these)<br />
* Avoid entries like <code>pam_unix(cron:session): session closed for user pi</code> in <code>/var/log/auth.log</code><br />
** Edit <code>/etc/pam.d/cron</code> and comment the line <code>@include common-session-noninteractive</code> ([http://ubuntuforums.org/showthread.php?t=1256801])<br />
:or<br />
:* Edit <code>/etc/pam.d/common-session-noninteractive</code> as shown here: http://ubuntuforums.org/showthread.php?t=1256801&p=10283830#post10283830<br />
* I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)<br />
** moved all the .rrd files as well as the created images to my persistent-ramdisk location<br />
** moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links<br />
*** <code>/var/spool</code><br />
*** <code>/var/log</code><br />
*** <code>/var/cache/samba</code><br />
** edited <code>/etc/insserv.conf</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:<br />
<br />
$local_fs_orig +mountall +mountall-bootclean +mountoverflowtmp +umountfs<br />
# we need the sym-link data in /var/log and /var/spool to be available<br />
$local_fs $local_fs_orig +persist-ramdisk<br />
<br />
:: <code>/etc/init.d/persist-ramdisk</code> 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.<br />
<br />
:* set ''RAMTMP'' to yes in <code>/etc/default/tmpfs</code> to get tempfs based <code>/tmp</code><br />
<br />
Before changing <code>/tmp</code>:<br />
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').<br />
::I need to do more digging...<br />
<br />
After changing <code>/tmp</code>:<br />
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...<br />
<br />
===Useful stuff and Q&A===<br />
<br />
* Q: Why does my Pi restart when hotplugging a USB drive?<br />
** http://thestuffsido.blogspot.de/2013/05/fixing-raspberry-pi-hotplugging.html<br />
** http://therandomlab.blogspot.de/2013/01/raspberry-pi-mod-to-avoid-shutdown-on.html<br />
<br />
* Q: Does Raspberry support WOL?<br />
: A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)<br />
<br />
* Q: The new password is to short, or too simple<br />
: A: Try adjusting the PAM settings in <code>/etc/pam.d/common-password</code>:<br />
:* remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)<br />
::<code>password [success=1 default=ignore] pam_unix.so sha512 minlen=2</code><br />
<br />
::!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!<br><br />
::But it's nice for testing (if you cannot or do not want to use auto-login.)<br />
<br />
* Q: How to configure static IP?<br />
: A: In /etc/network/interfaces:<br />
::<code>iface eth0 inet static<br>address 192.168.0.31<br>netmask 255.255.255.0<br>gateway 192.168.0.1</code><br />
<br />
* Q: How to read core temperature, etc?<br />
: A: [http://elinux.org/RPI_vcgencmd_usage vcgencmd]:<br />
::<code>vcgencmd measure_temp<br>vcgencmd measure_clock arm</code><br />
<br />
* External USB HDD spin down<br />
** hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)<br />
** hd-idle works:<br />
::<code>hd-idle -a sda -i 600</code><br />
:: for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)<br />
<br />
* Q: How to avoid update of a certain package?<br />
: A: Put package on hold ([http://debiananwenderhandbuch.de/dpkg.html] (German)):<br />
::<code>echo <packagename> "hold" | dpkg --set-selections</code><br />
<br />
* [[wikipedia:Raspcontrol]] with nginx<br />
** http://www.foxplex.com/sites/raspcontrol-webinterface-auf-dem-raspberry-pi/ (German), http://www.foxplex.com/sites/performanter-nginx-webserver-auf-dem-raspberry-pi-mit-php-und-apc/ (German)<br />
** http://menzerath.eu/artikel/raspberry-pi-raspcontrol-installation-funktionen/ (German)<br />
<br />
* Q: How many bytes are written to my (SD) disc?<br />
: A: Use <code>iostat</code> http://www.mybinarylife.net/2012/08/linux-iostat-command.html<br />
: A: Use <code>iotop</code> http://guichaz.free.fr/iotop/<br />
: A: Raw data of the kernel can be found in files <code>/proc/diskstats</code> and <code>/sys/block/DEVNAME/stat</code> https://www.kernel.org/doc/Documentation/iostats.txt<br />
:* http://unix.stackexchange.com/questions/86391/how-to-get-total-number-of-bytes-sectors-blocks-written-to-disk-since-booting<br />
:* http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux<br />
<br />
* Q: How to reduce number of ext-fs checks?<br />
: A: <code>tune2fs -c 60 /dev/sda1</code> Change maximum mount count to 60<br />
: A: <code>tune2fs -i 12m /dev/sda1</code> Change check interval to 12 months<br />
: fore more details: http://wiki.ubuntuusers.de/Dateisystemcheck (German)<br />
<br />
===Overclocking===<br />
<br />
* I only set overclocking via <code>raspi-config</code><br />
<br />
* ''Turbo'': (Short) Raspberry stress test were ok. But I got an SD card error/corruption when doing a download and a dd-image of the SD card (according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907 the SD card error could be OC related.)<br />
::Luckily, I could recover all my data, see below.<br />
<br />
* '' Medium'': Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907] and its links).<br />
<br />
* Underclocking to 600 MHz<br />
:<code>echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</code><br />
: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.<br />
<br />
* Adjusting the ondemand-governor<br />
** https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt<br />
** set <code>/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor</code> to 10 [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&start=800]<br />
**: I had hoped this reduces the 1-wire CRC errors/device-disconnects problems, but with heavy (IO-) load (e.g. backup), 1wire sensors still get disconnected.<br />
<br />
* [http://moze.free.fr/blog/index.php?post/2013/02/Underclock-and-Overclock Nice power consumption analysis]<br />
<br />
====Stress test and benchmarks====<br />
<br />
* [http://www.roylongbottom.org.uk/ Roy Longbottom's PC Benchmark Collection]<br />
* [http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm Raspberry Pi Stress Tests]<br />
<br />
===SD card issues===<br />
<br />
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). I could still use this card for some time (see below), but finally I got a corrupted file system and could no longer repair it. That's when I re-installed Raspbian on a new SD card.<br />
<br />
Maybe I should try [http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ running from USB] sometime?<br />
<br />
====Recovery====<br />
* Creating a binary image of the SD card with my PC using [http://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] resulted in IO errors at about 17%.<br />
* 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 <code>dd conv=sync,noerror if=/dev/sdb2 of=rasp-image.img bs=1M</code> on my Linux machine (option <code>conv=noerror</code> ignores any errors, sync pads read-errors with zeros). The resulting image could not be mounted using a loop device. <br />
* Fortunately, <code>fsck.ext4 raspberry-image.bin</code> was able to repair the image, which I then could successfully mount on my Linux machine using <code>mount -o loop rasp-image.img /mnt</code>, and at a first glance, everything looked ok. So, I was at least able to get to my data. <br />
* On a later 'event', I dd-ed the repaired image back to the Raspberry, and could boot again.<br />
* On another a later 'event', I just fsck-ed the /dev/sdb2 using Linux, and could boot again... but I did not have luck this time - some files were gone.<br />
* 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.<br />
* My Raspberry successfully booted from this new image. I then used <code>raspi-config</code> to expand the root-fs (I've done this on my first installation as well). With Linux I was able to <code>dd</code> my repaired image to the repaired SD. The card booted as if nothing had happened...<br />
* But after some weeks, my Raspberry fried the SD card again, and some weeks later again ... And finally I could not get my pi to boot with this card. However, I can still read the data linux. Moving data to a new card... (easier said than done if the new card is slightly smaller... but, see below for resizing... and sometimes a fresh install is even less painful).<br />
<br />
===Reminders: dd, dd_rescue, losetup, mount and others===<br />
* Example partition table printed by fdisk:<br />
<code><br />
/dev/sdb: 7861 MB, 7861174272 bytes, 15353856 sectors<br />
Units = Sektoren of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
<br />
Gerät boot. Anfang Ende Blöcke Id System<br />
[...]<br />
/dev/sdb3 15288320 15353855 32768 83 Linux</code><br />
:Byte-offset of sdb3: 7827619840 = 15288320 * 512<br />
<br />
* Mount partition to /dev/loopN partition for repair, etc.<br />
:<code>losetup -o 7827619840 --find --show /dev/sdb</code><br />
:--show prints the used /dev/loopN device<br />
<br />
* Directly mount partition using loop device:<br />
:<code>mount -o loop,offset=7827619840 /dev/sdb /mnt</code><br />
* http://www.garloff.de/kurt/linux/ddrescue/<br />
* http://softwarebakery.com/shrinking-images-on-linux<br />
* http://www.tehfear.com/2007/10/08/resize-loop-disk-image/<br />
* http://wiki.ubuntuusers.de/dd (German)<br />
* http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device<br />
<br />
===Some 1-Wire Stuff===<br />
<br />
====Temperature Sensor DS1820====<br />
<br />
* How to?<br />
** http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/<br />
** https://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&start=1 (German)<br />
** http://kopfkino.irosaurus.com/tutorial-ds18s20-temperatur-sensor-an-einem-raspberry-pi/ (German)<br />
** http://raspberrywebserver.com/cgiscripting/rpi-temperature-logger/<br />
** http://elinux.org/RPi_Low-level_peripherals<br />
<br />
* I have two DS18B20 and log temperatures using rrdtool.<br />
<br />
* 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). <br />
** Q: Is this due to overclocking with using dynamic governor?<br />
** A: No - also occurs without overclocking (but less frequent?)<br />
** Q: Or is this due to voltage-problems?<br />
** A: No - also occurs without over-voltage<br />
** Q: Or something else?<br />
** 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). Using 3 sensors works almost all the time (without overclocking), but using 4 or more sensors (2 connected star topologies, very bad for 1-wire [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]), almost always fails to read values on most of the sensors.<br />
** A:'''Implement multiple 1-wire interfaces''' (see below), using 1 for each star-topology solved the problem. Reading 2x3 works perfect!<br />
<br />
====Multiple 1-wire buses====<br />
:* Inspired and guided by http://www.raspberrypi.org/forums/viewtopic.php?p=513312#p513312, I've patched my 3.12.y kernel <code>arch/arm/mach-bcm2708/bcm2708.c</code> (patch file http://holyhead.de/RaspberryPi/bcm2708-multiple_w-1.patch-3.12.21.txt).<br />
::* Note: With kernel version, device tree were introduced, see for example http://www.raspberrypi.org/documentation/configuration/device-tree.md<BR>But somehow 1-wire works for my 3.18.5+ without specifying any dtoverlays... And all tries to configure w1-gpio-overlay.dtb via config.txt resulted in my Raspberry not booting (I also tried a modified w1.dtb which should also handle my second w1-bus).<br />
:* I've cross-compiled the kernel on a linux-VM, using the instructions of http://elinux.org/RPi_Kernel_Compilation (compiling on the RaspberryPi takes 6 hours [http://wiki.gentoo.org/wiki/Raspberry_Pi_Kernel_Compilation] or much more [http://elinux.org/RPi_Kernel_Compilation]).<br />
<br />
====Some 1-wire internals====<br />
* https://www.kernel.org/doc/Documentation/w1/w1.generic<br />
* [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]<br />
* http://blog.gegg.us/2013/03/4-different-methods-of-1-wire-access-on-raspberry-pi/<br />
<br />
===Compiling own kernel===<br />
<br />
* Some hints on cross-compiling:<br />
:* http://elinux.org/RPi_Kernel_Compilation<br />
:* https://github.com/raspberrypi/linux/tree/rpi-3.12.y/arch/arm/mach-bcm2708<br />
:* https://github.com/notro/rpi-source/wiki<br />
:* https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489&start=75<br />
:* http://www.bootc.net/projects/raspberry-pi-kernel/<br />
:* http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-recompile.html<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-cross-compile.html<br />
:* http://www.gtkdb.de/index_36_2087.html<br />
<br />
* extract kernel config from image:<br />
::<code>scripts/extract-ikconfig kernel-image</code><br />
::(extract-ikconfig is part of the kernel sources)<br />
<br />
===Device Trees===<br />
<br />
:* http://www.raspberrypi.org/documentation/configuration/device-tree.md<br />
:* https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt<br />
<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=97216<br />
:* http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f<br />
:* http://www.forum-raspberrypi.de/Thread-tutorial-geraetetreiber-und-device-tree-dt (German)<br />
<br />
:* http://xillybus.com/tutorials/device-tree-zynq-1<br />
<br />
===What about updates?===<br />
<br />
As I always forget this<br />
* <code>apt-get update</code> - update package lists<br />
* <code>apt-get upgrade</code> - upgrade installed packages<br />
* <code>rpi-update</code> - update kernel and modules<br />
::use <code>SKIP_KERNEL=1 rpi-update</code> to update the RPi firmware, but keep the current kernel<br />
::set <code>SKIP_REPODELETE=1</code> to keep downloaded files (by default: <code>/root/.rpi-firmware</code>)<br />
<br />
Kernel Sources<br />
* https://github.com/notro/rpi-source gets the source data from https://github.com/Hexxeh/rpi-firmware and https://github.com/raspberrypi/linux/<br />
<br />
===Hints for reading Kernel Panics===<br />
<br />
* http://ptgmedia.pearsoncmg.com/images/013147751X/downloads/013147751X_book.pdf<br />
: p290:<br />
export CONFIG_DEBUG_INFO=1<br />
make kernel/sysctl.o<br />
objdump -d -S kernel/sysctl.o > kernel/sysctl.dump<br />
<br />
* http://www.opensourceforu.com/2011/01/understanding-a-kernel-oops/<br />
<br />
* http://www.lowlevel.eu/wiki/ARM-OS-Dev_Teil_2_%E2%80%93_Assembler_101<br />
<br />
==Attaching a LCD display (HD44780 controller)==<br />
<br />
===Wiring and Specs===<br />
<br />
* Specs<br />
** ftp://imall.iteadstudio.com/IM120424018_EONE_2004_Characters_LCD/SPE_IM120424018_EONE_2004_Characters_LCD.pdf<br />
** http://www.adafruit.com/datasheets/HD44780.pdf<br />
<br />
* http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display (German)<br />
<br />
* http://www.pro-linux.de/artikel/2/1624/5,die-anzeige-hardware-und-software.html<br />
<br />
* https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring<br />
<br />
* https://github.com/perryflynn/raspberrypi-misc/tree/master/charlcd_4x20_cmd<br />
<br />
* http://obrazki.elektroda.pl/5028699400_1384164963.jpg<br />
<br />
===Misc===<br />
<br />
* http://www.makerspaceuk.com/lcd-temp-sensor/<br />
<br />
* http://anwendungsentwickler.ws/blog/kategorien/raspberry-pi/4x20-lcd-screen-mit-dem-raspberry-pi.html (German)<br />
<br />
==Controlling the display==<br />
<br />
* Python [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO]<br />
<br />
===LCDProc hints===<br />
<br />
* Pi & GPIO powered HD44780 LCD: http://www.boeeerb.co.uk/pi-lcd/<br />
<br />
* https://metacpan.org/pod/Net::LCDproc<br />
<br />
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=63412<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-user.html<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-dev.html<br />
<br />
* http://tuxgraphics.org/electronics/200504/article375.shtml<br />
<br />
==Todo and Miscellaneous==<br />
<br />
<br />
===Collection of stuff to check - things I might) try sometime===<br />
<br />
* http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/<br />
<br />
* [http://en.wikipedia.org/wiki/F2FS f2fs]<br />
:* [http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=65330 F2fs, Ext4, FAT USB Benchmark]<br />
:* [http://forum.xda-developers.com/showthread.php?t=2697069 File System Performance: F2FS vs EXT4]<br />
<br />
* https://github.com/yuraa/Raspberry-Pi-Heartbeat<br />
<br />
* http://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html<br />
<br />
* [http://www.raspberrypi.org/archives/5282 Mathematica on Raspberry Pi, for free]<br />
:* also works in RasPi emulator, e.g. http://www.heise.de/ct/inhalt/2014/7/160/ (German, teaser to article)<br />
<br />
* NAS/Samba<br />
:* 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:<br />
:<code>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536</code><br />
<br />
* http://linuxtortures.blogspot.fr/2012/06/cross-compiling-and-cross-debugging-c.html<br />
<br />
===Things done===<br />
<br />
* Adjust swap file (size, location -> (ext4) HDD - too slow?): http://manpages.ubuntu.com/manpages/hardy/man8/dphys-swapfile.8.html<br />
<br />
* http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/<br />
<br />
==Some links (aka bookmark lists)==<br />
<br />
Project sites<br />
<br />
* [http://www.cl.cam.ac.uk/projects/raspberrypi/ University of Cambridge / Raspberry Pi Computer Laboratory]<br />
* [https://www.raspiprojekt.de/ raspiprojek] (German)<br />
* http://www.vanheusden.com/misc/rpi.php<br />
<br />
Blogs, forums, etc<br />
* http://www.raspberrypi.org/phpBB3/<br />
* [http://forum.stmlabs.com/forumdisplay.php?fid=6 Stm Labs Forum / Raspbmc]<br />
* [http://www.welzels.de/blog/projekte/raspberry-pi/ Wel!s Blog] (German)<br />
* [http://jankarres.de/category/raspberry-pi/ Raspberry Pi Blog of Jan Karres] (German)<br />
* http://www.forum-raspberrypi.de/ /(German)<br />
* http://raspberrycenter.de/ (German)<br />
* http://archlinuxarm.org/forum/viewforum.php?f=31&sid=57987232ca9177c35eb3ef7fdf6b3341<br />
<br />
* [[wikipedia:Raspberry_Pi Raspberry Pi in Wikipedia]]<br />
<br />
Miscellaneous<br />
<br />
* [http://www.raspberrypi.org/downloads New Out Of Box Software (Recommended)]<br />
* [http://elinux.org/R-Pi_Hub R-Pi_Hub]<br />
<br />
Manuals<br />
<br />
* https://github.com/raspberrypi/documentation<br />
<br />
* [http://debian-handbook.info/browse/stable/ The Debian Administrator's Handbook]</div>Holyheadhttps://holyhead.de/index.php?title=Raspberry_PiRaspberry Pi2015-02-11T23:03:20Z<p>Holyhead: /* Attaching a LCD display */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
===External USB drives===<br />
<br />
* Automount USB-Drives in Raspbian<br />
** One may use [http://selfprogramming.bplaced.net/index.php/2012/10/23/automount-usb-drives-in-raspbian/ USBmount and autofs]<br />
** I prefer [http://ignorantguru.github.io/udevil/ udevil], see below<br />
<br />
* Install ''ntfs-3g'' if you need write access to ntfs file systems<br />
<br />
* How to increase performance?<br />
** Mount with option ''''noatime'''' or ''''relatime''''<br />
** Mount ''without'' option sync (e.g. keep default async)<br />
** If using ntfs-3g (fuse) file system, try mounting with option 'big_writes', see for example http://obihoernchen.net/wordpress/tag/big_writes/<br />
<br />
===[http://ignorantguru.github.io/udevil/ udevil]===<br />
<br />
* example for manual mounting:<br />
<br />
udevil mount /dev/sda1<br />
<br />
* auto-mounting via udev-rule, see for example http://lsdlinux.org/wiki/doku.php?id=auto_mounting#using_udev_rule (I just copied the 95-udevil-mount.rules file from an OpenElec installation (http://www.raspberrypi.org/downloads) )<br />
<br />
* my build-steps (maybe there's a simpler way, but this worked...):<br />
** download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget<br />
** extract deb-package via <code>ar vx udevil_0.4.3-1_all.deb</code><br />
** extract data archive <code>tar xzvf data.tar.gz</code><br />
** change to tar usr/share/devil/src<br />
** untar <code>tar xvfJ udevil-current.tar.xz</code><br />
** <code>cd udevil-0.4.3</code><br />
** <code>mv distros/debian</code><br />
** execute <code>dpkg-buildpackage</code><br />
** 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<br />
** Install via <code>sudo dpkg -i udevil_0.4.3-1_armhf.deb</code><br />
<br />
===Samba server / NAS===<br />
<br />
* How to install?<br />
** [http://jankarres.de/2013/11/raspberry-pi-samba-server-installieren/ | Raspberry Pi: Samba Server installieren] (German)<br />
** [http://www.welzels.de/blog/projekte/raspberry-pi/low-budget-nas-mit-einem-raspberry-pi/ Low Budget NAS mit einem Raspberry PI] (German)<br />
<br />
* Slow disc performance?<br />
** see 'Slow USB drives' above<br />
** 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!)<br />
<br />
* Configuration and tuning<br />
** https://calomel.org/samba.html<br />
** https://calomel.org/samba_optimize.html<br />
<br />
* If your /var/log/samba/log.smbd fills up with ''printing/print_cups.c:110(cups_connect) Unable to connect to CUPS server localhost'' messages, try http://www.sotechdesign.com.au/samba-log-showing-error-failed-to-retrieve-printer-list/<br/>I also created an empty <code>/etc/printcap</code> to avoid ''Unable to open printcap file /etc/printcap for read'' messages.<br />
<br />
* I don't need sound:<br />
<br />
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf <br />
# I don't need sound<br />
blacklist snd<br />
blacklist snd_pcm<br />
blacklist snd_soc_core<br />
blacklist snd_soc_bcm2708_i2s<br />
<br />
===Trying to reduce number of disk writes (SD card)===<br />
<br />
I'm using [http://oss.oetiker.ch/rrdtool/ 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).<br />
<br />
Here's what I've done:<br />
<br />
* Edit <code>/etc/default/cron</code> and set <code>EXTRA_OPTS="-L 0"</code> to disable logging (I don't need these)<br />
* Avoid entries like <code>pam_unix(cron:session): session closed for user pi</code> in <code>/var/log/auth.log</code><br />
** Edit <code>/etc/pam.d/cron</code> and comment the line <code>@include common-session-noninteractive</code> ([http://ubuntuforums.org/showthread.php?t=1256801])<br />
:or<br />
:* Edit <code>/etc/pam.d/common-session-noninteractive</code> as shown here: http://ubuntuforums.org/showthread.php?t=1256801&p=10283830#post10283830<br />
* I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)<br />
** moved all the .rrd files as well as the created images to my persistent-ramdisk location<br />
** moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links<br />
*** <code>/var/spool</code><br />
*** <code>/var/log</code><br />
*** <code>/var/cache/samba</code><br />
** edited <code>/etc/insserv.conf</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:<br />
<br />
$local_fs_orig +mountall +mountall-bootclean +mountoverflowtmp +umountfs<br />
# we need the sym-link data in /var/log and /var/spool to be available<br />
$local_fs $local_fs_orig +persist-ramdisk<br />
<br />
:: <code>/etc/init.d/persist-ramdisk</code> 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.<br />
<br />
:* set ''RAMTMP'' to yes in <code>/etc/default/tmpfs</code> to get tempfs based <code>/tmp</code><br />
<br />
Before changing <code>/tmp</code>:<br />
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').<br />
::I need to do more digging...<br />
<br />
After changing <code>/tmp</code>:<br />
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...<br />
<br />
===Useful stuff and Q&A===<br />
<br />
* Q: Why does my Pi restart when hotplugging a USB drive?<br />
** http://thestuffsido.blogspot.de/2013/05/fixing-raspberry-pi-hotplugging.html<br />
** http://therandomlab.blogspot.de/2013/01/raspberry-pi-mod-to-avoid-shutdown-on.html<br />
<br />
* Q: Does Raspberry support WOL?<br />
: A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)<br />
<br />
* Q: The new password is to short, or too simple<br />
: A: Try adjusting the PAM settings in <code>/etc/pam.d/common-password</code>:<br />
:* remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)<br />
::<code>password [success=1 default=ignore] pam_unix.so sha512 minlen=2</code><br />
<br />
::!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!<br><br />
::But it's nice for testing (if you cannot or do not want to use auto-login.)<br />
<br />
* Q: How to configure static IP?<br />
: A: In /etc/network/interfaces:<br />
::<code>iface eth0 inet static<br>address 192.168.0.31<br>netmask 255.255.255.0<br>gateway 192.168.0.1</code><br />
<br />
* Q: How to read core temperature, etc?<br />
: A: [http://elinux.org/RPI_vcgencmd_usage vcgencmd]:<br />
::<code>vcgencmd measure_temp<br>vcgencmd measure_clock arm</code><br />
<br />
* External USB HDD spin down<br />
** hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)<br />
** hd-idle works:<br />
::<code>hd-idle -a sda -i 600</code><br />
:: for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)<br />
<br />
* Q: How to avoid update of a certain package?<br />
: A: Put package on hold ([http://debiananwenderhandbuch.de/dpkg.html] (German)):<br />
::<code>echo <packagename> "hold" | dpkg --set-selections</code><br />
<br />
* [[wikipedia:Raspcontrol]] with nginx<br />
** http://www.foxplex.com/sites/raspcontrol-webinterface-auf-dem-raspberry-pi/ (German), http://www.foxplex.com/sites/performanter-nginx-webserver-auf-dem-raspberry-pi-mit-php-und-apc/ (German)<br />
** http://menzerath.eu/artikel/raspberry-pi-raspcontrol-installation-funktionen/ (German)<br />
<br />
* Q: How many bytes are written to my (SD) disc?<br />
: A: Use <code>iostat</code> http://www.mybinarylife.net/2012/08/linux-iostat-command.html<br />
: A: Use <code>iotop</code> http://guichaz.free.fr/iotop/<br />
: A: Raw data of the kernel can be found in files <code>/proc/diskstats</code> and <code>/sys/block/DEVNAME/stat</code> https://www.kernel.org/doc/Documentation/iostats.txt<br />
:* http://unix.stackexchange.com/questions/86391/how-to-get-total-number-of-bytes-sectors-blocks-written-to-disk-since-booting<br />
:* http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux<br />
<br />
* Q: How to reduce number of ext-fs checks?<br />
: A: <code>tune2fs -c 60 /dev/sda1</code> Change maximum mount count to 60<br />
: A: <code>tune2fs -i 12m /dev/sda1</code> Change check interval to 12 months<br />
: fore more details: http://wiki.ubuntuusers.de/Dateisystemcheck (German)<br />
<br />
===Overclocking===<br />
<br />
* I only set overclocking via <code>raspi-config</code><br />
<br />
* ''Turbo'': (Short) Raspberry stress test were ok. But I got an SD card error/corruption when doing a download and a dd-image of the SD card (according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907 the SD card error could be OC related.)<br />
::Luckily, I could recover all my data, see below.<br />
<br />
* '' Medium'': Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907] and its links).<br />
<br />
* Underclocking to 600 MHz<br />
:<code>echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</code><br />
: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.<br />
<br />
* Adjusting the ondemand-governor<br />
** https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt<br />
** set <code>/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor</code> to 10 [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&start=800]<br />
**: I had hoped this reduces the 1-wire CRC errors/device-disconnects problems, but with heavy (IO-) load (e.g. backup), 1wire sensors still get disconnected.<br />
<br />
* [http://moze.free.fr/blog/index.php?post/2013/02/Underclock-and-Overclock Nice power consumption analysis]<br />
<br />
====Stress test and benchmarks====<br />
<br />
* [http://www.roylongbottom.org.uk/ Roy Longbottom's PC Benchmark Collection]<br />
* [http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm Raspberry Pi Stress Tests]<br />
<br />
===SD card issues===<br />
<br />
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). I could still use this card for some time (see below), but finally I got a corrupted file system and could no longer repair it. That's when I re-installed Raspbian on a new SD card.<br />
<br />
Maybe I should try [http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ running from USB] sometime?<br />
<br />
====Recovery====<br />
* Creating a binary image of the SD card with my PC using [http://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] resulted in IO errors at about 17%.<br />
* 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 <code>dd conv=sync,noerror if=/dev/sdb2 of=rasp-image.img bs=1M</code> on my Linux machine (option <code>conv=noerror</code> ignores any errors, sync pads read-errors with zeros). The resulting image could not be mounted using a loop device. <br />
* Fortunately, <code>fsck.ext4 raspberry-image.bin</code> was able to repair the image, which I then could successfully mount on my Linux machine using <code>mount -o loop rasp-image.img /mnt</code>, and at a first glance, everything looked ok. So, I was at least able to get to my data. <br />
* On a later 'event', I dd-ed the repaired image back to the Raspberry, and could boot again.<br />
* On another a later 'event', I just fsck-ed the /dev/sdb2 using Linux, and could boot again... but I did not have luck this time - some files were gone.<br />
* 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.<br />
* My Raspberry successfully booted from this new image. I then used <code>raspi-config</code> to expand the root-fs (I've done this on my first installation as well). With Linux I was able to <code>dd</code> my repaired image to the repaired SD. The card booted as if nothing had happened...<br />
* But after some weeks, my Raspberry fried the SD card again, and some weeks later again ... And finally I could not get my pi to boot with this card. However, I can still read the data linux. Moving data to a new card... (easier said than done if the new card is slightly smaller... but, see below for resizing... and sometimes a fresh install is even less painful).<br />
<br />
===Reminders: dd, dd_rescue, losetup, mount and others===<br />
* Example partition table printed by fdisk:<br />
<code><br />
/dev/sdb: 7861 MB, 7861174272 bytes, 15353856 sectors<br />
Units = Sektoren of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
<br />
Gerät boot. Anfang Ende Blöcke Id System<br />
[...]<br />
/dev/sdb3 15288320 15353855 32768 83 Linux</code><br />
:Byte-offset of sdb3: 7827619840 = 15288320 * 512<br />
<br />
* Mount partition to /dev/loopN partition for repair, etc.<br />
:<code>losetup -o 7827619840 --find --show /dev/sdb</code><br />
:--show prints the used /dev/loopN device<br />
<br />
* Directly mount partition using loop device:<br />
:<code>mount -o loop,offset=7827619840 /dev/sdb /mnt</code><br />
* http://www.garloff.de/kurt/linux/ddrescue/<br />
* http://softwarebakery.com/shrinking-images-on-linux<br />
* http://www.tehfear.com/2007/10/08/resize-loop-disk-image/<br />
* http://wiki.ubuntuusers.de/dd (German)<br />
* http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device<br />
<br />
===Some 1-Wire Stuff===<br />
<br />
====Temperature Sensor DS1820====<br />
<br />
* How to?<br />
** http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/<br />
** https://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&start=1 (German)<br />
** http://kopfkino.irosaurus.com/tutorial-ds18s20-temperatur-sensor-an-einem-raspberry-pi/ (German)<br />
** http://raspberrywebserver.com/cgiscripting/rpi-temperature-logger/<br />
** http://elinux.org/RPi_Low-level_peripherals<br />
<br />
* I have two DS18B20 and log temperatures using rrdtool.<br />
<br />
* 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). <br />
** Q: Is this due to overclocking with using dynamic governor?<br />
** A: No - also occurs without overclocking (but less frequent?)<br />
** Q: Or is this due to voltage-problems?<br />
** A: No - also occurs without over-voltage<br />
** Q: Or something else?<br />
** 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). Using 3 sensors works almost all the time (without overclocking), but using 4 or more sensors (2 connected star topologies, very bad for 1-wire [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]), almost always fails to read values on most of the sensors.<br />
** A:'''Implement multiple 1-wire interfaces''' (see below), using 1 for each star-topology solved the problem. Reading 2x3 works perfect!<br />
<br />
====Multiple 1-wire buses====<br />
:* Inspired and guided by http://www.raspberrypi.org/forums/viewtopic.php?p=513312#p513312, I've patched my 3.12.y kernel <code>arch/arm/mach-bcm2708/bcm2708.c</code> (patch file http://holyhead.de/RaspberryPi/bcm2708-multiple_w-1.patch-3.12.21.txt).<br />
::* Note: With kernel version, device tree were introduced, see for example http://www.raspberrypi.org/documentation/configuration/device-tree.md<BR>But somehow 1-wire works for my 3.18.5+ without specifying any dtoverlays... And all tries to configure w1-gpio-overlay.dtb via config.txt resulted in my Raspberry not booting (I also tried a modified w1.dtb which should also handle my second w1-bus).<br />
:* I've cross-compiled the kernel on a linux-VM, using the instructions of http://elinux.org/RPi_Kernel_Compilation (compiling on the RaspberryPi takes 6 hours [http://wiki.gentoo.org/wiki/Raspberry_Pi_Kernel_Compilation] or much more [http://elinux.org/RPi_Kernel_Compilation]).<br />
<br />
====Some 1-wire internals====<br />
* https://www.kernel.org/doc/Documentation/w1/w1.generic<br />
* [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]<br />
* http://blog.gegg.us/2013/03/4-different-methods-of-1-wire-access-on-raspberry-pi/<br />
<br />
===Compiling own kernel===<br />
<br />
* Some hints on cross-compiling:<br />
:* http://elinux.org/RPi_Kernel_Compilation<br />
:* https://github.com/raspberrypi/linux/tree/rpi-3.12.y/arch/arm/mach-bcm2708<br />
:* https://github.com/notro/rpi-source/wiki<br />
:* https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489&start=75<br />
:* http://www.bootc.net/projects/raspberry-pi-kernel/<br />
:* http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-recompile.html<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-cross-compile.html<br />
:* http://www.gtkdb.de/index_36_2087.html<br />
<br />
* extract kernel config from image:<br />
::<code>scripts/extract-ikconfig kernel-image</code><br />
::(extract-ikconfig is part of the kernel sources)<br />
<br />
===Device Trees===<br />
<br />
:* http://www.raspberrypi.org/documentation/configuration/device-tree.md<br />
:* https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt<br />
<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=97216<br />
:* http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f<br />
:* http://www.forum-raspberrypi.de/Thread-tutorial-geraetetreiber-und-device-tree-dt (German)<br />
<br />
:* http://xillybus.com/tutorials/device-tree-zynq-1<br />
<br />
===What about updates?===<br />
<br />
As I always forget this<br />
* <code>apt-get update</code> - update package lists<br />
* <code>apt-get upgrade</code> - upgrade installed packages<br />
* <code>rpi-update</code> - update kernel and modules<br />
::use <code>SKIP_KERNEL=1 rpi-update</code> to update the RPi firmware, but keep the current kernel<br />
::set <code>SKIP_REPODELETE=1</code> to keep downloaded files (by default: <code>/root/.rpi-firmware</code>)<br />
<br />
Kernel Sources<br />
* https://github.com/notro/rpi-source gets the source data from https://github.com/Hexxeh/rpi-firmware and https://github.com/raspberrypi/linux/<br />
<br />
===Hints for reading Kernel Panics===<br />
<br />
* http://ptgmedia.pearsoncmg.com/images/013147751X/downloads/013147751X_book.pdf<br />
: p290:<br />
export CONFIG_DEBUG_INFO=1<br />
make kernel/sysctl.o<br />
objdump -d -S kernel/sysctl.o > kernel/sysctl.dump<br />
<br />
* http://www.opensourceforu.com/2011/01/understanding-a-kernel-oops/<br />
<br />
* http://www.lowlevel.eu/wiki/ARM-OS-Dev_Teil_2_%E2%80%93_Assembler_101<br />
<br />
==Attaching a LCD display (HD44780 controller)==<br />
<br />
===Wiring and Specs===<br />
<br />
* Specs ftp://imall.iteadstudio.com/IM120424018_EONE_2004_Characters_LCD/SPE_IM120424018_EONE_2004_Characters_LCD.pdf<br />
<br />
* http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display (German)<br />
<br />
* http://www.pro-linux.de/artikel/2/1624/5,die-anzeige-hardware-und-software.html<br />
<br />
* https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring<br />
<br />
* https://github.com/perryflynn/raspberrypi-misc/tree/master/charlcd_4x20_cmd<br />
<br />
* http://obrazki.elektroda.pl/5028699400_1384164963.jpg<br />
<br />
===Misc===<br />
<br />
* http://www.makerspaceuk.com/lcd-temp-sensor/<br />
<br />
* http://anwendungsentwickler.ws/blog/kategorien/raspberry-pi/4x20-lcd-screen-mit-dem-raspberry-pi.html (German)<br />
<br />
==Controlling the display==<br />
<br />
* Python [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO]<br />
<br />
===LCDProc hints===<br />
<br />
* Pi & GPIO powered HD44780 LCD: http://www.boeeerb.co.uk/pi-lcd/<br />
<br />
* https://metacpan.org/pod/Net::LCDproc<br />
<br />
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=63412<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-user.html<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-dev.html<br />
<br />
* http://tuxgraphics.org/electronics/200504/article375.shtml<br />
<br />
==Todo and Miscellaneous==<br />
<br />
<br />
===Collection of stuff to check - things I might) try sometime===<br />
<br />
* http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/<br />
<br />
* [http://en.wikipedia.org/wiki/F2FS f2fs]<br />
:* [http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=65330 F2fs, Ext4, FAT USB Benchmark]<br />
:* [http://forum.xda-developers.com/showthread.php?t=2697069 File System Performance: F2FS vs EXT4]<br />
<br />
* https://github.com/yuraa/Raspberry-Pi-Heartbeat<br />
<br />
* http://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html<br />
<br />
* [http://www.raspberrypi.org/archives/5282 Mathematica on Raspberry Pi, for free]<br />
:* also works in RasPi emulator, e.g. http://www.heise.de/ct/inhalt/2014/7/160/ (German, teaser to article)<br />
<br />
* NAS/Samba<br />
:* 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:<br />
:<code>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536</code><br />
<br />
* http://linuxtortures.blogspot.fr/2012/06/cross-compiling-and-cross-debugging-c.html<br />
<br />
===Things done===<br />
<br />
* Adjust swap file (size, location -> (ext4) HDD - too slow?): http://manpages.ubuntu.com/manpages/hardy/man8/dphys-swapfile.8.html<br />
<br />
* http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/<br />
<br />
==Some links (aka bookmark lists)==<br />
<br />
Project sites<br />
<br />
* [http://www.cl.cam.ac.uk/projects/raspberrypi/ University of Cambridge / Raspberry Pi Computer Laboratory]<br />
* [https://www.raspiprojekt.de/ raspiprojek] (German)<br />
* http://www.vanheusden.com/misc/rpi.php<br />
<br />
Blogs, forums, etc<br />
* http://www.raspberrypi.org/phpBB3/<br />
* [http://forum.stmlabs.com/forumdisplay.php?fid=6 Stm Labs Forum / Raspbmc]<br />
* [http://www.welzels.de/blog/projekte/raspberry-pi/ Wel!s Blog] (German)<br />
* [http://jankarres.de/category/raspberry-pi/ Raspberry Pi Blog of Jan Karres] (German)<br />
* http://www.forum-raspberrypi.de/ /(German)<br />
* http://raspberrycenter.de/ (German)<br />
* http://archlinuxarm.org/forum/viewforum.php?f=31&sid=57987232ca9177c35eb3ef7fdf6b3341<br />
<br />
* [[wikipedia:Raspberry_Pi Raspberry Pi in Wikipedia]]<br />
<br />
Miscellaneous<br />
<br />
* [http://www.raspberrypi.org/downloads New Out Of Box Software (Recommended)]<br />
* [http://elinux.org/R-Pi_Hub R-Pi_Hub]<br />
<br />
Manuals<br />
<br />
* https://github.com/raspberrypi/documentation<br />
<br />
* [http://debian-handbook.info/browse/stable/ The Debian Administrator's Handbook]</div>Holyheadhttps://holyhead.de/index.php?title=Raspberry_PiRaspberry Pi2015-02-11T22:29:00Z<p>Holyhead: /* Reading Kernel Panics */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
===External USB drives===<br />
<br />
* Automount USB-Drives in Raspbian<br />
** One may use [http://selfprogramming.bplaced.net/index.php/2012/10/23/automount-usb-drives-in-raspbian/ USBmount and autofs]<br />
** I prefer [http://ignorantguru.github.io/udevil/ udevil], see below<br />
<br />
* Install ''ntfs-3g'' if you need write access to ntfs file systems<br />
<br />
* How to increase performance?<br />
** Mount with option ''''noatime'''' or ''''relatime''''<br />
** Mount ''without'' option sync (e.g. keep default async)<br />
** If using ntfs-3g (fuse) file system, try mounting with option 'big_writes', see for example http://obihoernchen.net/wordpress/tag/big_writes/<br />
<br />
===[http://ignorantguru.github.io/udevil/ udevil]===<br />
<br />
* example for manual mounting:<br />
<br />
udevil mount /dev/sda1<br />
<br />
* auto-mounting via udev-rule, see for example http://lsdlinux.org/wiki/doku.php?id=auto_mounting#using_udev_rule (I just copied the 95-udevil-mount.rules file from an OpenElec installation (http://www.raspberrypi.org/downloads) )<br />
<br />
* my build-steps (maybe there's a simpler way, but this worked...):<br />
** download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget<br />
** extract deb-package via <code>ar vx udevil_0.4.3-1_all.deb</code><br />
** extract data archive <code>tar xzvf data.tar.gz</code><br />
** change to tar usr/share/devil/src<br />
** untar <code>tar xvfJ udevil-current.tar.xz</code><br />
** <code>cd udevil-0.4.3</code><br />
** <code>mv distros/debian</code><br />
** execute <code>dpkg-buildpackage</code><br />
** 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<br />
** Install via <code>sudo dpkg -i udevil_0.4.3-1_armhf.deb</code><br />
<br />
===Samba server / NAS===<br />
<br />
* How to install?<br />
** [http://jankarres.de/2013/11/raspberry-pi-samba-server-installieren/ | Raspberry Pi: Samba Server installieren] (German)<br />
** [http://www.welzels.de/blog/projekte/raspberry-pi/low-budget-nas-mit-einem-raspberry-pi/ Low Budget NAS mit einem Raspberry PI] (German)<br />
<br />
* Slow disc performance?<br />
** see 'Slow USB drives' above<br />
** 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!)<br />
<br />
* Configuration and tuning<br />
** https://calomel.org/samba.html<br />
** https://calomel.org/samba_optimize.html<br />
<br />
* If your /var/log/samba/log.smbd fills up with ''printing/print_cups.c:110(cups_connect) Unable to connect to CUPS server localhost'' messages, try http://www.sotechdesign.com.au/samba-log-showing-error-failed-to-retrieve-printer-list/<br/>I also created an empty <code>/etc/printcap</code> to avoid ''Unable to open printcap file /etc/printcap for read'' messages.<br />
<br />
* I don't need sound:<br />
<br />
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf <br />
# I don't need sound<br />
blacklist snd<br />
blacklist snd_pcm<br />
blacklist snd_soc_core<br />
blacklist snd_soc_bcm2708_i2s<br />
<br />
===Trying to reduce number of disk writes (SD card)===<br />
<br />
I'm using [http://oss.oetiker.ch/rrdtool/ 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).<br />
<br />
Here's what I've done:<br />
<br />
* Edit <code>/etc/default/cron</code> and set <code>EXTRA_OPTS="-L 0"</code> to disable logging (I don't need these)<br />
* Avoid entries like <code>pam_unix(cron:session): session closed for user pi</code> in <code>/var/log/auth.log</code><br />
** Edit <code>/etc/pam.d/cron</code> and comment the line <code>@include common-session-noninteractive</code> ([http://ubuntuforums.org/showthread.php?t=1256801])<br />
:or<br />
:* Edit <code>/etc/pam.d/common-session-noninteractive</code> as shown here: http://ubuntuforums.org/showthread.php?t=1256801&p=10283830#post10283830<br />
* I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)<br />
** moved all the .rrd files as well as the created images to my persistent-ramdisk location<br />
** moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links<br />
*** <code>/var/spool</code><br />
*** <code>/var/log</code><br />
*** <code>/var/cache/samba</code><br />
** edited <code>/etc/insserv.conf</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:<br />
<br />
$local_fs_orig +mountall +mountall-bootclean +mountoverflowtmp +umountfs<br />
# we need the sym-link data in /var/log and /var/spool to be available<br />
$local_fs $local_fs_orig +persist-ramdisk<br />
<br />
:: <code>/etc/init.d/persist-ramdisk</code> 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.<br />
<br />
:* set ''RAMTMP'' to yes in <code>/etc/default/tmpfs</code> to get tempfs based <code>/tmp</code><br />
<br />
Before changing <code>/tmp</code>:<br />
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').<br />
::I need to do more digging...<br />
<br />
After changing <code>/tmp</code>:<br />
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...<br />
<br />
===Useful stuff and Q&A===<br />
<br />
* Q: Why does my Pi restart when hotplugging a USB drive?<br />
** http://thestuffsido.blogspot.de/2013/05/fixing-raspberry-pi-hotplugging.html<br />
** http://therandomlab.blogspot.de/2013/01/raspberry-pi-mod-to-avoid-shutdown-on.html<br />
<br />
* Q: Does Raspberry support WOL?<br />
: A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)<br />
<br />
* Q: The new password is to short, or too simple<br />
: A: Try adjusting the PAM settings in <code>/etc/pam.d/common-password</code>:<br />
:* remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)<br />
::<code>password [success=1 default=ignore] pam_unix.so sha512 minlen=2</code><br />
<br />
::!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!<br><br />
::But it's nice for testing (if you cannot or do not want to use auto-login.)<br />
<br />
* Q: How to configure static IP?<br />
: A: In /etc/network/interfaces:<br />
::<code>iface eth0 inet static<br>address 192.168.0.31<br>netmask 255.255.255.0<br>gateway 192.168.0.1</code><br />
<br />
* Q: How to read core temperature, etc?<br />
: A: [http://elinux.org/RPI_vcgencmd_usage vcgencmd]:<br />
::<code>vcgencmd measure_temp<br>vcgencmd measure_clock arm</code><br />
<br />
* External USB HDD spin down<br />
** hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)<br />
** hd-idle works:<br />
::<code>hd-idle -a sda -i 600</code><br />
:: for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)<br />
<br />
* Q: How to avoid update of a certain package?<br />
: A: Put package on hold ([http://debiananwenderhandbuch.de/dpkg.html] (German)):<br />
::<code>echo <packagename> "hold" | dpkg --set-selections</code><br />
<br />
* [[wikipedia:Raspcontrol]] with nginx<br />
** http://www.foxplex.com/sites/raspcontrol-webinterface-auf-dem-raspberry-pi/ (German), http://www.foxplex.com/sites/performanter-nginx-webserver-auf-dem-raspberry-pi-mit-php-und-apc/ (German)<br />
** http://menzerath.eu/artikel/raspberry-pi-raspcontrol-installation-funktionen/ (German)<br />
<br />
* Q: How many bytes are written to my (SD) disc?<br />
: A: Use <code>iostat</code> http://www.mybinarylife.net/2012/08/linux-iostat-command.html<br />
: A: Use <code>iotop</code> http://guichaz.free.fr/iotop/<br />
: A: Raw data of the kernel can be found in files <code>/proc/diskstats</code> and <code>/sys/block/DEVNAME/stat</code> https://www.kernel.org/doc/Documentation/iostats.txt<br />
:* http://unix.stackexchange.com/questions/86391/how-to-get-total-number-of-bytes-sectors-blocks-written-to-disk-since-booting<br />
:* http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux<br />
<br />
* Q: How to reduce number of ext-fs checks?<br />
: A: <code>tune2fs -c 60 /dev/sda1</code> Change maximum mount count to 60<br />
: A: <code>tune2fs -i 12m /dev/sda1</code> Change check interval to 12 months<br />
: fore more details: http://wiki.ubuntuusers.de/Dateisystemcheck (German)<br />
<br />
===Overclocking===<br />
<br />
* I only set overclocking via <code>raspi-config</code><br />
<br />
* ''Turbo'': (Short) Raspberry stress test were ok. But I got an SD card error/corruption when doing a download and a dd-image of the SD card (according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907 the SD card error could be OC related.)<br />
::Luckily, I could recover all my data, see below.<br />
<br />
* '' Medium'': Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907] and its links).<br />
<br />
* Underclocking to 600 MHz<br />
:<code>echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</code><br />
: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.<br />
<br />
* Adjusting the ondemand-governor<br />
** https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt<br />
** set <code>/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor</code> to 10 [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&start=800]<br />
**: I had hoped this reduces the 1-wire CRC errors/device-disconnects problems, but with heavy (IO-) load (e.g. backup), 1wire sensors still get disconnected.<br />
<br />
* [http://moze.free.fr/blog/index.php?post/2013/02/Underclock-and-Overclock Nice power consumption analysis]<br />
<br />
====Stress test and benchmarks====<br />
<br />
* [http://www.roylongbottom.org.uk/ Roy Longbottom's PC Benchmark Collection]<br />
* [http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm Raspberry Pi Stress Tests]<br />
<br />
===SD card issues===<br />
<br />
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). I could still use this card for some time (see below), but finally I got a corrupted file system and could no longer repair it. That's when I re-installed Raspbian on a new SD card.<br />
<br />
Maybe I should try [http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ running from USB] sometime?<br />
<br />
====Recovery====<br />
* Creating a binary image of the SD card with my PC using [http://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] resulted in IO errors at about 17%.<br />
* 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 <code>dd conv=sync,noerror if=/dev/sdb2 of=rasp-image.img bs=1M</code> on my Linux machine (option <code>conv=noerror</code> ignores any errors, sync pads read-errors with zeros). The resulting image could not be mounted using a loop device. <br />
* Fortunately, <code>fsck.ext4 raspberry-image.bin</code> was able to repair the image, which I then could successfully mount on my Linux machine using <code>mount -o loop rasp-image.img /mnt</code>, and at a first glance, everything looked ok. So, I was at least able to get to my data. <br />
* On a later 'event', I dd-ed the repaired image back to the Raspberry, and could boot again.<br />
* On another a later 'event', I just fsck-ed the /dev/sdb2 using Linux, and could boot again... but I did not have luck this time - some files were gone.<br />
* 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.<br />
* My Raspberry successfully booted from this new image. I then used <code>raspi-config</code> to expand the root-fs (I've done this on my first installation as well). With Linux I was able to <code>dd</code> my repaired image to the repaired SD. The card booted as if nothing had happened...<br />
* But after some weeks, my Raspberry fried the SD card again, and some weeks later again ... And finally I could not get my pi to boot with this card. However, I can still read the data linux. Moving data to a new card... (easier said than done if the new card is slightly smaller... but, see below for resizing... and sometimes a fresh install is even less painful).<br />
<br />
===Reminders: dd, dd_rescue, losetup, mount and others===<br />
* Example partition table printed by fdisk:<br />
<code><br />
/dev/sdb: 7861 MB, 7861174272 bytes, 15353856 sectors<br />
Units = Sektoren of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
<br />
Gerät boot. Anfang Ende Blöcke Id System<br />
[...]<br />
/dev/sdb3 15288320 15353855 32768 83 Linux</code><br />
:Byte-offset of sdb3: 7827619840 = 15288320 * 512<br />
<br />
* Mount partition to /dev/loopN partition for repair, etc.<br />
:<code>losetup -o 7827619840 --find --show /dev/sdb</code><br />
:--show prints the used /dev/loopN device<br />
<br />
* Directly mount partition using loop device:<br />
:<code>mount -o loop,offset=7827619840 /dev/sdb /mnt</code><br />
* http://www.garloff.de/kurt/linux/ddrescue/<br />
* http://softwarebakery.com/shrinking-images-on-linux<br />
* http://www.tehfear.com/2007/10/08/resize-loop-disk-image/<br />
* http://wiki.ubuntuusers.de/dd (German)<br />
* http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device<br />
<br />
===Some 1-Wire Stuff===<br />
<br />
====Temperature Sensor DS1820====<br />
<br />
* How to?<br />
** http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/<br />
** https://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&start=1 (German)<br />
** http://kopfkino.irosaurus.com/tutorial-ds18s20-temperatur-sensor-an-einem-raspberry-pi/ (German)<br />
** http://raspberrywebserver.com/cgiscripting/rpi-temperature-logger/<br />
** http://elinux.org/RPi_Low-level_peripherals<br />
<br />
* I have two DS18B20 and log temperatures using rrdtool.<br />
<br />
* 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). <br />
** Q: Is this due to overclocking with using dynamic governor?<br />
** A: No - also occurs without overclocking (but less frequent?)<br />
** Q: Or is this due to voltage-problems?<br />
** A: No - also occurs without over-voltage<br />
** Q: Or something else?<br />
** 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). Using 3 sensors works almost all the time (without overclocking), but using 4 or more sensors (2 connected star topologies, very bad for 1-wire [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]), almost always fails to read values on most of the sensors.<br />
** A:'''Implement multiple 1-wire interfaces''' (see below), using 1 for each star-topology solved the problem. Reading 2x3 works perfect!<br />
<br />
====Multiple 1-wire buses====<br />
:* Inspired and guided by http://www.raspberrypi.org/forums/viewtopic.php?p=513312#p513312, I've patched my 3.12.y kernel <code>arch/arm/mach-bcm2708/bcm2708.c</code> (patch file http://holyhead.de/RaspberryPi/bcm2708-multiple_w-1.patch-3.12.21.txt).<br />
::* Note: With kernel version, device tree were introduced, see for example http://www.raspberrypi.org/documentation/configuration/device-tree.md<BR>But somehow 1-wire works for my 3.18.5+ without specifying any dtoverlays... And all tries to configure w1-gpio-overlay.dtb via config.txt resulted in my Raspberry not booting (I also tried a modified w1.dtb which should also handle my second w1-bus).<br />
:* I've cross-compiled the kernel on a linux-VM, using the instructions of http://elinux.org/RPi_Kernel_Compilation (compiling on the RaspberryPi takes 6 hours [http://wiki.gentoo.org/wiki/Raspberry_Pi_Kernel_Compilation] or much more [http://elinux.org/RPi_Kernel_Compilation]).<br />
<br />
====Some 1-wire internals====<br />
* https://www.kernel.org/doc/Documentation/w1/w1.generic<br />
* [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]<br />
* http://blog.gegg.us/2013/03/4-different-methods-of-1-wire-access-on-raspberry-pi/<br />
<br />
===Compiling own kernel===<br />
<br />
* Some hints on cross-compiling:<br />
:* http://elinux.org/RPi_Kernel_Compilation<br />
:* https://github.com/raspberrypi/linux/tree/rpi-3.12.y/arch/arm/mach-bcm2708<br />
:* https://github.com/notro/rpi-source/wiki<br />
:* https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489&start=75<br />
:* http://www.bootc.net/projects/raspberry-pi-kernel/<br />
:* http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-recompile.html<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-cross-compile.html<br />
:* http://www.gtkdb.de/index_36_2087.html<br />
<br />
* extract kernel config from image:<br />
::<code>scripts/extract-ikconfig kernel-image</code><br />
::(extract-ikconfig is part of the kernel sources)<br />
<br />
===Device Trees===<br />
<br />
:* http://www.raspberrypi.org/documentation/configuration/device-tree.md<br />
:* https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt<br />
<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=97216<br />
:* http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f<br />
:* http://www.forum-raspberrypi.de/Thread-tutorial-geraetetreiber-und-device-tree-dt (German)<br />
<br />
:* http://xillybus.com/tutorials/device-tree-zynq-1<br />
<br />
===What about updates?===<br />
<br />
As I always forget this<br />
* <code>apt-get update</code> - update package lists<br />
* <code>apt-get upgrade</code> - upgrade installed packages<br />
* <code>rpi-update</code> - update kernel and modules<br />
::use <code>SKIP_KERNEL=1 rpi-update</code> to update the RPi firmware, but keep the current kernel<br />
::set <code>SKIP_REPODELETE=1</code> to keep downloaded files (by default: <code>/root/.rpi-firmware</code>)<br />
<br />
Kernel Sources<br />
* https://github.com/notro/rpi-source gets the source data from https://github.com/Hexxeh/rpi-firmware and https://github.com/raspberrypi/linux/<br />
<br />
===Hints for reading Kernel Panics===<br />
<br />
* http://ptgmedia.pearsoncmg.com/images/013147751X/downloads/013147751X_book.pdf<br />
: p290:<br />
export CONFIG_DEBUG_INFO=1<br />
make kernel/sysctl.o<br />
objdump -d -S kernel/sysctl.o > kernel/sysctl.dump<br />
<br />
* http://www.opensourceforu.com/2011/01/understanding-a-kernel-oops/<br />
<br />
* http://www.lowlevel.eu/wiki/ARM-OS-Dev_Teil_2_%E2%80%93_Assembler_101<br />
<br />
==Attaching a LCD display==<br />
<br />
===Wiring and Specs===<br />
<br />
* Specs ftp://imall.iteadstudio.com/IM120424018_EONE_2004_Characters_LCD/SPE_IM120424018_EONE_2004_Characters_LCD.pdf<br />
<br />
* http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display (German)<br />
<br />
* http://www.pro-linux.de/artikel/2/1624/5,die-anzeige-hardware-und-software.html<br />
<br />
* https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring<br />
<br />
* https://github.com/perryflynn/raspberrypi-misc/tree/master/charlcd_4x20_cmd<br />
<br />
* http://obrazki.elektroda.pl/5028699400_1384164963.jpg<br />
<br />
===Misc===<br />
<br />
* http://www.makerspaceuk.com/lcd-temp-sensor/<br />
<br />
* http://anwendungsentwickler.ws/blog/kategorien/raspberry-pi/4x20-lcd-screen-mit-dem-raspberry-pi.html (German)<br />
<br />
==Controlling the display==<br />
<br />
* Python [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO]<br />
<br />
===LCDProc hints===<br />
<br />
* Pi & GPIO powered HD44780 LCD: http://www.boeeerb.co.uk/pi-lcd/<br />
<br />
* https://metacpan.org/pod/Net::LCDproc<br />
<br />
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=63412<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-user.html<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-dev.html<br />
<br />
* http://tuxgraphics.org/electronics/200504/article375.shtml<br />
<br />
==Todo and Miscellaneous==<br />
<br />
<br />
===Collection of stuff to check - things I might) try sometime===<br />
<br />
* http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/<br />
<br />
* [http://en.wikipedia.org/wiki/F2FS f2fs]<br />
:* [http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=65330 F2fs, Ext4, FAT USB Benchmark]<br />
:* [http://forum.xda-developers.com/showthread.php?t=2697069 File System Performance: F2FS vs EXT4]<br />
<br />
* https://github.com/yuraa/Raspberry-Pi-Heartbeat<br />
<br />
* http://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html<br />
<br />
* [http://www.raspberrypi.org/archives/5282 Mathematica on Raspberry Pi, for free]<br />
:* also works in RasPi emulator, e.g. http://www.heise.de/ct/inhalt/2014/7/160/ (German, teaser to article)<br />
<br />
* NAS/Samba<br />
:* 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:<br />
:<code>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536</code><br />
<br />
* http://linuxtortures.blogspot.fr/2012/06/cross-compiling-and-cross-debugging-c.html<br />
<br />
===Things done===<br />
<br />
* Adjust swap file (size, location -> (ext4) HDD - too slow?): http://manpages.ubuntu.com/manpages/hardy/man8/dphys-swapfile.8.html<br />
<br />
* http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/<br />
<br />
==Some links (aka bookmark lists)==<br />
<br />
Project sites<br />
<br />
* [http://www.cl.cam.ac.uk/projects/raspberrypi/ University of Cambridge / Raspberry Pi Computer Laboratory]<br />
* [https://www.raspiprojekt.de/ raspiprojek] (German)<br />
* http://www.vanheusden.com/misc/rpi.php<br />
<br />
Blogs, forums, etc<br />
* http://www.raspberrypi.org/phpBB3/<br />
* [http://forum.stmlabs.com/forumdisplay.php?fid=6 Stm Labs Forum / Raspbmc]<br />
* [http://www.welzels.de/blog/projekte/raspberry-pi/ Wel!s Blog] (German)<br />
* [http://jankarres.de/category/raspberry-pi/ Raspberry Pi Blog of Jan Karres] (German)<br />
* http://www.forum-raspberrypi.de/ /(German)<br />
* http://raspberrycenter.de/ (German)<br />
* http://archlinuxarm.org/forum/viewforum.php?f=31&sid=57987232ca9177c35eb3ef7fdf6b3341<br />
<br />
* [[wikipedia:Raspberry_Pi Raspberry Pi in Wikipedia]]<br />
<br />
Miscellaneous<br />
<br />
* [http://www.raspberrypi.org/downloads New Out Of Box Software (Recommended)]<br />
* [http://elinux.org/R-Pi_Hub R-Pi_Hub]<br />
<br />
Manuals<br />
<br />
* https://github.com/raspberrypi/documentation<br />
<br />
* [http://debian-handbook.info/browse/stable/ The Debian Administrator's Handbook]</div>Holyheadhttps://holyhead.de/index.php?title=Raspberry_PiRaspberry Pi2015-02-11T22:28:47Z<p>Holyhead: /* Kernel Panics */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
===External USB drives===<br />
<br />
* Automount USB-Drives in Raspbian<br />
** One may use [http://selfprogramming.bplaced.net/index.php/2012/10/23/automount-usb-drives-in-raspbian/ USBmount and autofs]<br />
** I prefer [http://ignorantguru.github.io/udevil/ udevil], see below<br />
<br />
* Install ''ntfs-3g'' if you need write access to ntfs file systems<br />
<br />
* How to increase performance?<br />
** Mount with option ''''noatime'''' or ''''relatime''''<br />
** Mount ''without'' option sync (e.g. keep default async)<br />
** If using ntfs-3g (fuse) file system, try mounting with option 'big_writes', see for example http://obihoernchen.net/wordpress/tag/big_writes/<br />
<br />
===[http://ignorantguru.github.io/udevil/ udevil]===<br />
<br />
* example for manual mounting:<br />
<br />
udevil mount /dev/sda1<br />
<br />
* auto-mounting via udev-rule, see for example http://lsdlinux.org/wiki/doku.php?id=auto_mounting#using_udev_rule (I just copied the 95-udevil-mount.rules file from an OpenElec installation (http://www.raspberrypi.org/downloads) )<br />
<br />
* my build-steps (maybe there's a simpler way, but this worked...):<br />
** download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget<br />
** extract deb-package via <code>ar vx udevil_0.4.3-1_all.deb</code><br />
** extract data archive <code>tar xzvf data.tar.gz</code><br />
** change to tar usr/share/devil/src<br />
** untar <code>tar xvfJ udevil-current.tar.xz</code><br />
** <code>cd udevil-0.4.3</code><br />
** <code>mv distros/debian</code><br />
** execute <code>dpkg-buildpackage</code><br />
** 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<br />
** Install via <code>sudo dpkg -i udevil_0.4.3-1_armhf.deb</code><br />
<br />
===Samba server / NAS===<br />
<br />
* How to install?<br />
** [http://jankarres.de/2013/11/raspberry-pi-samba-server-installieren/ | Raspberry Pi: Samba Server installieren] (German)<br />
** [http://www.welzels.de/blog/projekte/raspberry-pi/low-budget-nas-mit-einem-raspberry-pi/ Low Budget NAS mit einem Raspberry PI] (German)<br />
<br />
* Slow disc performance?<br />
** see 'Slow USB drives' above<br />
** 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!)<br />
<br />
* Configuration and tuning<br />
** https://calomel.org/samba.html<br />
** https://calomel.org/samba_optimize.html<br />
<br />
* If your /var/log/samba/log.smbd fills up with ''printing/print_cups.c:110(cups_connect) Unable to connect to CUPS server localhost'' messages, try http://www.sotechdesign.com.au/samba-log-showing-error-failed-to-retrieve-printer-list/<br/>I also created an empty <code>/etc/printcap</code> to avoid ''Unable to open printcap file /etc/printcap for read'' messages.<br />
<br />
* I don't need sound:<br />
<br />
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf <br />
# I don't need sound<br />
blacklist snd<br />
blacklist snd_pcm<br />
blacklist snd_soc_core<br />
blacklist snd_soc_bcm2708_i2s<br />
<br />
===Trying to reduce number of disk writes (SD card)===<br />
<br />
I'm using [http://oss.oetiker.ch/rrdtool/ 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).<br />
<br />
Here's what I've done:<br />
<br />
* Edit <code>/etc/default/cron</code> and set <code>EXTRA_OPTS="-L 0"</code> to disable logging (I don't need these)<br />
* Avoid entries like <code>pam_unix(cron:session): session closed for user pi</code> in <code>/var/log/auth.log</code><br />
** Edit <code>/etc/pam.d/cron</code> and comment the line <code>@include common-session-noninteractive</code> ([http://ubuntuforums.org/showthread.php?t=1256801])<br />
:or<br />
:* Edit <code>/etc/pam.d/common-session-noninteractive</code> as shown here: http://ubuntuforums.org/showthread.php?t=1256801&p=10283830#post10283830<br />
* I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)<br />
** moved all the .rrd files as well as the created images to my persistent-ramdisk location<br />
** moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links<br />
*** <code>/var/spool</code><br />
*** <code>/var/log</code><br />
*** <code>/var/cache/samba</code><br />
** edited <code>/etc/insserv.conf</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:<br />
<br />
$local_fs_orig +mountall +mountall-bootclean +mountoverflowtmp +umountfs<br />
# we need the sym-link data in /var/log and /var/spool to be available<br />
$local_fs $local_fs_orig +persist-ramdisk<br />
<br />
:: <code>/etc/init.d/persist-ramdisk</code> 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.<br />
<br />
:* set ''RAMTMP'' to yes in <code>/etc/default/tmpfs</code> to get tempfs based <code>/tmp</code><br />
<br />
Before changing <code>/tmp</code>:<br />
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').<br />
::I need to do more digging...<br />
<br />
After changing <code>/tmp</code>:<br />
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...<br />
<br />
===Useful stuff and Q&A===<br />
<br />
* Q: Why does my Pi restart when hotplugging a USB drive?<br />
** http://thestuffsido.blogspot.de/2013/05/fixing-raspberry-pi-hotplugging.html<br />
** http://therandomlab.blogspot.de/2013/01/raspberry-pi-mod-to-avoid-shutdown-on.html<br />
<br />
* Q: Does Raspberry support WOL?<br />
: A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)<br />
<br />
* Q: The new password is to short, or too simple<br />
: A: Try adjusting the PAM settings in <code>/etc/pam.d/common-password</code>:<br />
:* remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)<br />
::<code>password [success=1 default=ignore] pam_unix.so sha512 minlen=2</code><br />
<br />
::!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!<br><br />
::But it's nice for testing (if you cannot or do not want to use auto-login.)<br />
<br />
* Q: How to configure static IP?<br />
: A: In /etc/network/interfaces:<br />
::<code>iface eth0 inet static<br>address 192.168.0.31<br>netmask 255.255.255.0<br>gateway 192.168.0.1</code><br />
<br />
* Q: How to read core temperature, etc?<br />
: A: [http://elinux.org/RPI_vcgencmd_usage vcgencmd]:<br />
::<code>vcgencmd measure_temp<br>vcgencmd measure_clock arm</code><br />
<br />
* External USB HDD spin down<br />
** hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)<br />
** hd-idle works:<br />
::<code>hd-idle -a sda -i 600</code><br />
:: for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)<br />
<br />
* Q: How to avoid update of a certain package?<br />
: A: Put package on hold ([http://debiananwenderhandbuch.de/dpkg.html] (German)):<br />
::<code>echo <packagename> "hold" | dpkg --set-selections</code><br />
<br />
* [[wikipedia:Raspcontrol]] with nginx<br />
** http://www.foxplex.com/sites/raspcontrol-webinterface-auf-dem-raspberry-pi/ (German), http://www.foxplex.com/sites/performanter-nginx-webserver-auf-dem-raspberry-pi-mit-php-und-apc/ (German)<br />
** http://menzerath.eu/artikel/raspberry-pi-raspcontrol-installation-funktionen/ (German)<br />
<br />
* Q: How many bytes are written to my (SD) disc?<br />
: A: Use <code>iostat</code> http://www.mybinarylife.net/2012/08/linux-iostat-command.html<br />
: A: Use <code>iotop</code> http://guichaz.free.fr/iotop/<br />
: A: Raw data of the kernel can be found in files <code>/proc/diskstats</code> and <code>/sys/block/DEVNAME/stat</code> https://www.kernel.org/doc/Documentation/iostats.txt<br />
:* http://unix.stackexchange.com/questions/86391/how-to-get-total-number-of-bytes-sectors-blocks-written-to-disk-since-booting<br />
:* http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux<br />
<br />
* Q: How to reduce number of ext-fs checks?<br />
: A: <code>tune2fs -c 60 /dev/sda1</code> Change maximum mount count to 60<br />
: A: <code>tune2fs -i 12m /dev/sda1</code> Change check interval to 12 months<br />
: fore more details: http://wiki.ubuntuusers.de/Dateisystemcheck (German)<br />
<br />
===Overclocking===<br />
<br />
* I only set overclocking via <code>raspi-config</code><br />
<br />
* ''Turbo'': (Short) Raspberry stress test were ok. But I got an SD card error/corruption when doing a download and a dd-image of the SD card (according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907 the SD card error could be OC related.)<br />
::Luckily, I could recover all my data, see below.<br />
<br />
* '' Medium'': Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907] and its links).<br />
<br />
* Underclocking to 600 MHz<br />
:<code>echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</code><br />
: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.<br />
<br />
* Adjusting the ondemand-governor<br />
** https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt<br />
** set <code>/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor</code> to 10 [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&start=800]<br />
**: I had hoped this reduces the 1-wire CRC errors/device-disconnects problems, but with heavy (IO-) load (e.g. backup), 1wire sensors still get disconnected.<br />
<br />
* [http://moze.free.fr/blog/index.php?post/2013/02/Underclock-and-Overclock Nice power consumption analysis]<br />
<br />
====Stress test and benchmarks====<br />
<br />
* [http://www.roylongbottom.org.uk/ Roy Longbottom's PC Benchmark Collection]<br />
* [http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm Raspberry Pi Stress Tests]<br />
<br />
===SD card issues===<br />
<br />
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). I could still use this card for some time (see below), but finally I got a corrupted file system and could no longer repair it. That's when I re-installed Raspbian on a new SD card.<br />
<br />
Maybe I should try [http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ running from USB] sometime?<br />
<br />
====Recovery====<br />
* Creating a binary image of the SD card with my PC using [http://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] resulted in IO errors at about 17%.<br />
* 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 <code>dd conv=sync,noerror if=/dev/sdb2 of=rasp-image.img bs=1M</code> on my Linux machine (option <code>conv=noerror</code> ignores any errors, sync pads read-errors with zeros). The resulting image could not be mounted using a loop device. <br />
* Fortunately, <code>fsck.ext4 raspberry-image.bin</code> was able to repair the image, which I then could successfully mount on my Linux machine using <code>mount -o loop rasp-image.img /mnt</code>, and at a first glance, everything looked ok. So, I was at least able to get to my data. <br />
* On a later 'event', I dd-ed the repaired image back to the Raspberry, and could boot again.<br />
* On another a later 'event', I just fsck-ed the /dev/sdb2 using Linux, and could boot again... but I did not have luck this time - some files were gone.<br />
* 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.<br />
* My Raspberry successfully booted from this new image. I then used <code>raspi-config</code> to expand the root-fs (I've done this on my first installation as well). With Linux I was able to <code>dd</code> my repaired image to the repaired SD. The card booted as if nothing had happened...<br />
* But after some weeks, my Raspberry fried the SD card again, and some weeks later again ... And finally I could not get my pi to boot with this card. However, I can still read the data linux. Moving data to a new card... (easier said than done if the new card is slightly smaller... but, see below for resizing... and sometimes a fresh install is even less painful).<br />
<br />
===Reminders: dd, dd_rescue, losetup, mount and others===<br />
* Example partition table printed by fdisk:<br />
<code><br />
/dev/sdb: 7861 MB, 7861174272 bytes, 15353856 sectors<br />
Units = Sektoren of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
<br />
Gerät boot. Anfang Ende Blöcke Id System<br />
[...]<br />
/dev/sdb3 15288320 15353855 32768 83 Linux</code><br />
:Byte-offset of sdb3: 7827619840 = 15288320 * 512<br />
<br />
* Mount partition to /dev/loopN partition for repair, etc.<br />
:<code>losetup -o 7827619840 --find --show /dev/sdb</code><br />
:--show prints the used /dev/loopN device<br />
<br />
* Directly mount partition using loop device:<br />
:<code>mount -o loop,offset=7827619840 /dev/sdb /mnt</code><br />
* http://www.garloff.de/kurt/linux/ddrescue/<br />
* http://softwarebakery.com/shrinking-images-on-linux<br />
* http://www.tehfear.com/2007/10/08/resize-loop-disk-image/<br />
* http://wiki.ubuntuusers.de/dd (German)<br />
* http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device<br />
<br />
===Some 1-Wire Stuff===<br />
<br />
====Temperature Sensor DS1820====<br />
<br />
* How to?<br />
** http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/<br />
** https://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&start=1 (German)<br />
** http://kopfkino.irosaurus.com/tutorial-ds18s20-temperatur-sensor-an-einem-raspberry-pi/ (German)<br />
** http://raspberrywebserver.com/cgiscripting/rpi-temperature-logger/<br />
** http://elinux.org/RPi_Low-level_peripherals<br />
<br />
* I have two DS18B20 and log temperatures using rrdtool.<br />
<br />
* 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). <br />
** Q: Is this due to overclocking with using dynamic governor?<br />
** A: No - also occurs without overclocking (but less frequent?)<br />
** Q: Or is this due to voltage-problems?<br />
** A: No - also occurs without over-voltage<br />
** Q: Or something else?<br />
** 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). Using 3 sensors works almost all the time (without overclocking), but using 4 or more sensors (2 connected star topologies, very bad for 1-wire [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]), almost always fails to read values on most of the sensors.<br />
** A:'''Implement multiple 1-wire interfaces''' (see below), using 1 for each star-topology solved the problem. Reading 2x3 works perfect!<br />
<br />
====Multiple 1-wire buses====<br />
:* Inspired and guided by http://www.raspberrypi.org/forums/viewtopic.php?p=513312#p513312, I've patched my 3.12.y kernel <code>arch/arm/mach-bcm2708/bcm2708.c</code> (patch file http://holyhead.de/RaspberryPi/bcm2708-multiple_w-1.patch-3.12.21.txt).<br />
::* Note: With kernel version, device tree were introduced, see for example http://www.raspberrypi.org/documentation/configuration/device-tree.md<BR>But somehow 1-wire works for my 3.18.5+ without specifying any dtoverlays... And all tries to configure w1-gpio-overlay.dtb via config.txt resulted in my Raspberry not booting (I also tried a modified w1.dtb which should also handle my second w1-bus).<br />
:* I've cross-compiled the kernel on a linux-VM, using the instructions of http://elinux.org/RPi_Kernel_Compilation (compiling on the RaspberryPi takes 6 hours [http://wiki.gentoo.org/wiki/Raspberry_Pi_Kernel_Compilation] or much more [http://elinux.org/RPi_Kernel_Compilation]).<br />
<br />
====Some 1-wire internals====<br />
* https://www.kernel.org/doc/Documentation/w1/w1.generic<br />
* [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]<br />
* http://blog.gegg.us/2013/03/4-different-methods-of-1-wire-access-on-raspberry-pi/<br />
<br />
===Compiling own kernel===<br />
<br />
* Some hints on cross-compiling:<br />
:* http://elinux.org/RPi_Kernel_Compilation<br />
:* https://github.com/raspberrypi/linux/tree/rpi-3.12.y/arch/arm/mach-bcm2708<br />
:* https://github.com/notro/rpi-source/wiki<br />
:* https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489&start=75<br />
:* http://www.bootc.net/projects/raspberry-pi-kernel/<br />
:* http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-recompile.html<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-cross-compile.html<br />
:* http://www.gtkdb.de/index_36_2087.html<br />
<br />
* extract kernel config from image:<br />
::<code>scripts/extract-ikconfig kernel-image</code><br />
::(extract-ikconfig is part of the kernel sources)<br />
<br />
===Device Trees===<br />
<br />
:* http://www.raspberrypi.org/documentation/configuration/device-tree.md<br />
:* https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt<br />
<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=97216<br />
:* http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f<br />
:* http://www.forum-raspberrypi.de/Thread-tutorial-geraetetreiber-und-device-tree-dt (German)<br />
<br />
:* http://xillybus.com/tutorials/device-tree-zynq-1<br />
<br />
===What about updates?===<br />
<br />
As I always forget this<br />
* <code>apt-get update</code> - update package lists<br />
* <code>apt-get upgrade</code> - upgrade installed packages<br />
* <code>rpi-update</code> - update kernel and modules<br />
::use <code>SKIP_KERNEL=1 rpi-update</code> to update the RPi firmware, but keep the current kernel<br />
::set <code>SKIP_REPODELETE=1</code> to keep downloaded files (by default: <code>/root/.rpi-firmware</code>)<br />
<br />
Kernel Sources<br />
* https://github.com/notro/rpi-source gets the source data from https://github.com/Hexxeh/rpi-firmware and https://github.com/raspberrypi/linux/<br />
<br />
===Reading Kernel Panics===<br />
<br />
* http://ptgmedia.pearsoncmg.com/images/013147751X/downloads/013147751X_book.pdf<br />
: p290:<br />
export CONFIG_DEBUG_INFO=1<br />
make kernel/sysctl.o<br />
objdump -d -S kernel/sysctl.o > kernel/sysctl.dump<br />
<br />
* http://www.opensourceforu.com/2011/01/understanding-a-kernel-oops/<br />
<br />
* http://www.lowlevel.eu/wiki/ARM-OS-Dev_Teil_2_%E2%80%93_Assembler_101<br />
<br />
==Attaching a LCD display==<br />
<br />
===Wiring and Specs===<br />
<br />
* Specs ftp://imall.iteadstudio.com/IM120424018_EONE_2004_Characters_LCD/SPE_IM120424018_EONE_2004_Characters_LCD.pdf<br />
<br />
* http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display (German)<br />
<br />
* http://www.pro-linux.de/artikel/2/1624/5,die-anzeige-hardware-und-software.html<br />
<br />
* https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring<br />
<br />
* https://github.com/perryflynn/raspberrypi-misc/tree/master/charlcd_4x20_cmd<br />
<br />
* http://obrazki.elektroda.pl/5028699400_1384164963.jpg<br />
<br />
===Misc===<br />
<br />
* http://www.makerspaceuk.com/lcd-temp-sensor/<br />
<br />
* http://anwendungsentwickler.ws/blog/kategorien/raspberry-pi/4x20-lcd-screen-mit-dem-raspberry-pi.html (German)<br />
<br />
==Controlling the display==<br />
<br />
* Python [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO]<br />
<br />
===LCDProc hints===<br />
<br />
* Pi & GPIO powered HD44780 LCD: http://www.boeeerb.co.uk/pi-lcd/<br />
<br />
* https://metacpan.org/pod/Net::LCDproc<br />
<br />
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=63412<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-user.html<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-dev.html<br />
<br />
* http://tuxgraphics.org/electronics/200504/article375.shtml<br />
<br />
==Todo and Miscellaneous==<br />
<br />
<br />
===Collection of stuff to check - things I might) try sometime===<br />
<br />
* http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/<br />
<br />
* [http://en.wikipedia.org/wiki/F2FS f2fs]<br />
:* [http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=65330 F2fs, Ext4, FAT USB Benchmark]<br />
:* [http://forum.xda-developers.com/showthread.php?t=2697069 File System Performance: F2FS vs EXT4]<br />
<br />
* https://github.com/yuraa/Raspberry-Pi-Heartbeat<br />
<br />
* http://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html<br />
<br />
* [http://www.raspberrypi.org/archives/5282 Mathematica on Raspberry Pi, for free]<br />
:* also works in RasPi emulator, e.g. http://www.heise.de/ct/inhalt/2014/7/160/ (German, teaser to article)<br />
<br />
* NAS/Samba<br />
:* 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:<br />
:<code>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536</code><br />
<br />
* http://linuxtortures.blogspot.fr/2012/06/cross-compiling-and-cross-debugging-c.html<br />
<br />
===Things done===<br />
<br />
* Adjust swap file (size, location -> (ext4) HDD - too slow?): http://manpages.ubuntu.com/manpages/hardy/man8/dphys-swapfile.8.html<br />
<br />
* http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/<br />
<br />
==Some links (aka bookmark lists)==<br />
<br />
Project sites<br />
<br />
* [http://www.cl.cam.ac.uk/projects/raspberrypi/ University of Cambridge / Raspberry Pi Computer Laboratory]<br />
* [https://www.raspiprojekt.de/ raspiprojek] (German)<br />
* http://www.vanheusden.com/misc/rpi.php<br />
<br />
Blogs, forums, etc<br />
* http://www.raspberrypi.org/phpBB3/<br />
* [http://forum.stmlabs.com/forumdisplay.php?fid=6 Stm Labs Forum / Raspbmc]<br />
* [http://www.welzels.de/blog/projekte/raspberry-pi/ Wel!s Blog] (German)<br />
* [http://jankarres.de/category/raspberry-pi/ Raspberry Pi Blog of Jan Karres] (German)<br />
* http://www.forum-raspberrypi.de/ /(German)<br />
* http://raspberrycenter.de/ (German)<br />
* http://archlinuxarm.org/forum/viewforum.php?f=31&sid=57987232ca9177c35eb3ef7fdf6b3341<br />
<br />
* [[wikipedia:Raspberry_Pi Raspberry Pi in Wikipedia]]<br />
<br />
Miscellaneous<br />
<br />
* [http://www.raspberrypi.org/downloads New Out Of Box Software (Recommended)]<br />
* [http://elinux.org/R-Pi_Hub R-Pi_Hub]<br />
<br />
Manuals<br />
<br />
* https://github.com/raspberrypi/documentation<br />
<br />
* [http://debian-handbook.info/browse/stable/ The Debian Administrator's Handbook]</div>Holyheadhttps://holyhead.de/index.php?title=Raspberry_PiRaspberry Pi2015-02-11T22:27:50Z<p>Holyhead: /* Some links (aka bookmark lists) */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
===External USB drives===<br />
<br />
* Automount USB-Drives in Raspbian<br />
** One may use [http://selfprogramming.bplaced.net/index.php/2012/10/23/automount-usb-drives-in-raspbian/ USBmount and autofs]<br />
** I prefer [http://ignorantguru.github.io/udevil/ udevil], see below<br />
<br />
* Install ''ntfs-3g'' if you need write access to ntfs file systems<br />
<br />
* How to increase performance?<br />
** Mount with option ''''noatime'''' or ''''relatime''''<br />
** Mount ''without'' option sync (e.g. keep default async)<br />
** If using ntfs-3g (fuse) file system, try mounting with option 'big_writes', see for example http://obihoernchen.net/wordpress/tag/big_writes/<br />
<br />
===[http://ignorantguru.github.io/udevil/ udevil]===<br />
<br />
* example for manual mounting:<br />
<br />
udevil mount /dev/sda1<br />
<br />
* auto-mounting via udev-rule, see for example http://lsdlinux.org/wiki/doku.php?id=auto_mounting#using_udev_rule (I just copied the 95-udevil-mount.rules file from an OpenElec installation (http://www.raspberrypi.org/downloads) )<br />
<br />
* my build-steps (maybe there's a simpler way, but this worked...):<br />
** download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget<br />
** extract deb-package via <code>ar vx udevil_0.4.3-1_all.deb</code><br />
** extract data archive <code>tar xzvf data.tar.gz</code><br />
** change to tar usr/share/devil/src<br />
** untar <code>tar xvfJ udevil-current.tar.xz</code><br />
** <code>cd udevil-0.4.3</code><br />
** <code>mv distros/debian</code><br />
** execute <code>dpkg-buildpackage</code><br />
** 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<br />
** Install via <code>sudo dpkg -i udevil_0.4.3-1_armhf.deb</code><br />
<br />
===Samba server / NAS===<br />
<br />
* How to install?<br />
** [http://jankarres.de/2013/11/raspberry-pi-samba-server-installieren/ | Raspberry Pi: Samba Server installieren] (German)<br />
** [http://www.welzels.de/blog/projekte/raspberry-pi/low-budget-nas-mit-einem-raspberry-pi/ Low Budget NAS mit einem Raspberry PI] (German)<br />
<br />
* Slow disc performance?<br />
** see 'Slow USB drives' above<br />
** 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!)<br />
<br />
* Configuration and tuning<br />
** https://calomel.org/samba.html<br />
** https://calomel.org/samba_optimize.html<br />
<br />
* If your /var/log/samba/log.smbd fills up with ''printing/print_cups.c:110(cups_connect) Unable to connect to CUPS server localhost'' messages, try http://www.sotechdesign.com.au/samba-log-showing-error-failed-to-retrieve-printer-list/<br/>I also created an empty <code>/etc/printcap</code> to avoid ''Unable to open printcap file /etc/printcap for read'' messages.<br />
<br />
* I don't need sound:<br />
<br />
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf <br />
# I don't need sound<br />
blacklist snd<br />
blacklist snd_pcm<br />
blacklist snd_soc_core<br />
blacklist snd_soc_bcm2708_i2s<br />
<br />
===Trying to reduce number of disk writes (SD card)===<br />
<br />
I'm using [http://oss.oetiker.ch/rrdtool/ 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).<br />
<br />
Here's what I've done:<br />
<br />
* Edit <code>/etc/default/cron</code> and set <code>EXTRA_OPTS="-L 0"</code> to disable logging (I don't need these)<br />
* Avoid entries like <code>pam_unix(cron:session): session closed for user pi</code> in <code>/var/log/auth.log</code><br />
** Edit <code>/etc/pam.d/cron</code> and comment the line <code>@include common-session-noninteractive</code> ([http://ubuntuforums.org/showthread.php?t=1256801])<br />
:or<br />
:* Edit <code>/etc/pam.d/common-session-noninteractive</code> as shown here: http://ubuntuforums.org/showthread.php?t=1256801&p=10283830#post10283830<br />
* I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)<br />
** moved all the .rrd files as well as the created images to my persistent-ramdisk location<br />
** moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links<br />
*** <code>/var/spool</code><br />
*** <code>/var/log</code><br />
*** <code>/var/cache/samba</code><br />
** edited <code>/etc/insserv.conf</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:<br />
<br />
$local_fs_orig +mountall +mountall-bootclean +mountoverflowtmp +umountfs<br />
# we need the sym-link data in /var/log and /var/spool to be available<br />
$local_fs $local_fs_orig +persist-ramdisk<br />
<br />
:: <code>/etc/init.d/persist-ramdisk</code> 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.<br />
<br />
:* set ''RAMTMP'' to yes in <code>/etc/default/tmpfs</code> to get tempfs based <code>/tmp</code><br />
<br />
Before changing <code>/tmp</code>:<br />
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').<br />
::I need to do more digging...<br />
<br />
After changing <code>/tmp</code>:<br />
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...<br />
<br />
===Useful stuff and Q&A===<br />
<br />
* Q: Why does my Pi restart when hotplugging a USB drive?<br />
** http://thestuffsido.blogspot.de/2013/05/fixing-raspberry-pi-hotplugging.html<br />
** http://therandomlab.blogspot.de/2013/01/raspberry-pi-mod-to-avoid-shutdown-on.html<br />
<br />
* Q: Does Raspberry support WOL?<br />
: A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)<br />
<br />
* Q: The new password is to short, or too simple<br />
: A: Try adjusting the PAM settings in <code>/etc/pam.d/common-password</code>:<br />
:* remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)<br />
::<code>password [success=1 default=ignore] pam_unix.so sha512 minlen=2</code><br />
<br />
::!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!<br><br />
::But it's nice for testing (if you cannot or do not want to use auto-login.)<br />
<br />
* Q: How to configure static IP?<br />
: A: In /etc/network/interfaces:<br />
::<code>iface eth0 inet static<br>address 192.168.0.31<br>netmask 255.255.255.0<br>gateway 192.168.0.1</code><br />
<br />
* Q: How to read core temperature, etc?<br />
: A: [http://elinux.org/RPI_vcgencmd_usage vcgencmd]:<br />
::<code>vcgencmd measure_temp<br>vcgencmd measure_clock arm</code><br />
<br />
* External USB HDD spin down<br />
** hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)<br />
** hd-idle works:<br />
::<code>hd-idle -a sda -i 600</code><br />
:: for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)<br />
<br />
* Q: How to avoid update of a certain package?<br />
: A: Put package on hold ([http://debiananwenderhandbuch.de/dpkg.html] (German)):<br />
::<code>echo <packagename> "hold" | dpkg --set-selections</code><br />
<br />
* [[wikipedia:Raspcontrol]] with nginx<br />
** http://www.foxplex.com/sites/raspcontrol-webinterface-auf-dem-raspberry-pi/ (German), http://www.foxplex.com/sites/performanter-nginx-webserver-auf-dem-raspberry-pi-mit-php-und-apc/ (German)<br />
** http://menzerath.eu/artikel/raspberry-pi-raspcontrol-installation-funktionen/ (German)<br />
<br />
* Q: How many bytes are written to my (SD) disc?<br />
: A: Use <code>iostat</code> http://www.mybinarylife.net/2012/08/linux-iostat-command.html<br />
: A: Use <code>iotop</code> http://guichaz.free.fr/iotop/<br />
: A: Raw data of the kernel can be found in files <code>/proc/diskstats</code> and <code>/sys/block/DEVNAME/stat</code> https://www.kernel.org/doc/Documentation/iostats.txt<br />
:* http://unix.stackexchange.com/questions/86391/how-to-get-total-number-of-bytes-sectors-blocks-written-to-disk-since-booting<br />
:* http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux<br />
<br />
* Q: How to reduce number of ext-fs checks?<br />
: A: <code>tune2fs -c 60 /dev/sda1</code> Change maximum mount count to 60<br />
: A: <code>tune2fs -i 12m /dev/sda1</code> Change check interval to 12 months<br />
: fore more details: http://wiki.ubuntuusers.de/Dateisystemcheck (German)<br />
<br />
===Overclocking===<br />
<br />
* I only set overclocking via <code>raspi-config</code><br />
<br />
* ''Turbo'': (Short) Raspberry stress test were ok. But I got an SD card error/corruption when doing a download and a dd-image of the SD card (according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907 the SD card error could be OC related.)<br />
::Luckily, I could recover all my data, see below.<br />
<br />
* '' Medium'': Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907] and its links).<br />
<br />
* Underclocking to 600 MHz<br />
:<code>echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</code><br />
: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.<br />
<br />
* Adjusting the ondemand-governor<br />
** https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt<br />
** set <code>/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor</code> to 10 [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&start=800]<br />
**: I had hoped this reduces the 1-wire CRC errors/device-disconnects problems, but with heavy (IO-) load (e.g. backup), 1wire sensors still get disconnected.<br />
<br />
* [http://moze.free.fr/blog/index.php?post/2013/02/Underclock-and-Overclock Nice power consumption analysis]<br />
<br />
====Stress test and benchmarks====<br />
<br />
* [http://www.roylongbottom.org.uk/ Roy Longbottom's PC Benchmark Collection]<br />
* [http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm Raspberry Pi Stress Tests]<br />
<br />
===SD card issues===<br />
<br />
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). I could still use this card for some time (see below), but finally I got a corrupted file system and could no longer repair it. That's when I re-installed Raspbian on a new SD card.<br />
<br />
Maybe I should try [http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ running from USB] sometime?<br />
<br />
====Recovery====<br />
* Creating a binary image of the SD card with my PC using [http://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] resulted in IO errors at about 17%.<br />
* 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 <code>dd conv=sync,noerror if=/dev/sdb2 of=rasp-image.img bs=1M</code> on my Linux machine (option <code>conv=noerror</code> ignores any errors, sync pads read-errors with zeros). The resulting image could not be mounted using a loop device. <br />
* Fortunately, <code>fsck.ext4 raspberry-image.bin</code> was able to repair the image, which I then could successfully mount on my Linux machine using <code>mount -o loop rasp-image.img /mnt</code>, and at a first glance, everything looked ok. So, I was at least able to get to my data. <br />
* On a later 'event', I dd-ed the repaired image back to the Raspberry, and could boot again.<br />
* On another a later 'event', I just fsck-ed the /dev/sdb2 using Linux, and could boot again... but I did not have luck this time - some files were gone.<br />
* 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.<br />
* My Raspberry successfully booted from this new image. I then used <code>raspi-config</code> to expand the root-fs (I've done this on my first installation as well). With Linux I was able to <code>dd</code> my repaired image to the repaired SD. The card booted as if nothing had happened...<br />
* But after some weeks, my Raspberry fried the SD card again, and some weeks later again ... And finally I could not get my pi to boot with this card. However, I can still read the data linux. Moving data to a new card... (easier said than done if the new card is slightly smaller... but, see below for resizing... and sometimes a fresh install is even less painful).<br />
<br />
===Reminders: dd, dd_rescue, losetup, mount and others===<br />
* Example partition table printed by fdisk:<br />
<code><br />
/dev/sdb: 7861 MB, 7861174272 bytes, 15353856 sectors<br />
Units = Sektoren of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
<br />
Gerät boot. Anfang Ende Blöcke Id System<br />
[...]<br />
/dev/sdb3 15288320 15353855 32768 83 Linux</code><br />
:Byte-offset of sdb3: 7827619840 = 15288320 * 512<br />
<br />
* Mount partition to /dev/loopN partition for repair, etc.<br />
:<code>losetup -o 7827619840 --find --show /dev/sdb</code><br />
:--show prints the used /dev/loopN device<br />
<br />
* Directly mount partition using loop device:<br />
:<code>mount -o loop,offset=7827619840 /dev/sdb /mnt</code><br />
* http://www.garloff.de/kurt/linux/ddrescue/<br />
* http://softwarebakery.com/shrinking-images-on-linux<br />
* http://www.tehfear.com/2007/10/08/resize-loop-disk-image/<br />
* http://wiki.ubuntuusers.de/dd (German)<br />
* http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device<br />
<br />
===Some 1-Wire Stuff===<br />
<br />
====Temperature Sensor DS1820====<br />
<br />
* How to?<br />
** http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/<br />
** https://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&start=1 (German)<br />
** http://kopfkino.irosaurus.com/tutorial-ds18s20-temperatur-sensor-an-einem-raspberry-pi/ (German)<br />
** http://raspberrywebserver.com/cgiscripting/rpi-temperature-logger/<br />
** http://elinux.org/RPi_Low-level_peripherals<br />
<br />
* I have two DS18B20 and log temperatures using rrdtool.<br />
<br />
* 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). <br />
** Q: Is this due to overclocking with using dynamic governor?<br />
** A: No - also occurs without overclocking (but less frequent?)<br />
** Q: Or is this due to voltage-problems?<br />
** A: No - also occurs without over-voltage<br />
** Q: Or something else?<br />
** 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). Using 3 sensors works almost all the time (without overclocking), but using 4 or more sensors (2 connected star topologies, very bad for 1-wire [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]), almost always fails to read values on most of the sensors.<br />
** A:'''Implement multiple 1-wire interfaces''' (see below), using 1 for each star-topology solved the problem. Reading 2x3 works perfect!<br />
<br />
====Multiple 1-wire buses====<br />
:* Inspired and guided by http://www.raspberrypi.org/forums/viewtopic.php?p=513312#p513312, I've patched my 3.12.y kernel <code>arch/arm/mach-bcm2708/bcm2708.c</code> (patch file http://holyhead.de/RaspberryPi/bcm2708-multiple_w-1.patch-3.12.21.txt).<br />
::* Note: With kernel version, device tree were introduced, see for example http://www.raspberrypi.org/documentation/configuration/device-tree.md<BR>But somehow 1-wire works for my 3.18.5+ without specifying any dtoverlays... And all tries to configure w1-gpio-overlay.dtb via config.txt resulted in my Raspberry not booting (I also tried a modified w1.dtb which should also handle my second w1-bus).<br />
:* I've cross-compiled the kernel on a linux-VM, using the instructions of http://elinux.org/RPi_Kernel_Compilation (compiling on the RaspberryPi takes 6 hours [http://wiki.gentoo.org/wiki/Raspberry_Pi_Kernel_Compilation] or much more [http://elinux.org/RPi_Kernel_Compilation]).<br />
<br />
====Some 1-wire internals====<br />
* https://www.kernel.org/doc/Documentation/w1/w1.generic<br />
* [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]<br />
* http://blog.gegg.us/2013/03/4-different-methods-of-1-wire-access-on-raspberry-pi/<br />
<br />
===Compiling own kernel===<br />
<br />
* Some hints on cross-compiling:<br />
:* http://elinux.org/RPi_Kernel_Compilation<br />
:* https://github.com/raspberrypi/linux/tree/rpi-3.12.y/arch/arm/mach-bcm2708<br />
:* https://github.com/notro/rpi-source/wiki<br />
:* https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489&start=75<br />
:* http://www.bootc.net/projects/raspberry-pi-kernel/<br />
:* http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-recompile.html<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-cross-compile.html<br />
:* http://www.gtkdb.de/index_36_2087.html<br />
<br />
* extract kernel config from image:<br />
::<code>scripts/extract-ikconfig kernel-image</code><br />
::(extract-ikconfig is part of the kernel sources)<br />
<br />
===Device Trees===<br />
<br />
:* http://www.raspberrypi.org/documentation/configuration/device-tree.md<br />
:* https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt<br />
<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=97216<br />
:* http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f<br />
:* http://www.forum-raspberrypi.de/Thread-tutorial-geraetetreiber-und-device-tree-dt (German)<br />
<br />
:* http://xillybus.com/tutorials/device-tree-zynq-1<br />
<br />
===What about updates?===<br />
<br />
As I always forget this<br />
* <code>apt-get update</code> - update package lists<br />
* <code>apt-get upgrade</code> - upgrade installed packages<br />
* <code>rpi-update</code> - update kernel and modules<br />
::use <code>SKIP_KERNEL=1 rpi-update</code> to update the RPi firmware, but keep the current kernel<br />
::set <code>SKIP_REPODELETE=1</code> to keep downloaded files (by default: <code>/root/.rpi-firmware</code>)<br />
<br />
Kernel Sources<br />
* https://github.com/notro/rpi-source gets the source data from https://github.com/Hexxeh/rpi-firmware and https://github.com/raspberrypi/linux/<br />
<br />
===Kernel Panics===<br />
<br />
* http://ptgmedia.pearsoncmg.com/images/013147751X/downloads/013147751X_book.pdf<br />
: p290:<br />
export CONFIG_DEBUG_INFO=1<br />
make kernel/sysctl.o<br />
objdump -d -S kernel/sysctl.o > kernel/sysctl.dump<br />
<br />
* http://www.opensourceforu.com/2011/01/understanding-a-kernel-oops/<br />
<br />
==Attaching a LCD display==<br />
<br />
===Wiring and Specs===<br />
<br />
* Specs ftp://imall.iteadstudio.com/IM120424018_EONE_2004_Characters_LCD/SPE_IM120424018_EONE_2004_Characters_LCD.pdf<br />
<br />
* http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display (German)<br />
<br />
* http://www.pro-linux.de/artikel/2/1624/5,die-anzeige-hardware-und-software.html<br />
<br />
* https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring<br />
<br />
* https://github.com/perryflynn/raspberrypi-misc/tree/master/charlcd_4x20_cmd<br />
<br />
* http://obrazki.elektroda.pl/5028699400_1384164963.jpg<br />
<br />
===Misc===<br />
<br />
* http://www.makerspaceuk.com/lcd-temp-sensor/<br />
<br />
* http://anwendungsentwickler.ws/blog/kategorien/raspberry-pi/4x20-lcd-screen-mit-dem-raspberry-pi.html (German)<br />
<br />
==Controlling the display==<br />
<br />
* Python [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO]<br />
<br />
===LCDProc hints===<br />
<br />
* Pi & GPIO powered HD44780 LCD: http://www.boeeerb.co.uk/pi-lcd/<br />
<br />
* https://metacpan.org/pod/Net::LCDproc<br />
<br />
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=63412<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-user.html<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-dev.html<br />
<br />
* http://tuxgraphics.org/electronics/200504/article375.shtml<br />
<br />
==Todo and Miscellaneous==<br />
<br />
<br />
===Collection of stuff to check - things I might) try sometime===<br />
<br />
* http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/<br />
<br />
* [http://en.wikipedia.org/wiki/F2FS f2fs]<br />
:* [http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=65330 F2fs, Ext4, FAT USB Benchmark]<br />
:* [http://forum.xda-developers.com/showthread.php?t=2697069 File System Performance: F2FS vs EXT4]<br />
<br />
* https://github.com/yuraa/Raspberry-Pi-Heartbeat<br />
<br />
* http://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html<br />
<br />
* [http://www.raspberrypi.org/archives/5282 Mathematica on Raspberry Pi, for free]<br />
:* also works in RasPi emulator, e.g. http://www.heise.de/ct/inhalt/2014/7/160/ (German, teaser to article)<br />
<br />
* NAS/Samba<br />
:* 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:<br />
:<code>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536</code><br />
<br />
* http://linuxtortures.blogspot.fr/2012/06/cross-compiling-and-cross-debugging-c.html<br />
<br />
===Things done===<br />
<br />
* Adjust swap file (size, location -> (ext4) HDD - too slow?): http://manpages.ubuntu.com/manpages/hardy/man8/dphys-swapfile.8.html<br />
<br />
* http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/<br />
<br />
==Some links (aka bookmark lists)==<br />
<br />
Project sites<br />
<br />
* [http://www.cl.cam.ac.uk/projects/raspberrypi/ University of Cambridge / Raspberry Pi Computer Laboratory]<br />
* [https://www.raspiprojekt.de/ raspiprojek] (German)<br />
* http://www.vanheusden.com/misc/rpi.php<br />
<br />
Blogs, forums, etc<br />
* http://www.raspberrypi.org/phpBB3/<br />
* [http://forum.stmlabs.com/forumdisplay.php?fid=6 Stm Labs Forum / Raspbmc]<br />
* [http://www.welzels.de/blog/projekte/raspberry-pi/ Wel!s Blog] (German)<br />
* [http://jankarres.de/category/raspberry-pi/ Raspberry Pi Blog of Jan Karres] (German)<br />
* http://www.forum-raspberrypi.de/ /(German)<br />
* http://raspberrycenter.de/ (German)<br />
* http://archlinuxarm.org/forum/viewforum.php?f=31&sid=57987232ca9177c35eb3ef7fdf6b3341<br />
<br />
* [[wikipedia:Raspberry_Pi Raspberry Pi in Wikipedia]]<br />
<br />
Miscellaneous<br />
<br />
* [http://www.raspberrypi.org/downloads New Out Of Box Software (Recommended)]<br />
* [http://elinux.org/R-Pi_Hub R-Pi_Hub]<br />
<br />
Manuals<br />
<br />
* https://github.com/raspberrypi/documentation<br />
<br />
* [http://debian-handbook.info/browse/stable/ The Debian Administrator's Handbook]</div>Holyheadhttps://holyhead.de/index.php?title=Raspberry_PiRaspberry Pi2015-02-11T22:27:34Z<p>Holyhead: </p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
===External USB drives===<br />
<br />
* Automount USB-Drives in Raspbian<br />
** One may use [http://selfprogramming.bplaced.net/index.php/2012/10/23/automount-usb-drives-in-raspbian/ USBmount and autofs]<br />
** I prefer [http://ignorantguru.github.io/udevil/ udevil], see below<br />
<br />
* Install ''ntfs-3g'' if you need write access to ntfs file systems<br />
<br />
* How to increase performance?<br />
** Mount with option ''''noatime'''' or ''''relatime''''<br />
** Mount ''without'' option sync (e.g. keep default async)<br />
** If using ntfs-3g (fuse) file system, try mounting with option 'big_writes', see for example http://obihoernchen.net/wordpress/tag/big_writes/<br />
<br />
===[http://ignorantguru.github.io/udevil/ udevil]===<br />
<br />
* example for manual mounting:<br />
<br />
udevil mount /dev/sda1<br />
<br />
* auto-mounting via udev-rule, see for example http://lsdlinux.org/wiki/doku.php?id=auto_mounting#using_udev_rule (I just copied the 95-udevil-mount.rules file from an OpenElec installation (http://www.raspberrypi.org/downloads) )<br />
<br />
* my build-steps (maybe there's a simpler way, but this worked...):<br />
** download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget<br />
** extract deb-package via <code>ar vx udevil_0.4.3-1_all.deb</code><br />
** extract data archive <code>tar xzvf data.tar.gz</code><br />
** change to tar usr/share/devil/src<br />
** untar <code>tar xvfJ udevil-current.tar.xz</code><br />
** <code>cd udevil-0.4.3</code><br />
** <code>mv distros/debian</code><br />
** execute <code>dpkg-buildpackage</code><br />
** 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<br />
** Install via <code>sudo dpkg -i udevil_0.4.3-1_armhf.deb</code><br />
<br />
===Samba server / NAS===<br />
<br />
* How to install?<br />
** [http://jankarres.de/2013/11/raspberry-pi-samba-server-installieren/ | Raspberry Pi: Samba Server installieren] (German)<br />
** [http://www.welzels.de/blog/projekte/raspberry-pi/low-budget-nas-mit-einem-raspberry-pi/ Low Budget NAS mit einem Raspberry PI] (German)<br />
<br />
* Slow disc performance?<br />
** see 'Slow USB drives' above<br />
** 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!)<br />
<br />
* Configuration and tuning<br />
** https://calomel.org/samba.html<br />
** https://calomel.org/samba_optimize.html<br />
<br />
* If your /var/log/samba/log.smbd fills up with ''printing/print_cups.c:110(cups_connect) Unable to connect to CUPS server localhost'' messages, try http://www.sotechdesign.com.au/samba-log-showing-error-failed-to-retrieve-printer-list/<br/>I also created an empty <code>/etc/printcap</code> to avoid ''Unable to open printcap file /etc/printcap for read'' messages.<br />
<br />
* I don't need sound:<br />
<br />
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf <br />
# I don't need sound<br />
blacklist snd<br />
blacklist snd_pcm<br />
blacklist snd_soc_core<br />
blacklist snd_soc_bcm2708_i2s<br />
<br />
===Trying to reduce number of disk writes (SD card)===<br />
<br />
I'm using [http://oss.oetiker.ch/rrdtool/ 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).<br />
<br />
Here's what I've done:<br />
<br />
* Edit <code>/etc/default/cron</code> and set <code>EXTRA_OPTS="-L 0"</code> to disable logging (I don't need these)<br />
* Avoid entries like <code>pam_unix(cron:session): session closed for user pi</code> in <code>/var/log/auth.log</code><br />
** Edit <code>/etc/pam.d/cron</code> and comment the line <code>@include common-session-noninteractive</code> ([http://ubuntuforums.org/showthread.php?t=1256801])<br />
:or<br />
:* Edit <code>/etc/pam.d/common-session-noninteractive</code> as shown here: http://ubuntuforums.org/showthread.php?t=1256801&p=10283830#post10283830<br />
* I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)<br />
** moved all the .rrd files as well as the created images to my persistent-ramdisk location<br />
** moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links<br />
*** <code>/var/spool</code><br />
*** <code>/var/log</code><br />
*** <code>/var/cache/samba</code><br />
** edited <code>/etc/insserv.conf</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:<br />
<br />
$local_fs_orig +mountall +mountall-bootclean +mountoverflowtmp +umountfs<br />
# we need the sym-link data in /var/log and /var/spool to be available<br />
$local_fs $local_fs_orig +persist-ramdisk<br />
<br />
:: <code>/etc/init.d/persist-ramdisk</code> 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.<br />
<br />
:* set ''RAMTMP'' to yes in <code>/etc/default/tmpfs</code> to get tempfs based <code>/tmp</code><br />
<br />
Before changing <code>/tmp</code>:<br />
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').<br />
::I need to do more digging...<br />
<br />
After changing <code>/tmp</code>:<br />
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...<br />
<br />
===Useful stuff and Q&A===<br />
<br />
* Q: Why does my Pi restart when hotplugging a USB drive?<br />
** http://thestuffsido.blogspot.de/2013/05/fixing-raspberry-pi-hotplugging.html<br />
** http://therandomlab.blogspot.de/2013/01/raspberry-pi-mod-to-avoid-shutdown-on.html<br />
<br />
* Q: Does Raspberry support WOL?<br />
: A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)<br />
<br />
* Q: The new password is to short, or too simple<br />
: A: Try adjusting the PAM settings in <code>/etc/pam.d/common-password</code>:<br />
:* remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)<br />
::<code>password [success=1 default=ignore] pam_unix.so sha512 minlen=2</code><br />
<br />
::!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!<br><br />
::But it's nice for testing (if you cannot or do not want to use auto-login.)<br />
<br />
* Q: How to configure static IP?<br />
: A: In /etc/network/interfaces:<br />
::<code>iface eth0 inet static<br>address 192.168.0.31<br>netmask 255.255.255.0<br>gateway 192.168.0.1</code><br />
<br />
* Q: How to read core temperature, etc?<br />
: A: [http://elinux.org/RPI_vcgencmd_usage vcgencmd]:<br />
::<code>vcgencmd measure_temp<br>vcgencmd measure_clock arm</code><br />
<br />
* External USB HDD spin down<br />
** hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)<br />
** hd-idle works:<br />
::<code>hd-idle -a sda -i 600</code><br />
:: for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)<br />
<br />
* Q: How to avoid update of a certain package?<br />
: A: Put package on hold ([http://debiananwenderhandbuch.de/dpkg.html] (German)):<br />
::<code>echo <packagename> "hold" | dpkg --set-selections</code><br />
<br />
* [[wikipedia:Raspcontrol]] with nginx<br />
** http://www.foxplex.com/sites/raspcontrol-webinterface-auf-dem-raspberry-pi/ (German), http://www.foxplex.com/sites/performanter-nginx-webserver-auf-dem-raspberry-pi-mit-php-und-apc/ (German)<br />
** http://menzerath.eu/artikel/raspberry-pi-raspcontrol-installation-funktionen/ (German)<br />
<br />
* Q: How many bytes are written to my (SD) disc?<br />
: A: Use <code>iostat</code> http://www.mybinarylife.net/2012/08/linux-iostat-command.html<br />
: A: Use <code>iotop</code> http://guichaz.free.fr/iotop/<br />
: A: Raw data of the kernel can be found in files <code>/proc/diskstats</code> and <code>/sys/block/DEVNAME/stat</code> https://www.kernel.org/doc/Documentation/iostats.txt<br />
:* http://unix.stackexchange.com/questions/86391/how-to-get-total-number-of-bytes-sectors-blocks-written-to-disk-since-booting<br />
:* http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux<br />
<br />
* Q: How to reduce number of ext-fs checks?<br />
: A: <code>tune2fs -c 60 /dev/sda1</code> Change maximum mount count to 60<br />
: A: <code>tune2fs -i 12m /dev/sda1</code> Change check interval to 12 months<br />
: fore more details: http://wiki.ubuntuusers.de/Dateisystemcheck (German)<br />
<br />
===Overclocking===<br />
<br />
* I only set overclocking via <code>raspi-config</code><br />
<br />
* ''Turbo'': (Short) Raspberry stress test were ok. But I got an SD card error/corruption when doing a download and a dd-image of the SD card (according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907 the SD card error could be OC related.)<br />
::Luckily, I could recover all my data, see below.<br />
<br />
* '' Medium'': Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907] and its links).<br />
<br />
* Underclocking to 600 MHz<br />
:<code>echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</code><br />
: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.<br />
<br />
* Adjusting the ondemand-governor<br />
** https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt<br />
** set <code>/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor</code> to 10 [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&start=800]<br />
**: I had hoped this reduces the 1-wire CRC errors/device-disconnects problems, but with heavy (IO-) load (e.g. backup), 1wire sensors still get disconnected.<br />
<br />
* [http://moze.free.fr/blog/index.php?post/2013/02/Underclock-and-Overclock Nice power consumption analysis]<br />
<br />
====Stress test and benchmarks====<br />
<br />
* [http://www.roylongbottom.org.uk/ Roy Longbottom's PC Benchmark Collection]<br />
* [http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm Raspberry Pi Stress Tests]<br />
<br />
===SD card issues===<br />
<br />
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). I could still use this card for some time (see below), but finally I got a corrupted file system and could no longer repair it. That's when I re-installed Raspbian on a new SD card.<br />
<br />
Maybe I should try [http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ running from USB] sometime?<br />
<br />
====Recovery====<br />
* Creating a binary image of the SD card with my PC using [http://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] resulted in IO errors at about 17%.<br />
* 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 <code>dd conv=sync,noerror if=/dev/sdb2 of=rasp-image.img bs=1M</code> on my Linux machine (option <code>conv=noerror</code> ignores any errors, sync pads read-errors with zeros). The resulting image could not be mounted using a loop device. <br />
* Fortunately, <code>fsck.ext4 raspberry-image.bin</code> was able to repair the image, which I then could successfully mount on my Linux machine using <code>mount -o loop rasp-image.img /mnt</code>, and at a first glance, everything looked ok. So, I was at least able to get to my data. <br />
* On a later 'event', I dd-ed the repaired image back to the Raspberry, and could boot again.<br />
* On another a later 'event', I just fsck-ed the /dev/sdb2 using Linux, and could boot again... but I did not have luck this time - some files were gone.<br />
* 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.<br />
* My Raspberry successfully booted from this new image. I then used <code>raspi-config</code> to expand the root-fs (I've done this on my first installation as well). With Linux I was able to <code>dd</code> my repaired image to the repaired SD. The card booted as if nothing had happened...<br />
* But after some weeks, my Raspberry fried the SD card again, and some weeks later again ... And finally I could not get my pi to boot with this card. However, I can still read the data linux. Moving data to a new card... (easier said than done if the new card is slightly smaller... but, see below for resizing... and sometimes a fresh install is even less painful).<br />
<br />
===Reminders: dd, dd_rescue, losetup, mount and others===<br />
* Example partition table printed by fdisk:<br />
<code><br />
/dev/sdb: 7861 MB, 7861174272 bytes, 15353856 sectors<br />
Units = Sektoren of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
<br />
Gerät boot. Anfang Ende Blöcke Id System<br />
[...]<br />
/dev/sdb3 15288320 15353855 32768 83 Linux</code><br />
:Byte-offset of sdb3: 7827619840 = 15288320 * 512<br />
<br />
* Mount partition to /dev/loopN partition for repair, etc.<br />
:<code>losetup -o 7827619840 --find --show /dev/sdb</code><br />
:--show prints the used /dev/loopN device<br />
<br />
* Directly mount partition using loop device:<br />
:<code>mount -o loop,offset=7827619840 /dev/sdb /mnt</code><br />
* http://www.garloff.de/kurt/linux/ddrescue/<br />
* http://softwarebakery.com/shrinking-images-on-linux<br />
* http://www.tehfear.com/2007/10/08/resize-loop-disk-image/<br />
* http://wiki.ubuntuusers.de/dd (German)<br />
* http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device<br />
<br />
===Some 1-Wire Stuff===<br />
<br />
====Temperature Sensor DS1820====<br />
<br />
* How to?<br />
** http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/<br />
** https://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&start=1 (German)<br />
** http://kopfkino.irosaurus.com/tutorial-ds18s20-temperatur-sensor-an-einem-raspberry-pi/ (German)<br />
** http://raspberrywebserver.com/cgiscripting/rpi-temperature-logger/<br />
** http://elinux.org/RPi_Low-level_peripherals<br />
<br />
* I have two DS18B20 and log temperatures using rrdtool.<br />
<br />
* 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). <br />
** Q: Is this due to overclocking with using dynamic governor?<br />
** A: No - also occurs without overclocking (but less frequent?)<br />
** Q: Or is this due to voltage-problems?<br />
** A: No - also occurs without over-voltage<br />
** Q: Or something else?<br />
** 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). Using 3 sensors works almost all the time (without overclocking), but using 4 or more sensors (2 connected star topologies, very bad for 1-wire [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]), almost always fails to read values on most of the sensors.<br />
** A:'''Implement multiple 1-wire interfaces''' (see below), using 1 for each star-topology solved the problem. Reading 2x3 works perfect!<br />
<br />
====Multiple 1-wire buses====<br />
:* Inspired and guided by http://www.raspberrypi.org/forums/viewtopic.php?p=513312#p513312, I've patched my 3.12.y kernel <code>arch/arm/mach-bcm2708/bcm2708.c</code> (patch file http://holyhead.de/RaspberryPi/bcm2708-multiple_w-1.patch-3.12.21.txt).<br />
::* Note: With kernel version, device tree were introduced, see for example http://www.raspberrypi.org/documentation/configuration/device-tree.md<BR>But somehow 1-wire works for my 3.18.5+ without specifying any dtoverlays... And all tries to configure w1-gpio-overlay.dtb via config.txt resulted in my Raspberry not booting (I also tried a modified w1.dtb which should also handle my second w1-bus).<br />
:* I've cross-compiled the kernel on a linux-VM, using the instructions of http://elinux.org/RPi_Kernel_Compilation (compiling on the RaspberryPi takes 6 hours [http://wiki.gentoo.org/wiki/Raspberry_Pi_Kernel_Compilation] or much more [http://elinux.org/RPi_Kernel_Compilation]).<br />
<br />
====Some 1-wire internals====<br />
* https://www.kernel.org/doc/Documentation/w1/w1.generic<br />
* [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]<br />
* http://blog.gegg.us/2013/03/4-different-methods-of-1-wire-access-on-raspberry-pi/<br />
<br />
===Compiling own kernel===<br />
<br />
* Some hints on cross-compiling:<br />
:* http://elinux.org/RPi_Kernel_Compilation<br />
:* https://github.com/raspberrypi/linux/tree/rpi-3.12.y/arch/arm/mach-bcm2708<br />
:* https://github.com/notro/rpi-source/wiki<br />
:* https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489&start=75<br />
:* http://www.bootc.net/projects/raspberry-pi-kernel/<br />
:* http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-recompile.html<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-cross-compile.html<br />
:* http://www.gtkdb.de/index_36_2087.html<br />
<br />
* extract kernel config from image:<br />
::<code>scripts/extract-ikconfig kernel-image</code><br />
::(extract-ikconfig is part of the kernel sources)<br />
<br />
===Device Trees===<br />
<br />
:* http://www.raspberrypi.org/documentation/configuration/device-tree.md<br />
:* https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt<br />
<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=97216<br />
:* http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f<br />
:* http://www.forum-raspberrypi.de/Thread-tutorial-geraetetreiber-und-device-tree-dt (German)<br />
<br />
:* http://xillybus.com/tutorials/device-tree-zynq-1<br />
<br />
===What about updates?===<br />
<br />
As I always forget this<br />
* <code>apt-get update</code> - update package lists<br />
* <code>apt-get upgrade</code> - upgrade installed packages<br />
* <code>rpi-update</code> - update kernel and modules<br />
::use <code>SKIP_KERNEL=1 rpi-update</code> to update the RPi firmware, but keep the current kernel<br />
::set <code>SKIP_REPODELETE=1</code> to keep downloaded files (by default: <code>/root/.rpi-firmware</code>)<br />
<br />
Kernel Sources<br />
* https://github.com/notro/rpi-source gets the source data from https://github.com/Hexxeh/rpi-firmware and https://github.com/raspberrypi/linux/<br />
<br />
===Kernel Panics===<br />
<br />
* http://ptgmedia.pearsoncmg.com/images/013147751X/downloads/013147751X_book.pdf<br />
: p290:<br />
export CONFIG_DEBUG_INFO=1<br />
make kernel/sysctl.o<br />
objdump -d -S kernel/sysctl.o > kernel/sysctl.dump<br />
<br />
* http://www.opensourceforu.com/2011/01/understanding-a-kernel-oops/<br />
<br />
==Attaching a LCD display==<br />
<br />
===Wiring and Specs===<br />
<br />
* Specs ftp://imall.iteadstudio.com/IM120424018_EONE_2004_Characters_LCD/SPE_IM120424018_EONE_2004_Characters_LCD.pdf<br />
<br />
* http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display (German)<br />
<br />
* http://www.pro-linux.de/artikel/2/1624/5,die-anzeige-hardware-und-software.html<br />
<br />
* https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring<br />
<br />
* https://github.com/perryflynn/raspberrypi-misc/tree/master/charlcd_4x20_cmd<br />
<br />
* http://obrazki.elektroda.pl/5028699400_1384164963.jpg<br />
<br />
===Misc===<br />
<br />
* http://www.makerspaceuk.com/lcd-temp-sensor/<br />
<br />
* http://anwendungsentwickler.ws/blog/kategorien/raspberry-pi/4x20-lcd-screen-mit-dem-raspberry-pi.html (German)<br />
<br />
==Controlling the display==<br />
<br />
* Python [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO]<br />
<br />
===LCDProc hints===<br />
<br />
* Pi & GPIO powered HD44780 LCD: http://www.boeeerb.co.uk/pi-lcd/<br />
<br />
* https://metacpan.org/pod/Net::LCDproc<br />
<br />
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=63412<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-user.html<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-dev.html<br />
<br />
* http://tuxgraphics.org/electronics/200504/article375.shtml<br />
<br />
==Todo and Miscellaneous==<br />
<br />
<br />
===Collection of stuff to check - things I might) try sometime===<br />
<br />
* http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/<br />
<br />
* [http://en.wikipedia.org/wiki/F2FS f2fs]<br />
:* [http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=65330 F2fs, Ext4, FAT USB Benchmark]<br />
:* [http://forum.xda-developers.com/showthread.php?t=2697069 File System Performance: F2FS vs EXT4]<br />
<br />
* https://github.com/yuraa/Raspberry-Pi-Heartbeat<br />
<br />
* http://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html<br />
<br />
* [http://www.raspberrypi.org/archives/5282 Mathematica on Raspberry Pi, for free]<br />
:* also works in RasPi emulator, e.g. http://www.heise.de/ct/inhalt/2014/7/160/ (German, teaser to article)<br />
<br />
* NAS/Samba<br />
:* 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:<br />
:<code>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536</code><br />
<br />
* http://linuxtortures.blogspot.fr/2012/06/cross-compiling-and-cross-debugging-c.html<br />
<br />
===Things done===<br />
<br />
* Adjust swap file (size, location -> (ext4) HDD - too slow?): http://manpages.ubuntu.com/manpages/hardy/man8/dphys-swapfile.8.html<br />
<br />
* http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/<br />
<br />
==Some links (aka bookmark lists)==<br />
<br />
Project sites<br />
<br />
* [http://www.cl.cam.ac.uk/projects/raspberrypi/ University of Cambridge / Raspberry Pi Computer Laboratory]<br />
* [https://www.raspiprojekt.de/ raspiprojek] (German)<br />
* http://www.vanheusden.com/misc/rpi.php<br />
<br />
Blogs, forums, etc<br />
* http://www.raspberrypi.org/phpBB3/<br />
* [http://forum.stmlabs.com/forumdisplay.php?fid=6 Stm Labs Forum / Raspbmc]<br />
* [http://www.welzels.de/blog/projekte/raspberry-pi/ Wel!s Blog] (German)<br />
* [http://jankarres.de/category/raspberry-pi/ Raspberry Pi Blog of Jan Karres] (German)<br />
* http://www.forum-raspberrypi.de/ /(German)<br />
* http://raspberrycenter.de/ (German)<br />
<br />
* [[wikipedia:Raspberry_Pi Raspberry Pi in Wikipedia]]<br />
<br />
Miscellaneous<br />
<br />
* [http://www.raspberrypi.org/downloads New Out Of Box Software (Recommended)]<br />
* [http://elinux.org/R-Pi_Hub R-Pi_Hub]<br />
<br />
Manuals<br />
<br />
* https://github.com/raspberrypi/documentation<br />
<br />
* [http://debian-handbook.info/browse/stable/ The Debian Administrator's Handbook]</div>Holyheadhttps://holyhead.de/index.php?title=Raspberry_PiRaspberry Pi2015-02-10T05:53:52Z<p>Holyhead: /* Reminders: dd, dd_rescue, losetup, mount and others */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
===External USB drives===<br />
<br />
* Automount USB-Drives in Raspbian<br />
** One may use [http://selfprogramming.bplaced.net/index.php/2012/10/23/automount-usb-drives-in-raspbian/ USBmount and autofs]<br />
** I prefer [http://ignorantguru.github.io/udevil/ udevil], see below<br />
<br />
* Install ''ntfs-3g'' if you need write access to ntfs file systems<br />
<br />
* How to increase performance?<br />
** Mount with option ''''noatime'''' or ''''relatime''''<br />
** Mount ''without'' option sync (e.g. keep default async)<br />
** If using ntfs-3g (fuse) file system, try mounting with option 'big_writes', see for example http://obihoernchen.net/wordpress/tag/big_writes/<br />
<br />
===[http://ignorantguru.github.io/udevil/ udevil]===<br />
<br />
* example for manual mounting:<br />
<br />
udevil mount /dev/sda1<br />
<br />
* auto-mounting via udev-rule, see for example http://lsdlinux.org/wiki/doku.php?id=auto_mounting#using_udev_rule (I just copied the 95-udevil-mount.rules file from an OpenElec installation (http://www.raspberrypi.org/downloads) )<br />
<br />
* my build-steps (maybe there's a simpler way, but this worked...):<br />
** download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget<br />
** extract deb-package via <code>ar vx udevil_0.4.3-1_all.deb</code><br />
** extract data archive <code>tar xzvf data.tar.gz</code><br />
** change to tar usr/share/devil/src<br />
** untar <code>tar xvfJ udevil-current.tar.xz</code><br />
** <code>cd udevil-0.4.3</code><br />
** <code>mv distros/debian</code><br />
** execute <code>dpkg-buildpackage</code><br />
** 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<br />
** Install via <code>sudo dpkg -i udevil_0.4.3-1_armhf.deb</code><br />
<br />
===Samba server / NAS===<br />
<br />
* How to install?<br />
** [http://jankarres.de/2013/11/raspberry-pi-samba-server-installieren/ | Raspberry Pi: Samba Server installieren] (German)<br />
** [http://www.welzels.de/blog/projekte/raspberry-pi/low-budget-nas-mit-einem-raspberry-pi/ Low Budget NAS mit einem Raspberry PI] (German)<br />
<br />
* Slow disc performance?<br />
** see 'Slow USB drives' above<br />
** 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!)<br />
<br />
* Configuration and tuning<br />
** https://calomel.org/samba.html<br />
** https://calomel.org/samba_optimize.html<br />
<br />
* If your /var/log/samba/log.smbd fills up with ''printing/print_cups.c:110(cups_connect) Unable to connect to CUPS server localhost'' messages, try http://www.sotechdesign.com.au/samba-log-showing-error-failed-to-retrieve-printer-list/<br/>I also created an empty <code>/etc/printcap</code> to avoid ''Unable to open printcap file /etc/printcap for read'' messages.<br />
<br />
* I don't need sound:<br />
<br />
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf <br />
# I don't need sound<br />
blacklist snd<br />
blacklist snd_pcm<br />
blacklist snd_soc_core<br />
blacklist snd_soc_bcm2708_i2s<br />
<br />
===Trying to reduce number of disk writes (SD card)===<br />
<br />
I'm using [http://oss.oetiker.ch/rrdtool/ 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).<br />
<br />
Here's what I've done:<br />
<br />
* Edit <code>/etc/default/cron</code> and set <code>EXTRA_OPTS="-L 0"</code> to disable logging (I don't need these)<br />
* Avoid entries like <code>pam_unix(cron:session): session closed for user pi</code> in <code>/var/log/auth.log</code><br />
** Edit <code>/etc/pam.d/cron</code> and comment the line <code>@include common-session-noninteractive</code> ([http://ubuntuforums.org/showthread.php?t=1256801])<br />
:or<br />
:* Edit <code>/etc/pam.d/common-session-noninteractive</code> as shown here: http://ubuntuforums.org/showthread.php?t=1256801&p=10283830#post10283830<br />
* I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)<br />
** moved all the .rrd files as well as the created images to my persistent-ramdisk location<br />
** moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links<br />
*** <code>/var/spool</code><br />
*** <code>/var/log</code><br />
*** <code>/var/cache/samba</code><br />
** edited <code>/etc/insserv.conf</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:<br />
<br />
$local_fs_orig +mountall +mountall-bootclean +mountoverflowtmp +umountfs<br />
# we need the sym-link data in /var/log and /var/spool to be available<br />
$local_fs $local_fs_orig +persist-ramdisk<br />
<br />
:: <code>/etc/init.d/persist-ramdisk</code> 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.<br />
<br />
:* set ''RAMTMP'' to yes in <code>/etc/default/tmpfs</code> to get tempfs based <code>/tmp</code><br />
<br />
Before changing <code>/tmp</code>:<br />
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').<br />
::I need to do more digging...<br />
<br />
After changing <code>/tmp</code>:<br />
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...<br />
<br />
===Useful stuff and Q&A===<br />
<br />
* Q: Why does my Pi restart when hotplugging a USB drive?<br />
** http://thestuffsido.blogspot.de/2013/05/fixing-raspberry-pi-hotplugging.html<br />
** http://therandomlab.blogspot.de/2013/01/raspberry-pi-mod-to-avoid-shutdown-on.html<br />
<br />
* Q: Does Raspberry support WOL?<br />
: A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)<br />
<br />
* Q: The new password is to short, or too simple<br />
: A: Try adjusting the PAM settings in <code>/etc/pam.d/common-password</code>:<br />
:* remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)<br />
::<code>password [success=1 default=ignore] pam_unix.so sha512 minlen=2</code><br />
<br />
::!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!<br><br />
::But it's nice for testing (if you cannot or do not want to use auto-login.)<br />
<br />
* Q: How to configure static IP?<br />
: A: In /etc/network/interfaces:<br />
::<code>iface eth0 inet static<br>address 192.168.0.31<br>netmask 255.255.255.0<br>gateway 192.168.0.1</code><br />
<br />
* Q: How to read core temperature, etc?<br />
: A: [http://elinux.org/RPI_vcgencmd_usage vcgencmd]:<br />
::<code>vcgencmd measure_temp<br>vcgencmd measure_clock arm</code><br />
<br />
* External USB HDD spin down<br />
** hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)<br />
** hd-idle works:<br />
::<code>hd-idle -a sda -i 600</code><br />
:: for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)<br />
<br />
* Q: How to avoid update of a certain package?<br />
: A: Put package on hold ([http://debiananwenderhandbuch.de/dpkg.html] (German)):<br />
::<code>echo <packagename> "hold" | dpkg --set-selections</code><br />
<br />
* [[wikipedia:Raspcontrol]] with nginx<br />
** http://www.foxplex.com/sites/raspcontrol-webinterface-auf-dem-raspberry-pi/ (German), http://www.foxplex.com/sites/performanter-nginx-webserver-auf-dem-raspberry-pi-mit-php-und-apc/ (German)<br />
** http://menzerath.eu/artikel/raspberry-pi-raspcontrol-installation-funktionen/ (German)<br />
<br />
* Q: How many bytes are written to my (SD) disc?<br />
: A: Use <code>iostat</code> http://www.mybinarylife.net/2012/08/linux-iostat-command.html<br />
: A: Use <code>iotop</code> http://guichaz.free.fr/iotop/<br />
: A: Raw data of the kernel can be found in files <code>/proc/diskstats</code> and <code>/sys/block/DEVNAME/stat</code> https://www.kernel.org/doc/Documentation/iostats.txt<br />
:* http://unix.stackexchange.com/questions/86391/how-to-get-total-number-of-bytes-sectors-blocks-written-to-disk-since-booting<br />
:* http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux<br />
<br />
* Q: How to reduce number of ext-fs checks?<br />
: A: <code>tune2fs -c 60 /dev/sda1</code> Change maximum mount count to 60<br />
: A: <code>tune2fs -i 12m /dev/sda1</code> Change check interval to 12 months<br />
: fore more details: http://wiki.ubuntuusers.de/Dateisystemcheck (German)<br />
<br />
===Overclocking===<br />
<br />
* I only set overclocking via <code>raspi-config</code><br />
<br />
* ''Turbo'': (Short) Raspberry stress test were ok. But I got an SD card error/corruption when doing a download and a dd-image of the SD card (according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907 the SD card error could be OC related.)<br />
::Luckily, I could recover all my data, see below.<br />
<br />
* '' Medium'': Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907] and its links).<br />
<br />
* Underclocking to 600 MHz<br />
:<code>echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</code><br />
: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.<br />
<br />
* Adjusting the ondemand-governor<br />
** https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt<br />
** set <code>/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor</code> to 10 [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&start=800]<br />
**: I had hoped this reduces the 1-wire CRC errors/device-disconnects problems, but with heavy (IO-) load (e.g. backup), 1wire sensors still get disconnected.<br />
<br />
* [http://moze.free.fr/blog/index.php?post/2013/02/Underclock-and-Overclock Nice power consumption analysis]<br />
<br />
====Stress test and benchmarks====<br />
<br />
* [http://www.roylongbottom.org.uk/ Roy Longbottom's PC Benchmark Collection]<br />
* [http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm Raspberry Pi Stress Tests]<br />
<br />
===SD card issues===<br />
<br />
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). I could still use this card for some time (see below), but finally I got a corrupted file system and could no longer repair it. That's when I re-installed Raspbian on a new SD card.<br />
<br />
Maybe I should try [http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ running from USB] sometime?<br />
<br />
====Recovery====<br />
* Creating a binary image of the SD card with my PC using [http://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] resulted in IO errors at about 17%.<br />
* 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 <code>dd conv=sync,noerror if=/dev/sdb2 of=rasp-image.img bs=1M</code> on my Linux machine (option <code>conv=noerror</code> ignores any errors, sync pads read-errors with zeros). The resulting image could not be mounted using a loop device. <br />
* Fortunately, <code>fsck.ext4 raspberry-image.bin</code> was able to repair the image, which I then could successfully mount on my Linux machine using <code>mount -o loop rasp-image.img /mnt</code>, and at a first glance, everything looked ok. So, I was at least able to get to my data. <br />
* On a later 'event', I dd-ed the repaired image back to the Raspberry, and could boot again.<br />
* On another a later 'event', I just fsck-ed the /dev/sdb2 using Linux, and could boot again... but I did not have luck this time - some files were gone.<br />
* 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.<br />
* My Raspberry successfully booted from this new image. I then used <code>raspi-config</code> to expand the root-fs (I've done this on my first installation as well). With Linux I was able to <code>dd</code> my repaired image to the repaired SD. The card booted as if nothing had happened...<br />
* But after some weeks, my Raspberry fried the SD card again, and some weeks later again ... And finally I could not get my pi to boot with this card. However, I can still read the data linux. Moving data to a new card... (easier said than done if the new card is slightly smaller... but, see below for resizing... and sometimes a fresh install is even less painful).<br />
<br />
===Reminders: dd, dd_rescue, losetup, mount and others===<br />
* Example partition table printed by fdisk:<br />
<code><br />
/dev/sdb: 7861 MB, 7861174272 bytes, 15353856 sectors<br />
Units = Sektoren of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
<br />
Gerät boot. Anfang Ende Blöcke Id System<br />
[...]<br />
/dev/sdb3 15288320 15353855 32768 83 Linux</code><br />
:Byte-offset of sdb3: 7827619840 = 15288320 * 512<br />
<br />
* Mount partition to /dev/loopN partition for repair, etc.<br />
:<code>losetup -o 7827619840 --find --show /dev/sdb</code><br />
:--show prints the used /dev/loopN device<br />
<br />
* Directly mount partition using loop device:<br />
:<code>mount -o loop,offset=7827619840 /dev/sdb /mnt</code><br />
* http://www.garloff.de/kurt/linux/ddrescue/<br />
* http://softwarebakery.com/shrinking-images-on-linux<br />
* http://www.tehfear.com/2007/10/08/resize-loop-disk-image/<br />
* http://wiki.ubuntuusers.de/dd (German)<br />
* http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device<br />
<br />
===Some 1-Wire Stuff===<br />
<br />
====Temperature Sensor DS1820====<br />
<br />
* How to?<br />
** http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/<br />
** https://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&start=1 (German)<br />
** http://kopfkino.irosaurus.com/tutorial-ds18s20-temperatur-sensor-an-einem-raspberry-pi/ (German)<br />
** http://raspberrywebserver.com/cgiscripting/rpi-temperature-logger/<br />
** http://elinux.org/RPi_Low-level_peripherals<br />
<br />
* I have two DS18B20 and log temperatures using rrdtool.<br />
<br />
* 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). <br />
** Q: Is this due to overclocking with using dynamic governor?<br />
** A: No - also occurs without overclocking (but less frequent?)<br />
** Q: Or is this due to voltage-problems?<br />
** A: No - also occurs without over-voltage<br />
** Q: Or something else?<br />
** 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). Using 3 sensors works almost all the time (without overclocking), but using 4 or more sensors (2 connected star topologies, very bad for 1-wire [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]), almost always fails to read values on most of the sensors.<br />
** A:'''Implement multiple 1-wire interfaces''' (see below), using 1 for each star-topology solved the problem. Reading 2x3 works perfect!<br />
<br />
====Multiple 1-wire buses====<br />
:* Inspired and guided by http://www.raspberrypi.org/forums/viewtopic.php?p=513312#p513312, I've patched my 3.12.y kernel <code>arch/arm/mach-bcm2708/bcm2708.c</code> (patch file http://holyhead.de/RaspberryPi/bcm2708-multiple_w-1.patch-3.12.21.txt).<br />
::* Note: With kernel version, device tree were introduced, see for example http://www.raspberrypi.org/documentation/configuration/device-tree.md<BR>But somehow 1-wire works for my 3.18.5+ without specifying any dtoverlays... And all tries to configure w1-gpio-overlay.dtb via config.txt resulted in my Raspberry not booting (I also tried a modified w1.dtb which should also handle my second w1-bus).<br />
:* I've cross-compiled the kernel on a linux-VM, using the instructions of http://elinux.org/RPi_Kernel_Compilation (compiling on the RaspberryPi takes 6 hours [http://wiki.gentoo.org/wiki/Raspberry_Pi_Kernel_Compilation] or much more [http://elinux.org/RPi_Kernel_Compilation]).<br />
<br />
====Some 1-wire internals====<br />
* https://www.kernel.org/doc/Documentation/w1/w1.generic<br />
* [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]<br />
* http://blog.gegg.us/2013/03/4-different-methods-of-1-wire-access-on-raspberry-pi/<br />
<br />
===Compiling own kernel===<br />
<br />
* Some hints on cross-compiling:<br />
:* http://elinux.org/RPi_Kernel_Compilation<br />
:* https://github.com/raspberrypi/linux/tree/rpi-3.12.y/arch/arm/mach-bcm2708<br />
:* https://github.com/notro/rpi-source/wiki<br />
:* https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489&start=75<br />
:* http://www.bootc.net/projects/raspberry-pi-kernel/<br />
:* http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-recompile.html<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-cross-compile.html<br />
:* http://www.gtkdb.de/index_36_2087.html<br />
<br />
* extract kernel config from image:<br />
::<code>scripts/extract-ikconfig kernel-image</code><br />
::(extract-ikconfig is part of the kernel sources)<br />
<br />
===Device Trees===<br />
<br />
:* http://www.raspberrypi.org/documentation/configuration/device-tree.md<br />
:* https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt<br />
<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=97216<br />
:* http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f<br />
:* http://www.forum-raspberrypi.de/Thread-tutorial-geraetetreiber-und-device-tree-dt (German)<br />
<br />
:* http://xillybus.com/tutorials/device-tree-zynq-1<br />
<br />
===What about updates?===<br />
<br />
As I always forget this<br />
* <code>apt-get update</code> - update package lists<br />
* <code>apt-get upgrade</code> - upgrade installed packages<br />
* <code>rpi-update</code> - update kernel and modules<br />
::use <code>SKIP_KERNEL=1 rpi-update</code> to update the RPi firmware, but keep the current kernel<br />
::set <code>SKIP_REPODELETE=1</code> to keep downloaded files (by default: <code>/root/.rpi-firmware</code>)<br />
<br />
Kernel Sources<br />
* https://github.com/notro/rpi-source gets the source data from https://github.com/Hexxeh/rpi-firmware and https://github.com/raspberrypi/linux/<br />
<br />
<br />
==Attaching a LCD display==<br />
<br />
===Wiring and Specs===<br />
<br />
* Specs ftp://imall.iteadstudio.com/IM120424018_EONE_2004_Characters_LCD/SPE_IM120424018_EONE_2004_Characters_LCD.pdf<br />
<br />
* http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display (German)<br />
<br />
* http://www.pro-linux.de/artikel/2/1624/5,die-anzeige-hardware-und-software.html<br />
<br />
* https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring<br />
<br />
* https://github.com/perryflynn/raspberrypi-misc/tree/master/charlcd_4x20_cmd<br />
<br />
* http://obrazki.elektroda.pl/5028699400_1384164963.jpg<br />
<br />
===Misc===<br />
<br />
* http://www.makerspaceuk.com/lcd-temp-sensor/<br />
<br />
* http://anwendungsentwickler.ws/blog/kategorien/raspberry-pi/4x20-lcd-screen-mit-dem-raspberry-pi.html (German)<br />
<br />
==Controlling the display==<br />
<br />
* Python [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO]<br />
<br />
===LCDProc hints===<br />
<br />
* Pi & GPIO powered HD44780 LCD: http://www.boeeerb.co.uk/pi-lcd/<br />
<br />
* https://metacpan.org/pod/Net::LCDproc<br />
<br />
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=63412<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-user.html<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-dev.html<br />
<br />
* http://tuxgraphics.org/electronics/200504/article375.shtml<br />
<br />
==Todo and Miscellaneous==<br />
<br />
<br />
===Collection of stuff to check - things I might) try sometime===<br />
<br />
* http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/<br />
<br />
* [http://en.wikipedia.org/wiki/F2FS f2fs]<br />
:* [http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=65330 F2fs, Ext4, FAT USB Benchmark]<br />
:* [http://forum.xda-developers.com/showthread.php?t=2697069 File System Performance: F2FS vs EXT4]<br />
<br />
* https://github.com/yuraa/Raspberry-Pi-Heartbeat<br />
<br />
* http://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html<br />
<br />
* [http://www.raspberrypi.org/archives/5282 Mathematica on Raspberry Pi, for free]<br />
:* also works in RasPi emulator, e.g. http://www.heise.de/ct/inhalt/2014/7/160/ (German, teaser to article)<br />
<br />
* NAS/Samba<br />
:* 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:<br />
:<code>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536</code><br />
<br />
* http://linuxtortures.blogspot.fr/2012/06/cross-compiling-and-cross-debugging-c.html<br />
<br />
===Things done===<br />
<br />
* Adjust swap file (size, location -> (ext4) HDD - too slow?): http://manpages.ubuntu.com/manpages/hardy/man8/dphys-swapfile.8.html<br />
<br />
* http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/<br />
<br />
==Some links (aka bookmark lists)==<br />
<br />
Project sites<br />
<br />
* [http://www.cl.cam.ac.uk/projects/raspberrypi/ University of Cambridge / Raspberry Pi Computer Laboratory]<br />
* [https://www.raspiprojekt.de/ raspiprojek] (German)<br />
* http://www.vanheusden.com/misc/rpi.php<br />
<br />
Blogs, forums, etc<br />
* http://www.raspberrypi.org/phpBB3/<br />
* [http://forum.stmlabs.com/forumdisplay.php?fid=6 Stm Labs Forum / Raspbmc]<br />
* [http://www.welzels.de/blog/projekte/raspberry-pi/ Wel!s Blog] (German)<br />
* [http://jankarres.de/category/raspberry-pi/ Raspberry Pi Blog of Jan Karres] (German)<br />
* http://www.forum-raspberrypi.de/ /(German)<br />
* http://raspberrycenter.de/ (German)<br />
<br />
* [[wikipedia:Raspberry_Pi Raspberry Pi in Wikipedia]]<br />
<br />
Miscellaneous<br />
<br />
* [http://www.raspberrypi.org/downloads New Out Of Box Software (Recommended)]<br />
* [http://elinux.org/R-Pi_Hub R-Pi_Hub]<br />
<br />
Manuals<br />
<br />
* https://github.com/raspberrypi/documentation<br />
<br />
* [http://debian-handbook.info/browse/stable/ The Debian Administrator's Handbook]</div>Holyheadhttps://holyhead.de/index.php?title=Raspberry_PiRaspberry Pi2015-02-10T05:53:38Z<p>Holyhead: /* Reminders: dd, dd_rescue, losetup, mount and others */</p>
<hr />
<div>==Cookbook==<br />
<br />
My collection of hints, tips and tricks (supporting my memory and maybe also helping others).<br />
<br />
===External USB drives===<br />
<br />
* Automount USB-Drives in Raspbian<br />
** One may use [http://selfprogramming.bplaced.net/index.php/2012/10/23/automount-usb-drives-in-raspbian/ USBmount and autofs]<br />
** I prefer [http://ignorantguru.github.io/udevil/ udevil], see below<br />
<br />
* Install ''ntfs-3g'' if you need write access to ntfs file systems<br />
<br />
* How to increase performance?<br />
** Mount with option ''''noatime'''' or ''''relatime''''<br />
** Mount ''without'' option sync (e.g. keep default async)<br />
** If using ntfs-3g (fuse) file system, try mounting with option 'big_writes', see for example http://obihoernchen.net/wordpress/tag/big_writes/<br />
<br />
===[http://ignorantguru.github.io/udevil/ udevil]===<br />
<br />
* example for manual mounting:<br />
<br />
udevil mount /dev/sda1<br />
<br />
* auto-mounting via udev-rule, see for example http://lsdlinux.org/wiki/doku.php?id=auto_mounting#using_udev_rule (I just copied the 95-udevil-mount.rules file from an OpenElec installation (http://www.raspberrypi.org/downloads) )<br />
<br />
* my build-steps (maybe there's a simpler way, but this worked...):<br />
** download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget<br />
** extract deb-package via <code>ar vx udevil_0.4.3-1_all.deb</code><br />
** extract data archive <code>tar xzvf data.tar.gz</code><br />
** change to tar usr/share/devil/src<br />
** untar <code>tar xvfJ udevil-current.tar.xz</code><br />
** <code>cd udevil-0.4.3</code><br />
** <code>mv distros/debian</code><br />
** execute <code>dpkg-buildpackage</code><br />
** 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<br />
** Install via <code>sudo dpkg -i udevil_0.4.3-1_armhf.deb</code><br />
<br />
===Samba server / NAS===<br />
<br />
* How to install?<br />
** [http://jankarres.de/2013/11/raspberry-pi-samba-server-installieren/ | Raspberry Pi: Samba Server installieren] (German)<br />
** [http://www.welzels.de/blog/projekte/raspberry-pi/low-budget-nas-mit-einem-raspberry-pi/ Low Budget NAS mit einem Raspberry PI] (German)<br />
<br />
* Slow disc performance?<br />
** see 'Slow USB drives' above<br />
** 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!)<br />
<br />
* Configuration and tuning<br />
** https://calomel.org/samba.html<br />
** https://calomel.org/samba_optimize.html<br />
<br />
* If your /var/log/samba/log.smbd fills up with ''printing/print_cups.c:110(cups_connect) Unable to connect to CUPS server localhost'' messages, try http://www.sotechdesign.com.au/samba-log-showing-error-failed-to-retrieve-printer-list/<br/>I also created an empty <code>/etc/printcap</code> to avoid ''Unable to open printcap file /etc/printcap for read'' messages.<br />
<br />
* I don't need sound:<br />
<br />
root@pi ~ # cat /etc/modprobe.d/snd-blacklist.conf <br />
# I don't need sound<br />
blacklist snd<br />
blacklist snd_pcm<br />
blacklist snd_soc_core<br />
blacklist snd_soc_bcm2708_i2s<br />
<br />
===Trying to reduce number of disk writes (SD card)===<br />
<br />
I'm using [http://oss.oetiker.ch/rrdtool/ 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).<br />
<br />
Here's what I've done:<br />
<br />
* Edit <code>/etc/default/cron</code> and set <code>EXTRA_OPTS="-L 0"</code> to disable logging (I don't need these)<br />
* Avoid entries like <code>pam_unix(cron:session): session closed for user pi</code> in <code>/var/log/auth.log</code><br />
** Edit <code>/etc/pam.d/cron</code> and comment the line <code>@include common-session-noninteractive</code> ([http://ubuntuforums.org/showthread.php?t=1256801])<br />
:or<br />
:* Edit <code>/etc/pam.d/common-session-noninteractive</code> as shown here: http://ubuntuforums.org/showthread.php?t=1256801&p=10283830#post10283830<br />
* I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)<br />
** moved all the .rrd files as well as the created images to my persistent-ramdisk location<br />
** moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links<br />
*** <code>/var/spool</code><br />
*** <code>/var/log</code><br />
*** <code>/var/cache/samba</code><br />
** edited <code>/etc/insserv.conf</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:<br />
<br />
$local_fs_orig +mountall +mountall-bootclean +mountoverflowtmp +umountfs<br />
# we need the sym-link data in /var/log and /var/spool to be available<br />
$local_fs $local_fs_orig +persist-ramdisk<br />
<br />
:: <code>/etc/init.d/persist-ramdisk</code> 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.<br />
<br />
:* set ''RAMTMP'' to yes in <code>/etc/default/tmpfs</code> to get tempfs based <code>/tmp</code><br />
<br />
Before changing <code>/tmp</code>:<br />
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').<br />
::I need to do more digging...<br />
<br />
After changing <code>/tmp</code>:<br />
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...<br />
<br />
===Useful stuff and Q&A===<br />
<br />
* Q: Why does my Pi restart when hotplugging a USB drive?<br />
** http://thestuffsido.blogspot.de/2013/05/fixing-raspberry-pi-hotplugging.html<br />
** http://therandomlab.blogspot.de/2013/01/raspberry-pi-mod-to-avoid-shutdown-on.html<br />
<br />
* Q: Does Raspberry support WOL?<br />
: A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)<br />
<br />
* Q: The new password is to short, or too simple<br />
: A: Try adjusting the PAM settings in <code>/etc/pam.d/common-password</code>:<br />
:* remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)<br />
::<code>password [success=1 default=ignore] pam_unix.so sha512 minlen=2</code><br />
<br />
::!! This is not recommended if your box is connected to the internet or if it contains private data noone should know !!<br><br />
::But it's nice for testing (if you cannot or do not want to use auto-login.)<br />
<br />
* Q: How to configure static IP?<br />
: A: In /etc/network/interfaces:<br />
::<code>iface eth0 inet static<br>address 192.168.0.31<br>netmask 255.255.255.0<br>gateway 192.168.0.1</code><br />
<br />
* Q: How to read core temperature, etc?<br />
: A: [http://elinux.org/RPI_vcgencmd_usage vcgencmd]:<br />
::<code>vcgencmd measure_temp<br>vcgencmd measure_clock arm</code><br />
<br />
* External USB HDD spin down<br />
** hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)<br />
** hd-idle works:<br />
::<code>hd-idle -a sda -i 600</code><br />
:: for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)<br />
<br />
* Q: How to avoid update of a certain package?<br />
: A: Put package on hold ([http://debiananwenderhandbuch.de/dpkg.html] (German)):<br />
::<code>echo <packagename> "hold" | dpkg --set-selections</code><br />
<br />
* [[wikipedia:Raspcontrol]] with nginx<br />
** http://www.foxplex.com/sites/raspcontrol-webinterface-auf-dem-raspberry-pi/ (German), http://www.foxplex.com/sites/performanter-nginx-webserver-auf-dem-raspberry-pi-mit-php-und-apc/ (German)<br />
** http://menzerath.eu/artikel/raspberry-pi-raspcontrol-installation-funktionen/ (German)<br />
<br />
* Q: How many bytes are written to my (SD) disc?<br />
: A: Use <code>iostat</code> http://www.mybinarylife.net/2012/08/linux-iostat-command.html<br />
: A: Use <code>iotop</code> http://guichaz.free.fr/iotop/<br />
: A: Raw data of the kernel can be found in files <code>/proc/diskstats</code> and <code>/sys/block/DEVNAME/stat</code> https://www.kernel.org/doc/Documentation/iostats.txt<br />
:* http://unix.stackexchange.com/questions/86391/how-to-get-total-number-of-bytes-sectors-blocks-written-to-disk-since-booting<br />
:* http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux<br />
<br />
* Q: How to reduce number of ext-fs checks?<br />
: A: <code>tune2fs -c 60 /dev/sda1</code> Change maximum mount count to 60<br />
: A: <code>tune2fs -i 12m /dev/sda1</code> Change check interval to 12 months<br />
: fore more details: http://wiki.ubuntuusers.de/Dateisystemcheck (German)<br />
<br />
===Overclocking===<br />
<br />
* I only set overclocking via <code>raspi-config</code><br />
<br />
* ''Turbo'': (Short) Raspberry stress test were ok. But I got an SD card error/corruption when doing a download and a dd-image of the SD card (according to http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907 the SD card error could be OC related.)<br />
::Luckily, I could recover all my data, see below.<br />
<br />
* '' Medium'': Raspberry is stable. I've observed two file system corruption which might be related to overclocking (see [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=57907] and its links).<br />
<br />
* Underclocking to 600 MHz<br />
:<code>echo "600000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq</code><br />
: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.<br />
<br />
* Adjusting the ondemand-governor<br />
** https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt<br />
** set <code>/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor</code> to 10 [http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&start=800]<br />
**: I had hoped this reduces the 1-wire CRC errors/device-disconnects problems, but with heavy (IO-) load (e.g. backup), 1wire sensors still get disconnected.<br />
<br />
* [http://moze.free.fr/blog/index.php?post/2013/02/Underclock-and-Overclock Nice power consumption analysis]<br />
<br />
====Stress test and benchmarks====<br />
<br />
* [http://www.roylongbottom.org.uk/ Roy Longbottom's PC Benchmark Collection]<br />
* [http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm Raspberry Pi Stress Tests]<br />
<br />
===SD card issues===<br />
<br />
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). I could still use this card for some time (see below), but finally I got a corrupted file system and could no longer repair it. That's when I re-installed Raspbian on a new SD card.<br />
<br />
Maybe I should try [http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ running from USB] sometime?<br />
<br />
====Recovery====<br />
* Creating a binary image of the SD card with my PC using [http://sourceforge.net/projects/win32diskimager/ Win32 Disk Imager] resulted in IO errors at about 17%.<br />
* 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 <code>dd conv=sync,noerror if=/dev/sdb2 of=rasp-image.img bs=1M</code> on my Linux machine (option <code>conv=noerror</code> ignores any errors, sync pads read-errors with zeros). The resulting image could not be mounted using a loop device. <br />
* Fortunately, <code>fsck.ext4 raspberry-image.bin</code> was able to repair the image, which I then could successfully mount on my Linux machine using <code>mount -o loop rasp-image.img /mnt</code>, and at a first glance, everything looked ok. So, I was at least able to get to my data. <br />
* On a later 'event', I dd-ed the repaired image back to the Raspberry, and could boot again.<br />
* On another a later 'event', I just fsck-ed the /dev/sdb2 using Linux, and could boot again... but I did not have luck this time - some files were gone.<br />
* 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.<br />
* My Raspberry successfully booted from this new image. I then used <code>raspi-config</code> to expand the root-fs (I've done this on my first installation as well). With Linux I was able to <code>dd</code> my repaired image to the repaired SD. The card booted as if nothing had happened...<br />
* But after some weeks, my Raspberry fried the SD card again, and some weeks later again ... And finally I could not get my pi to boot with this card. However, I can still read the data linux. Moving data to a new card... (easier said than done if the new card is slightly smaller... but, see below for resizing... and sometimes a fresh install is even less painful).<br />
<br />
===Reminders: dd, dd_rescue, losetup, mount and others===<br />
* Example partition table printed by fdisk:<br />
<code><br />
/dev/sdb: 7861 MB, 7861174272 bytes, 15353856 sectors<br />
Units = Sektoren of 1 * 512 = 512 bytes<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
<br />
Gerät boot. Anfang Ende Blöcke Id System<br />
[...]<br />
/dev/sdb3 15288320 15353855 32768 83 Linux</code><br />
Byte-offset of sdb3: 7827619840 = 15288320 * 512<br />
<br />
* Mount partition to /dev/loopN partition for repair, etc.<br />
:<code>losetup -o 7827619840 --find --show /dev/sdb</code><br />
:--show prints the used /dev/loopN device<br />
<br />
* Directly mount partition using loop device:<br />
:<code>mount -o loop,offset=7827619840 /dev/sdb /mnt</code><br />
* http://www.garloff.de/kurt/linux/ddrescue/<br />
* http://softwarebakery.com/shrinking-images-on-linux<br />
* http://www.tehfear.com/2007/10/08/resize-loop-disk-image/<br />
* http://wiki.ubuntuusers.de/dd (German)<br />
* http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device<br />
<br />
===Some 1-Wire Stuff===<br />
<br />
====Temperature Sensor DS1820====<br />
<br />
* How to?<br />
** http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/<br />
** https://www.raspiprojekt.de/anleitungen/schaltungen/9-1wire-mit-temperatursensor-ds18b20.html?showall=&start=1 (German)<br />
** http://kopfkino.irosaurus.com/tutorial-ds18s20-temperatur-sensor-an-einem-raspberry-pi/ (German)<br />
** http://raspberrywebserver.com/cgiscripting/rpi-temperature-logger/<br />
** http://elinux.org/RPi_Low-level_peripherals<br />
<br />
* I have two DS18B20 and log temperatures using rrdtool.<br />
<br />
* 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). <br />
** Q: Is this due to overclocking with using dynamic governor?<br />
** A: No - also occurs without overclocking (but less frequent?)<br />
** Q: Or is this due to voltage-problems?<br />
** A: No - also occurs without over-voltage<br />
** Q: Or something else?<br />
** 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). Using 3 sensors works almost all the time (without overclocking), but using 4 or more sensors (2 connected star topologies, very bad for 1-wire [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]), almost always fails to read values on most of the sensors.<br />
** A:'''Implement multiple 1-wire interfaces''' (see below), using 1 for each star-topology solved the problem. Reading 2x3 works perfect!<br />
<br />
====Multiple 1-wire buses====<br />
:* Inspired and guided by http://www.raspberrypi.org/forums/viewtopic.php?p=513312#p513312, I've patched my 3.12.y kernel <code>arch/arm/mach-bcm2708/bcm2708.c</code> (patch file http://holyhead.de/RaspberryPi/bcm2708-multiple_w-1.patch-3.12.21.txt).<br />
::* Note: With kernel version, device tree were introduced, see for example http://www.raspberrypi.org/documentation/configuration/device-tree.md<BR>But somehow 1-wire works for my 3.18.5+ without specifying any dtoverlays... And all tries to configure w1-gpio-overlay.dtb via config.txt resulted in my Raspberry not booting (I also tried a modified w1.dtb which should also handle my second w1-bus).<br />
:* I've cross-compiled the kernel on a linux-VM, using the instructions of http://elinux.org/RPi_Kernel_Compilation (compiling on the RaspberryPi takes 6 hours [http://wiki.gentoo.org/wiki/Raspberry_Pi_Kernel_Compilation] or much more [http://elinux.org/RPi_Kernel_Compilation]).<br />
<br />
====Some 1-wire internals====<br />
* https://www.kernel.org/doc/Documentation/w1/w1.generic<br />
* [http://www.maximintegrated.com/en/app-notes/index.mvp/id/148 GUIDELINES FOR RELIABLE LONG LINE 1-WIRE NETWORKS]<br />
* http://blog.gegg.us/2013/03/4-different-methods-of-1-wire-access-on-raspberry-pi/<br />
<br />
===Compiling own kernel===<br />
<br />
* Some hints on cross-compiling:<br />
:* http://elinux.org/RPi_Kernel_Compilation<br />
:* https://github.com/raspberrypi/linux/tree/rpi-3.12.y/arch/arm/mach-bcm2708<br />
:* https://github.com/notro/rpi-source/wiki<br />
:* https://github.com/notro/rpi-source/wiki/Examples-on-how-to-build-various-modules<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489&start=75<br />
:* http://www.bootc.net/projects/raspberry-pi-kernel/<br />
:* http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-recompile.html<br />
:* http://www.satsignal.eu/raspberry-pi/kernel-cross-compile.html<br />
:* http://www.gtkdb.de/index_36_2087.html<br />
<br />
* extract kernel config from image:<br />
::<code>scripts/extract-ikconfig kernel-image</code><br />
::(extract-ikconfig is part of the kernel sources)<br />
<br />
===Device Trees===<br />
<br />
:* http://www.raspberrypi.org/documentation/configuration/device-tree.md<br />
:* https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt<br />
<br />
:* http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=97216<br />
:* http://raspberrypi.stackexchange.com/questions/27073/firmware-3-18-x-breaks-i2c-spi-audio-lirc-1-wire-e-g-dev-i2c-1-no-such-f<br />
:* http://www.forum-raspberrypi.de/Thread-tutorial-geraetetreiber-und-device-tree-dt (German)<br />
<br />
:* http://xillybus.com/tutorials/device-tree-zynq-1<br />
<br />
===What about updates?===<br />
<br />
As I always forget this<br />
* <code>apt-get update</code> - update package lists<br />
* <code>apt-get upgrade</code> - upgrade installed packages<br />
* <code>rpi-update</code> - update kernel and modules<br />
::use <code>SKIP_KERNEL=1 rpi-update</code> to update the RPi firmware, but keep the current kernel<br />
::set <code>SKIP_REPODELETE=1</code> to keep downloaded files (by default: <code>/root/.rpi-firmware</code>)<br />
<br />
Kernel Sources<br />
* https://github.com/notro/rpi-source gets the source data from https://github.com/Hexxeh/rpi-firmware and https://github.com/raspberrypi/linux/<br />
<br />
<br />
==Attaching a LCD display==<br />
<br />
===Wiring and Specs===<br />
<br />
* Specs ftp://imall.iteadstudio.com/IM120424018_EONE_2004_Characters_LCD/SPE_IM120424018_EONE_2004_Characters_LCD.pdf<br />
<br />
* http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display (German)<br />
<br />
* http://www.pro-linux.de/artikel/2/1624/5,die-anzeige-hardware-und-software.html<br />
<br />
* https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/wiring<br />
<br />
* https://github.com/perryflynn/raspberrypi-misc/tree/master/charlcd_4x20_cmd<br />
<br />
* http://obrazki.elektroda.pl/5028699400_1384164963.jpg<br />
<br />
===Misc===<br />
<br />
* http://www.makerspaceuk.com/lcd-temp-sensor/<br />
<br />
* http://anwendungsentwickler.ws/blog/kategorien/raspberry-pi/4x20-lcd-screen-mit-dem-raspberry-pi.html (German)<br />
<br />
==Controlling the display==<br />
<br />
* Python [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO]<br />
<br />
===LCDProc hints===<br />
<br />
* Pi & GPIO powered HD44780 LCD: http://www.boeeerb.co.uk/pi-lcd/<br />
<br />
* https://metacpan.org/pod/Net::LCDproc<br />
<br />
* http://www.raspberrypi.org/forums/viewtopic.php?f=35&t=63412<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-user.html<br />
<br />
* http://lcdproc.sourceforge.net/docs/current-dev.html<br />
<br />
* http://tuxgraphics.org/electronics/200504/article375.shtml<br />
<br />
==Todo and Miscellaneous==<br />
<br />
<br />
===Collection of stuff to check - things I might) try sometime===<br />
<br />
* http://www.raspipress.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/<br />
<br />
* [http://en.wikipedia.org/wiki/F2FS f2fs]<br />
:* [http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=65330 F2fs, Ext4, FAT USB Benchmark]<br />
:* [http://forum.xda-developers.com/showthread.php?t=2697069 File System Performance: F2FS vs EXT4]<br />
<br />
* https://github.com/yuraa/Raspberry-Pi-Heartbeat<br />
<br />
* http://raspberrywebserver.com/serveradmin/back-up-your-pi-to-your-google-drive.html<br />
<br />
* [http://www.raspberrypi.org/archives/5282 Mathematica on Raspberry Pi, for free]<br />
:* also works in RasPi emulator, e.g. http://www.heise.de/ct/inhalt/2014/7/160/ (German, teaser to article)<br />
<br />
* NAS/Samba<br />
:* 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:<br />
:<code>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536</code><br />
<br />
* http://linuxtortures.blogspot.fr/2012/06/cross-compiling-and-cross-debugging-c.html<br />
<br />
===Things done===<br />
<br />
* Adjust swap file (size, location -> (ext4) HDD - too slow?): http://manpages.ubuntu.com/manpages/hardy/man8/dphys-swapfile.8.html<br />
<br />
* http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/<br />
<br />
==Some links (aka bookmark lists)==<br />
<br />
Project sites<br />
<br />
* [http://www.cl.cam.ac.uk/projects/raspberrypi/ University of Cambridge / Raspberry Pi Computer Laboratory]<br />
* [https://www.raspiprojekt.de/ raspiprojek] (German)<br />
* http://www.vanheusden.com/misc/rpi.php<br />
<br />
Blogs, forums, etc<br />
* http://www.raspberrypi.org/phpBB3/<br />
* [http://forum.stmlabs.com/forumdisplay.php?fid=6 Stm Labs Forum / Raspbmc]<br />
* [http://www.welzels.de/blog/projekte/raspberry-pi/ Wel!s Blog] (German)<br />
* [http://jankarres.de/category/raspberry-pi/ Raspberry Pi Blog of Jan Karres] (German)<br />
* http://www.forum-raspberrypi.de/ /(German)<br />
* http://raspberrycenter.de/ (German)<br />
<br />
* [[wikipedia:Raspberry_Pi Raspberry Pi in Wikipedia]]<br />
<br />
Miscellaneous<br />
<br />
* [http://www.raspberrypi.org/downloads New Out Of Box Software (Recommended)]<br />
* [http://elinux.org/R-Pi_Hub R-Pi_Hub]<br />
<br />
Manuals<br />
<br />
* https://github.com/raspberrypi/documentation<br />
<br />
* [http://debian-handbook.info/browse/stable/ The Debian Administrator's Handbook]</div>Holyhead