Skip to content

Commit cf517f9

Browse files
djiatsaf-stkartben
authored andcommitted
scripts: twister: fix regenerate serial device with unknown platform
Since BOOT-SERIAL isn't a recognized STMicroelectronics product name, when Twister saves the new map.yaml, it will also check if the previous map.yaml had the 'SERIAL-BOOT' product name and attach the corresponding serial device.It won't generate a new one with an unknown platform name. Signed-off-by: Fabrice DJIATSA <fabrice.djiatsa-ext@st.com>
1 parent 68f6cfb commit cf517f9

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

scripts/pylib/twister/twisterlib/hardwaremap.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,9 @@ def readlink(link):
382382
logger.warning(f"Unsupported device ({d.manufacturer}): {d}")
383383

384384
def save(self, hwm_file):
385+
# list of board ids with boot-serial sequence
386+
boot_ids = []
387+
385388
# use existing map
386389
self.detected = natsorted(self.detected, key=lambda x: x.serial or '')
387390
if os.path.exists(hwm_file):
@@ -390,10 +393,13 @@ def save(self, hwm_file):
390393
if hwm:
391394
hwm.sort(key=lambda x: x.get('id', ''))
392395

393-
# disconnect everything
396+
# disconnect everything except boards with boot-serial sequence
394397
for h in hwm:
395-
h['connected'] = False
396-
h['serial'] = None
398+
if h['product'] != 'BOOT-SERIAL' :
399+
h['connected'] = False
400+
h['serial'] = None
401+
else :
402+
boot_ids.append(h['id'])
397403

398404
for _detected in self.detected:
399405
for h in hwm:
@@ -418,6 +424,11 @@ def save(self, hwm_file):
418424
else:
419425
hwm = new
420426

427+
#remove duplicated devices with unknown platform names before saving the file
428+
for h in hwm :
429+
if h['id'] in boot_ids and h['platform'] == 'unknown':
430+
hwm.remove(h)
431+
421432
with open(hwm_file, 'w') as yaml_file:
422433
yaml.dump(hwm, yaml_file, Dumper=Dumper, default_flow_style=False)
423434

0 commit comments

Comments
 (0)