Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 15 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
TOPDIR := $(PWD)
PLATFORMS := $(foreach platform,$(wildcard platforms/*),$(platform)/gpt)
BINS := gen_partition.py msp.py ptool.py
PARTITIONS_XML := $(foreach platform,$(wildcard platforms/*),$(platform)/partitions.xml)
CONTENTS_XML := $(patsubst %.xml.in,%.xml,$(wildcard platforms/*/contents.xml.in))
BINS := gen_contents.py gen_partition.py msp.py ptool.py
PREFIX ?= /usr/local

.PHONY: all check lint integration
.PHONY: all check clean lint integration

all: $(PLATFORMS)
all: $(PLATFORMS) $(PARTITIONS_XML) $(CONTENTS_XML)

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

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

%/contents.xml: %/partitions.xml %/contents.xml.in
$(TOPDIR)/gen_contents.py -p $< -t $@.in -o $@

lint:
# W605: invalid escape sequence
pycodestyle --select=W605 *.py

# gen_contents.py is nearly perfect except E501: line too long.
# Ensure there are no regressions.
pycodestyle --ignore=E501 gen_contents.py

integration: all
# make sure generated output has created expected files
tests/integration/check-missing-files platforms/*/*.xml
Expand All @@ -26,3 +35,6 @@ check: lint integration
install: $(BINS)
install -d $(DESTDIR)$(PREFIX)/bin
install -m 755 $^ $(DESTDIR)$(PREFIX)/bin

clean:
@rm -f platforms/*/*.xml platforms/*/*.bin
148 changes: 148 additions & 0 deletions gen_contents.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
#!/usr/bin/env python3
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause

import getopt
import sys

from xml.etree import ElementTree as ET


def usage():
print(("\n\tUsage: %s -t <template> -p <partitions_xml_path> -o <output> \n\tVersion 0.1\n" % (sys.argv[0])))
sys.exit(1)


def ParseXML(XMLFile):
try:
tree = ET.parse(XMLFile)
root = tree.getroot()
return root
except FileNotFoundError:
print(f"Error: File '{XMLFile}' not found")
return None
except ET.ParseError as e:
print(f"Error: Failed parsing '{XMLFile}': {e}")
return None


def UpdateMetaData(TemplateRoot, PartitionRoot):
ChipIdList = TemplateRoot.findall('product_info/chipid')
DefaultStorageType = None
for ChipId in ChipIdList:
Flavor = ChipId.get('flavor')
StorageType = ChipId.get('storage_type')
print(f"Chipid Flavor: {Flavor} Storage Type: {StorageType}")
if Flavor == "default":
DefaultStorageType = ChipId.get('storage_type')

PhyPartition = PartitionRoot.findall('physical_partition')
PartitionsSet = set()
Partitions = PartitionRoot.findall('physical_partition/partition')
for partition in Partitions:
label = partition.get('label')
filename = partition.get('filename')
if label and filename:
PartitionsSet.add((label, filename))
print(f"PartitionsSet: {PartitionsSet}")

builds = TemplateRoot.findall('builds_flat/build')
for build in builds:
Name = build.find('name')
print(f"Build Name: {Name.text}")
if Name.text != "common":
continue
DownloadFile = build.find('download_file')
if DownloadFile is not None:
build.remove(DownloadFile)
# Partition entires
for Partition in PartitionsSet:
new_download_file = ET.SubElement(build, "download_file")
new_download_file.set("fastboot_complete", Partition[0])
new_file_name = ET.SubElement(new_download_file, "file_name")
new_file_name.text = Partition[1]
new_file_path = ET.SubElement(new_download_file, "file_path")
new_file_path.text = "."
# GPT Main & GPT Backup entries
for PhysicalPartitionNumber in range(0, len(PhyPartition)):
new_download_file = ET.SubElement(build, "download_file")
new_download_file.set("storage_type", DefaultStorageType)
new_file_name = ET.SubElement(new_download_file, "file_name")
new_file_name.text = 'gpt_main%d.xml' % (PhysicalPartitionNumber)
new_file_path = ET.SubElement(new_download_file, "file_path")
new_file_path.text = "."
new_download_file = ET.SubElement(build, "download_file")
new_download_file.set("storage_type", DefaultStorageType)
new_file_name = ET.SubElement(new_download_file, "file_name")
new_file_name.text = 'gpt_backup%d.xml' % (PhysicalPartitionNumber)
new_file_path = ET.SubElement(new_download_file, "file_path")
new_file_path.text = "."

PartitionFile = build.find('partition_file')
if PartitionFile is not None:
build.remove(PartitionFile)
# Rawprogram entries
for PhysicalPartitionNumber in range(0, len(PhyPartition)):
new_partition_file = ET.SubElement(build, "partition_file")
new_partition_file.set("storage_type", DefaultStorageType)
new_file_name = ET.SubElement(new_partition_file, "file_name")
new_file_name.text = 'rawprogram%d.xml' % (PhysicalPartitionNumber)
new_file_path = ET.SubElement(new_partition_file, "file_path")
new_file_path.set("flavor", "default")
new_file_path.text = "."

PartitionPatchFile = build.find('partition_patch_file')
if PartitionPatchFile is not None:
build.remove(PartitionPatchFile)
# Patch entries
for PhysicalPartitionNumber in range(0, len(PhyPartition)):
new_partition_patch_file = ET.SubElement(build, "partition_patch_file")
new_partition_patch_file.set("storage_type", DefaultStorageType)
new_file_name = ET.SubElement(new_partition_patch_file, "file_name")
new_file_name.text = 'patch%d.xml' % (PhysicalPartitionNumber)
new_file_path = ET.SubElement(new_partition_patch_file, "file_path")
new_file_path.set("flavor", "default")
new_file_path.text = "."

###############################################################################
# main
###############################################################################


if len(sys.argv) < 3:
usage()

try:
if sys.argv[1] == "-h" or sys.argv[1] == "--help":
usage()
try:
opts, rem = getopt.getopt(sys.argv[1:], "t:p:o:")
for (opt, arg) in opts:
if opt in ["-t"]:
template = arg
elif opt in ["-p"]:
partition_xml = arg
elif opt in ["-o"]:
output_xml = arg
else:
usage()
except Exception as argerr:
print(str(argerr))
usage()

print("Selected Template: " + template)
xml_root = ParseXML(template)

print("Selected Partition XML: " + partition_xml)
partition_root = ParseXML(partition_xml)

UpdateMetaData(xml_root, partition_root)

OutputTree = ET.ElementTree(xml_root)
ET.indent(OutputTree, space="\t", level=0)
OutputTree.write(output_xml, encoding="utf-8", xml_declaration=True)
except Exception as e:
print(("Error: ", e))
sys.exit(1)

sys.exit(0)
77 changes: 77 additions & 0 deletions platforms/qcs6490-rb3gen2/contents.xml.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" ?>
<!--
========================================================================
contents.in

General Description
Contains information about component builds for this target.
It will clone as contents.xml during build compilation process.

Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
SPDX-License-Identifier: BSD-3-Clause

========================================================================
-->

<contents>
<product_flavors cmm_pf_var="PRODUCT_FLAVORS">
<pf>
<name>default</name>
<component>
<name>common</name>
<flavor>default</flavor>
</component>
<component>
<name>apps</name>
<flavor>default</flavor>
</component>
</pf>
</product_flavors>
<product_info>
<product_name>QCM6490.LE.1.0</product_name>
<chipid flavor="default" storage_type="ufs" flash_phase="1">QCM6490</chipid>
<additional_chipid>SM7325,QCS6490</additional_chipid>
<meta_type>SPF</meta_type>
</product_info>
<builds_flat>
<build>
<name>apps</name>
<role>apps</role>
<chipset>QCM6490</chipset>
<windows_root_path>.\</windows_root_path>
<linux_root_path>./</linux_root_path>
<image_dir>apps_proc</image_dir>
</build>
<build>
<name>common</name>
<role>common</role>
<chipset>QCM6490</chipset>
<windows_root_path>.\</windows_root_path>
<linux_root_path>./</linux_root_path>
<image_dir>common</image_dir>
<device_programmer>
<file_name>prog_firehose_ddr.elf</file_name>
<file_path>.</file_path>
</device_programmer>
<device_programmer firehose_type="lite">
<file_name>prog_firehose_lite.elf</file_name>
<file_path>.</file_path>
</device_programmer>
<download_file>
<fastboot_complete>{partition_name}</fastboot_complete>
<file_name>{image_name}</file_name>
<file_path>.</file_path>
</download_file>
<partition_file>
<storage_type>{storage_type}</storage_type>
<file_name>{partition_file_name}</file_name>
<file_path flavor="default">.</file_path>
</partition_file>
<partition_patch_file>
<storage_type>{storage_type}</storage_type>
<file_name>{partition_patch_file_name}</file_name>
<file_path flavor="default">.</file_path>
</partition_patch_file>
</build>
</builds_flat>
</contents>
105 changes: 105 additions & 0 deletions platforms/qcs8300-ride-sx/contents.xml.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?xml version="1.0" ?>
<!--
========================================================================
contents.xml.in

General Description
Contains information about component builds for this target.
It will clone as contents.xml during build compilation process.

Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
SPDX-License-Identifier: BSD-3-Clause

========================================================================
-->

<contents>
<product_flavors cmm_pf_var="PRODUCT_FLAVORS">
<pf>
<name>default</name>
<component>
<name>common</name>
<flavor>default</flavor>
</component>
<component>
<name>apps</name>
<flavor>default</flavor>
</component>
</pf>
<pf>
<name>sail_nor</name>
<component>
<name>common</name>
<flavor>sail_nor</flavor>
</component>
</pf>
</product_flavors>
<product_info>
<product_name>QCS8300.LE.1.0</product_name>
<chipid flavor="default" storage_type="ufs" flash_phase="1">QCS8300</chipid>
<chipid flavor="sail_nor" storage_type="spinor" flash_phase="2">QCS8300</chipid>
<additional_chipid>QCS8275</additional_chipid>
<meta_type>SPF</meta_type>
</product_info>
<builds_flat>
<build>
<name>apps</name>
<role>apps</role>
<chipset>QCS8300</chipset>
<windows_root_path>.\</windows_root_path>
<linux_root_path>./</linux_root_path>
<image_dir>apps_proc</image_dir>
</build>
<build>
<name>common</name>
<role>common</role>
<chipset>QCS8300</chipset>
<windows_root_path>.\</windows_root_path>
<linux_root_path>./</linux_root_path>
<image_dir>common</image_dir>
<device_programmer>
<file_name>prog_firehose_ddr.elf</file_name>
<file_path>.</file_path>
</device_programmer>
<device_programmer firehose_type="lite">
<file_name>prog_firehose_lite.elf</file_name>
<file_path>.</file_path>
</device_programmer>
<download_file>
<fastboot_complete>{partition_name}</fastboot_complete>
<file_name>{image_name}</file_name>
<file_path>.</file_path>
</download_file>
<partition_file>
<storage_type>{storage_type}</storage_type>
<file_name>{partition_file_name}</file_name>
<file_path flavor="default">.</file_path>
</partition_file>
<partition_patch_file>
<storage_type>{storage_type}</storage_type>
<file_name>{partition_patch_file_name}</file_name>
<file_path flavor="default">.</file_path>
</partition_patch_file>
<download_file storage_type="spinor" fastboot_complete="SAIL_HYP">
<file_name>sailfreertos.elf</file_name>
<file_path flavor="sail_nor">./sail_nor</file_path>
</download_file>
<download_file storage_type="spinor" flavor="sail_nor">
<file_name>gpt_main0.bin</file_name>
<file_path flavor="sail_nor">./sail_nor</file_path>
</download_file>
<download_file storage_type="spinor" flavor="sail_nor">
<file_name>gpt_backup0.bin</file_name>
<file_path flavor="sail_nor">./sail_nor</file_path>
</download_file>
<partition_file storage_type="spinor" flavor="sail_nor">
<file_name>rawprogram0.xml</file_name>
<file_path flavor="sail_nor">./sail_nor</file_path>
</partition_file>
<partition_patch_file storage_type="spinor" flavor="sail_nor">
<file_name>patch0.xml</file_name>
<file_path flavor="sail_nor">./sail_nor</file_path>
</partition_patch_file>
</build>
</builds_flat>
</contents>
Loading
Loading