Pyhton on Free RTOS

Hello there!

I’m studying Aerospace Technology and I’m going to start my final thesis soon. My topic is the coding of a program that will gather data from an experiment on a satellite.
My supervisor plans to use an onboard computer (OBC) that runs Free RTOS and is supposed to communicate with the computer of the satellite.
My assignment is to enable the OBC to run Python code (as I am way more familiar with Python than with C) and to write the actual code that deals with gathering and processing all the neccessary data coming from the experiment.
However, as I am completely new to anything concerning microcontrollers and/or operating systems, I don’t really know where to start. I’ve tried to read up on the topic with the “Hands on tutorial guide” but I don’t understand much. I then watched a video series on Youtube and I learned a few things but I still feel like I’m far away from any sort of breakthrough and that the whole topic might be too much for me to know about in the context of a final thesis. Especially since I feel like I don’t really need to know the ins and outs of an embedded system but rather only how to get Python running.
So, having said all that, I guess my main question is: is there any way to have Python run on Free RTOS and if so, how can I achieve this?

Thanks in advance for any reply!

Hi @Viktor,

This is not my area of expertise at all to be honest, but I would start here…

I hope that helps…

Kind Regards,

Pete

I think that application sits at the bare metal layer, so doesn’t give ‘room’ for FreeRTOS beside it (but maybe there would be a way to make it work)

Another resource (perhaps combined with the above) would be: https://docs.python.org/3/extending/embedding.html

Which talks about adding python as in interpreter to an existing program, which is more what you seem to want (but likely you would want that stripped down MicroPython to help it fit)

I would probably look at setting up a task to run the Python interpreter, and have ONLY that task talk to Python. That task could use the various FreeRTOS tools to talk to other tasks, but unless you REALLY understand how Python multi-tasks, I would avoid making it do so.

Hi @Viktor ,

I have also noticed via another forum I am involved with, there is already a project built which implements micro-python on FreeRTOS for the ESP32 MCUs… I have no idea which MCU you are aiming for, but this might be of use to you.

https://docs.micropython.org/en/latest/esp32/general.html

Kind Regards,

Pete.

Thank you, @pete-pjb and @richard-damon for your answers, they look promising.
I’ve decided that I need to know more about microcontrollers and computers before I can continue, so I’ve put the implementation of Python on hold for now until I feel like I have a good basis to build onto. However, I feel like I will need to come back here at a later point :smiley:
Until then!

1 Like

I would tell you that the difference between a bare metal super loop and RTOS , is that an RTOS can run multiple tasks simultaneously , its memory efficient and has perfect deadlines!! what features of these do you need in your system/architecture? you can plan and I think most of these features are available in python , for example you could run multiple tasks simultaneous using threading or multiprocessing libraries in python

I would say that the big difference between the super loop and priority tasking is that the super loop needs to have the work divided into work quanta and one quanta will alway run to completion before the next one can start.

With priority tasking you don’t need to divide up the work into the quanta, as the schedule can switch from one task to another as needed, even using dead I/O time from one task to run another. Also if a high priority task comes in, it doesn’t need to wait for the next lower priority quanta to finish so the super loop can recognize the high priority request, but it can just start right away when the request comes in.