@furiousben
The HiKey 4.1 kernel I used for the Android demo
The Xenomai tree (userspace)
The userspace has a gpiopwm executable that can be accessed via adb or via UDP (if you wish to control your motors from a server somewhere instead of the Android screen).
You then need to install glibc on the Android target making sure the dynamic linker can be found (there are a number of documents on the web on how to do that); you will also have to install the Xenomai libaries on the Android rootfs.
I wrote some notes back then for private consumption which I’ll paste here (maybe things can be done differently in a better way, I dont know)
[...]
$ cd aosp
$ mkdir rootfs-glibc
$ mkdir rootfs-glibc/rootfs
$ cd rootfs-glibc
1 Add makefile:
===============
[jramirez@titan rootfs-glibc]$ cat Android.mk
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
# This part is a hack, we're doing "addprefix" because if we don't,
# this dependency will be stripped out by the build system
GLIBC_ROOTFS := $(addprefix $(TARGET_OUT)/, rootfs-glibc)
$(GLIBC_ROOTFS):
mkdir -p $(TARGET_OUT)/glibc
cp -af $(TOPDIR)rootfs-glibc/rootfs/* $(TARGET_OUT)/glibc
ALL_PREBUILT += $(GLIBC_ROOTFS)
2. populate rootfs (can add detail later)
===========================================
- the aarch64 dynamic linker is ld-linux-aarch64.so.1 (as per the aarch64 elf files)
- copy the libs from linaros 16.03 release (or generate your own with debian tools)
- install busybox if you want..
3. modify the build so it steps into rootfs-glibc
=================================================
[jramirez@titan build ((37aa85e...) *)]$ pwd
/home/jramirez/fssd/hikey/android/build
[jramirez@titan build ((37aa85e...) *)]$ git diff
diff --git a/core/legacy_prebuilts.mk b/core/legacy_prebuilts.mk
index f4633d0..8e9bfed 100644
--- a/core/legacy_prebuilts.mk
+++ b/core/legacy_prebuilts.mk
@@ -26,6 +26,7 @@ GRANDFATHERED_ALL_PREBUILT := \
ime \
input \
monkey \
+ rootfs-glibc \
pm \
RFFspeed_501.bmd \
RFFstd_501.bmd \
4. modify system/core to add executable permissions and create symlinks
=======================================================================
[jramirez@titan core ((6c03e31...) +)]$ git diff HEAD
diff --git a/libcutils/fs_config.c b/libcutils/fs_config.c
index 6d50adc..415edcc 100644
--- a/libcutils/fs_config.c
+++ b/libcutils/fs_config.c
@@ -151,6 +151,18 @@ static const struct fs_path_config android_files[] = {
{ 00755, AID_ROOT, AID_SHELL, 0, "vendor/bin/*" },
{ 00750, AID_ROOT, AID_SHELL, 0, "sbin/*" },
{ 00755, AID_ROOT, AID_ROOT, 0, "bin/*" },
+ { 00755, AID_ROOT, AID_ROOT, 0, "system/glibc/lib/*" },
+ { 00755, AID_ROOT, AID_ROOT, 0, "system/glibc/bin/*" },
+ { 00755, AID_ROOT, AID_ROOT, 0, "system/glibc/sbin/*" },
+ { 00755, AID_ROOT, AID_ROOT, 0, "system/glibc/usr/bin/*" },
+ { 00755, AID_ROOT, AID_ROOT, 0, "system/glibc/usr/sbin/*" },
+ { 00755, AID_ROOT, AID_ROOT, 0, "system/glibc/usr/bin/*" },
+ { 00755, AID_ROOT, AID_ROOT, 0, "system/glibc/usr/sbin/*" },
+ { 00755, AID_ROOT, AID_ROOT, 0, "system/glibc/usr/lib/*" },
+ { 00755, AID_ROOT, AID_ROOT, 0, "system/glibc/usr/xenomai-cobalt/bin/*" },
+ { 00755, AID_ROOT, AID_ROOT, 0, "system/glibc/usr/xenomai-cobalt/sbin/*" },
+ { 00755, AID_ROOT, AID_ROOT, 0, "system/glibc/usr/xenomai-cobalt/lib/*" },
+ { 00755, AID_ROOT, AID_ROOT, 0, "system/glibc/usr/xenomai-cobalt/demo/*" },
{ 00750, AID_ROOT, AID_SHELL, 0, "init*" },
{ 00750, AID_ROOT, AID_SHELL, 0, "sbin/fs_mgr" },
{ 00640, AID_ROOT, AID_SHELL, 0, "fstab.*" },
diff --git a/rootdir/init.rc b/rootdir/init.rc
index aa32343..d631299 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -38,6 +38,12 @@ on init
# Backward compatibility.
symlink /system/etc /etc
symlink /sys/kernel/debug /d
+ symlink /system/glibc/bin /bin
+ symlink /system/glibc/lib /lib
+ symlink /system/glibc/lib /lib64
+ symlink /system/glibc/usr/xenomai-cobalt/lib /xeno.lib
+ symlink /system/glibc/usr/xenomai-cobalt/bin /xeno.bin
+ symlink /system/glibx/usr/xenomai-cobalt/demo /xeno.demo
# Link /vendor to /system/vendor for devices without a vendor partition.
symlink /system/vendor /vendor
5. TODO
=======
- devtmpfs is not being created and mounting it after boot seems to cause problems
(xenomai RTDM workaround:
- cd /dev
- ln -s /dev/ /dev/rtdm
- LD_LIBRARY_PATH needs to setup manually
[...]
I hope that helps.