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/mbed_targets.md
+146Lines changed: 146 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -212,3 +212,149 @@ The `release_versions` property is a list of major versions of mbed OS that the
212
212
#### `supported_form_factors`
213
213
214
214
The `supported_form_factors` property is an optional list of form factors that a development board supports. You can use this property in C, C++ and assembly language by passing a macro prefixed with `TARGET_FF_` to the compiler. The accepted values for `supported_form_factors` are `ARDUINO`, which indicates compatibility with Arduino headers, and `MORPHO`, which indicates compatibility with ST Morpho headers.
215
+
216
+
### Style guide
217
+
218
+
A linting script for `targets.json` is available as `tools/targets/lint.py` in mbed OS. This script is a utility for avoiding common errors when defining targets and detecting style inconsistencies between targets. This linting script displays style errors based on a few rules outlined below.
219
+
220
+
#### Rules enforced
221
+
222
+
There are two sets of rules: rules that affect how you must structure target inheritance and rules that govern what each role within the inheritance hierarchy can do.
223
+
224
+
##### Inheritance rules
225
+
226
+
A target's inheritance must look like one of these:
227
+
228
+
```
229
+
MCU -> Board
230
+
MCU -> Module -> Board
231
+
Family -> MCU -> Board
232
+
Family -> MCU -> Module -> Board
233
+
Family -> Subfamily -> MCU -> Board
234
+
Family -> Subfamily -> MCU -> Module -> Board
235
+
```
236
+
237
+
The linting script guesses where the Boards and Modules stop and the MCUs, Families and Subfamilies begin. An MCU, Family or Subfamily must have at least one Board or Module above it in any hierarchy.
238
+
239
+
##### Role rules
240
+
241
+
For each of these target roles, some restrictions are in place:
242
+
- Families, MCUs and Subfamilies may contain the following keys:
243
+
-`core`.
244
+
-`extra_labels`.
245
+
-`features`.
246
+
-`bootloader_supported`.
247
+
-`device_name`.
248
+
-`post_binary_hook`.
249
+
-`default_tool chain`.
250
+
-`config`.
251
+
-`target_overrides`.
252
+
- MCUs are required to have, and Families and Subfamilies may have:
253
+
-`release_versions`.
254
+
-`supported_toolchains`.
255
+
-`default_lib`.
256
+
-`public`.
257
+
-`device_has`.
258
+
- Modules and Boards may have the following keys:
259
+
-`supported_form_factors`.
260
+
-`is_disk_virtual`.
261
+
-`detect_code`.
262
+
-`extra_labels`.
263
+
-`public`.
264
+
-`config`.
265
+
-`forced_reset_timeout`.
266
+
-`target_overrides`
267
+
-`macros` are not used. That is intentional: they do not provide any benefit over `config` and `target_overrides` but can be very difficult to use. In practice it is very difficult to override the value of a macro with a value. `config` and `target_overries`, on the other hand, are designed for this use case.
268
+
-`extra_labels` may not contain any target names
269
+
-`device_has` may only contain values from the following list:
270
+
-`ANALOGIN`.
271
+
-`ANALOGOUT`.
272
+
-`CAN`.
273
+
-`ETHERNET`.
274
+
-`EMAC`.
275
+
-`FLASH`.
276
+
-`I2C`.
277
+
-`I2CSLAVE`.
278
+
-`I2C_ASYNCH`.
279
+
-`INTERRUPTIN`.
280
+
-`LOWPOWERTIMER`.
281
+
-`PORTIN`.
282
+
-`PORTINOUT`.
283
+
-`PORTOUT`.
284
+
-`PWMOUT`.
285
+
-`RTC`.
286
+
-`TRNG`.
287
+
-`SERIAL`.
288
+
-`SERIAL_ASYNCH`.
289
+
-`SERIAL_FC`.
290
+
-`SLEEP`.
291
+
-`SPI`.
292
+
-`SPI_ASYNCH`.
293
+
-`SPISLAVE`.
294
+
- If `release_versions` contains 5, then `supported_toolchains` must contain all of `GCC_ARM`, `ARM` and `IAR`
295
+
- MCUs, Families and SubFamilies must set `public` to `false`
296
+
297
+
#### Sample output
298
+
299
+
The linting script takes three subcommands: `targets`, `all-targets` and `orphans`.
300
+
301
+
##### `targets` and `all-targets` commands
302
+
303
+
The `targets` and `all-targets` commands both show errors within public inheritance hierarchies. For example:
0 commit comments