Debian on the Medion Lifetab E10316

After having already added three other 7 inch tablets, I was very happy to receive a 10 inch one. Which I naturally wanted to integrate into my multi-monitor setup.

Again, I found no custom ROM for the E10316, but it came with SuperSU from its previous owner. A second one was later successfully rooted via Cydia Imapctor.

Early experiments highlighted:
1. Framebuffer support existed and dd could write random pixels
2. Touchscreen was available via evdev
3. /system did not have enough free inodes to hold a debian
4. The kernel version 3.0.36 is not supported by debian stretch and later

So I decided to use /data/debian this time. After puzzling for a while why I'd get permission denieds on /dev/null, I did

mount -o remount,rw,suid,dev /data

and via

debootstrap --arch=armhf --foreign oldoldstable ./debian-jessie

got hold of some binaries willing to run on that kernel version. From the other devices, I already knew to create a copy of chroot with a patched dynamic loader (pointing to /system/ld-lx-... instead of the normal /lib/ld-linux-...).

As before I installed SimpleSSHd on the device and

rsync -e 'ssh -p 2222' -aDHv --progress debian-jessie root@device:/data/

Then the usual preparatory scripts:

root@android:/ # cat /data/debian-jessie/start.sh                              
setprop ctl.stop media
setprop ctl.stop zygote
setprop ctl.stop surfaceflinger
sleep 2
setprop ctl.stop bootanim
sleep 2
setprop ctl.stop media
setprop ctl.stop zygote
sleep 2
setprop ctl.stop bootanim
setprop ctl.start surfaceflinger

mount -o remount,rw /system
mount -t proc proc /data/debian-jessie/proc
mount -t sysfs sysfs /data/debian-jessie/sys
mount -t devpts devpts /data/debian-jessie/dev/pts
mount -o bind /storage/emulated/legacy /data/debian-jessie/sdcard
mount -o remount,rw,suid,dev /data

root@android:/ # cat /data/debian-jessie/enter.sh                              
export SHELL=/bin/zsh
export PATH=/bin:/usr/bin:/sbin:/usr/sbin
export TERM=linux
export PS1='lifetab %25<..<%~ %% '
LD_LIBRARY_PATH=/data/debian-jessie/lib/arm-linux-gnueabihf/ /data/debian-jessie/usr/sbin/chroot.android /data/debian-jessie "${@:-/bin/zsh}"

I added $PS1 as the android default included some calls to precmd which debian didn't have and thus spammed the console with errors.

After checking out the new system, it appeared many packages (in particular apt-get) were not really installed, instead debootstrap just put them into /var/cache/apt/archives ready to be installed from there.

Unfortunately

cd /var/cache/apt/archives/
dpkg -i *.deb

did not do anything useful, except to complain about either libc6 or multiarch-support not being installed.

One of the problems was definitely that the kernel was reporting "3.0.36+" as its version, and the preinst script of libc6 was trying (and failing) to parse the kernel version and thus assumed it was about to be installed on something even more super-old and refused to let that happen.

I tried various things (which I'll post here because some of those options might be interesting again occasionally):

dpkg --ignore-depends=libc6,dpkg --unpack perl*
dpkg --ignore-depends=libc6,dpkg,multiarch-support --unpack *read*

root@android:/bin # mv uname uname.orig
/bin/sh: 1: precmd: not found
root@android:/bin # cat > uname
#!/bin/sh
echo 3.0.36 
root@android:/bin # chmod +x uname

export LD_LIBRARY_PATH=
dpkg -D7777777 -i /var/cache/apt/archives/libc6*

Ultimately, what did help was

root@android:/var/lib/dpkg/info # dpkg --force-all --configure libc6
root@android:/var/lib/dpkg/info # dpkg --configure --pending

... and some cleanup

apt-get remove systemd systemd-sysv init

... devices ...

mkdir /sdcard

mkdir /dev/input
mknod event0 c 13 64
mknod event1 c 13 65
mknod event2 c 13 66
mknod event3 c 13 67
mknod event4 c 13 68
mknod event5 c 13 69
mknod event6 c 13 70

mknod tty0 c 4 0
mknod tty1 c 4 1
mknod fb0 c 29 0
mknod fb1 c 29 1
mknod fb2 c 29 2
mknod fb3 c 29 3

Some probing of the input devices gave

# /dev/input/event1 -> volume keys
# /dev/input/event3 -> touchscreen

(On the second one, I found the touchscreen at /dev/input/event5.)

So after the obvious

apt-get install xserver-xorg-video-fbdev xserver-xorg-input-evdev
apt-get install fbset   # for checking out the FB properties

Xorg -sharevts -noreset -retro -verbose vt1

I got

(WW) Warning, couldn't open module modesetting
(II) Unloading modesetting
(EE) Failed to load module "modesetting" (module does not exist, 0)
(II) Loading /usr/lib/xorg/modules/drivers/fbdev_drv.so
(II) Module fbdev: vendor="X.Org Foundation"
        compiled for 1.15.99.904, module version = 0.4.4
(II) FBDEV: driver for framebuffer: fbdev
(++) using VT number 1

(WW) Falling back to old probe method for fbdev
(II) Loading /usr/lib/xorg/modules/libfbdevhw.so
(II) Module fbdevhw: vendor="X.Org Foundation"
        compiled for 1.16.4, module version = 0.0.2
(II) FBDEV(0): using default device
(WW) VGA arbiter: cannot open kernel arbiter, no multi-card support
(EE) FBDEV(0): Specified depth (24) is greater than the fbbpp (16)
(EE) Screen(s) found, but none have a usable configuration.

After fiddling a bit with xorg.conf, I got the X server to be happy about those 16 bits framebuffer bits, but then the screen showed my experimental random dots (from earlier dd testing) on one half, and a weirdly-broken Xorg pattern on one the other half.

Quick testing ...

( while sleep 0.0001; do echo -ne '\0\0\xff\0'; done ) >/dev/fb0

showed the framebuffer was obviously 32bit. I got the X server to accept that fact via

Section "Screen"
  Identifier  "Screen0"
  Device  "Card0"
  Monitor "Monitor0"
  DefaultDepth    32
  SubSection      "Display"
    Depth               32
    Modes   "1280x800"
  EndSubSection
EndSection

Section "Monitor"
  Identifier "Monitor0"
  Mode "1280x800"
      # D: 64.000 MHz, H: 44.444 kHz, V: 54.003 Hz
      DotClock 64.001
      HTimings 1280 1328 1360 1440
      VTimings 800 802 808 823
      Flags    "-HSync" "-VSync"
  EndMode
EndSection

and

Xorg -sharevts -noreset -retro -verbose -fbbpp 32 vt1

I'm not sure both changes are necessary, but anyway it works now.

Unfortunately, it only worked up to the point where I tried to move the mouse cursor. Upon touching the screen, I saw

libevdev error in sanitize_event: BUG: Device "ct36x_ts" received a double tracking ID 342 in slot 0.

and a segfault of Xorg.

So I did

apt-get install libevdev2   (but from unstable)

... without much effect.

(II) XINPUT: Adding extended input device "Keyboard0" (type: KEYBOARD, id 7)
libevdev error in sanitize_event: BUG: Device "ct36x_ts" received a double tracking ID 432 in slot 0.

Clearly, there must be a way...

gdb Xorg
run -sharevts -noreset -retro -verbose -fbbpp 32 vt1

Program received signal SIGSEGV, Segmentation fault.
0x2a048de2 in valuator_mask_set_double ()
(gdb) bt
#0  0x2a048de2 in valuator_mask_set_double ()
#1  0x408eadd2 in ?? () from /usr/lib/xorg/modules/input/evdev_drv.so
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)

After pondering my options for a while, I decided to get to the bottom of this and get me that 10 inch drawing tablet.

apt-get install evtest

And evtest looked fine to me.

Surely, something is doing that valuator_mask_set_double and printing that BUG line.

git clone https://gitlab.freedesktop.org/xorg/driver/xf86-input-evdev
..ces/xf86-input-evdev % git log -S valuator_mask_set_double                           (master...origin/master)
commit 034be31159f22ce28d84994d541a45ee44963fd8

..ces/xf86-input-evdev % git co xf86-input-evdev-2.10.0                               (HEAD (no branch))
Previous HEAD position was 1936632 evdev 2.4.0
HEAD is now at 01e7ac4 evdev 2.10.0
..ces/xf86-input-evdev % vim src/evdev.c

At that point I noticed that there was another error message about the mouse device not having absolute axes, but only multitouch axes. And after some reading the source it became likely that this led to later attempts to set "the axes" resolution was not going to work well indeed.

Internet told me, evdev-2.9.2 introduced a fix which simulates absolute axes from the multitouch axes. Well, jessie ships with 2.9.0. And getting it from oldstable (i.e. actually newer stable) will pull a new libc6, which refuses to live under kernel 3.0.36...

*sigh*, so clearly I'll be doing some development work on the device itself (will be easier than cross-compiling and copying stuff over all the time).

apt-get install git
git clone https://gitlab.freedesktop.org/xorg/driver/xf86-input-evdev
git checkout xf86-input-evdev-2.9.2

apt-get install xutils-dev xorg-dev
apt-get install gcc libevdev-dev libudev-dev make

Oh, wonderful, autotools...

lifetab /root/xf86-input-evdev % autoconf
configure.ac:41: error: must install xorg-macros 1.8 or later before running autoconf/autogen
configure.ac:41: the top level
autom4te: /usr/bin/m4 failed with exit status: 1

hrmrm... After some installing various packages as suggested by various forum posts but without much progress on obtaining xorg-macros, I decided I could not be bothered further and:

lifetab /root/xf86-input-evdev % cat Makefile
yolo.so:
        gcc \
                -DPACKAGE_VERSION_MAJOR=2 -DPACKAGE_VERSION_MINOR=9 -DPACKAGE_VERSION_PATCHLEVEL=2 \
                -I src -I include -I /usr/include/libevdev-1.0 -I /usr/include/xorg -I /usr/include/pixman-1 \
                -fPIC -levdev -shared -o yolo.so src/*.c

install: yolo.so
        cp yolo.so /usr/lib/xorg/modules/input/evdev_drv.so

.PHONY: yolo.so install

NO MORE CRASH \o/ (but also no mouse control). Huh? Checking the code once more, I should have defined MULTITOUCH:

apt-get install libmtdev-dev

lifetab /root/xf86-input-evdev % cat Makefile
yolo.so:
        gcc \
                -DMULTITOUCH -DPACKAGE_VERSION_MAJOR=2 -DPACKAGE_VERSION_MINOR=9 -DPACKAGE_VERSION_PATCHLEVEL=2 \
                -I src -I include -I /usr/include/libevdev-1.0 -I /usr/include/xorg -I /usr/include/pixman-1 \
                -fPIC -levdev -shared -o yolo.so src/*.c

install: yolo.so
        cp yolo.so /usr/lib/xorg/modules/input/evdev_drv.so

.PHONY: yolo.so install

Success!

For some reason, the screen is rotated 180 degrees with respect to the "lifetab" branding at the bottom (top?) of the device, so I had to put some extra rotations everywhere, with the final xorg.conf being

Section "ServerLayout"
  Identifier "Layout0"
  Screen   "Screen0"
  InputDevice "Mouse0" "CorePointer"
  InputDevice "Keyboard0" "CoreKeyboard"
EndSection

Section "InputDevice"
  Identifier  "Keyboard0"
  Driver   "evdev"
  Option  "Device" "/dev/input/event1"
  Option  "Protocol" "usb"
EndSection

Section "InputDevice"
  Identifier "Mouse0"
  Driver  "evdev"
  Option  "Device" "/dev/input/event3"
  Option  "IgnoreRelativeAxes" "true"
  Option  "IgnoreAbsoluteAxes" "false"
  Option  "InvertX" "true"
  Option  "InvertY" "true"
  Option  "Mode" "Absolute"
EndSection

Section "Device"
  Identifier "Card0"
  Driver  "fbdev"
  Option  "fbdev" "/dev/fb0"
  Option  "debug" "true"
  Option  "Rotate" "UD"
  VendorName "Unknown"
  BoardName "Unknown"
EndSection

Section "Screen"
  Identifier  "Screen0"
  Device  "Card0"
  Monitor "Monitor0"
  DefaultDepth    32
  SubSection      "Display"
    Depth               32
    Modes   "1280x800"
  EndSubSection
EndSection

Section "Monitor"
  Identifier "Monitor0"
  Mode "1280x800"
      # D: 64.000 MHz, H: 44.444 kHz, V: 54.003 Hz
      DotClock 64.001
      HTimings 1280 1328 1360 1440
      VTimings 800 802 808 823
      Flags    "-HSync" "-VSync"
  EndMode
EndSection

Section "ServerFlags"
  Option "AutoAddDevices" "false"
EndSection

And X11 now even supports dpms, so

lifetab /root/xf86-input-evdev % cat /root/vnc.sh
#!/bin/sh

export DISPLAY=:0
xset b off
xset dpms 0 0 0
xset s 0 0
xset dpms force on

The device has a very slow bootup, and surfaceflinger seems to be necessary to correctly blit fb0 onto the screen, so I'm still fiddling a bit to get a reliable bootup into a functioning VNC client, but that's mostly tuning some sleep timings.

I finally got around testing audio as well. First, create the devices in /dev/snd as on the original /system. Then alsa works in principle, but no sound will be playing until Voice Call Path has been changed in alsamixer (regardless to what value as far as I could ascertain).