Skip to content

Commit 0adf787

Browse files
feat(eth): Allow setting the RX task stack size (espressif#10003)
* 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. * ci(pre-commit): Apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 60b6faa commit 0adf787

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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

+10-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +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-
{
133+
,
134+
_task_stack_size(4096) {
134135
}
135136

136137
ETHClass::~ETHClass() {}
@@ -141,6 +142,10 @@ bool ETHClass::ethDetachBus(void *bus_pointer) {
141142
return true;
142143
}
143144

145+
void ETHClass::setTaskStackSize(size_t size) {
146+
_task_stack_size = size;
147+
}
148+
144149
#if CONFIG_ETH_USE_ESP32_EMAC
145150
bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, int power, eth_clock_mode_t clock_mode) {
146151
esp_err_t ret = ESP_OK;
@@ -214,6 +219,7 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i
214219

215220
eth_mac_config_t eth_mac_config = ETH_MAC_DEFAULT_CONFIG();
216221
eth_mac_config.sw_reset_timeout_ms = 1000;
222+
eth_mac_config.rx_task_stack_size = _task_stack_size;
217223

218224
esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&mac_config, &eth_mac_config);
219225
if (mac == NULL) {
@@ -578,6 +584,9 @@ bool ETHClass::beginSPI(
578584
__unused eth_mac_config_t eth_mac_config = ETH_MAC_DEFAULT_CONFIG();
579585
__unused eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
580586

587+
// Set RX Task Stack Size
588+
eth_mac_config.rx_task_stack_size = _task_stack_size;
589+
581590
// Update PHY config based on board specific configuration
582591
phy_config.phy_addr = phy_addr;
583592
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)