1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/docs/README-raspberrypi.md Tue Jul 29 08:04:15 2014 -0700
1.3 @@ -0,0 +1,160 @@
1.4 +Raspberry Pi
1.5 +================================================================================
1.6 +
1.7 +Requirements:
1.8 +
1.9 +Raspbian (other Linux distros may work as well).
1.10 +
1.11 +================================================================================
1.12 + Features
1.13 +================================================================================
1.14 +
1.15 +* Works without X11
1.16 +* Hardware accelerated OpenGL ES 2.x
1.17 +* Sound via ALSA
1.18 +* Input (mouse/keyboard/joystick) via EVDEV
1.19 +* Hotplugging of input devices via UDEV
1.20 +
1.21 +================================================================================
1.22 + Raspbian Build Dependencies
1.23 +================================================================================
1.24 +
1.25 +sudo apt-get install libudev-dev libasound2-dev libdbus-1-dev
1.26 +
1.27 +You also need the VideoCore binary stuff that ships in /opt/vc for EGL and
1.28 +OpenGL ES 2.x, it usually comes pre installed, but in any case:
1.29 +
1.30 +sudo apt-get install libraspberrypi0 libraspberrypi-bin libraspberrypi-dev
1.31 +
1.32 +================================================================================
1.33 + Cross compiling from x86 Linux
1.34 +================================================================================
1.35 +
1.36 +To cross compile SDL for Raspbian from your desktop machine, you'll need a
1.37 +Raspbian system root and the cross compilation tools. We'll assume these tools
1.38 +will be placed in /opt/rpi-tools
1.39 +
1.40 + sudo git clone --depth 1 https://github.com/raspberrypi/tools /opt/rpi-tools
1.41 +
1.42 +You'll also need a Rasbian binary image.
1.43 +Get it from: http://downloads.raspberrypi.org/raspbian_latest
1.44 +After unzipping, you'll get file with a name like: <date>-wheezy-raspbian.img
1.45 +Let's assume the sysroot will be built in /opt/rpi-sysroot.
1.46 +
1.47 + export SYSROOT=/opt/rpi-sysroot
1.48 + sudo kpartx -a -v <path_to_raspbian_image>.img
1.49 + sudo mount -o loop /dev/mapper/loop0p2 /mnt
1.50 + sudo cp -r /mnt $SYSROOT
1.51 + sudo apt-get install qemu binfmt-support qemu-user-static
1.52 + sudo cp /usr/bin/qemu-arm-static $SYSROOT/usr/bin
1.53 + sudo mount --bind /dev $SYSROOT/dev
1.54 + sudo mount --bind /proc $SYSROOT/proc
1.55 + sudo mount --bind /sys $SYSROOT/sys
1.56 +
1.57 +Now, before chrooting into the ARM sysroot, you'll need to apply a workaround,
1.58 +edit $SYSROOT/etc/ld.so.preload and comment out all lines in it.
1.59 +
1.60 + sudo chroot $SYSROOT
1.61 + 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
1.62 + exit
1.63 + sudo umount $SYSROOT/dev
1.64 + sudo umount $SYSROOT/proc
1.65 + sudo umount $SYSROOT/sys
1.66 + sudo umount /mnt
1.67 +
1.68 +There's one more fix required, as the libdl.so symlink uses an absolute path
1.69 +which doesn't quite work in our setup.
1.70 +
1.71 + sudo rm -rf $SYSROOT/usr/lib/arm-linux-gnueabihf/libdl.so
1.72 + sudo ln -s ../../../lib/arm-linux-gnueabihf/libdl.so.2 $SYSROOT/usr/lib/arm-linux-gnueabihf/libdl.so
1.73 +
1.74 +The final step is compiling SDL itself.
1.75 +
1.76 + 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"
1.77 + cd <SDL SOURCE>
1.78 + mkdir -p build;cd build
1.79 + ../configure --with-sysroot=$SYSROOT --host=arm-raspberry-linux-gnueabihf --prefix=$PWD/rpi-sdl2-installed --disable-pulseaudio --disable-esd
1.80 + make
1.81 + make install
1.82 +
1.83 +To be able to deploy this to /usr/local in the Raspbian system you need to fix up a few paths:
1.84 +
1.85 + 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
1.86 +
1.87 +================================================================================
1.88 + Apps don't work or poor video/audio performance
1.89 +================================================================================
1.90 +
1.91 +If you get sound problems, buffer underruns, etc, run "sudo rpi-update" to
1.92 +update the RPi's firmware. Note that doing so will fix these problems, but it
1.93 +will also render the CMA - Dynamic Memory Split functionality useless.
1.94 +
1.95 +Also, by default the Raspbian distro configures the GPU RAM at 64MB, this is too
1.96 +low in general, specially if a 1080p TV is hooked up.
1.97 +
1.98 +See here how to configure this setting: http://elinux.org/RPiconfig
1.99 +
1.100 +Using a fixed gpu_mem=128 is the best option (specially if you updated the
1.101 +firmware, using CMA probably won't work, at least it's the current case).
1.102 +
1.103 +================================================================================
1.104 + No input
1.105 +================================================================================
1.106 +
1.107 +Make sure you belong to the "input" group.
1.108 +
1.109 + sudo usermod -aG input `whoami`
1.110 +
1.111 +================================================================================
1.112 + No HDMI Audio
1.113 +================================================================================
1.114 +
1.115 +If you notice that ALSA works but there's no audio over HDMI, try adding:
1.116 +
1.117 + hdmi_drive=2
1.118 +
1.119 +to your config.txt file and reboot.
1.120 +
1.121 +Reference: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=5062
1.122 +
1.123 +================================================================================
1.124 + Text Input API support
1.125 +================================================================================
1.126 +
1.127 +The Text Input API is supported, with translation of scan codes done via the
1.128 +kernel symbol tables. For this to work, SDL needs access to a valid console.
1.129 +If you notice there's no SDL_TEXTINPUT message being emitted, double check that
1.130 +your app has read access to one of the following:
1.131 +
1.132 +* /proc/self/fd/0
1.133 +* /dev/tty
1.134 +* /dev/tty[0...6]
1.135 +* /dev/vc/0
1.136 +* /dev/console
1.137 +
1.138 +This is usually not a problem if you run from the physical terminal (as opposed
1.139 +to running from a pseudo terminal, such as via SSH). If running from a PTS, a
1.140 +quick workaround is to run your app as root or add yourself to the tty group,
1.141 +then re login to the system.
1.142 +
1.143 + sudo usermod -aG tty `whoami`
1.144 +
1.145 +The keyboard layout used by SDL is the same as the one the kernel uses.
1.146 +To configure the layout on Raspbian:
1.147 +
1.148 + sudo dpkg-reconfigure keyboard-configuration
1.149 +
1.150 +To configure the locale, which controls which keys are interpreted as letters,
1.151 +this determining the CAPS LOCK behavior:
1.152 +
1.153 + sudo dpkg-reconfigure locales
1.154 +
1.155 +================================================================================
1.156 + Notes
1.157 +================================================================================
1.158 +
1.159 +* When launching apps remotely (via SSH), SDL can prevent local keystrokes from
1.160 + leaking into the console only if it has root privileges. Launching apps locally
1.161 + does not suffer from this issue.
1.162 +
1.163 +