Page 1 of 3

no <sys/stat.h> and <sys/types.h>

Posted: Sat Jul 27, 2013 2:27 pm
by delphi
Hello,
I am trying to use lwip. It's seems need the syscalls.h in various folder. However, the syscalls.h requests <sys/stat.h> and <sys/types.h> which are not available in my keil MDK environment.
Can someone help?
Delphi

Re: no <sys/stat.h> and <sys/types.h>

Posted: Sat Jul 27, 2013 2:30 pm
by Giovanni
You should not use syscalls.h, it is for newlib support.

Giovanni

Re: no <sys/stat.h> and <sys/types.h>

Posted: Sat Jul 27, 2013 2:42 pm
by delphi
But there is a lot of function call needed by the files of lwip are in sys calls.h. I attached a linking error list. Any idea?


Delphi

Re: no <sys/stat.h> and <sys/types.h>

Posted: Sat Jul 27, 2013 2:54 pm
by Giovanni
You are not including all the required files, open an existing demo and look at the makefiles.

Giovanni

Re: no <sys/stat.h> and <sys/types.h>

Posted: Sat Jul 27, 2013 4:40 pm
by delphi
Giovanni, Thanks for your advice. After I read the makefiles from the demo, I can compile my codes without error but it doesn't work. And there is a thread which is blinking the leds also stopped.
I try to make it simple and clear. I go back to my previous project which blinking leds in separate threads only(no LWIP in this project). once i turn the HAL_USE_MAC to TRUE, the leds don't blink.
And the leds blink again when i set the HAL_USE_MAC to FALSE. Any idea?
Delphi

Re: no <sys/stat.h> and <sys/types.h>

Posted: Sat Jul 27, 2013 4:44 pm
by Giovanni
Using the debugger, where it stops while enabling the MAC? most likely during PHY initialization. What board are you using? are your board files configured correctly for the PHY you are using?

Giovanni

Re: no <sys/stat.h> and <sys/types.h>

Posted: Sat Jul 27, 2013 4:54 pm
by delphi
My board is STM32F4 Discovery and the PHY is DP83848. Should I set the Alternative function by my self or the init function of MAC will set for me? Will try debug tool tomorrow since it is almost mid-night in Hong Kong. Thanks anyway.
Delphi

Re: no <sys/stat.h> and <sys/types.h>

Posted: Sat Jul 27, 2013 4:58 pm
by Giovanni
Drivers never change pin settings by themselves, you need to create board files or change the settings at runtime.

Probably if you search the forum you will find board files for that combination (google search recommended, the forum search is broken).

Giovanni

Re: no <sys/stat.h> and <sys/types.h>

Posted: Sun Jul 28, 2013 3:21 pm
by delphi
I did some debug and setups in board.h today. Well the LEDs blink again, but the board still doesn't reply ARP when i ping it. I read the codes in lwipthread.c, at the bottom of the file there is a switch case for determinate if the frame is IP frame or ARP frame,but it looks doesn't handle any. Should i add codes here? or Am I miss anything?

Delphi

Code: Select all

switch (htons(ethhdr->type)) {
        /* IP or ARP packet? */
        case ETHTYPE_IP:
        case ETHTYPE_ARP:
#if PPPOE_SUPPORT
        /* PPPoE packet? */
        case ETHTYPE_PPPOEDISC:
        case ETHTYPE_PPPOE:
#endif /* PPPOE_SUPPORT */
          /* full packet send to tcpip_thread to process */
          if (thisif.input(p, &thisif) == ERR_OK)
            break;
          LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
        default:
          pbuf_free(p);

Re: no <sys/stat.h> and <sys/types.h>

Posted: Sun Jul 28, 2013 4:14 pm
by delphi
I tried to comment out the lwipthread and wrote a test thread to check if the MAC driver is well configured. The thread init the MAC 's hard address and poll the link status then show on the LEDs. My code shown below

Code: Select all

static WORKING_AREA(waTH21,128);

static msg_t thFunc_MAC(void *arg)
{
   MACConfig MACConf;

   MACConf.mac_address[0] = 0xAA;
   MACConf.mac_address[1] = 0x55;
   MACConf.mac_address[2] = 0x13;
   MACConf.mac_address[3] = 0x37;
   MACConf.mac_address[4] = 0x01;
   MACConf.mac_address[5] = 0x10;
   
   macStart (&ETHD1, &MACConf);
   
   while(true)
   {
         if(macPollLinkStatus (&ETHD1))
            palSetPad(GPIOD, GPIOD_LED6);
         else
            palClearPad(GPIOD, GPIOD_LED6);
   }
}

It works. Once I plug the lan cable into the PHY the LED on, and it off when i unplug the cable. I am pretty sure my board files are configured properly. However, the LWIP still don't work. Anyone help?


Delphi