cancel
Showing results for 
Search instead for 
Did you mean: 

BlueNRG-LP Hard Fault on Reset with BLE active

IJenk.1
Associate II

I am using a BlueNRG-LP MC355 SoC. When connected to my debugger, I can call NVIC_SystemReset() just fine. However, if I disconnect the debugger, the device hard faults on reset.

uint8_t ret = BLE_STATUS_SUCCESS;
    uint16_t service_handle, dev_name_char_handle, appearance_char_handle;
 
    static uint8_t adv_data[] = {0x02, AD_TYPE_FLAGS, FLAG_BIT_LE_GENERAL_DISCOVERABLE_MODE | FLAG_BIT_BR_EDR_NOT_SUPPORTED,
                                 6, AD_TYPE_COMPLETE_LOCAL_NAME, 'H', 'O', 'W', 'D', 'Y'};
 
    /* Set the TX power 0 dBm */
    aci_hal_set_tx_power_level(0, 24);
 
    /* GATT Init */
    ret = aci_gatt_srv_init();
    if (ret != BLE_STATUS_SUCCESS)
    {
        PRINTF("aci_gatt_srv_init() failed: 0x%02x\r\n", ret);
        return ret;
    }
 
    /* GAP Init */
    ret = aci_gap_init(GAP_PERIPHERAL_ROLE, 0, 0x07, STATIC_RANDOM_ADDR, &service_handle, &dev_name_char_handle, &appearance_char_handle);
    if (ret != BLE_STATUS_SUCCESS)
    {
        PRINTF("aci_gap_init() failed: 0x%02x\r\n", ret);
        return ret;
    }
 
    /* Update device name */
    Gap_profile_set_dev_name(0, sizeof(device_name), device_name);
 
    ret = aci_gap_set_authentication_requirement(BONDING,
                                                 MITM_PROTECTION_REQUIRED,
                                                 SC_IS_NOT_SUPPORTED,
                                                 KEYPRESS_IS_NOT_SUPPORTED,
                                                 7,
                                                 16,
                                                 USE_FIXED_PIN_FOR_PAIRING,
                                                 123456);
    if (ret != BLE_STATUS_SUCCESS)
    {
        PRINTF("aci_gap_set_authentication_requirement()failed: 0x%02x\r\n", ret);
        return ret;
    }
 
    // HARD FAULT HAPPENS HERE
    ret = aci_gap_set_advertising_configuration(0, GAP_MODE_GENERAL_DISCOVERABLE,
                                                ADV_PROP_CONNECTABLE | ADV_PROP_SCANNABLE | ADV_PROP_LEGACY,
                                                (ADV_INTERVAL_MIN_MS * 1000) / 625, (ADV_INTERVAL_MAX_MS * 1000) / 625,
                                                ADV_CH_ALL,
                                                0, NULL,
                                                ADV_NO_WHITE_LIST_USE,
                                                0,         /* 0 dBm */
                                                LE_1M_PHY, /* Primary advertising PHY */
                                                0,         /* 0 skips */
                                                LE_1M_PHY, /* Secondary advertising PHY. Not used with legacy advertising. */
                                                0,         /* SID */
                                                0 /* No scan request notifications */);
    PRINTF("Advertising configuration 0x%02X\n", ret);
 
    ret = aci_gap_set_advertising_data(0, ADV_COMPLETE_DATA, sizeof(adv_data), adv_data);
 
    PRINTF("Set advertising data 0x%02X\n", ret);
 
    PRINTF("BLE Stack Initialized with SUCCESS\n");
 
    // init services here
    services_init();
 
}

On reset, without a debugger connected, I cannot get passed `aci_gap_set_advertising_configuration()`...

My config file is almost exactly like the BLE_Sensor_Demo:

My intention was to create a BLE characteristic that when written would reset the device:

/* .... */
 
/* Device information characteristic definition */
static ble_gatt_chr_def_t chars[] = {
    {/* Reset characteristic */
     .properties = BLE_GATT_SRV_CHAR_PROP_WRITE | BLE_GATT_SRV_CHAR_PROP_WRITE_NO_RESP,
     .permissions = BLE_GATT_SRV_PERM_NONE,
     .min_key_size = BLE_GATT_SRV_MAX_ENCRY_KEY_SIZE,
     .uuid = BLE_UUID_INIT_16((RESET_UUID)},
};
 
/* WOWL service definition */
static ble_gatt_srv_def_t service = {
    .type = BLE_GATT_SRV_PRIMARY_SRV_TYPE,
    .uuid = BLE_UUID_INIT_16SERVICE_UUID),
    .chrs = {
        .chrs_p = chars,
        .chr_count = 1u,
    },
};

On write to that characteristic, I simply call `NVIC_SystemReset()`. Any help appreciated.

@Sebastien DENOUAL​ @Winfred LU​ , Thoughts? What am I missing?

0 REPLIES 0