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.

RM57L843: Lwip integration in IAR issue

Part Number: RM57L843
Other Parts Discussed in Thread: HALCOGEN

Hello,

I have Integrated and complied the Lwip 1.4.1 stack in IAR,

The same stack is working in ccs and tested the UDP protocol,

As following image the workaround for intrinsic function in IAR for enabling the interrupts and CPSR status Getting is as,

CPSR status getting workaround

uint32_t IntMasterStatusGet(void)
{
   // return (0xC0 & _get_CPSR());
  return (0xC0 & __get_CPSR());
}

But as initializing the lwip, the code is getting hanged in mloop in HL_sys_core.asm as, and i observed that MINIDONE bit is set to 0 which means Memory hardware initialization is not complete for all memory

but if i comment 

lwIPInit(0u, pucMacaddress, (uint32_t)SERVER_IP, (uint32_t)SUBNET_MASK, (uint32_t)GATE_WAY, (uint32_t)IPADDR_USE_STATIC);

my rest code is working well without UDP feature,

please let me know where and what i am missing,

Thank you,

Vikas N.

  • Hi Vikas,

    The pbistStop() generated through HCG misses a reset for the PBIST controller. This will prevent other bus master from writing to the memory. 

    Please make changes to the pbistStop() function as below (highlighted instructions):

  • Please take a look at the following thread. Did you try the old IAR workbench (v8)?

  • Hello QJ Wang,

    Thank you,

    The Memory hardware initialization problem has resolved by changes as you mentioned and now i can proceed further to check the UDP feature,

    As i observed that 

            lwIPInit(0u, pucMacaddress, (uint32_t)SERVER_IP, (uint32_t)SUBNET_MASK, (uint32_t)GATE_WAY, (uint32_t)IPADDR_USE_STATIC);
    
            if ( ML_UDP_Server_Init() != eRM_SUCCESS)
            {
                Eret = eRM_FAILURE;
            }

    The above function is get executed successfully in IAR if LAN cable is not connected but,

    if i connect the LAN cable to check the UDP feature the code i getting hangs in MDIOPhyRegRead line number 101 for a some time and gets into Data_entry.

    The same code i have compiled and checked the UDP feature in Code composer studio, The only workaround is i have changed the intrinsic to enable/disable Irq and get cpsr status for IAR as follows,

    Please suggest how to resolve the above issue.

    Also Please suggest If There is any example to check lwip stack UDP/TCp feature in IAR.

    Thank you 

    Vikas N.

  • Hi Vikas,

    Since GO bit is cleared, the PHY read has not been completed. Is the clock in valid range (<2.5MHz, typical 1MHz)? Are register number and PHY address correct?

  • Hi Wang,

    Thank you, now i can able to compile the project without error now and the run time errors are also removed,

    Currently i am facing issue is unable to ping. (I am able to ping same project in css) without following work around.

    The workaround is some of include files are commented in lwiplib.c as shown in image, 

      

    If i uncomment the commented includes as in image complier produces following error (Duplicate Definitions),

    Building configuration: PL CODE IAR - Debug 
    Updating build tree... 
     
    Linking 
    
       Copyright 2007-2018 IAR Systems AB. 
    Error[Li006]: duplicate definitions for "current_header"; in "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\ip.o", and "C:\ 
    Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\lwiplib.o" 
    Error[Li006]: duplicate definitions for "current_iphdr_dest"; in "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\ip.o", and "C:\ 
    Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\lwiplib.o" 
    Error[Li006]: duplicate definitions for "current_iphdr_src"; in "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\ip.o", and "C:\ 
    Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\lwiplib.o" 
    Error[Li006]: duplicate definitions for "current_netif"; in "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\ip.o", and "C:\Users\ 
    Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\lwiplib.o" 
    Error[Li006]: duplicate definitions for "icmp_dest_unreach"; in "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\icmp.o", and  
    "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\lwiplib.o" 
    Error[Li006]: duplicate definitions for "icmp_input"; in "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\icmp.o", and "C:\ 
    Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\lwiplib.o" 
    Error[Li006]: duplicate definitions for "inet_chksum"; in "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\inet_chksum.o",  
    and "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\lwiplib.o" 
    Error[Li006]: duplicate definitions for "inet_chksum_pbuf"; in "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\ 
    inet_chksum.o", and "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\lwiplib.o" 
    Error[Li006]: duplicate definitions for "inet_chksum_pseudo"; in "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\ 
    inet_chksum.o", and "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\lwiplib.o" 
    Error[Li006]: duplicate definitions for "inet_chksum_pseudo_partial"; in "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\ 
    inet_chksum.o", and "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\lwiplib.o" 
    Error[Li006]: duplicate definitions for "ip4_addr_isbroadcast"; in "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\ 
    ip_addr.o", and "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\lwiplib.o" 
    Error[Li006]: duplicate definitions for "ip4_addr_netmask_valid"; in "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\ 
    ip_addr.o", and "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\lwiplib.o" 
    Error[Li006]: duplicate definitions for "ip_addr_any"; in "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\ip_addr.o", and "C:\ 
    Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\lwiplib.o" 
    Error[Li006]: duplicate definitions for "ip_addr_broadcast"; in "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\ip_addr.o",  
    and "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\lwiplib.o" 
    Error[Li006]: duplicate definitions for "ip_input"; in "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\ip.o", and "C:\Users\ 
    Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\lwiplib.o" 
    Error[Li006]: duplicate definitions for "ip_output"; in "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\ip.o", and "C:\Users\ 
    Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\lwiplib.o" 
    Error[Li006]: duplicate definitions for "ip_output_if"; in "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\ip.o", and "C:\Users\ 
    Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\lwiplib.o" 
    Error[Li006]: duplicate definitions for "ip_route"; in "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\ip.o", and "C:\Users\ 
    Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\lwiplib.o" 
    Error[Li006]: duplicate definitions for "ipaddr_addr"; in "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\ip_addr.o", and "C:\ 
    Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\lwiplib.o" 
    Error[Li006]: duplicate definitions for "ipaddr_aton"; in "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\ip_addr.o", and "C:\ 
    Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\lwiplib.o" 
    Error[Li006]: duplicate definitions for "ipaddr_ntoa"; in "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\ip_addr.o", and "C:\ 
    Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\lwiplib.o" 
    Error[Li006]: duplicate definitions for "ipaddr_ntoa_r"; in "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\ip_addr.o", and  
    "C:\Users\Vikas.n\Desktop\to Iar _2\PL CODE IAR - build without runtime error - 1\Debug\Obj\lwiplib.o" 
     
       56 288 bytes of readonly  code memory 
        2 068 bytes of readonly  data memory 
      138 357 bytes of readwrite data memory 
     
    Errors: 22 
    Warnings: none 
     
    Link time:   0.22 (CPU)   0.24 (elapsed) 
    Error while running Linker 
     
    Total number of errors: 22 
    Total number of warnings: 0 
    

    Integration procedure of lwip in IAR as follow,

    1. Preprocessor - Include Directories:

    2. exclude from the build:

    please suggest the solution,

    Also provide if there is any example of lwip stack compiled using IAR EWARM.

    Thank you,

    Vikas N.

  • Hello Vikas,

    I am not familiar with IAR IDE.

    Some source files are already included in lwiplib.c file. Those files needed to be excluded for the compilation:

    The linker cmd files used for CCS and IAR should be different. Please regenerate the those files (linker, *.asm) using option "IAR":

  • Hello Qj wang,

    Thank you.

    Now I am able to compile the project and PHY read is getting successful (as i have Verify the read address and PHY address).

    as I going forward and investigating the lwip integration i have checked the "void EMACCore0RxIsr(void)" ISR getting call periodically (Note; not using RTOS), the c0_tx_pulse and c0_rx_pulse interrupt are enable in halcogen.

    In ccs i have checked the after ping it went into icmp_input function and ping is getting successful but in IAR based project it does not went into icmp_input after pinging.

    I have checked the all files of lwip are correct and compare with working project,

    Please suggest me a solution.

    Thank you,

    Vikas N.

  • Hello Vikas,

    The symbol _RM57Lx_ should be predefined. If you want to use the feature of MPU, you also need to enable the MPU manually. The HAL generates MPU init function in HL_sys_core.asm, but you need call _mpuInit()_ in your main(0 or startup.c.

    I am not familiar with IAR compiler, so I am not able to provide more suggestion. Is the code optimization enabled?