# nRF5340 — Board Knowledge

## Hardware Overview
- **SoC:** nRF5340 — **Dual-core** ARM Cortex-M33
  - **Application Core:** 128 MHz, 1 MB Flash, 512 KB RAM (runs user application)
  - **Network Core:** 64 MHz, 256 KB Flash, 64 KB RAM (runs BLE controller / radio stack)
- **Radio:** 2.4 GHz multi-protocol (BLE 5.3 with Direction Finding, Thread, Zigbee, 802.15.4, NFC)
- **USB:** Full-speed USB 2.0 (on application core)
- **Security:** ARM TrustZone, CryptoCell-312

## Board Target
Use `nrf5340dk/nrf5340/cpuapp` for the application core build target.
Use `nrf5340dk/nrf5340/cpunet` for the network core (typically built automatically via Sysbuild or child images).

## Development Kit: nRF5340 DK (PCA10095)
- **J-Link debugger:** On-board SEGGER J-Link OB (supports RTT for BOTH cores)
- **Two RTT sessions needed:** one for `cpuapp`, one for `cpunet`
- **UART:** Dual VCOM (USB-CDC), one per core

## Dual-Core Architecture — Critical Knowledge

### Building
- Use **Sysbuild** (`west build --sysbuild`) or **child images** to build both cores together.
- The network core runs the SoftDevice Controller (SDC) or the BLE HCI IPC sample (`hci_ipc`).
- Application-side BLE API calls are forwarded to the network core via IPC.

### Logging the Network Core
Controller (LL/radio) logs live on the **Network Core**. To enable them:

Add to `child_image/hci_ipc.conf`:
```ini
CONFIG_MPSL_LOG_LEVEL_DBG=y
CONFIG_SDC_LOG_LEVEL_DBG=y
CONFIG_BT_CTLR_LOG_LEVEL_DBG=y
```

View network core logs via a **second RTT session** targeting `cpunet`:
- The J-Link serial number is the same, but the core target differs.
- Use `nrfutil device log` or a second RTT viewer instance.

### Common Pitfalls
- Forgetting to build the network core image → BLE stack doesn't start.
- Using `nrf5340dk/nrf5340` without specifying `/cpuapp` → ambiguous target.
- Network core assertion crashes only visible via RTT on `cpunet` — invisible on the application core.
- IPC mailbox overflow under heavy BLE traffic → increase `CONFIG_HEAP_MEM_POOL_SIZE`.

## Key Considerations
- TrustZone partitioning: secure/non-secure boot. SPM (Secure Partition Manager) or TF-M required.
- For BLE-only projects, the network core typically auto-builds with `hci_ipc`.
- Power profiling requires external PPK2 or the on-board current measurement pins.
