From 4401776546603978a233ebe86b58f5050446c50b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Przytu=C5=82a?= Date: Tue, 6 Feb 2024 09:28:15 +0100 Subject: [PATCH] openocd: finer-grained error msg if board unknown When trying to set up tockloader to use openocd, I kept getting the generic message saying "Could not determine the current board or arch or openocd board name". Not only did it not mention missing page_size parameter, but also was too coarse-grained. With splitting the error message, I managed to debug this, so I believe this could be beneficial to anyone. --- tockloader/openocd.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tockloader/openocd.py b/tockloader/openocd.py index 7535520..465e6ed 100644 --- a/tockloader/openocd.py +++ b/tockloader/openocd.py @@ -369,14 +369,21 @@ def determine_current_board(self): self._configure_from_known_boards() # Check that we learned what we needed to learn. - if ( - self.board == None - or self.arch == None - or self.openocd_board == "cortex-m0" - or self.page_size == 0 - ): + if self.board is None: raise TockLoaderException( - "Could not determine the current board or arch or openocd board name" + "Could not determine the current board" + ) + if self.arch is None: + raise TockLoaderException( + "Could not determine the current arch" + ) + if self.openocd_board == "cortex-m0": + raise TockLoaderException( + "Could not determine the current openocd board name" + ) + if self.page_size == 0: + raise TockLoaderException( + "Could not determine the current page size" ) def run_terminal(self):