esptool 4.6.1__tar.gz → 4.7.dev1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. {esptool-4.6.1/esptool.egg-info → esptool-4.7.dev1}/PKG-INFO +20 -17
  2. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/__init__.py +2 -0
  3. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/base_fields.py +7 -2
  4. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32c6/fields.py +22 -11
  5. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32c6/mem_definition.py +11 -0
  6. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32c6/operations.py +1 -2
  7. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32h2/fields.py +21 -14
  8. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32h2/mem_definition.py +16 -1
  9. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32h2/operations.py +1 -2
  10. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32h2beta1/fields.py +22 -14
  11. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32h2beta1/operations.py +1 -2
  12. esptool-4.7.dev1/espefuse/efuse/esp32p4/emulate_efuse_controller.py +92 -0
  13. esptool-4.7.dev1/espefuse/efuse/esp32p4/fields.py +433 -0
  14. esptool-4.7.dev1/espefuse/efuse/esp32p4/mem_definition.py +169 -0
  15. esptool-4.7.dev1/espefuse/efuse/esp32p4/operations.py +384 -0
  16. esptool-4.7.dev1/espefuse/efuse/esp32s3beta2/__init__.py +3 -0
  17. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse_defs/esp32c3.yaml +5 -3
  18. esptool-4.7.dev1/espefuse/efuse_defs/esp32p4.yaml +91 -0
  19. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse_defs/esp32s3.yaml +8 -3
  20. {esptool-4.6.1 → esptool-4.7.dev1}/espsecure/__init__.py +2 -2
  21. {esptool-4.6.1 → esptool-4.7.dev1}/espsecure/esp_hsm_sign/__init__.py +8 -1
  22. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/__init__.py +12 -4
  23. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/bin_image.py +25 -13
  24. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/cmds.py +94 -10
  25. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/loader.py +7 -2
  26. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/targets/__init__.py +2 -0
  27. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/targets/esp32.py +4 -1
  28. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/targets/esp32c2.py +1 -1
  29. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/targets/esp32c3.py +29 -3
  30. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/targets/esp32c6.py +15 -8
  31. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/targets/esp32h2.py +1 -1
  32. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/targets/esp32h2beta1.py +4 -1
  33. esptool-4.7.dev1/esptool/targets/esp32p4.py +184 -0
  34. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/targets/esp32s2.py +13 -4
  35. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/targets/esp32s3.py +49 -3
  36. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/targets/esp32s3beta2.py +0 -5
  37. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/targets/esp8266.py +3 -1
  38. esptool-4.7.dev1/esptool/targets/stub_flasher/stub_flasher_32.json +7 -0
  39. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/targets/stub_flasher/stub_flasher_32c2.json +2 -2
  40. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/targets/stub_flasher/stub_flasher_32c3.json +2 -2
  41. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/targets/stub_flasher/stub_flasher_32c6.json +2 -2
  42. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/targets/stub_flasher/stub_flasher_32c6beta.json +2 -2
  43. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/targets/stub_flasher/stub_flasher_32h2.json +2 -2
  44. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/targets/stub_flasher/stub_flasher_32h2beta1.json +2 -2
  45. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/targets/stub_flasher/stub_flasher_32h2beta2.json +2 -2
  46. esptool-4.7.dev1/esptool/targets/stub_flasher/stub_flasher_32s2.json +7 -0
  47. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/targets/stub_flasher/stub_flasher_32s3.json +2 -2
  48. esptool-4.7.dev1/esptool/targets/stub_flasher/stub_flasher_32s3beta2.json +7 -0
  49. esptool-4.7.dev1/esptool/targets/stub_flasher/stub_flasher_8266.json +7 -0
  50. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/util.py +2 -0
  51. {esptool-4.6.1 → esptool-4.7.dev1/esptool.egg-info}/PKG-INFO +20 -17
  52. {esptool-4.6.1 → esptool-4.7.dev1}/esptool.egg-info/SOURCES.txt +7 -0
  53. esptool-4.6.1/esptool/targets/stub_flasher/stub_flasher_32.json +0 -7
  54. esptool-4.6.1/esptool/targets/stub_flasher/stub_flasher_32s2.json +0 -7
  55. esptool-4.6.1/esptool/targets/stub_flasher/stub_flasher_32s3beta2.json +0 -7
  56. esptool-4.6.1/esptool/targets/stub_flasher/stub_flasher_8266.json +0 -7
  57. {esptool-4.6.1 → esptool-4.7.dev1}/LICENSE +0 -0
  58. {esptool-4.6.1 → esptool-4.7.dev1}/MANIFEST.in +0 -0
  59. {esptool-4.6.1 → esptool-4.7.dev1}/README.md +0 -0
  60. {esptool-4.6.1 → esptool-4.7.dev1}/esp_rfc2217_server.py +0 -0
  61. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/__main__.py +0 -0
  62. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/__init__.py +0 -0
  63. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/base_operations.py +0 -0
  64. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/emulate_efuse_controller_base.py +0 -0
  65. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32/__init__.py +0 -0
  66. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32/emulate_efuse_controller.py +0 -0
  67. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32/fields.py +0 -0
  68. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32/mem_definition.py +0 -0
  69. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32/operations.py +0 -0
  70. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32c2/__init__.py +0 -0
  71. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32c2/emulate_efuse_controller.py +0 -0
  72. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32c2/fields.py +0 -0
  73. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32c2/mem_definition.py +0 -0
  74. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32c2/operations.py +0 -0
  75. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32c3/__init__.py +0 -0
  76. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32c3/emulate_efuse_controller.py +0 -0
  77. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32c3/fields.py +0 -0
  78. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32c3/mem_definition.py +0 -0
  79. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32c3/operations.py +0 -0
  80. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32c6/__init__.py +0 -0
  81. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32c6/emulate_efuse_controller.py +0 -0
  82. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32h2/__init__.py +0 -0
  83. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32h2/emulate_efuse_controller.py +0 -0
  84. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32h2beta1/__init__.py +0 -0
  85. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32h2beta1/emulate_efuse_controller.py +0 -0
  86. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32h2beta1/mem_definition.py +0 -0
  87. {esptool-4.6.1/espefuse/efuse/esp32s2 → esptool-4.7.dev1/espefuse/efuse/esp32p4}/__init__.py +0 -0
  88. {esptool-4.6.1/espefuse/efuse/esp32s3 → esptool-4.7.dev1/espefuse/efuse/esp32s2}/__init__.py +0 -0
  89. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32s2/emulate_efuse_controller.py +0 -0
  90. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32s2/fields.py +0 -0
  91. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32s2/mem_definition.py +0 -0
  92. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32s2/operations.py +0 -0
  93. {esptool-4.6.1/espefuse/efuse/esp32s3beta2 → esptool-4.7.dev1/espefuse/efuse/esp32s3}/__init__.py +0 -0
  94. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32s3/emulate_efuse_controller.py +0 -0
  95. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32s3/fields.py +0 -0
  96. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32s3/mem_definition.py +0 -0
  97. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32s3/operations.py +0 -0
  98. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32s3beta2/emulate_efuse_controller.py +0 -0
  99. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32s3beta2/fields.py +0 -0
  100. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32s3beta2/mem_definition.py +0 -0
  101. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/esp32s3beta2/operations.py +0 -0
  102. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/mem_definition_base.py +0 -0
  103. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse/util.py +0 -0
  104. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse_defs/esp32.yaml +0 -0
  105. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse_defs/esp32c2.yaml +0 -0
  106. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse_defs/esp32c6.yaml +0 -0
  107. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse_defs/esp32h2.yaml +0 -0
  108. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse/efuse_defs/esp32s2.yaml +0 -0
  109. {esptool-4.6.1 → esptool-4.7.dev1}/espefuse.py +0 -0
  110. {esptool-4.6.1 → esptool-4.7.dev1}/espsecure/__main__.py +0 -0
  111. {esptool-4.6.1 → esptool-4.7.dev1}/espsecure/esp_hsm_sign/exceptions.py +0 -0
  112. {esptool-4.6.1 → esptool-4.7.dev1}/espsecure.py +0 -0
  113. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/__main__.py +0 -0
  114. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/config.py +0 -0
  115. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/reset.py +0 -0
  116. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/targets/esp32c6beta.py +0 -0
  117. {esptool-4.6.1 → esptool-4.7.dev1}/esptool/targets/esp32h2beta2.py +0 -0
  118. {esptool-4.6.1 → esptool-4.7.dev1}/esptool.egg-info/dependency_links.txt +0 -0
  119. {esptool-4.6.1 → esptool-4.7.dev1}/esptool.egg-info/requires.txt +0 -0
  120. {esptool-4.6.1 → esptool-4.7.dev1}/esptool.egg-info/top_level.txt +0 -0
  121. {esptool-4.6.1 → esptool-4.7.dev1}/esptool.py +0 -0
  122. {esptool-4.6.1 → esptool-4.7.dev1}/setup.cfg +0 -0
  123. {esptool-4.6.1 → esptool-4.7.dev1}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: esptool
3
- Version: 4.6.1
3
+ Version: 4.7.dev1
4
4
  Summary: A serial utility to communicate & flash code to Espressif chips.
5
5
  Home-page: https://github.com/espressif/esptool/
6
6
  Author: Fredrik Ahlberg (themadinventor) & Angus Gratton (projectgus) & Espressif Systems
@@ -9,22 +9,6 @@ License: GPLv2+
9
9
  Project-URL: Documentation, https://docs.espressif.com/projects/esptool/
10
10
  Project-URL: Source, https://github.com/espressif/esptool/
11
11
  Project-URL: Tracker, https://github.com/espressif/esptool/issues/
12
- Description:
13
- ==========
14
- esptool.py
15
- ==========
16
- A Python-based, open-source, platform-independent utility to communicate with the ROM bootloader in Espressif chips.
17
-
18
- The esptool.py project is `hosted on github <https://github.com/espressif/esptool>`_.
19
-
20
- Documentation
21
- -------------
22
- Visit online `esptool documentation <https://docs.espressif.com/projects/esptool/>`_ or run ``esptool.py -h``.
23
-
24
- Contributing
25
- ------------
26
- Please see the `contributions guide <https://docs.espressif.com/projects/esptool/en/latest/contributing.html>`_.
27
-
28
12
  Platform: UNKNOWN
29
13
  Classifier: Development Status :: 5 - Production/Stable
30
14
  Classifier: Intended Audience :: Developers
@@ -42,3 +26,22 @@ Classifier: Programming Language :: Python :: 3.10
42
26
  Requires-Python: >=3.7
43
27
  Provides-Extra: dev
44
28
  Provides-Extra: hsm
29
+ License-File: LICENSE
30
+
31
+
32
+ ==========
33
+ esptool.py
34
+ ==========
35
+ A Python-based, open-source, platform-independent utility to communicate with the ROM bootloader in Espressif chips.
36
+
37
+ The esptool.py project is `hosted on github <https://github.com/espressif/esptool>`_.
38
+
39
+ Documentation
40
+ -------------
41
+ Visit online `esptool documentation <https://docs.espressif.com/projects/esptool/>`_ or run ``esptool.py -h``.
42
+
43
+ Contributing
44
+ ------------
45
+ Please see the `contributions guide <https://docs.espressif.com/projects/esptool/en/latest/contributing.html>`_.
46
+
47
+
@@ -14,6 +14,7 @@ import espefuse.efuse.esp32c3 as esp32c3_efuse
14
14
  import espefuse.efuse.esp32c6 as esp32c6_efuse
15
15
  import espefuse.efuse.esp32h2 as esp32h2_efuse
16
16
  import espefuse.efuse.esp32h2beta1 as esp32h2beta1_efuse
17
+ import espefuse.efuse.esp32p4 as esp32p4_efuse
17
18
  import espefuse.efuse.esp32s2 as esp32s2_efuse
18
19
  import espefuse.efuse.esp32s3 as esp32s3_efuse
19
20
  import espefuse.efuse.esp32s3beta2 as esp32s3beta2_efuse
@@ -49,6 +50,7 @@ SUPPORTED_CHIPS = {
49
50
  "esp32c3": DefChip("ESP32-C3", esp32c3_efuse, esptool.targets.ESP32C3ROM),
50
51
  "esp32c6": DefChip("ESP32-C6", esp32c6_efuse, esptool.targets.ESP32C6ROM),
51
52
  "esp32h2": DefChip("ESP32-H2", esp32h2_efuse, esptool.targets.ESP32H2ROM),
53
+ "esp32p4": DefChip("ESP32-P4", esp32p4_efuse, esptool.targets.ESP32P4ROM),
52
54
  "esp32h2beta1": DefChip(
53
55
  "ESP32-H2(beta1)", esp32h2beta1_efuse, esptool.targets.ESP32H2BETA1ROM
54
56
  ),
@@ -577,6 +577,9 @@ class EfuseFieldBase(EfuseProtectBase):
577
577
  self.bitarray.set(0)
578
578
  self.update(self.parent.blocks[self.block].bitarray)
579
579
 
580
+ def is_field_calculated(self):
581
+ return self.word is None or self.pos is None
582
+
580
583
  def check_format(self, new_value_str):
581
584
  if new_value_str is None:
582
585
  return new_value_str
@@ -669,8 +672,10 @@ class EfuseFieldBase(EfuseProtectBase):
669
672
  self.save_to_block(bitarray_field)
670
673
 
671
674
  def update(self, bit_array_block):
672
- if self.word is None or self.pos is None:
673
- self.bitarray.overwrite(self.convert_to_bitstring(self.get()), pos=0)
675
+ if self.is_field_calculated():
676
+ self.bitarray.overwrite(
677
+ self.convert_to_bitstring(self.check_format(self.get())), pos=0
678
+ )
674
679
  return
675
680
  field_len = self.bitarray.len
676
681
  bit_array_block.pos = bit_array_block.length - (
@@ -326,23 +326,27 @@ class EfuseMacField(EfuseField):
326
326
  raise esptool.FatalError(
327
327
  "Required MAC Address in AA:CD:EF:01:02:03 format!"
328
328
  )
329
- if new_value_str.count(":") != 5:
329
+ num_bytes = 8 if self.name == "MAC_EUI64" else 6
330
+ if new_value_str.count(":") != num_bytes - 1:
330
331
  raise esptool.FatalError(
331
- "MAC Address needs to be a 6-byte hexadecimal format "
332
+ f"MAC Address needs to be a {num_bytes}-byte hexadecimal format "
332
333
  "separated by colons (:)!"
333
334
  )
334
- hexad = new_value_str.replace(":", "")
335
- if len(hexad) != 12:
335
+ hexad = new_value_str.replace(":", "").split(" ", 1)[0]
336
+ hexad = hexad.split(" ", 1)[0] if self.is_field_calculated() else hexad
337
+ if len(hexad) != num_bytes * 2:
336
338
  raise esptool.FatalError(
337
- "MAC Address needs to be a 6-byte hexadecimal number "
338
- "(12 hexadecimal characters)!"
339
+ f"MAC Address needs to be a {num_bytes}-byte hexadecimal number "
340
+ f"({num_bytes * 2} hexadecimal characters)!"
339
341
  )
340
342
  # order of bytearray = b'\xaa\xcd\xef\x01\x02\x03',
341
343
  bindata = binascii.unhexlify(hexad)
342
- # unicast address check according to
343
- # https://tools.ietf.org/html/rfc7042#section-2.1
344
- if esptool.util.byte(bindata, 0) & 0x01:
345
- raise esptool.FatalError("Custom MAC must be a unicast MAC!")
344
+
345
+ if not self.is_field_calculated():
346
+ # unicast address check according to
347
+ # https://tools.ietf.org/html/rfc7042#section-2.1
348
+ if esptool.util.byte(bindata, 0) & 0x01:
349
+ raise esptool.FatalError("Custom MAC must be a unicast MAC!")
346
350
  return bindata
347
351
 
348
352
  def check(self):
@@ -356,6 +360,13 @@ class EfuseMacField(EfuseField):
356
360
  def get(self, from_read=True):
357
361
  if self.name == "CUSTOM_MAC":
358
362
  mac = self.get_raw(from_read)[::-1]
363
+ elif self.name == "MAC":
364
+ mac = self.get_raw(from_read)
365
+ elif self.name == "MAC_EUI64":
366
+ mac = self.parent["MAC"].get_bitstring(from_read).copy()
367
+ mac_ext = self.parent["MAC_EXT"].get_bitstring(from_read)
368
+ mac.insert(mac_ext, 24)
369
+ mac = mac.bytes
359
370
  else:
360
371
  mac = self.get_raw(from_read)
361
372
  return "%s %s" % (util.hexify(mac, ":"), self.check())
@@ -375,7 +386,7 @@ class EfuseMacField(EfuseField):
375
386
  else:
376
387
  # Writing the BLOCK1 (MAC_SPI_8M_0) default MAC is not possible,
377
388
  # as it's written in the factory.
378
- raise esptool.FatalError("Writing Factory MAC address is not supported")
389
+ raise esptool.FatalError(f"Burning {self.name} is not supported")
379
390
 
380
391
 
381
392
  # fmt: off
@@ -12,6 +12,7 @@ from ..mem_definition_base import (
12
12
  EfuseBlocksBase,
13
13
  EfuseFieldsBase,
14
14
  EfuseRegistersBase,
15
+ Field,
15
16
  )
16
17
 
17
18
 
@@ -151,6 +152,16 @@ class EfuseDefineFields(EfuseFieldsBase):
151
152
  self.BLOCK2_CALIBRATION_EFUSES.append(efuse)
152
153
  self.ALL_EFUSES[i] = None
153
154
 
155
+ f = Field()
156
+ f.name = "MAC_EUI64"
157
+ f.block = 1
158
+ f.bit_len = 64
159
+ f.type = f"bytes:{f.bit_len // 8}"
160
+ f.category = "MAC"
161
+ f.class_type = "mac"
162
+ f.description = "calc MAC_EUI64 = MAC[0]:MAC[1]:MAC[2]:MAC_EXT[0]:MAC_EXT[1]:MAC[3]:MAC[4]:MAC[5]"
163
+ self.CALC.append(f)
164
+
154
165
  for efuse in self.ALL_EFUSES:
155
166
  if efuse is not None:
156
167
  self.EFUSES.append(efuse)
@@ -167,8 +167,7 @@ def add_commands(subparsers, efuses):
167
167
  p.add_argument(
168
168
  "mac",
169
169
  help="Custom MAC Address to burn given in hexadecimal format with bytes "
170
- "separated by colons (e.g. AA:CD:EF:01:02:03). "
171
- "Final CUSTOM_MAC = CUSTOM_MAC[48] + MAC_EXT[16]",
170
+ "separated by colons (e.g. AA:CD:EF:01:02:03).",
172
171
  type=fields.base_fields.CheckArgValue(efuses, "CUSTOM_MAC"),
173
172
  )
174
173
  add_force_write_always(p)
@@ -327,23 +327,27 @@ class EfuseMacField(EfuseField):
327
327
  raise esptool.FatalError(
328
328
  "Required MAC Address in AA:CD:EF:01:02:03 format!"
329
329
  )
330
- if new_value_str.count(":") != 5:
330
+ num_bytes = 8 if self.name == "MAC_EUI64" else 6
331
+ if new_value_str.count(":") != num_bytes - 1:
331
332
  raise esptool.FatalError(
332
- "MAC Address needs to be a 6-byte hexadecimal format "
333
+ f"MAC Address needs to be a {num_bytes}-byte hexadecimal format "
333
334
  "separated by colons (:)!"
334
335
  )
335
336
  hexad = new_value_str.replace(":", "")
336
- if len(hexad) != 12:
337
+ hexad = hexad.split(" ", 1)[0] if self.is_field_calculated() else hexad
338
+ if len(hexad) != num_bytes * 2:
337
339
  raise esptool.FatalError(
338
- "MAC Address needs to be a 6-byte hexadecimal number "
339
- "(12 hexadecimal characters)!"
340
+ f"MAC Address needs to be a {num_bytes}-byte hexadecimal number "
341
+ f"({num_bytes * 2} hexadecimal characters)!"
340
342
  )
341
343
  # order of bytearray = b'\xaa\xcd\xef\x01\x02\x03',
342
344
  bindata = binascii.unhexlify(hexad)
343
- # unicast address check according to
344
- # https://tools.ietf.org/html/rfc7042#section-2.1
345
- if esptool.util.byte(bindata, 0) & 0x01:
346
- raise esptool.FatalError("Custom MAC must be a unicast MAC!")
345
+
346
+ if not self.is_field_calculated():
347
+ # unicast address check according to
348
+ # https://tools.ietf.org/html/rfc7042#section-2.1
349
+ if esptool.util.byte(bindata, 0) & 0x01:
350
+ raise esptool.FatalError("Custom MAC must be a unicast MAC!")
347
351
  return bindata
348
352
 
349
353
  def check(self):
@@ -356,11 +360,14 @@ class EfuseMacField(EfuseField):
356
360
 
357
361
  def get(self, from_read=True):
358
362
  if self.name == "CUSTOM_MAC":
359
- mac = self.get_raw(from_read)[::-1] + self.parent["MAC_EXT"].get_raw(
360
- from_read
361
- )
363
+ mac = self.get_raw(from_read)[::-1]
362
364
  elif self.name == "MAC":
363
- mac = self.get_raw(from_read) + self.parent["MAC_EXT"].get_raw(from_read)
365
+ mac = self.get_raw(from_read)
366
+ elif self.name == "MAC_EUI64":
367
+ mac = self.parent["MAC"].get_bitstring(from_read).copy()
368
+ mac_ext = self.parent["MAC_EXT"].get_bitstring(from_read)
369
+ mac.insert(mac_ext, 24)
370
+ mac = mac.bytes
364
371
  else:
365
372
  mac = self.get_raw(from_read)
366
373
  return "%s %s" % (util.hexify(mac, ":"), self.check())
@@ -380,7 +387,7 @@ class EfuseMacField(EfuseField):
380
387
  else:
381
388
  # Writing the BLOCK1 (MAC_SPI_8M_0) default MAC is not possible,
382
389
  # as it's written in the factory.
383
- raise esptool.FatalError("Writing Factory MAC address is not supported")
390
+ raise esptool.FatalError(f"Burning {self.name} is not supported")
384
391
 
385
392
 
386
393
  # fmt: off
@@ -8,7 +8,12 @@ import os
8
8
 
9
9
  import yaml
10
10
 
11
- from ..mem_definition_base import EfuseBlocksBase, EfuseFieldsBase, EfuseRegistersBase
11
+ from ..mem_definition_base import (
12
+ EfuseBlocksBase,
13
+ EfuseFieldsBase,
14
+ EfuseRegistersBase,
15
+ Field,
16
+ )
12
17
 
13
18
 
14
19
  class EfuseDefineRegisters(EfuseRegistersBase):
@@ -147,6 +152,16 @@ class EfuseDefineFields(EfuseFieldsBase):
147
152
  self.BLOCK2_CALIBRATION_EFUSES.append(efuse)
148
153
  self.ALL_EFUSES[i] = None
149
154
 
155
+ f = Field()
156
+ f.name = "MAC_EUI64"
157
+ f.block = 1
158
+ f.bit_len = 64
159
+ f.type = f"bytes:{f.bit_len // 8}"
160
+ f.category = "MAC"
161
+ f.class_type = "mac"
162
+ f.description = "calc MAC_EUI64 = MAC[0]:MAC[1]:MAC[2]:MAC_EXT[0]:MAC_EXT[1]:MAC[3]:MAC[4]:MAC[5]"
163
+ self.CALC.append(f)
164
+
150
165
  for efuse in self.ALL_EFUSES:
151
166
  if efuse is not None:
152
167
  self.EFUSES.append(efuse)
@@ -166,8 +166,7 @@ def add_commands(subparsers, efuses):
166
166
  p.add_argument(
167
167
  "mac",
168
168
  help="Custom MAC Address to burn given in hexadecimal format with bytes "
169
- "separated by colons (e.g. AA:CD:EF:01:02:03). "
170
- "Final CUSTOM_MAC = CUSTOM_MAC[48] + MAC_EXT[16]",
169
+ "separated by colons (e.g. AA:CD:EF:01:02:03).",
171
170
  type=fields.base_fields.CheckArgValue(efuses, "CUSTOM_MAC"),
172
171
  )
173
172
  add_force_write_always(p)
@@ -326,23 +326,27 @@ class EfuseMacField(EfuseField):
326
326
  raise esptool.FatalError(
327
327
  "Required MAC Address in AA:CD:EF:01:02:03 format!"
328
328
  )
329
- if new_value_str.count(":") != 5:
329
+ num_bytes = 8 if self.name == "MAC_EUI64" else 6
330
+ if new_value_str.count(":") != num_bytes - 1:
330
331
  raise esptool.FatalError(
331
- "MAC Address needs to be a 6-byte hexadecimal format "
332
+ f"MAC Address needs to be a {num_bytes}-byte hexadecimal format "
332
333
  "separated by colons (:)!"
333
334
  )
334
- hexad = new_value_str.replace(":", "")
335
- if len(hexad) != 12:
335
+ hexad = new_value_str.replace(":", "").split(" ", 1)[0]
336
+ hexad = hexad.split(" ", 1)[0] if self.is_field_calculated() else hexad
337
+ if len(hexad) != num_bytes * 2:
336
338
  raise esptool.FatalError(
337
- "MAC Address needs to be a 6-byte hexadecimal number "
338
- "(12 hexadecimal characters)!"
339
+ f"MAC Address needs to be a {num_bytes}-byte hexadecimal number "
340
+ f"({num_bytes * 2} hexadecimal characters)!"
339
341
  )
340
342
  # order of bytearray = b'\xaa\xcd\xef\x01\x02\x03',
341
343
  bindata = binascii.unhexlify(hexad)
342
- # unicast address check according to
343
- # https://tools.ietf.org/html/rfc7042#section-2.1
344
- if esptool.util.byte(bindata, 0) & 0x01:
345
- raise esptool.FatalError("Custom MAC must be a unicast MAC!")
344
+
345
+ if not self.is_field_calculated():
346
+ # unicast address check according to
347
+ # https://tools.ietf.org/html/rfc7042#section-2.1
348
+ if esptool.util.byte(bindata, 0) & 0x01:
349
+ raise esptool.FatalError("Custom MAC must be a unicast MAC!")
346
350
  return bindata
347
351
 
348
352
  def check(self):
@@ -355,11 +359,14 @@ class EfuseMacField(EfuseField):
355
359
 
356
360
  def get(self, from_read=True):
357
361
  if self.name == "CUSTOM_MAC":
358
- mac = self.get_raw(from_read)[::-1] + self.parent["MAC_EXT"].get_raw(
359
- from_read
360
- )
362
+ mac = self.get_raw(from_read)[::-1]
361
363
  elif self.name == "MAC":
362
- mac = self.get_raw(from_read) + self.parent["MAC_EXT"].get_raw(from_read)
364
+ mac = self.get_raw(from_read)
365
+ elif self.name == "MAC_EUI64":
366
+ mac = self.parent["MAC"].get_bitstring(from_read).copy()
367
+ mac_ext = self.parent["MAC_EXT"].get_bitstring(from_read)
368
+ mac.insert(mac_ext, 24)
369
+ mac = mac.bytes
363
370
  else:
364
371
  mac = self.get_raw(from_read)
365
372
  return "%s %s" % (util.hexify(mac, ":"), self.check())
@@ -379,6 +386,7 @@ class EfuseMacField(EfuseField):
379
386
  else:
380
387
  # Writing the BLOCK1 (MAC_SPI_8M_0) default MAC is not possible,
381
388
  # as it's written in the factory.
389
+ raise esptool.FatalError(f"Burning {self.name} is not supported")
382
390
  raise esptool.FatalError("Writing Factory MAC address is not supported")
383
391
 
384
392
 
@@ -166,8 +166,7 @@ def add_commands(subparsers, efuses):
166
166
  p.add_argument(
167
167
  "mac",
168
168
  help="Custom MAC Address to burn given in hexadecimal format with bytes "
169
- "separated by colons (e.g. AA:CD:EF:01:02:03). "
170
- "Final CUSTOM_MAC = CUSTOM_MAC[48] + MAC_EXT[16]",
169
+ "separated by colons (e.g. AA:CD:EF:01:02:03).",
171
170
  type=fields.base_fields.CheckArgValue(efuses, "CUSTOM_MAC"),
172
171
  )
173
172
  add_force_write_always(p)
@@ -0,0 +1,92 @@
1
+ # This file describes eFuses controller for ESP32-P4 chip
2
+ #
3
+ # SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
4
+ #
5
+ # SPDX-License-Identifier: GPL-2.0-or-later
6
+
7
+ import reedsolo
8
+
9
+ from .mem_definition import EfuseDefineBlocks, EfuseDefineFields, EfuseDefineRegisters
10
+ from ..emulate_efuse_controller_base import EmulateEfuseControllerBase, FatalError
11
+
12
+
13
+ class EmulateEfuseController(EmulateEfuseControllerBase):
14
+ """The class for virtual efuse operation. Using for HOST_TEST."""
15
+
16
+ CHIP_NAME = "ESP32-P4"
17
+ mem = None
18
+ debug = False
19
+
20
+ def __init__(self, efuse_file=None, debug=False):
21
+ self.Blocks = EfuseDefineBlocks
22
+ self.Fields = EfuseDefineFields()
23
+ self.REGS = EfuseDefineRegisters
24
+ super(EmulateEfuseController, self).__init__(efuse_file, debug)
25
+ self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
26
+
27
+ """ esptool method start >>"""
28
+
29
+ def get_major_chip_version(self):
30
+ return 0
31
+
32
+ def get_minor_chip_version(self):
33
+ return 0
34
+
35
+ def get_crystal_freq(self):
36
+ return 40 # MHz (common for all chips)
37
+
38
+ def get_security_info(self):
39
+ return {
40
+ "flags": 0,
41
+ "flash_crypt_cnt": 0,
42
+ "key_purposes": 0,
43
+ "chip_id": 0,
44
+ "api_version": 0,
45
+ }
46
+
47
+ """ << esptool method end """
48
+
49
+ def handle_writing_event(self, addr, value):
50
+ if addr == self.REGS.EFUSE_CMD_REG:
51
+ if value & self.REGS.EFUSE_PGM_CMD:
52
+ self.copy_blocks_wr_regs_to_rd_regs(updated_block=(value >> 2) & 0xF)
53
+ self.clean_blocks_wr_regs()
54
+ self.check_rd_protection_area()
55
+ self.write_reg(addr, 0)
56
+ self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
57
+ elif value == self.REGS.EFUSE_READ_CMD:
58
+ self.write_reg(addr, 0)
59
+ self.write_reg(self.REGS.EFUSE_STATUS_REG, 1)
60
+ self.save_to_file()
61
+
62
+ def get_bitlen_of_block(self, blk, wr=False):
63
+ if blk.id == 0:
64
+ if wr:
65
+ return 32 * 8
66
+ else:
67
+ return 32 * blk.len
68
+ else:
69
+ if wr:
70
+ rs_coding = 32 * 3
71
+ return 32 * 8 + rs_coding
72
+ else:
73
+ return 32 * blk.len
74
+
75
+ def handle_coding_scheme(self, blk, data):
76
+ if blk.id != 0:
77
+ # CODING_SCHEME RS applied only for all blocks except BLK0.
78
+ coded_bytes = 12
79
+ data.pos = coded_bytes * 8
80
+ plain_data = data.readlist("32*uint:8")[::-1]
81
+ # takes 32 bytes
82
+ # apply RS encoding
83
+ rs = reedsolo.RSCodec(coded_bytes)
84
+ # 32 byte of data + 12 bytes RS
85
+ calc_encoded_data = list(rs.encode([x for x in plain_data]))
86
+ data.pos = 0
87
+ if calc_encoded_data != data.readlist("44*uint:8")[::-1]:
88
+ raise FatalError("Error in coding scheme data")
89
+ data = data[coded_bytes * 8 :]
90
+ if blk.len < 8:
91
+ data = data[(8 - blk.len) * 32 :]
92
+ return data