twister: fix hardware map updates

When re-generating hardware map for DKs with more than 1 serial port (more
enries in the hardware map), then we keep enfo only about the last entry.
For boards like nrf5340 it works, because the last serial port is used,
but for nrf52840 with two ports, the first one is important, so after
re-generating the hardware map it does not work.
The solution is to keep all entries after re-generating the hardware map.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
This commit is contained in:
Grzegorz Chwierut 2022-12-21 02:28:06 -08:00 committed by Carles Cufí
commit f016761859

View file

@ -320,10 +320,16 @@ class HardwareMap:
for _detected in self.detected: for _detected in self.detected:
for h in hwm: for h in hwm:
if _detected.id == h['id'] and _detected.product == h['product'] and not _detected.match: if all([
_detected.id == h['id'],
_detected.product == h['product'],
_detected.match is False,
h['connected'] is False
]):
h['connected'] = True h['connected'] = True
h['serial'] = _detected.serial h['serial'] = _detected.serial
_detected.match = True _detected.match = True
break
new_duts = list(filter(lambda d: not d.match, self.detected)) new_duts = list(filter(lambda d: not d.match, self.detected))
new = [] new = []