Running FreeRTOS on the Kendryte Framework using Renode

I followed the steps in the following article to integrate PlatformIO with Renode:

The demo works properly, but however I’m not able to run my own custom programs
Here’s a program I wrote:

#include <FreeRTOS.h>
#include <stdio.h>
#include <queue.h>
#include <task.h>

TaskHandle_t vTask1Handle = NULL;

void vTask1(void* pvParameters)
{
    int count = 0;
    while(1)
    {
        printf("This is Task 1: %d\r\n", count++);
        vTaskDelay(1000);
    }
}

int main(void)
{

    xTaskCreate(&vTask1,             // Function that the task executes
                "Task 1",            // Name
                1024,                // Stack Size
                NULL,                // Parameters
                1,                  // Priority
                &vTask1Handle);      // Task Handler
    vTaskStartScheduler();
    while(1)
    {
        ;
    }
    return 0;
}

Here’s the platformio.ini file:

[env:sipeed-maix-go]
platform = kendryte210
board = sipeed-maix-go
framework = kendryte-freertos-sdk
## ----- Settings below are for Antmicro Renode integration ----- ##
# Monitor port for Renode integration
monitor_port = socket://localhost:1234
monitor_speed = 115200
# Upload settings for Renode integration
; debug_tool = renode
upload_port = /dev/ttyUSB0
upload_command = renode $UPLOAD_FLAGS
upload_flags =
    -e include @scripts/single-node/kendryte_k210.resc
    -e machine StartGdbServer 3333 True
    -e logLevel 3           ;Loglevel = Error
    -e emulation CreateServerSocketTerminal 1234 \"externalUART\"
    -e connector Connect uart externalUART
    -e sysbus LoadELF @$PROJECT_BUILD_DIR/$PIOENV/$PROGNAME".elf"
    -e start
# Debug settings for Renode integration
debug_tool = custom
debug_port = localhost:3333
debug_server = renode
    --hide-log
    -e include @scripts/single-node/kendryte_k210.resc
    -e machine StartGdbServer 3333 True
    -e logLevel 3           ;Loglevel = Error
    -e emulation CreateServerSocketTerminal 1234 "externalUART"
    -e connector Connect uart externalUART
debug_extra_cmds =
    monitor start

Here’s the output I get:
image

It gets stuck. But if I remove the line involving delay, it works perfectly. I’m also facing similar issues while using queues. I believe that I would have to make some changes in the FreeRTOS source files. Please let me know what do I have to do and where I could find the source files.

If you post the same on thing in multiple places, please link them. I see you’ve already opened an issue at Running FreeRTOS codes on Windows · Issue #4 · carlosedp/PlatformIO-Renode-Demos · GitHub where the project comes from (but didn’t link).

Usually not being able to survive a vTaskDelay() is an indication of the task switching not working due to not or wrongly called timer interrupt handler or service call handler (that’s how it’s called on ARM at least).

The used renode version is the latest stable 1.12 but it’s still from April 2021 and there have been

295 commits to master since this release

so Renode might have already fixed the bug (given that the firmware was valid and would work on real HW in the first place). Does it behave the same when you use the latest nightly build? GitHub - renode/renode: Renode - Antmicro's open source simulation and virtual development framework for complex embedded systems