Task seems to stop at 2nd call

Hello, i finally got the RTOS Code running on my SAM7S256 using gcc-tools. I tried a simple test, by having 2 processes writing to the UART. …..     printf("Task a creation %d r", xTaskCreate(( void * ) test_taskA, ( signed portCHAR * ) "Task A", 500, NULL, 3, NULL ));     printf("Task b creation %d r", xTaskCreate(( void * ) test_taskB, ( signed portCHAR * ) "Task B", 500, NULL, 3, NULL ));     vTaskStartScheduler(); ….. static void test_taskA(void) {      int i;     while(1)   {            // taskENTER_CRITICAL(); // no solution :/           uart0_putc(’a’);            //     taskEXIT_CRITICAL();           for(i=0;i<0xfffff;i++);   } } ….. static void test_taskB(void) {      int i;   while(1)   {               uart0_putc(’b’);          for(i=0;i<0xfffff;i++);   } } The output is as follows: " Task a creation 1 Task b creation 1 bbbbbbbbbbbbbaaaaaaaaaaa" The MCU hangs now and is in an "Prefetch Abort exception" endless loop. I tried different startup codes (for Mode stack init …) with the same result. What could be the Problem? Thank you very much!

Task seems to stop at 2nd call

Okey, finally i got the command which causes the prefetch abort. It’s in the portRESTORE_CONTEXT() macro in portmacro.h. #define portRESTORE_CONTEXT()                                            {                                                                        extern volatile void * volatile pxCurrentTCB;                            extern volatile unsigned portLONG ulCriticalNesting;                                                                                                /* Set the LR to the task stack. */                                        asm volatile (                                                            "LDR        R0, =pxCurrentTCB                                nt"        "LDR        R0, [R0]                                        nt"        "LDR        LR, [R0]                                        nt"                                                                                /* The critical nesting depth is the first item on the stack. */        /* Load it into the ulCriticalNesting variable. */                        "LDR        R0, =ulCriticalNesting                            nt"        "LDMFD    LR!, {R1}                                            nt"        "STR        R1, [R0]                                        nt"                                                                                /* Get the SPSR from the stack. */                                        "LDMFD    LR!, {R0}                                            nt"        "MSR        SPSR, R0                                        nt"                                                                                /* Restore all system mode registers for the task. */                    "LDMFD    LR, {R0-R14}^                                        nt"        "NOP                                                        nt"                                                                                /* Restore the return address. */                                        "LDR        LR, [LR, #+60]                                    nt"                                                                                /* And return – correcting the offset in the LR to obtain the */        /* correct address. */                                                    "SUBS    PC, LR, #4                                            nt"        );                                                                        ( void ) ulCriticalNesting;                                                ( void ) pxCurrentTCB;                                                } Here the prefetchabort occours: http://cashfox.net/prefetchabort.JPG Can anyone help me now? Thank you!

Task seems to stop at 2nd call

Okey i found a SOLUTION :) I used the startup and linker file from the SAM7X – Eclipse Sample Projekt. I think the Problem is, that my old startup code did support nested interrupts. But can someone help me with an explanation what could go wrong if the startupcode supports nested interrupts?

Task seems to stop at 2nd call

The startup code must either configure the IRQ handler to vector directly to the interrupt handler or vector to a common entry point that contains the context saving code. Examples are provided of both methods. In either case the first code executed after the jump must be the FreeRTOS.org context save code, not any compiler provided intermediary code. This is to ensure that the task finds the stack in exactly the state it expects when exiting an ISR. The main reason for this is that a task can be placed into the blocked state from a call to Yield at the task level, but start executing again after being moved out of the blocked state within an ISR.  In both cases it needs to have the stack popped back into the registers in exactly the same way. You can implement nesting of interrupts by modifying the code after the saving of the context only.  It is unlikely that nesting of interrupts would be required though.  See http://www.freertos.org/FAQISR.html#Nest for more info. Regards.