浏览代码

asterix: work around busted LFXOs on some evt2s by increasing SCA tolerance

Signed-off-by: Joshua Wise <joshua@joshuawise.com>
Joshua Wise 2 月之前
父节点
当前提交
6b702ae938

+ 16 - 0
src/fw/drivers/nrf5/rtc.c

@@ -315,6 +315,22 @@ void rtc_init(void) {
 
 
   nrf_rtc_prescaler_set(BOARD_RTC_INST, NRF_RTC_FREQ_TO_PRESCALER(RTC_TICKS_HZ));
   nrf_rtc_prescaler_set(BOARD_RTC_INST, NRF_RTC_FREQ_TO_PRESCALER(RTC_TICKS_HZ));
   nrf_rtc_task_trigger(BOARD_RTC_INST, NRF_RTC_TASK_START);
   nrf_rtc_task_trigger(BOARD_RTC_INST, NRF_RTC_TASK_START);
+
+#if TEST_RTC_FREQ
+  // FIXME: can be removed after FIRM-121 is fixed
+  extern void board_early_init();
+  board_early_init();
+  for (int i = 0; i < 100; i++) {
+    uint32_t ctr0 = nrf_rtc_counter_get(BOARD_RTC_INST);
+    while (nrf_rtc_counter_get(BOARD_RTC_INST) == ctr0)
+      ;
+    ctr0 = nrf_rtc_counter_get(BOARD_RTC_INST) + 100;
+    uint32_t iters = 0;
+    while (nrf_rtc_counter_get(BOARD_RTC_INST) != ctr0)
+      iters++;
+    PBL_LOG(LOG_LEVEL_INFO, "RTC: 100 RTC ticks took %"PRIu32" iters", iters);
+  }
+#endif
   
   
   prv_restore_rtc_time_state();
   prv_restore_rtc_time_state();
   s_did_init_rtc = true;
   s_did_init_rtc = true;

+ 1 - 1
third_party/nimble/port/include/nrf52/syscfg/syscfg.h

@@ -1752,7 +1752,7 @@
 
 
 /* Value copied from BLE_LL_OUR_SCA */
 /* Value copied from BLE_LL_OUR_SCA */
 #ifndef MYNEWT_VAL_BLE_LL_SCA
 #ifndef MYNEWT_VAL_BLE_LL_SCA
-#define MYNEWT_VAL_BLE_LL_SCA (60)
+#define MYNEWT_VAL_BLE_LL_SCA (500)
 #endif
 #endif
 
 
 /* Value copied from BLE_LL_CFG_FEAT_LL_PRIVACY */
 /* Value copied from BLE_LL_CFG_FEAT_LL_PRIVACY */

+ 2 - 0
third_party/nimble/syscfg/targets/nrf52/syscfg.yml

@@ -24,3 +24,5 @@ syscfg.vals:
     BLE_SM_LEGACY: 0
     BLE_SM_LEGACY: 0
     BLE_SM_MITM: 1
     BLE_SM_MITM: 1
     BLE_SM_LVL: 4
     BLE_SM_LVL: 4
+    # TODO: put this back in production [FIRM-121]
+    BLE_LL_SCA: 500