build ROM library
I'm planning to build a couple of libraries that will reside in ROM, and call them from a Zephyr application.
The nature of these libraries is that I don't have control of their source code and their APIs, so calling them
indirectly using a function pointers table is not a route I'd like to go.
The ROM code could be some standard compression library, or maybe portions of commonly used libc functions, and it will not make calls to external code, like OS or other libraries.
The questions are:
1. Can I use Zephyr's build infrastructure to build a library (preferred ELF format) that does not contain the Zephyr OS and is not an application? I figure I'll probably need to relocate the data section of this library from ROM to RAM during boot.
2. How can I link a Zephyr application with this library so that all the calls will be resolved?
Yes you can use the Zephyr build system to build a library. Just put a CMakeLists.txt file in the subdirectory where you have your library (the atmel crypto library in my case). Here is the CMakeLists.txt file
To build the library I have this bash script in the directory above
To link the prebuilt libraries into the zephyr build, it is just a latter of telling CMakeLists.txt where the libraries are, add something like this to your CMakeLists.txt
The part I haven't done is forcing the libraries to link to a specific location (your ROM), maybe someone else can tell you how to do that.
On Wed, May 25, 2022 at 9:03 AM Jacob Avraham <jacob.avraham@...> wrote: