Can you please help me clarifying a point you are willing to use freertos to allocate memory in a dynamic way like in the following post?
Or you are just looking to have an specific link file for the application?
I'll try to clarify further (although I think I explained it well enough in my previous post)
I have my own FW, but I have to provide the user with the ability to write, compile, and run its plugins.
What does this mean? The user should not be forced to compile the entire FW by adding its algorithms into the complete set of source files. Conversely, it should be possible to add user algorithms at runtime (the user will be provided with some kind of SDK).
My development stack includes:
- gcc-arm-none-eabi toolchain: The toolchain used to compile the FW, and presumably to be used to compile the plugin as well, unless ways are found with which to compile with other toolchains (such as: llvm clang, rust, etc.).
- FreeRTOS: The FW uses FreeRTOS, and the plugin will have to be allowed to use the APIs that FreeROTS provides, such as: task creation, task synchronization, semaphores, mutexes, dynamic memory, etc.
- LittleFS: The board has flash memory that will be used as mass storage, and it will be used to store plugins file to load.
Of course, the whole feature must also include the dynamic linker/loader (which will be contained in the FW).
Searching the Internet, I found a couple of projects:
- Linkable Loadable Extensions (LLEXT) in Zephyr OS (https://docs.zephyrproject.org/latest/services/llext/index.html Unfortunately, I am forced to use FreeRTOS, so I cannot use this solution. Besides, it's still experimental and not yet stable or even released
- Udynlink (https://github.com/bogdanm/udynlink the project is a bit old, and of "pre-alpha" quality. Other than that it seems very rigid and insufficiently flexible regarding the compilation process.
There are a number of forks that I should study better.
so I repeat and argue the most important and urgent points that I need to know/understand:
- Plugin File Format and Loading: In considering the implementation of a dynamic linker/loader for plugin functionality, I am prioritizing a file format that allows for introspection to properly load the necessary memories (both instructions and data). I aim to adopt a simple yet standard format, preferably one that's already been used in similar contexts, to avoid reinventing existing solutions. What file format and loading strategy would you recommend that aligns with these requirements?
- Function Entry Points Management: In my plugin implementation scenario, unlike typical cases where plugins solely provide functionalities to the host, my plugins will also need to utilize APIs offered by the firmware. I've deduced that the plugins should have two function pointer tables: one for the functions they provide and another for the functions they use from the firmware. Hence, I believe the linker/loader should populate this second table. Additionally, the firmware must be designed to retrieve function pointers at runtime for invoking functions provided by the plugin. How can I effectively manage these function entry points and ensure seamless interaction between the firmware and the plugins?
- Compilation and Linking Requirements: In light of the requirement for dual function pointer tables in my plugins (one for functions they provide and another for functions they use from the firmware) I am seeking guidance on the compilation process. I anticipate needing to use flags like -fPIC or -fPIE and link with options like --unresolved-symbols=ignore-in-object-files and --emit-relocs. However, I would like to know what additional parameters are necessary. Specifically, are the standard compiler and linker sufficient to 'create' these tables, or is there a need for any post-build steps? Should I anticipate the need to utilize existing tools or develop custom solutions for this purpose?
In addition to understanding the compilation process for the plugins, I also need guidance on how to modify the compilation of my firmware. Specifically, how should I adjust the firmware's compilation process to enable or facilitate the retrieval of function pointers that the plugins require? Is there a particular approach or modification necessary to ensure smooth interaction between the firmware and the plugins, especially in the context of function pointer handling?
I hope this will be enough to clarify the use case and what I'm looking for
regards
Max