Skip to content

Commit fedbd1c

Browse files
committed
Porting header changes
1 parent 4f3f38d commit fedbd1c

37 files changed

+300
-304
lines changed

docs/porting/connectivity/NetworkStack.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## NetworkStack
1+
# NetworkStack
22

33
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.
44

docs/porting/connectivity/connectivity.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<h1 id="contributing-connectivity">Connectivity</h1>
22

3-
## The network socket API
4-
5-
### New device
3+
## The network socket API - new device
64

75
The NetworkSocketAPI is designed to make porting new devices as easy as possible and only requires a handful of methods for a minimal implementation.
86

docs/porting/custom-target-porting.md

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ When designing a custom microcontroller board to run Mbed OS, you may need to ma
44

55
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).
66

7-
# Extending an existing MCU target configuration
7+
## Extending an existing MCU target configuration
88

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.
1010

1111
Follow these steps to create a custom port for Mbed OS:
1212

13-
## Preparing
13+
### Preparing
1414

1515
1. [Install Mbed CLI](../tools/installation-and-setup.html) if you don't already have it.
1616

@@ -21,22 +21,22 @@ Follow these steps to create a custom port for Mbed OS:
2121
```
2222
mbed new --program mbed-os-imaginary-port
2323
```
24-
24+
2525
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.
2626

2727
1. Change directories into your new project:
2828

2929
```
3030
cd mbed-os-imaginary-port
3131
```
32-
32+
3333
1. Create a new file named `custom_targets.json` at the same level as the `mbed-os` directory.
3434

3535
1. Inspect the contents of `mbed-os/targets/targets.json`. For this example, search for `DISCO_L475VG_IOT01A`.
3636

3737
1. Copy the contents from the `DISCO_L475VG_IOT01A` section into your `custom_targets.json` file. Be sure to include brackets `{ }` surrounding the content.
3838

39-
## Customizing
39+
### Customizing
4040

4141
1. Make changes to `custom_targets.json` for your board.
4242

@@ -48,7 +48,7 @@ Follow these steps to create a custom port for Mbed OS:
4848
1. The `device_has_add` section changes to remove the `ANALOGOUT`, `CAN`, and `USBDEVICE` drivers because the new board doesn't use those features.
4949

5050
After making changes, the full contents look like this:
51-
51+
5252
```
5353
{
5454
"IMAGINARYBOARD": {
@@ -92,11 +92,11 @@ Follow these steps to create a custom port for Mbed OS:
9292
}
9393
```
9494

95-
### Additions
95+
#### Additions
9696

9797
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.
9898

99-
### Other possible additions
99+
#### Other possible additions
100100

101101
Other changes you may need include:
102102

@@ -105,11 +105,11 @@ Other changes you may need include:
105105

106106
<span class="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>
107107

108-
### Where other configurations live
108+
#### Where other configurations live
109109

110110
All the other configurations for the board are inherited from the MCU Family configuration called `FAMILY_STM32`.
111111

112-
# Configuring the target code directories
112+
## Configuring the target code directories
113113

114114
In some cases, the target source code directories follow a similar structure to the target configuration, but they could have a few more levels.
115115

@@ -128,43 +128,43 @@ Boards typically inherit files that support the MCU, MCU family and MCU vendor.
128128

129129
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.
130130

131-
## Preparing
131+
### Preparing
132132

133133
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+
135135
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:
136-
136+
137137
`PeripheralNames.h`, `PeripheralPins.c`, `PinNames.h`, `system_clock.c`
138-
138+
139139
1. Copy the files into your new `TARGET_IMAGINARYBOARD` directory.
140-
140+
141141
The files provide these capabilities:
142-
142+
143143
- `PeripheralNames.h` describes the available peripherals and their base addresses.
144144
- `PeripheralPins.c` describes the available pins and their association with peripherals.
145145
- `PinNames.h` sets macros for pins that define their function.
146146
- `system_clock.c` vendor specific file that initializes the system and sets up the clocks.
147147

148-
## Customizing
149-
148+
### Customizing
149+
150150
1. Modify the files.
151151

152152
`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+
154154
```
155155
I2C_SCL = D15,
156156
I2C_SDA = D14,
157157
```
158-
158+
159159
to
160-
160+
161161
```
162162
I2C_SCL = PC_0,
163163
I2C_SDA = PC_1,
164164
```
165-
165+
166166
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+
168168
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.
169169

170170
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
173173

174174
```
175175
#include "mbed.h"
176-
176+
177177
DigitalOut led1(LED1);
178178
179179
int main()
@@ -183,12 +183,12 @@ There are more directory levels than target configuration levels because many ta
183183
wait_ms(500);
184184
}
185185
}
186-
```
187-
186+
```
187+
188188
This blinks an LED. If `LED1` is not defined, inspect `PinNames.h` for a valid pin definition for an available LED.
189-
189+
190190
Your directory now looks something like this:
191-
191+
192192
```
193193
main.cpp
194194
custom_target.json
@@ -199,60 +199,60 @@ There are more directory levels than target configuration levels because many ta
199199
mbed-os.lib
200200
```
201201

202-
# Testing your code
203-
202+
## Testing your code
203+
204204
1. Compile the application:
205-
205+
206206
```
207207
mbed compile -m IMAGINARYBOARD -t <toolchain>
208208
```
209-
209+
210210
When successful, it compiles, links and generates a `.bin` file (or `.hex` file for some other boards).
211211

212212
For example, it prints to the screen:
213-
213+
214214
```
215215
Image: .\BUILD\IMAGINARYBOARD\GCC_ARM\mbed-os-imaginary-port.bin
216216
```
217217

218218
1. Program the board.
219219

220220
You can test this using a `DISCO-L475VG-IOT01A`. If you actually created an `ImaginaryBoard` board, you could use that, too.
221-
221+
222222
<span class="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+
224224
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+
226226
1. Locate the binary file, and drag it onto the disk drive name for the board (for example, `DIS_L4IOT`).
227-
227+
228228
1. Wait for the file transfer to complete.
229-
229+
230230
1. Run the application
231231

232232
Press the reset button on the board. You should see the LED blinking.
233-
233+
234234
1. (Optional) Run automated tests.
235235

236236
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+
238238
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+
240240
For the `ImaginaryBoard` based on `DISCO-L475VG-IOT01A`, run this command.
241241

242242
```
243243
mbedls --mock 0764:IMAGINARYBOARD
244244
```
245-
245+
246246
<span class="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>
247247

248248
1. Run the tests, with the following command:
249-
249+
250250
```
251251
mbed test -m IMAGINARYBOARD -t <toolchain>
252252
```
253-
253+
254254
The tests start running.
255-
255+
256256
For more information on testing a new board, go to the [Testing your port](../porting/testing.html) section of the porting guide.
257257

258258
Now you have successfully ported Mbed OS to a new board.

docs/porting/porting_full_process/built_in_tests.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ It's important to test your port at the end of each module porting, rather than
55
1. Running the Mbed OS built-in tests with [*Greentea*](../tools/greentea-testing-applications.html).
66
1. Manually running the Mbed OS built-in tests.
77

8-
# Testing with the Greentea framework
8+
## Testing with the Greentea framework
99

1010
Read the following page to understand how tests are structured:
1111

12-
## Prerequisites
12+
### Prerequisites
1313

14-
### Minimum HAL module support
14+
#### Minimum HAL module support
1515

1616
To run the Mbed OS built-in tests, you need to have ported and verified at least these HAL modules:
1717

@@ -23,7 +23,7 @@ To run the Mbed OS built-in tests, you need to have ported and verified at least
2323
You'll also need to have ported DAPLink or compatible interface firmware to your interface chip.
2424
<span class="notes">If DAPLink is still under development, you can still [run tests manually](../porting/manual-testing.html).</span>
2525

26-
### mbedls
26+
#### mbedls
2727

2828
The platform under test needs to be supported in mbedls for automated tests to work.
2929

@@ -47,7 +47,7 @@ If an updated mbedls pip package including support for your platform hasn't been
4747
4848
Where `"33000000e062afa300000000000000000000000097969902"` is the correct target id.
4949
50-
## Compiling and running tests
50+
### Compiling and running tests
5151
5252
1. Compile the tests:
5353
- To compile all tests, run `mbed test --compile`.

docs/porting/psa/TLS-on-PSA.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Using PSA-enabled Mbed TLS
22

3-
# Building PSA-enabled Mbed TLS from Git
3+
## Building PSA-enabled Mbed TLS from Git
44

55
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):
66

77
1. Clone the repository, switch to the `development-psa` branch and initialize the submodule: `git checkout development-psa && git submodule update --init`.
88
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`.
99
1. Build normally, for example (with GNU Make) make all test or (with CMake) `mkdir build && cd build && cmake .. && make all test`.
1010

11-
# Using PSA-enabled Mbed TLS
11+
## Using PSA-enabled Mbed TLS
1212

1313
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.
1414

@@ -18,17 +18,17 @@ If your application doesn't use any of the PSA-specific APIs described below, th
1818

1919
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.
2020

21-
# PSA-based APIs in Mbed TLS
21+
## PSA-based APIs in Mbed TLS
2222

2323
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.
2424

2525
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.
2626

27-
# Using opaque ECDSA keys for TLS client authentication
27+
## Using opaque ECDSA keys for TLS client authentication
2828

2929
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.
3030

31-
## Application flow without PSA
31+
### Application flow without PSA
3232

3333
1. At application startup, make sure `mbedtls_platform_setup()` is called if relevant.
3434
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
3737
1. Use the resulting SSL configuration for TLS connections as usual.
3838
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()`.
3939

40-
## Application flow with PSA
40+
### Application flow with PSA
4141

4242
1. At application startup, make sure `mbedtls_platform_setup()` is called if relevant, and make sure `psa_crypto_init()` is called, too.
4343
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
4747
1. Use the resulting SSL configuration for TLS connections as usual.
4848
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.
4949

50-
# Using opaque ECDSA keys to generate certificate signing requests (CSRs)
50+
## Using opaque ECDSA keys to generate certificate signing requests (CSRs)
5151

5252
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.
5353

54-
## Application flow without PSA
54+
### Application flow without PSA
5555

5656
1. At application startup, make sure `mbedtls_platform_setup() is called if relevant.
5757
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
6060
1. Call any other function you need to configure and generate the CSR.
6161
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()`.
6262

63-
## Application flow with PSA
63+
### Application flow with PSA
6464

6565
1. At application startup, make sure `mbedtls_platform_setup()` is called if relevant, and make sure `psa_crypto_init()` is called, too.
6666
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
7070
1. Call any other function that you need to configure and generate the CSR.
7171
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.
7272

73-
# Using opaque pre-shared keys with TLS PSK ciphersuites
73+
## Using opaque pre-shared keys with TLS PSK ciphersuites
7474

7575
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.
7676

77-
## Application flow without PSA
77+
### Application flow without PSA
7878

7979
1. At application startup, make sure `mbedtls_platform_setup()` is called if relevant.
8080
1. Set up an `unsigned char *` to point to a memory area holding your pre-shared key.
8181
1. Call `mbedtls_ssl_conf_psk()` on the SSL configuration object.
8282
1. Use that configuration object in TLS connections.
8383

84-
## Application flow with PSA
84+
### Application flow with PSA
8585

8686
1. At application startup, make sure `mbedtls_platform_setup()` is called if relevant, and make sure `psa_crypto_init()` is called, too.
8787
1. Set up a *`psa_key_handle_t`* to point to a configured slot holding your pre-shared key.

0 commit comments

Comments
 (0)