From 5618c1a2e5a9e4f98a0dfb7b57fd0714743afd13 Mon Sep 17 00:00:00 2001 From: Gustavo Romero Date: Fri, 11 Jun 2021 03:06:47 -0300 Subject: [PATCH] =?UTF-8?q?[=C2=B5TVM]=20Zephyr:=20Fix=20missing=20board-s?= =?UTF-8?q?pecific=20config=20file=20in=20build=20dir=20(#8230)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently board-specific config files (boards/*.conf) are not copied from Zephyr project dir to the destination build dir, so as a consequence the per board configs are not used when building the runtime libraries, like libcommon. Hence, for instance, it's currently not possible to set CONFIG_FPU per board since it only takes effect when it's set in the generic 'prj.con' config file. This commit fixes it by copying to the build dir (to each lib dir) the proper .conf for the selected target board. For example, if target 'qemu_x86' is selected 'qemu_x86.conf' is copied to the boards/ dir inside the lib dirs, so Zephyr build system can find it and combine it with configs found in the generic 'prj.conf'. Signed-off-by: Gustavo Romero --- python/tvm/micro/contrib/zephyr.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/python/tvm/micro/contrib/zephyr.py b/python/tvm/micro/contrib/zephyr.py index b7d7496b7440..fedd470a8350 100644 --- a/python/tvm/micro/contrib/zephyr.py +++ b/python/tvm/micro/contrib/zephyr.py @@ -172,6 +172,17 @@ def library(self, output, sources, options=None): project_dir_conf = os.path.join(self._project_dir, "prj.conf") if os.path.exists(project_dir_conf): shutil.copy(project_dir_conf, lib_prj_conf) + + # Copy board-specific Zephyr config file from the project_dir to + # the build lib dir so board-specific configs can be found and used by + # Zephyr's build system in conjunction with the generic prj.conf configs. + board_conf = os.path.join("boards", self._board + ".conf") + project_dir_board_conf = os.path.join(self._project_dir, board_conf) + if os.path.exists(project_dir_board_conf): + os.mkdir(os.path.join(output, "boards")) + lib_dir_board_conf = os.path.join(output, board_conf) + shutil.copy(project_dir_board_conf, lib_dir_board_conf) + else: with open(lib_prj_conf, "w") as prj_conf_f: prj_conf_f.write("CONFIG_CPLUSPLUS=y\n")