logo elektroda
logo elektroda
X
logo elektroda

PS3_Controller_Host esp_base_mac_addr_set error on ESP32 Arduino core 2.x/3.x (IDF v5.x) – MAC API migration

User question

libraries/PS3_Controller_Host/src/ps3.c:287:5: error: implicit declaration of function 'esp_base_mac_addr_set' [-Wimplicit-function-declaration]
287 | esp_base_mac_addr_set(base_mac);

Artificial Intelligence Response

Direct answer to the question

  • The compiler cannot find esp_base_mac_addr_set() because the function was deprecated in ESP-IDF v4.x and removed in ESP-IDF v5.x (Arduino-ESP32 core ≥ 2.0.x is based on ESP-IDF v5).
  • Your PS3_Controller_Host library was written for an older core (ESP-IDF ≤ v3.3).
  • Fix it by either
    1. Updating the library code to use the current MAC-address APIs (esp_read_mac(), esp_efuse_mac_get_default(), esp_iface_mac_addr_set()), guarded with version checks, or
    2. Building your sketch with an older Arduino-ESP32 core (≤ v1.0.6) that still includes esp_base_mac_addr_set().

Key points
• Function removed in recent IDF → implicit declaration error.
• Replace the call or downgrade the core.
• Add the correct header (esp_mac.h) if you stay on IDF v4.x where the function still exists.


Detailed problem analysis

  1. API Evolution
    • IDF ≤ v3.3 esp_base_mac_addr_set() – fully supported.
    • IDF v4.x   kept but marked “legacy”; new helpers added (esp_efuse_mac_get_default()).
    • IDF v5.0   function deleted; unified MAC API introduced (esp_read_mac(), esp_write_mac(), esp_iface_mac_addr_set()).

  2. What happens in your build
    • Arduino-ESP32 core 2.0.x/3.0.x (default for “DevKit V1” since 2023) is based on IDF v5.x.
    • The header esp_mac.h no longer declares the removed symbol, so the compiler reports an “implicit declaration”.
    • When you select the older “ESP32 WROOM-32S” board package (likely core 1.0.6, IDF v3.3), the symbol exists and compilation succeeds, hence the observed difference.

  3. Impact on PS3 Controller Host library
    • Library uses the old call to load the factory MAC into RAM before creating a Bluetooth host stack.
    • On IDF v5.x this must be replaced by a two-step sequence:

     uint8_t base_mac[6];
    esp_read_mac(base_mac, ESP_MAC_WIFI_STA); // read factory MAC
    esp_iface_mac_addr_set(base_mac, ESP_MAC_BT); // re-apply for BT base

Current information and trends

• ESP-IDF v5.2 (Q2-2024) continues to remove legacy APIs; new projects must migrate.
• Official Arduino-ESP32 core 3.0.0 (May 2024) is now built on top of IDF v5.2-release.
• Maintainers of game-controller libraries (Bluepad32, ESP32-PS3, NimBLE-Gamepad) have already merged patches that drop esp_base_mac_addr_set().


Supporting explanations and details

Version-conditional patch you can drop into ps3.c (around line 287):

#include "esp_mac.h"
static esp_err_t set_bt_base_mac(void)
{
uint8_t base_mac[6];
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) // Arduino-core ≥2.0
ESP_ERROR_CHECK(esp_read_mac(base_mac, ESP_MAC_WIFI_STA));
return esp_iface_mac_addr_set(base_mac, ESP_MAC_BT);
#elif ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0) // legacy but still present
esp_efuse_mac_get_default(base_mac);
return esp_base_mac_addr_set(base_mac);
#else // IDF ≤3.3
return esp_base_mac_addr_set(base_mac);
#endif
}

esp_read_mac() fetches the factory-programmed MAC from eFuse.
esp_iface_mac_addr_set() (IDF v4.4+) sets the base MAC for a specific interface (ESP_MAC_BT for Bluetooth).


Ethical and legal aspects

• Changing MAC addresses can violate device certification or regulatory requirements if done improperly.
• Ensure that modified MACs remain globally unique—never ship devices with duplicate or random public MACs unless you use the locally-administered bit (bit 1 of the first octet).


Practical guidelines

  1. Preferred long-term route
    • Fork the library and apply the version-guarded patch above.
    • Push the change upstream to keep the community codebase healthy.
  2. Quick workaround
    • Tools → Board → Boards Manager → select “esp32 by Espressif Systems” → install version 1.0.6 → compile (keeps old API but freezes you on IDF v3.3).
  3. Verification
    idf.py --version (PlatformIO: pio run -v) to confirm the IDF version pulled in by the core.
    • After patching, run esptool.py chip_id to ensure Bluetooth still reports a valid MAC.

Possible disclaimers or additional notes

• Conditional compilation increases maintenance complexity; test on all targeted cores.
• Some PS3 libraries allocate MAC addresses manually for second controller instances—ensure those code paths are also migrated.
• Future IDF versions may deprecate esp_iface_mac_addr_set() in favour of unified netif APIs; monitor release notes.


Suggestions for further research

• Track Espressif’s “Breaking Changes” section in each IDF release note.
• Examine more modern controller stacks (Bluepad32) for reference MAC-handling patterns.
• Consider moving projects to PlatformIO with a fixed platform = espressif32@~6 entry to lock the IDF version for reproducible builds.


Brief summary

esp_base_mac_addr_set() disappeared in the ESP-IDF used by the current Arduino-ESP32 core, so the PS3 library fails to compile. Replace the call with the new MAC APIs (esp_read_mac() + esp_iface_mac_addr_set()) under a version guard, or compile with an older core that still carries the legacy function. The patch above restores compatibility across IDF v3.3 – v5.x while keeping your firmware forward-proof.

Ask additional question

Wait...(2min)
Disclaimer: The responses provided by artificial intelligence (language model) may be inaccurate and misleading. Elektroda is not responsible for the accuracy, reliability, or completeness of the presented information. All responses should be verified by the user.