Skip to content

Commit 7501ee7

Browse files
author
Jamie Smith
authored
Document and clean up wifi and LoRa modules, add ability in Python to get non-public targets (ARMmbed#247)
* Add a way to get target attributes for non public targets * Document all WiFi and LoRa modules * Fix some errors * Fix another CMake error
1 parent f19273a commit 7501ee7

File tree

18 files changed

+104
-57
lines changed

18 files changed

+104
-57
lines changed

connectivity/drivers/802.15.4_RF/CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
# The 'mbed-802.15.4-rf' target is lazily created because there might not be any subdirectories needing it at all.
5-
macro(create_802_15_4_target)
6-
if(NOT TARGET create_802_15_4_target)
5+
macro(create_mbed_802_15_4_target)
6+
if(NOT TARGET mbed-802.15.4-rf)
77
add_library(mbed-802.15.4-rf STATIC EXCLUDE_FROM_ALL)
88

99
# Nanostack drivers always require Mbed RTOS
@@ -14,29 +14,29 @@ macro(create_802_15_4_target)
1414
mbed-802.15.4-rf
1515
)
1616
endif()
17-
endmacro()
17+
endmacro(create_mbed_802_15_4_target)
1818

1919

2020
if("Freescale" IN_LIST MBED_TARGET_LABELS)
21-
create_802_15_4_target()
21+
create_mbed_802_15_4_target()
2222
add_subdirectory(TARGET_Freescale)
2323
elseif("Silicon_Labs" IN_LIST MBED_TARGET_LABELS)
24-
create_802_15_4_target()
24+
create_mbed_802_15_4_target()
2525
add_subdirectory(TARGET_Silicon_Labs)
2626
endif()
2727

2828
if("COMPONENT_MICROCHIP_AT86RF=1" IN_LIST MBED_TARGET_DEFINITIONS)
29-
create_802_15_4_target()
29+
create_mbed_802_15_4_target()
3030
add_subdirectory(COMPONENT_MICROCHIP_AT86RF)
3131
endif()
3232

3333
if("COMPONENT_NXP_MCR20A=1" IN_LIST MBED_TARGET_DEFINITIONS)
34-
create_802_15_4_target()
34+
create_mbed_802_15_4_target()
3535
add_subdirectory(COMPONENT_NXP_MCR20A)
3636
endif()
3737

3838
if("COMPONENT_STM_S2_LP=1" IN_LIST MBED_TARGET_DEFINITIONS)
39-
create_802_15_4_target()
39+
create_mbed_802_15_4_target()
4040
add_subdirectory(COMPONENT_STM_S2_LP)
4141
endif()
4242

connectivity/drivers/wifi/CMakeLists.txt

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,38 @@
11
# Copyright (c) 2020-2021 ARM Limited. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
add_library(mbed-wifi STATIC EXCLUDE_FROM_ALL)
4+
# The 'mbed-wifi' target is lazily created because there might not be any subdirectories needing it at all.
5+
macro(create_mbed_wifi_target)
6+
if(NOT TARGET mbed-wifi)
7+
add_library(mbed-wifi STATIC EXCLUDE_FROM_ALL)
58

6-
add_subdirectory(TARGET_WICED EXCLUDE_FROM_ALL)
9+
target_link_libraries(mbed-wifi
10+
PUBLIC
11+
mbed-rtos-flags
12+
mbed-netsocket-api
13+
)
14+
endif()
15+
endmacro()
716

8-
add_subdirectory(TARGET_STM EXCLUDE_FROM_ALL)
17+
18+
# The WICED subdirectory is for wifi drivers developed using Infineon WICED framework.
19+
# https://community.infineon.com/t5/Knowledge-Base-Articles/WICED-Wi-Fi-FAQ/ta-p/247356
20+
if("WICED" IN_LIST MBED_TARGET_LABELS)
21+
create_mbed_wifi_target()
22+
add_subdirectory(TARGET_WICED EXCLUDE_FROM_ALL)
23+
endif()
24+
25+
if("STM" IN_LIST MBED_TARGET_LABELS)
26+
add_subdirectory(TARGET_STM EXCLUDE_FROM_ALL)
27+
endif()
928

1029
if("WHD" IN_LIST MBED_TARGET_LABELS)
30+
create_mbed_wifi_target()
1131
add_subdirectory(COMPONENT_WHD EXCLUDE_FROM_ALL)
1232
endif()
1333

14-
add_subdirectory(esp8266-driver)
34+
if("COMPONENT_ESPRESSIF_ESP8266=1" IN_LIST MBED_TARGET_DEFINITIONS)
35+
create_mbed_wifi_target()
36+
add_subdirectory(COMPONENT_ESPRESSIF_ESP8266)
37+
endif()
1538

16-
target_link_libraries(mbed-wifi
17-
PUBLIC
18-
mbed-rtos-flags
19-
mbed-netsocket-api
20-
)

connectivity/drivers/wifi/esp8266-driver/README.md renamed to connectivity/drivers/wifi/COMPONENT_ESPRESSIF_ESP8266/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The Mbed OS driver for the ESP8266 WiFi module.
66

77
ESP8266 modules come in different shapes and formats, but the firmware version is the most important factor. To
88
make sure that the firmware in your module is compatible with Mbed OS, follow the
9-
[Update guide](https://developer.mbed.org/teams/ESP8266/wiki/Firmware-Update).
9+
[Update guide](https://web.archive.org/web/20211025195109/https://os.mbed.com/teams/ESP8266/wiki/Firmware-Update).
1010

1111
This driver supports AT firmware versions 1.3.0 to 1.7.0. We advise updating the
1212
[AT firmware](https://www.espressif.com/en/support/download/at?keys=) to at least version 1.7.0.

connectivity/drivers/wifi/TARGET_STM/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
if("EMW3080B" IN_LIST MBED_TARGET_LABELS)
5+
create_mbed_wifi_target()
56
add_subdirectory(COMPONENT_EMW3080B EXCLUDE_FROM_ALL)
67
endif()

connectivity/drivers/wifi/TARGET_WICED/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ target_sources(mbed-wiced
2222
PRIVATE
2323
wiced_interface/default_wifi_interface.cpp
2424
)
25+
26+
target_link_libraries(mbed-wifi PUBLIC mbed-wiced)

targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F412xG/TARGET_WIO_EMW3166/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ target_include_directories(mbed-wio-emw3166
1313
.
1414
)
1515

16-
target_link_libraries(mbed-wio-emw3166 INTERFACE mbed-wiced mbed-stm32f412xg)
16+
target_link_libraries(mbed-wio-emw3166 INTERFACE mbed-stm32f412xg)

targets/features.json5

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,53 @@
1414

1515
// WiFI and WiFi/BT modules -----------------------------------------------------------
1616
"COMPONENT_43012": {
17-
"description": "Infineon/Cypress AIROC Wifi/BT module",
17+
"description": "Infineon/Cypress AIROC Wifi 802.11n (2.4GHz and 5GHz) + BT 5.4 module",
1818
"friendly_name": "Infineon CYW43012"
1919
},
2020
"COMPONENT_43438": {
21-
"description": "Infineon/Cypress AIROC Wifi/BT module",
21+
"description": "Infineon/Cypress AIROC Wifi 802.11n (2.4GHz) + BT 5.3 module",
2222
"friendly_name": "Infineon CYW43438"
2323
},
2424
"COMPONENT_4343W": {
25-
"description": "",
26-
"friendly_name": ""
25+
"description": "Infineon/Cypress AIROC Wifi 802.11n (2.4GHz) + BT 5.3 module",
26+
"friendly_name": "Infineon CYW4343W"
2727
},
2828
"COMPONENT_4343W_FS": {
29-
"description": "",
30-
"friendly_name": ""
29+
"description": "Infineon/Cypress AIROC Wifi 802.11n (2.4GHz) + BT 5.3 module",
30+
"friendly_name": "Infineon CYW4343W (Arduino Portenta variant)"
3131
},
3232
"COMPONENT_CYW43XXX": {
33-
"description": "",
34-
"friendly_name": ""
33+
"description": "Generic component for Infineon/Cypress AIROC Wifi modules. Add one of the specific part number components to get configs + firmware for your device.",
34+
"friendly_name": "Infineon CYW43XXX"
35+
},
36+
"COMPONENT_WHD": {
37+
"description": "Generic component for the driver for Infineon/Cypress wifi modules. Works in combination with other components.",
38+
"friendly_name": "Infineon Wifi Host Driver"
3539
},
40+
// Annoyingly, STMicro wrote the driver for this module (since it is used on
41+
// some of their dev boards), and they licensed it under terms that the
42+
// code may only run on STM32 chips. So, this component is only available when
43+
// an STMicro processor is in use.
3644
"COMPONENT_EMW3080B": {
37-
"description": "",
38-
"friendly_name": ""
45+
"description": "Wifi 802.11b/g/n module (driver available for STM32 targets only)",
46+
"friendly_name": "MXChip EMW3080B"
47+
},
48+
"COMPONENT_ESPRESSIF_ESP8266": {
49+
"description": "Wifi 802.11b/g/n MCU running ESP8266-IDF-AT AT command firmware",
50+
"friendly_name": "Espressif ESP8366"
3951
},
4052

4153
// Bluetooth only modules -----------------------------------------------------------
4254
"COMPONENT_BlueNRG_2": {
43-
"description": "",
44-
"friendly_name": ""
55+
"description": "STMicro BlueNRG-2",
56+
"friendly_name": "STMicro BlueNRG-2"
4557
},
4658
"COMPONENT_BlueNRG_MS": {
47-
"description": "",
48-
"friendly_name": ""
59+
"description": "Bluetooth 4.2 module",
60+
"friendly_name": "STMicro BlueNRG-MS"
4961
},
5062

51-
// Cellular modules -----------------------------------------------------------------
63+
// Cellular and Cellular/GNSS modules ----------------------------------------------
5264
"COMPONENT_ALTAIR_ALT1250": {
5365
"description": "Cellular module from Altair",
5466
"friendly_name": "Altair ALT1250"
@@ -117,17 +129,32 @@
117129
},
118130
"COMPONENT_STM_S2_LP": {
119131
"description": "802.15.4 module, present on X-Nucleo-S2868A1 board",
120-
"friendly_name": "NXP/Freescale MCR20A"
132+
"friendly_name": "STMicro S2-LP"
133+
},
134+
135+
// LoRa modules ---------------------------------------------------------------------
136+
"COMPONENT_SX126x": {
137+
"description": "LoRa Connect™ 150-960MHz Transcievers",
138+
"friendly_name": "Semtech SX1272"
139+
},
140+
"COMPONENT_SX1272": {
141+
"description": "LoRa Connect™ 860-1000MHz Transciever",
142+
"friendly_name": "Semtech SX1272"
143+
},
144+
"COMPONENT_SX1276": {
145+
"description": "LoRa Connect™ 137-1020MHz Transciever",
146+
"friendly_name": "Semtech SX1276"
121147
},
122148

123149
// Other ----------------------------------------------------------------------------
124150

125151
"COMPONENT_CM0P_SECURE": {
126-
"description": "Used on Cypress PSoC6 dual core processors. When enabled, this activates the Cortex-M0 coprocessor in sleep mode.",
127-
"friendly_name": "PSoC CM0 in Sleep Mode"
152+
"description": "Used on Cypress PSoC 64 dual core processors with secure boot. When enabled, activates the Cortex-M0 coprocessor as a security coprocessor.",
153+
154+
"friendly_name": "PSoC CM0 in Security Mode"
128155
},
129156
"COMPONENT_CM0P_SLEEP": {
130-
"description": "Used on Cypress PSoC 64 dual core processors with secure boot. When enabled, activates the Cortex-M0 coprocessor as a security coprocessor.",
157+
"description": "Used on Cypress PSoC6 dual core processors. When enabled, this activates the Cortex-M0 coprocessor in sleep mode.",
131158
"friendly_name": "PSoC CM0 in Sleep Mode"
132159
},
133160

@@ -178,18 +205,11 @@
178205
"friendly_name": ""
179206
},
180207

181-
"COMPONENT_SX1276": {
182-
"description": "",
183-
"friendly_name": ""
184-
},
208+
185209
"COMPONENT_TFM_S_FW": {
186210
"description": "",
187211
"friendly_name": ""
188212
},
189-
"COMPONENT_WHD": {
190-
"description": "",
191-
"friendly_name": ""
192-
},
193213
"COMPONENT_hm01b0": {
194214
"description": "320x320 monochrome camera module",
195215
"friendly_name": "Himax HM01B0"

targets/targets.json5

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,6 +1982,7 @@
19821982
],
19831983
"device_name": "STM32F412ZGTx"
19841984
},
1985+
// Also known as MXChip EMW3166
19851986
"WIO_EMW3166": {
19861987
"inherits": [
19871988
"MCU_STM32F412xG"

tools/python/mbed_tools/targets/_internal/target_attributes.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@ class TargetNotFoundError(TargetAttributesError):
4040
"""Target definition not found in targets.json."""
4141

4242

43-
def get_target_attributes(targets_json_data: dict, target_name: str) -> dict:
43+
def get_target_attributes(targets_json_data: dict, target_name: str, allow_non_public_targets: bool = False) -> dict:
4444
"""Retrieves attribute data taken from targets.json for a single target.
4545
4646
Args:
4747
targets_json_data: target definitions from targets.json
4848
target_name: the name of the target (often a Board's board_type).
49+
allow_non_public_targets: If set to True, attributes can be gotten even for non-public targets
4950
5051
Returns:
5152
A dictionary representation of the attributes for the target.
@@ -54,7 +55,7 @@ def get_target_attributes(targets_json_data: dict, target_name: str) -> dict:
5455
ParsingTargetJSONError: error parsing targets.json
5556
TargetNotFoundError: there is no target attribute data found for that target.
5657
"""
57-
target_attributes = _extract_target_attributes(targets_json_data, target_name)
58+
target_attributes = _extract_target_attributes(targets_json_data, target_name, allow_non_public_targets)
5859
target_attributes["labels"] = get_labels_for_target(targets_json_data, target_name).union(
5960
_extract_core_labels(target_attributes.get("core", None))
6061
)
@@ -68,12 +69,13 @@ def get_target_attributes(targets_json_data: dict, target_name: str) -> dict:
6869
return target_attributes
6970

7071

71-
def _extract_target_attributes(all_targets_data: Dict[str, Any], target_name: str) -> dict:
72+
def _extract_target_attributes(all_targets_data: Dict[str, Any], target_name: str, allow_non_public_targets: bool) -> dict:
7273
"""Extracts the definition for a particular target from all the targets in targets.json.
7374
7475
Args:
7576
all_targets_data: a dictionary representation of the raw targets.json data.
7677
target_name: the name of the target.
78+
allow_non_public_targets: If set to True, attributes can be gotten even for non-public targets
7779
7880
Returns:
7981
A dictionary representation the target definition.
@@ -85,8 +87,8 @@ def _extract_target_attributes(all_targets_data: Dict[str, Any], target_name: st
8587
raise TargetNotFoundError(f"Target attributes for {target_name} not found.")
8688

8789
# All target definitions are assumed to be public unless specifically set as public=false
88-
if not all_targets_data[target_name].get("public", True):
89-
raise TargetNotFoundError(f"Target attributes for {target_name} not found.")
90+
if not all_targets_data[target_name].get("public", True) and not allow_non_public_targets:
91+
raise TargetNotFoundError(f"Cannot get attributes for {target_name} because it is marked non-public in targets JSON. This likely means you set MBED_TARGET to the name of the MCU rather than the name of the board.")
9092

9193
target_attributes = get_overriding_attributes_for_target(all_targets_data, target_name)
9294
accumulated_attributes = get_accumulating_attributes_for_target(all_targets_data, target_name)

tools/python/python_tests/mbed_tools/targets/_internal/test_target_attributes.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_no_target_found(self):
2121
"Target_2": "some more attributes",
2222
}
2323
with self.assertRaises(TargetNotFoundError):
24-
_extract_target_attributes(all_targets_data, "Unlisted_Target")
24+
_extract_target_attributes(all_targets_data, "Unlisted_Target", False)
2525

2626
def test_target_found(self):
2727
target_attributes = {"attribute1": "something"}
@@ -31,23 +31,26 @@ def test_target_found(self):
3131
"Target_2": "some more attributes",
3232
}
3333
# When not explicitly included public is assumed to be True
34-
self.assertEqual(_extract_target_attributes(all_targets_data, "Target_1"), target_attributes)
34+
self.assertEqual(_extract_target_attributes(all_targets_data, "Target_1", False), target_attributes)
3535

3636
def test_target_public(self):
3737
all_targets_data = {
3838
"Target_1": {"attribute1": "something", "public": True},
3939
"Target_2": "some more attributes",
4040
}
4141
# The public attribute affects visibility but is removed from result
42-
self.assertEqual(_extract_target_attributes(all_targets_data, "Target_1"), {"attribute1": "something"})
42+
self.assertEqual(_extract_target_attributes(all_targets_data, "Target_1", False), {"attribute1": "something"})
4343

4444
def test_target_private(self):
4545
all_targets_data = {
4646
"Target_1": {"attribute1": "something", "public": False},
4747
"Target_2": "some more attributes",
4848
}
4949
with self.assertRaises(TargetNotFoundError):
50-
_extract_target_attributes(all_targets_data, "Target_1"),
50+
_extract_target_attributes(all_targets_data, "Target_1", False)
51+
52+
# Should be able to get it if we pass the allow non public flag
53+
self.assertEqual(_extract_target_attributes(all_targets_data, "Target_1", True), {"attribute1": "something"})
5154

5255

5356
class TestGetTargetAttributes(TestCase):
@@ -60,9 +63,9 @@ def test_gets_attributes_for_target(self, extract_core_labels, get_labels_for_ta
6063
build_attributes = {"attribute": "value"}
6164
extract_target_attributes.return_value = build_attributes
6265

63-
result = get_target_attributes(targets_json_data, target_name)
66+
result = get_target_attributes(targets_json_data, target_name, False)
6467

65-
extract_target_attributes.assert_called_once_with(targets_json_data, target_name)
68+
extract_target_attributes.assert_called_once_with(targets_json_data, target_name, False)
6669
get_labels_for_target.assert_called_once_with(targets_json_data, target_name)
6770
extract_core_labels.assert_called_once_with(build_attributes.get("core", None))
6871
self.assertEqual(result, extract_target_attributes.return_value)

0 commit comments

Comments
 (0)