🛠️🐜 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.

188 lines
7.7 KiB

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