Dragonrise joypad support for Amlogic S905

I have a quite old Telos Vega S95 tv box running Ugoos AM1 firmware.When attaching a gamepad it turned out it doesn’t support the joypad modules out-of-the box. I have a Dragonrise Generic USB and a Chinese clone of the Sony PS2 controller.

On the net I found several forums, that complied the drivers from the original source, like this one. However those are still missing the patch to support this particular controller (0079:0006) that was created by Maciej Zuk, that fixes the axis that are mashed together, So loading them straight away did not work.

The solution was to grab the kernel tree, patch the source and compile the module myself.

Since I have Ubuntu 19.04 running on my laptop, and the kernel source is originally designed to be compiled on GCC 5, that is no longer available on the repositories.

So I modified some things in the kernel source to make it compilable. To help others achieve this feature, and for myself so I won’t forget, I did this in the kernel source directory expanded from the zip.

$ ln -s include/linux/compiler-gcc5.h include/linux/compiler-gcc5.h

In the Makefile I added -Wno-error to the KBUILD_CFLAGS to forcibly ignore the errror messages from the gcc-9.

KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs 
                   -fno-strict-aliasing -fno-common 
                   -Werror-implicit-function-declaration 
                   -Wno-format-security 
                   -fno-delete-null-pointer-checks 
                   -Wno-error

Then I built the kernel tree to end up with my new modules. So I created a script named build_modules.sh with this content:

#!/bin/bash
# My laptop is ancient and has 4 cores only
CORECOUNT=4 
mkdir -p .git/hooks
make ARCH=arm64 clean
make ARCH=arm64 meson64_defconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j${CORECOUNT} modules
make menuconfig ARCH=arm64 meson64_defconfig
# save your new configuration as new_config
mv new_config arch/arm64/meson64_defconfig
make ARCH=arm64 meson64_defconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j${CORECOUNT} modules
mkdir new_modules
cp drivers/input/*.ko new_modules
cp drivers/hid/*.ko new_modules

Unfortunately it turned out the latest gcc references are different than to actually revert to a docker running ubuntu 14.04.

$ docker pull ubuntu:14.04
$ docker run --rm -ti -v /<source location/>:/mnt/build ubuntu:14.04
docker$ apt-get update
docker$ apt-get install gcc-aarch64-linux-gnu libc6-dev gcc g++ make dpkg-dev ncurses-dev lzop
docker$ cd /mnt/build/arm-src-kernel-2016-08-18-26e194264c/
docker$ . build_modules.sh

It seems that the ugoos AM1 was compiled on an Ubuntu 14.10, which was not a LTE edition, so I also tried building on that.

$ docker pull ubuntu:14.10
$ docker run --rm -ti -v /<source location/>:/mnt/build ubuntu:14.10
docker$ sed -i "s/archive.ubuntu/old-releases/" /etc/sources.list
docker$ apt-get update
docker$ apt-get install gcc-aarch64-linux-gnu libc6-dev gcc g++ make dpkg-dev ncurses-dev lzop
docker$ cd /mnt/build/arm-src-kernel-2016-08-18-26e194264c/
docker$ . build_modules.sh

This build completed in no time, and the created modules could easy be installed.

The only drawback is that the modules need to be inserted manually, as the Ugoos does not have an init.d script to allow auto loading.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.