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 2022/08/08 16:57:41 UTC

[GitHub] [tvm] mehrdadh opened a new pull request, #12338: [microTVM][Zephyr] Fix bug: missing BOARD in CMakeCache file

mehrdadh opened a new pull request, #12338:
URL: https://github.com/apache/tvm/pull/12338

   This bug was caught in the microtvm hardware in the loop CI. 
   This PR changes microtvm template project to read BOARD from cmake file instead of cmake cache file.
   
   cc @areusch  


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

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


[GitHub] [tvm] gromero commented on a diff in pull request #12338: [microTVM][Zephyr] Fix bug: missing BOARD in CMakeCache file

Posted by GitBox <gi...@apache.org>.
gromero commented on code in PR #12338:
URL: https://github.com/apache/tvm/pull/12338#discussion_r940861161


##########
apps/microtvm/zephyr/template_project/microtvm_api_server.py:
##########
@@ -152,6 +152,20 @@ def _get_flash_runner():
     return doc["flash-runner"]
 
 
+def _find_board_from_cmake_file(cmake_file: Union[str, pathlib.Path]) -> str:
+    """Find Zephyr board from generated CMakeLists.txt"""
+    zephyr_board = None
+    with open(cmake_file) as cmake_f:
+        for line in cmake_f:
+            if line.startswith("set(BOARD"):
+                zephyr_board = line.strip("\n").strip("\r").strip(")").split(" ")[1]

Review Comment:
   I think it's call for a capture group here. For instance:
   ```
        zephyr_board = None
        with open(cmake_file) as cmake_f:
            for line in cmake_f:
   -            if line.startswith("set(BOARD"):
   -                zephyr_board = line.strip("\n").strip("\r").strip(")").split(" ")[1]
   +            set_board = re.match("set\(BOARD (.*)\)", line)
   +            if set_board:
   +                zephyr_board = set_board.group(1)
                    break
    
        if not zephyr_board:
            raise RuntimeError(f"No Zephyr board set in the {cmake_file}.")
   +
        return zephyr_board
   
   ```



##########
apps/microtvm/zephyr/template_project/microtvm_api_server.py:
##########
@@ -152,6 +152,20 @@ def _get_flash_runner():
     return doc["flash-runner"]
 
 
+def _find_board_from_cmake_file(cmake_file: Union[str, pathlib.Path]) -> str:
+    """Find Zephyr board from generated CMakeLists.txt"""
+    zephyr_board = None
+    with open(cmake_file) as cmake_f:
+        for line in cmake_f:
+            if line.startswith("set(BOARD"):
+                zephyr_board = line.strip("\n").strip("\r").strip(")").split(" ")[1]

Review Comment:
   But since it's minor enhancement I won't block on this.



##########
apps/microtvm/zephyr/template_project/microtvm_api_server.py:
##########
@@ -162,7 +176,7 @@ def _get_device_args(options):
         return _get_openocd_device_args(options)
 
     raise BoardError(
-        f"Don't know how to find serial terminal for board {CMAKE_CACHE['BOARD']} with flash "
+        f"Don't know how to find serial terminal for board {_find_board_from_cmake_file(API_SERVER_DIR / CMAKELIST_FILENAME)} with flash "

Review Comment:
   nit, and since it's out of scope for this PR I won't block on this (send a follow-on PR if you like): I think this error message should read something like:
   `f"Don't know how to get device arguments for runner {flash_runner}"`  so I don't think mentioning the board here is really necessary, like it happens in 
   
   https://github.com/apache/tvm/blob/main/apps/microtvm/zephyr/template_project/microtvm_api_server.py#L743
   
   The runner is the important info here.
   
   



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

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


[GitHub] [tvm] mehrdadh commented on a diff in pull request #12338: [microTVM][Zephyr] Fix bug: missing BOARD in CMakeCache file

Posted by GitBox <gi...@apache.org>.
mehrdadh commented on code in PR #12338:
URL: https://github.com/apache/tvm/pull/12338#discussion_r941551892


##########
apps/microtvm/zephyr/template_project/microtvm_api_server.py:
##########
@@ -152,6 +152,20 @@ def _get_flash_runner():
     return doc["flash-runner"]
 
 
+def _find_board_from_cmake_file(cmake_file: Union[str, pathlib.Path]) -> str:
+    """Find Zephyr board from generated CMakeLists.txt"""
+    zephyr_board = None
+    with open(cmake_file) as cmake_f:
+        for line in cmake_f:
+            if line.startswith("set(BOARD"):
+                zephyr_board = line.strip("\n").strip("\r").strip(")").split(" ")[1]

Review Comment:
   thanks for the suggestion, I will fix this in a follow up PR



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

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


[GitHub] [tvm] gromero merged pull request #12338: [microTVM][Zephyr] Fix bug: missing BOARD in CMakeCache file

Posted by GitBox <gi...@apache.org>.
gromero merged PR #12338:
URL: https://github.com/apache/tvm/pull/12338


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

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