From ab8d24f9354bbb0033a297a40493c73b4404aa85 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 14 Aug 2018 18:54:49 +0700 Subject: [PATCH] OTA cannot start with SD v6.1.0, but start without issue with 6.0.0 force ota for testing. --- .../libraries/bootloader_dfu/dfu_transport_ble.c | 3 ++- src/main.c | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/sdk11/components/libraries/bootloader_dfu/dfu_transport_ble.c b/lib/sdk11/components/libraries/bootloader_dfu/dfu_transport_ble.c index 65bc503..f5ebb33 100644 --- a/lib/sdk11/components/libraries/bootloader_dfu/dfu_transport_ble.c +++ b/lib/sdk11/components/libraries/bootloader_dfu/dfu_transport_ble.c @@ -704,7 +704,8 @@ static void advertising_start(void) APP_ERROR_CHECK( sd_ble_gap_adv_set_configure(&_adv_handle, &gap_adv, &m_adv_params) ); // maximum power for nrf52832, nrf52840 max power is +8 APP_ERROR_CHECK( sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, _adv_handle, 4) ); - APP_ERROR_CHECK( sd_ble_gap_adv_start(_adv_handle, BLE_CONN_CFG_HIGH_BANDWIDTH) ); +// APP_ERROR_CHECK( sd_ble_gap_adv_start(_adv_handle, BLE_CONN_CFG_HIGH_BANDWIDTH) ); + APP_ERROR_CHECK( sd_ble_gap_adv_start(_adv_handle, BLE_CONN_CFG_TAG_DEFAULT) ); m_is_advertising = true; } diff --git a/src/main.c b/src/main.c index 53fde55..3ae51ea 100644 --- a/src/main.c +++ b/src/main.c @@ -153,7 +153,7 @@ static uint32_t softdev_init(bool init_softdevice) // Enable Softdevice nrf_clock_lf_cfg_t clock_cfg = { -#ifdef NRF52840_XXAA // TODO use xtal source for feather52832 +#if defined(NRF52840_XXAA) // TODO use xtal source for feather52832 .source = NRF_CLOCK_LF_SRC_XTAL, .rc_ctiv = 0, .rc_temp_ctiv = 0, @@ -173,10 +173,12 @@ static uint32_t softdev_init(bool init_softdevice) extern uint32_t __data_start__[]; // defined in linker uint32_t ram_start = (uint32_t) __data_start__; +#if 0 ble_cfg_t blecfg; // Configure the maximum number of connections. varclr(&blecfg); + blecfg.gap_cfg.role_count_cfg.adv_set_count = 1; blecfg.gap_cfg.role_count_cfg.periph_role_count = 1; blecfg.gap_cfg.role_count_cfg.central_role_count = 0; blecfg.gap_cfg.role_count_cfg.central_sec_count = 0; @@ -199,11 +201,19 @@ static uint32_t softdev_init(bool init_softdevice) blecfg.conn_cfg.params.gap_conn_cfg.conn_count = 1; blecfg.conn_cfg.params.gap_conn_cfg.event_length = BLEGAP_EVENT_LENGTH; APP_ERROR_CHECK( sd_ble_cfg_set(BLE_CONN_CFG_GAP, &blecfg, ram_start) ); +#endif // Enable BLE stack. // Note: Interrupt state (enabled, forwarding) is not work properly if not enable ble APP_ERROR_CHECK( sd_ble_enable(&ram_start) ); +#if 0 + ble_opt_t opt; + varclr(&opt); + opt.common_opt.conn_evt_ext.enable = 1; // enable Data Length Extension + APP_ERROR_CHECK( sd_ble_opt_set(BLE_COMMON_OPT_CONN_EVT_EXT, &opt) ); +#endif + return NRF_SUCCESS; } @@ -216,6 +226,8 @@ int main(void) _ota_update = (NRF_POWER->GPREGRET == BOOTLOADER_DFU_OTA_MAGIC) || (NRF_POWER->GPREGRET == BOOTLOADER_DFU_OTA_FULLRESET_MAGIC); + _ota_update = 1; // force OTA for testing + // start bootloader either serial or ble bool dfu_start = _ota_update || (NRF_POWER->GPREGRET == BOOTLOADER_DFU_SERIAL_MAGIC); @@ -342,7 +354,7 @@ void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info) void assert_nrf_callback(uint16_t line_num, const uint8_t * p_file_name) { - app_error_handler(0xDEADBEEF, line_num, p_file_name); + app_error_fault_handler(0xDEADBEEF, 0, 0); } /*------------------------------------------------------------------*/