Pin Ethernet related tasks to core 1 [IDFGH-3383]

maximekli
Posts: 8
Joined: Thu May 14, 2020 12:29 pm

Pin Ethernet related tasks to core 1 [IDFGH-3383]

Postby maximekli » Wed May 20, 2020 9:58 am

Hello,

I am currently working on a project where an ESP32 based board needs to communicate with a computer via Ethernet.
Is there any way to pin all Ethernet related tasks to core 1, as for the Wi-Fi task in menuconfig ?
I should specify that I am using the driver in standalone mode (without TCP/IP stack).

Thanks in advance,

Maxime

maximekli
Posts: 8
Joined: Thu May 14, 2020 12:29 pm

Re: Pin Ethernet related tasks to core 1

Postby maximekli » Mon May 25, 2020 9:36 am

The reaction to a incoming packet needs to be as fast as possible, that's why being able to pin that to one core would be very helpful.

Any insight on this ?

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Re: Pin Ethernet related tasks to core 1

Postby PeterR » Mon May 25, 2020 9:54 pm

Tasks are core mobile unless told not to be. Interrupts are tied to the creating core.
main is core 0 so launch a task pinned to core 1 and from that task initialise ethernet resolves interrupts.
You did not say which Ethernet tasks you want pinned. HTTP, mDNS, DNS etc?
Gets to be a bit of a system question & so I will ask; why do you think that pinning to core 1 will help & expecially as other system tasks may float into core 1. Would not a priority system be better?
Also re: 'fast as possible' - would be better for you to state your time constraint. OOM I can tell you if it could fly. You have after all achieved your own 'fast as possible' ;)
EDIT: I would add that you're Ethernet protocol & its setup matter a load. Its wrong to ask for solution without requirement but were you thinking UDP, TCP or higher e.g. HTTP? There are just so many performance issues relating so I will wait for your requirement.
& I also believe that IDF CAN should be fixed.

maximekli
Posts: 8
Joined: Thu May 14, 2020 12:29 pm

Re: Pin Ethernet related tasks to core 1

Postby maximekli » Wed May 27, 2020 9:42 am

Hi !

Thank you for your answer.

The board I'm working on is used in a legged robot as a bridge between a control computer using Ethernet and a set of sensors and actuators using SPI. The control loop is working at 1kHz.

Then, we need the Ethernet communication, and especially the receiving callback, to happen in a negligeable amount of time against the 1ms period (10 to 100µs).

As most of the loop time is used for SPI communication, we can't really afford any extra latency coming from the Ethernet data transfer between our ESP board and the computer. That's why we want to make these tasks independant by having SPI on core 0 and Ethernet on core 1.

Also, we are using raw ethernet frames at MAC level, so no TCP/IP layer or anything.

The project : https://open-dynamic-robot-initiative.github.io/
The ESP32 firmware : https://github.com/maximekli/master-boa ... r/firmware

Thank you for your time,

Maxime

ESP_morris
Posts: 290
Joined: Wed Sep 05, 2018 6:23 am

Re: Pin Ethernet related tasks to core 1

Postby ESP_morris » Wed May 27, 2020 10:15 am

Fantastic project @maximekli

Ethernet driver does have a dedicated task to doing packets receiving stuffs. Unfortunately, there's no way to pin that task to a specific core for now. But it's easy to add that support in esp-idf and won't break any API. I think it's reasonable to have such an option. Will do it!

By now, you can hack esp-idf code a little to pin the task to the core you want: https://github.com/espressif/esp-idf/bl ... p32.c#L458

ESP_Alvin
Posts: 211
Joined: Thu May 17, 2018 2:26 am

Re: Pin Ethernet related tasks to core 1 [IDFGH-3383]

Postby ESP_Alvin » Wed May 27, 2020 11:20 am

Moderator's note: edit the topic title for issue tracking, thanks.

maximekli
Posts: 8
Joined: Thu May 14, 2020 12:29 pm

Re: Pin Ethernet related tasks to core 1

Postby maximekli » Thu May 28, 2020 10:32 am

Thank you for your answer, that would be great !

ESP_morris wrote:
Wed May 27, 2020 10:15 am
By now, you can hack esp-idf code a little to pin the task to the core you want: https://github.com/espressif/esp-idf/bl ... p32.c#L458
This litlle hack worked perfectly, thanks.

Maxime

Who is online

Users browsing this forum: dg9ngf and 105 guests