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

Add support for DISCO_L475VG_IOT01A #6

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 1 addition & 3 deletions MCUboot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ This demo application extends the [Mock](../Mock) example by including a bootloa

To use the Python client, the host computer must have Bluetooth capabilities, either through an inbuilt chipset or via an external USB adapter.

This application requires the [NRF52840_DK](https://os.mbed.com/platforms/Nordic-nRF52840-DK/) platform to run.

You will also need the [GNU ARM Embedded](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm) toolchain and `python3` in your path to build the example.

> **Important**: For macOS users, your terminal emulator would have to be granted access to Bluetooth through `System Preferences > Security & Privacy > Pirvacy > Bluetooth`. Click on the padlock to make changes and check the box next to your terminal app. If the app is missing from the menu, click on the `+` icon to add your terminal app to the list.
Expand All @@ -20,7 +18,7 @@ If you chose to auto-update the `application/mbed_app.json` file, then the [jq](

To build the example, please run the following command from the repository root. To view more information on the steps involved in the build, please refer to the comments in [mcuboot.sh](../scripts/mcuboot.sh).
```shell
./scripts/fota.sh -e=mcuboot
./scripts/fota.sh -b=DISCO_L475VG_IOT01A -e=mcuboot --flash
```
> **Note**: You can build the example without a connected target board. The script indicates the location of the factory firmware and the update binary. The factory firmware would have to be flashed manually when the target board is indeed connected later. The update binary would be used in the demonstration stage.

Expand Down
55 changes: 55 additions & 0 deletions MCUboot/target/application/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

# Application

cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR)

set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/mbed-os CACHE INTERNAL "")
set(EXP_BLE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/mbed-os-experimental-ble-services CACHE INTERNAL "")
set(MCUBOOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/mcuboot CACHE INTERNAL "")
set(MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "")
set(APP_TARGET application)

include(${MBED_PATH}/tools/cmake/app.cmake)

project(${APP_TARGET})

add_subdirectory(${MBED_PATH})
add_subdirectory(${EXP_BLE_PATH}/services/FOTA)
add_subdirectory(${MCUBOOT_PATH}/boot/bootutil/)
add_subdirectory(${MCUBOOT_PATH}/boot/mbed/) # Mbed-MCUboot Port

include_directories(mbed-os-experimental-ble-services)

add_executable(${APP_TARGET})

project(${APP_TARGET})

target_sources(${APP_TARGET}
PRIVATE
source/main.cpp
source/BlockDeviceFOTAEventHandler.h
source/BlockDeviceFOTAEventHandler.cpp
source/PeriodicBlockDeviceEraser.cpp
source/PeriodicBlockDeviceEraser.h
)

target_link_libraries(${APP_TARGET}
PUBLIC
mbed-os
mbed-ble
bootutil
mbed-events
mbed-mcuboot
mbed-storage
mbed-mbedtls
ble-service-fota
)

mbed_set_post_build(${APP_TARGET})

option(VERBOSE_BUILD "Have a verbose build process")
if(VERBOSE_BUILD)
set(CMAKE_VERBOSE_MAKEFILE ON)
endif()
2 changes: 1 addition & 1 deletion MCUboot/target/application/mbed-os.lib
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://github.com/noonfom/mbed-os/#27160dbe0460ed5c898effbaf8881c39117ba505
https://github.com/ARMmbed/mbed-os.git
14 changes: 9 additions & 5 deletions MCUboot/target/application/mbed_app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
"config": {
"version-number": {
"value": "\"0.1.0\""
},
"mbed_app_start": {
"help": "Use a custom application start address",
"macro_name": "MBED_APP_START",
"required": true
}
},
"target_overrides": {
"*": {
"target.c_lib": "small",
"platform.stdio-convert-newlines": true,
"platform.stdio-baud-rate": 115200,
"mbed-trace.enable": true,
Expand All @@ -14,26 +20,24 @@
"ble-api-implementation.max-characteristic-authorisation-count": 100
},
"DISCO_L475VG_IOT01A": {
"mbed_app_start": "0x8021000",
"target.features_add": ["BLE"],
"cordio.desired-att-mtu": 200,
"cordio.rx-acl-buffer-size": 204,
"target.mbed_app_start": "0x8021000",
"target.mbed_app_size": "0xBE000",
"mcuboot.primary-slot-address": "0x8020000",
"mcuboot.slot-size": "0xC0000",
"mcuboot.scratch-address": "0x80E0000",
"mcuboot.scratch-size": "0x20000",
"mcuboot.max-img-sectors": "0x180",
"mcuboot.read-granularity": 1,
"qspif.QSPI_MIN_PROG_SIZE": 1
"mcuboot.max-img-sectors": "0x180"
},
"NRF52840_DK": {
"mbed_app_start": "0x21000",
"target.features_add": ["BLE"],
"cordio.desired-att-mtu": 200,
"cordio.rx-acl-buffer-size": 204,
"cordio-ll.max-acl-size": 204,
"cordio-nordic-ll.wsf-pool-buffer-size": 8192,
"target.mbed_app_start": "0x21000",
"target.mbed_app_size": "0xBE000",
"mcuboot.primary-slot-address": "0x20000",
"mcuboot.slot-size": "0xC0000",
Expand Down
2 changes: 1 addition & 1 deletion MCUboot/target/application/mcuboot.lib
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://github.com/mcu-tools/mcuboot/
https://github.com/lambda-shuttle/mcuboot.git
2 changes: 1 addition & 1 deletion MCUboot/target/application/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "platform/mbed_power_mgmt.h"
#include "mbed-trace/mbed_trace.h"
#include "bootutil/bootutil.h"
#include "secondary_bd.h"
#include "flash_map_backend/secondary_bd.h"

#define TRACE_GROUP "MAIN"

Expand Down
43 changes: 43 additions & 0 deletions MCUboot/target/bootloader/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

# Bootloader

cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR)

set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/mbed-os CACHE INTERNAL "")
set(MCUBOOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/mcuboot CACHE INTERNAL "")
set(MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "")
set(APP_TARGET bootloader)

include(${MBED_PATH}/tools/cmake/app.cmake)

project(${APP_TARGET})

add_subdirectory(${MBED_PATH})
add_subdirectory(${MCUBOOT_PATH}/boot/bootutil/)
add_subdirectory(${MCUBOOT_PATH}/boot/mbed/) # Mbed-MCUboot Port

add_executable(${APP_TARGET})

target_sources(${APP_TARGET}
PUBLIC
default_bd.cpp
signing_keys.c
)

target_link_libraries(${APP_TARGET}
PUBLIC
bootutil
mbed-mcuboot
mbed-storage-spif
mbed-storage-qspif
mbed-baremetal
)

mbed_set_post_build(${APP_TARGET})

option(VERBOSE_BUILD "Have a verbose build process")
if(VERBOSE_BUILD)
set(CMAKE_VERBOSE_MAKEFILE ON)
endif()
2 changes: 1 addition & 1 deletion MCUboot/target/bootloader/mbed-os.lib
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://github.com/noonfom/mbed-os/#27160dbe0460ed5c898effbaf8881c39117ba505
https://github.com/ARMmbed/mbed-os.git
5 changes: 2 additions & 3 deletions MCUboot/target/bootloader/mbed_app.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"*": {
"target.restrict_size": "0x20000",
"target.c_lib": "small",
"target.OUTPUT_EXT": "hex",
"mcuboot.log-level": "MCUBOOT_LOG_LEVEL_DEBUG",
"mbed-trace.enable": true,
"mbed-trace.fea-ipv6": false
Expand All @@ -30,9 +31,7 @@
"mcuboot.slot-size": "0xC0000",
"mcuboot.scratch-address": "0x80E0000",
"mcuboot.scratch-size": "0x20000",
"mcuboot.max-img-sectors": "0x180",
"mcuboot.read-granularity": 1,
"qspif.QSPI_MIN_PROG_SIZE": 1
"mcuboot.max-img-sectors": "0x180"
}
}
}
2 changes: 1 addition & 1 deletion MCUboot/target/bootloader/mcuboot.lib
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://github.com/mcu-tools/mcuboot/
https://github.com/lambda-shuttle/mcuboot.git
4 changes: 2 additions & 2 deletions Mock/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ To verify the success of the transfer, the application computes the [SHA-256](ht

## Pre-requisites

To use the Python client, the host computer must have Bluetooth capabilites, either through an inbuilt chipset or via an external USB adapter. This application requires the [NRF52840_DK](https://os.mbed.com/platforms/Nordic-nRF52840-DK/) platform to run; currently, the build tool only supports this platform. You will also need the [GNU ARM Embedded](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm) toolchain and `python3` in your path to build the example.
To use the Python client, the host computer must have Bluetooth capabilites, either through an inbuilt chipset or via an external USB adapter. You will need the [GNU ARM Embedded](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm) toolchain and `python3` in your path to build the example.

> **Important**: For macOS users, your terminal emulator would have to be granted access to Bluetooth through `System Preferences > Security & Privacy > Pirvacy > Bluetooth`. Click on the padlock to make changes and check the box next to your terminal app. If the app is missing from the menu, click on the `+` icon to add your terminal app to the list.

## Build

To build the example, please run the following command from the repository root. To view more information on the steps involved in the build, please refer to the comments in [mock.sh](../scripts/mock.sh).
```shell
./scripts/fota.sh -e=mock
./scripts/fota.sh -b=DISCO_L475VG_IOT01A -e=mock --flash
```
> **Note**: You can build the example without a connected target board. The script indicates the location of the flash binary at the end of the build; this binary would have to be flashed manually when the target board is indeed connected later.

Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ This repository houses example applications built for the Arm® Mbed™ OS platf
The examples come with _batteries included!_ They're bundled with an automated build tool, "fota.sh", that eases the build process for the end-user. Please refer to the sections below for more information.

## Pre-requisites
Currently, the only supported target board for the examples is the [`NRF52840_DK`](https://os.mbed.com/platforms/Nordic-nRF52840-DK/). The [BLE documentation](https://os.mbed.com/docs/mbed-os/v6.12/apis/ble.html) describes the BLE APIs available on Mbed™ OS; going through this documentation isn't strictly essential to run the examples, but is helpful in understanding the sources.
Currently, the only supported target boards for the examples are the [`NRF52840_DK`](https://os.mbed.com/platforms/Nordic-nRF52840-DK/) and [`DISCO_L475VG_IOT01A`](https://os.mbed.com/platforms/ST-Discovery-L475E-IOT01A/). The [BLE documentation](https://os.mbed.com/docs/mbed-os/v6.12/apis/ble.html) describes the BLE APIs available on Mbed™ OS; going through this documentation isn't strictly essential to run the examples, but is helpful in understanding the sources.

## Build Tool
The `fota.sh` cli tool aids in setup and build of the examples in this repository. Please run `./scripts/fota.sh --help` for usage instructions.

> **Note**: If the mount point is not provided (it could be the case that an end-user is trying to build without the board connected), then the target binary is not flashed. This is especially useful for building the examples with a CI workflow.
> **Note**: If the `-f` or `--flash` option isn't provided (it could be the case that an end-user is trying to build without the board connected), then the target binary is not flashed. This is especially useful for building the examples with a CI workflow. Note that both flashing and erasing is acheived using `pyocd`.
>
> In the case of the MCUboot example, the _"factory firmware"_ is saved and would require manual transfer when the board is indeed connected. In either case, the demonstration step would be the only part that requires manual intervention from the user.
>
> **Important**: For now, the tool assumes the target board, toolchain, and example unless otherwise specified by the end-user. Currently, the only board and toolchain supported are `NRF52840_DK` and `GCC_ARM` respectively.
> **Important**: The tool assumes the target board (`NRF52840_DK`), toolchain (`GCC_ARM`), and example (`mock`) unless otherwise specified by the end-user. Currently, only the `GCC_ARM` toolchain has been verified to work; the verification of functionality for binaries built using ARM Compiler 6 is pending.

## Examples

Expand All @@ -27,10 +27,10 @@ Please refer to the example-specific READMEs for build and demonstration instruc

## Known Issues

1. **Dependency Conflicts**: The difference in version requirements of the [PyYAML](https://pyyaml.org) dependency imposed by both mbed-os and pyocd led to the creation of a temporary virtual environment; this is used in the "_creating and flashing the factory firmware_" stage of the MCUboot example build process. This is a known issue and would require changes to the `requirements.txt` file in the mbed-os to resolve.\
1. **Dependency Conflicts**: The difference in version requirements of the [PyYAML](https://pyyaml.org) dependency imposed by both mbed-os and pyocd led to the creation of a temporary virtual environment (venv), which is used in the target binary flashing stage of both examples. This is a known issue and would require changes to the `requirements.txt` file in the mbed-os to resolve. Another conflict is that between pyocd and mbed-ls on the version requirement of [PrettyTable](https://pypi.org/project/prettytable/), which is resolved through the temporary venv. \
\
Another minor conflict that doesn't hinder the build process is one between mbed-tools and mbed-os on the version requirement of the [Click](https://click.palletsprojects.com/en/8.0.x/) dependency; mbed-tools requires that the minimum version of Click to be greater than 7.1 while mbed-os requires it to be greater than 7.0. Now, the dependencies for mbed-os are installed after those of mbed-tools, which overwrites the newer version and generates a conflict. This would (again) require changes to the requirements file in the mbed-os repository to bump up the minimum version number of Click to 7.1.

Yet another minor conflict that doesn't hinder the build process is one between mbed-tools and mbed-os on the version requirement of the [Click](https://click.palletsprojects.com/en/8.0.x/) dependency; mbed-tools requires that the minimum version of Click to be greater than 7.1 while mbed-os requires it to be greater than 7.0. Now, the dependencies for mbed-os are installed after those of mbed-tools, which overwrites the newer version and generates a conflict. This would (again) require changes to the requirements file in the mbed-os repository to bump up the minimum version number of Click to 7.1.
2. **Target Binary Flashing**: For the Mock example, compiling with mbed-tools results in the following error:
```
ERROR: Build program file (firmware) not found <path to mock example>/target/cmake_build/<target board>/develop/<toolchain>/target.hex
Expand All @@ -50,3 +50,5 @@ Mbed™ OS is an open-source, device software platform for the Internet of Thing
* [mbed-os-example-ble](https://github.com/ARMmbed/mbed-os-example-ble)
* [mbed-os-experimental-ble-services](https://github.com/ARMmbed/mbed-os-experimental-ble-services)
* [mcuboot](https://github.com/mcu-tools/mcuboot)
* [mbed-mcuboot-demo](https://github.com/AGlass0fMilk/mbed-mcuboot-demo)
* [mbed-mcuboot-blinky](https://github.com/AGlass0fMilk/mbed-mcuboot-blinky)
Loading