# Microblaze Port does not compile \[edk 9.2\]

**URL:** <https://forums.freertos.org/t/microblaze-port-does-not-compile-edk-9-2/5095>\
**Category:** Kernel\
**Created:** [May 29, 2008, 12:32pm UTC](https://forums.freertos.org/t/microblaze-port-does-not-compile-edk-9-2/5095 "2008-05-29T12:32:36Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 29, 2008, 12:32pm UTC](https://forums.freertos.org/t/microblaze-port-does-not-compile-edk-9-2/5095/1 "2008-05-29T12:32:36Z")

</div>

**[threinbacher](https://sourceforge.net/u/threinbacher/)** wrote on [Thursday, May 29, 2008](https://sourceforge.net/p/freertos/discussion/382005/thread/e246c27d/#bbfb):

Hi everybody,

I’m having currently a microblaze design in front of me. I already included a timer and a interrupt controller, both worked fine (without FreeRTOS). Therefore the timer and interrupt setup seems to be correct.

After adding FreeRTOS Sources to the project it couldn’t even manage to compile all the files.

In the File port.c:

/src/freeRTOS/portable/port.c: In function ‘vPortYield’:  
/src/freeRTOS/portable/port.c:253: error: conflicting type qualifiers for ‘uxCriticalNesting’  
/src/freeRTOS/portable/port.c:85: error: previous definition of ‘uxCriticalNesting’ was here  
make: \*\*\* [TestApp\_Memory/executable.elf] Error 1

Line 85 of port.c looks like:  
/\* Counts the nesting depth of calls to portENTER\_CRITICAL().&nbsp; Each task  
maintains it’s own count, so this variable is saved as part of the task  
context. \*/  
volatile unsigned portBASE\_TYPE uxCriticalNesting = portINITIAL\_NESTING\_VALUE;

An on Line 253 we can find something like that:  
/\* Perform the context switch in a critical section to assure it is  
not interrupted by the tick ISR.&nbsp; It is not a problem to do this as  
each task maintains it’s own interrupt status. \*/  
portENTER\_CRITICAL();  
&nbsp;&nbsp;&nbsp; /\* Jump directly to the yield function to ensure there is no  
&nbsp;&nbsp;&nbsp; compiler generated prologue code. \*/  
&nbsp;&nbsp;&nbsp; asm volatile (&nbsp;&nbsp;&nbsp; “bralid r14, VPortYieldASM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \n\t”   
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; “or r0, r0, r0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \n\t” );  
portEXIT\_CRITICAL();

Do i have to set some special compiler settings to get FreeRTOS compiled? Any Help is appreciated!

Greetings from Vienna,

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [May 29, 2008, 12:46pm UTC](https://forums.freertos.org/t/microblaze-port-does-not-compile-edk-9-2/5095/2 "2008-05-29T12:46:44Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Thursday, May 29, 2008](https://sourceforge.net/p/freertos/discussion/382005/thread/e246c27d/#bbfb/9f45):

There has been a long discussion over the last few days about the Microblaze port, which was created (and still functions under) EDK V7.1 but not under later versions.&nbsp; There are two issues:

1) This is the easy one to fix.&nbsp; The later versions of GCC generate warnings for code the old version was perfectly happy to let pass.&nbsp; The code currently in the [FreeRTOS.org](http://FreeRTOS.org) Subversion repository have fixed all these.&nbsp; The warning you highlight above is simply that the original declaration of the variable has a volatile qualifier, whereas the extern declaration in the macro does not.&nbsp; You can add the volatile qualifier to the extern declaration and the error will go away.

2) More difficult is the change in the way interrupts are installed executed in the later versions of the EDK.&nbsp; This is going to require a code change to fix.&nbsp; It might be that the contributor to the other thread has this fixed already.&nbsp; If you look a couple of threads down the list you will see the one I’m referring to (it has 20 or so replies).&nbsp;&nbsp; I hope to get this updated in the release soon but its not going to be in the next few days.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 29, 2008, 1:34pm UTC](https://forums.freertos.org/t/microblaze-port-does-not-compile-edk-9-2/5095/3 "2008-05-29T13:34:06Z")

</div>

**[threinbacher](https://sourceforge.net/u/threinbacher/)** wrote on [Thursday, May 29, 2008](https://sourceforge.net/p/freertos/discussion/382005/thread/e246c27d/#bbfb/9f45/2126):

Hi,

Thanks a lot for your detailed reply.

Yeah - i read the Microblaze Thread. Even though i think my setup is a bit differnt, since i have already the timer up and running on my system.

Unfortunatelly, i still could’nt manage to get FreeRTOS compiled:

I fixed in portmacro.h :  
from  
extern volatile unsigned portBASE\_TYPE uxCriticalNesting;&nbsp;&nbsp;&nbsp;  
to  
extern unsigned portBASE\_TYPE uxCriticalNesting;&nbsp;&nbsp;&nbsp;

But i still got a bunch of other warnings/errors regarding

tmp/cctx8Z9x.o: In function `xCoRoutineCreate’:  
/src/freeRTOS/croutine.c:118: undefined reference to `pvPortMalloc’

And a lot more - all complaining about undefined references to pvPortMalloc, vPortFree.

Hmm, did i forgot something?

greetings from Vienna,

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 29, 2008, 1:52pm UTC](https://forums.freertos.org/t/microblaze-port-does-not-compile-edk-9-2/5095/4 "2008-05-29T13:52:47Z")

</div>

**[woops\_](https://sourceforge.net/u/woops_/)** wrote on [Thursday, May 29, 2008](https://sourceforge.net/p/freertos/discussion/382005/thread/e246c27d/#bbfb/9f45/2126/e0a1):

Most likely forgot to include heap\_x.c. look in the source\portable\memmang directory.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 29, 2008, 2:35pm UTC](https://forums.freertos.org/t/microblaze-port-does-not-compile-edk-9-2/5095/5 "2008-05-29T14:35:32Z")

</div>

**[threinbacher](https://sourceforge.net/u/threinbacher/)** wrote on [Thursday, May 29, 2008](https://sourceforge.net/p/freertos/discussion/382005/thread/e246c27d/#bbfb/9f45/2126/e0a1/36ec):

hi,

@woops\_

That worked fine for me. Thanks a lot.

But, i still didn’t manage to compile the sources:

tmp/ccktBDYh.o: In function `xTaskResumeAll’:  
/tasks.c:1145: undefined reference to `traceTASK\_SWITCHED\_OUT’  
and  
/tmp/ccGwpPZG.o: In function `Toggler2’:  
/application.c:75: undefined reference to `vParTestInitialise’

application.c:

/\* Board Includes \*/  
#include "xparameters.h"  
#include "stdio.h"  
#include "xutil.h"  
#include "xgpio.h"  
#include "xtmrctr.h"  
#include "xintc.h"

/\* Scheduler includes. \*/  
#include "FreeRTOS.h"  
#include "task.h"

/\* Hardware library includes. \*/  
#include \<xintc.h\>

#define mainTINY\_STACK&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 70  
#define LED\_CHANNEL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1

static void prvSetupHardware( void );  
static void Toggler1( void \*pvParameters );  
static void Toggler2( void \*pvParameters );  
static void initGPIO( void );

XGpio GpioOutput;&nbsp;&nbsp; /\* The driver instance for GPIO Device configured as O/P \*/

// Create all the tasks, then start the scheduler.  
int main (void)  
{  
&nbsp;&nbsp;&nbsp; print("Starting OS now! \r\n");

&nbsp;&nbsp;&nbsp; portDISABLE\_INTERRUPTS();

&nbsp;&nbsp;&nbsp; prvSetupHardware();

&nbsp;&nbsp;&nbsp; xTaskCreate( Toggler1, "Tog1", mainTINY\_STACK, ( void \* ) 10, tskIDLE\_PRIORITY+3, NULL );  
&nbsp;&nbsp;&nbsp; xTaskCreate( Toggler2, "Tog2", mainTINY\_STACK, ( void \* ) 20, tskIDLE\_PRIORITY, NULL );

&nbsp;&nbsp;&nbsp; /\* Finally start the scheduler. \*/  
&nbsp;&nbsp;&nbsp; vTaskStartScheduler();

&nbsp;&nbsp;&nbsp; /\* Should not get here as the processor is now under control of the scheduler! \*/

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;  
}  
/\*-----------------------------------------------------------\*/

static void Toggler1( void \*pvParameters )  
{  
/\* The parameters are not used. \*/  
( void ) pvParameters;

/\* Block for 500ms. \*/  
const portTickType xDelay = 500 / portTICK\_RATE\_MS;

&nbsp;&nbsp;&nbsp; for( ;; )  
&nbsp;&nbsp;&nbsp; {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XGpio\_DiscreteWrite(&GpioOutput, LED\_CHANNEL, ~(1 \<\< 3));  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vTaskDelay( xDelay );  
&nbsp;&nbsp;&nbsp; }  
}

static void Toggler2( void \*pvParameters )  
{  
/\* The parameters are not used. \*/  
( void ) pvParameters;

/\* Block for 1s. \*/  
const portTickType xDelay = 1000 / portTICK\_RATE\_MS;

&nbsp;&nbsp;&nbsp; for( ;; )  
&nbsp;&nbsp;&nbsp; {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XGpio\_DiscreteWrite(&GpioOutput, LED\_CHANNEL, ~(1 \<\< 1));  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vTaskDelay( xDelay );  
&nbsp;&nbsp;&nbsp; }  
}  
/\*-----------------------------------------------------------\*/

static void prvSetupHardware( void )  
{  
&nbsp;&nbsp;&nbsp; XIntc\_mMasterEnable( XPAR\_OPB\_INTC\_0\_BASEADDR );

&nbsp;&nbsp;&nbsp; /\* Initialise the GPIO used for the LED’s. \*/  
&nbsp;&nbsp;&nbsp; vParTestInitialise();  
}  
/\*-----------------------------------------------------------\*/

static void initGPIO( void )  
{  
&nbsp;&nbsp;&nbsp; XStatus Status;

&nbsp;&nbsp;&nbsp; Status = XGpio\_Initialize(&GpioOutput, XPAR\_LEDS\_4BIT\_DEVICE\_ID);

&nbsp;&nbsp;&nbsp; // Set the direction for all signals to be outputs  
&nbsp;&nbsp;&nbsp; XGpio\_SetDataDirection(&GpioOutput, LED\_CHANNEL, 0x0);

&nbsp;&nbsp;&nbsp; // Set the GPIO outputs to high  
&nbsp;&nbsp;&nbsp; XGpio\_DiscreteWrite(&GpioOutput, LED\_CHANNEL, 0x0);  
}

Again, any ideas on that?

Greetings from Vienna,

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 29, 2008, 3:33pm UTC](https://forums.freertos.org/t/microblaze-port-does-not-compile-edk-9-2/5095/6 "2008-05-29T15:33:17Z")

</div>

**[threinbacher](https://sourceforge.net/u/threinbacher/)** wrote on [Thursday, May 29, 2008](https://sourceforge.net/p/freertos/discussion/382005/thread/e246c27d/#bbfb/9f45/2126/e0a1/36ec/aca5):

Hi all,

Found a stupid bug in the application.c posted above.

Finally, there is still one error that i can’t get rid of:

undefined reference to `traceTASK\_SWITCHED\_OUT’ in tasks.c:1145

tasks.c:1145 looks like:

What the hell is wrong in here? - Any help appreciated.

greetings from vienna,

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 29, 2008, 3:34pm UTC](https://forums.freertos.org/t/microblaze-port-does-not-compile-edk-9-2/5095/7 "2008-05-29T15:34:23Z")

</div>

**[threinbacher](https://sourceforge.net/u/threinbacher/)** wrote on [Thursday, May 29, 2008](https://sourceforge.net/p/freertos/discussion/382005/thread/e246c27d/#bbfb/9f45/2126/e0a1/36ec/aca5/b79d):

tasks.c:1145 looks like:

&nbsp;&nbsp;&nbsp; }  
-\>&nbsp;&nbsp;&nbsp; portEXIT\_CRITICAL();

&nbsp;&nbsp;&nbsp; return xAlreadyYielded;  
}

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [May 29, 2008, 3:49pm UTC](https://forums.freertos.org/t/microblaze-port-does-not-compile-edk-9-2/5095/8 "2008-05-29T15:49:19Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Thursday, May 29, 2008](https://sourceforge.net/p/freertos/discussion/382005/thread/e246c27d/#bbfb/9f45/2126/e0a1/36ec/aca5/e896):

Source/include/FreeRTOS.h should include the lines:

#ifndef traceTASK\_SWITCHED\_OUT  
&nbsp;&nbsp;&nbsp; /\* Called before a task has been selected to run.&nbsp; pxCurrentTCB holds a pointer  
&nbsp;&nbsp;&nbsp; to the task control block of the task being switched out. \*/  
&nbsp;&nbsp;&nbsp; #define traceTASK\_SWITCHED\_OUT()  
#endif

to #define the call away.

Did you base your project on the Xilinx PowerPC port?&nbsp; If so then traceTASK\_SWITCHED\_OUT is used for the floating point register saves.&nbsp; Check you don’t have fpu\_macros.h included within FreeRTOSConfig.h.

Regards

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 29, 2008, 4:24pm UTC](https://forums.freertos.org/t/microblaze-port-does-not-compile-edk-9-2/5095/9 "2008-05-29T16:24:14Z")

</div>

**[threinbacher](https://sourceforge.net/u/threinbacher/)** wrote on [Thursday, May 29, 2008](https://sourceforge.net/p/freertos/discussion/382005/thread/e246c27d/#bbfb/a7e6):

@ Richard

Your hint did the trick. -\> Thanks a lot.

It seems that the system with the current interrupt handling executes a reset after the other.  
Seems that i run into the same prMore difficult is the change in the way interrupts are installed executed in the later versions of the EDK. This is going to require a code change to fix. It might be that the contributor to the other thread has this fixed already. If you look a couple of threads down the list you will see the one I’m referring to (it has 20 or so replies). I hope to get this updated in the release soon but its not going to be in the next few days. oblem than the other guys here in the forum.

I can provide some code to initialize Timer and the Interrupt Controller for exk 9.2 if needed…

greetings,

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 1, 2008, 6:58am UTC](https://forums.freertos.org/t/microblaze-port-does-not-compile-edk-9-2/5095/10 "2008-06-01T06:58:22Z")

</div>

**[nxdefiant](https://sourceforge.net/u/nxdefiant/)** wrote on [Sunday, June 01, 2008](https://sourceforge.net/p/freertos/discussion/382005/thread/e246c27d/#bbfb/68af):

No sorry, I havn’t fixed it yet. I still have a problem on the stack. I was hoping to find some time on Monday to debug it.  
When jumping back from the ISR, I currently miss the return address by two instructions.
