lwip + webserver in simulator

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
xnr
Posts: 9
Joined: Fri Jul 18, 2014 4:49 pm

lwip + webserver in simulator

Post 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?
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: lwip + webserver in simulator

Post 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
colin
Posts: 149
Joined: Thu Dec 22, 2011 7:44 pm

Re: lwip + webserver in simulator

Post 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.
Post Reply