Skip to content

Commit

Permalink
Rockchip: add 32-bit userland support
Browse files Browse the repository at this point in the history
  • Loading branch information
Kwiboo committed Jul 30, 2017
1 parent 98735f5 commit 477290b
Show file tree
Hide file tree
Showing 13 changed files with 161 additions and 33 deletions.
5 changes: 2 additions & 3 deletions config/arch.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
TARGET_SUBARCH=aarch64
TARGET_VARIANT=armv8-a
TARGET_ABI=eabi
TARGET_EXTRA_FLAGS="-mcpu=${TARGET_CPU}${TARGET_CPU_FLAGS}"
SIMD_SUPPORT="yes"
;;
esac
Expand All @@ -23,6 +22,6 @@
TARGET_KERNEL_ARCH=arm64

# setup ARCH specific *FLAGS
TARGET_CFLAGS="-march=${TARGET_VARIANT}${TARGET_CPU_FLAGS} -mabi=lp64 -Wno-psabi $TARGET_EXTRA_FLAGS"
TARGET_LDFLAGS="-march=${TARGET_VARIANT}${TARGET_CPU_FLAGS} -mtune=$TARGET_CPU"
TARGET_CFLAGS="-mcpu=${TARGET_CPU}${TARGET_CPU_FLAGS} -mabi=lp64 -Wno-psabi"
TARGET_LDFLAGS="-mcpu=${TARGET_CPU}${TARGET_CPU_FLAGS}"
GCC_OPTS="--with-abi=lp64 --with-arch=$TARGET_VARIANT"
18 changes: 8 additions & 10 deletions config/arch.arm
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,29 @@
arm1176jzf-s)
TARGET_SUBARCH=armv6zk
TARGET_ABI=eabi
TARGET_EXTRA_FLAGS="-mcpu=$TARGET_CPU"
TARGET_FPU_FLAGS="-mfloat-abi=$TARGET_FLOAT -mfpu=$TARGET_FPU"
SIMD_SUPPORT="no"
;;
cortex-a7|cortex-a15|cortex-a17|cortex-a15.cortex-a7|cortex-a17.cortex-a7)
TARGET_SUBARCH=armv7ve
TARGET_ABI=eabi
TARGET_EXTRA_FLAGS="-mcpu=$TARGET_CPU"
TARGET_FPU_FLAGS="-mfloat-abi=$TARGET_FLOAT -mfpu=$TARGET_FPU"
SIMD_SUPPORT="yes"
;;
cortex-a5|cortex-a8|cortex-a9)
TARGET_SUBARCH=armv7-a
TARGET_ABI=eabi
TARGET_EXTRA_FLAGS="-mcpu=$TARGET_CPU"
TARGET_FPU_FLAGS="-mfloat-abi=$TARGET_FLOAT -mfpu=$TARGET_FPU"
SIMD_SUPPORT="yes"
;;
cortex-a53)
TARGET_SUBARCH=armv8-a
TARGET_ABI=eabi
SIMD_SUPPORT="yes"
;;
esac

TARGET_GCC_ARCH=${TARGET_SUBARCH/-}
TARGET_KERNEL_ARCH=arm
TARGET_KERNEL_ARCH=${TARGET_KERNEL_ARCH:-arm}

# setup ARCH specific *FLAGS
TARGET_CFLAGS="-march=$TARGET_SUBARCH -mabi=aapcs-linux -Wno-psabi -Wa,-mno-warn-deprecated $TARGET_EXTRA_FLAGS"
[ -n "$TARGET_FPU" ] && TARGET_CFLAGS="$TARGET_CFLAGS $TARGET_FPU_FLAGS"
TARGET_LDFLAGS="-march=$TARGET_SUBARCH -mtune=$TARGET_CPU"
TARGET_CFLAGS="-mcpu=$TARGET_CPU -mabi=aapcs-linux -Wno-psabi -Wa,-mno-warn-deprecated -mfloat-abi=$TARGET_FLOAT -mfpu=$TARGET_FPU"
TARGET_LDFLAGS="-mcpu=$TARGET_CPU"
GCC_OPTS="--with-abi=aapcs-linux --with-arch=$TARGET_SUBARCH --with-float=$TARGET_FLOAT --with-fpu=$TARGET_FPU"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff -Naur Python-2.7.13.orig/Lib/platform.py Python-2.7.13/Lib/platform.py
--- Python-2.7.13.orig/Lib/platform.py 2017-01-08 11:57:36.615886244 +0100
+++ Python-2.7.13/Lib/platform.py 2017-01-08 12:12:44.567848271 +0100
@@ -1250,6 +1250,9 @@
system = 'Windows'
release = 'Vista'

+ if machine == 'aarch64' and architecture()[0] == '32bit':
+ machine = 'armv7l'
+
_uname_cache = system,node,release,version,machine,processor
return _uname_cache

50 changes: 31 additions & 19 deletions packages/linux/package.mk
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,14 @@ esac
PKG_IS_ADDON="no"
PKG_AUTORECONF="no"

PKG_MAKE_OPTS_HOST="ARCH=$TARGET_KERNEL_ARCH headers_check"
if [ "$TARGET_KERNEL_ARCH" = "arm64" -a "$TARGET_ARCH" = "arm" ]; then
PKG_DEPENDS_TARGET="$PKG_DEPENDS_TARGET gcc-linaro-aarch64-elf:host"
export PATH=$TOOLCHAIN/lib/gcc-linaro-aarch64-elf/bin:$PATH
TARGET_PREFIX=aarch64-elf-
PKG_MAKE_OPTS_HOST="ARCH=$TARGET_ARCH headers_check"
else
PKG_MAKE_OPTS_HOST="ARCH=$TARGET_KERNEL_ARCH headers_check"
fi

if [ "$TARGET_ARCH" = "x86_64" ]; then
PKG_DEPENDS_TARGET="$PKG_DEPENDS_TARGET intel-ucode:host kernel-firmware"
Expand All @@ -90,24 +97,25 @@ if [ "$BUILD_ANDROID_BOOTIMG" = "yes" ]; then
fi

post_patch() {
if [ -n "$DEVICE" -a -f $PROJECT_DIR/$PROJECT/devices/$DEVICE/$PKG_NAME/$PKG_VERSION/$PKG_NAME.$TARGET_ARCH.conf ]; then
KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/devices/$DEVICE/$PKG_NAME/$PKG_VERSION/$PKG_NAME.$TARGET_ARCH.conf
elif [ -n "$DEVICE" -a -f $PROJECT_DIR/$PROJECT/devices/$DEVICE/$PKG_NAME/$LINUX/$PKG_NAME.$TARGET_ARCH.conf ]; then
KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/devices/$DEVICE/$PKG_NAME/$LINUX/$PKG_NAME.$TARGET_ARCH.conf
elif [ -n "$DEVICE" -a -f $PROJECT_DIR/$PROJECT/devices/$DEVICE/$PKG_NAME/$PKG_NAME.$TARGET_ARCH.conf ]; then
KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/devices/$DEVICE/$PKG_NAME/$PKG_NAME.$TARGET_ARCH.conf
elif [ -f $PROJECT_DIR/$PROJECT/$PKG_NAME/$PKG_VERSION/$PKG_NAME.$TARGET_ARCH.conf ]; then
KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/$PKG_NAME/$PKG_VERSION/$PKG_NAME.$TARGET_ARCH.conf
elif [ -f $PROJECT_DIR/$PROJECT/$PKG_NAME/$LINUX/$PKG_NAME.$TARGET_ARCH.conf ]; then
KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/$PKG_NAME/$LINUX/$PKG_NAME.$TARGET_ARCH.conf
elif [ -f $PROJECT_DIR/$PROJECT/$PKG_NAME/$PKG_NAME.$TARGET_ARCH.conf ]; then
KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/$PKG_NAME/$PKG_NAME.$TARGET_ARCH.conf
elif [ -f $PKG_DIR/config/$PKG_VERSION/$PKG_NAME.$TARGET_ARCH.conf ]; then
KERNEL_CFG_FILE=$PKG_DIR/config/$PKG_VERSION/$PKG_NAME.$TARGET_ARCH.conf
elif [ -f $PKG_DIR/config/$LINUX/$PKG_NAME.$TARGET_ARCH.conf ]; then
KERNEL_CFG_FILE=$PKG_DIR/config/$LINUX/$PKG_NAME.$TARGET_ARCH.conf
CFG_FILE="$PKG_NAME.${TARGET_PATCH_ARCH:-$TARGET_ARCH}.conf"
if [ -n "$DEVICE" -a -f $PROJECT_DIR/$PROJECT/devices/$DEVICE/$PKG_NAME/$PKG_VERSION/$CFG_FILE ]; then
KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/devices/$DEVICE/$PKG_NAME/$PKG_VERSION/$CFG_FILE
elif [ -n "$DEVICE" -a -f $PROJECT_DIR/$PROJECT/devices/$DEVICE/$PKG_NAME/$LINUX/$CFG_FILE ]; then
KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/devices/$DEVICE/$PKG_NAME/$LINUX/$CFG_FILE
elif [ -n "$DEVICE" -a -f $PROJECT_DIR/$PROJECT/devices/$DEVICE/$PKG_NAME/$CFG_FILE ]; then
KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/devices/$DEVICE/$PKG_NAME/$CFG_FILE
elif [ -f $PROJECT_DIR/$PROJECT/$PKG_NAME/$PKG_VERSION/$CFG_FILE ]; then
KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/$PKG_NAME/$PKG_VERSION/$CFG_FILE
elif [ -f $PROJECT_DIR/$PROJECT/$PKG_NAME/$LINUX/$CFG_FILE ]; then
KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/$PKG_NAME/$LINUX/$CFG_FILE
elif [ -f $PROJECT_DIR/$PROJECT/$PKG_NAME/$CFG_FILE ]; then
KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/$PKG_NAME/$CFG_FILE
elif [ -f $PKG_DIR/config/$PKG_VERSION/$CFG_FILE ]; then
KERNEL_CFG_FILE=$PKG_DIR/config/$PKG_VERSION/$CFG_FILE
elif [ -f $PKG_DIR/config/$LINUX/$CFG_FILE ]; then
KERNEL_CFG_FILE=$PKG_DIR/config/$LINUX/$CFG_FILE
else
KERNEL_CFG_FILE=$PKG_DIR/config/$PKG_NAME.$TARGET_ARCH.conf
KERNEL_CFG_FILE=$PKG_DIR/config/$CFG_FILE
fi

sed -i -e "s|^HOSTCC[[:space:]]*=.*$|HOSTCC = $TOOLCHAIN/bin/host-gcc|" \
Expand Down Expand Up @@ -150,7 +158,11 @@ post_patch() {
}

makeinstall_host() {
make ARCH=$TARGET_KERNEL_ARCH INSTALL_HDR_PATH=dest headers_install
if [ "$TARGET_KERNEL_ARCH" = "arm64" -a "$TARGET_ARCH" = "arm" ]; then
make ARCH=$TARGET_ARCH INSTALL_HDR_PATH=dest headers_install
else
make ARCH=$TARGET_KERNEL_ARCH INSTALL_HDR_PATH=dest headers_install
fi
mkdir -p $SYSROOT_PREFIX/usr/include
cp -R dest/include/* $SYSROOT_PREFIX/usr/include
}
Expand Down
1 change: 1 addition & 0 deletions projects/Rockchip/devices/RK3328/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ This is a highly experimental project for RK3328 SoC devices
**Build**

* `PROJECT=Rockchip DEVICE=RK3328 ARCH=aarch64 make image`
* `PROJECT=Rockchip DEVICE=RK3328 ARCH=arm make image`
7 changes: 7 additions & 0 deletions projects/Rockchip/devices/RK3328/options
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
TARGET_CPU="cortex-a53"
TARGET_CPU_FLAGS="+crc+crypto"
;;
arm)
TARGET_CPU="cortex-a53"
TARGET_FLOAT="hard"
TARGET_FPU="crypto-neon-fp-armv8"
TARGET_KERNEL_ARCH="arm64"
TARGET_PATCH_ARCH="aarch64"
;;
esac

# Configuration for u-boot
Expand Down
1 change: 1 addition & 0 deletions projects/Rockchip/devices/ROCK64/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ This is a highly experimental project for the PINE64 ROCK64
**Build**

* `PROJECT=Rockchip DEVICE=ROCK64 ARCH=aarch64 make image`
* `PROJECT=Rockchip DEVICE=ROCK64 ARCH=arm make image`
7 changes: 7 additions & 0 deletions projects/Rockchip/devices/ROCK64/options
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
TARGET_CPU="cortex-a53"
TARGET_CPU_FLAGS="+crc+crypto"
;;
arm)
TARGET_CPU="cortex-a53"
TARGET_FLOAT="hard"
TARGET_FPU="crypto-neon-fp-armv8"
TARGET_KERNEL_ARCH="arm64"
TARGET_PATCH_ARCH="aarch64"
;;
esac

# Configuration for u-boot
Expand Down
41 changes: 41 additions & 0 deletions projects/Rockchip/packages/gcc-linaro-aarch64-elf/package.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
################################################################################
# This file is part of LibreELEC - https://libreelec.tv
# Copyright (C) 2017 Team LibreELEC
#
# LibreELEC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# LibreELEC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LibreELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################

PKG_NAME="gcc-linaro-aarch64-elf"
PKG_VERSION="6.3.1-2017.05"
PKG_ARCH="any"
PKG_LICENSE="GPL"
PKG_SITE=""
PKG_URL="https://releases.linaro.org/components/toolchain/binaries/6.3-2017.05/aarch64-elf/gcc-linaro-${PKG_VERSION}-x86_64_aarch64-elf.tar.xz"
PKG_SOURCE_DIR="gcc-linaro-${PKG_VERSION}-x86_64_aarch64-elf"
PKG_DEPENDS_HOST="toolchain"
PKG_SECTION="lang"
PKG_SHORTDESC=""
PKG_LONGDESC=""

PKG_IS_ADDON="no"
PKG_AUTORECONF="no"

make_host() {
:
}

makeinstall_host() {
mkdir -p $TOOLCHAIN/lib/gcc-linaro-aarch64-elf/
cp -a * $TOOLCHAIN/lib/gcc-linaro-aarch64-elf
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
From 376fb9c7c24c3b8a322cd583839d582cd7041d47 Mon Sep 17 00:00:00 2001
From: Jakob Unterwurzacher <[email protected]>
Date: Mon, 29 May 2017 14:08:43 +0200
Subject: [PATCH] [drm] fix 32-bit mmap issue on 64-bit kernels

Running 32-bit userland on a 64-bit kernel resulted in the error:

mpp_drm: mmap failed: Invalid argument

Both the pagesize_mask and the mmap call truncated the offset
value to 32 bit. This patch fixes both issues.

For details see https://github.com/rockchip-linux/kernel/issues/17
---
osal/allocator/allocator_drm.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/osal/allocator/allocator_drm.c b/osal/allocator/allocator_drm.c
index 3057671f..9a4e31fe 100644
--- a/osal/allocator/allocator_drm.c
+++ b/osal/allocator/allocator_drm.c
@@ -15,6 +15,8 @@
*/

#define MODULE_TAG "mpp_drm"
+/* Enable 64-bit mmap also when compiling for 32 bit */
+#define _FILE_OFFSET_BITS 64

#include <unistd.h>
#include <string.h>
@@ -67,7 +69,7 @@ static int drm_ioctl(int fd, int req, void *arg)

static void* drm_mmap(int fd, size_t len, int prot, int flags, loff_t offset)
{
- static unsigned long pagesize_mask = 0;
+ static loff_t pagesize_mask = 0;
#if !defined(__gnu_linux__)
func_mmap64 fp_mmap64 = mpp_rt_get_mmap64();
#endif
6 changes: 6 additions & 0 deletions projects/Rockchip/packages/u-boot/package.mk
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ PKG_LONGDESC="Das U-Boot is a cross-platform bootloader for embedded systems, us
PKG_IS_ADDON="no"
PKG_AUTORECONF="no"

if [ "$TARGET_KERNEL_ARCH" = "arm64" -a "$TARGET_ARCH" = "arm" ]; then
PKG_DEPENDS_TARGET="$PKG_DEPENDS_TARGET gcc-linaro-aarch64-elf:host"
export PATH=$TOOLCHAIN/lib/gcc-linaro-aarch64-elf/bin:$PATH
TARGET_PREFIX=aarch64-elf-
fi

if [ "$UBOOT_SOC" = "rk3328" ]; then
PKG_DEPENDS_TARGET="$PKG_DEPENDS_TARGET rkbin"
PKG_NEED_UNPACK="$(get_pkg_directory rkbin)"
Expand Down
4 changes: 4 additions & 0 deletions scripts/image
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ find $INSTALL/usr/lib/modules/$MODVER/ -name *.ko | \
$TOOLCHAIN/bin/depmod -b $INSTALL/usr -a -e -F "$BUILD/linux-$(kernel_version)/System.map" $MODVER

# strip kernel modules
if [ "$TARGET_KERNEL_ARCH" = "arm64" -a "$TARGET_ARCH" = "arm" ]; then
export PATH=$TOOLCHAIN/lib/gcc-linaro-aarch64-elf/bin:$PATH
STRIP=aarch64-elf-strip
fi
for MOD in `find $INSTALL/usr/lib/modules/ -type f -name *.ko`; do
$STRIP --strip-debug $MOD
done
Expand Down
2 changes: 1 addition & 1 deletion scripts/unpack
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ if [ -d "$SOURCES/$1" -o -d "$PKG_DIR/sources" ]; then
if [ "$TARGET_ARCH" = "x86_64" ]; then
PATCH_ARCH="x86"
else
PATCH_ARCH="$TARGET_ARCH"
PATCH_ARCH="${TARGET_PATCH_ARCH:-$TARGET_ARCH}"
fi

PATCH_DIRS_PKG=""
Expand Down

0 comments on commit 477290b

Please sign in to comment.