Use external LPDDR memory on tile #1

Discussions relating to the XK-EVK-XU316
alex4d1
Member++
Posts: 28
Joined: Mon May 13, 2024 11:38 pm

Use external LPDDR memory on tile #1

Post by alex4d1 »

Hi all,

I have a custom board with a XU316 and external memory, identical setup as on the xcore.ai Explorer board.
My XN file has an entry for the external memory just like the XN file of the XCORE examples provided by XMOS.

I was able to use the external memory on tile #0 simply by doing this:

Code: Select all

#if ON_TILE(0)
__attribute__ ((section(".ExtMem.bss")))
#endif
int32_t mic_data[4096]; 
Note that this array is used in my code further down, so it won't be discarded by the linker.


Based on the documentation I can use the external memory either on tile #0 or on tile #1, this is decided at compile time.
So I changed my code to this:

Code: Select all

#if ON_TILE(1)
__attribute__ ((section(".ExtMem.bss")))
#endif
int32_t mic_data[4096]; 
Now my application compiles correctly, but it doesn't run. XRUN does not run correctly, I don't see any output and it doesn't return.
Only if I reduce the array size to 64 or less it works.
I believe this lines up with the L1 cache size, so does this mean the caching works but the cache is not able to write the ext memory?

If I use the following attribute

Code: Select all

__attribute__ ((section(".ExtMem.data")))
instead and run the application with XRUN I get:
xrun: Binary not correctly downloaded to target device
and XRUN returns.

I also tried manually enabling the external memory on tile one in main.c:

Code: Select all

    // Enable external memory access
    unsigned int ctrl0 = getps(XS1_PS_XCORE_CTRL0);
    ctrl0 |= XS1_XCORE_CTRL0_EXTMEM_ENABLE_MASK;
    setps(XS1_PS_XCORE_CTRL0, ctrl0);
But I believe this would be too late anyways, since the array is in the BSS section which is initialized by the startup code.

Does anybody have successfully accessed the external memory from tile #1? Any help would be greatly appreciated.

Cheers
Alex
alex4d1
Member++
Posts: 28
Joined: Mon May 13, 2024 11:38 pm

Post by alex4d1 »

Just some follow up information:

I confirmed the issue with the "getting_started" example and the xcore.ai Explorer board.
I modified the "getting_started" example as follows:

#if ON_TILE(1)
__attribute__ ((section(".ExtMem.bss")))
uint32_t mic[4096];
#else
uint32_t mic[4096];
#endif


void tile0_hello_task(void *arg) {
rtos_printf("Hello task running from tile %d on core %d\n", THIS_XCORE_TILE,
portGET_CORE_ID());

for (;;) {
rtos_printf("Hello from tile %d: %d\n", THIS_XCORE_TILE, mic[0]);
vTaskDelay(pdMS_TO_TICKS(1000));
mic[0]++;
}
}

void tile1_hello_task(void *arg) {
rtos_printf("Hello task running from tile %d on core %d\n", THIS_XCORE_TILE,
portGET_CORE_ID());

for (;;) {
rtos_printf("Hello from tile %d: %d\n", THIS_XCORE_TILE, mic[0]);
vTaskDelay(pdMS_TO_TICKS(1000));
mic[0]++;
}
}

If the mic array of tile #0 is defined on the external memory then everything works fine. If the mic array of tile #1 is defined on the external memory then tile #1 is getting stuck somewhere in the __start_core function.
The address pointer is pretty high so I assume it is stuck in the hard fault handler or similar.

I verified that the XCORE_CTRL0 register is set correctly (by setting the array size to <= 64, so I was able to get the tile running to read back the register). I can see that the correct tile has the external memory interface enabled and the size is configured correctly.

I am clearly missing something here. Any ideas what it could be?

Cheers
Alex