Commit Graph

29 Commits (be295e42a470a4738142a7c2f4b1e1a424a1bee2)

Author SHA1 Message Date
pea-pod 507181d262 Change MBED_STATIC_ASSERTs version for built-in 2020-10-27 08:30:40 -05:00
Kevin Bracey 5ab6f1cef6 Make readdir reentrant
Remove the static allocation for the dirent, and allocate it from the
heap during opendir().

Removing the static data can reduce RAM usage on some toolchains when
directories are not being used. The static allocation sometimes is
combined with the file handle array and can't be dropped by the linker.

Original readdir() was not thread-safe at all.

This was in violation of POSIX which states the result of readdir "is
not overwritten by another call to readdir() on a different directory
stream."

POSIX also defines readdir_r() as separate totally reentrant form where
the caller allocates the dirent, but this is generally deprecated as it
opens the door for an inadequate allocation causing a stack smash. Full
reentrancy is not typically necessary - having readdir()'s buffer data
be per-DIR is generally sufficient.
2020-09-04 16:58:23 +03:00
Devaraj Ranganna 76e911c5ef psa: Replace Mbed PSA with TF-M
Add TF-M to Mbed OS, replacing the previous PSA implementation for
TF-M-capable targets. This commit adds files imported from TF-M, without
modification. The version of TF-M imported can be found in
`features/FEATURE_PSA/TARGET_TFM/VERSION.txt`.

These changes switch to TF-M as the sole PSA implementation for v8-M and
dual core targets, with TF-M running on the secure side and Mbed OS
running on the non-secure side. Single core v7-M targets will continue
to have PSA implemented via PSA emulation, implemented by Mbed OS.

Move or remove many PSA-implementing files, as PSA will be provided by
TF-M on non-single-v7-M targets. Delete any files that are not relevant
for PSA emulation mode.
 - Remove imported TF-M SPM
 - Remove Mbed SPM and tests
 - Remove Mbed-implemented PSA services and tests
 - Remove PSA_SRV_IMPL, PSA_SRV_IPC, PSA_SRV_EMUL and NSPE.
 - Replace PSA_SRV_EMUL and PSA_SRV_IMPL with MBED_PSA_SRV
 - Remove any files autogenerated by
   "tools/psa/generate_partition_code.py", which no longer exists.

Add new feature `PSA` to support PSA in Mbed OS.

Move the Mbed OS implementation of PSA services for v7-M targets (which
employ PSA emulation, and don't yet use TF-M) to
features/FEATURE_PSA/TARGET_MBED_PSA_SRV. Update the `requires`
attribute in TESTS/configs/baremetal.json to avoid breaking baremetal
testing builds.

Update .astyleignore to match new directory structure

Update Mbed TLS importer to place files into FEATURE_PSA

Create the following generic PSA targets:

* `PSA_Target` (Root level PSA generic target)
* `PSA_V7_M` (Single v7-M PSA generic target)
* `PSA_DUAL_CORE` (Dual-core PSA generic target)
* `PSA_V8_M` (v8-M PSA generic target)

Flatten MUSCA_NS and private MUSCA targets into public MUSCA targets.

Move mcuboot.bin to flat location (removing prebuilt folder)

Signed-off-by: Devaraj Ranganna <devaraj.ranganna@arm.com>
Signed-off-by: Jaeden Amero <jaeden.amero@arm.com>
2020-06-18 12:16:20 +01:00
Jaeden Amero fcf427ac11 psa: Remove S-mode only code
Remove all PSA S-mode only code, as it is unused. Only PSA S targets
would use the code, and we've removed those targets in a previous
commit.

Ensure all tests for S-mode code we are deleting is also removed, even
if that code would run in NS-mode. Keep any tests that also test our PSA
emulation support (for single v7-M targets).

Signed-off-by: Jaeden Amero <jaeden.amero@arm.com>
2020-04-27 09:51:13 +01:00
Hugues Kamba eca09b7c17 Fix: Return the correct std I/O device handle for Microlib in retarget code
Return the correct filehandle based on the mode requested. The mode is used
as the pathname is always the default one (":tt") for Microlib. The
previous implementation relied on three successive calls to open the std
I/O device handles, this was not the case.
2020-04-07 13:10:20 +01:00
Rajkumar Kanagaraj 47e68b20cb - Remove the pre-processor directive __ARMCC_VERSION >= 6010050
- Add the code prior to 6.01.0050 versions.
2020-03-27 14:37:01 +00:00
Rajkumar Kanagaraj eb40dbcc20 Remove ARMC5 reference from Mbed OS platform 2020-03-19 10:48:14 -07:00
Maciej Bocianski 783953e5dc ARMC6 keep __user_setup_stackheap symbol when LTO enabled
Fix for the error L6915E: Library reports error: Heap was used, but no heap region was defined
2020-02-04 12:29:53 +01:00
Anna Bridge 40a0b28068
Merge pull request #12225 from evedon/ed-heap-stack-test
Fix baremetal heap and stack initialisation
2020-01-21 16:27:37 +00:00
Evelyne Donnaes 3e3af70afc Fixed baremetal heap and stack initialisation.
Enabled heap_and_stack test for baremetal.
Added a test to check that global variables are initialised.

In mbed_sdk_boot:
- Added initialisation for mbed_stack_isr_start/size and mbed_heap_start/size for all toolchains.
- ARM toolchain:
   - Added call to mbed_toolchain_init() to initialise global variables.
   - Moved microlib initialisation code from mbed_retarget.cpp to mbed_sdk_boot.c.
- IAR toolchain: there is no equivalent to a software init hook that can be called. __low_level_init() was used but since this function is called before RAM initialisation, it cannot be used to initialize global variables. Defined a new __mbed_init() function called from IAR startup file instead.
2020-01-21 10:13:16 +00:00
Hugues Kamba a74ffacf81 Remove usage of UARTSerial in Mbed OS Core diretories
Replace with BufferedSerial as UARTSerial has been deprecated.
2020-01-13 13:20:57 +00:00
Rajkumar Kanagaraj 957dca2082 Enabling small C library option and deprecating uARM toolchain
- By default, Mbed OS build tools use standard C library for all supported toolchains.
   It is possible to use smaller C libraries by overriding the "target.default_lib" option
   with "small". This option is only currently supported for the GCC_ARM toolchain.
   This override config option is now extended in the build tool for ARM toolchain.
 - Add configuration option to specify libraries supported for each toolchain per targets.
 - Move __aeabi_assert function from rtos to retarget code so it’s available for bare metal.
 - Use 2 memory region model for ARM toolchain scatter file for the following targets:
   NUCLEO_F207ZG, STM32F411xE, STM32F429xI, NUCLEO_L073RZ, STM32F303xE
 - Add a warning message in the build tools to deprecate uARM toolchain.
 - NewLib-Nano C library is not supporting floating-point and printf with %hhd,%hhu,%hhX,%lld,%llu,%llX
   format specifier so skipping those green tea test cases.
2019-12-19 10:05:11 -08:00
Hugues Kamba 431f6cb604 Minimal Console: Use static pin map 2019-12-10 15:32:15 +00:00
Martin Kojtal d58e9d6e76
Merge pull request #11959 from hugueskamba/hk-fix-minimal-console
Minimal Console: Fix compilation error
2019-11-28 15:47:20 +01:00
Przemyslaw Stekiel b2dad08387 Change explicit pinmap to static pinmap 2019-11-28 08:32:12 +01:00
Przemyslaw Stekiel ba12228556 Explicit pinmap: Fix build failures reported by CI 2019-11-28 08:32:03 +01:00
Przemyslaw Stekiel d75cc97d80 Explicit pinmap - fix style 2019-11-28 08:32:02 +01:00
Przemyslaw Stekiel 3d719f7e35 K64F, NUCLEO_F429ZI: Use explicit pinmap for console 2019-11-28 08:32:00 +01:00
Hugues Kamba 240758db42 Minimal Console: Fix compilation error
Build successfully when `platform.stdio-convert-tty-newlines` or
`platform.stdio-convert-newlines` are set to `true` by ensuring
`isatty()` is also included when `platform.stdio-minimal-console-only`
is set to `true`.
2019-11-27 12:17:03 +00:00
Hugues Kamba 72d5b51762 Minimal Console: Fix syntax errors 2019-11-26 14:09:01 +00:00
Martin Kojtal eab1c2e594
Merge pull request #11796 from hugueskamba/hk-add-minimal-console-to-retarget
mbed_retarget: Add a minimal console implementation to provide basic functionalities
2019-11-13 17:11:27 +01:00
Hugues Kamba 051991fafb mbed_retarget: Add a minimal console implementation to provide basic functionalities
The retarget code allocates an array of FileHandle* for console and file
handling (filehandles). A tiny target only needs a console (putc/getc).
There is no need for file handling.

The POSIX layer and the array of FileHandle* is not required for small
targets that only need a console ; this code is optionally compiled
out if the configuration parameter platform.stdio-minimal-console-only is
set to `"true"`.
2019-11-11 15:14:00 +00:00
Kevin Bracey 93fbfafedf ARM toolchain: heap setup micro-optimisation
Locating and checking the length of the `ARM_LIB_HEAP` region is an
extra task, when we're just interested in the base and limit. Looking at
only those saves 8 bytes of ROM.

More space could be saved if we ensured all targets had `ARM_LIB_HEAP`,
removing the need for this run-time fallback code.
2019-10-17 12:39:33 +03:00
Anna Bridge 8688b183a9
Merge pull request #11572 from kjbracey-arm/sbrk2_fix
Tighten GCC 2-region _sbrk
2019-10-03 11:19:37 +01:00
Kevin Bracey 046379e629 Tighten GCC 2-region _sbrk
When moving to the second heap region due to overflowing the first
region, the `_sbrk` implementation assumed the allocation would fit in
the second region, and didn't check for that overflowing too.

Problem revealed in `stats_heap` test with GCC 8 on K64F - the allocation
attempt for 1GiB crashed, as `_sbrk` indicated 1GiB was available at the
start of the second region.
second region.

Presumably older versions of newlib fault that allocation attempt before
passing to `_sbrk`.

While there, adjust the code to not use a separate static `bool`, saving
RAM. We can track with just one pointer, as order of the two regions is
fixed, and already relied on by newlib.
2019-09-26 16:12:59 +03:00
Hugues Kamba cc7403457d Fix ARMC6 linker error for the bare metal profile
The ARMC6 compiler inadvertently introduces the `_scanf_mbtowc` symbol
to the build. The commit provides a weak definition of the symbol to
satisfy the linker whenever the symbol is included. This affects ARM
Compiler 6 version 6.12 and earlier.

The compiler error was previously observed when the MICROLIB library is
used with the uARM toolchain. However, the weak definition was put in
`mbed-os/rtos` which is not included when the bare metal profile is used.
2019-09-25 12:20:50 +01:00
Hugues Kamba 93f50eef3d Suppress Coverity warnings 2019-09-12 15:44:55 +01:00
Hugues Kamba e12400932d Fix Coverity issues
Issues fixed are related to:
* Non-static class member initialization in constructors
* Unused function return value
* Always false statements
2019-09-11 11:27:27 +01:00
Hugues Kamba 83354e46a7 Platform: Separate internal APIs from public APIs
Also includes:
* rename `mbed_sleep_manager.c` to `mbed_power_mgmt.c` to match its
  header file
* create Doxygen groups for public and internal APIs
* use relative path to include header files where inconsistent
* update references to internal APIs throughout libraries
* update the copyright year for all modified files
2019-08-02 12:23:47 +01:00