bluetooth: hci: rpmsg: use ipc service library
The Bluetooth HCI driver based on the RPMsg transport now uses the IPC service module. The compatible Bluetooth sample - HCI RPMsg - has also been migrated to the new IPC solution. Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
This commit is contained in:
parent
5e810dd34d
commit
cf6a58d3f6
24 changed files with 310 additions and 174 deletions
|
@ -7,6 +7,9 @@
|
||||||
config IPM_NRFX
|
config IPM_NRFX
|
||||||
default IPM
|
default IPM
|
||||||
|
|
||||||
|
config MBOX_NRFX_IPC
|
||||||
|
default MBOX
|
||||||
|
|
||||||
config RPMSG_SERVICE_DUAL_IPM_SUPPORT
|
config RPMSG_SERVICE_DUAL_IPM_SUPPORT
|
||||||
default RPMSG_SERVICE
|
default RPMSG_SERVICE
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
config IPM_NRFX
|
config IPM_NRFX
|
||||||
default IPM
|
default IPM
|
||||||
|
|
||||||
|
config MBOX_NRFX_IPC
|
||||||
|
default MBOX
|
||||||
|
|
||||||
config RPMSG_SERVICE_DUAL_IPM_SUPPORT
|
config RPMSG_SERVICE_DUAL_IPM_SUPPORT
|
||||||
default RPMSG_SERVICE
|
default RPMSG_SERVICE
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,9 @@ config THINGY53_INIT_PRIORITY
|
||||||
config IPM_NRFX
|
config IPM_NRFX
|
||||||
default IPM
|
default IPM
|
||||||
|
|
||||||
|
config MBOX_NRFX_IPC
|
||||||
|
default MBOX
|
||||||
|
|
||||||
config RPMSG_SERVICE_DUAL_IPM_SUPPORT
|
config RPMSG_SERVICE_DUAL_IPM_SUPPORT
|
||||||
default RPMSG_SERVICE
|
default RPMSG_SERVICE
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ zephyr_library_sources_ifdef(CONFIG_BT_ESP32 hci_esp32.c)
|
||||||
zephyr_library_sources_ifdef(CONFIG_BT_H4 h4.c)
|
zephyr_library_sources_ifdef(CONFIG_BT_H4 h4.c)
|
||||||
zephyr_library_sources_ifdef(CONFIG_BT_H5 h5.c)
|
zephyr_library_sources_ifdef(CONFIG_BT_H5 h5.c)
|
||||||
zephyr_library_sources_ifdef(CONFIG_BT_RPMSG rpmsg.c)
|
zephyr_library_sources_ifdef(CONFIG_BT_RPMSG rpmsg.c)
|
||||||
zephyr_library_sources_ifdef(CONFIG_BT_RPMSG_NRF53 rpmsg_nrf53.c)
|
|
||||||
zephyr_library_sources_ifdef(CONFIG_BT_SPI spi.c)
|
zephyr_library_sources_ifdef(CONFIG_BT_SPI spi.c)
|
||||||
zephyr_library_sources_ifdef(CONFIG_BT_STM32_IPM ipm_stm32wb.c)
|
zephyr_library_sources_ifdef(CONFIG_BT_STM32_IPM ipm_stm32wb.c)
|
||||||
zephyr_library_sources_ifdef(CONFIG_BT_USERCHAN userchan.c)
|
zephyr_library_sources_ifdef(CONFIG_BT_USERCHAN userchan.c)
|
||||||
|
|
|
@ -33,10 +33,20 @@ config BT_H5
|
||||||
|
|
||||||
config BT_RPMSG
|
config BT_RPMSG
|
||||||
bool "HCI using RPMsg"
|
bool "HCI using RPMsg"
|
||||||
|
select IPC_SERVICE
|
||||||
|
select MBOX
|
||||||
help
|
help
|
||||||
Bluetooth HCI driver for communication with another CPU
|
Bluetooth HCI driver for communication with another CPU
|
||||||
using RPMsg framework.
|
using RPMsg framework.
|
||||||
|
|
||||||
|
if BT_RPMSG
|
||||||
|
|
||||||
|
choice IPC_SERVICE_BACKEND
|
||||||
|
default IPC_SERVICE_BACKEND_RPMSG
|
||||||
|
endchoice
|
||||||
|
|
||||||
|
endif # BT_RPMSG
|
||||||
|
|
||||||
config BT_SPI
|
config BT_SPI
|
||||||
bool "SPI HCI"
|
bool "SPI HCI"
|
||||||
depends on SPI
|
depends on SPI
|
||||||
|
@ -102,27 +112,10 @@ config BT_STM32_IPM_RX_STACK_SIZE
|
||||||
depends on BT_STM32_IPM
|
depends on BT_STM32_IPM
|
||||||
default 512
|
default 512
|
||||||
|
|
||||||
config BT_RPMSG_NRF53
|
|
||||||
bool "nRF53 configuration of RPMsg"
|
|
||||||
default y if SOC_NRF5340_CPUAPP
|
|
||||||
depends on BT_RPMSG
|
|
||||||
select RPMSG_SERVICE
|
|
||||||
help
|
|
||||||
Enable RPMsg configuration for nRF53. Two channels of the IPM driver
|
|
||||||
are used in the HCI driver: channel 0 for TX and channel 1 for RX.
|
|
||||||
|
|
||||||
if BT_RPMSG_NRF53
|
|
||||||
|
|
||||||
choice RPMSG_SERVICE_MODE
|
|
||||||
default RPMSG_SERVICE_MODE_MASTER
|
|
||||||
endchoice
|
|
||||||
|
|
||||||
endif # BT_RPMSG_NRF53
|
|
||||||
|
|
||||||
config BT_DRIVER_QUIRK_NO_AUTO_DLE
|
config BT_DRIVER_QUIRK_NO_AUTO_DLE
|
||||||
bool "Host auto-initiated Data Length Update quirk"
|
bool "Host auto-initiated Data Length Update quirk"
|
||||||
depends on BT_AUTO_DATA_LEN_UPDATE
|
depends on BT_AUTO_DATA_LEN_UPDATE
|
||||||
default y if BT_RPMSG_NRF53 || BT_ESP32
|
default y if BT_RPMSG || BT_ESP32
|
||||||
help
|
help
|
||||||
Enable the quirk wherein BT Host stack will auto-initiate Data Length
|
Enable the quirk wherein BT Host stack will auto-initiate Data Length
|
||||||
Update procedure for new connections for controllers that do not
|
Update procedure for new connections for controllers that do not
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
#include <bluetooth/hci.h>
|
#include <bluetooth/hci.h>
|
||||||
#include <drivers/bluetooth/hci_driver.h>
|
#include <drivers/bluetooth/hci_driver.h>
|
||||||
|
|
||||||
|
#include <device.h>
|
||||||
|
#include <ipc/ipc_service.h>
|
||||||
|
|
||||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER)
|
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER)
|
||||||
#define LOG_MODULE_NAME bt_hci_driver
|
#define LOG_MODULE_NAME bt_hci_driver
|
||||||
#include "common/log.h"
|
#include "common/log.h"
|
||||||
|
@ -21,9 +24,10 @@
|
||||||
#define RPMSG_EVT 0x04
|
#define RPMSG_EVT 0x04
|
||||||
#define RPMSG_ISO 0x05
|
#define RPMSG_ISO 0x05
|
||||||
|
|
||||||
int bt_rpmsg_platform_init(void);
|
#define IPC_BOUND_TIMEOUT_IN_MS K_MSEC(1000)
|
||||||
int bt_rpmsg_platform_send(struct net_buf *buf);
|
|
||||||
int bt_rpmsg_platform_endpoint_is_bound(void);
|
static struct ipc_ept hci_ept;
|
||||||
|
static K_SEM_DEFINE(ipc_bound_sem, 0, 1);
|
||||||
|
|
||||||
static bool is_hci_event_discardable(const uint8_t *evt_data)
|
static bool is_hci_event_discardable(const uint8_t *evt_data)
|
||||||
{
|
{
|
||||||
|
@ -50,7 +54,7 @@ static bool is_hci_event_discardable(const uint8_t *evt_data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct net_buf *bt_rpmsg_evt_recv(uint8_t *data, size_t remaining)
|
static struct net_buf *bt_rpmsg_evt_recv(const uint8_t *data, size_t remaining)
|
||||||
{
|
{
|
||||||
bool discardable;
|
bool discardable;
|
||||||
struct bt_hci_evt_hdr hdr;
|
struct bt_hci_evt_hdr hdr;
|
||||||
|
@ -99,7 +103,7 @@ static struct net_buf *bt_rpmsg_evt_recv(uint8_t *data, size_t remaining)
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct net_buf *bt_rpmsg_acl_recv(uint8_t *data, size_t remaining)
|
static struct net_buf *bt_rpmsg_acl_recv(const uint8_t *data, size_t remaining)
|
||||||
{
|
{
|
||||||
struct bt_hci_acl_hdr hdr;
|
struct bt_hci_acl_hdr hdr;
|
||||||
struct net_buf *buf;
|
struct net_buf *buf;
|
||||||
|
@ -142,7 +146,7 @@ static struct net_buf *bt_rpmsg_acl_recv(uint8_t *data, size_t remaining)
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct net_buf *bt_rpmsg_iso_recv(uint8_t *data, size_t remaining)
|
static struct net_buf *bt_rpmsg_iso_recv(const uint8_t *data, size_t remaining)
|
||||||
{
|
{
|
||||||
struct bt_hci_iso_hdr hdr;
|
struct bt_hci_iso_hdr hdr;
|
||||||
struct net_buf *buf;
|
struct net_buf *buf;
|
||||||
|
@ -185,7 +189,7 @@ static struct net_buf *bt_rpmsg_iso_recv(uint8_t *data, size_t remaining)
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_rpmsg_rx(uint8_t *data, size_t len)
|
static void bt_rpmsg_rx(const uint8_t *data, size_t len)
|
||||||
{
|
{
|
||||||
uint8_t pkt_indicator;
|
uint8_t pkt_indicator;
|
||||||
struct net_buf *buf = NULL;
|
struct net_buf *buf = NULL;
|
||||||
|
@ -247,7 +251,7 @@ static int bt_rpmsg_send(struct net_buf *buf)
|
||||||
net_buf_push_u8(buf, pkt_indicator);
|
net_buf_push_u8(buf, pkt_indicator);
|
||||||
|
|
||||||
BT_HEXDUMP_DBG(buf->data, buf->len, "Final HCI buffer:");
|
BT_HEXDUMP_DBG(buf->data, buf->len, "Final HCI buffer:");
|
||||||
err = bt_rpmsg_platform_send(buf);
|
err = ipc_service_send(&hci_ept, buf->data, buf->len);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
BT_ERR("Failed to send (err %d)", err);
|
BT_ERR("Failed to send (err %d)", err);
|
||||||
}
|
}
|
||||||
|
@ -257,13 +261,49 @@ done:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void hci_ept_bound(void *priv)
|
||||||
|
{
|
||||||
|
k_sem_give(&ipc_bound_sem);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void hci_ept_recv(const void *data, size_t len, void *priv)
|
||||||
|
{
|
||||||
|
bt_rpmsg_rx(data, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct ipc_ept_cfg hci_ept_cfg = {
|
||||||
|
.name = "nrf_bt_hci",
|
||||||
|
.cb = {
|
||||||
|
.bound = hci_ept_bound,
|
||||||
|
.received = hci_ept_recv,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
static int bt_rpmsg_open(void)
|
static int bt_rpmsg_open(void)
|
||||||
{
|
{
|
||||||
|
int err;
|
||||||
|
const struct device *hci_ipc_instance = DEVICE_DT_GET(DT_NODELABEL(ipc0));
|
||||||
|
|
||||||
BT_DBG("");
|
BT_DBG("");
|
||||||
|
|
||||||
while (!bt_rpmsg_platform_endpoint_is_bound()) {
|
err = ipc_service_open_instance(hci_ipc_instance);
|
||||||
k_sleep(K_MSEC(1));
|
if (err && (err != -EALREADY)) {
|
||||||
|
BT_ERR("IPC service instance initialization failed: %d\n", err);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = ipc_service_register_endpoint(hci_ipc_instance, &hci_ept, &hci_ept_cfg);
|
||||||
|
if (err) {
|
||||||
|
BT_ERR("Registering endpoint failed with %d", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = k_sem_take(&ipc_bound_sem, IPC_BOUND_TIMEOUT_IN_MS);
|
||||||
|
if (err) {
|
||||||
|
BT_ERR("Endpoint binding failed with %d", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,12 +323,6 @@ static int bt_rpmsg_init(const struct device *unused)
|
||||||
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = bt_rpmsg_platform_init();
|
|
||||||
if (err < 0) {
|
|
||||||
BT_ERR("Failed to initialize BT RPMSG (err %d)", err);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = bt_hci_driver_register(&drv);
|
err = bt_hci_driver_register(&drv);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
BT_ERR("Failed to register BT HIC driver (err %d)", err);
|
BT_ERR("Failed to register BT HIC driver (err %d)", err);
|
||||||
|
@ -297,4 +331,4 @@ static int bt_rpmsg_init(const struct device *unused)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
SYS_INIT(bt_rpmsg_init, POST_KERNEL, CONFIG_RPMSG_SERVICE_EP_REG_PRIORITY);
|
SYS_INIT(bt_rpmsg_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);
|
||||||
|
|
|
@ -1,60 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 Nordic Semiconductor ASA
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <drivers/ipm.h>
|
|
||||||
|
|
||||||
#include <ipc/rpmsg_service.h>
|
|
||||||
|
|
||||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER)
|
|
||||||
#define LOG_MODULE_NAME bt_hci_driver_nrf53
|
|
||||||
#include "common/log.h"
|
|
||||||
|
|
||||||
void bt_rpmsg_rx(uint8_t *data, size_t len);
|
|
||||||
|
|
||||||
static K_SEM_DEFINE(ready_sem, 0, 1);
|
|
||||||
static K_SEM_DEFINE(rx_sem, 0, 1);
|
|
||||||
|
|
||||||
BUILD_ASSERT(CONFIG_HEAP_MEM_POOL_SIZE >= 1024,
|
|
||||||
"Not enough heap memory for RPMsg queue allocation");
|
|
||||||
|
|
||||||
static int endpoint_id;
|
|
||||||
|
|
||||||
static int endpoint_cb(struct rpmsg_endpoint *ept, void *data, size_t len,
|
|
||||||
uint32_t src, void *priv)
|
|
||||||
{
|
|
||||||
BT_DBG("Received message of %u bytes.", len);
|
|
||||||
BT_HEXDUMP_DBG((uint8_t *)data, len, "Data:");
|
|
||||||
|
|
||||||
bt_rpmsg_rx(data, len);
|
|
||||||
|
|
||||||
return RPMSG_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int bt_rpmsg_platform_init(void)
|
|
||||||
{
|
|
||||||
int err;
|
|
||||||
|
|
||||||
err = rpmsg_service_register_endpoint("nrf_bt_hci", endpoint_cb);
|
|
||||||
|
|
||||||
if (err < 0) {
|
|
||||||
LOG_ERR("Registering endpoint failed with %d", err);
|
|
||||||
return RPMSG_ERR_INIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
endpoint_id = err;
|
|
||||||
|
|
||||||
return RPMSG_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int bt_rpmsg_platform_send(struct net_buf *buf)
|
|
||||||
{
|
|
||||||
return rpmsg_service_send(endpoint_id, buf->data, buf->len);
|
|
||||||
}
|
|
||||||
|
|
||||||
int bt_rpmsg_platform_endpoint_is_bound(void)
|
|
||||||
{
|
|
||||||
return rpmsg_service_endpoint_is_bound(endpoint_id);
|
|
||||||
}
|
|
|
@ -378,12 +378,23 @@ i2s0: i2s@28000 {
|
||||||
label = "I2S_0";
|
label = "I2S_0";
|
||||||
};
|
};
|
||||||
|
|
||||||
ipc: ipc@2a000 {
|
ipc0: ipc0 {
|
||||||
compatible = "nordic,nrf-ipc";
|
compatible = "zephyr,ipc-openamp-static-vrings";
|
||||||
reg = <0x2a000 0x1000>;
|
memory-region = <&sram0_shared>;
|
||||||
interrupts = <42 NRF_DEFAULT_IRQ_PRIORITY>;
|
mboxes = <&mbox 0>, <&mbox 1>;
|
||||||
|
mbox-names = "tx", "rx";
|
||||||
|
role = "host";
|
||||||
|
status = "okay";
|
||||||
|
};
|
||||||
|
|
||||||
|
mbox: mbox@2a000 {
|
||||||
|
compatible = "nordic,mbox-nrf-ipc";
|
||||||
|
reg = <0x2a000 0x1000>;
|
||||||
|
tx-mask = <0x0000ffff>;
|
||||||
|
rx-mask = <0x0000ffff>;
|
||||||
|
interrupts = <42 NRF_DEFAULT_IRQ_PRIORITY>;
|
||||||
|
#mbox-cells = <1>;
|
||||||
status = "okay";
|
status = "okay";
|
||||||
label = "IPC";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
qspi: qspi@2b000 {
|
qspi: qspi@2b000 {
|
||||||
|
|
|
@ -142,12 +142,23 @@
|
||||||
label = "RTC_0";
|
label = "RTC_0";
|
||||||
};
|
};
|
||||||
|
|
||||||
ipc: ipc@41012000 {
|
ipc0: ipc0 {
|
||||||
compatible = "nordic,nrf-ipc";
|
compatible = "zephyr,ipc-openamp-static-vrings";
|
||||||
reg = <0x41012000 0x1000>;
|
memory-region = <&sram0_shared>;
|
||||||
interrupts = <18 NRF_DEFAULT_IRQ_PRIORITY>;
|
mboxes = <&mbox 0>, <&mbox 1>;
|
||||||
|
mbox-names = "rx", "tx";
|
||||||
|
role = "remote";
|
||||||
|
status = "okay";
|
||||||
|
};
|
||||||
|
|
||||||
|
mbox: mbox@41012000 {
|
||||||
|
compatible = "nordic,mbox-nrf-ipc";
|
||||||
|
reg = <0x41012000 0x1000>;
|
||||||
|
tx-mask = <0x0000ffff>;
|
||||||
|
rx-mask = <0x0000ffff>;
|
||||||
|
interrupts = <18 NRF_DEFAULT_IRQ_PRIORITY>;
|
||||||
|
#mbox-cells = <1>;
|
||||||
status = "okay";
|
status = "okay";
|
||||||
label = "IPC";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
i2c0: i2c@41013000 {
|
i2c0: i2c@41013000 {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
CONFIG_RPMSG_SERVICE=y
|
CONFIG_IPC_SERVICE=y
|
||||||
CONFIG_RPMSG_SERVICE_MODE_REMOTE=y
|
CONFIG_IPC_SERVICE_BACKEND_RPMSG=y
|
||||||
|
CONFIG_MBOX=y
|
||||||
|
|
||||||
CONFIG_HEAP_MEM_POOL_SIZE=8192
|
CONFIG_HEAP_MEM_POOL_SIZE=8192
|
||||||
|
|
||||||
|
|
|
@ -9,18 +9,12 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <device.h>
|
||||||
#include <zephyr.h>
|
#include <zephyr.h>
|
||||||
#include <arch/cpu.h>
|
|
||||||
#include <sys/byteorder.h>
|
#include <sys/byteorder.h>
|
||||||
#include <sys/util.h>
|
#include <sys/util.h>
|
||||||
#include <drivers/ipm.h>
|
|
||||||
|
|
||||||
#include <openamp/open_amp.h>
|
#include <ipc/ipc_service.h>
|
||||||
#include <metal/sys.h>
|
|
||||||
#include <metal/device.h>
|
|
||||||
#include <metal/alloc.h>
|
|
||||||
|
|
||||||
#include <ipc/rpmsg_service.h>
|
|
||||||
|
|
||||||
#include <net/buf.h>
|
#include <net/buf.h>
|
||||||
#include <bluetooth/bluetooth.h>
|
#include <bluetooth/bluetooth.h>
|
||||||
|
@ -33,11 +27,12 @@
|
||||||
#define LOG_MODULE_NAME hci_rpmsg
|
#define LOG_MODULE_NAME hci_rpmsg
|
||||||
#include "common/log.h"
|
#include "common/log.h"
|
||||||
|
|
||||||
static int endpoint_id;
|
static struct ipc_ept hci_ept;
|
||||||
|
|
||||||
static K_THREAD_STACK_DEFINE(tx_thread_stack, CONFIG_BT_HCI_TX_STACK_SIZE);
|
static K_THREAD_STACK_DEFINE(tx_thread_stack, CONFIG_BT_HCI_TX_STACK_SIZE);
|
||||||
static struct k_thread tx_thread_data;
|
static struct k_thread tx_thread_data;
|
||||||
static K_FIFO_DEFINE(tx_queue);
|
static K_FIFO_DEFINE(tx_queue);
|
||||||
|
static K_SEM_DEFINE(ipc_bound_sem, 0, 1);
|
||||||
|
|
||||||
#define HCI_RPMSG_CMD 0x01
|
#define HCI_RPMSG_CMD 0x01
|
||||||
#define HCI_RPMSG_ACL 0x02
|
#define HCI_RPMSG_ACL 0x02
|
||||||
|
@ -223,7 +218,7 @@ static int hci_rpmsg_send(struct net_buf *buf)
|
||||||
net_buf_push_u8(buf, pkt_indicator);
|
net_buf_push_u8(buf, pkt_indicator);
|
||||||
|
|
||||||
LOG_HEXDUMP_DBG(buf->data, buf->len, "Final HCI buffer:");
|
LOG_HEXDUMP_DBG(buf->data, buf->len, "Final HCI buffer:");
|
||||||
rpmsg_service_send(endpoint_id, buf->data, buf->len);
|
ipc_service_send(&hci_ept, buf->data, buf->len);
|
||||||
|
|
||||||
net_buf_unref(buf);
|
net_buf_unref(buf);
|
||||||
|
|
||||||
|
@ -237,18 +232,29 @@ void bt_ctlr_assert_handle(char *file, uint32_t line)
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_BT_CTLR_ASSERT_HANDLER */
|
#endif /* CONFIG_BT_CTLR_ASSERT_HANDLER */
|
||||||
|
|
||||||
int endpoint_cb(struct rpmsg_endpoint *ept, void *data, size_t len, uint32_t src,
|
static void hci_ept_bound(void *priv)
|
||||||
void *priv)
|
{
|
||||||
|
k_sem_give(&ipc_bound_sem);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void hci_ept_recv(const void *data, size_t len, void *priv)
|
||||||
{
|
{
|
||||||
LOG_INF("Received message of %u bytes.", len);
|
LOG_INF("Received message of %u bytes.", len);
|
||||||
hci_rpmsg_rx((uint8_t *) data, len);
|
hci_rpmsg_rx((uint8_t *) data, len);
|
||||||
|
|
||||||
return RPMSG_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct ipc_ept_cfg hci_ept_cfg = {
|
||||||
|
.name = "nrf_bt_hci",
|
||||||
|
.cb = {
|
||||||
|
.bound = hci_ept_bound,
|
||||||
|
.received = hci_ept_recv,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
const struct device *hci_ipc_instance = DEVICE_DT_GET(DT_NODELABEL(ipc0));
|
||||||
|
|
||||||
/* incoming events and data from the controller */
|
/* incoming events and data from the controller */
|
||||||
static K_FIFO_DEFINE(rx_queue);
|
static K_FIFO_DEFINE(rx_queue);
|
||||||
|
@ -266,6 +272,19 @@ void main(void)
|
||||||
NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT);
|
NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT);
|
||||||
k_thread_name_set(&tx_thread_data, "HCI rpmsg TX");
|
k_thread_name_set(&tx_thread_data, "HCI rpmsg TX");
|
||||||
|
|
||||||
|
/* Initialize IPC service instance and register endpoint. */
|
||||||
|
err = ipc_service_open_instance(hci_ipc_instance);
|
||||||
|
if (err) {
|
||||||
|
LOG_ERR("IPC service instance initialization failed: %d\n", err);
|
||||||
|
}
|
||||||
|
|
||||||
|
err = ipc_service_register_endpoint(hci_ipc_instance, &hci_ept, &hci_ept_cfg);
|
||||||
|
if (err) {
|
||||||
|
LOG_ERR("Registering endpoint failed with %d", err);
|
||||||
|
}
|
||||||
|
|
||||||
|
k_sem_take(&ipc_bound_sem, K_FOREVER);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
struct net_buf *buf;
|
struct net_buf *buf;
|
||||||
|
|
||||||
|
@ -276,22 +295,3 @@ void main(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure we register endpoint before RPMsg Service is initialized. */
|
|
||||||
int register_endpoint(const struct device *arg)
|
|
||||||
{
|
|
||||||
int status;
|
|
||||||
|
|
||||||
status = rpmsg_service_register_endpoint("nrf_bt_hci", endpoint_cb);
|
|
||||||
|
|
||||||
if (status < 0) {
|
|
||||||
LOG_ERR("Registering endpoint failed with %d", status);
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
endpoint_id = status;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SYS_INIT(register_endpoint, POST_KERNEL, CONFIG_RPMSG_SERVICE_EP_REG_PRIORITY);
|
|
||||||
|
|
|
@ -9,6 +9,12 @@
|
||||||
/delete-property/ zephyr,ipc_shm;
|
/delete-property/ zephyr,ipc_shm;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
soc {
|
||||||
|
peripheral@50000000 {
|
||||||
|
/delete-node/ ipc0;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
reserved-memory {
|
reserved-memory {
|
||||||
/delete-node/ memory@20070000;
|
/delete-node/ memory@20070000;
|
||||||
|
|
||||||
|
@ -21,22 +27,6 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
soc {
|
|
||||||
peripheral@50000000 {
|
|
||||||
/delete-node/ ipc@2a000;
|
|
||||||
|
|
||||||
mbox: mbox@2a000 {
|
|
||||||
compatible = "nordic,mbox-nrf-ipc";
|
|
||||||
reg = <0x2a000 0x1000>;
|
|
||||||
tx-mask = <0x0000ffff>;
|
|
||||||
rx-mask = <0x0000ffff>;
|
|
||||||
interrupts = <42 NRF_DEFAULT_IRQ_PRIORITY>;
|
|
||||||
#mbox-cells = <1>;
|
|
||||||
status = "okay";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
ipc0: ipc0 {
|
ipc0: ipc0 {
|
||||||
compatible = "zephyr,ipc-openamp-static-vrings";
|
compatible = "zephyr,ipc-openamp-static-vrings";
|
||||||
memory-region = <&sram_ipc0>;
|
memory-region = <&sram_ipc0>;
|
||||||
|
|
|
@ -9,6 +9,10 @@
|
||||||
/delete-property/ zephyr,ipc_shm;
|
/delete-property/ zephyr,ipc_shm;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
soc {
|
||||||
|
/delete-node/ ipc0;
|
||||||
|
};
|
||||||
|
|
||||||
reserved-memory {
|
reserved-memory {
|
||||||
/delete-node/ memory@20070000;
|
/delete-node/ memory@20070000;
|
||||||
|
|
||||||
|
@ -21,20 +25,6 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
soc {
|
|
||||||
/delete-node/ ipc@41012000;
|
|
||||||
|
|
||||||
mbox: mbox@41012000 {
|
|
||||||
compatible = "nordic,mbox-nrf-ipc";
|
|
||||||
reg = <0x41012000 0x1000>;
|
|
||||||
tx-mask = <0x0000ffff>;
|
|
||||||
rx-mask = <0x0000ffff>;
|
|
||||||
interrupts = <18 NRF_DEFAULT_IRQ_PRIORITY>;
|
|
||||||
#mbox-cells = <1>;
|
|
||||||
status = "okay";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
ipc0: ipc0 {
|
ipc0: ipc0 {
|
||||||
compatible = "zephyr,ipc-openamp-static-vrings";
|
compatible = "zephyr,ipc-openamp-static-vrings";
|
||||||
memory-region = <&sram_ipc0>;
|
memory-region = <&sram_ipc0>;
|
||||||
|
|
|
@ -30,7 +30,6 @@ ExternalProject_Add(
|
||||||
SOURCE_DIR ${APPLICATION_SOURCE_DIR}/remote
|
SOURCE_DIR ${APPLICATION_SOURCE_DIR}/remote
|
||||||
INSTALL_COMMAND "" # This particular build system has no install command
|
INSTALL_COMMAND "" # This particular build system has no install command
|
||||||
CMAKE_CACHE_ARGS -DBOARD:STRING=${BOARD_REMOTE}
|
CMAKE_CACHE_ARGS -DBOARD:STRING=${BOARD_REMOTE}
|
||||||
CMAKE_CACHE_ARGS -DDTC_OVERLAY_FILE:STRING=${DTC_OVERLAY_FILE}
|
|
||||||
BUILD_BYPRODUCTS "${REMOTE_ZEPHYR_DIR}/${KERNEL_BIN_NAME}"
|
BUILD_BYPRODUCTS "${REMOTE_ZEPHYR_DIR}/${KERNEL_BIN_NAME}"
|
||||||
# NB: Do we need to pass on more CMake variables?
|
# NB: Do we need to pass on more CMake variables?
|
||||||
BUILD_ALWAYS True
|
BUILD_ALWAYS True
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Nordic Semiconductor ASA
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/ {
|
||||||
|
soc {
|
||||||
|
peripheral@50000000 {
|
||||||
|
/delete-node/ ipc@2a000;
|
||||||
|
|
||||||
|
ipc: ipc@2a000 {
|
||||||
|
compatible = "nordic,nrf-ipc";
|
||||||
|
reg = <0x2a000 0x1000>;
|
||||||
|
interrupts = <42 NRF_DEFAULT_IRQ_PRIORITY>;
|
||||||
|
status = "okay";
|
||||||
|
label = "IPC";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Nordic Semiconductor ASA
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/ {
|
||||||
|
soc {
|
||||||
|
/delete-node/ ipc@41012000;
|
||||||
|
|
||||||
|
ipc: ipc@41012000 {
|
||||||
|
compatible = "nordic,nrf-ipc";
|
||||||
|
reg = <0x41012000 0x1000>;
|
||||||
|
interrupts = <18 NRF_DEFAULT_IRQ_PRIORITY>;
|
||||||
|
status = "okay";
|
||||||
|
label = "IPC";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
|
@ -38,7 +38,6 @@ ExternalProject_Add(
|
||||||
SOURCE_DIR ${APPLICATION_SOURCE_DIR}/remote
|
SOURCE_DIR ${APPLICATION_SOURCE_DIR}/remote
|
||||||
INSTALL_COMMAND "" # This particular build system has no install command
|
INSTALL_COMMAND "" # This particular build system has no install command
|
||||||
CMAKE_CACHE_ARGS -DBOARD:STRING=${BOARD_REMOTE}
|
CMAKE_CACHE_ARGS -DBOARD:STRING=${BOARD_REMOTE}
|
||||||
CMAKE_CACHE_ARGS -DDTC_OVERLAY_FILE:STRING=${DTC_OVERLAY_FILE}
|
|
||||||
BUILD_BYPRODUCTS "${REMOTE_ZEPHYR_DIR}/${KERNEL_BIN_NAME}"
|
BUILD_BYPRODUCTS "${REMOTE_ZEPHYR_DIR}/${KERNEL_BIN_NAME}"
|
||||||
# NB: Do we need to pass on more CMake variables?
|
# NB: Do we need to pass on more CMake variables?
|
||||||
BUILD_ALWAYS True
|
BUILD_ALWAYS True
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Nordic Semiconductor ASA
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/ {
|
||||||
|
soc {
|
||||||
|
peripheral@50000000 {
|
||||||
|
/delete-node/ ipc@2a000;
|
||||||
|
|
||||||
|
ipc: ipc@2a000 {
|
||||||
|
compatible = "nordic,nrf-ipc";
|
||||||
|
reg = <0x2a000 0x1000>;
|
||||||
|
interrupts = <42 NRF_DEFAULT_IRQ_PRIORITY>;
|
||||||
|
status = "okay";
|
||||||
|
label = "IPC";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Nordic Semiconductor ASA
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/ {
|
||||||
|
soc {
|
||||||
|
peripheral@50000000 {
|
||||||
|
/delete-node/ ipc@2a000;
|
||||||
|
|
||||||
|
ipc: ipc@2a000 {
|
||||||
|
compatible = "nordic,nrf-ipc";
|
||||||
|
reg = <0x2a000 0x1000>;
|
||||||
|
interrupts = <42 NRF_DEFAULT_IRQ_PRIORITY>;
|
||||||
|
status = "okay";
|
||||||
|
label = "IPC";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Nordic Semiconductor ASA
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/ {
|
||||||
|
soc {
|
||||||
|
/delete-node/ ipc@41012000;
|
||||||
|
|
||||||
|
ipc: ipc@41012000 {
|
||||||
|
compatible = "nordic,nrf-ipc";
|
||||||
|
reg = <0x41012000 0x1000>;
|
||||||
|
interrupts = <18 NRF_DEFAULT_IRQ_PRIORITY>;
|
||||||
|
status = "okay";
|
||||||
|
label = "IPC";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,20 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Nordic Semiconductor ASA
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/ {
|
||||||
|
chosen {
|
||||||
|
/*
|
||||||
|
* shared memory reserved for the inter-processor communication
|
||||||
|
*/
|
||||||
|
zephyr,ipc_shm = &sramx;
|
||||||
|
zephyr,ipc = &mhu0;
|
||||||
|
};
|
||||||
|
|
||||||
|
sramx: memory@28180000 {
|
||||||
|
compatible = "mmio-sram";
|
||||||
|
reg = <0x28180000 0x8000>;
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Nordic Semiconductor ASA
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/ {
|
||||||
|
soc {
|
||||||
|
/delete-node/ ipc@41012000;
|
||||||
|
|
||||||
|
ipc: ipc@41012000 {
|
||||||
|
compatible = "nordic,nrf-ipc";
|
||||||
|
reg = <0x41012000 0x1000>;
|
||||||
|
interrupts = <18 NRF_DEFAULT_IRQ_PRIORITY>;
|
||||||
|
status = "okay";
|
||||||
|
label = "IPC";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,20 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Nordic Semiconductor ASA
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/ {
|
||||||
|
chosen {
|
||||||
|
/*
|
||||||
|
* shared memory reserved for the inter-processor communication
|
||||||
|
*/
|
||||||
|
zephyr,ipc_shm = &sramx;
|
||||||
|
zephyr,ipc = &mhu0;
|
||||||
|
};
|
||||||
|
|
||||||
|
sramx: memory@20060000 {
|
||||||
|
compatible = "mmio-sram";
|
||||||
|
reg = <0x20060000 0x8000>;
|
||||||
|
};
|
||||||
|
};
|
|
@ -232,7 +232,7 @@ config NRF53_SYNC_RTC
|
||||||
default y if LOG && !LOG_MODE_MINIMAL
|
default y if LOG && !LOG_MODE_MINIMAL
|
||||||
depends on NRF_RTC_TIMER
|
depends on NRF_RTC_TIMER
|
||||||
select NRFX_DPPI
|
select NRFX_DPPI
|
||||||
select IPM if !MBOX
|
select MBOX if !IPM
|
||||||
|
|
||||||
if NRF53_SYNC_RTC
|
if NRF53_SYNC_RTC
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue