Browse Source

add support for csky in oe-core

tianshuliang 3 years ago
parent
commit
2ec67c069f

+ 67 - 0
envsetup.sh

@@ -0,0 +1,67 @@
+#!/bin/sh
+
+function gettop
+{
+    local TOPFILE=openembedded-core/envsetup.sh
+    if [ -n "$MPSOC_TOP" -a -f "$MPSOC_TOP/$TOPFILE" ] ; then
+        # The following circumlocution ensures we remove symlinks from TOP.
+        (\cd $MPSOC_TOP; PWD= /bin/pwd)
+    else
+        if [ -f $TOPFILE ] ; then
+            # The following circumlocution (repeated below as well) ensures
+            # that we record the true directory name and not one that is
+            # faked up with symlink names.
+            PWD= /bin/pwd
+        else
+            local here="${PWD}"
+            while [ "${here}" != "/" ]; do
+                if [ -f "${here}/${TOPFILE}" ]; then
+                    (\cd ${here}; PWD= /bin/pwd)
+                    break
+                fi
+                here="$(dirname ${here})"
+            done
+        fi
+    fi
+}
+
+
+pack_usage()
+{
+	printf "Usage: pack [-cARCH] [-iIMAGE] [-h]
+	-a ARCH (default: riscv)
+	-h print this help message
+"
+}
+
+T=$(gettop)
+ARCH=riscv
+IMAGE_DIR=thead-build/ice-base
+while getopts "a:o:h" arg
+do
+	case $arg in
+		a)
+			ARCH=${OPTARG}
+			;;
+		o)
+			IMAGE_DIR=${OPTARG}
+			;;
+		h)
+			pack_usage
+			exit 0
+			;;
+		*)
+		#exit 0
+		;;
+	esac
+done
+
+if [ "x$ARCH" = "x" ]; then
+	echo "ARCH:$ARCH not support"
+	exit 1
+fi
+#$T/scripts/pack_img.sh -c $chip -p $platform -b $board \
+echo "$T/openembedded-core/oe-init-build-env $IMAGE_DIR"
+[ -e ./openembedded-core/oe-init-build-env ] &&
+    source ./openembedded-core/oe-init-build-env $IMAGE_DIR
+

+ 1 - 0
meta/classes/kernel-arch.bbclass

@@ -31,6 +31,7 @@ def map_kernel_arch(a, d):
     elif re.match('mips(isa|)(32|64|)(r6|)(el|)$', a):      return 'mips'
     elif re.match('mcf', a):                    return 'm68k'
     elif re.match('riscv(32|64|)(eb|)$', a):    return 'riscv'
+    elif re.match('csky', a):    return 'csky'
     elif re.match('p(pc|owerpc)(|64)', a):      return 'powerpc'
     elif re.match('sh(3|4)$', a):               return 'sh'
     elif re.match('bfin', a):                   return 'blackfin'

+ 2 - 1
meta/classes/package.bbclass

@@ -1429,7 +1429,8 @@ python populate_packages () {
             mkdir_recurse(dvar, root, os.path.dirname(file))
             fpath = os.path.join(root,file)
             if not cpath.islink(file):
-                os.link(file, fpath)
+                if not os.path.exists(fpath):
+                    os.link(file, fpath)
                 continue
             ret = bb.utils.copyfile(file, fpath)
             if ret is False or ret == 0:

+ 3 - 0
meta/classes/siteinfo.bbclass

@@ -54,6 +54,7 @@ def siteinfo_data_for_machine(arch, os, d):
         "ppc64le" : "endian-little bit-64 powerpc-common",
         "riscv32": "endian-little bit-32 riscv-common",
         "riscv64": "endian-little bit-64 riscv-common",
+        "csky": "endian-little bit-32 csky-common",
         "sh3": "endian-little bit-32 sh-common",
         "sh3eb": "endian-big bit-32 sh-common",
         "sh4": "endian-little bit-32 sh-common",
@@ -118,6 +119,8 @@ def siteinfo_data_for_machine(arch, os, d):
         "riscv64-linux": "riscv64-linux",
         "riscv64-linux-musl": "riscv64-linux",
         "x86_64-cygwin": "bit-64",
+        "csky-linux": "csky-linux",
+        "csky-linux-musl": "csky-linux",
         "x86_64-darwin": "bit-64",
         "x86_64-darwin9": "bit-64",
         "x86_64-linux": "bit-64",

+ 15 - 0
meta/conf/machine/include/csky/arch-csky.inc

@@ -0,0 +1,15 @@
+# csky Architecture definition
+
+DEFAULTTUNE ?= "csky32"
+
+TUNE_ARCH = "${TUNE_ARCH_tune-${DEFAULTTUNE}}"
+TUNE_PKGARCH = "${TUNE_PKGARCH_tune-${DEFAULTTUNE}}"
+#TUNE_CCARGS_append = "${@bb.utils.contains('TUNE_FEATURES', 'csky32nf', ' -mabi=ilp32', ' ', d)}"
+
+# QEMU usermode fails with invalid instruction error (For riscv32)
+MACHINE_FEATURES_BACKFILL_CONSIDERED_append = "${@bb.utils.contains('TUNE_FEATURES', 'csky32', ' qemu-usermode', '', d)}"
+
+# Fix: ld: unrecognized option '--hash-style=sysv'
+LINKER_HASH_STYLE_libc-newlib = ""
+# Fix: ld: unrecognized option '--hash-style=gnu'
+LINKER_HASH_STYLE_libc-baremetal = ""

+ 35 - 0
meta/conf/machine/include/csky/qemucsky.inc

@@ -0,0 +1,35 @@
+PREFERRED_PROVIDER_virtual/bootloader ?= "u-boot"
+
+require conf/machine/include/qemu.inc
+require conf/machine/include/csky/tune-csky.inc
+
+MACHINE_FEATURES = "screen keyboard ext2 ext3 serial"
+
+KERNEL_IMAGETYPE = "Image"
+KERNEL_IMAGETYPES += "uImage"
+KEEPUIMAGE = "no"
+
+SERIAL_CONSOLES ?= "115200;ttyS0 115200;hvc0"
+
+IMAGE_FSTYPES += "ext4 wic.qcow2"
+
+WKS_FILE ?= "qemucsky.wks"
+
+MACHINE_EXTRA_RRECOMMENDS += " kernel-modules"
+
+EXTRA_IMAGEDEPENDS += "opensbi"
+RISCV_SBI_PLAT ?= "generic"
+RISCV_SBI_PAYLOAD ?= "${KERNEL_IMAGETYPE}-${MACHINE}.bin"
+
+UBOOT_ENTRYPOINT_riscv32 = "0x80400000"
+UBOOT_ENTRYPOINT_riscv64 = "0x80200000"
+
+# qemuboot options
+QB_KERNEL_CMDLINE_APPEND = "earlycon=sbi"
+QB_MACHINE = "-machine virt"
+QB_DEFAULT_BIOS = "fw_jump.elf"
+QB_TAP_OPT = "-netdev tap,id=net0,ifname=@TAP@,script=no,downscript=no"
+QB_NETWORK_DEVICE = "-device virtio-net-device,netdev=net0,mac=@MAC@"
+QB_ROOTFS_OPT = "-drive id=disk0,file=@ROOTFS@,if=none,format=raw -device virtio-blk-device,drive=disk0"
+QB_SERIAL_OPT = "-device virtio-serial-device -chardev null,id=virtcon -device virtconsole,chardev=virtcon"
+QB_TCPSERIAL_OPT = " -device virtio-serial-device -chardev socket,id=virtcon,port=@PORT@,host=127.0.0.1 -device virtconsole,chardev=virtcon"

+ 14 - 0
meta/conf/machine/include/csky/tune-csky.inc

@@ -0,0 +1,14 @@
+require conf/machine/include/csky/arch-csky.inc
+
+TUNEVALID[csky32] = "Enable 32-bit CSKY optimizations"
+
+TUNEVALID[bigendian] = "Big endian mode"
+
+AVAILTUNES += "csky"
+
+# Default
+TUNE_FEATURES_tune-csky32 = "csky32"
+TUNE_ARCH_tune-csky32 = "csky32"
+TUNE_PKGARCH_tune-csky32 = "csky32"
+PACKAGE_EXTRA_ARCHS_tune-csky32 = "csky32"
+

+ 3 - 0
meta/lib/oe/elf.py

@@ -24,6 +24,7 @@ def machine_dict(d):
                         "microblaze":  (189,   0,    0,          False,         32),
                         "microblazeel":(189,   0,    0,          True,          32),
                         "powerpc":    (20,     0,    0,          False,         32),
+                        "csky":       (252,    0,    0,          True,          32),
                         "riscv32":    (243,    0,    0,          True,          32),
                         "riscv64":    (243,    0,    0,          True,          64),
                       },
@@ -53,6 +54,7 @@ def machine_dict(d):
                         "mipsisa64r6":   ( 8,  0,    0,          False,         64),
                         "mipsisa64r6el": ( 8,  0,    0,          True,          64),
                         "nios2":      (113,    0,    0,          True,          32),
+                        "csky":       (252,    0,    0,          True,          32),
                         "riscv32":    (243,    0,    0,          True,          32),
                         "riscv64":    (243,    0,    0,          True,          64),
                         "s390":       (22,     0,    0,          False,         32),
@@ -80,6 +82,7 @@ def machine_dict(d):
                         "mips64el":   (   8,     0,    0,          True,          64),
                         "microblaze":  (189,     0,    0,          False,         32),
                         "microblazeel":(189,     0,    0,          True,          32),
+                        "csky":    (252,      0,    0,          True,          32),
                         "riscv32":    (243,      0,    0,          True,          32),
                         "riscv64":    (243,      0,    0,          True,          64),
                         "sh4":        (  42,     0,    0,          True,          32),

+ 1 - 1
meta/recipes-bsp/opensbi/opensbi_0.8.bb

@@ -41,7 +41,7 @@ FILES_${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_jump.*"
 # FILES_${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_payload.*"
 # FILES_${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_dynamic.*"
 
-COMPATIBLE_HOST = "(riscv64|riscv32).*"
+COMPATIBLE_HOST = "(riscv64|riscv32|csky).*"
 INHIBIT_PACKAGE_STRIP = "1"
 
 SECURITY_CFLAGS = ""

+ 3 - 0
meta/recipes-connectivity/openssl/openssl_1.1.1h.bb

@@ -107,6 +107,9 @@ do_configure () {
 	linux-riscv32)
 		target=linux-generic32
 		;;
+	linux-csky)
+		target=linux-generic32
+		;;
 	linux-riscv64)
 		target=linux-generic64
 		;;

+ 3 - 1
meta/recipes-graphics/mesa/mesa.inc

@@ -32,7 +32,9 @@ UPSTREAM_CHECK_GITTAGREGEX = "mesa-(?P<pver>\d+(\.\d+)+)"
 #make eglplatform.h independent of MESA_EGL_NO_X11_HEADER
 do_install_append() {
     if ${@bb.utils.contains('PACKAGECONFIG', 'egl', 'true', 'false', d)}; then
-        sed -i -e 's/^#elif defined(__unix__) && defined(EGL_NO_X11)$/#elif defined(__unix__) \&\& defined(EGL_NO_X11) || ${@bb.utils.contains('PACKAGECONFIG', 'x11', '0', '1', d)}/' ${D}${includedir}/EGL/eglplatform.h
+        if [ -f  ${D}${includedir}/EGL/eglplatform.h ]; then
+            sed -i -e 's/^#elif defined(__unix__) && defined(EGL_NO_X11)$/#elif defined(__unix__) \&\& defined(EGL_NO_X11) || ${@bb.utils.contains('PACKAGECONFIG', 'x11', '0', '1', d)}/' ${D}${includedir}/EGL/eglplatform.h
+        fi
     fi
 }