NRF52DK keeps rebooting when settings_load

I have a nRF52DK board that I loaded the peripheral_uart program in a while ago. I tried to get the board running again but when it calls err = settings_load() it just keeps rebooting. I cannot print the err return so I have no idea why it is rebooting. If I comment out the settings_load() I get the following message from the code. This used to work and the project was put aside for some months and now needs to go into production again. any help you can give to get the Bluetooth working again would be greatly appreciated.

    /* create unique BLE advertizer name */
    strcpy(device_name, DEVICE_NAME);
    strcat(device_name, devIDStr);
    device_name_len = strlen(device_name);
    sprintf(str, "BLE Advertizing name: %s\r\n", device_name);
    myPrintkS(str);
    ad[1].type = BT_DATA_NAME_COMPLETE;
    ad[1].data_len = device_name_len;
    ad[1].data = device_name;
    err = bt_le_adv_start(BT_LE_ADV_CONN, ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd)); /* start BLE advertising */
    if (err)
    {
        sprintf(str, "Advertising failed to start (err %d)", err);
        myPrintkE(str);
        error();
    }
************** ON CONSOLE ********************
BLE Advertizing name: Data_Logger_BLE_7C196D3C_B76562B3
Advertising failed to start (err -11)Fatal Error!!
Parents
  • Hello,

    I can recommend that you enable the log module, and use LOG_INF(), LOG_ERR(), etc, instead of myPrintkE(str). I don't know how you implemented myPrintkE(), but I assume it involves printk()/printf() one way or another. This way, you should see some more logging information before the device reboots. 

    I assume your error() looks like this:

    void error(void)
    {
    	dk_set_leds_state(DK_ALL_LEDS_MSK, DK_NO_LEDS_MSK);
    
    	while (true) {
    		/* Spin for ever */
    		k_sleep(K_MSEC(1000));
    	}
    }
    

    which is the default error function in the peripheral_uart() sample?

    Either way, I do see that your application prints this:

    "Advertising failed to start (err -11)Fatal Error!!"

    So that suggests that bt_le_adv_start() returns -11. -11 means EAGAIN, which suggests that the device is already advertising. But I do see another issue as well. You are trying to put the entire advertising name in your advertising packet. Usually, this is fine, but your device name is 33 characters = 33 bytes long. Every advertising module in your advertising packet consists of 1 byte of length, 1 byte of advertising module type (full_name, in this case), and then the payload (33 byte long name). The issue is that an advertising packet can be maximum 31 bytes long.

    In addition, this is ad[1]. You probably have ad[0]. Perhaps some flags, which would be a total of 3 bytes. This brings you up to 36 bytes, which is indeed higher than 31 bytes. So you need to shorten your device name significantly. For debugging purposes, try to use "TestName", and see if it still fails. If it still fails, is there any way for me to reproduce what you are seeing? Can you zip the application folder, and upload it here? If so, please specify what NCS version you are using.

    Best regards,

    Edvin

  • Edvin

    thank you for your prompt response. I have attached the zip file. This is a modified peripheral_uart.I have shortened the BLE name. Our example has an active I2c and SPI interface plus a command line interpreter. I could not get the LOG to work.

    any help would be appreciated.  if I comment out settings)load() it does not reboot but it does not advertise.

    BLE_Prototype_V0.03.7z

  • Edvin

    if I run the unmodified peripheral_uart project I get the following message and it hangs. It does not reboot. any idea what I am missing? I did have the nRF52DK board working a while ago.

    I am using SDK 2.5.0and toolchain 3.1.0

    *** Booting nRF Connect SDK v2.5.0 ***
    Starting Nordic UART service example

  • Edvin

    if I run the unmodified peripheral_uart project I get the following message and it hangs. It does not reboot. any idea what I am missing? I did have the nRF52DK board working a while ago.

    I am using SDK 2.5.0and toolchain 3.1.0

    *** Booting nRF Connect SDK v2.5.0 ***
    Starting Nordic UART service example

  • Ok, so I destroyed your sample. Your handling of the str parameter is faulty somewhere. Removing it completely makes it run.

    I can attached what I did, but I am not sure exactly what broke it. I tried removing parts in a different order a couple of times, and I think there are multiple places that causes the issue.

     BLE_Prototype2.zip

    I suggest you try to use the logging module, instead of your custom print functions. and remove all the char[xx] str; parameters. It is likely one of the sprintf(str, "...") that causes the issue. Not only in main.c. On my last run, removing this:

    int initHDC2080(void)
    {
    	unsigned char datas[6];
    	char str[80];
    
    	int ret;
    
    	ret = readReg(MID_L, datas, 4);
    	if (ret == FALSE)
    		return FALSE;
    	manfID = (datas[1] << 8) | datas[0];
    	deviceID = (datas[3] << 8) | datas[2];
    	if ((manfID != MAN_ID) || (deviceID != DEV_ID))
    	{
    		//sprintf(str, "Manf: %04X Device: %04X\r\n", manfID, deviceID);
    		// myPrintkE(str);
    		// myPrintkE("HDC2080 Temp/Humidty Sensor not found\r\n");
    		return FALSE;
    	}

    that caused the issue to disappear.

    If your application doesn't use the UART directly, other than logging, remove everything regarding UART from main.c, and enable UART logging in prj.conf by adding:

    CONFIG_LOG_BACKEND_UART=y.

    Best regards,

    Edvin

Reply Children
Related