ETH + BLE for WT32-ETH01

Guys, I found out that BLEDevice::init() will crash with ETH.begin(). If I call them separately, both works well. But whenever I try to use both ethernet and BLE, that 2 functions will keep on reset my board.

Does anyone met the same issue previously? To reproduce the issue, try the code below:

#include <ETH.h>
#include <WiFi.h>

#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>

/* 
   * ETH_CLOCK_GPIO0_IN   - default: external clock from crystal oscillator
   * ETH_CLOCK_GPIO0_OUT  - 50MHz clock from internal APLL output on GPIO0 - possibly an inverter is needed for LAN8720
   * ETH_CLOCK_GPIO16_OUT - 50MHz clock from internal APLL output on GPIO16 - possibly an inverter is needed for LAN8720
   * ETH_CLOCK_GPIO17_OUT - 50MHz clock from internal APLL inverted output on GPIO17 - tested with LAN8720
*/
#define ETH_CLK_MODE    ETH_CLOCK_GPIO17_OUT

// Pin# of the enable signal for the external crystal oscillator (-1 to disable for internal APLL source)
#define ETH_POWER_PIN   16  // GPIO16, HS1_DATA4, U2RXD, EMAC_CLK_OUT

// Type of the Ethernet PHY (LAN8720 or TLK110)
#define ETH_TYPE        ETH_PHY_LAN8720

// I²C-address of Ethernet PHY (0 or 1 for LAN8720, 31 for TLK110)
#define ETH_ADDR        1

// Pin# of the I²C clock signal for the Ethernet PHY
#define ETH_MDC_PIN     23  // GPIO23, VSPID, HS1_STROBE

// Pin# of the I²C IO signal for the Ethernet PHY
#define ETH_MDIO_PIN    18  // GPIO18, VSPICLK, HS1_DATA7

void setup()
{
   Serial.begin(115200);

   // Create and name the BLE Device
   BLEDevice::init("DEVICE_NAME");
   
   Serial.println("DEBUG_1"); // DEBUG
   
   ETH.begin(ETH_ADDR, ETH_POWER_PIN, ETH_MDC_PIN, ETH_MDIO_PIN, ETH_TYPE, ETH_CLK_MODE);

   Serial.println("DEBUG_2"); // DEBUG
}
void loop()
{}

We will see the board keep getting reset, but if we comment out the ETH.begin(), it will work.

After some trial and error, I found out that memory overflow might occurs within two basic function tcpipInit() within ETH.begin() and esp_bluedroid_init() within BLEDevice::init()

The tcpipInit() function contains _start_network_event_task() functions, there is one line of code that might be the root cause:

xTaskCreateUniversal(_arduino_event_task, "arduino_events", 4096, NULL, ESP_TASKD_EVENT_PRIO - 1, &_arduino_event_task_handle, ARDUINO_EVENT_RUNNING_CORE);

On the other hand, there is a line of codexTaskCreatePinnedToCore(btc_task, "Btc_task", BTC_TASK_STACK_SIZE, NULL, BTC_TASK_PRIO, &xBtcTaskHandle, 0); which can be found within btc_init() under esp_bluedroid_init()

The BTC_TASK_STACK_SIZE can be found defined as 2048 according to esp-idf-2.0 ‎ tools/unit-test-app/sdkconfig

As we can see above, they both used around 6144 of total stack size. Just curious if they really need that much stack size?

Ok, for those who met the same issue, here is the solution:
Open the "tools" on top of our Arduino IDE
Tools > Partition Scheme > Huge APP.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.