|
21 | 21 | import logging
|
22 | 22 | import os
|
23 | 23 | import sys
|
| 24 | +from enum import Enum |
24 | 25 | from types import SimpleNamespace
|
25 | 26 |
|
26 | 27 | import cryptography.x509
|
|
45 | 46 | INVALID_PASSCODES = [00000000, 11111111, 22222222, 33333333, 44444444, 55555555,
|
46 | 47 | 66666666, 77777777, 88888888, 99999999, 12345678, 87654321]
|
47 | 48 |
|
| 49 | + |
| 50 | +class Product_Finish_Enum(Enum): |
| 51 | + other = 0 |
| 52 | + matte = 1 |
| 53 | + satin = 2 |
| 54 | + polished = 3 |
| 55 | + rugged = 4 |
| 56 | + fabric = 5 |
| 57 | + |
| 58 | + |
| 59 | +class Product_Color_Enum(Enum): |
| 60 | + black = 0 |
| 61 | + navy = 1 |
| 62 | + green = 2 |
| 63 | + teal = 3 |
| 64 | + maroon = 4 |
| 65 | + purple = 5 |
| 66 | + olive = 6 |
| 67 | + gray = 7 |
| 68 | + blue = 8 |
| 69 | + lime = 9 |
| 70 | + aqua = 10 |
| 71 | + red = 11 |
| 72 | + fuchsia = 12 |
| 73 | + yellow = 13 |
| 74 | + white = 14 |
| 75 | + nickel = 15 |
| 76 | + chrome = 16 |
| 77 | + brass = 17 |
| 78 | + copper = 18 |
| 79 | + silver = 19 |
| 80 | + gold = 20 |
| 81 | + |
| 82 | + |
48 | 83 | TOOLS = {}
|
49 | 84 |
|
50 | 85 | FACTORY_PARTITION_CSV = 'nvs_partition.csv'
|
|
149 | 184 | 'encoding': 'hex2bin',
|
150 | 185 | 'value': None,
|
151 | 186 | },
|
| 187 | + 'product-finish': { |
| 188 | + 'type': 'data', |
| 189 | + 'encoding': 'u32', |
| 190 | + 'value': None, |
| 191 | + }, |
| 192 | + 'product-color': { |
| 193 | + 'type': 'data', |
| 194 | + 'encoding': 'u32', |
| 195 | + 'value': None, |
| 196 | + }, |
| 197 | + 'part-number': { |
| 198 | + 'type': 'data', |
| 199 | + 'encoding': 'string', |
| 200 | + 'value': None, |
| 201 | + }, |
| 202 | + 'product-label': { |
| 203 | + 'type': 'data', |
| 204 | + 'encoding': 'string', |
| 205 | + 'value': None, |
| 206 | + }, |
| 207 | + 'product-url': { |
| 208 | + 'type': 'data', |
| 209 | + 'encoding': 'string', |
| 210 | + 'value': None, |
| 211 | + }, |
152 | 212 | }
|
153 | 213 |
|
154 | 214 |
|
@@ -301,6 +361,16 @@ def populate_factory_data(args, spake2p_params):
|
301 | 361 | FACTORY_DATA['hardware-ver']['value'] = args.hw_ver
|
302 | 362 | if args.hw_ver_str:
|
303 | 363 | FACTORY_DATA['hw-ver-str']['value'] = args.hw_ver_str
|
| 364 | + if args.product_finish: |
| 365 | + FACTORY_DATA['product-finish']['value'] = Product_Finish_Enum[args.product_finish].value |
| 366 | + if args.product_color: |
| 367 | + FACTORY_DATA['product-color']['value'] = Product_Color_Enum[args.product_color].value |
| 368 | + if args.part_number: |
| 369 | + FACTORY_DATA['part-number']['value'] = args.part_number |
| 370 | + if args.product_url: |
| 371 | + FACTORY_DATA['product-url']['value'] = args.product_url |
| 372 | + if args.product_label: |
| 373 | + FACTORY_DATA['product-label']['value'] = args.product_label |
304 | 374 |
|
305 | 375 | # SupportedModes are stored as multiple entries
|
306 | 376 | # - sm-sz/<ep> : number of supported modes for the endpoint
|
@@ -471,6 +541,18 @@ def any_base_int(s): return int(s, 0)
|
471 | 541 | parser.add_argument('--supported-modes', type=str, nargs='+', required=False,
|
472 | 542 | help='List of supported modes, eg: mode1/label1/ep/"tagValue1\\mfgCode, tagValue2\\mfgCode" mode2/label2/ep/"tagValue1\\mfgCode, tagValue2\\mfgCode" mode3/label3/ep/"tagValue1\\mfgCode, tagValue2\\mfgCode"')
|
473 | 543 |
|
| 544 | + product_finish_choices = [finish.name for finish in Product_Finish_Enum] |
| 545 | + parser.add_argument("--product-finish", type=str, choices=product_finish_choices, |
| 546 | + help='Product finishes choices for product appearance') |
| 547 | + |
| 548 | + product_color_choices = [color.name for color in Product_Color_Enum] |
| 549 | + parser.add_argument("--product-color", type=str, choices=product_color_choices, |
| 550 | + help='Product colors choices for product appearance') |
| 551 | + |
| 552 | + parser.add_argument("--part-number", type=str, help='human readable product number') |
| 553 | + parser.add_argument("--product-label", type=str, help='human readable product label') |
| 554 | + parser.add_argument("--product-url", type=str, help='link to product specific web page') |
| 555 | + |
474 | 556 | parser.add_argument('-s', '--size', type=any_base_int, default=0x6000,
|
475 | 557 | help='The size of the partition.bin, default: 0x6000')
|
476 | 558 | parser.add_argument('--target', default='esp32',
|
@@ -509,7 +591,8 @@ def set_up_factory_data(args):
|
509 | 591 | def generate_factory_partiton_binary(args):
|
510 | 592 | generate_nvs_csv(args.output_dir, FACTORY_PARTITION_CSV)
|
511 | 593 | if args.generate_bin:
|
512 |
| - generate_nvs_bin(args.encrypt, args.size, FACTORY_PARTITION_CSV, FACTORY_PARTITION_BIN, args.output_dir) |
| 594 | + csv_file = os.path.join(args.output_dir, FACTORY_PARTITION_CSV) |
| 595 | + generate_nvs_bin(args.encrypt, args.size, csv_file, FACTORY_PARTITION_BIN, args.output_dir) |
513 | 596 | print_flashing_help(args.encrypt, args.output_dir, FACTORY_PARTITION_BIN)
|
514 | 597 | clean_up()
|
515 | 598 |
|
|
0 commit comments