This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RM48L952: Problems with lwIP integration

Part Number: RM48L952
Other Parts Discussed in Thread: HALCOGEN, DP83640, TMDSRM48HDK

Hi,

I need to integrate lwIP in a project developed in IAR Embedded Workbench.

I started from the code example for the LWIP web server on the RM48 HDK (processors.wiki.ti.com/.../HALCoGen_Ethernet_Driver_and_lwIP_Integration_Demonstration) and it works fine while I'm using Code Composer Studio.  I created a new IAR project importing the files of the example and configuring HALCoGen for IAR system. I don't find building errors, but the example doesn't run. Is there anyone who has developed the same example in IAR?

Thanks.

  • Hello Smeet,

    The demo is just an example, and was not tested on IAR workbench. Where does the code hang up, sys_start.c, lwip driver, ISR, or exception vector?
  • Hi,

    I took the lwIP_Demo_v03 and I did three tests changing just the lwip_main.c and lwipopts.h:

    1. dynamic IP address, DHCP (original code)
    in lwip_main.c
    ipAddr = lwIPInit(0, macAddress, 0, 0, 0, IPADDR_USE_DHCP);
    in lwipopts.h
    #define LWIP_DHCP 1

    results of the test:
    HERCULES MICROCONTROLLERS
    Texas Instruments
    Little Endian device
    Initializing ethernet (DHCP)
    DEBUG - Getting PHY ID....SUCCESS
    DEBUG - Getting PHY Alive Status...SUCCESS
    DEBUG - Getting PHY Link Status...SUCCESS
    DEBUG - Setting up Link...SUCCESS
    ..DONE
    -------- ERROR INITIALIZING HARDWARE --------

    2. dynamic IP address, no DHCP
    in lwip_main.c
    ipAddr = lwIPInit(0, macAddress, 0, 0, 0, IPADDR_USE_DHCP);
    in lwipopts.h
    #define LWIP_DHCP 0

    results of the test:
    HERCULES MICROCONTROLLERS
    Texas Instruments
    Little Endian device
    Initializing ethernet (DHCP)
    DEBUG - Getting PHY ID....SUCCESS
    DEBUG - Getting PHY Alive Status...SUCCESS
    DEBUG - Getting PHY Link Status...SUCCESS
    DEBUG - Setting up Link...SUCCESS
    ..DONE
    -------- ERROR INITIALIZING HARDWARE --------

    3. static IP address, no DHCP
    in lwip_main.c
    uint8 ip_addr[4] = { 192, 168, 2, 44 };
    uint8 netmask[4] = { 255, 255, 252, 0 };
    uint8 gateway[4] = { 192, 168, 2, 254 };
    ipAddr = lwIPInit(0, macAddress,
    *((uint32_t *)ip_addr),
    *((uint32_t *)netmask),
    *((uint32_t *)gateway),
    IPADDR_USE_STATIC);
    in lwipopts.h
    #define LWIP_DHCP 0

    results of the test:
    HERCULES MICROCONTROLLERS
    Texas Instruments
    Little Endian device
    Initializing ethernet (DHCP)
    DEBUG - Getting PHY ID....SUCCESS
    DEBUG - Getting PHY Alive Status...SUCCESS
    DEBUG - Getting PHY Link Status...SUCCESS
    DEBUG - Setting up Link...SUCCESS
    ..DONE

    HERCULES MICROCONTROLLERS
    Texas Instruments
    Little Endian device
    Device IP Address: 192.168.2.44
    Webserver accessible @ http:\\192.168.2.44

    but if I try to ping the IP, the destination host is not attainable.

    The same three tests are all successful in CCS.

    Are there other tests I can try?

    Thanks
  • Hi,

    I found the problem. There was an error in the Endianness settings of the IAR project. Now I'm facing another problem with the same example.
    I set in Halcogen/PINMUX the RMII instead of the MII because I need to use this configuration and now I have the same problem both in CCS and IAR:

    1. dynamic IP address, DHCP (original code)
    results of the test:
    HERCULES MICROCONTROLLERS
    Texas Instruments
    Little Endian device
    Initializing ethernet (DHCP)
    DEBUG - Getting PHY ID....SUCCESS
    DEBUG - Getting PHY Alive Status...SUCCESS
    DEBUG - Getting PHY Link Status...SUCCESS
    DEBUG - Setting up Link...SUCCESS
    ..DONE
    -------- ERROR INITIALIZING HARDWARE --------

    2. static IP address, no DHCP
    results of the test: there are not errors on the serial but if I try to ping the IP, the destination host is not attainable.

    I also added the patch reported in the example link page but nothing changed.
    Am I missing some settings?

    Thanks
  • Hi Smeet,

    The default HW settings is for MII. If you want to use RMII, two HW changes on HDK should be make:

    1. Replace Y3 with a 50MHz oscillator. 25MHz OSC is required for MII, but 50MHz is needed for RMII.
    2. Populate R193 (10kohms) to pull RX_DV (pin 39 of DP83640) to high
  • Hi,

    I have not the required oscillator, I'm going to buy it and try. However, is the need of a 50 MHz oscillator for RMII a requirement related to the specific DP83640 driver or is it mandatory in general? Because my intent is to adapt the example to a different phy.

    Thanks
  • Hello Smeet,

    It is required for RMII mode. DP83640 needs to follow the requirements of the standards.
  • Hi,

    despite the changes, the problem is still present:

    Hardware: TMDSRM48HDK, J-link

    Development Environment: Code Composer Studio 8.1.0, HALCoGen 04.07.00

    Code:
    lwIP_Demo_v03 with the following patch:
    in phy_dp83640.h
    #define PHY_ID2 (3u)
    #define PHY_AUTONEG_ADV (4u)
    #define PHY_LINK_PARTNER_ABLTY (5u)
    +#define PHY_LINK_PARTNER_SPD (10u)
    #define PHY_TXTS (28u)
    #define PHY_RXTS (29u)
    ....
    extern uint64 Dp83640GetTimeStamp(uint32 mdioBaseAddr, uint32 phyAddr, phyTimeStamp_t type);
    extern void Dp83640EnableLoopback(uint32 mdioBaseAddr, uint32 phyAddr);
    extern void Dp83640DisableLoopback(uint32 mdioBaseAddr, uint32 phyAddr);
    +extern unsigned int Dp83640PartnerSpdGet(unsigned int mdioBaseAddr, unsigned int phyAddr, unsigned short *ptnerAblty);

    in phy_dp83640.c
    return timeStamp;
    }
    +/**
    + * \brief Reads the Link Partner Ability register of the PHY.
    + *
    + * \param mdioBaseAddr Base Address of the MDIO Module Registers.
    + * \param phyAddr PHY Adress.
    + * \param ptnerAblty The partner abilities of the EMAC
    + *
    + * \return status after reading \n
    + * TRUE if reading successful
    + * FALSE if reading failed
    + **/
    +unsigned int Dp83640PartnerSpdGet(unsigned int mdioBaseAddr,
    + unsigned int phyAddr,
    + unsigned short *ptnerAblty)
    +{
    + return (MDIOPhyRegRead(mdioBaseAddr, phyAddr, PHY_LINK_PARTNER_SPD,
    + ptnerAblty));
    +}

    in hdkif.c
    struct txch *txch;
    struct rxch *rxch;
    struct pbuf *p, *q;
    + unsigned short partnr_spd;

    hdkif = netif->state;
    ...
    /* Write the RX HDP for channel 0 */
    EMACRxHdrDescPtrWrite(hdkif->emac_base, (uint32)rxch->active_head, 0);
    -
    +
    + Dp83640PartnerSpdGet(hdkif->mdio_base, hdkif->phy_addr, &partnr_spd);
    + if((partnr_spd & 2)==0)
    + EMACRMIISpeedSet(hdkif->emac_base, (u32_t)EMAC_MACCONTROL_RMIISPEED);
    +
    EMACMIIEnable(hdkif->emac_base);

    HALCoGen settings: the same of the example with the exception of RMII enable under PINMUX tab instead of MII.

    IP settings (in lwip_main.c) and results:
    1. dynamic IP address, DHCP (original code) and dynamic IP address, no DHCP
    results of the test:
    HERCULES MICROCONTROLLERS
    Texas Instruments
    Little Endian device
    Initializing ethernet (DHCP)
    DEBUG - Getting PHY ID....SUCCESS
    DEBUG - Getting PHY Alive Status...SUCCESS
    DEBUG - Getting PHY Link Status...SUCCESS
    DEBUG - Setting up Link...SUCCESS
    ..DONE
    -------- ERROR INITIALIZING HARDWARE --------

    2. static IP address, no DHCP and static IP address, DHCP
    results of the test: there are not errors on the serial but if I try to ping the IP, the destination host is not attainable.
    The steps are:
    - Run>>Debug
    - Resume
    -The code enters one time in the EMACCore0TxIsr, but not in the EMACCore0RxIsr
    -Ping the IP from the Command Prompt of Windows 10
    -The code does not enter in the EMACCore0RxIsr and in the EMACCore0TxIsr

    How can I face the problem?

    Thanks
  • In addition to the post above, I forgot to mention that I did the two hardware changes:
    1. Replace Y3 with a 50MHz oscillator.
    2. Populate R193 to pull RX_DV (pin 39 of DP83640) to high
  • Did you change the DIP switch on HDK (located at left bottom corner) to ETHERNET ON?
  • Yes, the DIP switch is changed to ETHERNET ON.
    Just as remind, the example ran correctly when using the MII interface with the 25 MHz oscillator. The problem is just with RMII, but as I understood, the example and the HDK should be compatible with also RMII.
    Are there other changes to do?
    Thanks.
  • Hi Smeet,

    The pinmmr configuration (pinmux) is different for MII and RMII. I assume you have changed this already.

    You also need to populate the R136

  • Hi,

    that was the problem. Now it is working.
    Thanks