Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restyle [Mbed] Add OTA-requestor-app and DFU support #12667

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
60f5b38
Add OTA requestor app draft
ATmobica Nov 25, 2021
2d4834a
Remove shell support only clusters support
ATmobica Nov 26, 2021
8aa86c7
Provider communication service
ATmobica Dec 1, 2021
f6a823a
Add Mbed OTA Downloader
ATmobica Dec 3, 2021
561b995
Move Mbed OTA implementation to platform/mbed directory
ATmobica Dec 6, 2021
39f8114
Mbed OTA-requestor-app cleanup
ATmobica Dec 7, 2021
9635fc6
Add Mbed MCUboot to third_party
ATmobica Dec 9, 2021
a3b72bb
Update mbed bootloader mbed_app.json
ATmobica Dec 15, 2021
4212b97
Update mbed-os and mbed-mcu-boot components versions
ATmobica Dec 15, 2021
77a2b27
Add build applicaiton with bootloader option to mbed_example.sh script
ATmobica Dec 15, 2021
66ef4f7
Improve mbed launch tasks in launch.json
ATmobica Dec 16, 2021
7b4a6b8
Move mcuboot scratch address after seceondary slot
ATmobica Dec 16, 2021
e81d4d3
Fix ota-requestor-app/zap-generated/attribute-size.cpp from source
ATmobica Dec 16, 2021
1f619b8
Fix OTA.cpp file
ATmobica Dec 16, 2021
2238751
Update Mbed OTA requestor app - implement common OTARequestor and BDX…
ATmobica Dec 16, 2021
7430413
Implement Mbed bootloader in ota-requestor app
ATmobica Dec 17, 2021
67fc6cf
Add IPV6_MULTICAST_IMPLEMENTED flag to Mbed platform config
ATmobica Dec 21, 2021
0bb8646
Fix gitmodules
ATmobica Dec 21, 2021
ec5d93f
Update ota-requestor-app build
ATmobica Dec 21, 2021
0413d88
Implement mbed OTA image processor
ATmobica Dec 22, 2021
cf488d9
Move capsense lib including to common cmake file
ATmobica Dec 23, 2021
4268ed9
Add Mbed OTA Requestor app README file
ATmobica Dec 23, 2021
c0465bf
Improve launch.json and tasks.json - remove bootloader option
ATmobica Dec 23, 2021
ead364a
Improve launch.json - revert file extension changes
ATmobica Dec 23, 2021
e5359eb
Restyled by whitespace
restyled-commits Dec 23, 2021
49a4b37
Restyled by gn
restyled-commits Dec 23, 2021
8664723
Restyled by prettier-json
restyled-commits Dec 23, 2021
41181c0
Restyled by prettier-markdown
restyled-commits Dec 23, 2021
07fae55
Restyled by shellharden
restyled-commits Dec 23, 2021
cf73be8
Restyled by shfmt
restyled-commits Dec 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
url = https://github.com/openthread/ot-efr32.git
[submodule "third_party/mbed-os/repo"]
path = third_party/mbed-os/repo
url = https://github.com/ARMmbed/mbed-os.git
url = https://github.com/ATmobica/mbed-os.git
branch = master
[submodule "third_party/mbed-os-posix-socket/repo"]
path = third_party/mbed-os-posix-socket/repo
Expand Down Expand Up @@ -162,3 +162,6 @@
[submodule "p6/lwip"]
path = third_party/p6/p6_sdk/libs/lwip
url = https://github.com/lwip-tcpip/lwip.git
[submodule "third_party/mbed-mcu-boot/repo"]
path = third_party/mbed-mcu-boot/repo
url = https://github.com/ATmobica/mcuboot.git
5 changes: 3 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
"configFiles": ["${input:mbedTarget}.tcl"],
"overrideLaunchCommands": [
"monitor reset halt",
"monitor program {./build-${input:mbedTarget}/${input:mbedFlashProfile}/chip-mbed-unit-tests}",
"monitor program {./build-${input:mbedTarget}/${input:mbedFlashProfile}/chip-mbed-unit-tests.hex}",
"monitor reset run",
"quit"
],
Expand Down Expand Up @@ -315,7 +315,8 @@
"lighting-app",
"pigweed-app",
"all-clusters-app",
"shell"
"shell",
"ota-requestor-app"
],
"default": "lock-app"
},
Expand Down
17 changes: 13 additions & 4 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@
"-c=${input:mbedCommand}",
"-a=${input:mbedApp}",
"-b=${input:mbedTarget}",
"-p=${input:mbedProfile}"
"-p=${input:mbedProfile}",
"-T=${input:mbedAppType}"
],
"group": "build",
"problemMatcher": {
Expand Down Expand Up @@ -200,7 +201,8 @@
"lighting-app",
"pigweed-app",
"all-clusters-app",
"shell"
"shell",
"ota-requestor-app"
],
"default": "lock-app"
},
Expand All @@ -215,8 +217,15 @@
"type": "pickString",
"id": "mbedProfile",
"description": "What mbed profile do you want to use?",
"options": ["develop", "release", "debug"],
"default": "develop"
"options": ["release", "develop", "debug"],
"default": "release"
},
{
"type": "pickString",
"id": "mbedAppType",
"description": "What mbed application type do you want to use?",
"options": ["simple", "boot", "upgrade"],
"default": "simple"
},
{
"type": "promptString",
Expand Down
62 changes: 62 additions & 0 deletions config/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ if (CONFIG_CHIP_PW_RPC)
chip_gn_arg_bool ("chip_build_pw_rpc_lighting_proto" CONFIG_CHIP_PW_RPC_LIGHTING_PROTO)
chip_gn_arg_bool ("chip_build_pw_rpc_locking_proto" CONFIG_CHIP_PW_RPC_LOCKING_PROTO)
endif(CONFIG_CHIP_PW_RPC)
if (CONFIG_CHIP_OTA_REQUESTOR)
chip_gn_arg_bool ("chip_enable_ota_requestor" CONFIG_CHIP_OTA_REQUESTOR)
endif(CONFIG_CHIP_OTA_REQUESTOR)


file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/args.gn CONTENT ${CHIP_GN_ARGS})

Expand Down Expand Up @@ -325,6 +329,12 @@ list(APPEND CHIP_INCLUDES)
# CHIP defines
list(APPEND CHIP_DEFINES)

# Target specific configuration
if("capsense" IN_LIST MBED_TARGET_LABELS)
add_subdirectory(${CHIP_ROOT}/third_party/mbed-os-cypress-capsense-button/repo ${CMAKE_BINARY_DIR}/capsense_build)
target_link_libraries(${APP_TARGET} capsense)
endif()

list(APPEND CHIP_INCLUDES
${CHIP_ROOT}/config/mbed/mbedtls
)
Expand Down Expand Up @@ -442,6 +452,58 @@ endif(CONFIG_CHIP_PW_RPC_LOCKING_PROTO)

endif(CONFIG_CHIP_PW_RPC)

if (CONFIG_CHIP_OTA_REQUESTOR)
target_include_directories(${APP_TARGET} PRIVATE
${CHIP_ROOT}/zzz_generated/ota-requestor-app
${CHIP_ROOT}/src/app/clusters/ota-requestor
${CHIP_ROOT}/src/platform/mbed
${CHIP_ROOT}/src/include/platform
)

target_sources(${APP_TARGET} PRIVATE
${CHIP_ROOT}/zzz_generated/ota-requestor-app/zap-generated/callback-stub.cpp
${CHIP_ROOT}/zzz_generated/ota-requestor-app/zap-generated/CHIPClusters.cpp
${CHIP_ROOT}/zzz_generated/ota-requestor-app/zap-generated/IMClusterCommandHandler.cpp

${CHIP_ROOT}/src/app/clusters/ota-requestor/OTARequestor.cpp
${CHIP_ROOT}/src/app/clusters/ota-requestor/BDXDownloader.cpp
${CHIP_ROOT}/src/app/clusters/ota-requestor/ota-requestor-server.cpp

${CHIP_ROOT}/src/platform/mbed/OTAImageProcessorImpl.cpp
)

list(APPEND CHIP_DEFINES
CHIP_OTA_REQUESTOR=1
)
endif(CONFIG_CHIP_OTA_REQUESTOR)

if(BOOT_ENABLED)
add_subdirectory(${MCUBOOT_PATH}/boot/bootutil/ ${CMAKE_BINARY_DIR}/mbed_mcu_boot_util_build)
add_subdirectory(${MCUBOOT_PATH}/boot/mbed/ ${CMAKE_BINARY_DIR}/mbed_mcu_boot_build)

target_include_directories(bootutil PUBLIC
${CHIP_ROOT}/config/mbed/mbedtls
)

target_link_libraries(${APP_TARGET} mbed-mcuboot bootutil)

file(READ ${APP_PATH}/mbed_app.json mbedAppJson)
string(JSON PRIMARY_SLOT_ADDRESS GET "${mbedAppJson}" target_overrides ${MBED_TARGET} mcuboot.primary-slot-address)
string(JSON HEADER_SIZE GET "${mbedAppJson}" target_overrides ${MBED_TARGET} mcuboot.header-size)
string(JSON SLOT_SIZE GET "${mbedAppJson}" target_overrides ${MBED_TARGET} mcuboot.slot-size)
math(EXPR APP_START "${PRIMARY_SLOT_ADDRESS} + ${HEADER_SIZE}" OUTPUT_FORMAT HEXADECIMAL)
math(EXPR APP_SIZE "${SLOT_SIZE} - 2 * ${HEADER_SIZE}" OUTPUT_FORMAT HEXADECIMAL)
target_compile_definitions(mbed-core
INTERFACE
"-DMBED_APP_START=${APP_START}"
"-DMBED_APP_SIZE=${APP_SIZE}"
)

list(APPEND CHIP_DEFINES
BOOT_ENABLED=1
)
endif()


target_include_directories(${APP_TARGET} PRIVATE
${CHIP_INCLUDES}
Expand Down
4 changes: 4 additions & 0 deletions config/mbed/chip-gn/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ group("mbed") {
if (chip_build_pw_rpc_lib) {
deps += [ "//lib/pw_rpc" ]
}

if (chip_enable_ota_requestor) {
deps += [ "${chip_root}/examples/ota-requestor-app/ota-requestor-common" ]
}
}

group("default") {
Expand Down
3 changes: 1 addition & 2 deletions examples/all-clusters-app/mbed/mbed_app.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"MXCRYPTO_DISABLED",
"NL_ASSERT_LOG=NL_ASSERT_LOG_DEFAULT",
"NL_ASSERT_EXPECT_FLAGS=NL_ASSERT_FLAG_LOG",
"WHD_PRINT_DISABLE",
"MBED_CONF_LWIP_NETBUF_RECVINFO_ENABLED"
"WHD_PRINT_DISABLE"
]
}
},
Expand Down
5 changes: 0 additions & 5 deletions examples/lighting-app/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,6 @@ if(MBED_TARGET STREQUAL "CY8CPROTO_062_4343W")
target_link_libraries(${APP_TARGET} mbed-cy-psoc6-common-network)
endif()

if("capsense" IN_LIST MBED_TARGET_LABELS)
add_subdirectory(${CHIP_ROOT}/third_party/mbed-os-cypress-capsense-button/repo ./capsense_build)
target_link_libraries(${APP_TARGET} capsense)
endif()

mbed_set_post_build(${APP_TARGET})

option(VERBOSE_BUILD "Have a verbose build process")
Expand Down
3 changes: 1 addition & 2 deletions examples/lighting-app/mbed/mbed_app.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"MXCRYPTO_DISABLED",
"NL_ASSERT_LOG=NL_ASSERT_LOG_DEFAULT",
"NL_ASSERT_EXPECT_FLAGS=NL_ASSERT_FLAG_LOG",
"WHD_PRINT_DISABLE",
"MBED_CONF_LWIP_NETBUF_RECVINFO_ENABLED"
"WHD_PRINT_DISABLE"
],
"target.components_add": ["capsense"],
"lighting-state-led": "P9_6",
Expand Down
5 changes: 0 additions & 5 deletions examples/lock-app/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ if(MBED_TARGET STREQUAL "CY8CPROTO_062_4343W")
target_link_libraries(${APP_TARGET} mbed-cy-psoc6-common-network)
endif()

if("capsense" IN_LIST MBED_TARGET_LABELS)
add_subdirectory(${CHIP_ROOT}/third_party/mbed-os-cypress-capsense-button/repo ./capsense_build)
target_link_libraries(${APP_TARGET} capsense)
endif()

mbed_set_post_build(${APP_TARGET})

option(VERBOSE_BUILD "Have a verbose build process")
Expand Down
3 changes: 1 addition & 2 deletions examples/lock-app/mbed/mbed_app.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"MXCRYPTO_DISABLED",
"NL_ASSERT_LOG=NL_ASSERT_LOG_DEFAULT",
"NL_ASSERT_EXPECT_FLAGS=NL_ASSERT_FLAG_LOG",
"WHD_PRINT_DISABLE",
"MBED_CONF_LWIP_NETBUF_RECVINFO_ENABLED"
"WHD_PRINT_DISABLE"
],
"target.components_add": ["capsense"],
"lock-state-led": "P9_6",
Expand Down
2 changes: 2 additions & 0 deletions examples/ota-requestor-app/mbed/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build-*/
mcuboot
80 changes: 80 additions & 0 deletions examples/ota-requestor-app/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.19.0)

get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../.. REALPATH)
get_filename_component(MBED_COMMON ${CHIP_ROOT}/examples/platform/mbed REALPATH)
get_filename_component(GEN_DIR ${CHIP_ROOT}/zzz_generated/ REALPATH)
get_filename_component(NLIO_DIR ${CHIP_ROOT}/third_party/nlio/repo/include REALPATH)

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/config.in
${CMAKE_CURRENT_BINARY_DIR}/chip_build/config
@ONLY
)

set(MBED_PATH ${MBED_OS_PATH} CACHE INTERNAL "")
set(MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "")
set(MCUBOOT_PATH ${MBED_MCU_BOOT_PATH} CACHE INTERNAL "")
set(APP_PATH ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "")
set(APP_TYPE ${MBED_APP_TYPE} CACHE INTERNAL "")
set(BOOT_ENABLED FALSE)
set(APP_TARGET chip-mbed-ota-requestor-app-example)

if(APP_TYPE STREQUAL "boot" OR APP_TYPE STREQUAL "upgrade")
set(BOOT_ENABLED TRUE)
endif()

include(${MBED_PATH}/tools/cmake/app.cmake)
if(MBED_TARGET STREQUAL "CY8CPROTO_062_4343W" AND BOOT_ENABLED)
list(REMOVE_ITEM MBED_TARGET_LABELS CM0P_SLEEP)
list(REMOVE_ITEM MBED_TARGET_DEFINITIONS COMPONENT_CM0P_SLEEP=1)
endif()
include(${CHIP_ROOT}/src/app/chip_data_model.cmake)

project(${APP_TARGET})

add_subdirectory(${MBED_PATH} ./mbed_build)
add_subdirectory(${MBED_OS_POSIX_SOCKET_PATH} ./mbed_os_posix_socket_build)

add_executable(${APP_TARGET})

add_subdirectory(${CHIP_ROOT}/config/mbed ./chip_build)

mbed_configure_app_target(${APP_TARGET})

target_include_directories(${APP_TARGET} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/main/include/
${NLIO_DIR}
${GEN_DIR}/app-common
${MBED_COMMON}/util/include
)

target_sources(${APP_TARGET} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/main/main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/main/AppTask.cpp
${CMAKE_CURRENT_SOURCE_DIR}/main/OTARequestorDriverImpl.cpp
${MBED_COMMON}/util/LEDWidget.cpp
)

chip_configure_data_model(${APP_TARGET}
INCLUDE_SERVER
INCLUDE_CLIENT_CALLBACKS
ZAP_FILE ${CHIP_ROOT}/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.zap
GEN_DIR ${CHIP_ROOT}/zzz_generated/ota-requestor-app/zap-generated
)

target_link_libraries(${APP_TARGET} mbed-os-posix-socket mbed-os mbed-ble mbed-events mbed-netsocket mbed-storage mbed-storage-kv-global-api mbed-mbedtls mbed-emac chip)

if(MBED_TARGET STREQUAL "CY8CPROTO_062_4343W")
target_link_libraries(${APP_TARGET} mbed-cy-psoc6-common-network)
endif()

mbed_set_post_build(${APP_TARGET})

option(VERBOSE_BUILD "Have a verbose build process")
if(VERBOSE_BUILD)
set(CMAKE_VERBOSE_MAKEFILE ON)
endif()
Loading