Skip to content

Commit d45f6dc

Browse files
Enable CHIP to use latest Mbed
1 parent 998c66f commit d45f6dc

File tree

18 files changed

+72
-54
lines changed

18 files changed

+72
-54
lines changed

.vscode/launch.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
"type": "cortex-debug",
9191
"request": "launch",
9292
"cwd": "${workspaceRoot}/examples/${input:mbedApp}/mbed",
93-
"executable": "./build-CY8CPROTO_062_4343W/${input:mbedDebugProfile}/chip-mbed-${input:mbedApp}-example",
93+
"executable": "./build-CY8CPROTO_062_4343W/${input:mbedDebugProfile}/chip-mbed-${input:mbedApp}-example.elf",
9494
"servertype": "openocd",
9595
"searchDir": [
9696
"${workspaceRoot}/config/mbed/scripts",
@@ -121,7 +121,7 @@
121121
"type": "cortex-debug",
122122
"request": "launch",
123123
"cwd": "${workspaceRoot}/examples/${input:mbedApp}/mbed",
124-
"executable": "./build-CY8CPROTO_062_4343W/${input:mbedDebugProfile}/chip-mbed-${input:mbedApp}-example",
124+
"executable": "./build-CY8CPROTO_062_4343W/${input:mbedDebugProfile}/chip-mbed-${input:mbedApp}-example.elf",
125125
"servertype": "external",
126126
"gdbTarget": "host.docker.internal:3334", //port 3333 for the CM0+, 3334 for the CM4
127127
"overrideLaunchCommands": [
@@ -147,7 +147,7 @@
147147
"type": "cortex-debug",
148148
"request": "launch",
149149
"cwd": "${workspaceRoot}/examples/${input:mbedApp}/mbed",
150-
"executable": "./build-CY8CPROTO_062_4343W/${input:mbedFlashProfile}/chip-mbed-${input:mbedApp}-example",
150+
"executable": "./build-CY8CPROTO_062_4343W/${input:mbedFlashProfile}/chip-mbed-${input:mbedApp}-example.elf",
151151
"servertype": "openocd",
152152
"searchDir": [
153153
"${workspaceRoot}/config/mbed/scripts",
@@ -170,7 +170,7 @@
170170
"type": "cortex-debug",
171171
"request": "launch",
172172
"cwd": "${workspaceRoot}/examples/${input:mbedApp}/mbed",
173-
"executable": "./build-CY8CPROTO_062_4343W/${input:mbedFlashProfile}/chip-mbed-${input:mbedApp}-example.hex",
173+
"executable": "./build-CY8CPROTO_062_4343W/${input:mbedFlashProfile}/chip-mbed-${input:mbedApp}-example.elf",
174174
"servertype": "external",
175175
"gdbTarget": "host.docker.internal:3334", //port 3333 for the CM0+, 3334 for the CM4
176176
"overrideLaunchCommands": [
@@ -332,7 +332,12 @@
332332
"type": "pickString",
333333
"id": "mbedApp",
334334
"description": "What mbed application do you want to use?",
335-
"options": ["shell", "lock-app", "lighting-app", "all-clusters-app"],
335+
"options": [
336+
"shell",
337+
"lock-app",
338+
"lighting-app",
339+
"all-clusters-app"
340+
],
336341
"default": "shell"
337342
}
338343
]

config/mbed/CMakeLists.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,35 @@ mbed_get_lang_compile_flags(CHIP_CFLAGS_C mbed-core C)
120120
list(APPEND CHIP_CFLAGS_C ${CMAKE_C_FLAGS_INIT})
121121
mbed_get_lang_compile_flags(CHIP_CFLAGS_CC mbed-core CXX)
122122
list(APPEND CHIP_CFLAGS_CC ${CMAKE_CXX_FLAGS_INIT})
123+
mbed_get_target_common_compile_flags(CHIP_MBEDCMSISCM_CFLAGS mbed-cmsis-cortex-m)
124+
list(APPEND CHIP_CFLAGS ${CHIP_MBEDCMSISCM_CFLAGS})
125+
126+
127+
if("WHD" IN_LIST MBED_TARGET_LABELS)
128+
mbed_get_target_common_compile_flags(CHIP_MBEDPSOC6_CFLAGS mbed-psoc6)
129+
list(APPEND CHIP_CFLAGS ${CHIP_MBEDPSOC6_CFLAGS})
130+
mbed_get_target_common_compile_flags(CHIP_MBEDCAT1_CFLAGS mbed-cat1a)
131+
list(APPEND CHIP_CFLAGS ${CHIP_MBEDCAT1_CFLAGS})
132+
mbed_get_target_common_compile_flags(CHIP_MBEDCMSISCY8_CFLAGS mbed-cy8cproto-062-4343w)
133+
list(APPEND CHIP_CFLAGS ${CHIP_MBEDCMSISCY8_CFLAGS})
134+
mbed_get_target_common_compile_flags(CHIP_MBEDCMSISCY8MODUS_CFLAGS mbed-cy8cproto-062-4343w-bsp-design-modus)
135+
list(APPEND CHIP_CFLAGS ${CHIP_MBEDCMSISCY8MODUS_CFLAGS})
136+
mbed_get_target_common_compile_flags(CHIP_MBEDCMSISCY8NET_CFLAGS mbed-cy-psoc6-common-network )
137+
list(APPEND CHIP_CFLAGS ${CHIP_MBEDCMSISCY8NET_CFLAGS})
138+
endif()
139+
140+
if("BlueNRG_MS" IN_LIST MBED_TARGET_LABELS)
141+
mbed_get_target_common_compile_flags(CHIP_MBEDSTM_CFLAGS mbed-stm )
142+
list(APPEND CHIP_CFLAGS ${CHIP_MBEDSTM_CFLAGS})
143+
mbed_get_target_common_compile_flags(CHIP_MBEDCMSISCM_CFLAGS mbed-stm32l4)
144+
list(APPEND CHIP_CFLAGS ${CHIP_MBEDCMSISCM_CFLAGS})
145+
mbed_get_target_common_compile_flags(CHIP_MBEDCSTMCUBE_CFLAGS mbed-stm32l4cube-fw)
146+
list(APPEND CHIP_CFLAGS ${CHIP_MBEDCSTMCUBE_CFLAGS})
147+
mbed_get_target_common_compile_flags(CHIP_MBEDSTML4_CFLAGS mbed-stm32l475xg)
148+
list(APPEND CHIP_CFLAGS ${CHIP_MBEDSTML4_CFLAGS})
149+
mbed_get_target_common_compile_flags(CHIP_MBEDSTML4IOT_CFLAGS mbed-disco-l475vg-iot01a)
150+
list(APPEND CHIP_CFLAGS ${CHIP_MBEDSTML4IOT_CFLAGS})
151+
endif()
123152

124153
# Add support for Mbed BLE
125154
mbed_get_target_common_compile_flags(CHIP_MBEDBLE_CFLAGS mbed-ble)

examples/all-clusters-app/mbed/CMakeLists.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ add_subdirectory(${CHIP_ROOT}/config/mbed ./chip_build)
9999

100100
mbed_configure_app_target(${APP_TARGET})
101101

102-
mbed_set_mbed_target_linker_script(${APP_TARGET})
103-
104102
project(${APP_TARGET})
105103

106104
if("wifi_ism43362" IN_LIST MBED_TARGET_LABELS)
@@ -111,17 +109,15 @@ endif()
111109

112110
if("BlueNRG_MS" IN_LIST MBED_TARGET_LABELS)
113111
target_link_libraries(${APP_TARGET}
114-
mbed-ble-blue_nrg
112+
mbed-ble
115113
)
116114
endif()
117115

118116
if("WHD" IN_LIST MBED_TARGET_LABELS)
119-
target_link_libraries(${APP_TARGET}
120-
mbed-cy_psoc6_common_network mbed-emac mbed-cy_psoc6_whd
121-
)
117+
target_link_libraries(${APP_TARGET} mbed-cy-psoc6-common-network)
122118
endif()
123119

124-
target_link_libraries(${APP_TARGET} mbed-os mbed-ble mbed-events mbed-netsocket mbed-storage mbed-storage-kv-global-api mbed-mbedtls mbed-mbedtls-cryptocell310 chip)
120+
target_link_libraries(${APP_TARGET} mbed-os mbed-ble mbed-events mbed-netsocket mbed-storage mbed-storage-kv-global-api mbed-mbedtls mbed-emac chip)
125121

126122
mbed_set_post_build(${APP_TARGET})
127123

examples/lighting-app/mbed/CMakeLists.txt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ configure_file(
1414
@ONLY
1515
)
1616

17-
set(MBED_PATH $ENV{MBED_OS_PATH} CACHE INTERNAL "")
17+
#set(MBED_PATH $ENV{MBED_OS_PATH} CACHE INTERNAL "")
18+
set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/mbed-os CACHE INTERNAL "")
1819
set(MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "")
1920
set(APP_TARGET chip-mbed-lighting-app-example)
2021

@@ -72,8 +73,7 @@ add_subdirectory(${CHIP_ROOT}/config/mbed ./chip_build)
7273

7374
mbed_configure_app_target(${APP_TARGET})
7475

75-
mbed_set_mbed_target_linker_script(${APP_TARGET})
76-
76+
7777
project(${APP_TARGET})
7878

7979
if("wifi_ism43362" IN_LIST MBED_TARGET_LABELS)
@@ -84,17 +84,15 @@ endif()
8484

8585
if("BlueNRG_MS" IN_LIST MBED_TARGET_LABELS)
8686
target_link_libraries(${APP_TARGET}
87-
mbed-ble-blue_nrg
87+
mbed-ble
8888
)
8989
endif()
9090

9191
if("WHD" IN_LIST MBED_TARGET_LABELS)
92-
target_link_libraries(${APP_TARGET}
93-
mbed-cy_psoc6_common_network mbed-emac mbed-cy_psoc6_whd
94-
)
92+
target_link_libraries(${APP_TARGET} mbed-cy-psoc6-common-network)
9593
endif()
9694

97-
target_link_libraries(${APP_TARGET} mbed-os mbed-ble mbed-events mbed-netsocket mbed-storage mbed-storage-kv-global-api mbed-mbedtls mbed-mbedtls-cryptocell310 chip)
95+
target_link_libraries(${APP_TARGET} mbed-os mbed-ble mbed-events mbed-netsocket mbed-storage mbed-storage-kv-global-api mbed-mbedtls mbed-emac chip)
9896

9997
mbed_set_post_build(${APP_TARGET})
10098

examples/lighting-app/mbed/mbed_app.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"CORDIO"
3131
],
3232
"led-active-state": 1,
33-
"lighting-button": "USER_BUTTON",
33+
"lighting-button": "BUTTON1",
3434
"function-button": "NC"
3535
},
3636
"CY8CPROTO_062_4343W": {
@@ -43,8 +43,7 @@
4343
"led-active-state": 0,
4444
"system-state-led": "LED1",
4545
"lighting-state-led": "P9_6",
46-
"lighting-button": "USER_BUTTON",
47-
"function-button": "P9_7"
46+
"lighting-button": "USER_BUTTON"
4847
}
4948
},
5049
"config": {

examples/lock-app/mbed/CMakeLists.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ add_subdirectory(${CHIP_ROOT}/config/mbed ./chip_build)
7171

7272
mbed_configure_app_target(${APP_TARGET})
7373

74-
mbed_set_mbed_target_linker_script(${APP_TARGET})
75-
7674
project(${APP_TARGET})
7775

7876
if("wifi_ism43362" IN_LIST MBED_TARGET_LABELS)
@@ -83,17 +81,15 @@ endif()
8381

8482
if("BlueNRG_MS" IN_LIST MBED_TARGET_LABELS)
8583
target_link_libraries(${APP_TARGET}
86-
mbed-ble-blue_nrg
84+
mbed-ble
8785
)
8886
endif()
8987

9088
if("WHD" IN_LIST MBED_TARGET_LABELS)
91-
target_link_libraries(${APP_TARGET}
92-
mbed-cy_psoc6_common_network mbed-emac mbed-cy_psoc6_whd
93-
)
89+
target_link_libraries(${APP_TARGET} mbed-cy-psoc6-common-network)
9490
endif()
9591

96-
target_link_libraries(${APP_TARGET} mbed-os mbed-ble mbed-events mbed-netsocket mbed-storage mbed-storage-kv-global-api mbed-mbedtls mbed-mbedtls-cryptocell310 chip)
92+
target_link_libraries(${APP_TARGET} mbed-os mbed-ble mbed-events mbed-netsocket mbed-storage mbed-storage-kv-global-api mbed-mbedtls mbed-emac chip)
9793

9894
mbed_set_post_build(${APP_TARGET})
9995

examples/lock-app/mbed/mbed_app.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"CORDIO"
3131
],
3232
"led-active-state": 1,
33-
"lock-button": "USER_BUTTON",
33+
"lock-button": "BUTTON1",
3434
"function-button": "NC"
3535
},
3636
"CY8CPROTO_062_4343W": {
@@ -44,8 +44,7 @@
4444
"led-active-state": 1,
4545
"system-state-led": "LED1",
4646
"lock-state-led": "P9_6",
47-
"lock-button": "USER_BUTTON",
48-
"function-button": "P9_7"
47+
"lock-button": "USER_BUTTON"
4948
}
5049
},
5150
"config": {

examples/shell/mbed/CMakeLists.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ add_subdirectory(${CHIP_ROOT}/config/mbed ./chip_build)
4343

4444
mbed_configure_app_target(${APP_TARGET})
4545

46-
mbed_set_mbed_target_linker_script(${APP_TARGET})
47-
4846
project(${APP_TARGET})
4947

5048
if("wifi_ism43362" IN_LIST MBED_TARGET_LABELS)
@@ -55,17 +53,15 @@ endif()
5553

5654
if("BlueNRG_MS" IN_LIST MBED_TARGET_LABELS)
5755
target_link_libraries(${APP_TARGET}
58-
mbed-ble-blue_nrg
56+
mbed-ble
5957
)
6058
endif()
6159

6260
if("WHD" IN_LIST MBED_TARGET_LABELS)
63-
target_link_libraries(${APP_TARGET}
64-
mbed-cy_psoc6_common_network mbed-emac mbed-cy_psoc6_whd
65-
)
61+
target_link_libraries(${APP_TARGET} mbed-cy-psoc6-common-network)
6662
endif()
6763

68-
target_link_libraries(${APP_TARGET} mbed-os mbed-ble mbed-events mbed-netsocket mbed-storage mbed-storage-kv-global-api mbed-mbedtls mbed-mbedtls-cryptocell310 chip)
64+
target_link_libraries(${APP_TARGET} mbed-os mbed-ble mbed-events mbed-netsocket mbed-storage mbed-storage-kv-global-api mbed-mbedtls mbed-emac chip)
6965

7066
mbed_set_post_build(${APP_TARGET})
7167

examples/shell/mbed/cmd_mbed_utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#include <rtos/EventFlags.h>
4646

4747
#include "netdb.h"
48-
#include <common.h>
48+
#include <net_common.h>
4949
#include <net_socket.h>
5050

5151
using namespace chip;

scripts/examples/mbed_example.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,5 @@ if [[ "$COMMAND" == *"flash"* ]]; then
134134
MBED_FLASH_SCRIPTS_PATH=$CHIP_ROOT/config/mbed/scripts
135135

136136
# Flash application
137-
openocd -f $MBED_FLASH_SCRIPTS_PATH/$TARGET_BOARD.tcl -c "program $BUILD_DIRECTORY/chip-mbed-$APP-example verify reset exit"
137+
openocd -f $MBED_FLASH_SCRIPTS_PATH/$TARGET_BOARD.tcl -c "program $BUILD_DIRECTORY/chip-mbed-$APP-example.elf verify reset exit"
138138
fi

src/inet/BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ if (chip_device_platform == "mbed") {
7979
"${chip_root}/src/platform/mbed/posix/src/socket.cpp",
8080
"${chip_root}/src/platform/mbed/posix/src/select.cpp",
8181
"${chip_root}/src/platform/mbed/posix/src/netdb.cpp",
82-
"${chip_root}/src/platform/mbed/net/src/common.cpp",
82+
"${chip_root}/src/platform/mbed/net/src/net_common.cpp",
8383
"${chip_root}/src/platform/mbed/net/src/net_if.cpp",
8484
"${chip_root}/src/platform/mbed/net/src/net_socket.cpp",
8585
"${chip_root}/src/platform/mbed/net/src/net_dns.cpp",

src/platform/mbed/net/include/BSDSocket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define MBED_NET_BSD_SOCKET_H
2020

2121
#include "OpenFileHandleAsFileDescriptor.h"
22-
#include "common.h"
22+
#include "net_common.h"
2323
#include <mstd_atomic>
2424
#include <netsocket/TCPSocket.h>
2525
#include <netsocket/UDPSocket.h>

src/platform/mbed/net/src/common.cpp renamed to src/platform/mbed/net/src/net_common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "common.h"
1+
#include "net_common.h"
22
#include <stdlib.h>
33
#include <string.h>
44

src/platform/mbed/net/src/net_dns.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "net_dns.h"
2-
#include <common.h>
2+
#include <net_common.h>
33
#include <netsocket/NetworkInterface.h>
44

55
int mbed_getaddrinfo(const char * nodename, const char * servname, const struct addrinfo * hints, struct addrinfo ** res)

src/platform/mbed/net/src/net_if.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include "net_if.h"
2-
#include "common.h"
32
#include <NetworkInterface.h>
43
#include <arpa/inet.h>
54
#include <ifaddrs.h>
5+
#include <net_common.h>
66
#include <sys/ioctl.h>
77

88
static int mbed_get_if_flags(unsigned int * flags);

src/platform/mbed/net/src/net_socket.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <net_socket.h>
66
#include <rtos/EventFlags.h>
77

8-
#include "common.h"
8+
#include "net_common.h"
99

1010
#include "mbed-trace/mbed_trace.h"
1111

@@ -15,7 +15,6 @@ using namespace rtos;
1515
#define TRACE_GROUP "NETS"
1616

1717
#define NO_FREE_SOCKET_SLOT (-1)
18-
1918
static BSDSocket sockets[MBED_NET_SOCKET_MAX_NUMBER];
2019

2120
static BSDSocket * getBSDSocket(int fd)

src/test_driver/mbed/CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ add_subdirectory(${CHIP_ROOT}/config/mbed ./chip_build)
3737

3838
mbed_configure_app_target(${APP_TARGET})
3939

40-
mbed_set_mbed_target_linker_script(${APP_TARGET})
40+
4141

4242
project(${APP_TARGET})
4343

@@ -53,12 +53,13 @@ if("BlueNRG_MS" IN_LIST MBED_TARGET_LABELS)
5353
)
5454
endif()
5555

56+
5657
if("WHD" IN_LIST MBED_TARGET_LABELS)
57-
target_link_libraries(${APP_TARGET}
58-
mbed-cy_psoc6_common_network mbed-emac mbed-cy_psoc6_whd
59-
)
58+
target_link_libraries(${APP_TARGET} mbed-cy-psoc6-common-network)
6059
endif()
6160

61+
target_link_libraries(${APP_TARGET} mbed-os mbed-ble mbed-events mbed-netsocket mbed-storage mbed-storage-kv-global-api mbed-mbedtls mbed-emac chip)
62+
6263
# As noted in the nrfconnect impl:
6364
# TODO: this list is hard to maintain manually (and currently incomplete).
6465
# An automated way that includes figuring out dependencies would be much better
@@ -101,7 +102,7 @@ target_link_libraries(${APP_TARGET}
101102
MinimalMdnsRecords
102103
)
103104

104-
target_link_libraries(${APP_TARGET} mbed-os mbed-ble mbed-events mbed-netsocket mbed-storage mbed-storage-kv-global-api mbed-mbedtls mbed-mbedtls-cryptocell310 chip)
105+
target_link_libraries(${APP_TARGET} mbed-os mbed-ble mbed-events mbed-netsocket mbed-storage mbed-storage-kv-global-api mbed-mbedtls mbed-mbedtls chip)
105106

106107
mbed_set_post_build(${APP_TARGET})
107108

0 commit comments

Comments
 (0)