Porting complex legacy linux application to freertos running on IMX microcontroller

Hi,

I am trying to port an existing C++ application running on linux currently to freertos.

My application has various custom libraries ( prj_lib1, prj_lib2, … prj_lib9) which I wanna link to one .exe(Project_main.exe)

I just need a bit of clarification on how to proceed in this scenario.

Do I need to create freertos static library for each library to link in the Project_main.exe or normal c++ static library should be good enough?

Currently what I am doing is, I have generated Project_main.exe by modifying an existing demo application. And then created normal C++ static library for different libraries which I link in the Project_main.exe.

Is this the correct way to go ahead? Or should I modify existing demo application to generate libraries too?

If there’s some other way please do let me know.

Converting a Linux application to FreeRTOS is not always a trivial job, as things are done somewhat differently.

One key thing that you don’t seem to be thinking about is that a FreeRTOS application is just a single executable image, so it only has one copy of it in the system. FreeRTOS Tasks are sort of like Linux Threads, NOT like Processes, so if you application used multi-processes that doesn’t map over easily.

In addition to what Richard wrote, FreeRTOS does not have distinct bootloader, system and application startup sequences, no daemons (in particular no systemd which coordinates process srartups and (luckily) none of the terrible Linux history mandated signal “architecture.” No system-mandated file system and no CLI built-in terminal either (both again pros). Plus many more surprises down the road.

You are looking ar a potentially very significant (yet worthwhile) rewrite.

1 Like

Hi Richard,
Thanks for responding. Does that mean I cant run an application with few statically linked library on FreeRTOS?

Statically linked libraries aren’t a problem, but why do you think each one gets its own copy of another library? When statically linking an application, all your libraries can refer to any of each other. Also, the way FreeRTOS is configured with FreeRTOSconfig.h to configure it, it really doesn’t become a normal “Static Library” as that would need to have a fixed common FreeRTOSconfig.h for all applications using it. I tend to use FreeRTOS as a set of files that are just complied and linked as part of the application. If you have libraries that want to call it, they can just do so.

1 Like

Hi @richard-damon,
when I’m trying to run my application from external memory (Board RAM ) instead of internal memory. But my application crashes at BOARD_InitBootClocks();

int main(void)
{
    /* Init board hardware. */
    BOARD_ConfigMPU();
    BOARD_InitBootPins();
    BOARD_InitBootClocks();
    BOARD_InitDebugConsole();
    PRINTF("Enter Main!.\r\n");
    if (xTaskCreate(hello_task, "Hello_task", configMINIMAL_STACK_SIZE + 100, NULL, hello_task_PRIORITY, NULL) !=
        pdPASS)
    {
        PRINTF("Task creation failed!.\r\n");
        while (1)
            ;
    }
    vTaskStartScheduler();
    for (;;)
        ;
}

Any Reason for this?

I afraid you’ve to debug your application yourself since you’re are the man with the debugger connected to your board :wink:
Just step thru / into the code and see what’s going wrong.
I guess you’ve already verified that your application is properly linked and loaded into external RAM…

1 Like