Add support for riscv64 47/304847/1 accepted/tizen_unified_riscv accepted/tizen/unified/20240124.163307 accepted/tizen/unified/riscv/20240128.235642 accepted/tizen/unified/toolchain/20240311.070041 accepted/tizen/unified/x/20240205.064100
authorxuhy <huayong.xu@samsung.com>
Wed, 24 Jan 2024 08:50:24 +0000 (16:50 +0800)
committerxuhy <huayong.xu@samsung.com>
Wed, 24 Jan 2024 08:54:15 +0000 (16:54 +0800)
Change-Id: I4ead58bcabeffbb08e89f2984e0af2e913452a40
Signed-off-by: Marek PikuĊ‚a <m.pikula@partner.samsung.com>
Signed-off-by: xuhy <huayong.xu@samsung.com>
MANIFEST.in [new file with mode: 0644]
etc/bash_completion.d/mic.sh
mic/chroot.py
mic/imager/baseimager.py
mic/imager/raw.py
mic/utils/misc.py
mic/utils/rpmmisc.py

diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644 (file)
index 0000000..d24b818
--- /dev/null
@@ -0,0 +1,2 @@
+include etc/mic.conf.in
+
index 4f467ca..38d5555 100644 (file)
@@ -110,6 +110,7 @@ __mic_complete_val()
         armv5tel
         armv5tejl
         armv7tnhl
+        riscv64
     "
     pkgmgr_values="
         yum
index 71e35b7..27278b6 100644 (file)
@@ -56,6 +56,7 @@ def ELF_arch(chrootdir):
                 r"Intel 80[0-9]86": "i686",
                 r"x86-64": "x86_64",
                 r"ARM": "arm",
+                r"RISC-V": "riscv64",
               }
 
     for path in chkfiles:
@@ -307,6 +308,8 @@ def chroot(chrootdir, bindmounts = None, execute = "/bin/bash"):
         qemu_emulators = misc.setup_qemu_emulator(chrootdir, "arm")
     elif arch == "mipsel":
         qemu_emulators = misc.setup_qemu_emulator(chrootdir, "mipsel")
+    elif arch == "riscv64":
+        qemu_emulators = misc.setup_qemu_emulator(chrootdir, "riscv64")
     else:
         qemu_emulators = []
 
index f0243f7..059e670 100644 (file)
@@ -203,6 +203,25 @@ class BaseImageCreator(object):
                             "\tYou can disable vdso with following command before "
                             "starting image build:\n"
                             "\techo 0 | sudo tee /proc/sys/vm/vdso_enabled")
+            elif self.target_arch == "riscv64":
+                for dep in self._dep_checks:
+                    if dep == "extlinux":
+                        self._dep_checks.remove(dep)
+
+                if not os.path.exists("/usr/bin/qemu-riscv64") or \
+                   not misc.is_statically_linked("/usr/bin/qemu-riscv64"):
+                    self._dep_checks.append("qemu-riscv64-static")
+
+                if os.path.exists("/proc/sys/vm/vdso_enabled"):
+                    vdso_fh = open("/proc/sys/vm/vdso_enabled","r")
+                    vdso_value = vdso_fh.read().strip()
+                    vdso_fh.close()
+                    if (int)(vdso_value) == 1:
+                        msger.warning("vdso is enabled on your host, which might "
+                            "cause problems with riscv64 emulations.\n"
+                            "\tYou can disable vdso with following command before "
+                            "starting image build:\n"
+                            "\techo 0 | sudo tee /proc/sys/vm/vdso_enabled")
 
         # make sure the specified tmpdir and cachedir exist
         if not os.path.exists(self.tmpdir):
@@ -831,7 +850,7 @@ class BaseImageCreator(object):
             fs.makedirs(self._instroot + d)
 
         if self.target_arch and self.target_arch.startswith("arm") or \
-            self.target_arch == "aarch64":
+            self.target_arch == "aarch64" or self.target_arch == "riscv64":
             self.qemu_emulators = misc.setup_qemu_emulator(self._instroot,
                                                           self.target_arch)
 
index 452ba8c..430cfd0 100644 (file)
@@ -491,8 +491,11 @@ class RawImageCreator(BaseImageCreator):
 
     def _write_image_xml(self):
         imgarch = "i686"
-        if self.target_arch and self.target_arch.startswith("arm"):
-            imgarch = "arm"
+        if self.target_arch:
+            if self.target_arch.startswith("arm"):
+                imgarch = "arm"
+            elif self.target_arch == "riscv64":
+                imgarch = "riscv64"
         xml = "<image>\n"
 
         name_attributes = ""
index a49e20f..1fbbcd9 100755 (executable)
@@ -923,6 +923,15 @@ def get_qemu_arm_binary(arch):
             arm_binary = "qemu-mipsel-static"
         if not os.path.exists("/usr/bin/%s" % arm_binary):
             raise CreatorError("Please install a statically-linked %s" % arm_binary)
+    elif arch == "riscv64":
+        node = "/proc/sys/fs/binfmt_misc/riscv64"
+        arm_binary = "qemu-riscv64"
+        if os.path.exists("/usr/bin/qemu-riscv64") and is_statically_linked("/usr/bin/qemu-riscv64"):
+            arm_binary = "qemu-riscv64"
+        elif os.path.exists("/usr/bin/qemu-riscv64-static"):
+            arm_binary = "qemu-riscv64-static"
+        else:
+            raise CreatorError("Please install a statically-linked %s" % arm_binary)
     else:
         node = "/proc/sys/fs/binfmt_misc/arm"
         arm_binary = "qemu-arm"
@@ -964,6 +973,8 @@ def setup_qemu_emulator(rootdir, arch):
             qemu_arm_string = ":aarch64:M::\\x7fELF\\x02\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\xb7:\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xfe\\xff\\xff:%s:\n" % qemu_emulator
         elif arch == "mipsel":
             qemu_arm_string = ":mipsel:M::\\x7fELF\\x01\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\x08\\x00:\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\xfe\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xfe\\xff\\xff\\xff:%s:\n" % qemu_emulator
+        elif arch == "riscv64":
+            qemu_arm_string = ":riscv64:M::\\x7fELF\\x02\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\xf3\\x00:\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xfe\\xff\\xff\\xff:%s:\n" % qemu_emulator
         else:
             qemu_arm_string = ":arm:M::\\x7fELF\\x01\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\x28\\x00:\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xfa\\xff\\xff\\xff:%s:\n" % qemu_emulator
 
index a656e40..3dde377 100644 (file)
@@ -323,6 +323,7 @@ archPolicies = {
     "armv5tel":     "armv5tel:armv5l:armv4tl:armv4l:armv3l",
     "armv5l":       "armv5l:armv4tl:armv4l:armv3l",
     "mipsel":       "mipsel",
+    "riscv64":      "riscv64",
 }
 
 # dict mapping arch -> ( multicompat, best personality, biarch personality )
@@ -358,6 +359,8 @@ arches = {
     "ia64": "noarch",
 
     "mipsel": "mipsel",
+
+    "riscv64": "noarch",
 }
 
 def isMultiLibArch(arch=None):