kendryte / kendryte-freertos-sdk

This project is no longer maintained Not recommended for product development.
Apache License 2.0
201 stars 67 forks source link

New issues with updated 'develop' branch #39

Closed loboris closed 5 years ago

loboris commented 5 years ago

As I cannot reopen the closed issue, I'm posting it as a new one. This continues discussion in https://github.com/kendryte/kendryte-freertos-sdk/issues/38

Running on both processors now works, but there is another issue: Using floats (float or double type) produces a wrong result.

I've used a slightly changed task functions to test the floats:

//---------------------------------------
static void test_task0(void *pvParameter)
{
    uint64_t n = 0, ticks;
    double x;
    while (1) {
        vTaskDelay(1000 / portTICK_PERIOD_MS);
        n++;
        ticks = xTaskGetTickCount();
        x = (double)ticks / 1.23456789;
        if (xSemaphoreTake( test_task_mutex, 100) == pdTRUE ) {
            printf("Task at 0: %lu, %lu, %.3f\n", n, ticks, x);
            xSemaphoreGive(test_task_mutex);
        }
    }
    vTaskDelete(NULL);
}

//----------------------------------------
static void test_task1(void *pvParameter)
{
    uint64_t n = 0, ticks;
    float x;
    while (1) {
        vTaskDelay(1000 / portTICK_PERIOD_MS);
        n++;
        ticks = xTaskGetTickCount();
        x = (float)ticks / 1.23456789;
        if (xSemaphoreTake( test_task_mutex, 100) == pdTRUE ) {
            printf("Task at 1: %lu, %lu, %.3f\n", n, ticks, x);
            xSemaphoreGive(test_task_mutex);
        }
    }
    vTaskDelete(NULL);
}

It gives the following result (doubles are not printed):

TEST
Task at 0: 1, 101, nan
Task at 1: 1, 152, nan
Task at 0: 2, 201, nan
Task at 1: 2, 252, nan
Task at 0: 3, 301, nan
Task at 1: 3, 352, nan
Task at 0: 4, 401, nan
Task at 1: 4, 452, nan
Task at 0: 5, 501, nan
Task at 1: 5, 552, nan
Task at 0: 6, 601, nan
Task at 1: 6, 652, nan
Task at 0: 7, 701, nan
Task at 1: 7, 752, nan
Task at 0: 8, 801, nan
Task at 1: 8, 852, nan
Task at 0: 9, 901, nan
Task at 1: 9, 952, nan
Task at 0: 10, 1001, nan
Task at 1: 10, 1052, nan

Changing crt.S to the one from (now deleted) new_sched branch results in correct result:

TEST
Task at 0: 1, 101, 81.810
Task at 1: 1, 152, 123.120
Task at 0: 2, 201, 162.810
Task at 1: 2, 252, 204.120
Task at 0: 3, 301, 243.810
Task at 1: 3, 352, 285.120
Task at 0: 4, 401, 324.810
Task at 1: 4, 452, 366.120
Task at 0: 5, 501, 405.810
Task at 1: 5, 552, 447.120
Task at 0: 6, 601, 486.810
Task at 1: 6, 652, 528.120
Task at 0: 7, 701, 567.810
Task at 1: 7, 752, 609.120
Task at 0: 8, 801, 648.810
Task at 1: 8, 852, 690.120
Task at 0: 9, 901, 729.810
Task at 1: 9, 952, 771.120
Task at 0: 10, 1001, 810.810
Task at 1: 10, 1052, 852.120

Why was it changed ?

sunnycase commented 5 years ago

Use the toolchain https://github.com/kendryte/kendryte-gnu-toolchain/releases/tag/v8.2.0-20190213

loboris commented 5 years ago

Thank you, all works with that toolchain version.