Enabling core 0 in mycropython 1.12 on ESP32

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
Rajendra Waghmare
Posts: 8
Joined: Mon Feb 18, 2019 12:30 pm

Enabling core 0 in mycropython 1.12 on ESP32

Post by Rajendra Waghmare » Thu Jan 09, 2020 10:31 am

Hello there,

I am developing an application where I have multiple threads. I want to distribute these threads on 2 CPU cores of ESP32.
To achieve this I am trying to use multicore functionality. I have downloaded micropython v1.12 and compiled with esp-idf V3.3.
As I can see in the code I can use core 1 as mentioned in - micropython-1.12\ports\esp32\main.c, function app_main, line 188

Code: Select all

xTaskCreatePinnedToCore(mp_task, "mp_task", MP_TASK_STACK_LEN, NULL, MP_TASK_PRIORITY, &mp_main_task_handle, MP_TASK_COREID);
// where MP_TASK_COREID = 1
Is there any way to use core 0 for micropython. I tried to change MP_TASK_COREID to 0, the application got compiled but my python threads did not start at all. Is there any additional settings required?

Here is my python code:

Code: Select all

from utime import sleep_ms, sleep, time
import _thread

def test0(p1,p2):
    print("This is test 0 ")
    count = 0
    while True:
        print("test0", count)
        count+=1
        sleep(1)

def test1(p1,p2):
    print("This is test 1 ")
    cnt = 0
    while True:
        sleep(2)
        print("test1", cnt)
        cnt+=1


_thread.stack_size(40*1024)
_thread.start_new_thread(test0, (1, 0))
print()
_thread.start_new_thread(test1, (1, 1))

print("Threads started...")

Thanks,
-Rajendra

User avatar
jimmo
Posts: 1465
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Enabling core 0 in mycropython 1.12 on ESP32

Post by jimmo » Thu Jan 09, 2020 12:47 pm

I think the relevant history about dual-core on ESP32 is mostly contained in this github issue: https://github.com/micropython/micropython/issues/4895

Post Reply