code breaks when trying to run any lwip function
Question
I am trying to run the sample code for tftp server. I get no complaints when synthesizing my hardware or compiling the code. However, when I add the lwip_init() statement, it seems to stop working (it doesn't output any of the print statements). This is very frustrating and I have no idea what is causing it. Any ideas? Thanks
#include <stdio.h>
#include "xenv_standalone.h"
#include "xparameters.h"
#include "platform.h"
#include "netif/xadapter.h"
#include "lwip/init.h"
#define EMAC_BASEADDR XPAR_LLTEMAC_0_BASEADDR
int main()
{
print("-- Starting main() -- \r\n");
struct netif *netif, server_netif;
struct ip_addr ipaddr, netmask, gw;
/* the mac address of the board. this should be unique per board */
unsigned char mac_ethernet_address[] = { 0x00, 0x0a, 0x35, 0x00, 0x01, 0x02 };
netif = &server_netif;
microblaze_init_icache_range(0, XPAR_MICROBLAZE_0_CACHE_BYTE_SIZE);
microblaze_init_dcache_range(0, XPAR_MICROBLAZE_0_DCACHE_BYTE_SIZE);
/* enable caches */
XCACHE_ENABLE_ICACHE();
XCACHE_ENABLE_DCACHE();
platform_setup_interrupts();
/* initliaze IP addresses to be used */
IP4_ADDR(&ipaddr, 192, 168, 1, 10);
IP4_ADDR(&netmask, 255, 255, 255, 0);
IP4_ADDR(&gw, 192, 168, 1, 1);
print_app_header();
print_ip_settings(&ipaddr, &netmask, &gw);
lwip_init();
...
}
EDIT in response to vicky:
maybe you can explain something cause you might be right. When i compile it without lwip_init(), i get:
text data bss dec hex
7214 356 1104 8674 21e2
and with lwip_init() i get:
text data bss dec hex
9726 356 559080 569162 8af4a
which is ALOT bigger. too bad it can't give a warning about this
Solution
Presumably (assuming you are doing a clean rebuild) it's linking in lots of new stuff when you start calling LWIP functions, so your image has changed. Has your image overflowed any of its constraints (program size, data size, stack size...)?