Skip to content

Commit 4589248

Browse files
committed
nrf5x: add nRF54L support
Add PHY support for nRF54L15, nRF54L10, and nRF54L05 (PCA10156 DK tested). The nRF54L uses a fundamentally different peripheral architecture from nRF52/53: - DPPI cross-domain routing via PPIB bridges instead of PPI - Scatter/gather DMA job lists for CCM, AAR, and ECB instead of flat memory pointers (INPTR/OUTPTR) - TIMER10 as the PHY timer instead of RTC0 - CCM KEY and NONCE registers use reversed byte order This change adds: - nrf54l/phy.c: CCM SG-DMA encrypt/decrypt (FastDecryption mode), AAR SG-DMA address resolution, PPIB routing init, DPPI channel layout - nrf54l/phy_hw.h: peripheral aliases, inline hardware functions, CCM/AAR/ECB attribute constants - nrf54l/phy_ppi.h: DPPI channel definitions and subscribe/publish helpers - nrf52/phy_hw.h: extracted nRF52 inline hardware functions (pure lift-and-shift from ble_phy.c; no logic change) - src/phy_hw.h, src/phy_ppi.h: MCU dispatcher headers (route to nrf54l/, nrf53/, or nrf52/ based on MYNEWT_VAL_CHOICE(MCU_TARGET)) - ble_phy.c: four nRF54L conditional blocks; nRF52/53 behavior unchanged - ble_hw.c: ECB SG-DMA path guarded by NRF_ECB_HAS_ECBDATAPTR - pkg.yml: nRF54L MCU_TARGET conditions for source_files and include_dirs - .github/targets/nordic_pca10156_{blehci,btshell}/: CI targets BLE features enabled: 2M PHY, Coded PHY, LE encryption, LL privacy, extended advertising, periodic advertising, DLE, DTM. nRF52/53 behaviour is unchanged.
1 parent c8ea92d commit 4589248

17 files changed

Lines changed: 1089 additions & 241 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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: "targets/nordic_pca10156_blehci"
21+
pkg.type: "target"
22+
pkg.description:
23+
pkg.author:
24+
pkg.homepage:
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
syscfg.vals:
21+
BLE_PHY_2M: 1
22+
BLE_PHY_CODED: 1
23+
24+
BLE_LL_CFG_FEAT_DATA_LEN_EXT: 1
25+
BLE_LL_CFG_FEAT_LE_ENCRYPTION: 1
26+
BLE_LL_CFG_FEAT_LL_PRIVACY: 1
27+
BLE_LL_CONN_INIT_MAX_TX_BYTES: 251
28+
BLE_LL_CONN_INIT_SLOTS: 4
29+
BLE_LL_DTM: 1
30+
BLE_LL_DTM_EXTENSIONS: 1
31+
BLE_LL_HCI_VS_EVENT_ON_ASSERT: 1
32+
BLE_MAX_CONNECTIONS: 5
33+
BLE_MAX_PERIODIC_SYNCS: 5
34+
BLE_MULTI_ADV_INSTANCES: 5
35+
BLE_EXT_ADV: 1
36+
BLE_PERIODIC_ADV: 1
37+
BLE_PERIODIC_ADV_SYNC_TRANSFER: 1
38+
BLE_VERSION: 51
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
target.app: "@apache-mynewt-nimble/apps/blehci"
21+
target.bsp: "@apache-mynewt-core/hw/bsp/nordic_pca10156"
22+
target.build_profile: "debug"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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: "targets/nordic_pca10156_btshell"
21+
pkg.type: "target"
22+
pkg.description:
23+
pkg.author:
24+
pkg.homepage:
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
syscfg.vals:
21+
BLE_PHY_2M: 1
22+
BLE_PHY_CODED: 1
23+
24+
BLE_LL_CFG_FEAT_DATA_LEN_EXT: 1
25+
BLE_LL_CFG_FEAT_LE_ENCRYPTION: 1
26+
BLE_LL_CFG_FEAT_LL_PRIVACY: 1
27+
BLE_LL_CONN_INIT_MAX_TX_BYTES: 251
28+
BLE_LL_CONN_INIT_SLOTS: 4
29+
BLE_LL_DTM: 1
30+
BLE_LL_DTM_EXTENSIONS: 1
31+
BLE_LL_HCI_VS_EVENT_ON_ASSERT: 1
32+
BLE_MAX_CONNECTIONS: 5
33+
BLE_MAX_PERIODIC_SYNCS: 5
34+
BLE_MULTI_ADV_INSTANCES: 5
35+
BLE_EXT_ADV: 1
36+
BLE_PERIODIC_ADV: 1
37+
BLE_PERIODIC_ADV_SYNC_TRANSFER: 1
38+
BLE_VERSION: 51
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
target.app: "@apache-mynewt-nimble/apps/btshell"
21+
target.bsp: "@apache-mynewt-core/hw/bsp/nordic_pca10156"
22+
target.build_profile: "debug"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ Feature highlight:
6363

6464
## Supported hardware
6565

66-
Controller supports Nordic nRF51, nRF52 and nRF5340 chipsets as well as DA1469x (cmac)
67-
from Renesas. Host runs on any board and architecture
66+
Controller supports Nordic nRF51, nRF52, nRF5340 and nRF54L chipsets as well as
67+
DA1469x (cmac) from Renesas. Host runs on any board and architecture
6868
[supported](https://github.com/apache/mynewt-core#overview) by Apache Mynewt OS.
6969

7070

nimble/doc/transport.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ assuming it's properly configured (see above).
120120
### Combined build
121121

122122
This setup runs both NimBLE host and controller on the same core. It's a typical
123-
configuration when running application on SoCs like nRF51 or nRF52.
123+
configuration when running application on SoCs like nRF51, nRF52 or nRF54L.
124124

125125
Note: this is the default configuration, no need to set it explicitly.
126126

@@ -134,7 +134,7 @@ BLE_TRANSPORT_LL: native
134134
This setup makes NimBLE controller accessible to external host connected via
135135
e.g. UART or USB, so it can be used as an external Bluetooth LE controller.
136136
The controller runs on the same core as external interface. It's typically
137-
used with `blehci` application running on SoCs like nRF51 or nRF52.
137+
used with `blehci` application running on SoCs like nRF51, nRF52 or nRF54L.
138138

139139
```yaml
140140
BLE_TRANSPORT_HS: uart

nimble/drivers/nrf5x/pkg.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#
1919

2020
pkg.name: nimble/drivers/nrf5x
21-
pkg.description: PHY for nRF52 and nRF53 series
21+
pkg.description: PHY for nRF52, nRF53 and nRF54L series
2222
pkg.author: "Apache Mynewt <dev@mynewt.apache.org>"
2323
pkg.homepage: "https://mynewt.apache.org/"
2424
pkg.keywords:
@@ -39,12 +39,12 @@ pkg.source_files.'MCU_TARGET=="nRF52810" || MCU_TARGET=="nRF52811" || MCU_TARGET
3939
- "src/nrf52/phy.c"
4040
pkg.source_files.'MCU_TARGET=="nRF5340_NET"':
4141
- "src/nrf53/phy.c"
42-
pkg.source_files.'MCU_TARGET=="nRF54L15"':
42+
pkg.source_files.'MCU_TARGET=="nRF54L15" || MCU_TARGET=="nRF54L10" || MCU_TARGET=="nRF54L05"':
4343
- "src/nrf54l/phy.c"
4444

4545
pkg.include_dirs.'MCU_TARGET=="nRF52810" || MCU_TARGET=="nRF52811" || MCU_TARGET=="nRF52832" || MCU_TARGET=="nRF52840"':
4646
- "src/nrf52/"
4747
pkg.include_dirs.'MCU_TARGET=="nRF5340_NET"':
4848
- "src/nrf53/"
49-
pkg.include_dirs.'MCU_TARGET=="nRF54L15"':
49+
pkg.include_dirs.'MCU_TARGET=="nRF54L15" || MCU_TARGET=="nRF54L10" || MCU_TARGET=="nRF54L05"':
5050
- "src/nrf54l/"

nimble/drivers/nrf5x/src/ble_hw.c

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,6 @@ ble_hw_encrypt_block(struct ble_encryption_block *ecb)
306306
return rc;
307307
}
308308
#else
309-
#define NRF_ECB NRF_ECB00
310-
#define NRF_AAR NRF_AAR00
311-
312309
/* ECB data structure */
313310
struct ecb_job_entry {
314311
uint8_t *ptr;
@@ -329,9 +326,9 @@ ble_hw_encrypt_block(struct ble_encryption_block *ecb)
329326
nrf_ecb_task_trigger(NRF_ECB, NRF_ECB_TASK_STOP);
330327

331328
ecb_input_job_list[0].ptr = ecb->plain_text;
332-
ecb_input_job_list[0].attr_and_length = (11 << 24) | (16 & 0x00ffffff);
329+
ecb_input_job_list[0].attr_and_length = (ECB_ATTR_DATA << 24) | 16;
333330
ecb_output_job_list[0].ptr = ecb->cipher_text;
334-
ecb_output_job_list[0].attr_and_length = (11 << 24) | (16 & 0x00ffffff);
331+
ecb_output_job_list[0].attr_and_length = (ECB_ATTR_DATA << 24) | 16;
335332

336333
/* The end of a job list shall be 0 */
337334
ecb_input_job_list[1].ptr = 0;
@@ -343,7 +340,14 @@ ble_hw_encrypt_block(struct ble_encryption_block *ecb)
343340
NRF_ECB->EVENTS_ERROR = 0;
344341
NRF_ECB->IN.PTR = (uint32_t)ecb_input_job_list;
345342
NRF_ECB->OUT.PTR = (uint32_t)ecb_output_job_list;
346-
memcpy((void *)NRF_ECB->KEY.VALUE, ecb->key, sizeof(uint32_t) * 4);
343+
/* nRF54L KEY.VALUE uses reversed byte order (same as CCM) */
344+
{
345+
const uint32_t *kp = (const uint32_t *)ecb->key;
346+
NRF_ECB->KEY.VALUE[0] = __builtin_bswap32(kp[3]);
347+
NRF_ECB->KEY.VALUE[1] = __builtin_bswap32(kp[2]);
348+
NRF_ECB->KEY.VALUE[2] = __builtin_bswap32(kp[1]);
349+
NRF_ECB->KEY.VALUE[3] = __builtin_bswap32(kp[0]);
350+
}
347351

348352
/* Start ECB */
349353
nrf_ecb_task_trigger(NRF_ECB, NRF_ECB_TASK_START);
@@ -361,6 +365,12 @@ ble_hw_encrypt_block(struct ble_encryption_block *ecb)
361365
}
362366
}
363367

368+
/* Clear events after polling to prevent a latched ECB event from
369+
* asserting ECB00_IRQn later if another user enables the interrupt. */
370+
NRF_ECB->EVENTS_END = 0;
371+
NRF_ECB->EVENTS_ERROR = 0;
372+
__DSB();
373+
364374
return rc;
365375
}
366376
#endif
@@ -508,7 +518,8 @@ ble_rng_isr(void)
508518
/* No callback? Clear and disable interrupts */
509519
if (g_ble_rng_isr_cb == NULL) {
510520
nrf_cracen_int_disable(NRF_CRACEN, NRF_CRACEN_INT_RNG_MASK);
511-
NRF_CRACENCORE->RNGCONTROL.CONTROL &= ~CRACENCORE_RNGCONTROL_CONTROL_INTENFULL_Msk;
521+
NRF_CRACENCORE->RNGCONTROL.CONTROL &=
522+
~CRACENCORE_RNGCONTROL_CONTROL_INTENFULL_Msk;
512523
NRF_CRACEN->EVENTS_RNG = 0;
513524
os_trace_isr_exit();
514525
return;
@@ -538,10 +549,10 @@ int
538549
ble_hw_rng_init(ble_rng_isr_cb_t cb, int bias)
539550
{
540551
NRF_CRACEN->ENABLE = CRACEN_ENABLE_CRYPTOMASTER_Msk |
541-
CRACEN_ENABLE_RNG_Msk |
542-
CRACEN_ENABLE_PKEIKG_Msk;
552+
CRACEN_ENABLE_RNG_Msk | CRACEN_ENABLE_PKEIKG_Msk;
543553

544-
while (NRF_CRACENCORE->PK.STATUS & CRACENCORE_PK_STATUS_PKBUSY_Msk);
554+
while (NRF_CRACENCORE->PK.STATUS & CRACENCORE_PK_STATUS_PKBUSY_Msk)
555+
;
545556
NRF_CRACENCORE->PK.CONTROL &= ~CRACENCORE_IKG_PKECONTROL_CLEARIRQ_Msk;
546557

547558
NRF_CRACENCORE->RNGCONTROL.CONTROL = CRACENCORE_RNGCONTROL_CONTROL_ResetValue |
@@ -573,7 +584,8 @@ ble_hw_rng_start(void)
573584

574585
if (g_ble_rng_isr_cb) {
575586
nrf_cracen_int_enable(NRF_CRACEN, NRF_CRACEN_INT_RNG_MASK);
576-
NRF_CRACENCORE->RNGCONTROL.CONTROL |= CRACENCORE_RNGCONTROL_CONTROL_INTENFULL_Msk;
587+
NRF_CRACENCORE->RNGCONTROL.CONTROL |=
588+
CRACENCORE_RNGCONTROL_CONTROL_INTENFULL_Msk;
577589
/* Force regeneration of the samples */
578590
NRF_CRACENCORE->RNGCONTROL.FIFOLEVEL = 0;
579591
}
@@ -615,10 +627,9 @@ ble_hw_rng_read(void)
615627

616628
/* Wait for a sample */
617629
while (NRF_CRACENCORE->RNGCONTROL.FIFOLEVEL == 0) {
618-
assert((NRF_CRACENCORE->RNGCONTROL.STATUS &
619-
CRACENCORE_RNGCONTROL_STATUS_STATE_Msk) !=
620-
(CRACENCORE_RNGCONTROL_STATUS_STATE_ERROR <<
621-
CRACENCORE_RNGCONTROL_STATUS_STATE_Pos));
630+
assert((NRF_CRACENCORE->RNGCONTROL.STATUS & CRACENCORE_RNGCONTROL_STATUS_STATE_Msk) !=
631+
(CRACENCORE_RNGCONTROL_STATUS_STATE_ERROR
632+
<< CRACENCORE_RNGCONTROL_STATUS_STATE_Pos));
622633
}
623634

624635
NRF_CRACEN->EVENTS_RNG = 0;

0 commit comments

Comments
 (0)