Skip to content

Commit 697fd0d

Browse files
committed
feat(eth): Allow setting the RX task stack size
Default stack size of 2K might not be enough in some cases. Increase the default to safer 4K and allow setting it to custom value.
1 parent 4e3523c commit 697fd0d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Diff for: libraries/Ethernet/src/ETH.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ ETHClass::ETHClass(uint8_t eth_index)
130130
,
131131
_pin_mcd(-1), _pin_mdio(-1), _pin_power(-1), _pin_rmii_clock(-1)
132132
#endif /* CONFIG_ETH_USE_ESP32_EMAC */
133+
,
134+
_task_stack_size(4096)
133135
{
134136
}
135137

@@ -141,6 +143,10 @@ bool ETHClass::ethDetachBus(void *bus_pointer) {
141143
return true;
142144
}
143145

146+
void ETHClass::setTaskStackSize(size_t size) {
147+
_task_stack_size = size;
148+
}
149+
144150
#if CONFIG_ETH_USE_ESP32_EMAC
145151
bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, int power, eth_clock_mode_t clock_mode) {
146152
esp_err_t ret = ESP_OK;
@@ -214,6 +220,7 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i
214220

215221
eth_mac_config_t eth_mac_config = ETH_MAC_DEFAULT_CONFIG();
216222
eth_mac_config.sw_reset_timeout_ms = 1000;
223+
eth_mac_config.rx_task_stack_size = _task_stack_size;
217224

218225
esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&mac_config, &eth_mac_config);
219226
if (mac == NULL) {
@@ -578,6 +585,9 @@ bool ETHClass::beginSPI(
578585
__unused eth_mac_config_t eth_mac_config = ETH_MAC_DEFAULT_CONFIG();
579586
__unused eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
580587

588+
// Set RX Task Stack Size
589+
eth_mac_config.rx_task_stack_size = _task_stack_size;
590+
581591
// Update PHY config based on board specific configuration
582592
phy_config.phy_addr = phy_addr;
583593
phy_config.reset_gpio_num = _pin_rst;

Diff for: libraries/Ethernet/src/ETH.h

+4
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ class ETHClass : public NetworkInterface {
153153

154154
void end();
155155

156+
// This function must be called before `begin()`
157+
void setTaskStackSize(size_t size);
158+
156159
// ETH Handle APIs
157160
bool fullDuplex() const;
158161
uint8_t linkSpeed() const;
@@ -203,6 +206,7 @@ class ETHClass : public NetworkInterface {
203206
int8_t _pin_power;
204207
int8_t _pin_rmii_clock;
205208
#endif /* CONFIG_ETH_USE_ESP32_EMAC */
209+
size_t _task_stack_size;
206210

207211
static bool ethDetachBus(void *bus_pointer);
208212
bool beginSPI(

0 commit comments

Comments
 (0)