sam7x256webserver_demo based problem

powerf wrote on Thursday, June 04, 2009:

Hi
I am using olimex sam7ex256 EB and Eclipse SR1 with yagarto 4.3.3, and I have quite weird problem. I have created my own freertos application using some of the files which were used in the ethernet/usb example for at91sam7x256 Eclipse.
Those files are: makefile, boot.s, atmel-rom.lds, kernel files and includes, Cstartup_sam7.c, heap2.c, port.c, portISR.c, portmacro.h, main.c
I’ve added my code, like creation on 2 simple tasks and communication between them and interrupt. And everything works fine, but only when in one of my source .c files there are added two lines of code, which normally were implemented in ethernet example in uIP_Task.c file in function vProcessInput(). These two lines of code are (after my modification to limit this code as much as possible) :
for example:

void MyFunc (void)
{
          char *c;
    if(strstr( c, "LED0=1" ) != NULL ){}
}

When those two lines are commented, project doesnt work at all, and when i run debugger, it ends id .dabt section

What is wrong? I do not use any of ethernet example files at all, those files and paths are also deleted from makefile and there is no connection between my application and demo apps.
Can someone tell me why is this happening? :]

rtel wrote on Thursday, June 04, 2009:

A couple of possibilities spring to mind.

1) In the code the variable c is uninitialised so could contain any value and point to any memory - if the memory is invalid then you could get a data abort.  Even if c happens to point to valid memory strstr will scan through the memory until it happens to find a null terminator which could again take the data pointer into invalid memory.  This is just a C thing, nothing to do with FreeRTOS.

2) strstr is a standard library function which could potentially use masses of stack, so you could just be getting a stack overflow.  See http://www.freertos.org/Stacks-and-stack-overflow-checking.html .

Regards.

powerf wrote on Wednesday, July 22, 2009:

Thank you for your answer Richard, unfortunately i meant something different in my previous post :slight_smile:

Problem is that I do not want (and do not need) to use the code presented in my previous post, but i am forced to add it, because without it my application ends in .dabt section.

Let me describe it in details what I mean.
My application was created basing on the sam7s_webserver example, but I do not have any of the webserver functionalities in it. From this demo project ii have taken such files:
makefile,
boot.s,
atmel-rom.lds,
kernel files and includes,
Cstartup_sam7.c,
heap2.c,
port.c,
portISR.c,
portmacro.h,

After i have created my own tasks etc I run my application and it entered the .dabt section.

Then i have started to analize the webserver project to discover why it is working and my application isn’t.
Then I noticed that if I comment out:
        1. creation of the “vuIP_Task” in main.c  :
//xTaskCreate(vuIP_Task, “uIP”,mainUIP_TASK_STACK_SIZE,NULL,mainUIP_PRIORITY,NULL)

        2. vProcessInput() function code in uIP_Task.c file
void vProcessInput( char *pcInput )
{
    /* Turn the LED on or off depending on the checkbox status. */

    //c = strstr( pcInput, "?" );
    //if( c )
    //{
        //if( strstr( c, "LED0=1" ) != NULL )
        //{
            //vParTestSetLED( 3, 0 );
        //}
        //else
        //{
        //    vParTestSetLED( 3, 1 );
        //}       
    //}
}

the other task in this project (USBtask)  stops working and program ends in .dabt.

Then i modified and limited the code of vProcessInput( ) function to what is presented in my first post and added it  to my application to MyFunc() function and then it worked fine. Note that this function is not used  in my application, it is only defined.

Without these two lines of code : char *c; 
                                                         if(strstr( c, "LED0=1" ) != NULL ){}

my application doesnt’ work. It is very strange and so far I have to add those lines to every of my applications because without them they do not work.

Anyone have any reasonable explanation to this? :slight_smile:

rtel wrote on Wednesday, July 22, 2009:

I’m not really following, but I think you have based your application on one that uses the idle hook (or was it the tick hook?) to trigger USB transfers.  If you are not starting the USB task then the queue used to unblock the USB task will not get created and the hook function attempting to write to the queue will cause a crash.

Could this be the route of your problem?  Try setting configUSE_IDLE_HOOK to 0 in FreeRTOSConfig.h.  Also try setting configUSE_TICK_HOOK to 0.

Regards.

powerf wrote on Wednesday, July 22, 2009:

Thank you for your answer Richard, unfortunately i meant something different in my previous post :slight_smile:

Problem is that I do not want (and do not need) to use the code presented in my previous post, but i am forced to add it, because without it my application ends in .dabt section.

Let me describe it in details what I mean.
My application was created basing on the sam7s_webserver example, but I do not have any of the webserver functionalities in it. From this demo project ii have taken such files:
makefile,
boot.s,
atmel-rom.lds,
kernel files and includes,
Cstartup_sam7.c,
heap2.c,
port.c,
portISR.c,
portmacro.h,

After i have created my own tasks etc I run my application and it entered the .dabt section.

Then i have started to analize the webserver project to discover why it is working and my application isn’t.
Then I noticed that if I comment out:
        1. creation of the “vuIP_Task” in main.c  :
//xTaskCreate(vuIP_Task, “uIP”,mainUIP_TASK_STACK_SIZE,NULL,mainUIP_PRIORITY,NULL)

        2. vProcessInput() function code in uIP_Task.c file
void vProcessInput( char *pcInput )
{
    /* Turn the LED on or off depending on the checkbox status. */

    //c = strstr( pcInput, "?" );
    //if( c )
    //{
        //if( strstr( c, "LED0=1" ) != NULL )
        //{
            //vParTestSetLED( 3, 0 );
        //}
        //else
        //{
        //    vParTestSetLED( 3, 1 );
        //}       
    //}
}

the other task in this project (USBtask)  stops working and program ends in .dabt.

Then i modified and limited the code of vProcessInput( ) function to what is presented in my first post and added it  to my application to MyFunc() function and then it worked fine. Note that this function is not used  in my application, it is only defined.

Without these two lines of code : char *c; 
                                                         if(strstr( c, "LED0=1" ) != NULL ){}

my application doesnt’ work. It is very strange and so far I have to add those lines to every of my applications because without them they do not work.

Anyone have any reasonable explanation to this? :slight_smile: