Troubleshooting Initialization Failures in Icarus IoT Dev Board (nRF9160): Error Code -8 During GPS and IoT Module Setup

I'm working on a tracking project using the Icarus IoT Dev Board (nRF9160), which employs both NB-IoT and GPS functionalities. During the project, I encountered an issue where, after successfully initializing either the GPS or the IoT module, attempting to initialize the other module fails. The error message returned is:

`<err> lte_lc: Could not send AT command, error: -8`.

I am using toolchain version 1.5.1.

I am seeking to understand the potential reasons behind this error. Specifically, why might the initialization of one module interfere with the initialization of the other, resulting in the inability to send AT commands? What are the possible underlying causes for this error code, and how can they be resolved to ensure successful initialization of both the GPS and IoT modules on the nRF9160 board?

  • Hi Nagib,

    Thanks for checking with us. I just share me through about your project.

    I'm working on a tracking project using the Icarus IoT Dev Board (nRF9160), which employs both NB-IoT and GPS functionalities.

    It seems you are working on a "moving" device. You can use NB-IoT for a moving device, but there are some considerations to keep in mind.

    NB-IoT is generally more suitable for static, low-power applications requiring low throughput, such as smart metering, smart agriculture, and smart city applications. However, when an NB-IoT device moves between base stations, it can be a disruptive and power-hungry operation. Nordic Semiconductor's modem firmware has enhanced mobility support for NB-IoT devices, reducing the overall power consumption when changing to a different base station.

    However, if the device is moving at relatively high speeds or requires support for handovers (transferring the connection from one base station to another as the device moves between coverage areas), LTE-M might be a better choice. LTE-M has inherent support for handovers, allowing a device to seamlessly start communication with the base station covering the new area, without any connection drops.

    We had a user ticket confirmed that live tracking is possible with NB-IoT. However, the performance might vary depending on the specific use case and network conditions.

    Before deciding on the technology, you should consider the specific requirements of your application, such as mobility support, latency, power consumption, and the technologies supported by the network operators in the regions where you plan to deploy the product.

    Here are some pages you can learn about NB-IoT and LTE-M differences.

    Unique Features - nordicsemi.com

    LTE-M and NB-IoT - Nordic Developer Academy (nordicsemi.com)

    LTE technology (nordicsemi.com)

    I am using toolchain version 1.5.1.

    Do you actually mean nRF Connection SDK(NCS) v1.5.1 which is released three years ago? I suggest you develop your project with latest NCS v2.6.1+MFW v1.3.6 if you can.

    During the project, I encountered an issue where, after successfully initializing either the GPS or the IoT module, attempting to initialize the other module fails. The error message returned is:

    `<err> lte_lc: Could not send AT command, error: -8`.

    Specifically, why might the initialization of one module interfere with the initialization of the other, resulting in the inability to send AT commands? What are the possible underlying causes for this error code, and how can they be resolved to ensure successful initialization of both the GPS and IoT modules on the nRF9160 board?

    For nRF9160, GPS and IoT connection are configured together in Modem Firmware(MFW). They are actually configured by AT%XSYSTEMODE command.

    I checked the error in nrf source codes. It acctually happen when running AT%XSYSTEMMODE command instead of "other module". -8 means an "Exec format error". I did not see a similar report before. Is your project based on an existing sample? Could you port your codes to NCS v2.6.1+MFW v1.3.6 first? if the problem still exists, you can share a minimal project that can repeat this issue, I can help you review it.

    	err = nrf_modem_at_printf("AT%%XSYSTEMMODE=%s,%c",
    				  system_mode_params[mode],
    				  system_mode_preference[preference]);
    	if (err) {
    		LOG_ERR("Could not send AT command, error: %d", err);
    		return -EFAULT;
    	}

    Best regards,

    Charlie

  • In this project, we aim to utilize NB-IoT and GPS technologies to develop a system that can accurately determine and communicate its location. The project involves setting up and controlling the GPS module using various AT commands and managing the LTE connection. 

    #### Objective

    To initialize and control the GPS using NB-IoT and ensure seamless LTE connectivity. The system should:

    1. Initialize the modem and configure it for NB-IoT and GPS usage.
    2. Start, stop, and restart the GPS as required.
    3. Ensure LTE connectivity for data transmission.

    #### Code Overview

    1. **AT Commands for System Configuration**:
    ```c
    #define AT_XSYSTEMMODE "AT%XSYSTEMMODE=0,1,1,2"
    #define AT_ACTIVATE_GPS "AT+CFUN=1"

    static const char *const at_commands[] = {
    AT_XSYSTEMMODE,
    AT_ACTIVATE_GPS
    };
    ```

    2. **GPS Control Macros**:
    ```c
    #define GNSS_INIT_AND_START 1
    #define GNSS_STOP 2
    #define GNSS_RESTART 3
    ```

    3. **Setup Modem Function**:
    ```c
    static int setup_modem(void)
    {
    for (int i = 0; i < ARRAY_SIZE(at_commands); i++)
    {
    if (at_cmd_write(at_commands[i], NULL, 0, NULL) != 0)
    {
    return -1;
    }
    }
    return 0;
    }
    ```

    4. **GPS Control Function**:
    ```c
    static int gnss_ctrl(uint32_t ctrl)
    {
    int retval;
    nrf_gnss_delete_mask_t delete_mask = 0;

    if (ctrl == GNSS_INIT_AND_START)
    {
    gnss_fd = nrf_socket(NRF_AF_LOCAL, NRF_SOCK_DGRAM, NRF_PROTO_GNSS);
    if (gnss_fd < 0)
    {
    printk("Could not init socket (err: %d)\n", gnss_fd);
    return -1;
    }
    nrf_gnss_fix_interval_t fix_interval = 1;
    retval = nrf_setsockopt(gnss_fd, NRF_SOL_GNSS, NRF_SO_GNSS_FIX_INTERVAL, &fix_interval, sizeof(fix_interval));
    if (retval != 0)
    {
    printk("Failed to set fix interval value\n");
    return -1;
    }
    }

    if ((ctrl == GNSS_INIT_AND_START) || (ctrl == GNSS_RESTART))
    {
    retval = nrf_setsockopt(gnss_fd, NRF_SOL_GNSS, NRF_SO_GNSS_START, &delete_mask, sizeof(delete_mask));
    if (retval != 0)
    {
    printk("Failed to start GPS\n");
    return -1;
    }
    }

    if (ctrl == GNSS_STOP)
    {
    retval = nrf_setsockopt(gnss_fd, NRF_SOL_GNSS, NRF_SO_GNSS_STOP, &delete_mask, sizeof(delete_mask));
    if (retval != 0)
    {
    printk("Failed to stop GPS\n");
    return -1;
    }
    }
    printk("GNSS control operation successful\n");
    return 0;
    }
    ```

    #### Main Loop Initialization

    In the main loop, the GPS is initialized first:

    ```c
    printk("Starting GPS application\n");

    if (setup_modem() != 0)
    {
    printk("Failed to initialize modem\n");
    return -1;
    }

    if (gnss_ctrl(GNSS_INIT_AND_START) != 0)
    {
    printk("Failed to start GNSS\n");
    return -1;
    }
    ```

    After initializing the GPS, LTE is initialized:

    ```c
    lte_lc_init_and_connect();
    ```

    #### Issue

    The error encountered is: `<err> lte_lc: Could not send AT command, error: -8`.

    #### Expected Outcome

    The project should successfully initialize the modem, control the GPS, and establish an LTE connection without any errors.

  • Hi Nagib,

    I am not sure how you write these codes, but some of the options like NRF_PROTO_GNSS, NRF_SO_GNSS_STOP, NRF_SOL_GNSS and so on I never see them before.

    Did you refer to any existing sample when you write the codes? Could you share your project with me so I can help you review and try to repeat the issue?

    Best regards,

    Charlie

  • Hi,

    I've condensed my code to a more concise form. Could you please pinpoint any issues? I'm using nRF SDK 1.5.1 because I'm working with the Icarus IoT Board v1, which isn't compatible with the latest package.

  • Hi Nagib,

    Thanks for sharing, but your src folder is empty, so I am not able to read your source codes. Another thing unclear is that which version of MFW are you using with your device?

    NCS v1.5.1 is released more than three years ago, and I even have problem set up a development environment with it on my PC now. I strongly suggest you adapt your codes based on latest NCS v2.6.1 + MFW v1.3.6. A lot of bug fix and feature improvement have been introduced since the last three years. It is total OK to use carus IoT Board v1 which use nRF9160 B0 with the new NCS and MFW for your development, you can switch to nRF9161 when you start to design a formal product. 

    According to the previous description about your application, I think you can even use this sample directly nRF91 simple tracker solution - Nordic Developer Academy (nordicsemi.com).

    Let me know what you want to move forward the next step.

    Best regards,

    Charlie

Related