Can I run non freeRTOS code on one core

tangray
Posts: 6
Joined: Tue Aug 15, 2017 7:37 am

Can I run non freeRTOS code on one core

Postby tangray » Tue Aug 15, 2017 8:19 am

I have seen in the examples how to activate single or dual core mode with Free RTOS and how to assign tasks to cores. What I would like to know is it possible to assign one core to running FreeRTOS tasks and then to use the other other core for running C CODE with no freeRTOS depencies just as its own code block, ie its own main() without uses freeRTOS tasks.

How would the code be structured in order to do this? how would the startup code in main look like? Does the standard tool chain and booloader support this. could you post a small example please.

best regards
Nick

User avatar
iot-bits.com
Posts: 25
Joined: Wed Dec 21, 2016 6:14 am
Location: India
Contact:

Re: Can I run non freeRTOS code on one core

Postby iot-bits.com » Tue Aug 15, 2017 3:48 pm

I guess you could simply have a high priority task running only on that core, with your program. Stack size will be the only issue.
I tried to do what you have been trying but it does not seem possible without too much pain.
- Pratik
:geek: Just another hobbyist and consultant

tangray
Posts: 6
Joined: Tue Aug 15, 2017 7:37 am

Re: Can I run non freeRTOS code on one core

Postby tangray » Fri Aug 18, 2017 4:21 am

Thanks for your idea. There are several other reasons why I dont want to run inside a task.
I want to run my own hard real time RTOS that uses a 1 ms tick and provides its own event driven scheduling and declaratory FSM.
Then I intend to access WIFI and other platform resources running on the other CORE.
So far I have put a while(1) loop in app-main, which prevents it from returning and I have connected this to Timer 01 and its native ISR. In this mode I still have access to FreeRTOS resources, which makes me think that app-main is actually implemented as a task, which normally runs once.
If I can pick up char input events in this mode for my command line I will be able to progress until I come to stack limitations.
Any comments welcome..

ESP_Sprite
Posts: 9761
Joined: Thu Nov 26, 2015 4:08 am

Re: Can I run non freeRTOS code on one core

Postby ESP_Sprite » Sat Aug 19, 2017 4:00 am

In the current setup, unfortunately having your own code running on Core1 exclusively is sort-of hard: there are some things where the hardware requires cooperation between the two CPUs. From memory, one of those things is writing to flash (which disables the flash cache, which can make the program on CPU1 suddenly 'not exist' anymore unless it has jumped to a 'safe' routine in IRAM first) and the DPORT/APB interaction bug comes to mind. I would very much suggest running your OS as a task on CPU1; if needed, you can disable the tick interrupt on that CPU in order to essentially kill the FreeRTOS non-preemptive scheduling but still have the logic in place to do pre-emptive scheduling so SPI flash writing etc will still work. The amount of stack you have is settable in the xTaskCreatePinnedToCore() call you use to set up that , if you need to modify it.

You are right about app_main being a task, by the way. It's started in esp32/cpu_start.c; if you really want to have a go at messing with FreeRTOS-less cores, you can possibly override start_cpu1() there to implement your own code.

tangray
Posts: 6
Joined: Tue Aug 15, 2017 7:37 am

Re: Can I run non freeRTOS code on one core

Postby tangray » Sat Aug 19, 2017 8:58 am

Thanks for your answer. I understand. I will in fact carry on running inside freeRTOs as you say but just run my own timer interrupt. I will at some point want to access queues to communication tasks running on the other core to send and receive messages so I want as much as possible of the free RTOS logic to remain in place. In fact I can port my platform as a soft rtos inside a task until I have tested all the functionality and maybe later what I want to do will be easier or in fact I will just not need to do it.

I have been sidetracked to see if I can get the espressif IDF running inside the Arduino IDE. I have been able to compile my timer example but I had some problems with casting IDF parameters (UGGGH!) but the runtime timer structures in the driver are not getting initialised so it doesnt run unless I define a static timer structure pointing to nothing but then there are no interrupts of course.

So I have given up on this approach as I dont understand and I dont really want to understand the Arduino API. I want use the Espressif IDF as it seems to be be the best documented and probably the most understandable and straightforward platform code. I have already seen that I can easily add interrupt sources without corrupting the Free RTOS environment. I would just like a slightly more productive environment than mingw32 make....

Any comments that may help me in using the Espressif IDF in and IDE are welcome....

ESP_Sprite
Posts: 9761
Joined: Thu Nov 26, 2015 4:08 am

Re: Can I run non freeRTOS code on one core

Postby ESP_Sprite » Sun Aug 20, 2017 4:13 am

I personally have no issues using make... but if you want a more high-level IDE, maybe Eclipse can work for you? http://esp-idf.readthedocs.io/en/latest ... ndows.html

tangray
Posts: 6
Joined: Tue Aug 15, 2017 7:37 am

Re: Can I run non freeRTOS code on one core

Postby tangray » Sun Aug 20, 2017 6:01 am

Well after 30 years of never quite being a unix man I am not at home with make. But I have discovered the existing espressif make files support a hierachical project so I am now happy enough working with this and my favorite editor. I would like to know eventually how to spawn a make operation inside msys from a windows task, but thats a rather small issue. Thanks for the discussion.

Who is online

Users browsing this forum: No registered users and 73 guests