Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ethernet emac_main.c stack to small (IDFGH-608) #3025

Closed
ardiehl opened this issue Feb 3, 2019 · 1 comment
Closed

Ethernet emac_main.c stack to small (IDFGH-608) #3025

ardiehl opened this issue Feb 3, 2019 · 1 comment
Assignees

Comments

@ardiehl
Copy link

ardiehl commented Feb 3, 2019

i'm currently on idf 3.1.1 but this problem exists with all previous versions as well. I have a lan8720 connected to the esp32. When the lan board is connected everything works fine. When the lan8720 board is not connected and i try to initialize ethernet, a stack overflow will happen in emacT. Increasing the stacksize in components/ethernet/emac_main.c from 2048 to 3072 solves the problem.

The problem does not happen with the ethernet sample. Within my code, this happens at various places. I have added a ps command to find the free stack of each runnig task. After changing the emac stacksize to 3k i get a free stack space of 600 bytes for the emac task. So there is more needed than the 2k currently in emac_main.c:

evse> ps
task name       cpu  prio  min stack free   run time count
------------------------------------------------------------------
main              0     1           11120           468527   0.03%
IDLE              1     0             528        703788899  46.72%
IDLE              0     0             456        746745074  49.57%
....
emacT           any    20             600          4497798   0.30%

when the board is connected, the needed stacksize is much lower, this is the ps output with 3k emacT stack and a connected lan8720 board

evse> ps
task name       cpu  prio  min stack free   run time count
------------------------------------------------------------------
main              0     1           10928           326231   0.40%
...
emacT           any    20            2328            14452   0.02%

So, in case the board is not connected, the needed stacksize grew by 1728 bytes. Could this be related to the ESP_LOG* routines called to output errors ? (i have set "Default log verbosity" = Warning)

this is the fix in emac_main.c (esp_eth_init_internal)

xTaskCreate(emac_task, "emacT", 3072, NULL, EMAC_TASK_PRIORITY, &emac_task_hdl);
  • Development Kit: ESP32-DevKitC or my own board with ESP32-WROOM-32 + Waveshare LAN8720
  • Module or chip used: ESP32-WROOM-32
  • IDF version 3.1.1 or any previous version
  • Build System: Make
  • Compiler version 5.2.0
  • Operating System: Linux
  • Power Supply: USB or external 5V

sdkconfig.zip

@Alvin1Zhang Alvin1Zhang changed the title Ethernet emac_main.c stack to small [TW#28654] Ethernet emac_main.c stack to small Feb 3, 2019
@suda-morris suda-morris self-assigned this Feb 13, 2019
@suda-morris
Copy link
Collaborator

suda-morris commented Feb 13, 2019

@ardiehl Thanks for your analysis. I will look into it later.
BTW, since IDF v3.2, the stack size has been configurable.

igrr pushed a commit that referenced this issue Feb 28, 2019
1. In original driver, the stack size for emac driver task "emacT" is only 2048 Bytes, which also can not be changed by user.
2. Each time when invoking "emac_start" function, it will reset emac registers, the driver should reconfig some important registers again.

Closes #3025
@projectgus projectgus changed the title [TW#28654] Ethernet emac_main.c stack to small Ethernet emac_main.c stack to small (IDFGH-608) Mar 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants