You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/porting/connectivity/NetworkStack.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
##NetworkStack
1
+
# NetworkStack
2
2
3
3
As explained in the [IP networking architecture](../reference/ip-networking.html) page, the [Socket API](../apis/network-socket.html) provides a TCP or UDP API on top of any IP based network stack. With the Socket API, you can write applications and libraries that use TCP or UDP sockets without regard to the type of IP connectivity. In addition to providing the TCP or UDP API, the Socket API includes virtual base classes for the different IP interface types.
Copy file name to clipboardExpand all lines: docs/porting/custom-target-porting.md
+46-46Lines changed: 46 additions & 46 deletions
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,13 @@ When designing a custom microcontroller board to run Mbed OS, you may need to ma
4
4
5
5
This tutorial covers the most common methods used to create a custom port of Mbed OS when starting from an existing Mbed Enabled board. For detailed information on how to create a port from scratch, go to the [Mbed Porting guide](../porting/index.html). Additionally, not all possible aspects of target configuration are covered. For detailed information on all the ways you can configure targets, go to [adding and configuring targets](../reference/adding-and-configuring-targets.html).
6
6
7
-
# Extending an existing MCU target configuration
7
+
##Extending an existing MCU target configuration
8
8
9
-
Consider a situation in which you are creating a new board based on an existing Mbed Enabled board. This tutorial lists the steps to create the software for a new board we will call `ImaginaryBoard`. This board is based on [DISCO-L475VG-IOT01A](https://os.mbed.com/platforms/ST-Discovery-L475E-IOT01A/). It shares most of the features of DISCO-L475VG-IOT01A, but it does not use `AnalogOut`, `AnalogIn`, `CAN` or `USB`. Some pins are connected differently on the new board.
9
+
Consider a situation in which you are creating a new board based on an existing Mbed Enabled board. This tutorial lists the steps to create the software for a new board we will call `ImaginaryBoard`. This board is based on [DISCO-L475VG-IOT01A](https://os.mbed.com/platforms/ST-Discovery-L475E-IOT01A/). It shares most of the features of DISCO-L475VG-IOT01A, but it does not use `AnalogOut`, `AnalogIn`, `CAN` or `USB`. Some pins are connected differently on the new board.
10
10
11
11
Follow these steps to create a custom port for Mbed OS:
12
12
13
-
## Preparing
13
+
###Preparing
14
14
15
15
1.[Install Mbed CLI](../tools/installation-and-setup.html) if you don't already have it.
16
16
@@ -21,22 +21,22 @@ Follow these steps to create a custom port for Mbed OS:
21
21
```
22
22
mbed new --program mbed-os-imaginary-port
23
23
```
24
-
24
+
25
25
This command creates a new program folder called `mbed-os-imaginary-port` and then imports `mbed-os` from the [official Mbed OS source repository](https://github.com/armmbed/mbed-os) into it.
26
26
27
27
1. Change directories into your new project:
28
28
29
29
```
30
30
cd mbed-os-imaginary-port
31
31
```
32
-
32
+
33
33
1. Create a new file named `custom_targets.json` at the same level as the `mbed-os` directory.
34
34
35
35
1. Inspect the contents of `mbed-os/targets/targets.json`. For this example, search for `DISCO_L475VG_IOT01A`.
36
36
37
37
1. Copy the contents from the `DISCO_L475VG_IOT01A` section into your `custom_targets.json` file. Be sure to include brackets `{ }` surrounding the content.
38
38
39
-
## Customizing
39
+
###Customizing
40
40
41
41
1. Make changes to `custom_targets.json` for your board.
42
42
@@ -48,7 +48,7 @@ Follow these steps to create a custom port for Mbed OS:
48
48
1. The `device_has_add` section changes to remove the `ANALOGOUT`, `CAN`, and `USBDEVICE` drivers because the new board doesn't use those features.
49
49
50
50
After making changes, the full contents look like this:
51
-
51
+
52
52
```
53
53
{
54
54
"IMAGINARYBOARD": {
@@ -92,11 +92,11 @@ Follow these steps to create a custom port for Mbed OS:
92
92
}
93
93
```
94
94
95
-
### Additions
95
+
####Additions
96
96
97
97
A new section, `device_has_remove`, was added. This removes the `ANALOGIN`, `I2CSLAVE` and `I2C_ASYNCH` drivers because these features are also not used. The reason why `device_has_remove` is used in this case is because the board is inheriting from the MCU Family configuration `FAMILY_STM32`, which has those drivers added by default.
98
98
99
-
### Other possible additions
99
+
####Other possible additions
100
100
101
101
Other changes you may need include:
102
102
@@ -105,11 +105,11 @@ Other changes you may need include:
105
105
106
106
<spanclass="notes">**Note:** If you choose to add a driver that is not already available for your hardware, you will have to provide the driver implementation.</span>
107
107
108
-
### Where other configurations live
108
+
####Where other configurations live
109
109
110
110
All the other configurations for the board are inherited from the MCU Family configuration called `FAMILY_STM32`.
111
111
112
-
# Configuring the target code directories
112
+
##Configuring the target code directories
113
113
114
114
In some cases, the target source code directories follow a similar structure to the target configuration, but they could have a few more levels.
115
115
@@ -128,43 +128,43 @@ Boards typically inherit files that support the MCU, MCU family and MCU vendor.
128
128
129
129
There are more directory levels than target configuration levels because many targets use the `extra_labels_add` feature in the target configuration. The keywords `STM32L4`, `STM32L475xG` and `STM32L475VG` resolve to `TARGET_STM32L4`, `TARGET_STM32L475xG` and `TARGET_STM32L475VG`, respectively. With those labels applied, the build includes these directory names for this target.
130
130
131
-
## Preparing
131
+
###Preparing
132
132
133
133
1. Create a new directory called `TARGET_IMAGINARYBOARD` at the top level of your project to store the source files for your board.
134
-
134
+
135
135
1. Inspect the files at `mbed-os\targets\TARGET_STM\TARGET_STM32L4\TARGET_STM32L475xG\TARGET_DISCO_L475VG_IOT01A`. You should find the following files or similar:
1. Copy the files into your new `TARGET_IMAGINARYBOARD` directory.
140
-
140
+
141
141
The files provide these capabilities:
142
-
142
+
143
143
-`PeripheralNames.h` describes the available peripherals and their base addresses.
144
144
-`PeripheralPins.c` describes the available pins and their association with peripherals.
145
145
-`PinNames.h` sets macros for pins that define their function.
146
146
-`system_clock.c` vendor specific file that initializes the system and sets up the clocks.
147
147
148
-
## Customizing
149
-
148
+
###Customizing
149
+
150
150
1. Modify the files.
151
151
152
152
`PinNames.h` is the most common file to be edited. For this tutorial, the ImaginaryBoard uses I2C but connected to different supported signals. Change the I2C pin macro definitions from:
153
-
153
+
154
154
```
155
155
I2C_SCL = D15,
156
156
I2C_SDA = D14,
157
157
```
158
-
158
+
159
159
to
160
-
160
+
161
161
```
162
162
I2C_SCL = PC_0,
163
163
I2C_SDA = PC_1,
164
164
```
165
-
165
+
166
166
You may also choose to add or remove peripherals, add or remove pins or change the clock frequency by editing `PeripheralNames.h`, `PeripheralPins.c`, or `system_clock.c`. For simplicity, this tutorial doesn't edit these files.
167
-
167
+
168
168
1. (Optional) Add additional source files for drivers or middleware you have implemented for the new board. This tutorial doesn't have any files to add.
169
169
170
170
1. (Optional) Add a simple application source file for testing.
@@ -173,7 +173,7 @@ There are more directory levels than target configuration levels because many ta
173
173
174
174
```
175
175
#include "mbed.h"
176
-
176
+
177
177
DigitalOut led1(LED1);
178
178
179
179
int main()
@@ -183,12 +183,12 @@ There are more directory levels than target configuration levels because many ta
183
183
wait_ms(500);
184
184
}
185
185
}
186
-
```
187
-
186
+
```
187
+
188
188
This blinks an LED. If `LED1` is not defined, inspect `PinNames.h` for a valid pin definition for an available LED.
189
-
189
+
190
190
Your directory now looks something like this:
191
-
191
+
192
192
```
193
193
main.cpp
194
194
custom_target.json
@@ -199,60 +199,60 @@ There are more directory levels than target configuration levels because many ta
199
199
mbed-os.lib
200
200
```
201
201
202
-
# Testing your code
203
-
202
+
##Testing your code
203
+
204
204
1. Compile the application:
205
-
205
+
206
206
```
207
207
mbed compile -m IMAGINARYBOARD -t <toolchain>
208
208
```
209
-
209
+
210
210
When successful, it compiles, links and generates a `.bin` file (or `.hex` file for some other boards).
You can test this using a `DISCO-L475VG-IOT01A`. If you actually created an `ImaginaryBoard` board, you could use that, too.
221
-
221
+
222
222
<spanclass="notes">**Note:** Unless your board has an Mbed Enabled debug interface, you need a method of flashing the memory on your board.</span>
223
-
223
+
224
224
Because the `DISCO-L475VG-IOT01A` has an Mbed Enabled debug interface (STLink in this case), you can use drag-and-drop programming to flash the board.
225
-
225
+
226
226
1. Locate the binary file, and drag it onto the disk drive name for the board (for example, `DIS_L4IOT`).
227
-
227
+
228
228
1. Wait for the file transfer to complete.
229
-
229
+
230
230
1. Run the application
231
231
232
232
Press the reset button on the board. You should see the LED blinking.
233
-
233
+
234
234
1. (Optional) Run automated tests.
235
235
236
236
With an Mbed Enabled debug interface, you can also run the Mbed OS automated tests on your port. Because a new board has a new name unknown to the Mbed tools, you need to tell the tools which `Platform ID` (aka `detect_code`) to associate it to.
237
-
237
+
238
238
To do this, you can use the `mbedls``mock` command option. This tutorial tests with a `DISCO-L475VG-IOT01A`, which has a debug interface that exposes `0764` as its `Platform ID`. If you have a new board that uses a different `Platform ID`, such as `1234`, then use that.
239
-
239
+
240
240
For the `ImaginaryBoard` based on `DISCO-L475VG-IOT01A`, run this command.
241
241
242
242
```
243
243
mbedls --mock 0764:IMAGINARYBOARD
244
244
```
245
-
245
+
246
246
<spanclass="notes">**Note:** If you intend to release a new target to the Mbed community, it needs a unique Platform ID. To get one, please contact your technical account manager or email [our support team](mailto:[email protected]).</span>
247
247
248
248
1. Run the tests, with the following command:
249
-
249
+
250
250
```
251
251
mbed test -m IMAGINARYBOARD -t <toolchain>
252
252
```
253
-
253
+
254
254
The tests start running.
255
-
255
+
256
256
For more information on testing a new board, go to the [Testing your port](../porting/testing.html) section of the porting guide.
257
257
258
258
Now you have successfully ported Mbed OS to a new board.
Copy file name to clipboardExpand all lines: docs/porting/psa/TLS-on-PSA.md
+12-12Lines changed: 12 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,14 @@
1
1
# Using PSA-enabled Mbed TLS
2
2
3
-
# Building PSA-enabled Mbed TLS from Git
3
+
##Building PSA-enabled Mbed TLS from Git
4
4
5
5
The version of Mbed TLS shipped in Mbed OS builds with PSA enabled by default. However, you can build a PSA-enabled version of Mbed TLS from [our Git repository](https://github.com/ARMmbed/mbedtls):
6
6
7
7
1. Clone the repository, switch to the `development-psa` branch and initialize the submodule: `git checkout development-psa && git submodule update --init`.
8
8
1. Enable the `MBEDTLS_USE_PSA_CRYPTO` build-time configuration option in `include/mbedtls/config.h`, either by editing the file manually, or using the config script: `scripts/config.pl set MBEDTLS_USE_PSA_CRYPTO`.
9
9
1. Build normally, for example (with GNU Make) make all test or (with CMake) `mkdir build && cd build && cmake .. && make all test`.
10
10
11
-
# Using PSA-enabled Mbed TLS
11
+
##Using PSA-enabled Mbed TLS
12
12
13
13
If an application was built with Mbed TLS that was not PSA enabled, you can still use the application with PSA-enabled Mbed TLS by recompiling it against a PSA-enabled version of Mbed TLS. (Note that relinking is not enough, though.) In other words, PSA-enabled Mbed TLS is fully API compatible with non-PSA-enabled Mbed TLS but not ABI compatible. All existing (pre-PSA) APIs are preserved and continue to exist in parallel with PSA-based APIs.
14
14
@@ -18,17 +18,17 @@ If your application doesn't use any of the PSA-specific APIs described below, th
18
18
19
19
If your application uses one of the PSA-specific APIs described below, then you need to change its source code because the APIs have changed in an incompatible way between Mbed OS 5.11 and Mbed OS 5.12 to reflect changes in PSA Crypto, whose API wasn't stable as of Mbed OS 5.11.
20
20
21
-
# PSA-based APIs in Mbed TLS
21
+
##PSA-based APIs in Mbed TLS
22
22
23
23
As mentioned in the previous section, you can use PSA-neabled Mbed TLS to build applications that are not PSA enabled. Doing so is enough to benefit from PSA in some areas (for example, some PSA-based hardware acceleration, depending on platform support), but in other areas, changes in the application source code are necessary. This mainly means replacing calls to pre-PSA APIs with calls to their PSA-based versions.
24
24
25
25
The new APIs allow using PSA-managed keys for a few purposes, such as TLS client authentication, CSR generation and TLS PSK connections. Letting the key be managed by PSA is good for security because PSA can isolate the keys from the rest of the applications (referred to below as "opaque keys"). To use such PSA-managed keys, you need to modify your code to use the new APIs as described below.
26
26
27
-
# Using opaque ECDSA keys for TLS client authentication
27
+
##Using opaque ECDSA keys for TLS client authentication
28
28
29
29
This mainly involves using the new API function `mbedtls_pk_setup_opaque()` to wrap a PSA-managed key into a PK context, then using that context with the usual TLS APIs.
30
30
31
-
## Application flow without PSA
31
+
###Application flow without PSA
32
32
33
33
1. At application startup, make sure `mbedtls_platform_setup()` is called if relevant.
34
34
1. Declare (and allocate) an object of type `mbedtls_pk_context`.
@@ -37,7 +37,7 @@ This mainly involves using the new API function `mbedtls_pk_setup_opaque()` to w
37
37
1. Use the resulting SSL configuration for TLS connections as usual.
38
38
1. When you're done using TLS connections based on that configuration, _and no longer want to use that key for anything else_, free the PK context using `mbedtls_pk_free()`.
39
39
40
-
## Application flow with PSA
40
+
###Application flow with PSA
41
41
42
42
1. At application startup, make sure `mbedtls_platform_setup()` is called if relevant, and make sure `psa_crypto_init()` is called, too.
43
43
1. Declare (and allocate) an object of type `mbedtls_pk_context`*and an object of type `psa_key_handle_t`*.
@@ -47,11 +47,11 @@ This mainly involves using the new API function `mbedtls_pk_setup_opaque()` to w
47
47
1. Use the resulting SSL configuration for TLS connections as usual.
48
48
1. When you're done using TLS connections based on that configuration, free the PK context using `mbedtls_pk_free()`. This only frees the PK context itself and leaves the key handle untouched. You can either keep using the key handle or call `psa_destroy_key()` on it depending on your application flow.
49
49
50
-
# Using opaque ECDSA keys to generate certificate signing requests (CSRs)
50
+
##Using opaque ECDSA keys to generate certificate signing requests (CSRs)
51
51
52
52
This mainly involves using the API function `mbedtls_pk_setup_opaque()` to wrap a PSA-managed key into a PK context, then using that context with the usual TLS APIs.
53
53
54
-
## Application flow without PSA
54
+
###Application flow without PSA
55
55
56
56
1. At application startup, make sure `mbedtls_platform_setup() is called if relevant.
57
57
1. Declare (and allocate) an object of type `mbedtls_pk_context`
@@ -60,7 +60,7 @@ This mainly involves using the API function `mbedtls_pk_setup_opaque()` to wrap
60
60
1. Call any other function you need to configure and generate the CSR.
61
61
1. When you're done generating the CSR, _and no longer want to use that key for anything else_, free the PK context using `mbedtls_pk_free()`.
62
62
63
-
## Application flow with PSA
63
+
###Application flow with PSA
64
64
65
65
1. At application startup, make sure `mbedtls_platform_setup()` is called if relevant, and make sure `psa_crypto_init()` is called, too.
66
66
1. Declare (and allocate) an object of type `mbedtls_pk_context` and an object of type *`psa_key_handle_t`*.
@@ -70,18 +70,18 @@ This mainly involves using the API function `mbedtls_pk_setup_opaque()` to wrap
70
70
1. Call any other function that you need to configure and generate the CSR.
71
71
1. When you're done generating the CSR, free the PK context using `mbedtls_pk_free()`. This only frees the PK context itself and leaves the key *handle* untouched. You can either keep using the key *handle* or call `psa_destroy_key()` on it, depending on your application flow.
72
72
73
-
# Using opaque pre-shared keys with TLS PSK ciphersuites
73
+
##Using opaque pre-shared keys with TLS PSK ciphersuites
74
74
75
75
This mainly involves using the API function `mbedtls_ssl_conf_psk_opaque()` in place of `mbedtls_ssl_conf_psk()` client-side or, server-side using `mbedtls_ssl_set_hs_psk_opaque()` instead of `mbedtls_ssl_set_hs_psk()` in the PSK callback.
76
76
77
-
## Application flow without PSA
77
+
###Application flow without PSA
78
78
79
79
1. At application startup, make sure `mbedtls_platform_setup()` is called if relevant.
80
80
1. Set up an `unsigned char *` to point to a memory area holding your pre-shared key.
81
81
1. Call `mbedtls_ssl_conf_psk()` on the SSL configuration object.
82
82
1. Use that configuration object in TLS connections.
83
83
84
-
## Application flow with PSA
84
+
###Application flow with PSA
85
85
86
86
1. At application startup, make sure `mbedtls_platform_setup()` is called if relevant, and make sure `psa_crypto_init()` is called, too.
87
87
1. Set up a *`psa_key_handle_t`* to point to a configured slot holding your pre-shared key.
0 commit comments