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>
This commit is contained in:
parent
68f6cfb382
commit
cf517f92fc
1 changed files with 14 additions and 3 deletions
|
@ -382,6 +382,9 @@ class HardwareMap:
|
||||||
logger.warning(f"Unsupported device ({d.manufacturer}): {d}")
|
logger.warning(f"Unsupported device ({d.manufacturer}): {d}")
|
||||||
|
|
||||||
def save(self, hwm_file):
|
def save(self, hwm_file):
|
||||||
|
# list of board ids with boot-serial sequence
|
||||||
|
boot_ids = []
|
||||||
|
|
||||||
# use existing map
|
# use existing map
|
||||||
self.detected = natsorted(self.detected, key=lambda x: x.serial or '')
|
self.detected = natsorted(self.detected, key=lambda x: x.serial or '')
|
||||||
if os.path.exists(hwm_file):
|
if os.path.exists(hwm_file):
|
||||||
|
@ -390,10 +393,13 @@ class HardwareMap:
|
||||||
if hwm:
|
if hwm:
|
||||||
hwm.sort(key=lambda x: x.get('id', ''))
|
hwm.sort(key=lambda x: x.get('id', ''))
|
||||||
|
|
||||||
# disconnect everything
|
# disconnect everything except boards with boot-serial sequence
|
||||||
for h in hwm:
|
for h in hwm:
|
||||||
h['connected'] = False
|
if h['product'] != 'BOOT-SERIAL' :
|
||||||
h['serial'] = None
|
h['connected'] = False
|
||||||
|
h['serial'] = None
|
||||||
|
else :
|
||||||
|
boot_ids.append(h['id'])
|
||||||
|
|
||||||
for _detected in self.detected:
|
for _detected in self.detected:
|
||||||
for h in hwm:
|
for h in hwm:
|
||||||
|
@ -418,6 +424,11 @@ class HardwareMap:
|
||||||
else:
|
else:
|
||||||
hwm = new
|
hwm = new
|
||||||
|
|
||||||
|
#remove duplicated devices with unknown platform names before saving the file
|
||||||
|
for h in hwm :
|
||||||
|
if h['id'] in boot_ids and h['platform'] == 'unknown':
|
||||||
|
hwm.remove(h)
|
||||||
|
|
||||||
with open(hwm_file, 'w') as yaml_file:
|
with open(hwm_file, 'w') as yaml_file:
|
||||||
yaml.dump(hwm, yaml_file, Dumper=Dumper, default_flow_style=False)
|
yaml.dump(hwm, yaml_file, Dumper=Dumper, default_flow_style=False)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue