Skip to content

Commit 2ad67cf

Browse files
committed
hw/drivers: Add support for IPC ICBMsg transport
Tested with nRF5340.
1 parent 7c8d6f0 commit 2ad67cf

File tree

27 files changed

+1700
-1368
lines changed

27 files changed

+1700
-1368
lines changed

hw/bsp/nordic_pca10095/boot-nrf5340.ld

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ MEMORY
2020
{
2121
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x8000
2222
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x80000
23+
sram_ipc0_tx (rw) : ORIGIN = 0x20070000, LENGTH = 0x4000
24+
sram_ipc0_rx (rw) : ORIGIN = 0x20074000, LENGTH = 0x4000
2325
}
2426

2527
/* The bootloader does not contain an image header */

hw/bsp/nordic_pca10095/nrf5340.ld

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ MEMORY
2020
{
2121
FLASH (rx) : ORIGIN = 0x0000c000, LENGTH = 0x76000
2222
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x80000
23+
sram_ipc0_tx (rw) : ORIGIN = 0x20070000, LENGTH = 0x4000
24+
sram_ipc0_rx (rw) : ORIGIN = 0x20074000, LENGTH = 0x4000
2325
}
2426

2527
/* This linker script is used for images and thus contains an image header */

hw/bsp/nordic_pca10095/syscfg.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,30 @@ syscfg.vals.BLE_TRANSPORT:
108108
BLE_TRANSPORT_LL: nrf5340
109109

110110
syscfg.vals.BSP_NRF5340_NET_ENABLE:
111-
BSP_NRF5340_NET_FLASH_ENABLE: 1
112111
BLE_HCI_VS: 1
113112

113+
syscfg.vals.'BSP_NRF5340_NET_ENABLE && BLE_TRANSPORT_LL != "ipc"':
114+
BSP_NRF5340_NET_FLASH_ENABLE: 1
115+
114116
syscfg.vals.BSP_NRF5340_NET_FLASH_ENABLE:
115117
IPC_NRF5340_CHANNELS: 4
116118

117119
syscfg.vals.IPC_NRF5340_FLASH_CLIENT:
118120
HAL_FLASH_MAX_DEVICE_COUNT: 3
119121

122+
syscfg.vals.'BLE_TRANSPORT_LL=="ipc" || BLE_TRANSPORT_IPC_BACKEND=="icbmsg"':
123+
# The APP core have the same values but switched directions
124+
BLE_TRANSPORT_IPC_TX_CHANNEL: 0
125+
BLE_TRANSPORT_IPC_RX_CHANNEL: 1
126+
IPC_SYNC_TX_CHANNEL: 0
127+
IPC_SYNC_RX_CHANNEL: 1
128+
IPC_ICBMSG_TX_REGION_NAME: "\".ipc0_tx\""
129+
IPC_ICBMSG_RX_REGION_NAME: "\".ipc0_rx\""
130+
IPC_ICBMSG_NUM_TX_BLOCKS: 16
131+
IPC_ICBMSG_NUM_RX_BLOCKS: 24
132+
IPC_ICBMSG_TX_REGION_SIZE: 0x4000
133+
IPC_ICBMSG_RX_REGION_SIZE: 0x4000
134+
120135
syscfg.restrictions.BSP_NRF5340_NET_FLASH_ENABLE:
121136
- 'IPC_NRF5340_CHANNELS >= 4'
122137

hw/bsp/nordic_pca10095_net/boot-nrf5340_net.ld

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ MEMORY
2121
FLASH (rx) : ORIGIN = 0x01000000, LENGTH = 0x4000
2222
RAM (rwx) : ORIGIN = 0x21000000, LENGTH = 0x10000
2323
IPC (rw) : ORIGIN = 0x20000400, LENGTH = 0x400
24+
sram_ipc0_tx (rw) : ORIGIN = 0x20070000, LENGTH = 0x4000
25+
sram_ipc0_rx (rw) : ORIGIN = 0x20074000, LENGTH = 0x4000
2426
}
2527

2628
/* The bootloader does not contain an image header */

hw/bsp/nordic_pca10095_net/nrf5340_net.ld

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ MEMORY
2121
FLASH (rx) : ORIGIN = 0x01008000, LENGTH = 0x30000
2222
RAM (rwx) : ORIGIN = 0x21000000, LENGTH = 0x10000
2323
IPC (rw) : ORIGIN = 0x20000400, LENGTH = 0x400
24+
sram_ipc0_tx (rw) : ORIGIN = 0x20070000, LENGTH = 0x4000
25+
sram_ipc0_rx (rw) : ORIGIN = 0x20074000, LENGTH = 0x4000
2426
}
2527

2628
/* This linker script is used for images and thus contains an image header */

hw/bsp/nordic_pca10095_net/pkg.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,7 @@ pkg.deps:
3434
- "@apache-mynewt-core/hw/scripts"
3535
- "@apache-mynewt-core/hw/mcu/nordic/nrf5340_net"
3636
- "@apache-mynewt-core/libc"
37+
38+
pkg.deps.'BLE_TRANSPORT == 1 && BLE_TRANSPORT_HS != "ipc"':
3739
- "@apache-mynewt-core/sys/flash_map"
3840
- "@apache-mynewt-core/hw/drivers/flash/ipc_nrf5340_flash"

hw/bsp/nordic_pca10095_net/syscfg.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,16 @@ syscfg.vals.BLE_CONTROLLER:
7979

8080
syscfg.vals.BLE_TRANSPORT:
8181
BLE_TRANSPORT_HS: nrf5340
82+
83+
syscfg.vals.'BLE_TRANSPORT_HS=="ipc" || BLE_TRANSPORT_IPC_BACKEND=="icbmsg"':
84+
# The APP core have the same values but switched directions
85+
BLE_TRANSPORT_IPC_TX_CHANNEL: 1
86+
BLE_TRANSPORT_IPC_RX_CHANNEL: 0
87+
IPC_SYNC_TX_CHANNEL: 1
88+
IPC_SYNC_RX_CHANNEL: 0
89+
IPC_ICBMSG_TX_REGION_NAME: "\".ipc0_rx\""
90+
IPC_ICBMSG_RX_REGION_NAME: "\".ipc0_tx\""
91+
IPC_ICBMSG_NUM_TX_BLOCKS: 24
92+
IPC_ICBMSG_NUM_RX_BLOCKS: 16
93+
IPC_ICBMSG_TX_REGION_SIZE: 0x4000
94+
IPC_ICBMSG_RX_REGION_SIZE: 0x4000
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
#ifndef _HW_DRIVERS_IPC_ICBMSG_H
21+
#define _HW_DRIVERS_IPC_ICBMSG_H
22+
23+
#include <stdint.h>
24+
#include <stdbool.h>
25+
#include <os/os.h>
26+
27+
#ifdef __cplusplus
28+
extern "C" {
29+
#endif
30+
31+
struct ipc_service_cb {
32+
void (*received)(const void *data, size_t len, void *user_data);
33+
};
34+
35+
struct ipc_ept_cfg {
36+
const char *name;
37+
struct ipc_service_cb cb;
38+
void *user_data;
39+
uint8_t tx_channel;
40+
uint8_t rx_channel;
41+
};
42+
43+
struct ipc_icmsg_buf {
44+
size_t block_id;
45+
uint8_t *data;
46+
uint16_t len;
47+
};
48+
49+
typedef void (*ipc_icbmsg_recv_cb)(uint8_t ipc_id, void *user_data);
50+
51+
uint8_t ipc_icmsg_register_ept(uint8_t ipc_id, struct ipc_ept_cfg *cfg);
52+
53+
int ipc_icbmsg_send(uint8_t ipc_id, uint8_t ept_addr, const void *data, uint16_t len);
54+
55+
int ipc_icbmsg_send_buf(uint8_t ipc_id, uint8_t ept_addr, struct ipc_icmsg_buf *buf);
56+
57+
int ipc_icbmsg_alloc_tx_buf(uint8_t ipc_id, struct ipc_icmsg_buf *buf, uint32_t size);
58+
59+
uint8_t ipc_icsmsg_ept_ready(uint8_t ipc_id, uint8_t ept_addr);
60+
61+
#ifdef __cplusplus
62+
}
63+
#endif
64+
65+
#endif /* _HW_DRIVERS_IPC_ICBMSG_H */

hw/drivers/ipc/icbmsg/pkg.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
pkg.name: hw/drivers/ipc/icbmsg
21+
pkg.description: IPC driver with icbmsg backend
22+
pkg.author: "Apache Mynewt <[email protected]>"
23+
pkg.homepage: "http://mynewt.apache.org/"
24+
pkg.keywords:
25+
- ipc
26+
27+
pkg.deps:
28+
- "@apache-mynewt-core/hw/mcu/nordic"
29+
- "@apache-mynewt-core/kernel/os"

0 commit comments

Comments
 (0)