Page 1 of 1

lwip + webserver in simulator

Posted: Fri Aug 22, 2014 7:43 am
by xnr
[ChibiOS/RT 2.6.4]

After successfully implementing the MACDriver for my mcu, I wanted to try the webserver using lwip. I am using a simulator for my mcu which uses the host machine's linux loopback-interface. I copied the webserver from the ARMCM3-STM32F107-LWIP demo.

My main looks like this:

Code: Select all

  halInit();
  chSysInit();

  chThdCreateStatic(wa_lwip_thread, LWIP_THREAD_STACK_SIZE, NORMALPRIO + 1,
                      lwip_thread, NULL);

  chThdCreateStatic(wa_http_server, sizeof(wa_http_server), NORMALPRIO + 1,
                    http_server, NULL);

  chThdSetPriority(LOWPRIO);
  while (TRUE) {
    puts("main\n");
    chThdSleepMilliseconds(500);
  }


When starting the application I can see ARP who-has requests on the loopback interface (using tcpdump).
Using curl 192.168.1.20, I get "no route to host".

Do I have to configure lwip to be able to use localhost?

Re: lwip + webserver in simulator

Posted: Fri Aug 22, 2014 8:47 am
by Giovanni
Never tried that but I imagine it cannot work because your simulator would have the same MAC address of the machine it works on, it is like having 2 nodes with the same address.

I think you need to simulate another network with the host working as a gateway or disable networking on the host and let the simulator take over entirely.

Giovanni

Re: lwip + webserver in simulator

Posted: Wed Sep 10, 2014 10:26 pm
by colin
You could also set up a bridged virtual network interface in Linux. For instance, VirtualBox allows you to choose "bridged" instead of "NAT" for the guest OS networking, and if you choose bridged, the guest machine gets a real MAC address that will appear on the host's LAN. Look up tun/tap interfaces and the brctl command for a bunch of info.