Open-CMSIS-Pack / devtools

Open-CMSIS-Pack development tools - C++
Apache License 2.0
74 stars 57 forks source link

Improve linker scripts for multi-project setup (multi-processor, boot/app, secure/non-secure) #1828

Open ReinhardKeil opened 6 days ago

ReinhardKeil commented 6 days ago

The Problem To Be Solved

It is complex to manage the memory resources across a multi-project system.

The CMSIS-Toolbox contains a flexible linker script management. There should be best-practice examples that show the usage.

One way outlined in the picture below is the usage of a central regions header file (that could be also generated by tools such as CMSIS-Zone). Using #define statements the preprocessor step should be able to extract the information for each project. The benefit is that generic linker scripts would still work. As the CMSIS-Toolbox provides this for each compiler toolchain, the project templates could be toolchain agnostic. Such template projects may be provided as part of a DFP or BSP and can be therefore contain a device or board specific setup.

image

A benefit of a regions header file is that it can be also directly used by C/C++ source files.

TeoMahnic commented 6 days ago

I have created a mock-up multi-project example available here: https://github.com/TeoMahnic/multi-project It has a global_regions.h file, which describes total device memory available and how it is split/partitioned between the projects A and B. In order to keep the global regions file as simple as possible, glue logic necessary for preprocessor step was moved to the check_regions.h (this could eventually also be handled by a tool/script). The projects include a modified AC6 linker script template (based on the one provided by CMSIS-Toolbox), which includes additional guards for startup, heap and stack.