It seems to me that the ON_TILE macro is causing this issue. I refactored the getting_started example and removed all the ON_TILE macros and now it works fine.
My application is heavily using this macros so I'll have to see how I can work around this.
Code: Select all
// Copyright 2021 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#include <platform.h>
#include "FreeRTOS.h"
#include "task.h"
#include "rtos_printf.h"
#include "platform/platform_init.h"
#include "platform/driver_instances.h"
__attribute__((section(".ExtMem_data"))) int x[] __attribute__((aligned(4))) = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
};
void tile0_blinky_task(void *arg) {
rtos_printf("Blinky task running from tile %d on core %d\n", THIS_XCORE_TILE,
portGET_CORE_ID());
uint32_t gpio_port = rtos_gpio_port(XS1_PORT_4C);
rtos_gpio_port_enable(gpio_ctx_t0, gpio_port);
for (;;) {
rtos_gpio_port_out(gpio_ctx_t0, gpio_port, 0x000F);
vTaskDelay(pdMS_TO_TICKS(1000));
rtos_gpio_port_out(gpio_ctx_t0, gpio_port, 0x0000);
vTaskDelay(pdMS_TO_TICKS(1000));
}
}
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\n", THIS_XCORE_TILE);
vTaskDelay(pdMS_TO_TICKS(1000));
}
}
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\n", THIS_XCORE_TILE);
vTaskDelay(pdMS_TO_TICKS(1000));
for (int i = 0; i < (sizeof(x)/sizeof(x[0])); i++) {
if (x[i] != i) {
fprintf(stderr, "Array index %d was not initialised in EXTMEM!\n", i);
exit(EXIT_FAILURE);
}
printf("x[%d]==%d\n", i, x[i]);
}
}
}
// static void tile_common_init(chanend_t c) {
// platform_init(c);
// #if ON_TILE(0)
// xTaskCreate((TaskFunction_t)tile0_hello_task, "tile0_hello_task",
// RTOS_THREAD_STACK_SIZE(tile0_hello_task), NULL,
// configMAX_PRIORITIES - 1, NULL);
// xTaskCreate((TaskFunction_t)tile0_blinky_task, "tile0_blinky_task",
// RTOS_THREAD_STACK_SIZE(tile0_blinky_task), NULL,
// configMAX_PRIORITIES - 1, NULL);
// #endif
// #if ON_TILE(1)
// xTaskCreate((TaskFunction_t)tile1_hello_task, "tile1_hello_task",
// RTOS_THREAD_STACK_SIZE(tile1_hello_task), NULL,
// configMAX_PRIORITIES - 1, NULL);
// #endif
// rtos_printf("Start scheduler on tile %d\n", THIS_XCORE_TILE);
// vTaskStartScheduler();
// }
static void tile_common_init_a(chanend_t c) {
platform_init(c);
xTaskCreate((TaskFunction_t)tile0_hello_task, "tile0_hello_task",
RTOS_THREAD_STACK_SIZE(tile0_hello_task), NULL,
configMAX_PRIORITIES - 1, NULL);
xTaskCreate((TaskFunction_t)tile0_blinky_task, "tile0_blinky_task",
RTOS_THREAD_STACK_SIZE(tile0_blinky_task), NULL,
configMAX_PRIORITIES - 1, NULL);
rtos_printf("Start scheduler on tile %d\n", THIS_XCORE_TILE);
vTaskStartScheduler();
}
static void tile_common_init_b(chanend_t c) {
platform_init(c);
xTaskCreate((TaskFunction_t)tile1_hello_task, "tile1_hello_task",
RTOS_THREAD_STACK_SIZE(tile1_hello_task), NULL,
configMAX_PRIORITIES - 1, NULL);
rtos_printf("Start scheduler on tile %d\n", THIS_XCORE_TILE);
vTaskStartScheduler();
}
//#if ON_TILE(0)
void main_tile0(chanend_t c0, chanend_t c1, chanend_t c2, chanend_t c3) {
(void)c0;
(void)c2;
(void)c3;
tile_common_init_a(c1);
}
//#endif
//#if ON_TILE(1)
void main_tile1(chanend_t c0, chanend_t c1, chanend_t c2, chanend_t c3) {
(void)c1;
(void)c2;
(void)c3;
tile_common_init_b(c0);
}
//#endif