# Binary partitioning

**URL:** <https://forums.freertos.org/t/binary-partitioning/14609>\
**Category:** Kernel\
**Created:** [March 4, 2022, 4:02pm UTC](https://forums.freertos.org/t/binary-partitioning/14609 "2022-03-04T16:02:20Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![phug](https://avatars.discourse-cdn.com/v4/letter/p/a183cd/32.png) [@phug](https://forums.freertos.org/u/phug)\
**Post date:** [March 4, 2022, 4:02pm UTC](https://forums.freertos.org/t/binary-partitioning/14609/1 "2022-03-04T16:02:20Z")

</div>

Hello, I am new and looking for an RTOS.

Does the FreeRTOS kernel supports execution of multiple binaries on a single uC core under control of the FreeRTOS . I am looking for something similar to a very simplistic time and space segregation solution. Sometimes also called modules or partitions. The main focus is not security. Moreover independent developing, versioning, testing and deployment of separate binaries. I am looking for something that includes the following elements:

The **platform core binary** :

- Contains the RTOS implementation.
- Contains services and all drivers.
- Exports functionality usable by application logic binaries.
- Can be developed, versioned, tested, deployed without compile time or runtime dependency to any application logic binary. This with the exception that during initialization time, the platform core binary detects and starts a present application logic binary. During runtime the platform core binary schedules tasks within the application logic binaries.

A **application logic binary** :

- Contains application logic.
- Has no direct access to peripherals.
- Can be developed, versioned, deployed without access to source code or object code used to create the platform core binary.
- Can use at runtime functionality provided by the platform binary.
- Shall be replaceable within deployment. This includes: Product variant binaries, OEM binaries and end customer created binaries.

The following figure might help what we try to achieve:

 ![application_partitioning](https://d2v6vdsk2p900z.cloudfront.net/original/2X/9/9d6505e698ea553d26f2ead24b44865386b5e682.png)

Any help is welcome

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [March 4, 2022, 5:02pm UTC](https://forums.freertos.org/t/binary-partitioning/14609/2 "2022-03-04T17:02:45Z")

</div>

Not studied your post in detail (time constraint right now) but other than the “has no direct access to peripherals” requirement, from my first read I would say this can be done. It is not the default way of using FreeRTOS though so would require some effort - restricting access to peripherals can be done too but require more effort as that can only be achieved using the memory protection unit. It would be interesting to provide an out of the box way of doing this though.

The reason I say it can be done is because years ago we put an RTOS (actually SafeRTOS) into the ROM of a chip. The application writer didn’t link to the RTOS APIs directly by compiling the source code, but indirectly through a header file that mapped API calls to known addresses in the chip’s ROM. Sort of like a jump table. The mechanism is opaque to the application writer - they still call the API functions as normal, but “linking” (not really linking in the normal sense of the word) was achieved by the preporcessor replacing the API calls with fixed addresses at which the API resided in ROM.

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [March 4, 2022, 7:46pm UTC](https://forums.freertos.org/t/binary-partitioning/14609/3 "2022-03-04T19:46:33Z")

</div>

Here is one way I tried it before - There is one “Loader” which loads various applications (called components afterwards).

 ![image](https://d2v6vdsk2p900z.cloudfront.net/original/2X/f/fde3371548578a88bd476a3a9ee422881ab8ea50.png)

In your description, you want FreeRTOS to be part of loader as well. Each component has an header at the beginning which provides the loader necessary information to load the component:

![image](https://d2v6vdsk2p900z.cloudfront.net/original/2X/a/a078d3c27ede900ec8112e02d5ddcf092593a60d.png)

The way loader discovers various components is that FLASH and RAM are pre-partitioned for each component and therefore, the starting location of each component is fixed. Here is a sample partition:

 ![image](https://d2v6vdsk2p900z.cloudfront.net/original/2X/c/cae0e6d1eeaf6fa71bf2b0433aa1a0965fe3ae5f.png)

The loader is the first image that boots up and then loads all the components. The way you enable communication between components is by adding one indirection. The loader maintains a list of all the functions exported by each component. The loader has a function `GetProcAddress` which always resides at a fixed address and therefore, any component can all it. When a component wants to call a function exported by another component, it calls `GetProcAddress` to get the address of that function and then calls the function using the obtained address.

 ![image](https://d2v6vdsk2p900z.cloudfront.net/original/2X/f/fb1c80eb199b4e50136834d6a7c373f77fb9098e.png)

There is a agreed upon list of function ids among all components which is used to identify functions in `GetProcAddress`.

Does this sound like something you are looking for?

Thanks.

---

<div class="post-metadata">

**Author:** ![phug](https://avatars.discourse-cdn.com/v4/letter/p/a183cd/32.png) [@phug](https://forums.freertos.org/u/phug)\
**Post date:** [March 6, 2022, 1:06pm UTC](https://forums.freertos.org/t/binary-partitioning/14609/4 "2022-03-06T13:06:19Z")

</div>

Thank you. I think such an approach would work.

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [March 7, 2022, 3:48am UTC](https://forums.freertos.org/t/binary-partitioning/14609/5 "2022-03-07T03:48:11Z")

</div>

DM me your email and I can share some code that I wrote before for this approach.

---

<div class="post-metadata">

**Author:** ![phug](https://avatars.discourse-cdn.com/v4/letter/p/a183cd/32.png) [@phug](https://forums.freertos.org/u/phug)\
**Post date:** [March 7, 2022, 4:45pm UTC](https://forums.freertos.org/t/binary-partitioning/14609/6 "2022-03-07T16:45:15Z")

</div>

How can I post you my mail address directly?

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [March 8, 2022, 12:25am UTC](https://forums.freertos.org/t/binary-partitioning/14609/7 "2022-03-08T00:25:06Z")

</div>

I think you can click on the “aggarg” between Gaurav’s name and icon, then select “message”.

---

<div class="post-metadata">

**Author:** ![embynow](https://avatars.discourse-cdn.com/v4/letter/e/ee7513/32.png) [@embynow](https://forums.freertos.org/u/embynow)\
**Post date:** [May 2, 2023, 9:58am UTC](https://forums.freertos.org/t/binary-partitioning/14609/8 "2023-05-02T09:58:15Z")

</div>

Dear Guarav, you haven’t mention about “bsp section” in this scenario. Could you please explain its role some more in this issue, please…

Regards…

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [May 2, 2023, 10:49am UTC](https://forums.freertos.org/t/binary-partitioning/14609/9 "2023-05-02T10:49:53Z")

</div>

BSP stands for “Board Support Package” and you can think of like any other components which happens to contain all the drivers.

---

<div class="post-metadata">

**Author:** ![embynow](https://avatars.discourse-cdn.com/v4/letter/e/ee7513/32.png) [@embynow](https://forums.freertos.org/u/embynow)\
**Post date:** [May 2, 2023, 11:39am UTC](https://forums.freertos.org/t/binary-partitioning/14609/10 "2023-05-02T11:39:34Z")

</div>

could you please share some codes with me as well sir?

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [May 2, 2023, 2:11pm UTC](https://forums.freertos.org/t/binary-partitioning/14609/11 "2023-05-02T14:11:03Z")

</div>

This was an experiment that I did way before. Will try to see if I can find code and share.

---

<div class="post-metadata">

**Author:** ![DriesVR](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@DriesVR](https://forums.freertos.org/u/DriesVR)\
**Post date:** [February 29, 2024, 6:27pm UTC](https://forums.freertos.org/t/binary-partitioning/14609/12 "2024-02-29T18:27:28Z")

</div>

Dear Gaurav,

Did you find that code? I am very interested in that as well. Best regards!

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [March 3, 2024, 6:37pm UTC](https://forums.freertos.org/t/binary-partitioning/14609/13 "2024-03-03T18:37:41Z")

</div>

Here is the code - [DynLoad.zip](https://forums.freertos.org/uploads/short-url/AhWZqRoepwRSXHXwpu6TtqValBe.zip) (2.8 MB)

NOTE that it is an experiment that I did few years back.
