doc/README-raspberrypi.md
author Gabriel Jacobo <gabomdq@gmail.com>
Tue, 29 Jul 2014 09:20:12 -0300
changeset 9023 276802355854
permissions -rw-r--r--
Rearrange documentation

1) Moves all READMEs to docs/
2) Renames them to *.md, adds some Markdown with the idea to add a lot more
3) Moves the doxyfile config to doc/ and makes it parse the headers at ../include as well as the md files in docs.
4) Skips SDL_opengl*.h headers from the docs
5) Minor fixes to doxyfile
     1 Raspberry Pi
     2 ================================================================================
     3 
     4 Requirements:
     5 
     6 Raspbian (other Linux distros may work as well).
     7 
     8 ================================================================================
     9  Features
    10 ================================================================================
    11 
    12 * Works without X11
    13 * Hardware accelerated OpenGL ES 2.x
    14 * Sound via ALSA
    15 * Input (mouse/keyboard/joystick) via EVDEV
    16 * Hotplugging of input devices via UDEV
    17 
    18 ================================================================================
    19  Raspbian Build Dependencies
    20 ================================================================================
    21 
    22 sudo apt-get install libudev-dev libasound2-dev libdbus-1-dev
    23 
    24 You also need the VideoCore binary stuff that ships in /opt/vc for EGL and 
    25 OpenGL ES 2.x, it usually comes pre installed, but in any case:
    26     
    27 sudo apt-get install libraspberrypi0 libraspberrypi-bin libraspberrypi-dev
    28 
    29 ================================================================================
    30  Cross compiling from x86 Linux
    31 ================================================================================
    32 
    33 To cross compile SDL for Raspbian from your desktop machine, you'll need a
    34 Raspbian system root and the cross compilation tools. We'll assume these tools
    35 will be placed in /opt/rpi-tools
    36 
    37     sudo git clone --depth 1 https://github.com/raspberrypi/tools /opt/rpi-tools
    38 
    39 You'll also need a Rasbian binary image.
    40 Get it from: http://downloads.raspberrypi.org/raspbian_latest 
    41 After unzipping, you'll get file with a name like: <date>-wheezy-raspbian.img
    42 Let's assume the sysroot will be built in /opt/rpi-sysroot.
    43 
    44     export SYSROOT=/opt/rpi-sysroot
    45     sudo kpartx -a -v <path_to_raspbian_image>.img
    46     sudo mount -o loop /dev/mapper/loop0p2 /mnt
    47     sudo cp -r /mnt $SYSROOT
    48     sudo apt-get install qemu binfmt-support qemu-user-static
    49     sudo cp /usr/bin/qemu-arm-static $SYSROOT/usr/bin
    50     sudo mount --bind /dev $SYSROOT/dev
    51     sudo mount --bind /proc $SYSROOT/proc
    52     sudo mount --bind /sys $SYSROOT/sys
    53 
    54 Now, before chrooting into the ARM sysroot, you'll need to apply a workaround,
    55 edit $SYSROOT/etc/ld.so.preload and comment out all lines in it.
    56 
    57     sudo chroot $SYSROOT
    58     apt-get install libudev-dev libasound2-dev libdbus-1-dev libraspberrypi0 libraspberrypi-bin libraspberrypi-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxxf86vm-dev libxss-dev
    59     exit
    60     sudo umount $SYSROOT/dev
    61     sudo umount $SYSROOT/proc
    62     sudo umount $SYSROOT/sys
    63     sudo umount /mnt
    64     
    65 There's one more fix required, as the libdl.so symlink uses an absolute path 
    66 which doesn't quite work in our setup.
    67 
    68     sudo rm -rf $SYSROOT/usr/lib/arm-linux-gnueabihf/libdl.so
    69     sudo ln -s ../../../lib/arm-linux-gnueabihf/libdl.so.2 $SYSROOT/usr/lib/arm-linux-gnueabihf/libdl.so
    70 
    71 The final step is compiling SDL itself.
    72 
    73     export CC="/opt/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc --sysroot=$SYSROOT -I$SYSROOT/opt/vc/include -I$SYSROOT/usr/include -I$SYSROOT/opt/vc/include/interface/vcos/pthreads -I$SYSROOT/opt/vc/include/interface/vmcs_host/linux"
    74     cd <SDL SOURCE>
    75     mkdir -p build;cd build
    76     ../configure --with-sysroot=$SYSROOT --host=arm-raspberry-linux-gnueabihf --prefix=$PWD/rpi-sdl2-installed --disable-pulseaudio --disable-esd
    77     make
    78     make install
    79 
    80 To be able to deploy this to /usr/local in the Raspbian system you need to fix up a few paths:
    81     
    82     perl -w -pi -e "s#$PWD/rpi-sdl2-installed#/usr/local#g;" ./rpi-sdl2-installed/lib/libSDL2.la ./rpi-sdl2-installed/lib/pkgconfig/sdl2.pc ./rpi-sdl2-installed/bin/sdl2-config
    83     
    84 ================================================================================
    85  Apps don't work or poor video/audio performance
    86 ================================================================================
    87 
    88 If you get sound problems, buffer underruns, etc, run "sudo rpi-update" to 
    89 update the RPi's firmware. Note that doing so will fix these problems, but it
    90 will also render the CMA - Dynamic Memory Split functionality useless.
    91 
    92 Also, by default the Raspbian distro configures the GPU RAM at 64MB, this is too
    93 low in general, specially if a 1080p TV is hooked up.
    94 
    95 See here how to configure this setting: http://elinux.org/RPiconfig
    96 
    97 Using a fixed gpu_mem=128 is the best option (specially if you updated the 
    98 firmware, using CMA probably won't work, at least it's the current case).
    99 
   100 ================================================================================
   101  No input
   102 ================================================================================
   103 
   104 Make sure you belong to the "input" group.
   105 
   106     sudo usermod -aG input `whoami`
   107 
   108 ================================================================================
   109  No HDMI Audio
   110 ================================================================================
   111 
   112 If you notice that ALSA works but there's no audio over HDMI, try adding:
   113     
   114     hdmi_drive=2
   115     
   116 to your config.txt file and reboot.
   117 
   118 Reference: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=5062
   119 
   120 ================================================================================
   121  Text Input API support
   122 ================================================================================
   123 
   124 The Text Input API is supported, with translation of scan codes done via the
   125 kernel symbol tables. For this to work, SDL needs access to a valid console.
   126 If you notice there's no SDL_TEXTINPUT message being emitted, double check that
   127 your app has read access to one of the following:
   128     
   129 * /proc/self/fd/0
   130 * /dev/tty
   131 * /dev/tty[0...6]
   132 * /dev/vc/0
   133 * /dev/console
   134 
   135 This is usually not a problem if you run from the physical terminal (as opposed
   136 to running from a pseudo terminal, such as via SSH). If running from a PTS, a 
   137 quick workaround is to run your app as root or add yourself to the tty group,
   138 then re login to the system.
   139 
   140    sudo usermod -aG tty `whoami`
   141     
   142 The keyboard layout used by SDL is the same as the one the kernel uses.
   143 To configure the layout on Raspbian:
   144     
   145     sudo dpkg-reconfigure keyboard-configuration
   146     
   147 To configure the locale, which controls which keys are interpreted as letters,
   148 this determining the CAPS LOCK behavior:
   149 
   150     sudo dpkg-reconfigure locales
   151 
   152 ================================================================================
   153  Notes
   154 ================================================================================
   155 
   156 * When launching apps remotely (via SSH), SDL can prevent local keystrokes from
   157   leaking into the console only if it has root privileges. Launching apps locally
   158   does not suffer from this issue.
   159   
   160