From d9b9c32a951df275b043e9f6199678ee366cff34 Mon Sep 17 00:00:00 2001 From: Patrick Bellasi Date: Fri, 12 Aug 2016 15:21:35 +0100 Subject: [PATCH 1/2] libs/utils/env: add support for custom board specified via JSON file This allows to specify a custom board configuration using a JSON file located under libs/utils/platforms. A platform can be specified by reporting these properties: "cores" : list of cores identifiers unique names are used to defined clusters "big_core" : the name used to represent big CPUs in a big.LITTLE target "modules" : (optional) list of modules to load for that target Signed-off-by: Patrick Bellasi Signed-off-by: Michele Di Giorgio --- libs/utils/env.py | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/libs/utils/env.py b/libs/utils/env.py index 1e8a2c90f..a51502cb6 100644 --- a/libs/utils/env.py +++ b/libs/utils/env.py @@ -337,6 +337,8 @@ class TestEnv(ShareState): ######################################################################## # Setup board default if not specified by configuration + platform = None + self.__modules = [] if 'board' not in self.conf: self.conf['board'] = 'UNKNOWN' @@ -365,10 +367,18 @@ class TestEnv(ShareState): ) self.__modules = ['bl', 'cpufreq'] - # Initialize default UNKNOWN board - else: - platform = None - self.__modules = [] + elif self.conf['board'] != 'UNKNOWN': + # Initilize from platform descriptor (if available) + board = self._load_board(self.conf['board']) + if board: + core_names=board['cores'] + platform = Platform( + model=self.conf['board'], + core_names=core_names, + core_clusters = self._get_clusters(core_names), + big_core=board.get('big_core', None) + ) + self.__modules=board.get('modules', []) ######################################################################## # Modules configuration @@ -592,6 +602,31 @@ class TestEnv(ShareState): return None return board.json['nrg_model'] + def _load_board(self, board): + board_path = os.path.join(basepath, + 'libs/utils/platforms', board.lower() + '.json') + logging.debug('%14s - Trying to load board descriptor from %s', + 'Platform', board_path) + if not os.path.exists(board_path): + return None + logging.info('%14s - Loading board:', 'Platform') + logging.info('%14s - %s', 'Platform', board_path) + board = JsonConf(board_path) + board.load() + if 'board' not in board.json: + return None + return board.json['board'] + + def _get_clusters(self, core_names): + idx = 0 + clusters = [] + ids_map = { core_names[0] : 0 } + for name in core_names: + idx = ids_map.get(name, idx+1) + ids_map[name] = idx + clusters.append(idx) + return clusters + def _init_platform(self): if 'bl' in self.target.modules: self._init_platform_bl() -- GitLab From 1a6f05cba16eec293d393046a288496010df1ff4 Mon Sep 17 00:00:00 2001 From: Patrick Bellasi Date: Fri, 12 Aug 2016 15:23:51 +0100 Subject: [PATCH 2/2] libs/utils/env: use platform file for Nexus 5X target description We do not want to use hard-coded platforms descriptions when its possible to provide them via an external JSON file. Signed-off-by: Patrick Bellasi --- libs/utils/env.py | 10 ---------- libs/utils/platforms/nexus5x.json | 9 +++++++++ 2 files changed, 9 insertions(+), 10 deletions(-) create mode 100644 libs/utils/platforms/nexus5x.json diff --git a/libs/utils/env.py b/libs/utils/env.py index a51502cb6..348284655 100644 --- a/libs/utils/env.py +++ b/libs/utils/env.py @@ -357,16 +357,6 @@ class TestEnv(ShareState): platform = Platform(model='MT8173') self.__modules = ['bl', 'cpufreq'] - # Initialize N5X device - elif self.conf['board'].upper() == 'N5X': - platform = Platform(model='bullhead', - core_names = ['A53', 'A53', 'A53', 'A53', - 'A57', 'A57'], - core_clusters = [ 0, 0, 0, 0, 1, 1], - big_core = 'A57', - ) - self.__modules = ['bl', 'cpufreq'] - elif self.conf['board'] != 'UNKNOWN': # Initilize from platform descriptor (if available) board = self._load_board(self.conf['board']) diff --git a/libs/utils/platforms/nexus5x.json b/libs/utils/platforms/nexus5x.json new file mode 100644 index 000000000..d483e913f --- /dev/null +++ b/libs/utils/platforms/nexus5x.json @@ -0,0 +1,9 @@ +{ + "board" : { + "cores" : [ + "A53", "A53", "A53", "A53", "A57", "A57" + ], + "big_core" : "A57", + "modules" : ["bl", "cpufreq"] + } +} -- GitLab