2019-03-27 10:05 AM
I trying to make common address space for BT-stack in flash memory, show in below figure. I have two projects using same flash memory. In both the projects Bt stack is used, so, I thought to make common memory for BT stack so that both the projects can call functions and can reduce the flash memory size also.
Let's call OTA is project-1 and Application is project-2.Using Stm32f412CE controller with 512kbytes flash memory. BT stack will be in OTA project and storing in specific address location in flash memory. I need to call same functions which is stored in common place from application code as well.
I'm aware that I can use section attributes on functions and variables and then locate those sections at specific addresses during linking.
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 128K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 16K
MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K
}
.ip_code :
{
*(.IP_Code*);
} > IP_CODE
__attribute__((section(".IP_Code"))) int placed_logic().
2019-03-27 11:16 PM
I think there is not enough information.
First, I couldn't figure out what you are trying to achieve.
Only one of the projects is running at a time?
Do you use some OS?
Do you need to be able to flash both projects as one?
Also, two projects mean two sets of resource allocations and compilation settings - there may be conflicts.
Why do you need two projects?
Depending on the situation, I might use an array of function pointers in the common area and link that array to an absolute address in both projects (something like device descriptors often are). In that case I'd use two separate images with a common linker script.
2019-03-27 11:56 PM
Only one of the projects is running at a time ?
Only one project will be running at a time, I can choose either one of the project-1 or project-2 to be run.
Do you use some OS?
Yes, I'm using FreeRTOS OS.
Why do you need two projects ?
Basically those are two different projects sitting in single micro-controller. I can choose any one of the them based on condition like power button and user button it will go to project-1, with normal power button it will go to project-2.
It is a huge BT stack libraries, so, I can't use function pointers for many functions. If you keep BT stack common, so that I can call functions from project-2 also.
And I can use less flash memory also by doing this exercise.
2019-03-28 07:49 AM
2019-03-28 08:27 AM
Real problem calling code within another app is that it's view of RAM and where it's variables are will be completely different.
If I were building a common library, I'd probably make it a standalone image, with it's own RAM allocation not tied to anything else, and then exclude that RAM from the linker's view in the other apps, and provide entry points to the API via a definition file to the linker.
2019-03-28 11:45 PM
I didn't understand what you are trying to convey.
Is what I suggested making sense? or can we do it any other approach?
2019-03-28 11:54 PM
As there is no dynamic linking, it's not going to be easy to implement.
True, you can define say 3 flash sectors in the linker file to control where the flash functions and constant will drop. But the absolute address to call a program 1 function from common will change when it becomes program 2. The absolute address of constant data will too change.
Not exhaustive I would think of:
Making sense?
2019-03-29 12:10 AM
Note: You will also have to make sure that the stack size is still good enough for both configurations.
The RAM heap global variables should also be placed by the linker at the same location (to check on the MAP file for example).
Also consider the proper handling of the interrupt vector table.
2019-03-29 04:15 AM
thank you so much,
did i understood properly?
2019-03-29 04:47 AM
yes, stack size for both the projects are good enough to place in flash memory.
Still in confusion how to approach this problem or solve this step by step?
can you me actually what need to do or read ?