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

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

Merged
merged 3 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .github/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ alloc
Ameba
amebad
amebaiot
announcementReason
AnnounceOTAProvider
APIs
apk
Expand Down Expand Up @@ -782,6 +783,7 @@ pre
preprocessor
Presetup
prj
providerNodeId
ProductID
ProductLabel
ProductName
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/examples-mbed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ concurrency:
jobs:
mbedos:
name: Mbed OS examples building
timeout-minutes: 70
timeout-minutes: 80

env:
BUILD_TYPE: mbedos
Expand Down Expand Up @@ -110,6 +110,15 @@ jobs:
mbed $APP_TARGET+$APP_PROFILE shell \
examples/shell/mbed/build-CY8CPROTO_062_4343W/release/chip-mbed-shell-example.elf \
/tmp/bloat_reports/

- name: Build ota-requestor-app example
timeout-minutes: 10
run: |
scripts/examples/mbed_example.sh -a=ota-requestor-app -b=$APP_TARGET -p=$APP_PROFILE
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
mbed $APP_TARGET+$APP_PROFILE shell \
examples/ota-requestor-app/mbed/build-CY8CPROTO_062_4343W/release/chip-mbed-ota-requestor-app-example.elf \
/tmp/bloat_reports/

- name: Build unit tests
timeout-minutes: 10
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,6 @@
[submodule "cyw30739_sdk/tools"]
path = third_party/cyw30739_sdk/repos/btsdk-tools
url = https://github.com/Infineon/btsdk-tools.git
[submodule "third_party/mbed-mcu-boot/repo"]
path = third_party/mbed-mcu-boot/repo
url = https://github.com/ATmobica/mcuboot.git
65 changes: 63 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 All @@ -289,6 +289,66 @@
"quit"
],
"showDevDebugOutput": false // When set to true, displays output of GDB.
},

{
"name": "Debug Mbed bootloader",
"type": "cortex-debug",
"request": "launch",
"cwd": "${workspaceRoot}/examples/platform/mbed/bootloader",
"executable": "./build-${input:mbedTarget}/${input:mbedDebugProfile}/chip-mbed-bootloader.elf",
"armToolchainPath": "${env:PW_ENVIRONMENT_ROOT}/cipd/pigweed/bin/", // Pigweed environment bootstraping required
"servertype": "openocd",
"openocdPath": "${env:OPENOCD_PATH/bin}",
"searchDir": [
"${workspaceRoot}/config/mbed/scripts",
"${env:OPENOCD_PATH}/scripts"
],
"configFiles": ["${input:mbedTarget}.tcl"],
"overrideLaunchCommands": [
"-enable-pretty-printing",
"monitor program {./build-${input:mbedTarget}/${input:mbedDebugProfile}/chip-mbed-bootloader.hex}",
"monitor reset run",
"monitor sleep 200",
"monitor psoc6 reset_halt sysresetreq"
],
"numberOfProcessors": 2,
"targetProcessor": 1, // Set to 0 for the CM0+, set to 1 for the CM4
"overrideRestartCommands": [
"monitor reset init",
"monitor reset run",
"monitor sleep 200",
"monitor psoc6 reset_halt sysresetreq"
],
"runToMain": true, // if true, program will halt at main. Not used for a restart
"showDevDebugOutput": false // When set to true, displays output of GDB.
},

{
"name": "Debug Mbed bootloader [remote]",
"type": "cortex-debug",
"request": "launch",
"cwd": "${workspaceRoot}/examples/platform/mbed/bootloader",
"executable": "./build-${input:mbedTarget}/${input:mbedDebugProfile}/chip-mbed-bootloader.elf",
"armToolchainPath": "${env:PW_ENVIRONMENT_ROOT}/cipd/pigweed/bin/", // Pigweed environment bootstraping required
"servertype": "external",
"gdbTarget": "host.docker.internal:3334", //port 3333 for the CM0+, 3334 for the CM4
"overrideLaunchCommands": [
"-enable-pretty-printing",
"monitor reset halt",
"load ./build-${input:mbedTarget}/${input:mbedDebugProfile}/chip-mbed-bootloader.hex",
"monitor reset run",
"monitor sleep 200",
"monitor psoc6 reset_halt sysresetreq"
],
"overrideRestartCommands": [
"monitor reset init",
"monitor reset run",
"monitor sleep 200",
"monitor psoc6 reset_halt sysresetreq"
],
"runToMain": true, // if true, program will halt at main. Not used for a restart
"showDevDebugOutput": false // When set to true, displays output of GDB.
}
],
"inputs": [
Expand All @@ -315,7 +375,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
71 changes: 71 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,67 @@ 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
${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(${APP_TARGET} PRIVATE
${MCUBOOT_PATH}/boot/mbed/include
)

target_sources(${APP_TARGET} PRIVATE
${CHIP_ROOT}/examples/platform/mbed/bootloader/default_bd.cpp
)

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
14 changes: 12 additions & 2 deletions examples/all-clusters-app/mbed/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ example ported to the mbed-os platform.
- **by using generic vscode task**:

```
Command Palette (F1) => Run Task... => Run Mbed Application => build => all-clusters-app => (board name) => (build profile)`
Command Palette (F1) => Run Task... => Run Mbed Application => build => all-clusters-app => (board name) => (build profile) => (build type)
```

- **by calling explicitly building script:**

```
${MATTER_ROOT}/scripts/examples/mbed_example.sh -c=build -a=all-clusters-app -b=<board name> -p=<build profile>
${MATTER_ROOT}/scripts/examples/mbed_example.sh -c=build -a=all-clusters-app -b=<board name> -p=<build profile> -T=<build type>
```

Both approaches are limited to supported evaluation boards which are listed in
Expand All @@ -127,6 +127,16 @@ Mbed OS defines three building profiles: _develop, debug_ and _release_. For
more details please visit
[ARM Mbed OS build profiles](https://os.mbed.com/docs/mbed-os/latest/program-setup/build-profiles-and-rules.html).

There are also three types of built application: _simple, boot_ and _upgrade_:

- **simple** - standalone application, mainly for developing and testing
purpose (all building profiles are supported)
- **boot** - signed application + bootloader, it supports booting process and
can be use for firmware update (only _release_ building profiles is
supported)
- **update** - signed application, application image can be used for firmware
update (only _release_ building profiles is supported)

When using the building script, it is possible expand the list of acceptable
targets; this may be useful for rapid testing of a new mbed-targets.

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 @@ -109,11 +109,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
14 changes: 12 additions & 2 deletions examples/lighting-app/mbed/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ example ported to the mbed-os platform.
- **by using generic vscode task**:

```
Command Palette (F1) => Run Task... => Run Mbed Application => build => lighting-app => (board name) => (build profile)
Command Palette (F1) => Run Task... => Run Mbed Application => build => lighting-app => (board name) => (build profile) => (build type)
```

- **by calling explicitly building script:**

```
${MATTER_ROOT}/scripts/examples/mbed_example.sh -c=build -a=lighting-app -b=<board name> -p=<build profile>
${MATTER_ROOT}/scripts/examples/mbed_example.sh -c=build -a=lighting-app -b=<board name> -p=<build profile> -T=<build type>
```

Both approaches are limited to supported evaluation boards which are listed in
Expand All @@ -140,6 +140,16 @@ Mbed OS defines three building profiles: _develop, debug_ and _release_. For
more details please visit
[ARM Mbed OS build profiles](https://os.mbed.com/docs/mbed-os/latest/program-setup/build-profiles-and-rules.html).

There are also three types of built application: _simple, boot_ and _upgrade_:

- **simple** - standalone application, mainly for developing and testing
purpose (all building profiles are supported)
- **boot** - signed application + bootloader, it supports booting process and
can be use for firmware update (only _release_ building profiles is
supported)
- **update** - signed application, application image can be used for firmware
update (only _release_ building profiles is supported)

When using the building script, it is possible expand the list of acceptable
targets; this may be useful for rapid testing of a new mbed-targets.

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 @@ -102,11 +102,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
14 changes: 12 additions & 2 deletions examples/lock-app/mbed/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ ported to the mbed-os platform.
- **by using generic vscode task**:

```
Command Palette (F1) => Run Task... => Run Mbed Application => build => lock-app => (board name) => (build profile)
Command Palette (F1) => Run Task... => Run Mbed Application => build => lock-app => (board name) => (build profile) => (build type)
```

- **by calling explicitly building script:**

```
${MATTER_ROOT}/scripts/examples/mbed_example.sh -c=build -a=lock-app -b=<board name> -p=<build profile>
${MATTER_ROOT}/scripts/examples/mbed_example.sh -c=build -a=lock-app -b=<board name> -p=<build profile> -T=<build type>
```

Both approaches are limited to supported evaluation boards which are listed in
Expand All @@ -130,6 +130,16 @@ Mbed OS defines three building profiles: _develop, debug_ and _release_. For
more details please visit
[ARM Mbed OS build profiles](https://os.mbed.com/docs/mbed-os/latest/program-setup/build-profiles-and-rules.html).

There are also three types of built application: _simple, boot_ and _upgrade_:

- **simple** - standalone application, mainly for developing and testing
purpose (all building profiles are supported)
- **boot** - signed application + bootloader, it supports booting process and
can be use for firmware update (only _release_ building profiles is
supported)
- **update** - signed application, application image can be used for firmware
update (only _release_ building profiles is supported)

When using the building script, it is possible expand the list of acceptable
targets; this may be useful for rapid testing of a new mbed-targets.

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
Loading