Commit Graph

1316 Commits (refactor_hal_greentea_cmake)

Author SHA1 Message Date
Martin Kojtal c14396a5b6
Merge pull request #15045 from LDong-Arm/malloc_newlib_nano
Workaround for a bug in malloc() from newlib-nano 4.1.0 (in GCC 10.3)
2021-09-03 15:03:31 +01:00
Lingkai Dong 8d32b668ec Workaround for a bug in malloc() from newlib-nano 4.1.0
The commit 84d0689 "Nano-malloc: Fix for unwanted external heap
fragmentation" from newlib 4.1.0 introduced several optimizations,
one of which is as follows:

When the last chunk in the free list is smaller than requested,
nano_malloc() calls sbrk(0) to see if the heap's current head is
adjacent to this chunk, and if so it asks sbrk() to allocate the
difference in bytes only and expands the current chunk.

This doesn't work if the heap consists of non-contiguous regions.
sbrk(0) returns the the current region's head if the region has any
remaining capacity. But if this capacity is not enough for the second
(non-trivial) call to sbrk() described above, allocation will happen
from the next region if available. Expanding the current chunk won't
work and will result in a segmentation fault.

So this optimization needs to be reverted in order to bring back
compatibility with non-contiguous heaps. Before the next version
of newlib becomes available and gets updated in the GCC Arm Embedded
Toolchain, we work around this issue by including the fix in Mbed OS.
The linker prioritizes malloc() from the project to the one from the
toolchain.
2021-09-01 17:21:32 +01:00
Martin Kojtal 50c135292c
Merge pull request #15019 from ARMmbed/refactor_platform_greentea_cmake
Refactor platform greentea cmake
2021-09-01 15:24:49 +01:00
Martin Kojtal 513f581bce
Merge pull request #15012 from felser/MTS_DRAGONFLY_L496VG
Add platform MTS_DRAGONFLY_L496VG
2021-08-24 09:50:58 +01:00
Rajkumar Kanagaraj 6cc3d6dd17 Update platform CMake to include greentea test dir 2021-08-23 21:41:17 +01:00
Rajkumar Kanagaraj 16c9058fd1 CMake: greentea: Add skip reason to platform test 2021-08-23 21:40:50 +01:00
Rajkumar Kanagaraj 40253b2a54 CMake: Refactor platform greentea test CMake
Initially, every library greentea test has its project() creation in
their CMake. As running greentea using CTest move all greentea test
suite under one global project mbed-os and MBED_CONFIG_PATH set at
the root mbed os CMake under the condition BUILD_GREENTEA_TESTS
check so refactored platform greentea CMake accordingly.
2021-08-23 21:39:19 +01:00
Leon 4b27aef0ae Add platform MTS_DRAGONFLY_L496VG 2021-08-18 12:03:48 -05:00
mbedmain 3377f083b3 Update Mbed version block 2021-08-18 12:44:48 +01:00
Martin Kojtal 2ceb3bfd6a
Merge pull request #14935 from jeromecoutant/PR_IAR
mbed_retarget: enable IAR build
2021-08-17 10:25:03 +01:00
Lingkai Dong 6776069a18 CMake: greentea: Port PSA Attestation test to CTest
The PSA Attestation test suite requires full RTOS. There is no need
to explicitly check PSA support, because when we build all greentea
tests from the top of Mbed OS, PSA tests only get included if PSA is
enabled.
2021-08-11 11:43:17 +01:00
Robert Walton 7842320ab7 CMake: Add option to enable greentea tests
Add an option to enable the greentea tests independently from the unit
tests.

We can't just use the typical BUILD_TESTING option to enable greentea
tests. BUILD_TESTING enables unit tests and fetches googletest, which
are compiled for the host. Greentea tests are cross compiled and require
a toolchain file. For this reason we add a new option just to enable
greentea tests, preventing build failures triggered by the unit tests
and googletest.
2021-08-10 16:35:11 +01:00
Lingkai Dong dca2aa79a0 Unit tests: Remove redundant CMake target mbed-headers-base
Individual libraries' `target_h` stub headers have now all been moved
from `mbed-headers-base` to `mbed-headers-<library>`.

Note: Even though headers previously in `target_h` are technically
stubs/fakes too, they are used by not only unit tests but also regular
libraries when compiled for unit tests, because no target-specific HAL
implementation exists in this case. In order for regular library
sources to pick up `target_h` headers, those headers must

* have the same names as regular headers
* appear first in include paths

This is why those headers are part of `mbed-headers-<library>` and not
`mbed-stubs-<library>`. Before this refactoring, `mbed-headers-base`
was the first in unit tests' include paths.
2021-08-02 17:42:43 +01:00
Lingkai Dong c775e30b2d Unit tests: Move randLIB.h
The stub header randLIB.h overrides the header of the same name in
platform/randlib/ which is an external repository vendored into
the mbed-os codebase. As the repository is synchronized regularly,
it is better not to put overrides there, so we put the randLIB.h
stub into the regular platform doubles directory.
2021-08-02 17:42:43 +01:00
Lingkai Dong 4011e2ef85 Unit tests: Move platform target_h stubs
Stubs previously in UNITTESTS/target_h/ have the same names as
regular Mbed OS headers, intending to override the latter directly.
We move platform target_h stubs into
platform/tests/UNITTESTS/doubles/platform/.

Note: nvic_wrapper.h is normally implemented and used by Mbed targets
as needed. But as unit tests do not have a real target, we treat it
as a stub for the platform.
2021-08-02 17:42:42 +01:00
Lingkai Dong 7e3565b5f5 Unit tests: Move cmsis target_h stubs
This creates a new mbed-headers-cmsis which is always and only used
by mbed-headers-platform, so we add the former to the laters' linked
targets.
2021-08-02 17:42:42 +01:00
Jaeden Amero 744814f0a0
Merge pull request #14900 from 0xc0170/feature_CMSIS_5_13b9f72f2
Update CMSIS to 5.8.0
2021-07-30 09:43:11 +01:00
Martin Kojtal 38ca4bdce4 semihosting: add compat header where is required
ARMCC provides __semihost via compat header. As CMSIS 5.8.0 removed this compat header,
we need to explicitly include it to fix definition missing error.
2021-07-29 14:31:38 +01:00
Martin Kojtal 8bdec2b4db retarget: move compat header for ARMClang prior any cmsis headers
Reference: CMSIS 5.8.0 known issues and https://github.com/ARM-software/CMSIS_5/issues/1211

This fixes the error about redefinition of enable/disable irq. we need compat header because of
semihosting (not yet provided in CMSIS).
2021-07-29 14:31:33 +01:00
Robert Walton a09d08917b CMake: unittests: Show all tests in CTest report
Previously a test executable was recognised as a single test by CTest.
However, test executables usually contain multiple test cases, the
results of the test cases should be individually reported. With our
previous setup we could miss test case failures that didn't cause the
executable to return an error code.

This commit uses gtest_discover_test to discover all test cases in a
test executable. This enables CTest to match test passes and failures
from the googletest binary output.
2021-07-27 21:09:39 +01:00
Jaeden Amero 862a9420fe
Merge pull request #14948 from Patater/lorawan-timer-unittest-fake-fix
Fix lorawantimer unit test
2021-07-27 14:02:47 +01:00
Jaeden Amero 51b81e0629 test: Make MBED_ASSERT failures fail
Make MBED_ASSERT failures fail the unit test case. Without this, we
might not notice the assertion failure as it wouldn't be bubbled up to
googletest.
2021-07-27 10:28:12 +01:00
Jaeden Amero f0d7e24066 test: CircularBuffer: Don't push zero elements
The CircularBuffer doesn't allow pushing zero elements; you must push at
least one. Update the CircularBuffer unit test to avoid invalid use of
the CircularBuffer.
2021-07-27 10:28:12 +01:00
Martin Kojtal efaf159ca4
Merge pull request #14945 from OpenNuvoton/nuvoton_tfm_missing_update
TFM: Add missing IPC file for PSA Firmware Update
2021-07-23 14:33:06 +02:00
Chun-Chieh Li d5130d33d7 TFM: Add missing IPC file for PSA Firmware Update
On a target that doesn't support Firmware Update, compilation still works, and any attempt to call the Firmware Update API returns a runtime error which is good enough.
2021-07-23 09:26:17 +08:00
Lingkai Dong 351680fb18 Rework post-build to support multiple executables
When building greentea tests, each test is an executable with its
own output binary path. This is also the case when a user project
produces multiple executables. But the current implementation of
post-build operations always assumes there's only one executable,
at the root of the build directory.

The post-build command depends on Mbed target, and it always takes
the the executable we build as an input file. To achieve this, we
let each Mbed target (that has a post-build command) define a function

    function(mbed_post_build_function target)

which takes a CMake executable target as an argument from which it can
get its binary path using generator expressions. It generates and adds
to the passed executable target a post-build custom command.

Notes:
* The function name needs to be exact, because CMake only supports
literal function calls - CMake can't dereference a function name from
a variable. To avoid multiple definitions of this function, each Mbed
target needs to guard it with a macro to check if the user is
building this Mbed target.
* `mbed_post_build_function()` is a function, but it is usually
defined by another macro rather than a parent function, because
nesting functions would make many variables inaccessible inside the
innermost `mbed_post_build_function()`.
* There's no more need to force regenerate images. Previously, post-
build commands were custom *targets* which always got to run, so we
force regenerated images on every build to avoid patching an image
that's already been patched once on previous build. Now post-build
commands are custom *commands* of the same executable target, and they
are only run if the executable target itself is rebuilt.
2021-07-22 17:31:22 +01:00
Jerome Coutant e61aff6564 mbed_retarget: enable IAR build 2021-07-19 15:05:37 +02:00
mbedmain d147abc3e5 Update Mbed version block 2021-07-14 11:11:35 +01:00
Robert Walton 55f77ea77f CMake: unit-tests: Remove --coverage option from mbed-stubs-platform
We set the --coverage flag globally in UNITTESTS/CMakeLists.txt. We
shouldn't need to also set it on mbed-stubs-platform, so remove it.
2021-07-06 13:50:46 +01:00
Robert Walton 021baa68e7 CMake: unit-tests: Split platform headers out of mbed-stubs-headers
We have a central collection of "stub headers", which makes reasoning
about dependencies rather difficult, as it forces every stub library to
depend on all available stub headers. The standard approach would be for
each stub library to expose its public headers, and its dependents to
explicitly specify a dependency on the stub library containing the
headers it needs. This is a more modular design than creating a
header-only monolith library. Move the platform stub headers from this
central library into the mbed-stubs-platform library to increase
modularity.

mbed-stubs-connectivity now depends on the mbed-stubs-platform because
it requires some headers which were moved to mbed-stubs-platform.
2021-07-06 13:50:46 +01:00
Robert Walton b73b38a01f CMake: unit-tests: Make platform stub only depend on headers it uses
Previously the platform stub library depended on `mbed-headers`, which
is a collection of all available headers in mbed-os. To make it easier
to separate the library, only depend on the headers we're actually using.
2021-07-06 13:50:46 +01:00
Robert Walton e2704749f1 CMake: unit-tests: Move mbed-headers-platform to platform directory
Move the header-only mbed-headers-platform library the unit test stubs
depend on into the platform component directory. This makes the platform
stubs more self contained and improves composition of the library.
2021-07-06 13:50:46 +01:00
Robert Walton 40435fd9b3 CMake: Move platform stubs to the mbed-os/platform directory
Move the platform stub library into the platform component directory.
This change is so we can avoid duplicating the mbed-os source tree in a
central UNITTESTS folder.
2021-07-06 13:50:42 +01:00
Robert Walton 3abc7886a9 CMake: unit-tests: CircularBuffer: Remove trailing whitespace 2021-07-06 13:48:59 +01:00
Jaeden Amero 75808eaaf2
Merge pull request #14783 from rwalton-arm/dont_capture_stdout
tfm-post-build: Don't capture subprocess stdout
2021-07-06 12:57:45 +01:00
Chun-Chieh Li 51f74bcda3 PSA: Fix compile error with NV seed
This compile error can reproduce when both PSA V7M and MBEDTLS_ENTROPY_NV_SEED are both enabled.
2021-07-01 17:44:33 +08:00
Jaeden Amero b5c2f7079e
Merge pull request #14718 from Meano/develop
Feature: Make changes for Cortex-A5 support
2021-07-01 10:23:41 +01:00
Martin Kojtal aa0aa3dc65
Merge pull request #14816 from artokin/nanostack_release_14_0_0_master
Nanostack release v14.0.0
2021-07-01 10:52:18 +02:00
Robert Walton 6d78f93b9e tfm-post-build: Don't capture subprocess stdout
subprocess.PIPE is used to enable the parent process to communicate with
the subprocess via pipes, which mean all stdout and stderr messages are
captured and returned as part of Popen.communicate's result tuple.

In our case, we want to display the error messages on the console, so we
don't need to capture the output from stdout.

Example of a typical error message before this change:
```
Traceback (most recent call last):
  File "platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/scripts/generate_mbed_image.py", line 197, in <module>
    sign_and_merge_tfm_bin(args.tfm_target, args.target_path, args.non_secure_bin, args.secure_bin)
  File "platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/scripts/generate_mbed_image.py", line 81, in sign_and_merge_tfm_bin
    " secure binary, Error code: " + str(retcode))
Exception: Unable to sign musca_b1 secure binary, Error code: 1
```

Example of the error message after this change:
```
Traceback (most recent call last):
  File "/mbed-os/tools/psa/tfm/bin_utils/wrapper.py", line 13, in <module>
    import click
ModuleNotFoundError: No module named 'click'
Traceback (most recent call last):
  File "platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/scripts/generate_mbed_image.py", line 194, in <module>
    sign_and_merge_tfm_bin(args.tfm_target, args.target_path, args.non_secure_bin, args.secure_bin)
  File "platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/scripts/generate_mbed_image.py", line 80, in sign_and_merge_tfm_bin
    raise Exception("Unable to sign " + target_name +
Exception: Unable to sign musca_b1 secure binary, Error code: 1
```

This is a significant improvement as now you can see what the reason for
the failure was.
2021-06-29 15:37:44 +01:00
Jaeden Amero 472c688a83
Merge pull request #14828 from hazzlim/add-cmake-supports-psa-tests
CMake: Add CMake to mbed-psa greentea tests
2021-06-29 15:17:01 +01:00
Hari Limaye f69a37518f CMake: Add support for PSA compliance_its tests
PSA compliance_its tests can now be built with CMake.
2021-06-29 13:33:51 +01:00
Hari Limaye 13ea9f36c1 CMake: Add support for compliance_attestation test
Greentea test for PSA compliance_attestation can now build with CMake.
2021-06-29 13:33:51 +01:00
Hari Limaye 62f110c89b CMake: Add mbed-psa-tal (Test Abstraction Layers)
Move /val and /pal directories into /test_abstraction_layers directory
and combine into one CMake target, mbed-psa-tal. Moved into seperate
directory in order to have own CMakeLists.txt, rather than adding to
/TARGET_MBED_PSA_SRV CMake file.
2021-06-29 13:33:51 +01:00
Hari Limaye 26290addbe CMake: Add support for PSA entropy_inject test
The greentea test for PSA entropy_inject can now be built with CMake.
Note: requires MBEDTLS_ENTROPY_NV_SEED enabled, so not tested on target.
2021-06-29 13:33:51 +01:00
Hari Limaye 24a3daba48 CMake: Add support for PSA its_ps test
The greentea test for mbed-psa its_ps can now be built with CMake.
2021-06-29 13:33:51 +01:00
Hari Limaye 9dc39a8352 CMake: Add support for PSA crypto_init test
The greentea test for mbed-psa crypto_init can now be built with CMake.
2021-06-29 13:33:51 +01:00
Hari Limaye 4bed069d21 CMake: Add support for PSA attestation test
The greentea test for mbed-psa attestation can now be built with CMake.
2021-06-29 13:33:50 +01:00
Hari Limaye f95052cf6f CMake: Require TEST_SOURCES in greentea CMake file
Assumption that greentea test file is always named main.cpp is
incorrect. Updated mbed_greentea_add_test() macro to make TEST_SOURCES
parameter compulsory, which is used to specify greentea test
file(s). This allows tests to use C, or have a different name.
Therefore also updated all pre-existing greentea test CMake files to
explicity add main.cpp to TEST_SOURCES.
2021-06-29 13:33:42 +01:00
Arto Kinnunen 6249aad249 Update copyright (#15)
-Change company name from Arm Limited to Pelion
-Update years
2021-06-28 09:38:11 +03:00
Arto Kinnunen 3a3c728784 Update license text in test files. (#14) 2021-06-28 09:38:11 +03:00