Skip to content

Commit fc12ab8

Browse files
Merge pull request qualcomm-linux#29 from vkraleti/content-xml
Deploy contents.xml to enable automatic image flashing in Axiom
2 parents 5b8159f + cc55107 commit fc12ab8

File tree

5 files changed

+450
-3
lines changed

5 files changed

+450
-3
lines changed

Makefile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,31 @@
11
TOPDIR := $(PWD)
22
PLATFORMS := $(foreach platform,$(wildcard platforms/*),$(platform)/gpt)
3-
BINS := gen_partition.py msp.py ptool.py
3+
PARTITIONS_XML := $(foreach platform,$(wildcard platforms/*),$(platform)/partitions.xml)
4+
CONTENTS_XML := $(patsubst %.xml.in,%.xml,$(wildcard platforms/*/contents.xml.in))
5+
BINS := gen_contents.py gen_partition.py msp.py ptool.py
46
PREFIX ?= /usr/local
57

6-
.PHONY: all check lint integration
8+
.PHONY: all check clean lint integration
79

8-
all: $(PLATFORMS)
10+
all: $(PLATFORMS) $(PARTITIONS_XML) $(CONTENTS_XML)
911

1012
%/gpt: %/partitions.xml
1113
cd $(shell dirname $^) && $(TOPDIR)/ptool.py -x partitions.xml
1214

1315
%/partitions.xml: %/partitions.conf
1416
$(TOPDIR)/gen_partition.py -i $^ -o $@
1517

18+
%/contents.xml: %/partitions.xml %/contents.xml.in
19+
$(TOPDIR)/gen_contents.py -p $< -t $@.in -o $@
20+
1621
lint:
1722
# W605: invalid escape sequence
1823
pycodestyle --select=W605 *.py
1924

25+
# gen_contents.py is nearly perfect except E501: line too long.
26+
# Ensure there are no regressions.
27+
pycodestyle --ignore=E501 gen_contents.py
28+
2029
integration: all
2130
# make sure generated output has created expected files
2231
tests/integration/check-missing-files platforms/*/*.xml
@@ -26,3 +35,6 @@ check: lint integration
2635
install: $(BINS)
2736
install -d $(DESTDIR)$(PREFIX)/bin
2837
install -m 755 $^ $(DESTDIR)$(PREFIX)/bin
38+
39+
clean:
40+
@rm -f platforms/*/*.xml platforms/*/*.bin

gen_contents.py

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
3+
# SPDX-License-Identifier: BSD-3-Clause
4+
5+
import getopt
6+
import sys
7+
8+
from xml.etree import ElementTree as ET
9+
10+
11+
def usage():
12+
print(("\n\tUsage: %s -t <template> -p <partitions_xml_path> -o <output> \n\tVersion 0.1\n" % (sys.argv[0])))
13+
sys.exit(1)
14+
15+
16+
def ParseXML(XMLFile):
17+
try:
18+
tree = ET.parse(XMLFile)
19+
root = tree.getroot()
20+
return root
21+
except FileNotFoundError:
22+
print(f"Error: File '{XMLFile}' not found")
23+
return None
24+
except ET.ParseError as e:
25+
print(f"Error: Failed parsing '{XMLFile}': {e}")
26+
return None
27+
28+
29+
def UpdateMetaData(TemplateRoot, PartitionRoot):
30+
ChipIdList = TemplateRoot.findall('product_info/chipid')
31+
DefaultStorageType = None
32+
for ChipId in ChipIdList:
33+
Flavor = ChipId.get('flavor')
34+
StorageType = ChipId.get('storage_type')
35+
print(f"Chipid Flavor: {Flavor} Storage Type: {StorageType}")
36+
if Flavor == "default":
37+
DefaultStorageType = ChipId.get('storage_type')
38+
39+
PhyPartition = PartitionRoot.findall('physical_partition')
40+
PartitionsSet = set()
41+
Partitions = PartitionRoot.findall('physical_partition/partition')
42+
for partition in Partitions:
43+
label = partition.get('label')
44+
filename = partition.get('filename')
45+
if label and filename:
46+
PartitionsSet.add((label, filename))
47+
print(f"PartitionsSet: {PartitionsSet}")
48+
49+
builds = TemplateRoot.findall('builds_flat/build')
50+
for build in builds:
51+
Name = build.find('name')
52+
print(f"Build Name: {Name.text}")
53+
if Name.text != "common":
54+
continue
55+
DownloadFile = build.find('download_file')
56+
if DownloadFile is not None:
57+
build.remove(DownloadFile)
58+
# Partition entires
59+
for Partition in PartitionsSet:
60+
new_download_file = ET.SubElement(build, "download_file")
61+
new_download_file.set("fastboot_complete", Partition[0])
62+
new_file_name = ET.SubElement(new_download_file, "file_name")
63+
new_file_name.text = Partition[1]
64+
new_file_path = ET.SubElement(new_download_file, "file_path")
65+
new_file_path.text = "."
66+
# GPT Main & GPT Backup entries
67+
for PhysicalPartitionNumber in range(0, len(PhyPartition)):
68+
new_download_file = ET.SubElement(build, "download_file")
69+
new_download_file.set("storage_type", DefaultStorageType)
70+
new_file_name = ET.SubElement(new_download_file, "file_name")
71+
new_file_name.text = 'gpt_main%d.xml' % (PhysicalPartitionNumber)
72+
new_file_path = ET.SubElement(new_download_file, "file_path")
73+
new_file_path.text = "."
74+
new_download_file = ET.SubElement(build, "download_file")
75+
new_download_file.set("storage_type", DefaultStorageType)
76+
new_file_name = ET.SubElement(new_download_file, "file_name")
77+
new_file_name.text = 'gpt_backup%d.xml' % (PhysicalPartitionNumber)
78+
new_file_path = ET.SubElement(new_download_file, "file_path")
79+
new_file_path.text = "."
80+
81+
PartitionFile = build.find('partition_file')
82+
if PartitionFile is not None:
83+
build.remove(PartitionFile)
84+
# Rawprogram entries
85+
for PhysicalPartitionNumber in range(0, len(PhyPartition)):
86+
new_partition_file = ET.SubElement(build, "partition_file")
87+
new_partition_file.set("storage_type", DefaultStorageType)
88+
new_file_name = ET.SubElement(new_partition_file, "file_name")
89+
new_file_name.text = 'rawprogram%d.xml' % (PhysicalPartitionNumber)
90+
new_file_path = ET.SubElement(new_partition_file, "file_path")
91+
new_file_path.set("flavor", "default")
92+
new_file_path.text = "."
93+
94+
PartitionPatchFile = build.find('partition_patch_file')
95+
if PartitionPatchFile is not None:
96+
build.remove(PartitionPatchFile)
97+
# Patch entries
98+
for PhysicalPartitionNumber in range(0, len(PhyPartition)):
99+
new_partition_patch_file = ET.SubElement(build, "partition_patch_file")
100+
new_partition_patch_file.set("storage_type", DefaultStorageType)
101+
new_file_name = ET.SubElement(new_partition_patch_file, "file_name")
102+
new_file_name.text = 'patch%d.xml' % (PhysicalPartitionNumber)
103+
new_file_path = ET.SubElement(new_partition_patch_file, "file_path")
104+
new_file_path.set("flavor", "default")
105+
new_file_path.text = "."
106+
107+
###############################################################################
108+
# main
109+
###############################################################################
110+
111+
112+
if len(sys.argv) < 3:
113+
usage()
114+
115+
try:
116+
if sys.argv[1] == "-h" or sys.argv[1] == "--help":
117+
usage()
118+
try:
119+
opts, rem = getopt.getopt(sys.argv[1:], "t:p:o:")
120+
for (opt, arg) in opts:
121+
if opt in ["-t"]:
122+
template = arg
123+
elif opt in ["-p"]:
124+
partition_xml = arg
125+
elif opt in ["-o"]:
126+
output_xml = arg
127+
else:
128+
usage()
129+
except Exception as argerr:
130+
print(str(argerr))
131+
usage()
132+
133+
print("Selected Template: " + template)
134+
xml_root = ParseXML(template)
135+
136+
print("Selected Partition XML: " + partition_xml)
137+
partition_root = ParseXML(partition_xml)
138+
139+
UpdateMetaData(xml_root, partition_root)
140+
141+
OutputTree = ET.ElementTree(xml_root)
142+
ET.indent(OutputTree, space="\t", level=0)
143+
OutputTree.write(output_xml, encoding="utf-8", xml_declaration=True)
144+
except Exception as e:
145+
print(("Error: ", e))
146+
sys.exit(1)
147+
148+
sys.exit(0)
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?xml version="1.0" ?>
2+
<!--
3+
========================================================================
4+
contents.in
5+
6+
General Description
7+
Contains information about component builds for this target.
8+
It will clone as contents.xml during build compilation process.
9+
10+
Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
11+
SPDX-License-Identifier: BSD-3-Clause
12+
13+
========================================================================
14+
-->
15+
16+
<contents>
17+
<product_flavors cmm_pf_var="PRODUCT_FLAVORS">
18+
<pf>
19+
<name>default</name>
20+
<component>
21+
<name>common</name>
22+
<flavor>default</flavor>
23+
</component>
24+
<component>
25+
<name>apps</name>
26+
<flavor>default</flavor>
27+
</component>
28+
</pf>
29+
</product_flavors>
30+
<product_info>
31+
<product_name>QCM6490.LE.1.0</product_name>
32+
<chipid flavor="default" storage_type="ufs" flash_phase="1">QCM6490</chipid>
33+
<additional_chipid>SM7325,QCS6490</additional_chipid>
34+
<meta_type>SPF</meta_type>
35+
</product_info>
36+
<builds_flat>
37+
<build>
38+
<name>apps</name>
39+
<role>apps</role>
40+
<chipset>QCM6490</chipset>
41+
<windows_root_path>.\</windows_root_path>
42+
<linux_root_path>./</linux_root_path>
43+
<image_dir>apps_proc</image_dir>
44+
</build>
45+
<build>
46+
<name>common</name>
47+
<role>common</role>
48+
<chipset>QCM6490</chipset>
49+
<windows_root_path>.\</windows_root_path>
50+
<linux_root_path>./</linux_root_path>
51+
<image_dir>common</image_dir>
52+
<device_programmer>
53+
<file_name>prog_firehose_ddr.elf</file_name>
54+
<file_path>.</file_path>
55+
</device_programmer>
56+
<device_programmer firehose_type="lite">
57+
<file_name>prog_firehose_lite.elf</file_name>
58+
<file_path>.</file_path>
59+
</device_programmer>
60+
<download_file>
61+
<fastboot_complete>{partition_name}</fastboot_complete>
62+
<file_name>{image_name}</file_name>
63+
<file_path>.</file_path>
64+
</download_file>
65+
<partition_file>
66+
<storage_type>{storage_type}</storage_type>
67+
<file_name>{partition_file_name}</file_name>
68+
<file_path flavor="default">.</file_path>
69+
</partition_file>
70+
<partition_patch_file>
71+
<storage_type>{storage_type}</storage_type>
72+
<file_name>{partition_patch_file_name}</file_name>
73+
<file_path flavor="default">.</file_path>
74+
</partition_patch_file>
75+
</build>
76+
</builds_flat>
77+
</contents>
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?xml version="1.0" ?>
2+
<!--
3+
========================================================================
4+
contents.xml.in
5+
6+
General Description
7+
Contains information about component builds for this target.
8+
It will clone as contents.xml during build compilation process.
9+
10+
Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
11+
SPDX-License-Identifier: BSD-3-Clause
12+
13+
========================================================================
14+
-->
15+
16+
<contents>
17+
<product_flavors cmm_pf_var="PRODUCT_FLAVORS">
18+
<pf>
19+
<name>default</name>
20+
<component>
21+
<name>common</name>
22+
<flavor>default</flavor>
23+
</component>
24+
<component>
25+
<name>apps</name>
26+
<flavor>default</flavor>
27+
</component>
28+
</pf>
29+
<pf>
30+
<name>sail_nor</name>
31+
<component>
32+
<name>common</name>
33+
<flavor>sail_nor</flavor>
34+
</component>
35+
</pf>
36+
</product_flavors>
37+
<product_info>
38+
<product_name>QCS8300.LE.1.0</product_name>
39+
<chipid flavor="default" storage_type="ufs" flash_phase="1">QCS8300</chipid>
40+
<chipid flavor="sail_nor" storage_type="spinor" flash_phase="2">QCS8300</chipid>
41+
<additional_chipid>QCS8275</additional_chipid>
42+
<meta_type>SPF</meta_type>
43+
</product_info>
44+
<builds_flat>
45+
<build>
46+
<name>apps</name>
47+
<role>apps</role>
48+
<chipset>QCS8300</chipset>
49+
<windows_root_path>.\</windows_root_path>
50+
<linux_root_path>./</linux_root_path>
51+
<image_dir>apps_proc</image_dir>
52+
</build>
53+
<build>
54+
<name>common</name>
55+
<role>common</role>
56+
<chipset>QCS8300</chipset>
57+
<windows_root_path>.\</windows_root_path>
58+
<linux_root_path>./</linux_root_path>
59+
<image_dir>common</image_dir>
60+
<device_programmer>
61+
<file_name>prog_firehose_ddr.elf</file_name>
62+
<file_path>.</file_path>
63+
</device_programmer>
64+
<device_programmer firehose_type="lite">
65+
<file_name>prog_firehose_lite.elf</file_name>
66+
<file_path>.</file_path>
67+
</device_programmer>
68+
<download_file>
69+
<fastboot_complete>{partition_name}</fastboot_complete>
70+
<file_name>{image_name}</file_name>
71+
<file_path>.</file_path>
72+
</download_file>
73+
<partition_file>
74+
<storage_type>{storage_type}</storage_type>
75+
<file_name>{partition_file_name}</file_name>
76+
<file_path flavor="default">.</file_path>
77+
</partition_file>
78+
<partition_patch_file>
79+
<storage_type>{storage_type}</storage_type>
80+
<file_name>{partition_patch_file_name}</file_name>
81+
<file_path flavor="default">.</file_path>
82+
</partition_patch_file>
83+
<download_file storage_type="spinor" fastboot_complete="SAIL_HYP">
84+
<file_name>sailfreertos.elf</file_name>
85+
<file_path flavor="sail_nor">./sail_nor</file_path>
86+
</download_file>
87+
<download_file storage_type="spinor" flavor="sail_nor">
88+
<file_name>gpt_main0.bin</file_name>
89+
<file_path flavor="sail_nor">./sail_nor</file_path>
90+
</download_file>
91+
<download_file storage_type="spinor" flavor="sail_nor">
92+
<file_name>gpt_backup0.bin</file_name>
93+
<file_path flavor="sail_nor">./sail_nor</file_path>
94+
</download_file>
95+
<partition_file storage_type="spinor" flavor="sail_nor">
96+
<file_name>rawprogram0.xml</file_name>
97+
<file_path flavor="sail_nor">./sail_nor</file_path>
98+
</partition_file>
99+
<partition_patch_file storage_type="spinor" flavor="sail_nor">
100+
<file_name>patch0.xml</file_name>
101+
<file_path flavor="sail_nor">./sail_nor</file_path>
102+
</partition_patch_file>
103+
</build>
104+
</builds_flat>
105+
</contents>

0 commit comments

Comments
 (0)