Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 4 additions & 26 deletions gen_partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def usage():
"bootable": "false",
"readonly": "true",
"filename": "",
"sparse" : "false"
"sparse" : "false",
"physical_partition": "0"
}

##################################################################
Expand Down Expand Up @@ -151,28 +152,6 @@ def parse_disk_entry(disk_entry):
print (str(e))
usage()

def generate_single_disk_xml (disk_params, partition_entries_dict, output_xml):
root = ET.Element("configuration")
parser_instruction_text = ""

for key, value in disk_params.items():
if not key == 'size' and not key == 'type':
parser_instruction_text += '\n\t' + str(key) + '=' + str(value) + '\n\t'

parser_inst = ET.SubElement(root,"parser_instructions").text = (
parser_instruction_text
)

phy_part = ET.SubElement(root, "physical_partition")

for partition_index, entry in partition_entries_dict.items():
part_entry = parse_partition_entry(entry)
part = ET.SubElement(phy_part, "partition", attrib=part_entry)

xmlstr = minidom.parseString(ET.tostring(root)).toprettyxml()
with open(output_xml, "w") as f:
f.write(xmlstr)

def generate_multi_lun_xml (disk_params, partition_entries_dict, output_xml):
root = ET.Element("configuration")
parser_instruction_text = ""
Expand Down Expand Up @@ -207,9 +186,8 @@ def generate_multi_lun_xml (disk_params, partition_entries_dict, output_xml):
def generate_partition_xml (disk_entry, partition_entries_dict, output_xml):
parse_disk_entry(disk_entry)
print("Generating %s XML %s" %(disk_params["type"].upper(), output_xml))
if disk_params["type"] in ("emmc", "nvme", "spinor"):
generate_single_disk_xml(disk_params, partition_entries_dict, output_xml)
elif disk_params["type"] == "ufs":

if disk_params["type"] in ("emmc", "nvme", "spinor", "ufs"):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a really nice change. this code gives me headache each time i need to read it.. we probably should clean up even further (not in this PR) the generate_multi_lun_xml() function. you might have noticed that we are doing the main loop 6 times even there is just 1 or 2 physical partitions..

but for the purpose of this PR, I am +1

I also generated all partitions xml file before/after this PR, and they are unchanged (expected), except for the 8275 EVK of course.

generate_multi_lun_xml(disk_params, partition_entries_dict, output_xml)
else:
print("%s XML generation is curently not supported." %(disk_params["type"].upper()))
Expand Down