base_mac_address.rst 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. Base MAC address
  2. ================
  3. Overview
  4. --------
  5. Serveral MAC addresses (universally administered by IEEE) are uniquely assigned to the networking interfaces (WiFi/BT/Ethernet).
  6. The final octet of each universally administered MAC address increases by one. Only the first one which is called base MAC address
  7. of them is stored in EFUSE or external storage, the others are generated from it. Here, 'generate' means adding 0, 1, 2 and 3
  8. (respectively) to the final octet of the base MAC address.
  9. If the universally administered MAC addresses are not enough for all of the networking interfaces. Local administered MAC addresses
  10. which are derived from universally administered MAC addresses are assigned to the reset of networking interfaces.
  11. A `definition of local vs universal MAC address can be found on Wikipedia <https://en.wikipedia.org/wiki/MAC_address#Universal_vs._local>`_.
  12. The number of universally administered MAC address can be configured using ``make menuconfig``.
  13. Base MAC address
  14. ^^^^^^^^^^^^^^^^
  15. If using the default base MAC address factory programmed by Espressif in BLK0 of EFUSE, nothing needs to be done.
  16. If using a custom base MAC address stored in BLK3 of EFUSE, call API ``esp_efuse_mac_get_custom()`` to get the base MAC address
  17. which is stored in BLK3 of EFUSE. If correct MAC address is returned, then call ``esp_base_mac_addr_set()`` to set the base MAC
  18. address for system to generate the MAC addresses used by the networking interfaces(WiFi/BT/Ethernet).
  19. There are 192 bits storage spaces for custom to store base MAC address in BLK3 of EFUSE. They are EFUSE_BLK3_RDATA0,
  20. EFUSE_BLK3_RDATA1, EFUSE_BLK3_RDATA2, EFUSE_BLK3_RDATA3, EFUSE_BLK3_RDATA4 and EFUSE_BLK3_RDATA5, each of them is 32 bits
  21. register. The format of the 192 bits storage spaces is:
  22. .. highlight:: none
  23. ::
  24. ------------------------------------------------------
  25. Field |Bits |Range |Description
  26. ------------------------------------------------------
  27. version |8 |[191:184] |1: useful. 0: useless
  28. ------------------------------------------------------
  29. reserve |112 |[183:72] |reserved
  30. ------------------------------------------------------
  31. mac address |64 |[71:8] |base MAC address
  32. ------------------------------------------------------
  33. mac crc |8 |[7:0] |crc of base MAC address
  34. ------------------------------------------------------
  35. If using base MAC address stored in external storage, firstly get the base MAC address stored in external storage, then call
  36. API ``esp_base_mac_addr_set()`` to set the base MAC address for system to generate the MAC addresses used by the networking
  37. interfaces(WiFi/BT/Ethernet).
  38. All of the steps must be done before initializing the networking interfaces(WiFi/BT/Ethernet). It is recommended to do it in
  39. ``app_main()`` which can be referenced in :example:`system/base_mac_address`.
  40. Number of universally administered MAC address
  41. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  42. If the number of universal MAC addresses is two, only two interfaces (WiFi station and Bluetooth) receive a universally
  43. administered MAC address. These are generated sequentially by adding 0 and 1 (respectively) to the base MAC address.
  44. The remaining two interfaces (WiFi softap and Ethernet) receive local MAC addresses. These are derived from the universal
  45. WiFi station and Bluetooth MAC addresses, respectively.
  46. If the number of universal MAC addresses is four, all four interfaces (WiFi station, WiFi softap, Bluetooth and Ethernet)
  47. receive a universally administered MAC address. These are generated sequentially by adding 0, 1, 2 and 3 (respectively)
  48. to the final octet of the base MAC address.
  49. When using the default (Espressif-assigned) base MAC address, either setting can be used. When using a custom universal MAC
  50. address range, the correct setting will depend on the allocation of MAC addresses in this range (either 2 or 4 per device.)
  51. API Reference
  52. -------------
  53. Header Files
  54. ^^^^^^^^^^^^
  55. * :component_file:`esp32/include/esp_system.h`
  56. Functions
  57. ---------
  58. .. doxygenfunction:: esp_base_mac_addr_set
  59. .. doxygenfunction:: esp_efuse_mac_get_custom