🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

180 lines
6.1 KiB

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