Skip to content

Commit ef9bc9c

Browse files
author
Marcus Chang
committed
Add NRF52 support for building bootloader and updateable firmware
New directory structure: * TARGET_SOFTDEVICE_COMMON * TARGET_SOFTDEVICE_S112 * TARGET_SOFTDEVICE_S132_FULL (MBR + SoftDevice, default) * TARGET_SOFTDEVICE_S132_OTA (SoftDevice only, for firmware updates) * TARGET_SOFTDEVICE_S132_MBR (MBR only, for bootloader builds) * TARGET_SOFTDEVICE_S140_FULL (MBR + SoftDevice, default) * TARGET_SOFTDEVICE_S140_OTA (SoftDevice only, for firmware updates) * TARGET_SOFTDEVICE_S140_MBR (MBR only, for bootloader builds) * TARGET_SOFTDEVICE_NONE 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. Build application without SoftDevice: "target_overrides": { "*": { "target.extra_labels_remove": ["SOFTDEVICE_COMMON", "SOFTDEVICE_X_FULL"], "target.extra_labels_add": ["SOFTDEVICE_NONE"] } } Build application for firmware update using SoftDevice X: "target_overrides": { "*": { "target.extra_labels_remove": ["SOFTDEVICE_X_FULL"], "target.extra_labels_add": ["SOFTDEVICE_X_OTA"] } } Build bootloader without SoftDevice X: "target_overrides": { "*": { "target.extra_labels_remove": ["SOFTDEVICE_COMMON", "SOFTDEVICE_X_FULL"], "target.extra_labels_add": ["SOFTDEVICE_X_MBR"] } }
1 parent 6af843f commit ef9bc9c

File tree

136 files changed

+26920
-15
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

+26920
-15
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+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Copyright (c) 2007 - 2017, Nordic Semiconductor ASA
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification,
5+
are permitted provided that the following conditions are met:
6+
7+
1. Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
2. Redistributions in binary form, except as embedded into a Nordic
11+
Semiconductor ASA integrated circuit in a product or a software update for
12+
such product, must reproduce the above copyright notice, this list of
13+
conditions and the following disclaimer in the documentation and/or other
14+
materials provided with the distribution.
15+
16+
3. Neither the name of Nordic Semiconductor ASA nor the names of its
17+
contributors may be used to endorse or promote products derived from this
18+
software without specific prior written permission.
19+
20+
4. This software, with or without modification, must only be used with a
21+
Nordic Semiconductor ASA integrated circuit.
22+
23+
5. Any software provided in binary form under this license must not be reverse
24+
engineered, decompiled, modified and/or disassembled.
25+
26+
THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
27+
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28+
OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
29+
DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
30+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
32+
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
35+
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Copyright (c) 2007 - 2017, Nordic Semiconductor ASA
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification,
5+
are permitted provided that the following conditions are met:
6+
7+
1. Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
2. Redistributions in binary form, except as embedded into a Nordic
11+
Semiconductor ASA integrated circuit in a product or a software update for
12+
such product, must reproduce the above copyright notice, this list of
13+
conditions and the following disclaimer in the documentation and/or other
14+
materials provided with the distribution.
15+
16+
3. Neither the name of Nordic Semiconductor ASA nor the names of its
17+
contributors may be used to endorse or promote products derived from this
18+
software without specific prior written permission.
19+
20+
4. This software, with or without modification, must only be used with a
21+
Nordic Semiconductor ASA integrated circuit.
22+
23+
5. Any software provided in binary form under this license must not be reverse
24+
engineered, decompiled, modified and/or disassembled.
25+
26+
THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
27+
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28+
OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
29+
DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
30+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
32+
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
35+
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
:2000000000040020E90800007D050000C908000087050000910500009B05000000000000B6
2+
:200020000000000000000000000000000D090000A505000000000000AF050000B90500008E
3+
:20004000C3050000CD050000D7050000E1050000EB050000F5050000FF0500000906000047
4+
:20006000130600001D06000027060000310600003B060000450600004F06000059060000A0
5+
:20008000630600006D06000077060000810600008B060000950600009F060000A906000000
6+
:2000A000B3060000BD060000C7060000D1060000DB060000E5060000EF060000F906000060
7+
:2000C000030700000D07000017070000210700002B070000350700003F07000049070000B8
8+
:2000E000530700005D07000067070000710700007B070000850700008F0700009907000018
9+
:20010000A30700001FB500F003F88DE80F001FBD00F0E0BB1FB56FF00100009040100390E4
10+
:20012000029001904FF010208069000B420900F01F045DF822300120A04083434DF82230D6
11+
:20014000684600F045F91FBDF0B54FF6FF734FF4B4751A466E1E11E0A94201D3344600E029
12+
:200160000C46091B30F8027B641E3B441A44F9D19CB204EB134394B204EB12420029EBD13A
13+
:2001800098B200EB134002EB124140EA0140F0BDDE4992B00446D1E90001CDE91001FF2229
14+
:2001A0004021684600F03CFB94E80F008DE80F00684610A902E004C841F8042D8842FAD1E6
15+
:2001C00010216846FFF7C0FF1090AA208DF84400FFF7A0FF00F0F3F84FF01024A06910223A
16+
:2001E0006946803000F002F9A069082210A900F0FDF800F0D8F84FF080510A694969006887
17+
:200200004A43824201D8102070470020704710B5D0E900214FF0805002EB810302694469BF
18+
:200220006243934209D84FF01022536903EB81030169406941438B4201D9092010BD5069D7
19+
:20024000401C01D0002010BD0F2010BD70B501680446AF4D4FF01020072952D2DFE801F039
20+
:20026000330419293C1E2500D4E9026564682946304600F0CDF82A462146304600F0B6F811
21+
:20028000AA002146304600F09FFA002800D0032070BD00F051FB4FF4805007E0201DFFF79D
22+
:2002A000AAFF0028F4D100F047FB60682860002070BD241D94E80700920000F085FA0028EC
23+
:2002C000F6D00E2070BD8069401C12D0201DFFF79EFF0028F6D109E08069401C09D0201DD3
24+
:2002E000FFF789FF0028EDD1606820B12046FFF74FFF042070BDFFF70DFF00F060F800F0CC
25+
:2003000052F8072070BD10B50C46182802D00120086010BD2068FFF799FF206010BD4FF01E
26+
:200320001024A069401C05D0A569A66980353079AA2808D06069401C2DD060690068401C7B
27+
:2003400029D060692CE010212846FFF7FDFE316881421CD1A16901F18002C03105E030B1C1
28+
:2003600008CA51F8040D984201D1012000E000208A42F4D158B1286810B1042803D0FEE7B5
29+
:20038000284600F057F862496868086008E000F016F800F008F84FF480500168491C01D045
30+
:2003A00000F0A4FAFEE7BFF34F8F5A4801685A4A01F4E06111430160BFF34F8FFEE74FF0EC
31+
:2003C00010208169491C02D0806900F0AEB87047524A01681160121D416811604F4A816895
32+
:2003E00010321160111DC068086070472DE9F04117460D460646002406E03046296800F091
33+
:20040000A7F8641C2D1D361DBC42F6D3BDE8F08170B50C4605464FF4806608E0284600F012
34+
:2004200084F8B44205D3A4F5806405F58055002CF4D170BD4168044609B1012500E0002530
35+
:200440004FF010267069A268920000F0BDF9C8B1204600F01AF89DB17669A56864684FF4E2
36+
:20046000002084420AD2854208D229463046FFF7CFFF2A4621463046FFF7B8FFFFF79FFFE2
37+
:20048000FFF791FFFFF746FEF8E72DE9FF414FF01024616980680D0B01EB800000F6FF7059
38+
:2004A000010B002000900190029002460390684601230BE0560902F01F0C50F8267003FA6E
39+
:2004C0000CFC47EA0C0740F82670521CAA42F1D30AE04A0901F01F0650F8225003FA06F6DE
40+
:2004E000354340F82250491C8029F2D3A169090B4A0901F01F0150F822408B409C4340F8F9
41+
:200500002240FFF765FFBDE8FF8100005C090000000000200CED00E00400FA050006004053
42+
:20052000144801680029FCD07047134A0221116010490B68002BFCD00F4B1B1D186008681C
43+
:200540000028FCD00020106008680028FCD07047094B10B501221A60064A1468002CFCD082
44+
:20056000016010680028FCD00020186010680028FCD010BD00E4014004E5014008208F498E
45+
:2005800009680958084710208C4909680958084714208A4909680958084718208749096873
46+
:2005A0000958084730208549096809580847382082490968095808473C2080490968095811
47+
:2005C000084740207D4909680958084744207B4909680958084748207849096809580847F2
48+
:2005E0004C207649096809580847502073490968095808475420714909680958084758209B
49+
:200600006E490968095808475C206C49096809580847602069490968095808476420674929
50+
:20062000096809580847682064490968095808476C20624909680958084770205F49096842
51+
:200640000958084774205D4909680958084778205A490968095808477C2058490968095824
52+
:20066000084780205549096809580847842053490968095808478820504909680958084709
53+
:200680008C204E4909680958084790204B4909680958084794204949096809580847982072
54+
:2006A00046490968095808479C204449096809580847A0204149096809580847A4203F4969
55+
:2006C000096809580847A8203C49096809580847AC203A49096809580847B020374909685A
56+
:2006E00009580847B4203549096809580847B8203249096809580847BC203049096809583C
57+
:200700000847C0202D49096809580847C4202B49096809580847C820284909680958084720
58+
:20072000CC202649096809580847D0202349096809580847D4202149096809580847D82049
59+
:200740001E49096809580847DC201C49096809580847E0201949096809580847E4201749A8
60+
:20076000096809580847E8201449096809580847EC201249096809580847F0200F49096871
61+
:2007800009580847F4200D49096809580847F8200A49096809580847FC2008490968095853
62+
:2007A00008475FF480700549096809580847000003480449024A034B70470000000000202F
63+
:2007C000680900006809000040EA010310B59B070FD1042A0DD310C808C9121F9C42F8D034
64+
:2007E00020BA19BA884201D9012010BD4FF0FF3010BD1AB1D30703D0521C07E0002010BDC5
65+
:2008000010F8013B11F8014B1B1B07D110F8013B11F8014B1B1B01D1921EF1D1184610BDF3
66+
:2008200002F0FF0343EA032242EA024200F005B87047704770474FF000020429C0F0128080
67+
:2008400010F0030C00F01B80CCF1040CBCF1020F18BF00F8012BA8BF20F8022BA1EB0C0133
68+
:2008600000F00DB85FEAC17C24BF00F8012B00F8012B48BF00F8012B70474FF0000200B53A
69+
:20088000134694469646203922BFA0E80C50A0E80C50B1F12001BFF4F7AF090728BFA0E8AC
70+
:2008A0000C5048BF0CC05DF804EB890028BF40F8042B08BF704748BF20F8022B11F0804F54
71+
:2008C00018BF00F8012B7047014B1B68DB6818470000002009480A497047FFF7FBFFFFF794
72+
:2008E00011FC00BD20BFFDE7064B1847064A1060016881F30888406800470000680900002E
73+
:20090000680900001F030000000000201EF0040F0CBFEFF30881EFF30981886902380078BE
74+
:20092000182803D100E00000074A1047074A12682C3212681047000000B5054B1B68054A4A
75+
:200940009B58984700BD000007030000000000205809000004000000001000000000000069
76+
:0809600000FFFFFF0090D0032F
77+
:00000001FF

0 commit comments

Comments
 (0)