diff --git a/libs/utils/energy.py b/libs/utils/energy.py index 7a44edc7fae51f9addf0332e6a2abbb11253fe57..150ce7fa81771fe75a4f0a220d370aa8afaa7c15 100644 --- a/libs/utils/energy.py +++ b/libs/utils/energy.py @@ -37,7 +37,21 @@ DEFAULT_ENERGY_METER = { 'instrument' : 'hwmon', 'conf' : { 'sites' : [ 'a53', 'a57' ], + 'kinds' : [ 'energy' ], + } + }, + 'juno2' : { + 'instrument' : 'hwmon', + 'conf' : { + 'sites' : [ 'BOARDLITTLE', 'BOARDBIG' ], 'kinds' : [ 'energy' ] + }, + # if the channels do not contain a core name we can match to the + # little/big cores on the board, use a channel_map section to + # indicate which channel is which + 'channel_map' : { + 'little' : 'BOARDLITTLE', + 'big' : 'BOARDBIG', } }, @@ -71,7 +85,7 @@ class EnergyMeter(object): return None if emeter['instrument'] == 'hwmon': - EnergyMeter._meter = HWMon(target, emeter['conf']) + EnergyMeter._meter = HWMon(target, emeter) elif emeter['instrument'] == 'aep': EnergyMeter._meter = Aep(target) return EnergyMeter._meter @@ -108,8 +122,8 @@ class HWMon(EnergyMeter): self._hwmon = devlib.HwmonInstrument(self._target) # Configure channels for energy measurements - logging.debug('%14s - Enabling channels %s', 'EnergyMeter', hwmon_conf) - self._hwmon.reset(**hwmon_conf) + logging.debug('%14s - Enabling channels %s', 'EnergyMeter', hwmon_conf['conf']) + self._hwmon.reset(**hwmon_conf['conf']) # Logging enabled channels logging.info('%14s - Channels selected for energy sampling:', @@ -117,6 +131,18 @@ class HWMon(EnergyMeter): for channel in self._hwmon.active_channels: logging.info('%14s - %s', 'EnergyMeter', channel.label) + # record the hwmon channel mapping + self.little_channel = self._target.little_core.upper() + self.big_channel = self._target.big_core.upper() + if hwmon_conf and 'channel_map' in hwmon_conf: + self.little_channel = hwmon_conf['channel_map']['little'] + self.big_channel = hwmon_conf['channel_map']['big'] + logging.info('%14s - Using channel %s as little channel', + 'EnergyMeter', self.little_channel) + logging.info('%14s - Using channel %s as big channel', + 'EnergyMeter', self.big_channel) + + def sample(self): if self._hwmon is None: return @@ -163,9 +189,9 @@ class HWMon(EnergyMeter): nrg_total = nrg[ch]['total'] logging.info('%14s - Energy [%16s]: %.6f', 'EnergyReport', ch, nrg_total) - if self._target.little_core.upper() in ch.upper(): + if ch.upper() == self.little_channel: clusters_nrg['LITTLE'] = '{:.6f}'.format(nrg_total) - elif self._target.big_core.upper() in ch.upper(): + elif ch.upper() == self.big_channel: clusters_nrg['big'] = '{:.6f}'.format(nrg_total) else: logging.warning('%14s - Unable to bind hwmon channel [%s]'\ diff --git a/libs/utils/env.py b/libs/utils/env.py index 8d86f8a73029dc9b380e33a9d74a59c8b7396173..aec553a9c7e6d51e750fe24ba27e764f040fead5 100644 --- a/libs/utils/env.py +++ b/libs/utils/env.py @@ -340,7 +340,7 @@ class TestEnv(ShareState): self.__modules = ['bl', 'hwmon', 'cpufreq'] # Initialize JUNO board - elif self.conf['board'].upper() == 'JUNO': + elif self.conf['board'].upper() in ('JUNO', 'JUNO2'): platform = devlib.platform.arm.Juno() self.__modules = ['bl', 'hwmon', 'cpufreq'] diff --git a/target.config b/target.config index 26f2141b63958ed141ae1e76b25bc561c1ecbeaa..013db271d9fb82e14d5c84a7ac8cac314050856d 100644 --- a/target.config +++ b/target.config @@ -15,8 +15,13 @@ /* Board */ /* Currently supported boards are: */ - /* juno : target is a JUNO board */ - /* tc2 : target is a TC2 board */ + /* juno : target is a JUNO board */ + /* juno2 : target is a JUNO board, with mainline Hwmon */ + /* tc2 : target is a TC2 board */ + /* If your Juno board /sys/class/hwmon/hwmon0/energy?_name is */ + /* of the form BOARD_*_ENERGY, then you need 'juno2'. */ + /* Otherwise 'juno' is sufficient. In either case, lisa uses */ + /* devlib's 'juno' target definition to talk to the board. */ /* Leave commented if your board is not listed above */ "board" : "juno",