logo elektroda
logo elektroda
X

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 error appears because esp_base_mac_addr_set() no longer exists in the ESP-IDF version that ships with the current Arduino-ESP32 core (≥ v2.x, based on ESP-IDF v5).
  • The PS3_Controller_Host library you are compiling was written for ESP-IDF v3.x, where this function was still present.
  • Fixes:
    1. Update / patch the library to use the modern MAC-handling APIs (esp_read_mac(), esp_iface_mac_addr_set(), etc.).
    2. Or temporarily downgrade the Arduino-ESP32 core to v1.0.6 (ESP-IDF v3.3) so the original function is available.

Key points

  • esp_base_mac_addr_set() is deprecated (v4) and removed (v5).
  • Modern replacements: read the factory MAC with esp_read_mac() or esp_efuse_mac_get_default(), then set per-interface MACs with esp_iface_mac_addr_set().
  • Updating the library keeps you on the latest core; downgrading is only a quick workaround.

Detailed problem analysis

  1. Error mechanics
    The C compiler emits “implicit declaration …” when it does not find a prototype. In current ESP-IDF headers (v5.x) the symbol simply is not defined.

  2. API evolution
    • ≤ ESP-IDF v3.3:

    esp_err_t esp_base_mac_addr_set(const uint8_t *mac);

    set a 48-bit “base MAC”; Wi-Fi, BT, Ethernet derived interface MACs were calculated from it.

    • ESP-IDF v4.x: Function kept but tagged LEGACY; header moved to esp_mac.h.

    • ESP-IDF v5.x: Function removed. MAC management redesigned; each interface gets its MAC explicitly (or from eFuse) via

    esp_err_t esp_read_mac(uint8_t *mac, esp_mac_type_t type);
    esp_err_t esp_iface_mac_addr_set(const uint8_t *mac, esp_mac_type_t type);
  3. Library behaviour
    PS3_Controller_Host needs to spoof the Bluetooth MAC so a Sixaxis/DS3 recognises the host as a real PS3. In old code this was done with esp_base_mac_addr_set(). With modern IDF you must set the BT interface MAC before the BT controller is started, using the new API sequence.

  4. Environment mismatch
    • Older board (“ESP32-32S”) compiled with Arduino-ESP32 1.0.x → ESP-IDF 3.3 → OK.
    • New DevKit V1 compiled with Arduino-ESP32 2.0/3.0 → ESP-IDF 5 → symbol gone → build fails.


Current information and trends

  • Arduino-ESP32 2.0.14 and the forthcoming 3.x lines are pinned to ESP-IDF v5.1/5.2.
  • Espressif has unified MAC handling; future silicon (ESP32-C6, S3, H2, etc.) only supports the new API.
  • Actively maintained Bluetooth-HID host libraries (e.g. ps3-esp32 fork by mbs38) are being updated to remove esp_base_mac_addr_set(); watch the relevant GitHub issues/PRs.

Supporting explanations and details

Example patch for ps3.c (minimal, keeps spoofing logic):

#include "esp_mac.h" // new header for MAC functions
#include "esp_bt.h" // BT controller API
static void ps3_custom_mac_init(void)
{
uint8_t base_mac[6] = {0x00, 0x19, 0xC1, 0xA0, 0x00, 0x01}; // example PS3 MAC
#if ESP_IDF_VERSION_MAJOR >= 5
// --- new IDF path ---
// Must be called before esp_bt_controller_init()
esp_err_t err = esp_iface_mac_addr_set(base_mac, ESP_MAC_BT);
if (err != ESP_OK) {
ESP_LOGE("PS3", "Failed to set BT MAC (err 0x%x)", err);
}
#else
// --- legacy path ---
esp_base_mac_addr_set(base_mac);
#endif
}

Usage: call ps3_custom_mac_init() before esp_bt_controller_init() or btStart() inside the library.

Downgrading core (Arduino IDE):

  1. Tools → Board → Boards Manager → search “esp32”.
  2. Select version 1.0.6 (IDF v3.3) → Install → Re-compile.

Ethical and legal aspects

  • MAC spoofing may violate device pairing assumptions or local regulations if used to masquerade as another device on a commercial network.
  • Always disclose modified MACs in certification environments (CE/FCC).
  • Bluetooth operation must still comply with regional radio rules (power, channel use).

Practical guidelines

Implementation checklist for the modern API:

  1. Include esp_mac.h.
  2. Decide target interface (ESP_MAC_BT for PS3).
  3. Call esp_iface_mac_addr_set() before any BT stack initialisation.
  4. Re-pair the controller, as changing MAC invalidates stored link keys.
  5. Monitor with a serial terminal; check ESP_LOG for BT MAC confirmation.

Potential challenges & mitigations:

  • BT controller already initialised → “ESP_ERR_INVALID_STATE”: perform MAC set earlier or call esp_bt_controller_disable() first.
  • MAC in flash/eFuse collisions: ensure your custom MAC does not overlap vendor-assigned ranges.

Possible disclaimers or additional notes

  • Some game consoles will only accept MACs in the Sony OUI range (00:06:F5). Ensure you use a legally unicast, locally administered address if outside that scope.
  • Future ESP-IDF versions may rename esp_iface_mac_addr_set() again; always check release notes.
  • Downgrading the core locks you out of security fixes (e.g., CVE-2023-45866 Bluetooth attacks).

Suggestions for further research

  • Track PR #180 (or equivalent) in PS3_Controller_Host fork that migrates to IDF v5.
  • Study Espressif’s “MAC Address Management” chapter in ESP-IDF programming guide.
  • Evaluate alternative HID host stacks like NimBLE HID or esp_hidh for PS4/PS5 controller support.
  • Investigate ESP-IDF “BT classic host” examples that already use the new API.

Brief summary

Your build fails because the PS3 controller library still calls the legacy esp_base_mac_addr_set(), removed from the ESP-IDF version bundled with today’s Arduino-ESP32 boards.
Either (A) modernise the library with the new per-interface MAC APIs (esp_read_mac(), esp_iface_mac_addr_set()), or (B) roll back to Arduino-ESP32 1.0.6 / ESP-IDF 3.3. Updating the library is strongly recommended for long-term maintenance and security.

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.