avoiding duplicate port declaration errors in XC

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
User avatar
russf
XCore Addict
Posts: 146
Joined: Thu Dec 10, 2009 10:17 pm
Contact:

avoiding duplicate port declaration errors in XC

Post by russf »

I'm working on a multiprocessor project in XC. My XDE is up-to-date - 11.2.0

I receive 16 of the following type error, as soon as I define the second of the two arrays, below.
xmap: Error: Symbol __xccomp_internal_ports128_anon_0 is a duplicate port declaration.
xmap: Error: previously declared as __xccomp_internal_ports64_anon_0.
xmap: Error: Symbol __xccomp_internal_ports128_anon_1 is a duplicate port declaration.
xmap: Error: previously declared as __xccomp_internal_ports64_anon_1.
etc...

Code: Select all

struct pinDescriptors {
    port p;
    int width;
    char name[9];
    int pin;
};

struct pinDescriptors ports64[NPINS64] = {
    { XS1_PORT_1A, 1, "PORT_1A", 0 },
    { XS1_PORT_1B, 1, "PORT_1B", 1 },
etc.

struct pinDescriptors ports128[NPINS128] = {
    { XS1_PORT_1A, 1, "PORT_1A", 0 },
    { XS1_PORT_1B, 1, "PORT_1B", 1 },
etc...
The arrays describe the ports to be tested in a bring-up program. The initial rows are the same, and they diverge later in each table. I can work around this case, but I'm looking for the correct path for what seems a common case.

The source of the problem is the multiple declaration of a port by using the symbol XS1_PORT_1A more than once in a program. As I understand it, without an 'on' qualifier, these are assumed to be on stdcore[0], and the compiler rejects this. So I need a means to build two, and eventually 3, arrays of appropriately qualified port declarations.

I'm having trouble with syntax (again : nod to m_y who recently helped with a simpler case).

The tutorial 'Connecting Multiple XDKs using XN' contains as part of the LED example the following:

Code: Select all

out port leds[24] = { on stdcore[0] : X0LEDA,
on stdcore[0] : X0LEDB,
etc.
I've tried variants of that, and this...

Code: Select all

struct pinDescriptors portsPackage2[NPINS64] = {
    { on stdcore [2] : XS1_PORT_1A, 1, "PORT_1A", 0 },
etc.
but I have not found the correct incantation.

I'd appreciate some guidance.

Thanks,
--r.


User avatar
Andy
Respected Member
Posts: 279
Joined: Fri Dec 11, 2009 1:34 pm

Post by Andy »

Try putting the core declaration before the struct:

Code: Select all

on stdcore[0] : pinDescriptors ports = { XS1_PORT_1A, 1, "PORT_1A", 0 };
User avatar
russf
XCore Addict
Posts: 146
Joined: Thu Dec 10, 2009 10:17 pm
Contact:

Post by russf »

Sigh!

Yes, Andy. Quite right. Thank you!

--r
voodoosound
Active Member
Posts: 63
Joined: Sat Oct 15, 2011 8:53 pm

Post by voodoosound »

Hi everyone!

I have a similar problem, but the proposed solution did not work for me.

Here is the code:

Code: Select all


typedef struct {
	in buffered port:8 spiMISO;
	out port spiSS;
	out port spiCLK;
	out buffered port:8 spiMOSI;
	clock spiClkblk;
} fl_SPIPorts_t ;

on tile[0]: fl_SPIPorts_t spi_flash_memory_desc =
{
	PORT_SPI_MISO,
	PORT_SPI_MOSI,
	PORT_SPI_CLK,
	PORT_SPI_SS,
	XS1_CLKBLK_4
};

on tile[0]: fl_SPIPorts_t spi_device0_desc =
{
	PORT_SPI_MISO,
	PORT_SPI_MOSI,
	PORT_SPI_CLK,
	PORT_SDATA_IN3,
	XS1_CLKBLK_4
};

This produces an xmap error:

Code: Select all

xmap: Error: Symbol spi_device0_desc.spiCLK is a duplicate port declaration.
xmap: Error:   previously declared as spi_flash_memory_desc.spiCLK.
xmap: Error: Symbol spi_device0_desc.spiMISO is a duplicate port declaration.
xmap: Error:   previously declared as spi_flash_memory_desc.spiMISO.
xmap: Error: Symbol spi_device0_desc.spiSS is a duplicate port declaration.
xmap: Error:   previously declared as spi_flash_memory_desc.spiSS.
xmap: Error: Symbol b_spi_clk is a duplicate clock declaration.
xmap: Error:   previously declared as spi_device0_desc.spiClkblk.
xmap: Error: Symbol b_spi_clk is a duplicate clock declaration.
xmap: Error:   previously declared as spi_flash_memory_desc.spiClkblk.

Does anyone have another idea?

Regards,
Ck
User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am
Contact:

Post by segher »

You are declaring both structs as "on tile[0]". That doesn't fly.
voodoosound
Active Member
Posts: 63
Joined: Sat Oct 15, 2011 8:53 pm

Post by voodoosound »

Hmmm... then I am missing something.

Why is this problematic, since the ports are declared on tile[0]?
User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am
Contact:

Post by segher »

You are declaring the same port (e.g., tile 0 port SPI_MISO) twice.
XC does not allow that.

(btw, you have jumbled the order of the ports within the structs).
Post Reply