mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
nvs_partition_generator: Modifications to enable using the utility as a Python library
And also use directly as an executable
This commit is contained in:
parent
fdee0b64a0
commit
8369bd244b
45
components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py
Normal file → Executable file
45
components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py
Normal file → Executable file
@ -333,29 +333,42 @@ def nvs_close(nvs_instance):
|
|||||||
"""
|
"""
|
||||||
nvs_instance.__exit__(None, None, None)
|
nvs_instance.__exit__(None, None, None)
|
||||||
|
|
||||||
def main():
|
def nvs_part_gen(input_filename=None, output_filename=None):
|
||||||
parser = argparse.ArgumentParser(description="ESP32 NVS partition generation utility")
|
input_file = open(input_filename, 'rb')
|
||||||
parser.add_argument(
|
output_file = open(output_filename, 'wb')
|
||||||
"input",
|
|
||||||
help="Path to CSV file to parse. Will use stdin if omitted",
|
|
||||||
type=argparse.FileType('rb'),
|
|
||||||
default=sys.stdin)
|
|
||||||
|
|
||||||
parser.add_argument(
|
with nvs_open(output_file) as nvs_obj:
|
||||||
"output",
|
reader = csv.DictReader(input_file, delimiter=',')
|
||||||
help='Path to output converted binary file. Will use stdout if omitted',
|
|
||||||
type=argparse.FileType('wb'),
|
|
||||||
default=sys.stdout)
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
|
||||||
with nvs_open(args.output) as nvs_obj:
|
|
||||||
reader = csv.DictReader(args.input, delimiter=',')
|
|
||||||
for row in reader:
|
for row in reader:
|
||||||
try:
|
try:
|
||||||
write_entry(nvs_obj, row["key"], row["type"], row["encoding"], row["value"])
|
write_entry(nvs_obj, row["key"], row["type"], row["encoding"], row["value"])
|
||||||
except InputError as e:
|
except InputError as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
input_file.close()
|
||||||
|
output_file.close()
|
||||||
exit(-2)
|
exit(-2)
|
||||||
|
|
||||||
|
input_file.close()
|
||||||
|
output_file.close()
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description="ESP32 NVS partition generation utility")
|
||||||
|
parser.add_argument(
|
||||||
|
"input",
|
||||||
|
help="Path to CSV file to parse. Will use stdin if omitted",
|
||||||
|
default=sys.stdin)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"output",
|
||||||
|
help='Path to output converted binary file. Will use stdout if omitted',
|
||||||
|
default=sys.stdout)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
input_filename = args.input
|
||||||
|
output_filename = args.output
|
||||||
|
nvs_part_gen(input_filename, output_filename)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@ -7,6 +7,7 @@ components/partition_table/gen_esp32part.py
|
|||||||
components/partition_table/parttool.py
|
components/partition_table/parttool.py
|
||||||
components/partition_table/test_gen_esp32part_host/gen_esp32part_tests.py
|
components/partition_table/test_gen_esp32part_host/gen_esp32part_tests.py
|
||||||
components/ulp/esp32ulp_mapgen.py
|
components/ulp/esp32ulp_mapgen.py
|
||||||
|
components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py
|
||||||
docs/check_doc_warnings.sh
|
docs/check_doc_warnings.sh
|
||||||
docs/check_lang_folder_sync.sh
|
docs/check_lang_folder_sync.sh
|
||||||
docs/gen-kconfig-doc.py
|
docs/gen-kconfig-doc.py
|
||||||
|
Loading…
x
Reference in New Issue
Block a user