Touchscreen Kivy app for Raspberry Pi - raspberry-pi

Here's the scenario: I've written a gui using the python framework Kivy, and I want to run it on a raspberry pi with this touchscreen. I've done the installation fine, and TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/touchscreen FRAMEBUFFER=/dev/fb1 nohup startx & gets the xwindow desktop gui running fine. I've been unable to get my kivy gui working, though. I was able to get a test tkinter application working ok, by
setting the DISPLAY environment variable.
I tried putting the following at the top of my kivy app, but to no avail:
os.environ['SDL_VIDEODRIVER'] = 'fbcon'
os.environ['SDL_FBDEV'] = '/dev/fb1'
os.environ['SDL_MOUSEDRV'] = 'TSLIB'
os.environ['SDL_MOUSEDEV'] = '/dev/input/touchscreen'
When I run my application, this is the debug output:
[INFO ] [Logger ] Record log in /home/pi/.kivy/logs/kivy_14-04-21_10.txt
[INFO ] Kivy v1.8.1-dev
[INFO ] [Python ] v2.7.3 (default, Mar 18 2014, 05:13:23)
[GCC 4.6.3]
[INFO ] [Factory ] 157 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_pygame, img_gif (img_pil ignored)
[INFO ] [Text ] Provider: pygame
[INFO ] [Loader ] using a thread pool of 2 workers
[INFO ] [Window ] Provider: egl_rpi
[INFO ] [GL ] OpenGL version <OpenGL ES 2.0>
[INFO ] [GL ] OpenGL vendor <Broadcom>
[INFO ] [GL ] OpenGL renderer <VideoCore IV HW>
[INFO ] [GL ] OpenGL parsed version: 2, 0
[INFO ] [GL ] Shading version <OpenGL ES GLSL ES 1.00>
[INFO ] [GL ] Texture max size <2048>
[INFO ] [GL ] Texture max units <8>
[INFO ] [Shader ] fragment shader: <Compiled>
[INFO ] [Shader ] vertex shader: <Compiled>
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[INFO ] [GL ] NPOT texture support is available
[INFO ] [OSC ] using <multiprocessing> for socket
[INFO ] [ProbeSysfs ] device match: /dev/input/event0
[INFO ] [HIDInput ] Read event from </dev/input/event0>
[INFO ] [Base ] Start application main loop
[INFO ] [HIDMotionEvent] using <stmpe-ts>
I don't know much (anything) about framebuffers and such; I'm hoping someone can point me in the right direction. It appears that the above environment variables I mentioned are useful for getting pygame applications to show up, and kivy is built on pygame.
Some links:
This is something I'm trying right now, in case both DISPLAY and a FBDEV need to be set. I'm also going to check and see if I have directfb or fbcon actually installed.
The relevant kivy google group issue
A fork I may try
I've had a hard time finding anything directly on this much later than April of last year.
Any help would be greatly appreciated. Thanks in advance!

This will not works. SPI screen works on SPI which is controlled by your CPU: http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus
Kivy use the GPU of the Raspberry Pi, not the SPI or X11. As my understanding, displaying an accelerated GLES application on SPI will not work.
Ie, you could confirm this behavior by executing any GLES software from command line outside X11

I found this to work by uncommenting the following line in /boot/config.txt
disable_overscan=1
then starting fbcp
fbcp &
and the running for example the showcase demo (I compile it for kivy for python3.4):
python3.4 kivy/examples/demo/showcase/main.py
Touch works, except that my y-axis is inverted.

Related

kivy 1.10.1 and 1.11.0 not working on raspberry pi4 Buster

I just received my new raspberry pi4 and did a fresh install with the latest Raspian buster. I installed the latest kivy 1.11 and I cannot have it running. Kivy just get frozen at the start what application you are trying to open.
I also tried to do a fresh install of kivy 1.10.0 on my raspberry PI4 and the problem is the same.
Is there known issues or tricks to have kivy running on PI4 ?
I tried to start an apps I wrote which work working fine on Raspberry PI3 and Raspian.
I added log level = debug but don't see much in the logs.
[INFO ] [Logger ] Record log in /home/asysclay/.kivy/logs/kivy_19-07-09_3.txt
[INFO ] [Kivy ] v1.11.1
[INFO ] [Kivy ] Installed at "/home/asysclay/Container/local/lib/python2.7/site-packages/kivy/__init__.pyc"
[INFO ] [Python ] v2.7.16 (default, Apr 6 2019, 01:42:57)
[GCC 8.2.0]
[INFO ] [Python ] Interpreter at "/home/asysclay/Container/bin/python"
[WARNING] [Deprecated ] Python 2 Kivy support has been deprecated. The Kivy release after 1.11.0 will not support Python 2 anymore
[INFO ] [Factory ] 184 symbols loaded
[DEBUG ] [Cache ] register <kv.lang> with limit=None, timeout=None
[DEBUG ] [Cache ] register <kv.image> with limit=None, timeout=60
[DEBUG ] [Cache ] register <kv.atlas> with limit=None, timeout=None
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
[DEBUG ] [Cache ] register <kv.texture> with limit=1000, timeout=60
[DEBUG ] [Cache ] register <kv.shader> with limit=1000, timeout=3600
[INFO ] [Text ] Provider: sdl2
[INFO ] [Window ] Provider: egl_rpi
[DEBUG ] [Window ] Actual display size: 1920x1080
I got stuck here and even a Control-C cannot stop the apps.
I had the same problem. It appears to be caused by the fact that the text and window providers are different (sdl2 vs. egl_rpi).
Try this test:
export KIVY_WINDOW=sdl2
then run your Kivy program.
If it works, then you need to make the environment change permanent, or put the following at the head of each Kivy python file you write:
import os
os.environ["KIVY_WINDOW"] = "sdl2"
os.environ["KIVY_TEXT"] = "sdl2"
But to be honest, there are probably better solutions. This should work to get you over the hump.
The reply from Prince Hal was very helpful to me to get Kivy 1.11.1 working with Raspbian Buster on a Rpi 3B+. I run this without loading the desktop/window manager. The Kivy application is launched from the console at boot. The last thing that frustrated me is that there was no mouse cursor visible but its functions were there in the background. Setting this environment variable fixed that problem : )

MMC errors during tuning execution

I am developing MMC driver in Linux. My system now is able to boot stably via eMMC and sdcard. But during the booting, I saw some errors generated on console.
[ 0.889357] mmc0: tuning execution failed: -5
[ 0.903700] mmc0: error -5 whilst initialising SD card
with some debug logs,
[ 0.976730] [DEBUG] mmc_sd_init_card
[ 1.143724] [DEBUG] mmc_execute_tuning
[ 1.219758] [DEBUG] tmio_mmc_execute_tuning: Tuning procedure failed = -5
[ 1.253255] [DEBUG] mmc_sd_init_uhs_card: err=-5
The error seemed to come from sd card initialization (UHS).
Despite the error, I was still able to use sdcard and eMMC once system completed the booting.
I am a little ambiguous about the error "tuning execution". Who can explain it and propose the fixing ? Thanks!
For more details, I have searched in the SD Card specification
https://www.sdcard.org/downloads/pls/index.html
And figure out some patches can deal with my issue.
https://patchwork.kernel.org/patch/9963437/
https://patchwork.kernel.org/patch/9998159/
My board has:
+ sdhi0: used for sdcard 4-bit bus width
+ sdhi2: used for on-board 8bit eMMC
+ sd-uhs-sdr50: SD UHS SDR50 speed is supported
+ sd-uhs-sdr104: SD UHS SDR104 speed is supported
+ mmc-hs200-1_8v: eMMC HS200 mode(1.8V I/O) is supported
+ mmc-hs400-1_8v: eMMC HS400 mode(1.8V I/O) is supported

ath9k_htc (Atheros) TL-WN722N WiFi dongle on Angstrom

I am trying to interface the TL-WN722N to a Altera Cyclone SoC. I have taken the following approach:
Downloaded the open firmware ath9k_htc and try integrating it to my linux kernel image to be loaded.
a. https://wiki.debian.org/ath9k_htc/open_firmware: The steps here mention to build the toolchain and the firmware and then place it in /lib/firmware.
b. Built the linux kernel using the steps mentioned here : https://rocketboards.org/foswiki/Documentation/GSRDCompilingLinux
The firmware obtained in step a. was placed into /linux-socfpga/firmware , since there was no firmware folder in directory /lib/.
c. The image created was flashed and the wifi dongle was plugged in.
2.Here is a dmesg output for the cyclone board :
[ 2.223039] usb 1-1: New USB device found, idVendor=0cf3, idProduct=9271
[ 2.229735] usb 1-1: New USB device strings: Mfr=16, Product=32, SerialNumber=48
[ 2.237129] usb 1-1: Product: USB2.0 WLAN
[ 2.241124] usb 1-1: Manufacturer: ATHEROS
[ 2.245215] usb 1-1: SerialNumber: 12345
[ 5.351145] EXT4-fs (mmcblk0p2): recovery complete
[ 5.359958] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[ 5.368058] VFS: Mounted root (ext3 filesystem) on device 179:2.
[ 5.375560] devtmpfs: mounted
[ 5.379310] Freeing unused kernel memory: 1024K (c0900000 - c0a00000)
**[ 5.670820] systemd[1]: Failed to insert module 'autofs4': No such file or directory**
[ 5.722709] systemd[1]: systemd 226 running in system mode. (+PAM -AUDIT -SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP -LIBCRYPTSETUP -GCRYPT +GNUTLS +ACL +XZ -LZ4 -SECCOMP +BLKID -ELFUTILS +KMOD +IDN)
The linux is able to identify the Atheros usb device. However the driver module is not loaded. I have verified this using lsmod and it returns nothing. The commands ifconfig and ip a also returns no wireless connection.
Also when I see the path /lib/modules/.../kernel/drivers/net I observe only 2 modules ethernet and mdio.ko
Kernel version : 4.1.33-ltsi-altera
Does that mean that my driver is missing in the image? What could be the possible reasons for this issue? Does anyone have any other solution to this issue?
Edit:
I could find the linux drivers in /sys/bus/usb/drivers/ath9k_htc and the corresponding modules in /sys/module/ath9k_htc
So basically, the modules are configured static.
Now when I boot up the system, I find an error saying that the requested firmware is not found.
I have already placed the required firmware(htc_9271-1.4.0.fw & htc_9271.fw) in /lib/firmware/ath9k_htc
Here is the error :
[ 2.002205] usb 1-1: new high-speed USB device number 2 using dwc2
[ 2.262666] usb 1-1: New USB device found, idVendor=0cf3, idProduct=9271
[ 2.269348] usb 1-1: New USB device strings: Mfr=16, Product=32, SerialNumber=48
[ 2.276730] usb 1-1: Product: USB2.0 WLAN
[ 2.280724] usb 1-1: Manufacturer: ATHEROS
[ 2.284815] usb 1-1: SerialNumber: 12345
[ 2.289370] usb 1-1: ath9k_htc: Firmware ath9k_htc/htc_9271-1.4.0.fw requested
[ 2.297203] usb 1-1: Direct firmware load for ath9k_htc/htc_9271-1.4.0.fw failed with error -2
[ 2.305811] usb 1-1: ath9k_htc: Firmware htc_9271.fw requested
[ 2.311658] usb 1-1: Direct firmware load for htc_9271.fw failed with error -2
[ 2.318867] usb 1-1: no suitable firmware found!
[ 2.323478] usb 1-1: ath9k_htc: Failed to get firmware htc_9271.fw
[ 2.329951] usb 1-1: ath9k_htc: USB layer deinitialized
I have also followed the steps mentioned here :
https://unix.stackexchange.com/questions/21903/custom-kernel-fails-to-load-firmware-when-module-built-in
which explains how to provide configuration for the path for loading the firmware.
A quick grep for /proc/config.gz reveals this:
$zcat /proc/config.gz | grep CONFIG_ATH
CONFIG_ATH_COMMON=y
#CONFIG_ATH_DEBUG is not set
#CONFIG_ATH5K is not set
#CONFIG_ATH5K_PCI is not set
CONFIG_ATH9K_HW=y
CONFIG_ATH9K_COMMON=y
CONFIG_ATH9K_BTCOEX_SUPPORT=y
CONFIG_ATH9K=y
CONFIG_ATH9K_PCI=y
CONFIG_ATH9K_AHB=y
#CONFIG_ATH9K_DEBUGFS is not set
#CONFIG_ATH9K_DYNACK is not set
CONFIG_ATH9K_WOW=y
#CONFIG_ATH9K_CHANNEL_CONTEXT is not set
CONFIG_ATH9K_PCOEM=y
CONFIG_ATH9K_HTC=y
CONFIG_ATH9K_HTC_DEBUGFS=y
#CONFIG_ATH6KL is not set
#CONFIG_ATH10K is not set
$zcat /proc/config.gz | grep CONFIG_EXT
CONFIG_EXTRA_FIRMWARE="htc_9271-1.4.0.fw"
CONFIG_EXTRA_FIRMWARE_DIR="/lib/firmware/ath9k_htc"
#CONFIG_EXTCON is not set
zcat /proc/config.gz | grep CONFIG_FIRMW
CONFIG_FIRMWARE_IN_KERNEL=y
# CONFIG_FIRMWARE_MEMMAP is not set
Is there any other way to notify the kernel to load the firmware? I think I might be missing out some configuration.
Edit 2 :
I resolved the issue of firmware load failure by enabling the option Fallback user-help invocation for firmware loading. Now the device is initialised, but the driver seems to not support the device. Here is the dmesg log :
[ 14.568484] usb 1-1: ath9k_htc: Transferred FW: ath9k_htc/htc_9271-1.4.0.fw, size: 51008
[ 14.820407] ath9k_htc 1-1:1.0: ath9k_htc: HTC initialized with 33 credits
[ 15.852173] ath: phy0: Mac Chip Rev 0x0f.3 is not supported by this driver
[ 15.859064] ath: phy0: Unable to initialize hardware; initialization status: -95
[ 15.866512] ath: phy0: Unable to initialize hardware; initialization status: -95
[ 15.873973] ath9k_htc: Failed to initialize the device
A quick research on the device, I found that the official website of TP-Link states that the linux drivers are available for version 2, and not for version 1. My device is a version 1 device and I think because of this the driver does not support.

HFP profile with linux and iphone 5

how can I use hfp on my ubuntu linux with iphone 5s? I have bluetoooth, all bluez packages and ofono installed.
For ofono I need a modem. From what I understood from bluetooth core, protocoll and profile specification, rfcomm and spp of bluetooth can be used to emulate a modem. How does this work with bluez? Do the bluetoothd and ofonod dbus-services already handle incoming connections to hfp oder do I have to write my own listener?
EDIT:
The program is running. I implemented it according to the test-scripts. But I am experiencing audio issues, as I don't have any sound when performing calls. The sound is not muted.
pa log (translated):
Sep 26 13:57:47 ubu2 pulseaudio[2524]: [alsa-sink-Intel ICH]
alsa-sink.c: ALSA woke us up to write new Data on the Device but there
was nothing to write! Sep 26 13:57:47 ubu2 pulseaudio[2524]:
[alsa-sink-Intel ICH] alsa-sink.c: This is most probably an Error of
the ALSA-Driver 'snd_intel8x0'. Please send this error to the
ALSA-Developers. Sep 26 13:57:47 ubu2 pulseaudio[2524]:
[alsa-sink-Intel ICH] alsa-sink.c: We have been woken up by the
POLLOUT-Set, but a following call of snd_pcm_avail() returned the
value 0 or another value smaller than min_avail.
How can I see if ALSA has encountered some errors? I found no log.
When connecting the a2dp-Profile so that my computer are the speakers of the iPhone I also have no sound.
EDIT 2:
To solve this error, this is recommended:
File: /etc/pulse/default.pa
Add tsched=0 to the following line:
load-module module-detect
from post #21 https://bugs.launchpad.net/ubuntu/+source/linux/+bug/374002
But it does not solve my issue. I try force-loading the also modules too.
Having ofono and bluez should be enough.
However, latest version of bluez/ofono and pulseaudio don't support HSP and HFP profiles.
Pulseaudio release notes say that only A2DP is supported with bluez5.x. If you are using
bluez4.x, ofono and pulseaudio 4.x/5.x you might still get this working without a problem.
http://www.freedesktop.org/wiki/Software/PulseAudio/Notes/5.0/
ofono will treat your iPhone 5s as your modem. Once you get the iPhone paired and connected
through bluetoothctl or any alternative GUI, you could run the following ofono tests to see
if ofono picked it up right. Try running ofonod using ofonod -n -d on a terminal to monitor the debug log and probably run pulseaudio in verbose too (pulseaudio -k && pulseaudio -v)
bash$ cd */ofono-1.x/test
This directory contains sample dbus scripts to test the ofono functionalities.
bash$ ./list-modems
[ /hfp/org/bluez/hci0/dev_94_94_26_88_XX_XX ]
Type = hfp
Interfaces = org.ofono.Siri org.ofono.VoiceCallManager org.ofono.CallVolume org.ofono.Handsfree org.ofono.NetworkRegistration
Features = net
Serial = 94:94:26:88:XX:XX
Online = 1
Powered = 1
Lockdown = 0
Emergency = 0
Name = XXXXXX’s iPhone
[ org.ofono.Siri ]
EyesFreeMode = disabled
Enabled = 1
[ org.ofono.VoiceCallManager ]
EmergencyNumbers = 08 000 999 110 112 911 118 119
[ org.ofono.CallVolume ]
Muted = 0
SpeakerVolume = 50
MicrophoneVolume = 50
[ org.ofono.Handsfree ]
VoiceRecognition = 0
InbandRinging = 1
Features = three-way-calling echo-canceling-and-noise-reduction voice-recognition release-all-held release-specified-active-call private-chat create-multiparty
BatteryChargeLevel = 4
SubscriberNumbers = +XXXXXXXXXXXX
EchoCancelingNoiseReduction = 1
[ org.ofono.NetworkRegistration ]
Status = registered
Name = XXX XXXXXX
Mode = auto-only
Strength = 60
If you see output similar to above, enable the modem and try dialling using the following
command and observe ofono debug log if SCO socket is created or rejected. And, of course,
see if the audio is routed to Ubuntu.
bash$ ./enable-modem
bash$ ./dial-number +XXXXXXXXXXXX
...
Similarly, try calling up your iPhone and observe the ofono, pulseaudio logs.
bash$ ./answer-calls
Looks like folks at pulseaudio are trying to get this working with bluez5.x and ofono but
there doesn't seem to be a patch available publicly yet. The bug is being tracked here:
https://bugs.freedesktop.org/show_bug.cgi?id=73325
HFP for Linux is a Bluetooth Hands-Free Profile server.
It allows your Linux system to act as a speakerphone for your mobile phone. It aims to be a compliant Bluetooth HFP 1.5 Hands Free implementation, supporting all required commands and notifications, as well as streaming audio.
http://nohands.sourceforge.net/

iphone Simulator crashing from Xcode run and go

Does anybody know what might be causing this problem? When I run the code, the program immediately crashes on the simulator before getting anywhere; however if I just go to the simulator and run the program, the changes were loaded and there doesn't seem to be any obvious problems.
Or how could I try to pinpoint this problem?
[Session started at 2009-09-18 03:31:02 -0700.]
GNU gdb 6.3.50-20050815 (Apple version gdb-966) (Tue Mar 10 02:43:13 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin".sharedlibrary apply-load-rules all
Attaching to process 2171.
gdb-i386-apple-darwin(2172,0x778720) malloc: *** mmap(size=1420296192) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
gdb stack crawl at point of internal error:
[ 0 ] /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/libexec/gdb/gdb-i386-apple-darwin (align_down+0x0) [0x122300]
[ 1 ] /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/libexec/gdb/gdb-i386-apple-darwin (xstrvprintf+0x0) [0x123394]
[ 2 ] /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/libexec/gdb/gdb-i386-apple-darwin (xmalloc+0x28) [0x1235b7]
[ 3 ] /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/libexec/gdb/gdb-i386-apple-darwin (dyld_info_read_raw_data+0x50) [0x1659d7]
[ 4 ] /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/libexec/gdb/gdb-i386-apple-darwin (dyld_info_read+0x1bc) [0x168a80]
[ 5 ] /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/libexec/gdb/gdb-i386-apple-darwin (macosx_dyld_update+0xbf) [0x168cc4]
[ 6 ] /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/libexec/gdb/gdb-i386-apple-darwin (macosx_solib_add+0x36b) [0x169ff4]
[ 7 ] /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/libexec/gdb/gdb-i386-apple-darwin (macosx_child_attach+0x478) [0x17dd39]
[ 8 ] /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/libexec/gdb/gdb-i386-apple-darwin (attach_command+0x5d) [0x64eed]
[ 9 ] /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/libexec/gdb/gdb-i386-apple-darwin (mi_cmd_target_attach+0x4c) [0x15de9]
[ 10 ] /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/libexec/gdb/gdb-i386-apple-darwin (captured_mi_execute_command+0x16d) [0x17453]
[ 11 ] /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/libexec/gdb/gdb-i386-apple-darwin (catch_exception+0x41) [0x7a9c2]
[ 12 ] /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/libexec/gdb/gdb-i386-apple-darwin (mi_execute_command+0xa9) [0x16f8f]
/SourceCache/gdb/gdb-966/src/gdb/utils.c:1144: internal-error: virtual memory exhausted: can't allocate 1420296192 bytes.
A problem internal to GDB has been detected, further debugging may prove unreliable.
The Debugger has exited with status 1.The Debugger has exited with status 1.
When this happens for me, I take out code until it runs, then put it back in one piece at a time until something breaks.
Inside Xcode -> Preferences-> Debugging window please uncheck the "Load symbols lazily" option.