Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Building xpadneo kernel driver under OSMC on Raspberry Pi 4
git clone https://github.com/atar-axis/xpadneo.git
Cloning into 'xpadneo'...
sudo apt-get install -y aarch64-toolchain-osmc
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
qemu qemu-user-static
The following NEW packages will be installed:
aarch64-toolchain-osmc qemu qemu-user-static
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 72.6 MB/88.7 MB of archives.
After this operation, 474 MB of additional disk space will be used.
Get:1 http://ftp.fau.de/osmc/osmc/apt buster/main armhf aarch64-toolchain-osmc all 1.3.9 [72.6 MB]
Fetched 46.6 MB in 18s (2,523 kB/s)
Selecting previously unselected package qemu.
(Reading database ...
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 77920 files and directories currently installed.)
Preparing to unpack .../qemu_1%3a3.1+dfsg-8+deb10u8_armhf.deb ...
Unpacking qemu (1:3.1+dfsg-8+deb10u8) ...
Selecting previously unselected package qemu-user-static.
Preparing to unpack .../qemu-user-static_1%3a3.1+dfsg-8+deb10u8_armhf.deb ...
Unpacking qemu-user-static (1:3.1+dfsg-8+deb10u8) ...
Selecting previously unselected package aarch64-toolchain-osmc.
Preparing to unpack .../aarch64-toolchain-osmc_1.3.9_all.deb ...
Unpacking aarch64-toolchain-osmc (1.3.9) ...
Setting up qemu (1:3.1+dfsg-8+deb10u8) ...
Setting up qemu-user-static (1:3.1+dfsg-8+deb10u8) ...
Setting up aarch64-toolchain-osmc (1.3.9) ...
Copying QEMU binary
Processing triggers for man-db (2.8.5-2) ...
sudo apt-get install -y rbp464-headers-5.10.78-2-osmc
Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
rbp464-headers-5.10.78-2-osmc:arm64
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 9,807 kB of archives.
After this operation, 74.1 MB of additional disk space will be used.
Get:1 http://ftp.fau.de/osmc/osmc/apt buster/main arm64 rbp464-headers-5.10.78-2-osmc arm64 5.10.78-2-osmc [9,807 kB]
Fetched 9,807 kB in 4s (2,416 kB/s)
Selecting previously unselected package rbp464-headers-5.10.78-2-osmc:arm64.
(Reading database ...
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 89893 files and directories currently installed.)
Preparing to unpack .../rbp464-headers-5.10.78-2-osmc_5.10.78-2-osmc_arm64.deb ...
Unpacking rbp464-headers-5.10.78-2-osmc:arm64 (5.10.78-2-osmc) ...
Setting up rbp464-headers-5.10.78-2-osmc:arm64 (5.10.78-2-osmc) ...
sudo mkdir -p /opt/osmc-tc/aarch64-toolchain-osmc/usr/src/rbp464-headers-5.10.78-2-osmc
sudo mount --bind /usr/src/rbp464-headers-5.10.78-2-osmc /opt/osmc-tc/aarch64-toolchain-osmc/usr/src/rbp464-headers-5.10.78-2-osmc
sudo apt-get install -y rbp464-source-5.10.78-2-osmc
Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
rbp464-source-5.10.78-2-osmc:arm64
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 126 MB of archives.
After this operation, 1,027 MB of additional disk space will be used.
Get:1 http://ftp.fau.de/osmc/osmc/apt buster/main arm64 rbp464-source-5.10.78-2-osmc arm64 5.10.78-2-osmc [126 MB]
Fetched 126 MB in 27s (4,597 kB/s)
Selecting previously unselected package rbp464-source-5.10.78-2-osmc:arm64.
(Reading database ...
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 109641 files and directories currently installed.)
Preparing to unpack .../rbp464-source-5.10.78-2-osmc_5.10.78-2-osmc_arm64.deb ...
Unpacking rbp464-source-5.10.78-2-osmc:arm64 (5.10.78-2-osmc) ...
Setting up rbp464-source-5.10.78-2-osmc:arm64 (5.10.78-2-osmc) ...
sudo mkdir -p /opt/osmc-tc/aarch64-toolchain-osmc/usr/src/rbp464-source-5.10.78-2-osmc
sudo mount --bind /usr/src/rbp464-source-5.10.78-2-osmc /opt/osmc-tc/aarch64-toolchain-osmc/usr/src/rbp464-source-5.10.78-2-osmc
cd /opt/osmc-tc/aarch64-toolchain-osmc/usr/src && sudo ln -fs rbp464-source-5.10.78-2-osmc linux
sudo cp -p /etc/resolv.conf /opt/osmc-tc/aarch64-toolchain-osmc/etc/
sudo chroot /opt/osmc-tc/aarch64-toolchain-osmc /bin/sh -c 'apt-get update && apt-get install -y bc'
Get:1 http://security.debian.org buster/updates InRelease [65.4 kB]
Get:2 http://ftp.debian.org/debian buster InRelease [122 kB]
Get:3 http://ftp.debian.org/debian buster-updates InRelease [51.9 kB]
Get:4 http://ftp.fau.de/osmc/osmc/apt buster-devel InRelease [4711 B]
Get:5 http://security.debian.org buster/updates/main arm64 Packages [307 kB]
Get:6 http://security.debian.org buster/updates/main Translation-en [166 kB]
Get:7 http://security.debian.org buster/updates/non-free Translation-en [344 B]
Get:8 http://ftp.debian.org/debian buster/main arm64 Packages [7735 kB]
Get:9 http://ftp.debian.org/debian buster/main Translation-en [5968 kB]
Get:10 http://ftp.fau.de/osmc/osmc/apt buster-devel/main arm64 Packages [33.7 kB]
Get:11 http://ftp.debian.org/debian buster/contrib arm64 Packages [38.4 kB]
Get:12 http://ftp.debian.org/debian buster/contrib Translation-en [44.2 kB]
Get:13 http://ftp.debian.org/debian buster/non-free arm64 Packages [53.9 kB]
Get:14 http://ftp.debian.org/debian buster/non-free Translation-en [88.8 kB]
Get:15 http://ftp.debian.org/debian buster-updates/main arm64 Packages [14.5 kB]
Get:16 http://ftp.debian.org/debian buster-updates/main Translation-en [13.9 kB]
Fetched 14.7 MB in 8s (1846 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
libgpm2 libncurses6 libreadline7 readline-common
Suggested packages:
gpm readline-doc
The following NEW packages will be installed:
bc libgpm2 libncurses6 libreadline7 readline-common
0 upgraded, 5 newly installed, 0 to remove and 24 not upgraded.
Need to get 435 kB of archives.
After this operation, 1121 kB of additional disk space will be used.
Get:1 http://ftp.debian.org/debian buster/main arm64 readline-common all 7.0-5 [70.6 kB]
Get:2 http://ftp.debian.org/debian buster/main arm64 libncurses6 arm64 6.1+20181013-2+deb10u2 [92.6 kB]
Get:3 http://ftp.debian.org/debian buster/main arm64 libreadline7 arm64 7.0-5 [134 kB]
Get:4 http://ftp.debian.org/debian buster/main arm64 bc arm64 1.07.1-2+b1 [104 kB]
Get:5 http://ftp.debian.org/debian buster/main arm64 libgpm2 arm64 1.20.7-5 [34.5 kB]
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "en_US.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
debconf: delaying package configuration, since apt-utils is not installed
Fetched 435 kB in 0s (1562 kB/s)
E: Can not write log (Is /dev/pts mounted?) - posix_openpt (19: No such device)
Selecting previously unselected package readline-common.
(Reading database ... 12440 files and directories currently installed.)
Preparing to unpack .../readline-common_7.0-5_all.deb ...
Unpacking readline-common (7.0-5) ...
Selecting previously unselected package libncurses6:arm64.
Preparing to unpack .../libncurses6_6.1+20181013-2+deb10u2_arm64.deb ...
Unpacking libncurses6:arm64 (6.1+20181013-2+deb10u2) ...
Selecting previously unselected package libreadline7:arm64.
Preparing to unpack .../libreadline7_7.0-5_arm64.deb ...
Unpacking libreadline7:arm64 (7.0-5) ...
Selecting previously unselected package bc.
Preparing to unpack .../bc_1.07.1-2+b1_arm64.deb ...
Unpacking bc (1.07.1-2+b1) ...
Selecting previously unselected package libgpm2:arm64.
Preparing to unpack .../libgpm2_1.20.7-5_arm64.deb ...
Unpacking libgpm2:arm64 (1.20.7-5) ...
Setting up libgpm2:arm64 (1.20.7-5) ...
Setting up libncurses6:arm64 (6.1+20181013-2+deb10u2) ...
Setting up readline-common (7.0-5) ...
Setting up libreadline7:arm64 (7.0-5) ...
Setting up bc (1.07.1-2+b1) ...
Processing triggers for libc-bin (2.28-10) ...
sudo cp -p /boot/config-5.10.78-2-osmc /usr/src/rbp464-source-5.10.78-2-osmc/.config
sudo chroot /opt/osmc-tc/aarch64-toolchain-osmc /bin/sh -c 'cd /usr/src/rbp464-source-5.10.78-2-osmc && make modules_prepare'
SYNC include/config/auto.conf.cmd
WRAP arch/arm64/include/generated/uapi/asm/kvm_para.h
WRAP arch/arm64/include/generated/uapi/asm/errno.h
WRAP arch/arm64/include/generated/uapi/asm/ioctl.h
WRAP arch/arm64/include/generated/uapi/asm/ioctls.h
WRAP arch/arm64/include/generated/uapi/asm/ipcbuf.h
WRAP arch/arm64/include/generated/uapi/asm/msgbuf.h
WRAP arch/arm64/include/generated/uapi/asm/poll.h
WRAP arch/arm64/include/generated/uapi/asm/resource.h
WRAP arch/arm64/include/generated/uapi/asm/sembuf.h
WRAP arch/arm64/include/generated/uapi/asm/shmbuf.h
WRAP arch/arm64/include/generated/uapi/asm/siginfo.h
WRAP arch/arm64/include/generated/uapi/asm/socket.h
WRAP arch/arm64/include/generated/uapi/asm/sockios.h
WRAP arch/arm64/include/generated/uapi/asm/stat.h
WRAP arch/arm64/include/generated/uapi/asm/swab.h
WRAP arch/arm64/include/generated/uapi/asm/termbits.h
WRAP arch/arm64/include/generated/uapi/asm/termios.h
WRAP arch/arm64/include/generated/uapi/asm/types.h
WRAP arch/arm64/include/generated/asm/early_ioremap.h
WRAP arch/arm64/include/generated/asm/mcs_spinlock.h
WRAP arch/arm64/include/generated/asm/qrwlock.h
WRAP arch/arm64/include/generated/asm/qspinlock.h
WRAP arch/arm64/include/generated/asm/set_memory.h
WRAP arch/arm64/include/generated/asm/user.h
WRAP arch/arm64/include/generated/asm/bugs.h
WRAP arch/arm64/include/generated/asm/delay.h
WRAP arch/arm64/include/generated/asm/div64.h
WRAP arch/arm64/include/generated/asm/dma-mapping.h
WRAP arch/arm64/include/generated/asm/dma.h
WRAP arch/arm64/include/generated/asm/emergency-restart.h
WRAP arch/arm64/include/generated/asm/hw_irq.h
WRAP arch/arm64/include/generated/asm/irq_regs.h
WRAP arch/arm64/include/generated/asm/kdebug.h
WRAP arch/arm64/include/generated/asm/kmap_types.h
WRAP arch/arm64/include/generated/asm/local.h
WRAP arch/arm64/include/generated/asm/local64.h
WRAP arch/arm64/include/generated/asm/mm-arch-hooks.h
WRAP arch/arm64/include/generated/asm/mmiowb.h
WRAP arch/arm64/include/generated/asm/msi.h
WRAP arch/arm64/include/generated/asm/rwonce.h
WRAP arch/arm64/include/generated/asm/serial.h
WRAP arch/arm64/include/generated/asm/switch_to.h
WRAP arch/arm64/include/generated/asm/trace_clock.h
WRAP arch/arm64/include/generated/asm/unaligned.h
WRAP arch/arm64/include/generated/asm/vga.h
UPD include/config/kernel.release
UPD include/generated/uapi/linux/version.h
UPD include/generated/utsrelease.h
CC scripts/mod/empty.o
HOSTCC scripts/mod/mk_elfconfig
MKELF scripts/mod/elfconfig.h
HOSTCC scripts/mod/modpost.o
CC scripts/mod/devicetable-offsets.s
UPD scripts/mod/devicetable-offsets.h
HOSTCC scripts/mod/file2alias.o
HOSTCC scripts/mod/sumversion.o
HOSTLD scripts/mod/modpost
CC kernel/bounds.s
UPD include/generated/bounds.h
UPD include/generated/timeconst.h
CC arch/arm64/kernel/asm-offsets.s
UPD include/generated/asm-offsets.h
CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
LDS arch/arm64/kernel/vdso/vdso.lds
CC arch/arm64/kernel/vdso/vgettimeofday.o
AS arch/arm64/kernel/vdso/note.o
AS arch/arm64/kernel/vdso/sigreturn.o
LD arch/arm64/kernel/vdso/vdso.so.dbg
VDSOSYM include/generated/vdso-offsets.h
LDS scripts/module.lds
cd xpadneo/hid-xpadneo && make ../VERSION
make[1]: Entering directory '/home/osmc/xpadneo/hid-xpadneo'
git describe --tags --dirty >../VERSION
make[1]: Leaving directory '/home/osmc/xpadneo/hid-xpadneo'
sudo rm -rf /opt/osmc-tc/aarch64-toolchain-osmc/root/xpadneo && sudo cp -r xpadneo /opt/osmc-tc/aarch64-toolchain-osmc/root/
sudo chroot /opt/osmc-tc/aarch64-toolchain-osmc /bin/sh -c 'cd /root/xpadneo/hid-xpadneo && make modules'
make -C /usr/src/linux INSTALL_MOD_DIR="kernel/drivers/hid" LD=ld.bfd M=/root/xpadneo/hid-xpadneo/src VERSION="v0.9-93-gcf392a7" modules
make[1]: Entering directory '/usr/src/rbp464-source-5.10.78-2-osmc'
cp /root/xpadneo/hid-xpadneo/src/hid-xpadneo.c /root/xpadneo/hid-xpadneo/src/xpadneo.c
CC [M] /root/xpadneo/hid-xpadneo/src/xpadneo.o
CC [M] /root/xpadneo/hid-xpadneo/src/xpadneo/core.o
CC [M] /root/xpadneo/hid-xpadneo/src/xpadneo/consumer.o
LD [M] /root/xpadneo/hid-xpadneo/src/hid-xpadneo.o
WARNING: Symbol version dump "Module.symvers" is missing.
Modules may not have dependencies or modversions.
MODPOST /root/xpadneo/hid-xpadneo/src/Module.symvers
WARNING: modpost: Symbol info of vmlinux is missing. Unresolved symbol check will be entirely skipped.
CC [M] /root/xpadneo/hid-xpadneo/src/hid-xpadneo.mod.o
LD [M] /root/xpadneo/hid-xpadneo/src/hid-xpadneo.ko
make[1]: Leaving directory '/usr/src/rbp464-source-5.10.78-2-osmc'
sudo install -m644 -o osmc -g osmc /opt/osmc-tc/aarch64-toolchain-osmc/root/xpadneo/hid-xpadneo/src/hid-xpadneo.ko hid-xpadneo.ko
#!/usr/bin/make -f
KERNEL_VERSION=$(shell uname -r)
KERNEL_HEADERS_DIR=/usr/src/rbp464-headers-$(KERNEL_VERSION)
KERNEL_SOURCES_DIR=/usr/src/rbp464-source-$(KERNEL_VERSION)
CHROOT_DIR=/opt/osmc-tc/aarch64-toolchain-osmc
ifeq ($(shell id -u), 0)
SUDO=
OUSER=$(SUDO_USER)
else
SUDO=sudo
OUSER=$(shell id -un)
endif
OGROUP=$(shell id -gn $(OUSER))
default: hid-xpadneo.ko
$(CHROOT_DIR):
$(SUDO) apt-get install -y aarch64-toolchain-osmc
$(KERNEL_HEADERS_DIR)/Kconfig:
$(SUDO) apt-get install -y rbp464-headers-$(KERNEL_VERSION)
$(KERNEL_SOURCES_DIR)/Kconfig:
$(SUDO) apt-get install -y rbp464-source-$(KERNEL_VERSION)
$(CHROOT_DIR)$(KERNEL_HEADERS_DIR)/Kconfig: | $(CHROOT_DIR) $(KERNEL_HEADERS_DIR)/Kconfig
$(SUDO) mkdir -p $(CHROOT_DIR)$(KERNEL_HEADERS_DIR)
$(SUDO) mount --bind $(KERNEL_HEADERS_DIR) $(CHROOT_DIR)$(KERNEL_HEADERS_DIR)
$(CHROOT_DIR)$(KERNEL_SOURCES_DIR)/Kconfig: | $(CHROOT_DIR) $(KERNEL_SOURCES_DIR)/Kconfig
$(SUDO) mkdir -p $(CHROOT_DIR)$(KERNEL_SOURCES_DIR)
$(SUDO) mount --bind $(KERNEL_SOURCES_DIR) $(CHROOT_DIR)$(KERNEL_SOURCES_DIR)
$(CHROOT_DIR)/usr/src/linux: | $(CHROOT_DIR) $(KERNEL_SOURCES_DIR)
cd $(CHROOT_DIR)/usr/src && $(SUDO) ln -fs rbp464-source-$(KERNEL_VERSION) linux
chroot-bindings: $(CHROOT_DIR) $(CHROOT_DIR)$(KERNEL_HEADERS_DIR)/Kconfig $(CHROOT_DIR)$(KERNEL_SOURCES_DIR)/Kconfig $(CHROOT_DIR)/usr/src/linux
$(CHROOT_DIR)/etc/resolv.conf:
$(SUDO) cp -p /etc/resolv.conf $(CHROOT_DIR)/etc/
$(CHROOT_DIR)/usr/bin/bc: | $(CHROOT_DIR)/etc/resolv.conf
$(SUDO) chroot $(CHROOT_DIR) /bin/sh -c 'apt-get update && apt-get install -y bc'
chroot-extra: $(CHROOT_DIR) $(CHROOT_DIR)/etc/resolv.conf $(CHROOT_DIR)/usr/bin/bc
$(KERNEL_SOURCES_DIR)/.config:
$(SUDO) cp -p /boot/config-$(KERNEL_VERSION) $@
$(CHROOT_DIR)$(KERNEL_SOURCES_DIR)/scripts/module.lds: | chroot-bindings chroot-extra $(KERNEL_SOURCES_DIR)/.config $(CHROOT_DIR)/usr/bin/bc
$(SUDO) chroot $(CHROOT_DIR) /bin/sh -c 'cd $(KERNEL_SOURCES_DIR) && make modules_prepare'
modules_prepare: $(CHROOT_DIR)$(KERNEL_SOURCES_DIR)/scripts/module.lds
xpadneo:
git clone https://github.com/atar-axis/xpadneo.git
hid-xpadneo.ko: xpadneo | modules_prepare
cd xpadneo/hid-xpadneo && make ../VERSION
$(SUDO) rm -rf $(CHROOT_DIR)/root/xpadneo && $(SUDO) cp -r xpadneo $(CHROOT_DIR)/root/
$(SUDO) chroot $(CHROOT_DIR) /bin/sh -c 'cd /root/xpadneo/hid-xpadneo && make modules'
$(SUDO) install -m644 -o $(OUSER) -g $(OGROUP) $(CHROOT_DIR)/root/xpadneo/hid-xpadneo/src/hid-xpadneo.ko $@
mount: $(CHROOT_DIR)$(KERNEL_HEADERS_DIR)/Kconfig $(CHROOT_DIR)$(KERNEL_SOURCES_DIR)/Kconfig
umount:
test -n "`mount | grep -- 'on $(CHROOT_DIR)$(KERNEL_HEADERS_DIR)'`" && $(SUDO) umount $(CHROOT_DIR)$(KERNEL_HEADERS_DIR) ||:
test -n "`mount | grep -- 'on $(CHROOT_DIR)$(KERNEL_SOURCES_DIR)'`" && $(SUDO) umount $(CHROOT_DIR)$(KERNEL_SOURCES_DIR) ||:
clean: umount
rm -rf xpadneo hid-xpadneo.ko
purge: clean
$(SUDO) dpkg -P rbp464-headers-$(KERNEL_VERSION) rbp464-source-$(KERNEL_VERSION) aarch64-toolchain-osmc
$(SUDO) rm -rf $(KERNEL_SOURCES_DIR)
.PHONY: umount clean purge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment