Skip to content

Commit

Permalink
CMSIS: Restructure ported CMSIS_5
Browse files Browse the repository at this point in the history
See docs/adr/0001_cmsis_component_source_structure_recommendations.md
For details information.
  • Loading branch information
hugueskamba committed Sep 1, 2020
1 parent 5535eee commit 834e530
Show file tree
Hide file tree
Showing 107 changed files with 60 additions and 119 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ matrix:
# Check that example compiles without rtos
- sed -n '/``` cpp/,/```/{/```$/Q;/```/d;p;}' ${EVENTS}/README.md > main.cpp
- |
rm -r rtos/source/TARGET_CORTEX drivers/source/usb connectivity/cellular connectivity/drivers/cellular \
rm -r cmsis/CMSIS_5/CMSIS/RTOS2 cmsis/device/rtos drivers/source/usb connectivity/cellular connectivity/drivers/cellular \
connectivity/libraries/ppp connectivity/netsocket connectivity/nanostack connectivity/lwipstack features/frameworks/greentea-client \
features/frameworks/utest features/frameworks/unity components BUILD
- python tools/make.py -t GCC_ARM -m NUCLEO_F103RB --source=. --build=BUILD/NUCLEO_F103RB/GCC_ARM -j0
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions cmsis/CMSIS_5/CMSIS/RTOS2/mbed_lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "cmsis-cmsis5-rtos2"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
43 changes: 43 additions & 0 deletions cmsis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

# CMSIS Version 5

This directory contains a ported version of the upstream repository for [CMSIS_5](http://arm-software.github.io/CMSIS_5/General/html/index.html) as well as Mbed specific RTX configuration and RTOS boot source files.

The upstream source code is imported using the Python script located at [`tools/importer/importer.py`](../tools/importer/importer.py) when passed the [`tools/importer/cmsis_importer.json`](../tools/importer/cmsis_importer.json) configuration file.
For more information on the importer script please read [`tools/importer/README.md`](../tools/importer/README.md).

The directory is organised as follows:

```
+--cmsis
| +-- README.md # The present mardown file
| +-- device/
| +-- mbed_cmsis_conf.h # Process stack configuration
| +-- RTE/
| +-- include/
| +-- RTE_Components.h # Run-Time-Environment Component Configuration File
| +-- rtos/
| +-- mbed_lib.json # Mbed library configuration file
| +-- include/
| +-- mbed_boot.h # Declares the functions that run before main()
| +-- mbed_rtx_conf.h # Changes to RTX configuration
| +-- mbed_rtx_storage.h # Declares the primitives storage types for RTX
| +-- source/
| +-- mbed_boot.c # Implements some of the functions that run before main()
| +-- mbed_rtos_rtx.c # Implements some of the functions that run before main()
| +-- mbed_rtx_handlers.c # Implements RTX handlers
| +-- mbed_rtx_idle.cpp # Implements RTX idle loop
| +-- TOOLCHAIN_ARM_MICRO/
| +-- mbed_boot_arm_micro.c # Mbed entry point for the uARM toolchain
| +-- TOOLCHAIN_ARM_STD/
| +-- mbed_boot_arm_std.c # Mbed entry point for the ARM toolchain
| +-- TOOLCHAIN_GCC_ARM/
| +-- mbed_boot_gcc_arm.c # Mbed entry point for the GCC_ARM toolchain
| +-- TOOLCHAIN_IAR/
| +-- mbed_boot_iar.c # Mbed entry point for the IAR toolchain
| +-- CMSIS_5/ # Imported from the upstream repository as described in the importer script configuration file (cmsis_importer.json)
```

Two Mbed libraries live within this directory:
* `rtos` from `device/rtos`
* `cmsis-cmsis5-rtos2` from `CMSIS_5/CMSIS/RTOS2`
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
129 changes: 12 additions & 117 deletions docs/adr/0001_cmsis_component_source_structure_recommendations.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,125 +5,20 @@ Date: 2020-08-19
Proposed

## Context
[`ARM-software/CMSIS_5`](https://github.com/ARM-software/CMSIS_5) has been ported to Mbed OS. However, it is split across multiple directories and it is not immediately obvious that it comes from that repository when imported with the [importer script](../../tools/importer/importer.py ).

[`ARM-software/CMSIS_5`](https://github.com/ARM-software/CMSIS_5) has been ported to Mbed OS. However, it is split across multiple directories and it is not immediately obvious that it comes from that directory. It also makes it difficult to create an independent CMake target can be built as a library that can be optionally be added by end users.
## Decision
The current proposal is to create new directories within the existing `cmsis/` directory:
* `CMSIS_5/`: mirrors closely the structure used by `ARM-software/CMSIS_5/` keeping only the directories and files needed by Mbed OS and renames some directories in order to work with Mbed OS build tools. See [importer configuration file](./../tools/importer/cmsis_importer.json).
* `device`: includes Mbed OS specific files to configure RTX.

The current proposal is to create a new directory `CMSIS_5/` at the root of the repository that will mirror closely the structure used by `ARM-software/CMSIS_5/` keeping only the directories and files needed by Mbed OS. It will also include Mbed OS specific files and rename some directories in order to work with Mbed OS build tools (see [Decision](#decision) section below). This will result in the removal of the `rtos/source/TARGET_CORTEX/` and `cmsis/` directories.
This will result in the removal of the `rtos/source/TARGET_CORTEX/` directory.
Additionally, `cmsis/TARGET_CORTEX_A/TOOLCHAIN_IAR/cmain.S` to `platform/source/TARGET_CORTEX_A/TOOLCHAIN_IAR/cmain.S` so it can be accessible when building with the bare metal profile. Note that we already have the equivalent file for TARGET_CORTEX_M at `platform/source/TARGET_CORTEX_M/TOOLCHAIN_IAR/cmain.S`.

Additionally it will provide the following advantages:
* Better maintenance of component
* Easy creation of an independent CMake target
* Easy source navigation that mirrors closely the upstream repository


## <a name="decision"></a>Decision
The following directory restructure is recommended:

```
+--cmsis
| +-- README.md
| +-- TARGET_CORTEX_A/
| +-- TOOLCHAIN_IAR/
| +-- cmain.S # Currently cmsis/TARGET_CORTEX_A/TOOLCHAIN_IAR
| +-- device/
| +-- rtos2/
| +-- mbed_lib.json # New Mbed library named `cmsis-device-rtos2`, so it can be excluded from bare metal profile
| +-- include/
| +-- A # Header files currently in rtos/source/TARGET_CORTEX/
| +-- mbed_cmsis_conf.h # Currently in cmsis/
| +-- source/
| +-- B # Source files currently in rtos/source/TARGET_CORTEX/
| +-- RTE/
| +-- include/
| +-- RTE_Components.h # Currently in cmsis/
| +-- TOOLCHAIN_ARM_MICRO/ # Currently in rtos/source/TARGET_CORTEX/
| +-- TOOLCHAIN_ARM_STD/ # Currently in rtos/source/TARGET_CORTEX/
| +-- TOOLCHAIN_GCC_ARM/ # Currently in rtos/source/TARGET_CORTEX/
| +-- TOOLCHAIN_IAR/ # Currently in rtos/source/TARGET_CORTEX/
| +-- CMSIS_5/
| +-- CMSIS/
| +-- RTOS2/
| +-- mbed_lib.json # Currently in rtos/source/TARGET_CORTEX/, creates `cmsis-cmsis5-rtos2` Mbed library
| +-- Include/
| +-- C # Content of rtos/source/TARGET_CORTEX/rtx5/Include/
| +-- RTX/
| +-- Config/
| +-- D # Content of rtos/source/TARGET_CORTEX/rtx5/RTX/Config/
| +-- Include/
| +-- E # Content of rtos/source/TARGET_CORTEX/rtx5/RTX/Include/
| +-- Include1/
| +-- cmsis_os.h # Currently in rtos/source/TARGET_CORTEX/rtx4/
| +-- Library/
| +-- cmsis_os1.c # Currently in rtos/source/TARGET_CORTEX/rtx4/
| +-- Source/
| +-- F # Content of rtos/source/TARGET_CORTEX/rtx5/RTX/Source/
| +-- Source/
| +-- G # Content of rtos/source/TARGET_CORTEX/rtx5/Source
| +-- Core_A/
| +-- Include/
| +-- H # Header files currently in cmsis/TARGET_CORTEX_A/
| +-- Source/
| +-- I # Source files currently in cmsis/TARGET_CORTEX_A/
| +-- Core/
| +-- Include/
| +-- J # Header files currently in cmsis/TARGET_CORTEX_M/
| +-- Source/
| +-- K # Source files currently in cmsis/TARGET_CORTEX_M/
```

However, to cope with Mbed-CLI requirement to find directories to process with the target labels mechanism, some directories will be prefixed with `TARGET_` and capitalized. It will therefore look as follows:

```
+--cmsis
| +-- README.md
| +-- TARGET_CORTEX_A/
| +-- TOOLCHAIN_IAR/
| +-- cmain.S # Currently cmsis/TARGET_CORTEX_A/TOOLCHAIN_IAR
| +-- device/
| +-- rtos2/
| +-- mbed_lib.json # New Mbed library named `cmsis-rtos2`, so it can be excluded from bare metal profile
| +-- include/
| +-- A # Header files currently in rtos/source/TARGET_CORTEX/
| +-- mbed_cmsis_conf.h # Currently in cmsis/
| +-- source/
| +-- B # Source files currently in rtos/source/TARGET_CORTEX/
| +-- RTE/
| +-- include/
| +-- RTE_Components.h # Currently in cmsis/
| +-- TOOLCHAIN_ARM_MICRO/ # Currently in rtos/source/TARGET_CORTEX/
| +-- TOOLCHAIN_ARM_STD/ # Currently in rtos/source/TARGET_CORTEX/
| +-- TOOLCHAIN_GCC_ARM/ # Currently in rtos/source/TARGET_CORTEX/
| +-- TOOLCHAIN_IAR/ # Currently in rtos/source/TARGET_CORTEX/
| +-- CMSIS_5/
| +-- CMSIS/
| +-- RTOS2/
| +-- mbed_lib.json # Currently in rtos/source/TARGET_CORTEX/, creates `rtos` Mbed library
| +-- Include/
| +-- C # Content of rtos/source/TARGET_CORTEX/rtx5/Include/
| +-- RTX/
| +-- Config/
| +-- D # Content of rtos/source/TARGET_CORTEX/rtx5/RTX/Config/
| +-- Include/
| +-- E # Content of rtos/source/TARGET_CORTEX/rtx5/RTX/Include/
| +-- Include1/
| +-- cmsis_os.h # Currently in rtos/source/TARGET_CORTEX/rtx4/
| +-- Library/
| +-- cmsis_os1.c # Currently in rtos/source/TARGET_CORTEX/rtx4/
| +-- Source/
| +-- F # Content of rtos/source/TARGET_CORTEX/rtx5/RTX/Source/
| +-- Source/
| +-- G # Content of rtos/source/TARGET_CORTEX/rtx5/Source
| +-- TARGET_CORTEX_A/
| +-- Include/
| +-- H # Header files currently in cmsis/TARGET_CORTEX_A/
| +-- Source/
| +-- I # Source files currently in cmsis/TARGET_CORTEX_A/
| +-- TARGET_CORTEX_M/
| +-- Include/
| +-- J # Header files currently in cmsis/TARGET_CORTEX_M/
| +-- Source/
| +-- K # Source files currently in cmsis/TARGET_CORTEX_M/
```
It will provide the following advantages:
* Better maintenance of the CMSIS component
* Easy creation of an independent CMake target that can be built as a library that can be optionally be linked against by end users
* Easy source navigation that mirrors closely the upstream CMSIS_5 repository

## Documentation
The README.md may contain a brief introduction to the component. Detailed documentation may be added under `docs` directory.
A `README.md` within the `cmsis` will contain a brief introduction of the component and will detail the Mbed specific files added.
File renamed without changes.
2 changes: 1 addition & 1 deletion platform/source/mbed_sdk_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

/* This startup is for baremetal. There is no RTOS in baremetal,
* therefore we protect this file with MBED_CONF_RTOS_PRESENT.
* Note: The start-up code for mbed OS is in rtos/source/TARGET_CORTEX/mbed_boot code file.
* Note: The start-up code for mbed OS is in cmsis/device/rtos/TOOLCHAIN_<TOOLCHAIN>/mbed_boot_<TOOLCHAIN>.c code file.
*/
#if !defined(MBED_CONF_RTOS_PRESENT)

Expand Down

0 comments on commit 834e530

Please sign in to comment.