README-raspberrypi.txt
author Gabriel Jacobo <gabomdq@gmail.com>
Sat, 12 Oct 2013 11:35:47 -0300
changeset 7806 03e6aaea8347
parent 7778 a571a9947869
child 7808 627f256b0e56
permissions -rw-r--r--
Updates the Raspberry Pi README
     1 ================================================================================
     2 SDL2 for Raspberry Pi
     3 ================================================================================
     4 
     5 Requirements:
     6 
     7 Raspbian (other Linux distros may work as well).
     8 
     9 ================================================================================
    10  Features
    11 ================================================================================
    12 
    13 * Works without X11
    14 * Hardware accelerated OpenGL ES 2.x
    15 * Sound via ALSA
    16 * Input (mouse/keyboard/joystick) via EVDEV
    17 * Hotplugging of input devices via UDEV
    18 
    19 ================================================================================
    20  Raspbian Build Dependencies
    21 ================================================================================
    22 
    23 sudo apt-get install libudev-dev libasound2-dev libdbus-1-dev
    24 
    25 You also need the VideoCore binary stuff that ships in /opt/vc for EGL and 
    26 OpenGL ES 2.x, it usually comes pre installed, but in any case:
    27     
    28 sudo apt-get install libraspberrypi0 libraspberrypi-bin libraspberrypi-dev
    29 
    30 ================================================================================
    31  Cross compiling from x86 Linux
    32 ================================================================================
    33 
    34 To cross compile SDL for Raspbian from your desktop machine, you'll need a
    35 Raspbian system root and the cross compilation tools. We'll assume these tools
    36 will be placed in /opt/rpi-tools
    37 
    38     sudo git clone --depth 1 https://github.com/raspberrypi/tools /opt/rpi-tools
    39 
    40 You'll also need a Rasbian binary image.
    41 Get it from: http://downloads.raspberrypi.org/raspbian_latest 
    42 After unzipping, you'll get file with a name like: <date>-wheezy-raspbian.img
    43 Let's assume the sysroot will be built in /opt/rpi-sysroot.
    44 
    45     export SYSROOT=/opt/rpi-sysroot
    46     sudo kpartx -a -v <path_to_raspbian_image>.img
    47     sudo mount -o loop /dev/mapper/loop0p2 /mnt
    48     sudo cp -r /mnt $SYSROOT
    49     sudo apt-get install qemu binfmt-support qemu-user-static
    50     sudo cp /usr/bin/qemu-arm-static $SYSROOT/usr/bin
    51     sudo mount --bind /dev $SYSROOT/dev
    52     sudo mount --bind /proc $SYSROOT/proc
    53     sudo mount --bind /sys $SYSROOT/sys
    54 
    55 Now, before chrooting into the ARM sysroot, you'll need to apply a workaround,
    56 edit $SYSROOT/etc/ld.so.preload and comment out all lines in it.
    57 
    58     sudo chroot $SYSROOT
    59     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
    60     exit
    61     sudo umount $SYSROOT/dev
    62     sudo umount $SYSROOT/proc
    63     sudo umount $SYSROOT/sys
    64     sudo umount /mnt
    65 
    66 The final step is compiling SDL itself.
    67 
    68     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"
    69     cd <SDL SOURCE>
    70     mkdir -p build;cd build
    71     ../configure --with-sysroot=$SYSROOT --host=arm-raspberry-linux-gnueabihf --prefix=$PWD/rpi-sdl2-installed --disable-pulseaudio --disable-esd
    72 
    73 ================================================================================
    74  Apps don't work or poor video/audio performance
    75 ================================================================================
    76 
    77 If you get sound problems, buffer underruns, etc, run "sudo rpi-update" to 
    78 update the RPi's firmware. Note that doing so will fix these problems, but it
    79 will also render the CMA - Dynamic Memory Split functionality useless.
    80 
    81 Also, by default the Raspbian distro configures the GPU RAM at 64MB, this is too
    82 low in general, specially if a 1080p TV is hooked up.
    83 
    84 See here how to configure this setting: http://elinux.org/RPiconfig
    85 
    86 Using a fixed gpu_mem=128 is the best option (specially if you updated the 
    87 firmware, using CMA probably won't work, at least it's the current case).
    88 
    89 ================================================================================
    90  No input
    91 ================================================================================
    92 
    93 Make sure you belong to the "input" group.
    94 
    95     sudo usermod -aG input `whoami`
    96 
    97 ================================================================================
    98  No HDMI Audio
    99 ================================================================================
   100 
   101 If you notice that ALSA works but there's no audio over HDMI, try adding:
   102     
   103     hdmi_drive=2
   104     
   105 to your config.txt file and reboot.
   106 
   107 Reference: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=5062
   108 
   109 ================================================================================
   110  Text Input API support
   111 ================================================================================
   112 
   113 The Text Input API is supported, with translation of scan codes done via the
   114 kernel symbol tables. For this to work, SDL needs access to a valid console.
   115 If you notice there's no SDL_TEXTINPUT message being emmited, double check that
   116 your app has read access to one of the following:
   117     
   118 * /proc/self/fd/0
   119 * /dev/tty
   120 * /dev/tty[0...6]
   121 * /dev/vc/0
   122 * /dev/console
   123 
   124 This is usually not a problem if you run from the physical terminal (as opposed
   125 to running from a pseudo terminal, such as via SSH). If running from a PTS, a 
   126 quick workaround is to run your app as root or add yourself to the tty group,
   127 then re login to the system.
   128 
   129    sudo usermod -aG tty `whoami`
   130     
   131 The keyboard layout used by SDL is the same as the one the kernel uses.
   132 To configure the layout on Raspbian:
   133     
   134     sudo dpkg-reconfigure keyboard-configuration
   135     
   136 To configure the locale, which controls which keys are interpreted as letters,
   137 this determining the CAPS LOCK behavior:
   138 
   139     sudo dpkg-reconfigure locales
   140 
   141 ================================================================================
   142  Notes
   143 ================================================================================
   144 
   145 * Input events from the keyboard leak through to the console
   146