====== Raspberry PI ====== {{:embarcados:raspberry_pi_radio.pdf|}}\\ [[http://elinux.org/RPi_Beginners]] \\ ==== How to install XRDP and have it working ==== [[http://c-nergy.be/blog/?p=5357]] \\ [[http://c-nergy.be/blog/?p=5874]] \\ sudo apt-get update sudo apt-get install xrdp ===== Warnings Square ===== [[https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=82373]]\\ **Currently the symbols are:**\\ **Red square:** over-temperature\\ **Rainbow square:** under-voltage\\ \\ As usual you can override the behaviour in ''config.txt'' if you understand the risks:\\ **avoid_warnings=1** removes the warning overlay.\\ **avoid_warnings=2** additionally allows turbo when low-voltage is present. ===== Windows Emulador ===== [[http://sourceforge.net/projects/rpiqemuwindows/]] ===== config.txt ===== [[http://www.raspberrypi.org/documentation/configuration/config-txt.md]] ===== Basic Raspbian Setup ===== When you first turn on your Raspberry Pi with it's fresh Debian image on the SD card, you will likely want to tweak the system settings. Luckily, there's a tool called raspi-config which makes everything super-easy to set up. This automatically launches when you first boot Raspbian up, and (for the most part) it is in plain English.\\ \\ If you want to access the setup screen again, just type: sudo raspi-config in the terminal (LXTerminal in the desktop UI). ===== Manually resizing the SD card on Raspberry Pi ===== You can also resize the partitions of the SD card that your Pi is running on.\\ \\ First you need to change the partition table with fdisk. You need to remove the existing partition entries and then create a single new partition than takes the whole free space of the disk. This will only change the partition table, not the partitions data on disk. The start of the new partition needs to be aligned with the old partition!\\ \\ Start fdisk :\\ sudo fdisk /dev/mmcblk0 Then delete partitions with d and create a new with n. You can view the existing table with p.\\ \\ * p to see the current start of the main partition * d, 3 to delete the swap partition * d, 2 to delete the main partition * n p 2 to create a new primary partition, next you need to enter the start of the old main partition and then the size (enter for complete SD card). The main partition on the Debian image from 2012-04-19 starts at 157696, but the start of your partition might be different. Check the p output! * w write the new partition table Now you need to reboot:\\ sudo shutdown -r now After the reboot you need to resize the filesystem on the partition. The resize2fs command will resize your filesystem to the new size from the changed partition table.\\ sudo resize2fs /dev/mmcblk0p2 This will take a few minutes, depending on the size and speed of your SD card.\\ When it is done, you can check the new size with: df -h ===== vcgencmd usage ===== [[http://elinux.org/RPI_vcgencmd_usage]] ===== Epiphany Browser ===== [[https://git.gnome.org/browse/epiphany/]] MODO ANTIGO **1.** Install epiphany-browser, x11-xserver-utils and unclutter sudo apt-get update && apt-get upgrade -y sudo apt-get install epiphany-browser x11-xserver-utils unclutter **2.** We need to prevent screen from going blank and disable screen saver. – edit ''/etc/xdg/lxsession/LXDE/autostart'' and comment # ''screen saver'' line and add those lines: @xset s off @xset -dpms @xset s noblank @epiphany-browser --profile=/home/pi/ephy -a http://some.web. Done. ===== Raspbian Repository ===== [[http://www.raspbian.org/RaspbianRepository]] The ''/etc/apt/sources.list'' file contains the information needed to install additional software packages on your Raspberry Pi from the Raspbian repository. This file should contain the following information: deb http://archive.raspbian.org/raspbian wheezy main contrib non-free deb-src http://archive.raspbian.org/raspbian wheezy main contrib non-free If needed, the Raspbian public key can be stored into your apt-get keyring using the following command: wget http://archive.raspbian.org/raspbian.public.key -O - | sudo apt-key add - ===== Raspberry PI kiosk mode with Chromium ===== [[http://lokir.wordpress.com/2012/09/16/raspberry-pi-kiosk-mode-with-chromium/]] \\ [[http://superuser.com/questions/873381/how-can-i-disable-the-chromium-didn-t-shut-down-correctly-message-when-my-brow]] \\ [[http://superuser.com/questions/237608/how-to-hide-chrome-warning-after-crash]] MODO ANTIGO **1.** Install chromium, x11-xserver-utils and unclutter sudo apt-get update && apt-get upgrade -y sudo apt-get install chromium x11-xserver-utils unclutter **2.** Here they talk about running this command before starting Chrome to stop the Restore Bar from appearing: sed -i 's/"exited_cleanly": false/"exited_cleanly": true/' \ ~/.config/chromium/Default/Preferences **3.** We need to prevent screen from going blank and disable screen saver. – edit ''/etc/xdg/lxsession/LXDE/autostart'' and comment # ''screen saver'' line and add those lines: @xset s off @xset -dpms @xset s noblank @chromium --kiosk --incognito --disable-infobars http://some.web. Done. ===== fullscreen xinit ===== [[http://superuser.com/questions/538367/fullscreen-xinit-raspberry-pi]]\\ ''~/.config/chromium/Default/Preferences'' "window_placement": { "bottom": 1080, "left": 0, "maximized": true, "right": 1920, "top": 0, "work_area_bottom": 1080, "work_area_left": 0, "work_area_right": 1920, "work_area_top": 0 } The ''maximized'' option may not work, since I suppose you are not using a Window Manager, but you can see that the properties ''bottom'', ''left'', ''right'', ''top'', ''work_area_bottom'', ''work_area_left'', ''work_area_right'' and ''work_area_top'', refer to the size and position of the window. So play around with your own screen size and that should work. ===== Raspberry PI kiosk mode with Epigraphy Browser ===== [[http://blog.qruizelabs.com/2014/04/29/raspberrypi-kiosk-matchbox-uzbl/]] MODO ATUAL\\ **Epigraphy Browser** + **matchbox** - **Auto Log-in:** nodm - **Auto X start:** we use a simple __.xsession__ file - **Window Manager:** We’ll be using the full awesomeness of __matchbox__ - **Browser:** Epigraphy Browser - **Splash screen:** __fbi__. Yea I know how that sounds. :P ==== 1. Logging in automatically ==== This is optional. You can have a simple username/password prompt or nothing at all. But we’ll discuss automatically logging in without username and password. For this, we need nodm, which is a tool that does just that. sudo apt-get install nodm -y Now we need to start nodm at boot and configure the user that nodm will log in as. Edit **/etc/default/nodm** file sudo nano /etc/default/nodm NODM_ENABLED=true NODM_USER=pi It’s all self explanatory. First one says enable nodm at boot. Second one says log in as ‘pi’ user. Simple enough. ==== 2. Installing the Window Manager ==== Window managers, well, manage windows. They take care of size, positioning and tiling of window objects on the screen. We’ll be using matchbox to get our kiosk web browser to open in a full screen window. sudo apt-get install -y matchbox-window-manager This will install the Matchbox window manager, which is a specialized window manager written for resource restricted hardware like – you guessed it – Raspberry Pi. It’s fast, it’s lightweight, it’s effective and it does its job without complaining. Perfect. ==== 3. Installing the Web Browser ==== sudo apt-get install epiphany-browser The most important part of the kiosk is the web browser. It makes our kiosk, a kiosk. And we are going to load only a single website. Therefore it’s wise to stick to something lightweight. Chromium-browser and Firefox are overkills for this kind of job since they devour a ton of system resources. Hence we use a browser called uzbl ( pronounced “usable”. Naming skills, yea? ). This little beast is very versatile and extremely configurable. It is also super lightweight and very forgiving towards system resources. So let’s install it: ''sudo apt-get -y install uzbl'' ==== 4. Putting it all together ==== Now we need to make sure 1. The system boots and pi user logs in automatically (we’ve done that already), 2. The Window manager starts and 3. The web browser starts in full screen. We’ll be using an xsession file to do that. Note: You must have xinit installed. If not, install it sudo apt-get -y install xinit Create a new file ‘.xsession’ in the home directory /home/pi. That’s .xsession with a dot in the beginning (A hidden file in the UNIX world). Put the following content in it. mkdir /home/pi/ephy #!/bin/bash xset s off xset -dpms xset s noblank epiphany-browser --profile=/home/pi/ephy -a file:///home/pi/www/index.html & exec matchbox-window-manager -use_titlebar no #uzbl -u http://google.com/ -c /home/pi/uzbl.conf & exec matchbox-window-manager -use_titlebar no #chromium-browser --use-gl=egl That’s it. Save and close the file. What we have done is to start the uzbl browser during boot along with the Matchbox window-manager. The u stands for uri and the c stands for configuration file. uzbl uses the configuration file to lookup settings and apply them to itself. We are now going to create a configuration file to try and force uzbl to do two things 1. Not display it’s status bar and 2. Open in a maximized window. Go ahead and create **/home/pi/uzbl.conf** and put the following content in it: set show_status=0 set geometry=maximized Save it and close it. If you need help with uzbl, check this out: https://wiki.archlinux.org/index.php/UZBL-Browser\\ \\ To make the browser restart automatically if it crashes (it shouldn’t), put this in the .xsession file:\\ '' #!/bin/bash while true; do uzbl -u http://google.com/ -c /home/pi/uzbl.conf &; exec matchbox-window-manager -use_titlebar no; sleep 2s; done ''\\ The **-use_titlebar** no part is to make Matchbox window manager hide the titlebar. Reboot and check if everything is working as it should. If you get stuck in the terminal, you’ve messed up with the **.xsession** file. Recheck it. Type ‘startx‘ to start the X Window to see if it works. ==== 5. Splash screen ==== How can it be complete without a splash screen? So get a nice splash screen image – preferably in PNG fomat – and put it under **/etc/** directory. Let’s call it **mycoolimage.png**. Then install **fbi** sudo apt-get install -y fbi Fbi is a FrameBuffer Image viewer. Basically it’s something that let’s you view images even before the nuts and bolts of the operating system that enables you to view images are actually loaded. So it’s kindofacoolthing. Now create a new file called ''aaa'' under **/etc/init.d** directory as root. (use sudo) We want it to begin with ''a'' so that it can load early on (no kidding). Put the following content in it. #!/bin/sh do_start () { /usr/bin/fbi -T 1 -noverbose -a /etc/mycoolimage.png exit 0 } case "$1" in start) do_start ;; restart|reload|force-reload) echo "You can't do that" >&2 exit 3No-op ;; stop) # Nothing here. Move on. ;; status) exit 0 ;; *) echo "Script to show splash screen " >&2 exit 3 ;; esac : Make the file executable and make the system recognize it as an init script sudo chmod a+x /etc/init.d/aaa sudo insserv /etc/init.d/aaa We’re done. Check everything and reboot. Does it work? Sweet!\\ \\ **Bonus tips:** You can get rid of the crazy log tsunami that you get when you load the Pi for the first time. You can also make the fruit disappear. (Fruit lovers, please forgive). Open **/boot/cmdline.txt** and do the following changes: (without the quotes of course)\\ \\ **1.** Locate the section that says ''console=tty1'' and make it ''console=tty''. This pushes the logs to the fourth virtual terminal\\ **2.** Add a space in the end and add ''loglevel=3''. This sets the severity of the logging level to ''warning and above''.\\ **3.** Add a space in the end of the line and add ''logo.nologo''. That’s logonologo that – you guessed it – hides the little raspberry fruit logo.\\ **4.** Set the following directives in the file **/etc/kbd/config** (This prevents the screen from going to sleep)\\ BLANK_TIME=0 POWERDOWN_TIME=0 ==== 6. Disable Black Screen ==== xset -dpms # disable DPMS (Energy Star) features. xset s off # disable screen saver xset s noblank # don't blank the video device ===== Custom boot up screen ===== [[http://www.raspberry-projects.com/pi/pi-operating-systems/raspbian/custom-boot-up-screen]] MODO ATUAL Displaying an image during boot instead of the default command line scrolling text\\ This is based on the guide here. \\ This solution works but there are a few seconds of text shown before the boot image appears.\\ Install fbi sudo apt-get install fbi Copy the splashscreen image to be used\\ Copy your custom splash image into: ''/etc/'' and name it **"splash.png"**.\\ Presumably the resolution to use is 1920x1080px.\\ Create A Script sudo nano Paste the following into the text editor: #!/bin/sh ### BEGIN INIT INFO # Provides: asplashscreen # Required-Start: # Required-Stop: # Should-Start: # Default-Start: S # Default-Stop: # Short-Description: Show custom splashscreen # Description: Show custom splashscreen ### END INIT INFO do_start () { /usr/bin/fbi -T 1 -noverbose -a /etc/splash.png exit 0 } case "$1" in start|"") do_start ;; restart|reload|force-reload) echo "Error: argument '$1' not supported" >&2 exit 3 ;; stop) # No-op ;; status) exit 0 ;; *) echo "Usage: asplashscreen [start|stop]" >&2 exit 3 ;; esac : IMPORTANT – If copying and pasting via SSH check it has pasted in correctly (pasting via FiseSSH for us caused the # lines and the esac line to be altered and need modifying back to be correct) Exit and save the file as: ''/etc/init.d/asplashscreen'' (using a name starting with 'a' will ensure it runs first) Finally make the script ''executable'' and install it for init mode: sudo chmod a+x /etc/init.d/asplashscreen sudo insserv /etc/init.d/asplashscreen Thats it: sudo reboot ===== .xsession-errors file is huge. How can I disable? ===== [[http://askubuntu.com/questions/177058/xsession-errors-file-is-huge-how-can-i-disable]] There is a file called /etc/X11/Xsession. Which will create the symlink to a tmp file. IE. Starts on line number 61 ERRFILE=$HOME/.xsession-errors # attempt to create an error file; abort if we cannot if (umask 077 && touch "$ERRFILE") 2> /dev/null && [ -w "$ERRFILE" ] && [ ! -L "$ERRFILE" ]; then chmod 600 "$ERRFILE" elif ERRFILE=$(tempfile 2> /dev/null); then if ! ln -sf "$ERRFILE" "${TMPDIR:=/tmp}/xsession-$USER"; then message "warning: unable to symlink \"$TMPDIR/xsession-$USER\" to" \ "\"$ERRFILE\"; look for session log/errors in" \ "\"$TMPDIR/xsession-$USER\"." fi else errormsg "unable to create X session log/error file; aborting." fi You can cp this Xsession file to Xsession.bak. Then go a head and point your ERRFILE to /dev/null IE. Line 83 exec >> /dev/null 2>&1 ===== Raspberry Pi as Homeserver ===== [[http://www.stefan-seelmann.de/wiki/rasperrypi-homeserver]] Delete unused software packages, in reverse order of /var/log/apt/history.log, including automatically installed packages: # apt-get purge --auto-remove scratch # apt-get purge --auto-remove debian-reference-en dillo idle3 python3-tk idle python-pygame python-tk # apt-get purge --auto-remove lightdm gnome-themes-standard gnome-icon-theme raspberrypi-artwork # apt-get purge --auto-remove gvfs-backends gvfs-fuse desktop-base lxpolkit netsurf-gtk zenity xdg-utilse # apt-get purge --auto-remove mupdf gtk2-engines alsa-utils lxde lxtask menu-xdg gksu # apt-get purge --auto-remove midori xserver-xorg xinit xserver-xorg-video-fbdev # apt-get purge --auto-remove libraspberrypi-dev libraspberrypi-doc # apt-get purge --auto-remove dbus-x11 libx11-6 libx11-data libx11-xcb1 x11-common x11-utils # apt-get purge --auto-remove lxde-icon-theme gconf-service gconf2-common ===== Installing LIBCEC on Wheezy (tested on a Samsung TV, Panasonic Viera TV) ===== [[http://www.raspberrypi.org/forums/viewtopic.php?f=29&t=70923]] Step by step installation of the LIBCEC module on a Wheezy Rapberry. Start in the home directory cd /home Install the necessary tools for compiling: sudo apt-get install build-essential autoconf liblockdev1-dev libudev-dev git libtool pkg-config Clone the git repository: sudo git clone git://github.com/Pulse-Eight/libcec.git Compile: cd libcec sudo ./bootstrap sudo ./configure --with-rpi-include-path=/opt/vc/include --with-rpi-lib-path=/opt/vc/lib --enable-rpi sudo make sudo make install Link the libraries so that cec-client can find them: sudo ldconfig Check that cec-client have found the device by running: cec-client -l Found devices: 1 device: 1 com port: RPI vendor id: 2708 product id: 1001 firmware version: 1 type: Raspberry Pi To send commands to for instance a connected TV: Turn off TV: echo “standby 0” | cec-client -s