Porting FreeRTOS on ML605

roberto-plus wrote on Monday, December 09, 2013:

Hi guys,
I have a project with soft core Microblaze and I would like to use FreeRTOS on it.
I’m using a specific Hardware and BSP.
I tried to add the follow sources files FreeRTOS into project:
-list.c
-queue.c
-task.c
-timers.c
and heap_3.c
Then, I added (then to execute reateProjectDirectoryStructure.bat) the follow paths into my include path:
MicroBlaze_Spartan-6_EthernetLite\SDKProjects\RTOSDemo\FreeRTOS_Source\include
MicroBlaze_Spartan-6_EthernetLite\SDKProjects\RTOSDemo\FreeRTOS_Source\portable\GCC\MicroBlazeV8
In include path i putted also the FreeRTOSConfig.h.
I included these paths in all configuration and languages.
When i try to compile i have the follow erros:
C:/R/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemo/FreeRTOS_Source/include/FreeRTOSConfig.h:73:2: error: #error Ensure CreateProjectDirectoryStructure.bat has been executed before building. See comment immediately above.
make: *** [src/heap_3.o] Error 1

Are there other steps that I have to do?
Thanks.

roberto-plus wrote on Monday, December 09, 2013:

ok I removed the error line in FreeRTOSConfig.h but I have a lot of errors in FreeRTOS c files.

davedoors wrote on Monday, December 09, 2013:

If you can’t clear the errors post the output generated by the compiler.

roberto-plus wrote on Monday, December 09, 2013:

No, I can’t.
The output is here https://gist.github.com/anonymous/7872068
And I have posted also an image with the directory structure.
Thanks for answare.

davedoors wrote on Monday, December 09, 2013:

Looks like you didn’t include port.c in your build. freertos/source/portable/gcc/[chip]/port.c.

roberto-plus wrote on Monday, December 09, 2013:

Yes, I did.
I included all the follow directory
MicroBlaze_Spartan-6_EthernetLite\SDKProjects\RTOSDemo\FreeRTOS_Source
portable\GCC\MicroBlazeV8

roberto-plus wrote on Monday, December 09, 2013:

No one can help me?

rtel wrote on Monday, December 09, 2013:

Is the image you posted a clean build? If so, it does not appear to be building port.c as already mentioned, so I’m not sure what else I can add.

If that is not a clean build please post an image of a clean build so we can see port.c too. If it is a clean build, then please ensure port.c is getting built as you expect it to be, then post the errors that are generated once you are 100% sure it is being built.

Regards.

roberto-plus wrote on Monday, December 09, 2013:

Sorry, I don’t understand where I must put port.c.
I inculded path in “Includes” (in path and symbols) and now I included port.c also in src.
Where is my fault?

Here there is a build.
https://gist.github.com/anonymous/7874243

Thanks a lot

rtel wrote on Monday, December 09, 2013:

That looks better. See my comments below:

C:\R\workspace\DaUDPaRTOS\lwip_echo_server_0\Debug/…/src/heap_3.c:105: undefined
reference to `vApplicationMallocFailedHook’

This is complaining that you have configUSE_MALLOC_FAILED_HOOK set to 1 in FreeRTOSConfig.h, but have not defined a function called vApplicationMallocFailedHook() in your code.

http://www.freertos.org/a00016.html

./src/port.o: In function xPortStartScheduler': C:\R\workspace\DaUDPaRTOS\lwip_echo_server_0\Debug/../src/port.c:277: undefined reference to vApplicationSetupTimerInterrupt’

Search for vApplicationSetupTimerInterrupt() on the documentation page for your port:
http://www.freertos.org/Free-RTOS-for-Xilinx-MicroBlaze-on-Spartan-6-FPGA.html

C:\R\workspace\DaUDPaRTOS\lwip_echo_server_0\Debug/…/src/port.c:288: undefined reference
to `vPortStartFirstTask’

vPortStartFirstTask() is defined in port.S, which is in the same directory and port.c, and must also be included in your build.

./src/port.o: In function vPortYield': C:\R\workspace\DaUDPaRTOS\lwip_echo_server_0\Debug/../src/port.c:315: undefined reference to VPortYieldASM’

vPortYieldASM is also in Port.S

./src/port.o: In function vPortTickISR': C:\R\workspace\DaUDPaRTOS\lwip_echo_server_0\Debug/../src/port.c:424: undefined reference to vApplicationClearTimerInterrupt’

Refer to port documentation page - link provided already above.

./src/port.o: In function prvInitialiseInterruptController': C:\R\workspace\DaUDPaRTOS\lwip_echo_server_0\Debug/../src/port.c:447: undefined reference to vPortExceptionsInstallHandlers’

Refer to port documentation page - link provided already above.

./src/tasks.o: In function vTaskStartScheduler': C:\R\workspace\DaUDPaRTOS\lwip_echo_server_0\Debug/../src/tasks.c:1239: undefined reference to vMainConfigureTimerForRunTimeStats’

./src/tasks.o: In function uxTaskGetSystemState': C:\R\workspace\DaUDPaRTOS\lwip_echo_server_0\Debug/../src/tasks.c:1510: undefined reference to ulMainGetRunTimeCounterValue’

./src/tasks.o: In function xTaskIncrementTick': C:\R\workspace\DaUDPaRTOS\lwip_echo_server_0\Debug/../src/tasks.c:1683: undefined reference to ulMainGetRunTimeCounterValue’

These three are complaining that you have your FreeRTOSConfig.h header file set to use run time stats gathering, but have not provided the kernel with the source of the run time counter.

http://www.freertos.org/rtos-run-time-stats.html

./src/tasks.o: In function vTaskSwitchContext': C:\R\workspace\DaUDPaRTOS\lwip_echo_server_0\Debug/../src/tasks.c:1842: undefined reference to vApplicationStackOverflowHook’

This is complaining that you have configCHECK_FOR_STACK_OVERFLOW set to a non-zero value, but you have not provided the vApplicationStackOverflowHook() function.

http://www.freertos.org/Stacks-and-stack-overflow-checking.html

C:\R\workspace\DaUDPaRTOS\lwip_echo_server_0\Debug/…/src/tasks.c:2088: undefined
reference to `vApplicationIdleHook’

This is complaining that you have configUSE_IDLE_HOOK set to a non-zero value in FreeRTOSConfig.h, but have not provided the vApplicationIdleHook() function - see the same link already provided somewhere above to the kernel hook functions documentation page.

A lot of these look like you have taken a FreeRTOSConfig.h header file from an application that defined quite a rich set of functionality, but your current application does not currently provide the same hooks into that functionality.

Regards.

roberto-plus wrote on Tuesday, December 10, 2013:

Thanks a lot.
I cleaned errors outputs. Now the error is one and it refers to interrupt_hendler.
It says there is a multiple definition of `_interrupt_handler’.
In fact There are two errors in the project, one in portasm.c and one in BSP–>libsrcstandalone_v3_01_a–>src–>microblaze_interrupt_handler.c

C:\R\workspace\DaUDPaRTOS\lwip_echo_server_bsp_0\microblaze_0\libsrc\standalone_v3_01_a\src/microblaze_interrupt_handler.c:79: multiple definition of `_interrupt_handler’
./src/portasm.o:C:\R\workspace\DaUDPaRTOS\lwip_echo_server_0\Debug/…/src/portasm.S:272: first defined here
c:\xilinx\13.2\ise_ds\edk\gnu\microblaze\nt\bin…\lib\gcc\microblaze-xilinx-elf\4.1.2…\microblaze-xilinx-elf\bin\ld.exe: Disabling relaxation: it will not work with multiple definitions
collect2: ld returned 1 exit status
make: *** [lwip_echo_server_0.elf] Error 1

What can I do?

Regards.

rtel wrote on Tuesday, December 10, 2013:

You need to use the one defined in port.S - so presumably need to exclude the file that contains the other implementation from the build - but check what the official demo project does in this respect.

Regards.

roberto-plus wrote on Wednesday, December 11, 2013:

sorry, maybe I resolved some error.
Now, only the port.c has error.
The error is show below.
C:\R\workspace\DaUDPaRTOS\lwip_echo_server_0\Debug/…/src/port.c:284: undefined reference to vPortStartFirstTask' ./src/port.o: In function vPortYield’:
C:\R\workspace\DaUDPaRTOS\lwip_echo_server_0\Debug/…/src/port.c:311: undefined reference to `VPortYieldASM’
collect2: ld returned 1 exit status
make: *** [lwip_echo_server_0.elf] Error 1

What can I do?
Sorry I’m e new user and I don’t Know how I can resolve alone.

Thanks

rtel wrote on Wednesday, December 11, 2013:

Both these functions are defined in port.S - are you building port.S?

Regards.

roberto-plus wrote on Thursday, December 12, 2013:

No, I don’t have this file. I searched into previous (correct) projects but it is missing.
In all project I’ve only portasm.S

Regards

rtel wrote on Thursday, December 12, 2013:

Sorry - I meant portasm.S. Have you included that file. If you look in the file you will see it implements the functions the linker is complaining are missing.

Regards.

roberto-plus wrote on Thursday, December 12, 2013:

Yes, I included portasm.S and I find the implementation as above:

.text
.align  2

vPortStartFirstTask:

portRESTORE_CONTEXT

You can see my portasm.S at link above:
https://gist.github.com/anonymous/7925419

Regards.

roberto-plus wrote on Friday, December 13, 2013:

Sorry, I think that I resolved somethings.
Now i have only a problem with interrupt_hendler, because maybe both portasm.c and microblaze_interrupt_hendler.c want to handle interrupt.
Is it correct?
How can i resolve?

C:\R\workspace\PORTRTOS2\lwip_echo_server_bsp_0\microblaze_0\libsrc\standalone_v3_01_a\src/microblaze_interrupt_handler.c:79: multiple definition of `_interrupt_handler’
./src/portasm.o:C:\R\workspace\PORTRTOS2\lwip_echo_server_0\Debug/…/src/portasm.S:272: first defined here
c:\xilinx\13.2\ise_ds\edk\gnu\microblaze\nt\bin…\lib\gcc\microblaze-xilinx-elf\4.1.2…\microblaze-xilinx-elf\bin\ld.exe: Disabling relaxation: it will not work with multiple definitions
collect2: ld returned 1 exit status
make: *** [lwip_echo_server_0.elf] Error 1

Regards

regards

rtel wrote on Friday, December 13, 2013:

Circle back in the thread - you have already asked this and it has already been answered
http://sourceforge.net/p/freertos/discussion/382005/thread/57a9ea8f/#f754

Regards.

roberto-plus wrote on Friday, December 13, 2013:

Sorry, I can’t understand.
In a correct project I see that in a portasm.S the handler of interrupt is MICROBLAZE, because in above line configINTERRUPT_CONTROLLER_TO_USE is a deviceID of Microblaze
/* The parameter to the interrupt handler. */
ori r5, r0, configINTERRUPT_CONTROLLER_TO_USE

so the different with this project is in platform_config.h that is not blank but contains the above lines.

#define PLATFORM_EMAC_BASEADDR XPAR_ETHERNET_LITE_BASEADDR

#define PLATFORM_TIMER_BASEADDR XPAR_AXI_TIMER_0_BASEADDR
#define PLATFORM_TIMER_INTERRUPT_INTR XPAR_MICROBLAZE_0_INTC_AXI_TIMER_0_INTERRUPT_INTR
#define PLATFORM_TIMER_INTERRUPT_MASK (1 << XPAR_MICROBLAZE_0_INTC_AXI_TIMER_0_INTERRUPT_INTR)

so the error is with timer_interrupt

You can see my portasm.S at :
https://gist.github.com/anonymous/7946037

I have this file microblaze_interrupt_handler.c that contains a
void __interrupt_handler (void) attribute ((interrupt_handler));

but I don’t know how to risolve.

If you prefer i can attach enteire preject :slight_smile:
Regards