You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/03/04 08:34:40 UTC

[GitHub] [tvm] vinceab commented on a change in pull request #7537: [PYTHON][Target] add stm32mp1 target helper

vinceab commented on a change in pull request #7537:
URL: https://github.com/apache/tvm/pull/7537#discussion_r587259459



##########
File path: python/tvm/target/target.py
##########
@@ -324,6 +324,31 @@ def arm_cpu(model="unknown", options=None):
     return Target(" ".join(["llvm"] + opts))
 
 
+def stm32mp1(options=None):
+    """Return stm32mp1 target and the associated cross compiler based on the SDK.
+
+    Parameters
+    ----------
+    options : str or list of str
+        Additional options
+    """
+
+    from tvm.contrib import cc
+
+    if "TVM_STM32MP_SDK_PATH" not in os.environ or  os.getenv("TVM_STM32MP_SDK_PATH") == "":
+        raise RuntimeError("Require environment variable TVM_STM32MP_SDK_PATH providing the SDK path directory\n"
+                           "example: export TVM_STM32MP_SDK_PATH=<your path>/STM32MP15-Ecosystem-v2.1.0/Developer-Package/SDK")
+
+    sdk_path = os.environ["TVM_STM32MP_SDK_PATH"]
+    cc = cc.cross_compiler(sdk_path + '/sysroots/x86_64-ostl_sdk-linux/usr/bin/arm-ostl-linux-gnueabi/arm-ostl-linux-gnueabi-g++',
+                           options=['-mthumb',
+                                    '-mfpu=neon-vfpv4',
+                                    '-mfloat-abi=hard',
+                                    '-mcpu=cortex-a7',
+                                    '--sysroot=' + sdk_path + '/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi'])
+
+    return arm_cpu("stm32mp1", options), cc

Review comment:
       Hi @areusch I was questioning myself for the best way to achieve the STM32MP1 SDK path integration to get a cross-compiler configuration.
   The STM32MP1 MPU from STMicroelectronics is provided with and OpenSTLinux distribution base on Yocto build system.
   I can not afford to embed the full armv7 gcc tool chain in the distribution and therefore can not relink on the target the object file generated by TVM. 
   So my goal is to build on the host the shared library itself so that I can load it through RPC on the target without the need to relink.
   That why I would like to create an helper to get the cross-compiler based on the OpenSTLinux SDK path. The things are working well but it is maybe done at the wrong place.
   First of all I was thinking to add this fonctionnality in python/tvm/contrib/stm32mp.py but I changed my mind.
   
   Please advise and I will update accordingly.
   
   BR
   Vincent




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org