Why is Arduino's main task pinned to core 1?

MartyMacGyver
Posts: 56
Joined: Sun Dec 18, 2016 9:17 pm

Why is Arduino's main task pinned to core 1?

Postby MartyMacGyver » Sat Feb 11, 2017 2:29 am

I'm working on porting an RMT-driven NeoPixel/WS2812 driver to Arduino-ESP32 and in doing so I noticed that the main task is pinned to core 1:

Code: Select all

xTaskCreatePinnedToCore(loopTask, "loopTask", 4096, NULL, 1, NULL, 1);
Why is that? I've run with core 0 and no core at all (just xTaskCreate) and my sketches still work fine, insofar as it works at all. However, on the default pinned core 1 my port is not working and as I'm debugging that this came up. Thoughts?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Why is Arduino's main task pinned to core 1?

Postby WiFive » Sat Feb 11, 2017 3:39 am

System tasks are pinned to core 0 so user tasks are pinned to core 1 in general. It doesn't have to be but is a straightforward way to try and distribute the load between the CPUs.

Also: https://github.com/espressif/esp-idf/bl ... ore-issues

You may want to check the interrupts are not hardcoded to cpu0 in the code you are porting.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Why is Arduino's main task pinned to core 1?

Postby WiFive » Sat Feb 11, 2017 5:28 am

Looks like they are in fact hardcoded

https://github.com/MartyMacGyver/ESP32- ... 812.c#L149

Code: Select all

intr_matrix_set(0, ETS_RMT_INTR_SOURCE, ETS_RMT_CTRL_INUM);
Try

Code: Select all

intr_matrix_set(xPortGetCoreID(), ETS_RMT_INTR_SOURCE, ETS_RMT_CTRL_INUM);
Although you may want to switch to the new interrupt allocator too.

MartyMacGyver
Posts: 56
Joined: Sun Dec 18, 2016 9:17 pm

Re: Why is Arduino's main task pinned to core 1?

Postby MartyMacGyver » Sat Feb 11, 2017 8:43 am

You found the repo - and your fix worked! The update is pushed... I've got lots to do but getting this to work with the Arduino-ESP32 will hopefully be of benefit to those who wanted to see this working.

I really appreciate your help - I still need to learn more about how everything operates at this level. Tell me more of this new interrupt allocator... at least, what to keyword search on. (Or is it simply what was linked to above?)

Thank you again!

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Why is Arduino's main task pinned to core 1?

Postby WiFive » Sat Feb 11, 2017 9:06 am

Yes it is described in that same link.

MartyMacGyver
Posts: 56
Joined: Sun Dec 18, 2016 9:17 pm

Re: Why is Arduino's main task pinned to core 1?

Postby MartyMacGyver » Wed Feb 15, 2017 1:29 pm

Along with several other updates, I'm now using the new interrupt allocator. Thanks again for the tip!

electronicsguy
Posts: 18
Joined: Tue Jan 12, 2016 4:12 pm
Location: Pune, India
Contact:

Re: Why is Arduino's main task pinned to core 1?

Postby electronicsguy » Mon May 29, 2017 8:04 am

MartyMacGyver wrote:Along with several other updates, I'm now using the new interrupt allocator. Thanks again for the tip!
could you share your code describing how?

Also please update the links, they're broken.

MartyMacGyver
Posts: 56
Joined: Sun Dec 18, 2016 9:17 pm

Re: Why is Arduino's main task pinned to core 1?

Postby MartyMacGyver » Mon May 29, 2017 8:41 am

This is the driver I ported and extended:

https://github.com/MartyMacGyver/ESP32- ... ED-Drivers

As for the interrupt allocator info, a search shows it moved here:

https://github.com/espressif/esp-idf/bl ... _alloc.rst

classical
Posts: 1
Joined: Mon Oct 30, 2017 8:30 am

Re: Why is Arduino's main task pinned to core 1?

Postby classical » Mon Oct 30, 2017 8:36 am

The WiFi client is handled to be a part of the user program.
So the user program and the WiFi are running on the same core1.
If you have time critical operations like input countings running on application you get an interference with the wifi.
Is it possible in the arduino world to shift the wifi ont core0 so that you can do time critical actions on core1 without interference with wifi?

Who is online

Users browsing this forum: No registered users and 52 guests