XTC14.4.1 linker duplicate symbol across tiles Topic is solved

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
fabriceo
Respected Member
Posts: 270
Joined: Mon Jan 08, 2018 4:14 pm

XTC14.4.1 linker duplicate symbol across tiles

Post by fabriceo »

Hello,
I m facing a memory size problem on my XU216 application and I ve just realised that the "usb buffer" array is duplicated on the tile 0 and tile 1 during linkage...
the symbol appears in the MAPFILE at 2 different lines for tile0 and tile1 and of course 2 different address.
something like:
0x00057168 g O .dp.bss 0x00004464 usbfifo_OUTA
0x00052d00 g O .dp.bss 0x00004464 usbfifo_INA
and for the other tile:
0x00077a40 g O .dp.bss 0x00004464 usbfifo_OUTA
0x000735d8 g O .dp.bss 0x00004464 usbfifo_INA

doing some intensive search across files and generated assembly, I m 100% sure that no any reference or pointer or direct access exist in the audio tile0 to this arrays of course.
Also there are no function accessing the arrays that are shared across the tiles...
I ve tried many thing like declaring the arrays in other files, C or XC, or in other modules ... no change : the array appears twice and take memories on each tile...

can someone explain the exact behaviour of the linker here and what trick could be used to avoid the situation ?


Many thanks
fabriceo
View Solution
User avatar
fabriceo
Respected Member
Posts: 270
Joined: Mon Jan 08, 2018 4:14 pm

Post by fabriceo »

Hi,
I found the root cause, but not yet a solution: this comes from the interupt registration of the "audio handler" in decouple.xc

This routine is copied on both tiles.
And then any variable used is also promoted on both tiles...
if hiding all its content with #if 0 #endif, then the handler is still visible on both tile of course, but the variable, and especially the big fifo buffer, are not created on the audio tile.

any idea on how to specify the interrupt handler so that it is only on the usb tile ?

I also have another same kind of problem with a large assembly source code which is copied on both tile without good explanation, continuing investigation
User avatar
Ross
Verified
XCore Legend
Posts: 1251
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

is cc_top/cc_bottom used correctly in your asm?
Technical Director @ XMOS. Opinions expressed are my own
User avatar
fabriceo
Respected Member
Posts: 270
Joined: Mon Jan 08, 2018 4:14 pm

Post by fabriceo »

Hi There

you are right Ross pointing this !
there was a peice of code not included in a cc_top/bottom statement and this was the reason !

for the interrupt handler, I have found a solution which is OK for the linker, now testing it extensively.

The idea is simply to encapsulate the handler inside a cc_top/bottom statement, creating a function to host the code.
But then it is required to call this function from the decouple() at least once and I do it as part of the "set_interrupt_handler" macro.
but to avoid running its normal code and adding the stack usage to decouple() then the second idea is to add some code before the handler to return the address of the handler . This way the function does something useful for the caller and forcing nstackwords to 0 doesnt add anything to decouple()

will push the new interrupt.h file when fully tested. for time being, linker is very happy! me too

BTW Ross, I sent you an email @xmos.com last week which may have ended up in spam ?

fabriceo
User avatar
fabriceo
Respected Member
Posts: 270
Joined: Mon Jan 08, 2018 4:14 pm

Post by fabriceo »

Well,
things are more simple in the end : the current version of interrupt.h in xmos github lib_xua contains the proper cc_top/bottom to avoid the duplicate symbols in the audio tile...
I was using the original one from 6.15.2 which doesn't

done. topic can be closed.