Skip to content

Commit

Permalink
Add Mbed OTA requestor app
Browse files Browse the repository at this point in the history
Add Mbed MCUboot to third_party
Add Mbed bootloader application
Add build applicaiton with bootloader option to mbed_example.sh script
Improve mbed launch tasks in launch.json
Move capsense lib including to common cmake file
Update mbed-os-posix-socket module
  • Loading branch information
ATmobica committed Jan 21, 2022
1 parent 6e1a741 commit 6b9d181
Show file tree
Hide file tree
Showing 34 changed files with 2,233 additions and 34 deletions.
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
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
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 @@ -101,11 +101,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

0 comments on commit 6b9d181

Please sign in to comment.