@@ -446,7 +446,7 @@ esp_err_t ETHClass::eth_spi_write(uint32_t cmd, uint32_t addr, const void *data,
446446#endif
447447
448448bool ETHClass::beginSPI (
449- eth_phy_type_t type, int32_t phy_addr, int cs, int irq, int rst,
449+ eth_phy_type_t type, int32_t phy_addr, uint8_t * mac_addr_p, int cs, int irq, int rst,
450450#if ETH_SPI_SUPPORTS_CUSTOM
451451 SPIClass *spi,
452452#endif
@@ -654,16 +654,20 @@ bool ETHClass::beginSPI(
654654 return false ;
655655 }
656656
657- // Derive a new MAC address for this interface
658- uint8_t base_mac_addr[ETH_ADDR_LEN];
659- ret = esp_efuse_mac_get_default (base_mac_addr);
660- if (ret != ESP_OK) {
661- log_e (" Get EFUSE MAC failed: %d" , ret);
662- return false ;
663- }
664657 uint8_t mac_addr[ETH_ADDR_LEN];
665- base_mac_addr[ETH_ADDR_LEN - 1 ] += _eth_index; // Increment by the ETH number
666- esp_derive_local_mac (mac_addr, base_mac_addr);
658+ if (mac_addr_p != nullptr ) {
659+ memcpy (mac_addr, mac_addr_p, ETH_ADDR_LEN);
660+ } else {
661+ // Derive a new MAC address for this interface
662+ uint8_t base_mac_addr[ETH_ADDR_LEN];
663+ ret = esp_efuse_mac_get_default (base_mac_addr);
664+ if (ret != ESP_OK) {
665+ log_e (" Get EFUSE MAC failed: %d" , ret);
666+ return false ;
667+ }
668+ base_mac_addr[ETH_ADDR_LEN - 1 ] += _eth_index; // Increment by the ETH number
669+ esp_derive_local_mac (mac_addr, base_mac_addr);
670+ }
667671
668672 ret = esp_eth_ioctl (_eth_handle, ETH_CMD_S_MAC_ADDR, mac_addr);
669673 if (ret != ESP_OK) {
@@ -776,7 +780,7 @@ bool ETHClass::beginSPI(
776780#if ETH_SPI_SUPPORTS_CUSTOM
777781bool ETHClass::begin (eth_phy_type_t type, int32_t phy_addr, int cs, int irq, int rst, SPIClass &spi, uint8_t spi_freq_mhz) {
778782
779- return beginSPI (type, phy_addr, cs, irq, rst, &spi, -1 , -1 , -1 , SPI2_HOST, spi_freq_mhz);
783+ return beginSPI (type, phy_addr, nullptr , cs, irq, rst, &spi, -1 , -1 , -1 , SPI2_HOST, spi_freq_mhz);
780784}
781785#endif
782786
@@ -785,7 +789,7 @@ bool ETHClass::begin(
785789) {
786790
787791 return beginSPI (
788- type, phy_addr, cs, irq, rst,
792+ type, phy_addr, nullptr , cs, irq, rst,
789793#if ETH_SPI_SUPPORTS_CUSTOM
790794 NULL ,
791795#endif
0 commit comments