Background: FreeRTOS, Cortext-M3 Suppose there is a situation where the kernel and application are developed separately, and the .text segment of the kernel and the application is stored in two areas of the FLASH, and the RAM is also divided into the Kernel area and the application area, and the Kernel.bin and app.bin need to be downloaded when burning. Question:How do I use the kernel to call up the application? I would like to know how it works (using FreeRTOS as an example),As a beginner, I sincerely ask you for advice.
FreeRTOS and similar RTOS are normally statically linked to the application into a monolitic executable. There is no defined means to separate them; to do so would require you to implement such means in a proprietary fashion.
Operating systems that do support kernel/application separation do so either by dynamic linking on application load, or by software interrupts where OS entry points are essentially interrupt handlers, and the address is fetched from a vector table.
Dynamic linking is itself an OS function and probably not practical to implement yourself, but it would be feasible to have an entry point lookup table and a set of API wrapper functions or macros that access the lookup table to find the true entry point and jump to it, passing on any parameters.
The lookup would need to be generated and statically linked to the kernel and located at a known location shared with the application segment.
It is a lot of work for probably limited benefit, and you loose the benefit of any compile/link time error checking for existence of the required function and the number and types of arguments. All that could be resolved by a more complex look-up with metadata about arguments, at the expense perhaps of run-time performance and determinism.
There are no doubt other solutions. You could for example statically link the kernel and application but use the linker script to locate object modules for each in separate memory regions and hen generate separate binary images for each region. However in that case they are still statically linked and you could not for example replace either component with an updated version without updating the other.
Larger RTOS products that are more complete operating systems rather than simple scheduling/IPC kernels often have direct support for separation and dynamic application loading and linking. VxWorks and QNX Neutrino for example.