This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to sharing lib between different projects

Hi all,

First I want to deliver some background information to the given problem:There are two different MDK projects, both of which need to be written into the same chip to run at different times. Since both projects use the same library, the final flash will contain two identical binary data segments of the library. Is there any way for these two projects to use the same library binary data?

My approach is to set the same addresses for the Execution Region and Load Region of the same library in the scatter files of both projects, so that only one set of library binaries is needed during code burning. However, things did not go as planned because they are not linked in a fixed order.

Project 1:

scatter file

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
LR_ROM4 0x0000A000 FIXED 0x180000 ; A5LIB, 1.5M for RO
{
ROM4_A5LIB 0x0000A000 0x180000 ; RO data
{
*a5Alg*.lib(+RO)
*a5Kern*.lib(+RO)
*a5Dev*.lib(+RO)
}
ROM4_ZERO_FILL 0x00018A000 FIXED EMPTY 0x0 {}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

.map

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Load Region LR_ROM4 (Base: 0x0000a000, Size: 0x00180000, Max: 0x00180000, ABSOLUTE)
Execution Region ROM4_A5LIB (Exec base: 0x0000a000, Load base: 0x0000a000, Size: 0x000f8800, Max: 0x00180000, ABSOLUTE)
Exec Addr Load Addr Size Type Attr Idx E Section Name Object
0x0000a000 0x0000a000 0x00000bcc Code RO 29988 .text a5Alg.lib(dsplib.o)
0x0000abcc 0x0000abcc 0x00005624 Code RO 30186 .text a5Alg.lib(mixcontrol.o)
0x000101f0 0x000101f0 0x00000408 Code RO 30389 .text a5Alg.lib(mp3.o)
0x000105f8 0x000105f8 0x000001b4 Code RO 30464 .text a5Dev.lib(adclib.o)
0x000107ac 0x000107ac 0x00000230 Code RO 30492 .text a5Dev.lib(dmalib.o)
0x000109dc 0x000109dc 0x0000022c Code RO 30510 .text a5Dev.lib(iislib.o)
0x00010c08 0x00010c08 0x00000218 Code RO 30530 .text a5Dev.lib(irqlib.o)
0x00010e20 0x00010e20 0x000003d4 Code RO 30597 .text a5Dev.lib(spilib.o)
0x000111f4 0x000111f4 0x0000032c Code RO 30618 .text a5Dev.lib(systemlib.o)
0x00011520 0x00011520 0x000001f8 Code RO 30638 .text a5Dev.lib(timerlib.o)
0x00011718 0x00011718 0x00000538 Code RO 30659 .text a5Dev.lib(uartlib.o)
0x00011c50 0x00011c50 0x000007e8 Code RO 30681 .text a5Kern.lib(slotlib.o)
0x00012438 0x00012438 0x0000aba8 Code RO 30736 .text a5Kern.lib(kernlib.o)
0x0001cfe0 0x0001cfe0 0x0000ca74 Code RO 30804 .text a5Kern.lib(midilib.o)
0x00029a54 0x00029a54 0x00001ae0 Code RO 30942 .text a5Alg.lib(classicreverb.o)
0x0002b534 0x0002b534 0x00001794 Code RO 30998 .text a5Alg.lib(dynamic.o)
0x0002ccc8 0x0002ccc8 0x00007a10 Code RO 31014 .text a5Alg.lib(effectmanager.o)
0x000346d8 0x000346d8 0x00002ddc Code RO 31155 .text a5Alg.lib(equalizer.o)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Project 2:

scatter file

Fullscreen
1
2
3
4
5
6
7
8
9
10
LR_ROM4 0x0000A000 FIXED 0x180000 ; A5LIB, 1.5M for RO
{
ROM4_A5LIB 0x0000A000 0x180000 ; RO data
{
*a5Alg*.lib(+RO)
*a5Kern*.lib(+RO)
*a5Dev*.lib(+RO)
}
ROM4_ZERO_FILL 0x00018A000 FIXED EMPTY 0x0 {}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

.map:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Load Region LR_ROM4 (Base: 0x0000a000, Size: 0x00180000, Max: 0x00180000, ABSOLUTE)
Execution Region ROM4_A5LIB (Exec base: 0x0000a000, Load base: 0x0000a000, Size: 0x000f8800, Max: 0x00180000, ABSOLUTE)
Exec Addr Load Addr Size Type Attr Idx E Section Name Object
0x0000a000 0x0000a000 0x00000bcc Code RO 9466 .text a5Alg.lib(dsplib.o)
0x0000abcc 0x0000abcc 0x00005624 Code RO 9664 .text a5Alg.lib(mixcontrol.o)
0x000101f0 0x000101f0 0x00000408 Code RO 9867 .text a5Alg.lib(mp3.o)
0x000105f8 0x000105f8 0x00000e40 Code RO 9942 .text a5Alg.lib(sounddecode.o)
0x00011438 0x00011438 0x000001b4 Code RO 10031 .text a5Dev.lib(adclib.o)
0x000115ec 0x000115ec 0x00000230 Code RO 10059 .text a5Dev.lib(dmalib.o)
0x0001181c 0x0001181c 0x0000022c Code RO 10077 .text a5Dev.lib(iislib.o)
0x00011a48 0x00011a48 0x00000218 Code RO 10097 .text a5Dev.lib(irqlib.o)
0x00011c60 0x00011c60 0x000003d4 Code RO 10164 .text a5Dev.lib(spilib.o)
0x00012034 0x00012034 0x0000032c Code RO 10185 .text a5Dev.lib(systemlib.o)
0x00012360 0x00012360 0x000001f8 Code RO 10205 .text a5Dev.lib(timerlib.o)
0x00012558 0x00012558 0x00000538 Code RO 10226 .text a5Dev.lib(uartlib.o)
0x00012a90 0x00012a90 0x000007e8 Code RO 10248 .text a5Kern.lib(slotlib.o)
0x00013278 0x00013278 0x0000aba8 Code RO 10303 .text a5Kern.lib(kernlib.o)
0x0001de20 0x0001de20 0x0000ca74 Code RO 10371 .text a5Kern.lib(midilib.o)
0x0002a894 0x0002a894 0x00001ae0 Code RO 10439 .text a5Alg.lib(classicreverb.o)
0x0002c374 0x0002c374 0x00001794 Code RO 10474 .text a5Alg.lib(dynamic.o)
0x0002db08 0x0002db08 0x00007a10 Code RO 10490 .text a5Alg.lib(effectmanager.o)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

This approach reveals that the addresses of the third object are different.

I am wondering if it is necessary to specify the order of objects in the scatter file? So I tried to use armar -t to extract the .o files included in the lib and write them in order to the Execution Region, but after compiling and checking the address distribution in the .map file, it still did not follow the order specified in the scatter file.

scatter file

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
LR_ROM4 0x0000A000 FIXED 0x180000 ; A5LIB, 1.5M for RO
{
ROM4_A5LIB 0x0000A000 0x180000 ; RO data
{
dsplib.o(+RO)
amp.o(+RO)
classicreverb.o(+RO)
combinedeffect.o(+RO)
delay.o(+RO)
dspreverb.o(+RO)
dynamic.o(+RO)
effectmanager.o(+RO)
equalizer.o(+RO)
lofi.o(+RO)
mdist.o(+RO)
mixcontrol.o(+RO)
modernreverb.o(+RO)
modulator.o(+RO)
overdrive.o(+RO)
pedalresonance.o(+RO)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

.map

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Load Region LR_ROM4 (Base: 0x0000a000, Size: 0x00180000, Max: 0x00180000, ABSOLUTE)
Execution Region ROM4_A5LIB (Exec base: 0x0000a000, Load base: 0x0000a000, Size: 0x000bdcc4, Max: 0x00180000, ABSOLUTE)
Exec Addr Load Addr Size Type Attr Idx E Section Name Object
0x0000a000 0x0000a000 0x00000bcc Code RO 29988 .text a5Alg.lib(dsplib.o)
0x0000abcc 0x0000abcc 0x00005624 Code RO 30186 .text a5Alg.lib(mixcontrol.o)
0x000101f0 0x000101f0 0x00000408 Code RO 30389 .text a5Alg.lib(mp3.o)
0x000105f8 0x000105f8 0x00001ae0 Code RO 30942 .text a5Alg.lib(classicreverb.o)
0x000120d8 0x000120d8 0x00001794 Code RO 30998 .text a5Alg.lib(dynamic.o)
0x0001386c 0x0001386c 0x00007a10 Code RO 31014 .text a5Alg.lib(effectmanager.o)
0x0001b27c 0x0001b27c 0x00002ddc Code RO 31155 .text a5Alg.lib(equalizer.o)
0x0001e058 0x0001e058 0x0000043c Code RO 31170 .text a5Alg.lib(pedalresonance.o)
0x0001e494 0x0001e494 0x0000098c Code RO 31190 .text a5Alg.lib(soundalgorithmglobal.o)
0x0001ee20 0x0001ee20 0x00002e24 Code RO 31362 .text a5Alg.lib(organ.o)
0x00021c44 0x00021c44 0x000009d0 Code RO 31406 .text a5Alg.lib(mp3encode.o)
0x00022614 0x00022614 0x00000e40 Code RO 31463 .text a5Alg.lib(sounddecode.o)
0x00023454 0x00023454 0x000010b8 Code RO 31527 .text a5Alg.lib(aacdecode.o)
0x0002450c 0x0002450c 0x00000398 Code RO 31610 .text a5Alg.lib(polystringresonance.o)
0x000248a4 0x000248a4 0x00000280 Code RO 31631 .text a5Alg.lib(env.o)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

How can I make the linker arrange the image in order?
Returning to the fundamental question, how can I implement different MDK projects to share the binary code of the lib?
Thanks!
 
0