Просмотр исходного кода

fix compile error under MDK env

chenyingchun0312 3 лет назад
Родитель
Сommit
77652f0d8c

+ 1 - 1
SConscript

@@ -68,7 +68,6 @@ src += Split('''
     nimble/host/src/ble_uuid.c
     nimble/host/services/ans/src/ble_svc_ans.c
     nimble/host/services/bas/src/ble_svc_bas.c
-    nimble/host/services/bleuart/src/bleuart.c
     nimble/host/services/gap/src/ble_svc_gap.c
     nimble/host/services/gatt/src/ble_svc_gatt.c
     nimble/host/services/ias/src/ble_svc_ias.c
@@ -212,6 +211,7 @@ if GetDepend(['PKG_NIMBLE_SAMPLE_BLEUART']):
 
     src += Split("""
         apps/bleuart/src/bleuart.c
+        nimble/host/services/bleuart/src/bleuart.c
         """)
 
 # btshell

+ 12 - 0
ext/tinycrypt/src/ecc_dh.c

@@ -188,6 +188,17 @@ int uECC_shared_secret(const uint8_t *public_key, const uint8_t *private_key,
 	r = !EccPoint_isZero(_public, curve);
 
 clear_and_out:
+
+#ifdef __ARMCC_VERSION
+	/* erasing temporary buffer used to store secret: */
+	memset(p2, 0, sizeof(p2));
+//	__asm__ __volatile__("" :: "g"(p2) : "memory");
+	memset(tmp, 0, sizeof(tmp));
+//	__asm__ __volatile__("" :: "g"(tmp) : "memory");
+	memset(_private, 0, sizeof(_private));
+//	__asm__ __volatile__("" :: "g"(_private) : "memory");
+
+#else
 	/* erasing temporary buffer used to store secret: */
 	memset(p2, 0, sizeof(p2));
 	__asm__ __volatile__("" :: "g"(p2) : "memory");
@@ -195,6 +206,7 @@ clear_and_out:
 	__asm__ __volatile__("" :: "g"(tmp) : "memory");
 	memset(_private, 0, sizeof(_private));
 	__asm__ __volatile__("" :: "g"(_private) : "memory");
+#endif
 
 	return r;
 }

+ 6 - 1
nimble/controller/src/ble_ll_rand.c

@@ -135,7 +135,12 @@ ble_ll_rand(void)
         ble_ll_rand_data_get((uint8_t *)xsubi, sizeof(xsubi));
     }
 
-    return (uint32_t) jrand48(xsubi);
+#ifdef __ARMCC_VERSION
+    srand(xsubi);
+    return (uint32_t)rand();
+#else
+   return (uint32_t) jrand48(xsubi);
+#endif
 }
 
 /**

+ 72 - 0
nimble/drivers/nrf52/src/ble_phy.c

@@ -431,6 +431,77 @@ ble_phy_get_cur_phy(void)
  * lengths of the individual mbufs are not set prior to calling.
  *
  */
+
+#ifdef __ARMCC_VERSION
+void
+ble_phy_rxpdu_copy(uint8_t *dptr, struct os_mbuf *rxpdu)
+{
+    uint16_t rem_bytes;
+    uint16_t mb_bytes;
+    uint16_t copylen;
+    uint32_t *dst;
+    uint32_t *src;
+    struct os_mbuf *m;
+    struct ble_mbuf_hdr *ble_hdr;
+    struct os_mbuf_pkthdr *pkthdr;
+
+    /* Better be aligned */
+    assert(((uint32_t)dptr & 3) == 0);
+
+    pkthdr = OS_MBUF_PKTHDR(rxpdu);
+    rem_bytes = pkthdr->omp_len;
+
+    /* Fill in the mbuf pkthdr first. */
+    dst = (uint32_t *)(rxpdu->om_data);
+    src = (uint32_t *)dptr;
+
+    mb_bytes = (rxpdu->om_omp->omp_databuf_len - rxpdu->om_pkthdr_len - 4);
+    copylen = min(mb_bytes, rem_bytes);
+    copylen &= 0xFFFC;
+    rem_bytes -= copylen;
+    mb_bytes -= copylen;
+    rxpdu->om_len = copylen;
+    while (copylen > 0) {
+        *dst = *src;
+        ++dst;
+        ++src;
+        copylen -= 4;
+    }
+
+    /* Copy remaining bytes */
+    m = rxpdu;
+    while (rem_bytes > 0) {
+        /* If there are enough bytes in the mbuf, copy them and leave */
+        if (rem_bytes <= mb_bytes) {
+            memcpy(m->om_data + m->om_len, src, rem_bytes);
+            m->om_len += rem_bytes;
+            break;
+        }
+
+        m = SLIST_NEXT(m, om_next);
+        assert(m != NULL);
+
+        mb_bytes = m->om_omp->omp_databuf_len;
+        copylen = min(mb_bytes, rem_bytes);
+        copylen &= 0xFFFC;
+        rem_bytes -= copylen;
+        mb_bytes -= copylen;
+        m->om_len = copylen;
+        dst = (uint32_t *)m->om_data;
+        while (copylen > 0) {
+            *dst = *src;
+            ++dst;
+            ++src;
+            copylen -= 4;
+        }
+    }
+
+    /* Copy ble header */
+    ble_hdr = BLE_MBUF_HDR_PTR(rxpdu);
+    memcpy(ble_hdr, &g_ble_phy_data.rxhdr, sizeof(struct ble_mbuf_hdr));
+}
+
+#else
 void
 ble_phy_rxpdu_copy(uint8_t *dptr, struct os_mbuf *rxpdu)
 {
@@ -512,6 +583,7 @@ ble_phy_rxpdu_copy(uint8_t *dptr, struct os_mbuf *rxpdu)
     memcpy(BLE_MBUF_HDR_PTR(rxpdu), &g_ble_phy_data.rxhdr,
            sizeof(struct ble_mbuf_hdr));
 }
+#endif
 
 /**
  * Called when we want to wait if the radio is in either the rx or tx

+ 2 - 2
porting/nimble/src/os_mempool.c

@@ -307,8 +307,8 @@ os_memblock_from(const struct os_mempool *mp, const void *block_addr)
     uintptr_t baddr32;
     uint32_t end;
 
-    static_assert(sizeof block_addr == sizeof baddr32,
-                  "Pointer to void must be 32-bits.");
+    // static_assert(sizeof block_addr == sizeof baddr32,
+    //               "Pointer to void must be 32-bits.");
 
     baddr32 = (uint32_t)(uintptr_t)block_addr;
     true_block_size = OS_MEMPOOL_TRUE_BLOCK_SIZE(mp);