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

Children
Related