Sunday, February 21, 2016

TCP/IP over rpmsg OpenAMP with Udoo Neo

Finally got Ethernet driver for Linux completed using rpmsg and FreeRTOS LwIP working on the M4.  Curently the implementation is using Ethernet frames (includes destination/source MAC address and EtherType 14 bytes)  LwIP has iperf feature builtin for testing.  The MTU size is small (496-14)=482 bytes.  

Here is a code snippet:

static void
lwiperf_report(void *arg, enum lwiperf_report_type report_type,
  const ip_addr_t* local_addr, u16_t local_port, const ip_addr_t* remote_addr, u16_t remote_port,
  u32_t bytes_transferred, u32_t ms_duration, u32_t bandwidth_kbitpsec)
{
  LWIP_UNUSED_ARG(arg);
  LWIP_UNUSED_ARG(local_addr);
  LWIP_UNUSED_ARG(local_port);

  PRINTF("IPERF report: type=%d, remote: %s:%d, total bytes: %d, duration in ms: %d, kbits/s: %d\n",
    (int)report_type, ipaddr_ntoa(remote_addr), (int)remote_port, bytes_transferred, ms_duration, bandwidth_kbitpsec);
}


static void usrTask (void* param)
{
    struct rpmsg_endpoint *ept;
    int len;
    int result;

    vTaskSuspendAll();
    PRINTF("\r\n" VERSION " %s Task running... \r\n", __FUNCTION__);
    PRINTF("RPMSG Init as Remote\r\n");
    xTaskResumeAll ();

    result = rpmsg_rtos_init(0 /*REMOTE_CPU_ID*/, &rdev, RPMSG_MASTER, &app_chnl);
    assert(0 == result);
    vTaskSuspendAll();
    PRINTF("Name service handshake is done, M4 has setup a rpmsg channel [%d ---> %d]\r\n", app_chnl->src, app_chnl->dst);
    xTaskResumeAll ();
    
    
     lwipConfig();
     IP4_ADDR(&gw, 192,168,0,1);
     IP4_ADDR(&ipaddr, 192,168,0,2);
     IP4_ADDR(&netmask, 255,255,255,0);
     
    netif_add(&netif, &ipaddr, &netmask, &gw, NULL, rpmsg_init_drv, ethernet_input);
    PRINTF("INFO: %s %s %d \n",__FILE__,__FUNCTION__, __LINE__);

   netif_set_default(&netif);
   PRINTF("INFO: %s %s %d \n",__FILE__,__FUNCTION__, __LINE__);

   netif_set_up(&netif);
    PRINTF("INFO: %s %s %d \n",__FILE__,__FUNCTION__, __LINE__);

    ept = rpmsg_rtos_create_ept(app_chnl,USR_ENDPT);
    
    lwiperf_start_tcp_server_default(lwiperf_report, NULL);

running iperf:

# iperf -c 192.168.0.2
------------------------------------------------------------
Client connecting to 192.168.0.2, TCP port 5001
TCP window size: 23.8 KByte (default)
------------------------------------------------------------
[  3] local 192.168.0.1 port 50292 connected with 192.168.0.2 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.4 sec   896 KBytes   707 Kbits/sec
# iperf -c 192.168.0.2
------------------------------------------------------------
Client connecting to 192.168.0.2, TCP port 5001
TCP window size: 23.8 KByte (default)
------------------------------------------------------------
[  3] local 192.168.0.1 port 50293 connected with 192.168.0.2 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.4 sec   896 KBytes   709 Kbits/sec
# iperf -c 192.168.0.2
------------------------------------------------------------
Client connecting to 192.168.0.2, TCP port 5001
TCP window size: 23.8 KByte (default)
------------------------------------------------------------
[  3] local 192.168.0.1 port 50294 connected with 192.168.0.2 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.3 sec   896 KBytes   711 Kbits/sec

from the M4:
IPERF report: type=1, remote: 192.168.0.1:50292, total bytes: 917528, duration in ms: 10613, kbits/s: 688                                                         
IPERF report: type=1, remote: 192.168.0.1:50292, total bytes: 917528, duration in ms: 10613, kbits/s: 688          
IPERF report: type=1, remote: 192.168.0.1:50294, total bytes: 917528, duration in ms: 10609, kbits/s: 688                                                         
                                               




No comments:

Post a Comment