efuse_table_gen: Fixes wrong joining fields with omitted names

The issue is related to the non-sequential way of description when
such fields going together sequential.

Related to esp32h2 chip for eFuses: MAC_FACTORY and MAC_EXT.
The issue is in wrong indexes of MAC_EXT.
MAC_EXT got indexes like it is joined to MAC_FACTORY.

const esp_efuse_desc_t* ESP_EFUSE_MAC_FACTORY[] = {
    &MAC_FACTORY[0],
    &MAC_FACTORY[1],
    &MAC_FACTORY[2],
    &MAC_FACTORY[3],
    &MAC_FACTORY[4],
    &MAC_FACTORY[5],
    NULL
};

const esp_efuse_desc_t* ESP_EFUSE_MAC_EXT[] = {
    &MAC_EXT[6],
    &MAC_EXT[7],
    NULL
};

This commit fixed it to:

const esp_efuse_desc_t* ESP_EFUSE_MAC_EXT[] = {
    &MAC_EXT[0],
    &MAC_EXT[1],
    NULL
};
This commit is contained in:
KonstantinKondrashov 2021-10-28 20:15:24 +08:00
parent 281598077a
commit fb3c88510c
2 changed files with 70 additions and 1 deletions

View File

@ -98,9 +98,11 @@ class FuseTable(list):
# fill group
names = [p.field_name for p in res]
duplicates = set(n for n in names if names.count(n) > 1)
if len(duplicates) != 0:
for dname in duplicates:
i_count = 0
for p in res:
if p.field_name != dname:
continue
if len(duplicates.intersection([p.field_name])) != 0:
p.group = str(i_count)
i_count += 1

View File

@ -454,6 +454,73 @@ name2.F1, EFUSE_BLK2, 22,
with self.assertRaisesRegex(efuse_table_gen.InputError, 'name2 is not found'):
t.verify()
def test_two_fields_with_lists(self):
csv = """
MAC_FACTORY, EFUSE_BLK1, 40, 8, Factory MAC addr [0]
, EFUSE_BLK1, 32, 8, Factory MAC addr [1]
, EFUSE_BLK1, 24, 8, Factory MAC addr [2]
, EFUSE_BLK1, 16, 8, Factory MAC addr [3]
, EFUSE_BLK1, 8, 8, Factory MAC addr [4]
, EFUSE_BLK1, 0, 8, Factory MAC addr [5]
MAC_EXT, EFUSE_BLK1, 123, 8, Extend MAC addr [0]
, EFUSE_BLK1, 131, 8, Extend MAC addr [1]
"""
t = efuse_table_gen.FuseTable.from_csv(csv)
t.verify()
self.assertEqual(t[0].field_name, 'MAC_FACTORY')
self.assertEqual(t[0].group, str(0))
self.assertEqual(t[1].field_name, 'MAC_FACTORY')
self.assertEqual(t[1].group, str(1))
self.assertEqual(t[2].field_name, 'MAC_FACTORY')
self.assertEqual(t[2].group, str(2))
self.assertEqual(t[3].field_name, 'MAC_FACTORY')
self.assertEqual(t[3].group, str(3))
self.assertEqual(t[4].field_name, 'MAC_FACTORY')
self.assertEqual(t[4].group, str(4))
self.assertEqual(t[5].field_name, 'MAC_FACTORY')
self.assertEqual(t[5].group, str(5))
self.assertEqual(t[6].field_name, 'MAC_EXT')
self.assertEqual(t[6].group, str(0))
self.assertEqual(t[7].field_name, 'MAC_EXT')
self.assertEqual(t[7].group, str(1))
def test_two_fields_with_lists_and_field_between(self):
csv = """
MAC_FACTORY, EFUSE_BLK1, 40, 8, Factory MAC addr [0]
, EFUSE_BLK1, 32, 8, Factory MAC addr [1]
, EFUSE_BLK1, 24, 8, Factory MAC addr [2]
, EFUSE_BLK1, 16, 8, Factory MAC addr [3]
, EFUSE_BLK1, 8, 8, Factory MAC addr [4]
, EFUSE_BLK1, 0, 8, Factory MAC addr [5]
name2, EFUSE_BLK3, 5, 1, comment
MAC_EXT, EFUSE_BLK1, 123, 8, Extend MAC addr [0]
, EFUSE_BLK1, 131, 8, Extend MAC addr [1]
"""
t = efuse_table_gen.FuseTable.from_csv(csv)
t.verify()
self.assertEqual(t[0].field_name, 'MAC_FACTORY')
self.assertEqual(t[0].group, str(0))
self.assertEqual(t[1].field_name, 'MAC_FACTORY')
self.assertEqual(t[1].group, str(1))
self.assertEqual(t[2].field_name, 'MAC_FACTORY')
self.assertEqual(t[2].group, str(2))
self.assertEqual(t[3].field_name, 'MAC_FACTORY')
self.assertEqual(t[3].group, str(3))
self.assertEqual(t[4].field_name, 'MAC_FACTORY')
self.assertEqual(t[4].group, str(4))
self.assertEqual(t[5].field_name, 'MAC_FACTORY')
self.assertEqual(t[5].group, str(5))
self.assertEqual(t[6].field_name, 'name2')
self.assertEqual(t[7].field_name, 'MAC_EXT')
self.assertEqual(t[7].group, str(0))
self.assertEqual(t[8].field_name, 'MAC_EXT')
self.assertEqual(t[8].group, str(1))
if __name__ == '__main__':
unittest.main()