Skip to content

Commit 2fa6cb5

Browse files
author
Cruz Monrreal
authored
Merge pull request #6826 from marcuschangarm/feature-ota
Reorganize SoftDevices for NRF52 series
2 parents a651cb2 + ef9bc9c commit 2fa6cb5

File tree

136 files changed

+26928
-27
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+26928
-27
lines changed

targets/TARGET_NORDIC/TARGET_NRF5x/README.md

Lines changed: 67 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ First, create a new entry in `mbed-os/targets/targets.json` using the template b
1010
"inherits": [""],
1111
"release_versions": ["5"],
1212
"device_name": ""
13-
},
13+
}
1414
}
1515
```
1616

17-
Where `target_name` is the name of the new target, `inherits` can be either `MCU_NRF52832` or `MCU_NRF52840`, and `device_name` is the ID specifying actual RAM and flash size, for example, `nRF52832_xxAA` and `nRF52840_xxAA`. The `release_version` specifies that the target is compatible with Mbed OS 5.
17+
Where `target_name` is the name of the new target, `inherits` can be either `MCU_NRF52832` or `MCU_NRF52840`, and `device_name` is the ID specifying actual RAM and flash size, for example, `nRF52832_xxAA` and `nRF52840_xxAA`. The `release_version` specifies that the target is compatible with Mbed OS 5.
1818

1919
This entry enables the new target in the Mbed OS build system.
2020

21-
Next, add optional target specific configuration in `mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/mbed_lib.json`.
21+
Next, add optional target specific configuration in `mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/mbed_lib.json`.
2222

2323
```json
2424
{
@@ -40,11 +40,11 @@ The optional configuration includes specifying errata fixes specific for the MCU
4040
LF clock source configuration is used for MCU startup initialization and the BLE SoftDevice LF clock configuration (if BLE libraries is used). Advanced configurations are used only for the BLE SoftDevice LF clock configuration.
4141

4242
Default clock source is XTAL oscillator. There are three options that can be configured as the clock source:
43-
- NRF_LF_SRC_XTAL
44-
- NRF_LF_SRC_RC
45-
- NRF_LF_SRC_SYNTH
43+
- NRF_LF_SRC_XTAL
44+
- NRF_LF_SRC_RC
45+
- NRF_LF_SRC_SYNTH
4646

47-
Set `lf_clock_src` to what is most suitable for the target. This value can later be overridden by the user application if necessary.
47+
Set `lf_clock_src` to what is most suitable for the target. This value can later be overridden by the user application if necessary.
4848

4949

5050
## Mbed HAL Implementation Details
@@ -62,15 +62,15 @@ When instantiating a new Mbed SPI object or I2C object, the object will be assig
6262

6363
1. The driver will look up the pins in the configuration table and pick a pre-assigned instance.
6464
1. If the pins can't be found in the configuration table, the driver will check if a hardware instance has already been assigned to those pins so that objects using the same pins will share the same instance.
65-
1. If no instance has been assigned, the driver will look for a free instane. For I2C objects instances are assigned from 0 to 1. For SPI objects instances are assigned from 2 to 0. This ensures that no matter the order of instantiation the first three objects can be guaranteed to be on separate instances no matter the pins being used.
65+
1. If no instance has been assigned, the driver will look for a free instane. For I2C objects instances are assigned from 0 to 1. For SPI objects instances are assigned from 2 to 0. This ensures that no matter the order of instantiation the first three objects can be guaranteed to be on separate instances no matter the pins being used.
6666
1. If no unused instance can be found, objects not sharing any pins will be assigned to the same default instance, which is `Instance 0` for I2C and `Instance 2` for SPI.
6767

6868
#### Customization
6969

7070
A custom configuration table can be provided by overriding the weakly defined default empty table. In the example below, I2C objects using pins `p1` and `p2` for `SDA` and `SCL` will always be assigned to `Instance 1` and SPI objects using pins `p3`, `p4`, `p5` for `MOSI`, `MISO`, and `CLOCK` will be assigned to `Instance 2` and SPI objects using pins `p6`, `p7`, and `p8` will be assigned to `Instance 0`. The custom configuration table must always be terminated with a row of `NC`.
7171

7272
```
73-
const PinMapI2C PinMap_I2C[] = {
73+
const PinMapI2C PinMap_I2C[] = {
7474
{p1, p2, 1},
7575
{NC, NC, NC}
7676
};
@@ -86,7 +86,7 @@ The tables must be placed in a C compilation file.
8686

8787
#### Concurrency
8888

89-
1. When called from the same thread, it is safe to assign I2C and SPI objects to the same instance.
89+
1. When called from the same thread, it is safe to assign I2C and SPI objects to the same instance.
9090
1. If an instance is being used exclusively for either I2C or SPI, the objects can safely be called from multiple threads.
9191
1. If an instance is being used for both I2C and SPI, the user must provide thread safety between the objects.
9292

@@ -99,7 +99,7 @@ The serial implementation uses the UARTE module which works exclusively through
9999
1. Rx DMA buffer, pre-loaded in EasyDMA for automatic switchover.
100100
1. Rx FIFO buffer, for serving data to the application.
101101

102-
When the first DMA buffer is full or flushed the interrupt handler will automatically copy the DMA buffer to the FIFO buffer. This happens in interrupt context to avoid data loss and with UARTE interrupts set at the highest priority. The FIFO buffer is backed by the Nordic atomic fifo, which can be read and written to safely without disabling interrupts.
102+
When the first DMA buffer is full or flushed the interrupt handler will automatically copy the DMA buffer to the FIFO buffer. This happens in interrupt context to avoid data loss and with UARTE interrupts set at the highest priority. The FIFO buffer is backed by the Nordic atomic fifo, which can be read and written to safely without disabling interrupts.
103103

104104
#### Customization
105105

@@ -128,7 +128,7 @@ All DMA buffers are the same size and must be at least 5 bytes due to hardware r
128128
For the NRF52840, UARTE instances are assigned based on pins and calling order. Serial objects with the same pin configurations will go to the same instance. A custom configuration table can be provided by overriding the weakly defined default empty table. In the example below, serial objects using pins `p1` and `p2` for `Tx` and `Rx` will always be assigned to `Instance 1` and serial objects using pins `p3` and `p4` for `Tx` and `Rx` will be assigned to `Instance 0` regardless of calling order. The custom configuration table must always be terminated with a row of `NC`.
129129

130130
```
131-
const PinMapI2C PinMap_UART[] = {
131+
const PinMapI2C PinMap_UART[] = {
132132
{p1, p2, 1},
133133
{p3, p4, 0},
134134
{NC, NC, NC}
@@ -149,5 +149,59 @@ The RTC2 ISR is set at the lowest interrupt priority to ensure that UARTE interr
149149
* The UARTE hardware only supports 8-bit, None/Even parity, and 1 stop bit.
150150
* The asynchronous read and write implementation currently only support 255 byte transfers.
151151
* The EasyDMA hardware can only read from RAM, which means all Tx buffers must reside in RAM. If a Tx buffer residing in flash is passed to the asynchronous write function, the function will try to copy the Tx buffer to a temporary internal buffer and transmit the data from there.
152-
* It is not possible to do an asynchronous write from flash and receive non-asynchronously at the same time since the non-asynchronous receive buffer is being used as the temporary transmission buffer.
152+
* It is not possible to do an asynchronous write from flash and receive non-asynchronously at the same time since the non-asynchronous receive buffer is being used as the temporary transmission buffer.
153+
154+
## SoftDevice
155+
156+
SoftDevices are treated as bootloaders and automatically combined by the tools. Available SoftDevices:
157+
158+
* TARGET_SOFTDEVICE_COMMON
159+
* TARGET_SOFTDEVICE_S112
160+
* TARGET_SOFTDEVICE_S132_FULL (MBR + SoftDevice, default)
161+
* TARGET_SOFTDEVICE_S132_OTA (SoftDevice only, for firmware updates)
162+
* TARGET_SOFTDEVICE_S132_MBR (MBR only, for bootloader builds)
163+
* TARGET_SOFTDEVICE_S140_FULL (MBR + SoftDevice, default)
164+
* TARGET_SOFTDEVICE_S140_OTA (SoftDevice only, for firmware updates)
165+
* TARGET_SOFTDEVICE_S140_MBR (MBR only, for bootloader builds)
166+
* TARGET_SOFTDEVICE_NONE
167+
168+
NRF52832 uses the S132 SoftDevice and NRF52840 uses the S140 SoftDevice.
169+
170+
The X_OTA and X_MBR binaries are obtained from the original X_FULL SoftDevice by splitting it in an MBR part and a SoftDevice part. The MBR is needed for the bootloader and the SoftDevice for firmware updates.
171+
172+
### Changing SoftDevice
173+
174+
By default, all applications are built with the FULL SoftDevice. This can be changed by modifying the application's `mbed_app.json` configuration file.
175+
176+
Build application without SoftDevice:
177+
178+
```
179+
"target_overrides": {
180+
"*": {
181+
"target.extra_labels_remove": ["SOFTDEVICE_COMMON", "SOFTDEVICE_X_FULL"],
182+
"target.extra_labels_add": ["SOFTDEVICE_NONE"]
183+
}
184+
}
185+
```
186+
187+
Build application for firmware update using SoftDevice X:
188+
189+
```
190+
"target_overrides": {
191+
"*": {
192+
"target.extra_labels_remove": ["SOFTDEVICE_X_FULL"],
193+
"target.extra_labels_add": ["SOFTDEVICE_X_OTA"]
194+
}
195+
}
196+
```
197+
198+
Build bootloader without SoftDevice X:
153199

200+
```
201+
"target_overrides": {
202+
"*": {
203+
"target.extra_labels_remove": ["SOFTDEVICE_COMMON", "SOFTDEVICE_X_FULL"],
204+
"target.extra_labels_add": ["SOFTDEVICE_X_MBR"]
205+
}
206+
}
207+
```

0 commit comments

Comments
 (0)