FreeRTOS SMP on 2 elf project


I’m working on a project that uses the FreeRTOS SMP, the project if using NXP MPC5777C which has two cores, right now i’m using a single project for each core so my question is can we still use SMP even though we have two elf files?

At present there are no SMP ports for the Power z7 cores. If you want to use SMP you will need to create the port. Of course we would be happy accepting a PR with a new SMP port.

You are using AMP (asymmetric multiprocessing) and treating each core as an independent FreeRTOS system. This is an effective strategy and can be a little more deterministic than SMP due to the independent schedulers. Coordinating activities on the two cores is a little more difficult than an SMP system. You can roll your own coordination using hardware features (interrupts or spinlocks) between the cores or you can use the FreeRTOS Message Buffers which were specifically designed to simplify multi-core communication.

Good Luck

So the conclusion here is that: yes it is possible to have FreeRtos SMP for a 2 elf system but i have to figure out the multicore communication strategy

Yes, you can use FreeRTOS in a 2 elf system and FreeRTOS supports communications between the cores via message buffers.

If you have 2 ELF, it will NOT be SMP but AMP as @jjulich explained. The following is the definition of SMP from this page:

SMP support in the FreeRTOS Kernel enables one instance of the FreeRTOS kernel to schedule tasks across multiple identical processor cores. The core architectures must be identical and share the same memory.

Yeah but my cores architecture is identical and share the same memory, even though they are 2 elf, isn’t that still count as an SMP?

Can you elaborate what you mean by 2 ELFs? My understanding is that you are creating 2 separate binaries (possibly by compiling 2 different projects) each of which run on a core. If that is right, you have 2 instances of FreeRTOS, each running on a core. This is not SMP - SMP means only one instance of FreeRTOS which schedules tasks across multiple cores.

Having said that, I am not suggesting that SMP is what you need as I do not know the problem you are trying to solve. Depending on that, 2 ELFs may be the right solution for you. If you describe the problem you are trying to solve, we can probably assist you better.

yes two elf file is exactly as you describe it, our intention is to have one instance of FreeRTOS (one scheduler) on core 0, which can run on shared memory and it will take care of assigning tasks to either core, by using an interrupt so that each time the core0 wants to schedule some task on core1 it triggers an interrupt on it and core1 has to stop what it is doing and go to the ISR function which takes the core1 to the switch context function.

And since you mentioned that it is not necessary to use AMP for only Asymmetrical architecture? it can also be used in Symetrical Architecture like the one we are trying to use, right?

Also i place below the memory map of the MPC5777C, both cores they share the same memory but each one occupies a known area

How can you have 2 ELFs if you want one instance of FreeRTOS to schedule tasks on both cores? In the case of 2 ELFs, each core will run its own instance of FreeRTOS and each core will only run tasks contained in the respective binary.

You described your solution and not the problem? Can you describe the problem you want to solve instead?


i guess i kind of understand now.

the problem is that we want to be able to schedule tasks on both cores using one instance of scheduler but i guess that is not the way it should be (if we want to use SMP it should be a single project), so the conclusion i understand is that since we have 2 separate projects we can use AMP instead with for example Message buffers so that both cores can have communications.

My confusion was that understood that AMP is only designed for Asymmetrical processors and cannot be use for Symmetrical ones but now on know that it can be used also for the later ones.

i still have one question: the tasks.c in AMP can be the same as SMP right?

Yes, that is right. Make sure to set configNUMBER_OF_CORES to 1 in FreeRTOSConfig.h or leave it undefined.

I was trying now to do an AMP implementation and it works but my problem is that i want to use the MessageBuffers but something strange happened:
whenever i create the actual buffer the tasks will stop working (not always at runtime always but while debugging sometimes) it’s like they go to suspended state or something like that the moment i comment that line (message buffer creation) the tasks work again fine.
the context is that now i have a single task on each core, both of them will toggle an LED then for the task on core0 it will write to the message buffer while the tasks on core1 will read from it and the buffer is created in core0 before the creation of the task as seen below

xControlMessageBuffer = xMessageBufferCreateStatic(sizeof(ucMessageBufferStorage), ucMessageBufferStorage, &xMessageBufferStruct);

xHandle_0 = xTaskCreateStatic(vTaskLed, (const char *const) "TaskLed",
                              configSTATIC_STACK_DEPTH(ledSTACK), (void *) apCtx,
                              TASK_PRIORITY, ledSTACK, &ledTASK);

Read this blog post and see if it helps - Simple Multicore Core to Core Communication Using FreeRTOS Message Buffers - FreeRTOS.