<p>Hi! I'm trying to use go to make a graphical interface on my raspberry pi. I wish to avoid using the xserver, and thus are left with the framebuffer (fbdev) interface to draw graphics.
I have tried and failed a while and are looking for ideas.</p>
<p>It seems to me SDL2 and thus sdl2 bindings for other languages such as go, no longer support fbdev.</p>
<p>Any idea of a path forward? Should I try some sdl 1.2 bindings, or has anyone worked on a pure golang solution to this?</p>
<p>Should I just give in and run xserver?</p>
<hr/>**评论:**<br/><br/>chrisoboe: <pre><p>you could use kms instead of fbdev. It's available since SDL 2.0.6.
on the rpi it's supported by the open source vc4 driver. On raspbian you can use raspi-config to switch to the open source vc4 driver instead of the proprietary broadcom one (which doesn't support kms). </p></pre>birkbork: <pre><p>Thanks alot! I will check this out!</p></pre>whuppo: <pre><p>I would appreciate it if you could summarize your experiences and findings at some point, this is of general interest.</p></pre>birkbork: <pre><p>As requested, a small writeup of how to get sdl2 working on the raspberry without xserver.</p>
<p>I have issues using the VC4+drm sdl2 video driver, but am having success with the "RPI" sdl2 video driver.</p>
<p>I am using the official raspbian "jessie" release.
The packaged libsdl2-dev is version 2.0.2, which is too old.</p>
<p>So first we need to install a recent libsdl2 with kms support.</p>
<p>I chose to build custom deb:s, based on the upstream debian sdl2 repo which has the most recent sdl2 2.0.8, so:</p>
<p>On your pi:</p>
<pre><code>sudo apt-get build-dep libsdl2
git clone https://salsa.debian.org/sdl-team/libsdl2
cd libsdl2
cat > libsdl2-pi.diff << EOF
diff --git a/debian/control b/debian/control
index 4674513..79ff6e9 100644
--- a/debian/control
+++ b/debian/control
@@ -9,7 +9,6 @@ Uploaders:
Standards-Version: 4.1.1
Build-Depends:
debhelper (>= 10~),
- fcitx-libs-dev,
libasound2-dev [linux-any],
libdbus-1-dev,
libegl1-mesa-dev [!hurd-any],
@@ -22,7 +21,6 @@ Build-Depends:
libudev-dev [linux-any],
libusb2-dev [kfreebsd-any],
libusbhid-dev [kfreebsd-any],
- libvulkan-dev [linux-any],
libwayland-dev [linux-any],
libx11-dev,
libxcursor-dev,
@@ -36,8 +34,7 @@ Build-Depends:
libxv-dev,
libxxf86vm-dev,
pkg-config,
- libsamplerate0-dev,
- wayland-protocols
+ libsamplerate0-dev
Build-Depends-Indep:
doxygen
Vcs-Git: https://salsa.debian.org/sdl-team/libsdl2.git
diff --git a/debian/rules b/debian/rules
index 3a28a85..afbfc73 100755
--- a/debian/rules
+++ b/debian/rules
@@ -9,9 +9,8 @@ confflags = --disable-rpath --enable-sdl-dlopen --disable-loadso \
--disable-nas --disable-esd --disable-arts \
--disable-alsa-shared --disable-pulseaudio-shared \
--enable-ibus \
- --enable-video-opengles \
- --enable-video-wayland --disable-wayland-shared
+ --enable-video-opengles --enable-video-kmsdrm
# disable autoheader (invoked automatically by autoreconf), necessary in order
# to use debhelper compat level v10 without overriding dh-autoreconf calls
@@ -55,7 +54,7 @@ override_dh_auto_configure:
dh_auto_configure -- $(confflags)
override_dh_auto_build-indep:
- GZIP="-9n" tar czf debian/examples.tar.gz test --owner=0 --group=0 --mode=go=rX,u+rw,a-s --clamp-mtime --mtime="$(SOURCE_DATE)" --sort=name
+ GZIP="-9n" tar czf debian/examples.tar.gz test --owner=0 --group=0 --mode=go=rX,u+rw,a-s --mtime="$(SOURCE_DATE)"
doxygen docs/doxyfile
# useless files
find output -name "*.md5" -delete
EOF
git apply libsdl2-pi.diff
</code></pre>
<p>(some additional dependencies might be needed at this point)</p>
<pre><code>dpkg-buildpackage -b -uc -us
</code></pre>
<p>finally, install the deb's:</p>
<pre><code>sudo dpkg -i ../libsdl2-2.0-0_2.0.8+dfsg1-1_armhf.deb
sudo dpkg -i ../libsdl2-dev_2.0.8+dfsg1-1_armhf.deb
</code></pre>
<p>Building the debs took about 50 minutes on my raspberry pi 3 model b.</p></pre>birkbork: <pre><p>Sure. I'll post some notes in this thread.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传