You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2021/10/08 11:57:35 UTC
[mynewt-nimble] branch master updated: mesh: Fix linux port
This is an automated email from the ASF dual-hosted git repository.
janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
The following commit(s) were added to refs/heads/master by this push:
new 4ed4f9e mesh: Fix linux port
4ed4f9e is described below
commit 4ed4f9e3814b617f800094f74f8c01306f95f6a5
Author: Szymon Janc <sz...@codecoup.pl>
AuthorDate: Mon Oct 4 10:09:14 2021 +0200
mesh: Fix linux port
It looks like create_free_list() in glue.c requires word aligned
blocks which on 64-bit is 8 bytes.
---
nimble/host/mesh/include/mesh/glue.h | 2 +-
nimble/host/mesh/src/glue.c | 1 +
nimble/host/mesh/src/transport.c | 7 ++++---
porting/npl/linux/include/nimble/nimble_npl_os.h | 3 ++-
4 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/nimble/host/mesh/include/mesh/glue.h b/nimble/host/mesh/include/mesh/glue.h
index 8c9166c..9a4bd9a 100644
--- a/nimble/host/mesh/include/mesh/glue.h
+++ b/nimble/host/mesh/include/mesh/glue.h
@@ -411,7 +411,7 @@ static inline unsigned int find_msb_set(uint32_t op)
#define CONFIG_BT_MESH_LPN_GROUPS MYNEWT_VAL(BLE_MESH_LPN_GROUPS)
#define CONFIG_BT_MESH_ADV_BUF_COUNT MYNEWT_VAL(BLE_MESH_ADV_BUF_COUNT)
-#define CONFIG_BT_MESH_SEG_BUFS MYNEWT_VAL(BLE_MESH_SEG_BUFS )
+#define CONFIG_BT_MESH_SEG_BUFS MYNEWT_VAL(BLE_MESH_SEG_BUFS)
#define CONFIG_BT_MESH_FRIEND_QUEUE_SIZE MYNEWT_VAL(BLE_MESH_FRIEND_QUEUE_SIZE)
#define CONFIG_BT_MESH_FRIEND_RECV_WIN MYNEWT_VAL(BLE_MESH_FRIEND_RECV_WIN)
#define CONFIG_BT_MESH_LPN_POLL_TIMEOUT MYNEWT_VAL(BLE_MESH_LPN_POLL_TIMEOUT)
diff --git a/nimble/host/mesh/src/glue.c b/nimble/host/mesh/src/glue.c
index aab7f37..8862344 100644
--- a/nimble/host/mesh/src/glue.c
+++ b/nimble/host/mesh/src/glue.c
@@ -906,6 +906,7 @@ int create_free_list(struct k_mem_slab *slab)
uint32_t j;
char *p;
+ /* blocks must be word aligned */
if(((slab->block_size | (uintptr_t)slab->buffer) &
(sizeof(void *) - 1)) != 0) {
return -EINVAL;
diff --git a/nimble/host/mesh/src/transport.c b/nimble/host/mesh/src/transport.c
index 6391272..3582c99 100644
--- a/nimble/host/mesh/src/transport.c
+++ b/nimble/host/mesh/src/transport.c
@@ -113,11 +113,12 @@ static struct seg_rx {
struct k_delayed_work ack;
} seg_rx[CONFIG_BT_MESH_RX_SEG_MSG_COUNT];
-char _k_mem_slab_buffer_[(BT_MESH_APP_SEG_SDU_MAX*CONFIG_BT_MESH_SEG_BUFS)];
+
+char _k_mem_slab_buffer_[OS_ALIGN((BT_MESH_APP_SEG_SDU_MAX)*(CONFIG_BT_MESH_SEG_BUFS), OS_ALIGNMENT)];
struct k_mem_slab segs = {
.num_blocks = CONFIG_BT_MESH_SEG_BUFS,
- .block_size = BT_MESH_APP_SEG_SDU_MAX,
+ .block_size = OS_ALIGN(BT_MESH_APP_SEG_SDU_MAX, OS_ALIGNMENT),
.buffer = _k_mem_slab_buffer_,
.free_list = NULL,
.num_used = 0
@@ -1616,7 +1617,7 @@ void bt_mesh_trans_init(void)
/* We need to initialize memslab free list here */
rc = create_free_list(&segs);
if (rc) {
- BT_ERR("Failed to create free memslab list")
+ BT_ERR("Failed to create free memslab list (error: %d)", rc);
}
for (i = 0; i < ARRAY_SIZE(seg_tx); i++) {
diff --git a/porting/npl/linux/include/nimble/nimble_npl_os.h b/porting/npl/linux/include/nimble/nimble_npl_os.h
index bdd3988..585d378 100644
--- a/porting/npl/linux/include/nimble/nimble_npl_os.h
+++ b/porting/npl/linux/include/nimble/nimble_npl_os.h
@@ -23,6 +23,7 @@
#include <assert.h>
#include <stdint.h>
#include <string.h>
+#include <limits.h>
#include "os_types.h"
@@ -30,7 +31,7 @@
extern "C" {
#endif
-#define BLE_NPL_OS_ALIGNMENT 4
+#define BLE_NPL_OS_ALIGNMENT (__WORDSIZE / 8)
#define BLE_NPL_TIME_FOREVER INT32_MAX