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