Typically when adding a unit test directory to a CMake project a check
will be used to ensure the subdirectory is added only if the following
are true:
* The BUILD_TESTING option is set to ON.
* The current CMake project is the top-level project.
The reason being, if a downstream project includes our project they
generally don't want to build our unit tests.
In mbed-os, we do correctly specify the above condition before adding
the central UNITTEST subdirectory, which fetches googletest and adds the
"stub" libraries the unit tests depend on. However, we only check if
CMAKE_CROSSCOMPILING is OFF (or undefined) before actually adding the
unit tests. This mismatched logic would lead to unexpected build
failures in various scenarios. One likely case could be: a downstream
project including mbed-os happens to set CMAKE_CROSSCOMPILING to
OFF/undefined for any reason (possibly to build its own unit tests).
mbed-os would go ahead and attempt to build its tests without fetching
googletest or adding the required stub targets.
To fix the issue replace the check for CMAKE_CROSSCOMPILING in the unit
tests with the same BUILD_TESTING idiom we use for adding the central
UNITTESTS subdirectory.
We get a linker warning with the recently added timing module
implementation for Mbed. This is because there is Mbed TLS also ships a
file called timing.c, which we are including in Mbed OS also. With CLI
1, we get an error about unique object files because of the similarly
named implementation files.
Object file timing.o is not unique! It could be made from: mbed-os/connectivity/mbedtls/source/timing.c mbed-os/connectivity/mbedtls/platform/src/timing.cpp
Rename the Mbed timing module implementation to timing_mbed.cpp to avoid
this naming conflict.
Fixes: b8781e527b ("mbedtls: Add an alt implementation of timing")
Fixes#14759
Fix 'netsocket: several dynamic allocation results not checked' (#14210)
add_event_listener in NetworkInterface now returns an error if the method fails. Previous attempts to add the event listener would attempt to use an unchecked standard dynamically allocated ns_list_* item.
In other cases, the dynamically allocated items will now be checked, and if unsuccessful, will return after cleaning up any outstanding issues.
TCPSocket::accept will now check that its own internally allocated new TCPSocket call will succeed, and if not, will clean up the stack resources. This should help when memory is low but an incoming connection requests a connection when the TCPSocket is listening.
When calculating ufsi, the function was relying
on the slot processed by the unicast fhss timer
callback, which can be delayed. When it happens
the slot value is wrong, and the ufsi is incorrect.
The ufsi is then used by the peer to determined
the reply channel, so the devices are thus
unsynchronized until the next uplink packet.
The compiler gave redefinition warnings if
MBEDTLS_ENTROPY_HARDWARE_ALT is defined in the the compile
definitions. A check is added to prevent this warning.
Remove two expressions from at_cellularcontexttest that do nothing. This
fixes the following two warnings.
connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/at_cellularcontexttest.cpp:61:67: warning: expression result unused [-Wunused-value] ATHandler_stub::int_valid_count_table[kRead_int_table_size]; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~^
connectivity/cellular/tests/UNITTESTS/framework/AT/at_cellularcontext/at_cellularcontexttest.cpp:64:66: warning: expression result unused [-Wunused-value] ATHandler_stub::read_string_table[kRead_string_table_size];
Many test stub functions are meant to return a value, but weren't. Clang
would generate a warning for each instance where we weren't returning
anything in a function that was meant to return a value.
warning: non-void function does not return a value [-Wreturn-type]
For a specific example, my_radio::time_on_air() is supposed to return a
uint32_t, but wasn't returning anything. We'll return a zero instead of
relying on undefined behavior.
Without this, clang 11.0.1 was generating a virtual function
implementation with a `ud2` instruction to abort at run-time, causing
some execution of some unit tests to abort.
Running main() from gmock_main.cc
[==========] Running 10 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 10 tests from Test_LoRaPHYUS915
[ RUN ] Test_LoRaPHYUS915.constructor
[ OK ] Test_LoRaPHYUS915.constructor (0 ms)
[ RUN ] Test_LoRaPHYUS915.restore_default_channels
[ OK ] Test_LoRaPHYUS915.restore_default_channels (0 ms)
[ RUN ] Test_LoRaPHYUS915.rx_config
[ OK ] Test_LoRaPHYUS915.rx_config (0 ms)
[ RUN ] Test_LoRaPHYUS915.tx_config
Process 35669 stopped
* thread #1, name = 'lorawan-loraphy-', stop reason = signal SIGILL: privileged instruction
frame #0: 0x0000000000276f73 lorawan-loraphy-us915-unittest`my_radio::time_on_air(this=0x0000000800c2b048, modem=MODEM_LORA, pkt_len='\0') at Test_LoRaPHYUS915.cpp:90:5
87 };
88
89 virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len)
-> 90 {
91 };
92
93 virtual bool perform_carrier_sense(radio_modems_t modem,
(lldb) disassemble --pc
lorawan-loraphy-us915-unittest`my_radio::time_on_air:
-> 0x276f73 <+67>: ud2
0x276f75: int3
0x276f76: int3
0x276f77: int3
(lldb)
- Remove redundant cmake script as already added the CMake configuration file
- Remove redundant empty_baseline as it is no longer needed with the help of CMake configuration file
This commit introduces changes to fix a missing method, `as_entry`, and traces that were not updated properly to work with this new method.
Prior to this fix, it was not possible to use KVStoreSecurityDb as the build would fail since the `as_entry` method was not declared in the class header file.
This bug was introduced with commit 957486e0eb in PR ARMmbed/mbed-os#14198
Unlike some other cellular modem drivers which use
segmentation, the BG96 driver did not support sending of large
TCP packets, i.e. maximum TCP packet size was restricted to
1400 bytes. This adds segmentation to the send function, so
larger packets can be sent using the TCP socket.
mbedtls_stub uses memset but doesn't add the <string.h> include. This
causes build failures with clang.
Add the include so we can build unit tests using clang.
- Add a new MbedOS project in mbed os root CMake which can be used along with
BUILD_TESTING conditional check for enabling the unittest build
- Update UNITTEST CMake for setting the CMake configuration like c, cxx flags etc.,
- Add if CMAKE_CROSSCOMPILING conditional check wherever target configuration check
and toolchain configuration to avoid such configuration gets included for unittest build.
- Avoid using cmsis headers as it brings more redundant dependency into unittest build and for unittest build, all the required OS flags can provide from mbed rtos types header so replaced cmsis header with mbed os types header
Don't attempt to use default_random_seed unless both PSA and Experimental API
support are enabled. This prevents errors when the Mbed TLS NV Seed feature is
being used on platforms that have PSA enabled by default, but not Experimental
API support by default.
[DEBUG] Output: compilation terminated.
[ERROR] In file included from ./mbed-os/connectivity/mbedtls/include/mbedtls/config.h:31,
from ./mbed-os/connectivity/mbedtls/include/mbedtls/entropy.h:28,
./mbed-os/connectivity/mbedtls/platform/inc/platform_mbed.h:26:10: fatal error: default_random_seed.h: No such file or directory
26 | #include "default_random_seed.h"
Due to a known issue in Mbed TLS's architecture determination
(ARMmbed/mbedtls#1077), we get the error
error: inline assembly requires more registers than available
when compiling `bignum.c` for Cortex-M0/0+/1/M23 which do not have
the macro `__thumb2__` set by the compiler.
The workaround is to define the macro `MULADDC_CANNOT_USE_R7` which
is already defined by Mbed CLI 1 but missing in our CMake support.
FixesARMmbed/mbed-os-example-lorawan#220
mbed-nanostack should depend on mbed-802.15.4-rf to avoid a linker error
with an undefined reference to `NanostackRfPhy::get_default_instance()`.
The error occurs when `device_has: 802_15_4_PHY` is defined and the
consumer depends on mbed-nanostack in their CMakeLists.txt. Previously
we linked mbed-nanostack to mbed-802.15.4-rf, so mbed-802.15.4-rf's
usage requirements weren't forwarded to consumers who depended on
mbed-nanostack.
With the previous configuration, the consumer would have to depend on
mbed-802.15.4-rf directly to avoid an issue. This seems like a layering
violation: it appears that mbed-nanostack is "the API" and
mbed-802.15.4-rf is one of several possible implementations which are
selected based on configuration macros.
This commit changes the flow of dependencies so that mbed-nanostack ends
up with the correct symbol definitions.
Previously WisunBorderRouter start() used NetworkInterface type for mesh interface, although only
WisunInterface type is possible for the call. Added a new overloads of the start with the
WisunInterface as mesh interface type and deprecated the old ones. This makes the calls stricter
about the interface type and safer. It also allows to remove the reinterpret_cast that causes
compiler warning on ARM compiler.
Duplicate status callbacks don't bring any value and can cause
memory leaks if caller calls for this function multiple times with
same status_cb. Also remove all the instances of the status_cb when
removing event listener.
Add mbed_lib.json in the Ambiq target folder of FEATURE_BLE to make sure
the library is excluded in the baremetal build profile unless explicitly
added in `mbed_app.json`.
The CMake target mbed-mbedtls-cryptocell310 was not linked by
default, resulting in a compilation error on targets that use
Mbed TLS:
fatal error: mbedtls_device.h: No such file or directory
Other Mbed TLS drivers simply add themselve to mbed-mbedtls, so this
commits does the alignment to fix the build error.
Note: the driver and the core Mbed TLS have mutual dependency, so
they need to be one CMake target.
* Add traces to GattServerImpl.cpp
* Update BLGS traces
* Add context to BLGS traces
* Set value of TRACE_WRITE_VALUES to 0
* Add param logs to BLGS traces
* Apply changes from code review
* Add trace helper for UUIDs
* C++ string library is not needed
* Update to_string function for UUIDs
The previous implementation had a memory leak and did not format 128-bit UUIDs
* Possibly faster ternary
* Add more context to adding/inserting of services/characteristic
* Add trace to events and event path
* Refactor to_string helper for UUIDs
* Add traces to GapImpl.cpp
* Add helpers and param logs
* Update GapImpl.cpp
* Move helpers to ble_trace_helpers.h
* Add traces to whitelist setter & getter functions
* Prepend parent dir. to ble_trace_helpers.h include line
* Resolve portability issue by using PRI* macro in place of %lu
* Add traces to PalGapImpl.cpp
* Complete PAL GAP traces
* Remove stray include
* Make 'echo' traces in PAL configurable
Some of the tr_info traces at the beginning of PAL functions are duplicates ('echoes') of those in GAP functions. This commit enables including/excluding of these traces in mbed_app.json by writing 1/0, respectively to the MBED_CONF_CORDIO_TRACE_PAL_ECHOES config macro. The default is to exclude 'echo' traces.
* Add missing spaces in tr_info traces
* Clean-up param log for set_extended_advertising_parameters
* Remove "Failed: " from every tr_error trace
* Apply changes from PalGapImpl.cpp review
* Apply changes from GapImpl.cpp review
* Use binary for channel map trace
B0: ADVERTISING_CHANNEL_37
B1: ADVERTISING_CHANNEL_38
B2: ADVERTISING_CHANNEL_39
We're assuming that the user understands the above. This could be documented somewhere.
* Replace more %lu w/PRIu32
* Add tr_info to terminateSync for user call
* Make trace group for PAL traces BLDM
* Remove [PAL] prefix from every PAL trace
* Add trace to setPeripheralPrivacyConfiguration
* Make set scan params tr_info dependent on selected PHY
* Add trace to GAP events
* Other GAP events required traces
* add traces to gatt client
* add files to cmakelists
Co-Authored-By: Vincent Coubard <vincent.coubard@arm.com>
* fixed tracing variable name
Co-Authored-By: Vincent Coubard <vincent.coubard@arm.com>
* add pal tracing
* add more traces for successfull actions
* put write and read as tr_debug in pal
Co-authored-by: Vincent Coubard <vincent.coubard@arm.com>
* ble HCI tracing
* fix typo in SM trace
* add BLE instance tracing
* route wsf traces to mbed tr_debug
* Update connectivity/FEATURE_BLE/source/cordio/source/BLEInstanceBaseImpl.cpp
Co-authored-by: Vincent Coubard <vincent.coubard@arm.com>
* print hci on cordio side
* trace controller supported features
* log reset sequence
* include config for printing enums
* remove duplicate trace
* add tracing to security db
* workaround for macro error on use outside trace
Co-authored-by: Vincent Coubard <vincent.coubard@arm.com>
Add traces to the Bluetooth Security Manager and Privacy controller.
The traces are made to be comprehensive to improve the ux when users submit bugs.
A centralized set of helpers has been created to convert BLE types to string.
* BLE: Add SM traces
* BLE: Add traces to Security Manager PAL
* BLE: Make SM traces consistent.
- Prefix with Connection <id> - when appropriate.
- Display parameters after `:`.
- If multiple parameters should be displayed name then and print the value after =. They are separated by a `,`.
* BLE: Fix SM random number generation.
Only the first 8 bytes were generated from the stack.
* BLE: Regenerate CSRK if it is all zeroes.
* BLE: Add trace into privacy modules
Address resolution is set at the debug level as it is a very common operation and may clutter the output.
* Address trace review for SM:
- Put privacy traces in BLPR
- Add missing traces in PALSecurityManagerImpl.cpp
- Add missing EventHandler null pointer check
- Typo and parameters order fix.
Mbed TLS 2.24.0 has added a new function mbedtls_ecp_write_key()
which is the reverse of the existing mbedtls_ecp_read_key(). This
function should be platform agnostic, but needs to be copied into
Cypress's hardware-accelerated ECP driver as part of the updated
API.
The Mbed TLS importer accidentally imports Makefile and .gitignore
from Mbed TLS's `library/` directory. This commit restricts the
pattern to .h and .c files only, and removes the unnecessary files.
Files have been automatically imported by setting MBED_TLS_RELEASE to
mbedtls-2.24.0 in connectivity/mbedtls/tools/importer/Makefile and
running `make` in that directory.
- Make packet trace optional, can be enabled by enabling macro
STM32xx_DEEP_TRACE
- Shorten traces during driver initialisation to avoid problems with
driver startup when soft reset is used.
Refactor all Cypress targets to be CMake buildsystem targets. This removes
the need for checking MBED_TARGET_LABELS repeatedly and allows us to be
more flexible in the way we include MBED_TARGET source in the build.
A side effect of this is it will allow us to support custom targets
without breaking the build for 'standard' targets, as we use CMake's
standard mechanism for adding build rules to the build system, rather
than implementing our own layer of logic to exclude files not needed for
the target being built. Using this approach, if an MBED_TARGET is not
linked to using target_link_libraries its source files will not be
added to the build. This means custom target source can be added to the
user's application CMakeLists.txt without polluting the build system
when trying to compile for a standard MBED_TARGET.
The PSA crypto tests in
connectivity/mbedtls/tests/TESTS/mbedtls/sanity/main.cpp are only
supported for Arm-v7M PSA targets. For Arm-v8M PSA targets, crypto
regression tests provided by TF-M are used. Refer to
https://github.com/ARMmbed/mbed-os-tf-m-regression-tests for more
information.
Signed-off-by: Devaraj Ranganna <devaraj.ranganna@arm.com>
The test `test_crypto_asymmetric_encrypt_decrypt` was incorrectly
setting the key usage flags. The key usage is updated to support both
encryption and decryption.
Signed-off-by: Devaraj Ranganna <devaraj.ranganna@arm.com>
Add support to BlueNRG_2 BLE component
Signed-off-by: Andrea Palmieri <andrea.palmieri@st.com>
Co-authored-by: Andrea Palmieri <andrea.palmieri@st.com>
Co-authored-by: Paul Szczeanek <paul.szczepanek@arm.com>
This change allows external memory to be used for other purposes while
the WiFi firmware is stored in it by interacting with it via the
reserved region block device.
Corrected Wi-SUN certificate add and remove functions to work properly
with .json certificates. .json certificates are used only if certificates
added by add functions are not set. Corrected certificate add and remove
functions to work properly and improved function descriptions.
- Security manager uses some feature from wsf which is part of the mbed-ble-cordio library so added target_link_library to link the BLE library to cordio stack lib.
- Added absolute path as cmake failed to find linker file from relative path
- Added the missing MBED_CONF_CRYPTOCELL310_PRESENT
- Added the dependency library to BLE Cordio stack