This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

getaddrinfo crashes after some time

Dear Community;

I have a NRF9160 DK. I have flashed a program to it, and it works fine. The program connects to LTE every 10 minutes to send some data over HTTP. However, after 1 day working:

err = getaddrinfo(host_name, NULL, &hints, &res);

that line crashed:

Exception occurred in Secure State
***** HARD FAULT *****
  Fault escalation (see below)
***** BUS FAULT *****
  Precise data bus error
  BFAR Address: 0x50008120
***** Hardware exception *****
Current thread ID = 0x200201a8
Faulting instruction address = 0x29d34
Fatal fault in ISR! Spinning...

What is causing the fault?

This is my prj.conf file:

CONFIG_BSD_LIBRARY=y
CONFIG_GPIO=y
CONFIG_SERIAL=y
CONFIG_STDOUT_CONSOLE=y
CONFIG_UART_INTERRUPT_DRIVEN=n
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NETWORKING=y
CONFIG_NET_BUF_USER_DATA_SIZE=1
CONFIG_NET_SOCKETS_OFFLOAD=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_NET_RAW_MODE=y
CONFIG_TRUSTED_EXECUTION_NONSECURE=y
CONFIG_LOG=n
CONFIG_LOG_DEFAULT_LEVEL=4
CONFIG_NEWLIB_LIBC=y
CONFIG_REBOOT=y

# AT host
CONFIG_AT_HOST_LIBRARY=n

# LTE link control
CONFIG_LTE_LINK_CONTROL=y
CONFIG_LTE_AUTO_INIT_AND_CONNECT=n

# Heap and stacks
CONFIG_HEAP_MEM_POOL_SIZE=8192
CONFIG_MAIN_STACK_SIZE=16384

# Disable native network stack to save some memory
CONFIG_NET_IPV4=n
CONFIG_NET_IPV6=n
CONFIG_NET_UDP=n
CONFIG_NET_TCP=n

# ADC
CONFIG_ADC=y
CONFIG_ADC_0=y
CONFIG_ADC_NRFX_SAADC=y

#Flash memory
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_NVS=y
CONFIG_NVS_LOG_LEVEL_DBG=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y

I am using ncs tag 0.4.0

Any idea or suggestion is welcomed!

Thanks.

Parents
  • Hello, 

    NCS tag v0.4.0 is outdated. I encourage you to update your project to tag v1.2.0. Also, I encourage you to update your modem FW to the latest (v1.1.1), which can be downloaded from here. Both modem version and latest NCS include several bug fixes.

    Kind regards,
    Øyvind

  • Hello;

    I have updated to NCS tag v1.2.0 and modem FW to 1.1.1. I have made some little changes in my project (#include paths) and these are the results:

    First HTTP request try works fine. Then, I turn off the LTE connection(lte_lc_offline()). After 3 minutes I establish LTE connection again and the HTTP request gets stuck forever at:

    err = connect(client_fd, (struct sockaddr *)res->ai_addr,sizeof(struct sockaddr_in));

    One more strange thing I have noticed is that I can not see the print float values in the console. I have found some solutions, but I am not using SEGGER and I flash the NRF manually.

    Your help is highly appreciated.

    Kind regards.

  • Hi:

    I am not getting any error code. How can I share my full project? I don't want to make it public.

    Best regards.

  • https_client.zip

    Hi;

    I have modified my project to make it as simple as possible. The first cycle it runs fine, but then it gets stuck in connect() function.

    Any idea or suggestion is welcomed.

    Thanks.

  • Oh, you are initializing the LTE Link Control more than one time and that might cause some problems.

    Do the modem configuring and connecting some way like this:

    static void modem_configure(void)
    {
    	if (IS_ENABLED(CONFIG_LTE_AUTO_INIT_AND_CONNECT)) {
    		/* Do nothing, modem is already turned on and connected. */
    	} else {
    
    		int err;
    
    		printk("Initializing LTE Link Control...\n");
    		err = lte_lc_init();
    		__ASSERT(err == 0, "LTE Link Control could not be initialized.");
    		printk("LTE Link Control initialized.\n");
    
    	}
    }
    
    int main(void)
    {
    
        int err;
    
        modem_configure();
    	
    	while (1) {
            if ((err = lte_lc_connect() )){
    
    		    printk( "Failure to connect to LTE network: %d\n", err );
    	    }
    	    else{
    
    		    printk("\nConnected to LTE network.\n");
    	    }
            k_sleep(2000);
            app_http_start();
            if ((err = lte_lc_offline() )){
    
    		    printk( "Failure turning off Modem: %d\n", err );
    	    }
    	    else{
    
    		    printk("\nModem turned off.\n");
    	    }
            k_sleep(120000);
    	}
    }

    Please let me know how this works for you.

  • Hi,

    You are right, I didn't realize that I init more than one the LTE Link Control. Unfortunately, that didn't solve the problem, and after the first cycle it gets stuck at connect() function forever.

    Did you manage to get work my project after making the changes you mentioned? If so, which version of NCS tag and modem firmware are you using?

    I am really confused why such a simple project works in NCS tag 0.4.0 and not in 1.2.0.

    Thanks for your help.

  • Did you manage to get work my project after making the changes you mentioned? If so, which version of NCS tag and modem firmware are you using?

    Not yet, I could try it as soon as possible and let you know the results.

    I'm using the latest master branch of nRF Connect SDK and I have a 1.1.1 modem firmware on nRF9160 DK.

    UPDATE: Yes, it does work for me. I let the program run about 10 times and had no problems with it.

Reply Children
Related