Created
August 9, 2024 14:21
-
-
Save martonmiklos/2f6038335d374ea05475c2238fc5c54d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import glob | |
import os | |
import lxml.etree as ET | |
struct_item = '''\ | |
{{ | |
.vendor = "Microchip", | |
.name = "{name}", | |
.bustype = BUS_SPI, | |
.manufacture_id = 0, /* Not used. */ | |
.model_id = 0, | |
.total_size = 8, | |
.page_size = {page_size}, | |
.feature_bits = FEATURE_2BA | FEATURE_NO_ERASE, | |
.tested = TEST_UNTESTED, | |
.probe = NULL, | |
.probe_timing = TIMING_ZERO, | |
.block_erasers = | |
{{ | |
{{ | |
.eraseblocks = {{ {erase_block_size}, 1}}, | |
.block_erase = spi_block_erase_emulation, | |
}} | |
}}, | |
.printlock = spi_prettyprint_status_register_bp1_srwd, /* TODO: check */ | |
.unlock = spi_disable_blockprotect_bp1_srwd, | |
.write = spi_chip_write_256, | |
.read = spi_chip_read, | |
.voltage = {{ {min_voltage}, {max_voltage} }}, | |
}},''' | |
for pic in glob.glob("/home/mm/Projektek/flashrom/Microchip.SERIALEE_DFP.1.3.42/SPI only/*.PIC"): | |
root = ET.parse(pic) | |
print(struct_item.format(name=root.xpath("//edc:PIC/@edc:name", namespaces={'edc': 'http://crownking/edc'})[0], | |
page_size=root.xpath("//edc:ProgramSpace/edc:EEDataSector/@edc:endaddr", namespaces={'edc': 'http://crownking/edc'})[0], | |
erase_block_size=root.xpath("//edc:ProgramSpace/edc:EEDataSector/@edc:endaddr", namespaces={'edc': 'http://crownking/edc'})[0], | |
min_voltage=root.xpath("/*/edc:Power/edc:VDD/@edc:minvoltage", namespaces={'edc': 'http://crownking/edc'})[0], | |
max_voltage=root.xpath("/*/edc:Power/edc:VDD/@edc:maxvoltage", namespaces={'edc': 'http://crownking/edc'})[0])) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment