Commit Graph

305 Commits (7be79f93feff724cbd7ee88c7afdecc0b01559db)

Author SHA1 Message Date
Sarah Marsh ee7e21d722 Remove Thread::wait from thread example 2016-12-20 10:42:29 -06:00
sarahmarshy dd07d30c7e Remove invalid thread::start example
This changes reflects the correct syntax for spawning a thread that will execute a local function with given parameters.
2016-12-19 14:43:38 -06:00
Christopher Haster 048a47b908 Marked the RtosTimer class as deprecated
The non-irq timer functionality provided by the RtosTimer is now
duplicated by the EventQueue. See RtosTimer.h for more info.
2016-11-07 13:01:08 -06:00
Sam Grove f2b49b860d Merge pull request #2949 from NXPmicro/Fix_For_Cortex_M4
The HAL CM4 for ARM and IAR toolchains is valid only for FPU present.…
2016-10-07 11:15:22 -05:00
Sam Grove 3a16ca9855 Merge pull request #2911 from theotherjimmy/docs-generation
[Tools] Add documentation generation script
2016-10-06 15:57:08 -05:00
Mahadevan Mahesh b290c71f57 The HAL CM4 for ARM and IAR toolchains is valid only for FPU present. These guards were added
to mbed SDK as there are targets with Cortex-M4. This is similar to the implementation already
done for GCC ARM

Signed-off-by: Mahadevan Mahesh <Mahesh.Mahadevan@nxp.com>
2016-10-06 09:27:59 -05:00
Jimmy Brisson f1a78027d3 Add tags to our code 2016-10-04 15:02:44 -05:00
Laurent MEUNIER 3a61bd025f INIT:ARM + rtos: Align pre-main initialization steps between TCs
Various toolchains supported in MBED don't followthe same initialization
steps. This can have impacts on platform behavior.

For STM32, it is needed to call the HAL_Init() _after_ the  RAM has been
initialized (sdata from flash / zero initialized data) and _before_ the C++
objects are being created, especially if those objects require support
of tickers for instance.

In GCC and IAR, this was done in previous commit to avoid HAL_Init()
to be called twice.

In ARM this there is no hook defined in MBED yet to place the call.
The proposal is to take benefit of the library's
_platform_post_stackheap_init function that is going to be called before
__rt_lib_init where the C++ object init is done (__cpp_initialize__aeabi_)

In case of mbed with rtos, the __rt_entry is redefined so we need to add
the call to _platform_post_stackheap_init.

This series should solve issue reported here:
STM32 (At least F401) breaks if Tickers are activated in a global object #2115
2016-10-04 14:55:28 -05:00
Sam Grove 301b77c4b2 For drivers, events, hal, platform, rtos and mbed.h add one level of path to make sure specific and unique includes files are found. 2016-10-01 02:11:36 -05:00
Christopher Haster 2dd90bbe3c restructure - Restructured rtos directory 2016-09-30 19:18:09 -05:00
Mike Fiore 7836c6eaf1 rebase support for MultiTech xDot platform
[XDOT_L151] copy new target CMSIS files from NZ32_SC151 target

[XDOT_L151] remove Modtronix code, add HardFault_Handler, update clock configuration to match xDot hardware

[XDOT_L151] copy new target HAL files from NZ32_SC151 target

[XDOT_L151] update HAL to match xDot hardware

[XDOT_L151] add xdot_eeprom.* and xdot_low_power.* files

[XDOT_L151] add RTOS support for target

Conflicts:
	rtos/rtx/TARGET_CORTEX_M/RTX_Conf_CM.c

[XDOT_L151] match NUCLEO_L152RE startup code for GCC_ARM so RTOS works

[XDOT_L151] fix GPIO write failure

[XDOT_L151] add XDOT_L151CC target to targets.json

[XDOT_L151] change xDot default stack size to 256 bytes and main stack size to 1.5kB

[XDOT_L151] update PinNames.h to match rev E hardware - no change to external pinout

[XDOT_L151] update style in custom xDot HAL files

Conflicts:
	rtos/rtx/TARGET_CORTEX_M/RTX_CM_lib.h
	rtos/rtx/TARGET_CORTEX_M/RTX_Conf_CM.c
2016-09-27 00:13:08 -07:00
Sam Grove 196584d571 Merge pull request #2805 from RobMeades/master
OS_TCB struct size is increased to 64 bytes (from 60 bytes).  With th…
2016-09-25 22:20:29 -05:00
Sam Grove c49e970909 Merge pull request #2794 from geky/callback-c-order
callback - Reorder optional argument to static C function
2016-09-25 22:07:45 -05:00
Sam Grove 5556d781a1 Merge pull request #2779 from jeromecoutant/PR_NUCLEO_F103RB
[NUCLEO_F103RB] RTOS tests update
2016-09-25 21:57:35 -05:00
Sam Grove e453b5ea9f Merge pull request #2391 from geky/fix-rtos-critical-sections
[rtos] Fix irq-safe rtx calls when inside critical sections
2016-09-24 16:22:26 -05:00
Rob Meades 0b2657932d OS_TCB struct size is increased to 64 bytes (from 60 bytes). With the change to introduce stats checking in commit c1728p9, OS_TCB now includes an extra pointer, *argv, hence it is larger by 4 bytes. 2016-09-24 18:11:10 +01:00
Christopher Haster b371eb5269 callback - Reordered optional argument to static C function
Before:
Callback<void()> a = callback(obj, member)
Callback<void()> b = callback(context, function)

After:
Callback<void()> a = callback(obj, member)
Callback<void()> b = callback(function, context)

This ordering is more intuitive based on feedback from users. This order
was initially considered but proved problematic when integrated with
other variable arguments in attach functions.

With `callback` as a separate convenience function, this style
no longer presents a problem.
2016-09-23 04:52:58 -05:00
Christopher Haster 3e7b5ed6b9 Fixed rtx calls when inside critical sections
Before, rtx calls would hard fault in critical sections when an svc
instruction was attempted with interrupts disabled.

Required changes:
- Added check for CPSR I bit in cortex A rtx
- Added check for PRIMASK in cortex M rtx
- Modified critical sections in cortex M rtx to be recursive
  (already recursive in cortex A)
2016-09-22 21:19:22 -05:00
jeromecoutant c416a1286d [NUCLEO_F103RB] RTOS tests update
As this target has 20K RAM, default stack size needs to be tuned
2016-09-22 14:48:11 +02:00
Tony Wu aa663ea42d RTOS - Move per-target RTX config to mbed_rtx.h
Disintegrate global RTX target config. Move per-target fragment
to mbed_rtx.h under each vendor's directory.

One mbed_rtx.h is defined for each vendor at this moment, however,
the granularity of mbed_rtx.h can be per-chip, or per-board
if necessary.

Signed-off-by: Tony Wu <tung7970@gmail.com>
2016-09-22 15:09:49 +08:00
Sam Grove 0c0455bf3f Merge pull request #2745 from pan-/disable_global_objects_destruction
Disable global objects destruction
2016-09-22 00:48:08 -05:00
Vincent Coubard ce23ec3120 Disable registration of __libc_fini_array in the init process.
With this call, destructors are not registered for execution atexit.
2016-09-19 13:54:50 +01:00
jeromecoutant 7eb69b041f STM32F070RB/STM32F072RB: decrease thread_stack_main size
Thread_stack_main is by default too large for this 16K target
2016-09-19 10:17:53 +02:00
jeromecoutant 519b52181f [STM32F070RB] correct INITIAL_SP 2016-09-19 10:17:30 +02:00
Sam Grove ee1cba0b69 Merge pull request #2572 from tung7970/master
Fix STM32F407VG target name and LPC11U6X linker errors
2016-09-18 17:44:55 -05:00
Sam Grove 52fd7b6864 Merge pull request #2642 from c1728p9/stack_stats
Stack stats
2016-09-16 17:24:20 -05:00
Martin Kojtal 21a2123aad Merge pull request #2669 from andreaslarssonublox/updated_master
Target - Add u-blox C029 target
2016-09-14 10:35:22 +01:00
Russ Butler 8447843c68 Fix error handling when thread cannot be created
Update the Thread::start function to gracefully handle the failed
creation of a thread when there are no TCBs left. This patch does
the following:
1. Set memory handles to NULL after free to prevent double free
2. Post to the release semaphore so anything that tries to join this
    thread will join immediately
3. Remove dead return path since the new operator should never
    return NULL (it should trap instead)
2016-09-13 15:53:19 -05:00
Russ Butler 9e4a479794 Add prefix to mark cmsis_os functions as private
Add a leading underscore to give an indication that the new cmsis_os
API functions are not official.
2016-09-13 15:53:17 -05:00
Russ Butler 1041904914 Turn on stack init so stack usage is correct
Initialize stack memory since this is required for stack metrics to
work.
2016-09-13 15:52:08 -05:00
Russ Butler 6fd9154d75 Add task terminate hook
Add an RTX hook which gets called when a thread terminates. Add
the function Thread::attach_terminate_hook() to allow users to attach
a hook to this event at runtime.
2016-09-13 12:59:05 -05:00
Russ Butler c319296692 Add RTX API to report stack usage
Add the function osThreadGetInfo to allow various Thread information
to be queried.  This includes stack size and maximum stack usage among
other things.

Note - for Cortex-A devices the worst case stack usage is not
available.
2016-09-13 12:58:57 -05:00
Russ Butler ad24b7d982 Add RTX API to enumerate running threads
Add the functions osThreadsEnumStart, osThreadEnumNext and
osThreadEnumFree to allow enumeration of running threads. Protect
thread creation, thread exit and thread termination with a mutex
so threads are not created or destroyed while an enumeration is
ongoing.
2016-09-12 17:08:36 -05:00
andreas.larsson 173486fac0 Added u-blox C029 target 2016-09-12 13:41:38 +02:00
jeromecoutant 2d2a4bcf4b 8K RAM target is too small for RTOS support 2016-09-12 11:49:43 +02:00
Sam Grove 582da03312 Merge pull request #2589 from OpenNuvoton/ccli8
[NUC472] Fix heap configuration error with armcc
2016-09-10 13:08:47 -05:00
Sam Grove c1ee7fb494 Merge pull request #2504 from ohagendorf/disco_f769_ii
[Disco_F769NI] adding new target
2016-09-10 07:16:21 -05:00
Sam Grove 14f5647d62 Merge pull request #2643 from c1728p9/fix_thread_self_termination
Fix thread self termination
2016-09-09 18:01:38 -05:00
Sam Grove 3bb149cab2 Merge pull request #2549 from geky/thread-clarification
Clean up confusion with deprecated constructors and callbacks in thread-spawning functions
2016-09-09 17:58:13 -05:00
ohagendorf 54adfe10c0 [disco_f769ni] adding rtos lib 2016-09-09 14:18:16 +02:00
Sam Grove 57ebf8bdad Merge pull request #2548 from jamike/NUCLEO_F303ZE
Nucleof303ze
2016-09-09 01:48:13 +02:00
Sam Grove a6b27319ec Merge pull request #2496 from geky/callback-cv
Add cv-qualifiers to Callback and deprecate combinatorial explody functions
2016-09-09 01:45:25 +02:00
Russ Butler b49d7e4fb4 Properly handle a thread which terminates itself
In Thread::terminate() release the join semaphore before terminating
the thread. This allows the join semaphore to be properly signaled in
the case where a thread is terminating itself.
2016-09-07 17:21:25 -05:00
Michel Jaouen aae0b921db [NUCLEO_F303ZE] Add RTOS support 2016-09-05 09:09:42 +02:00
ccli8 0194135bf3 [NUC472] Fix heap configuration error with armcc
In rtos/rtx/TARGET_CORTEX_M/RTX_CM_lib.h, Image$$ARM_LIB_HEAP$$Base/Image$$ARM_LIB_HEAP$$Length will cause zero memory allocation.
Fix it with Image$$ARM_LIB_HEAP$$ZI$$Base/Image$$ARM_LIB_HEAP$$ZI$$Length. This is to place heap at external SRAM.
2016-08-31 14:32:13 +08:00
Tony Wu 934ac09d69 STM32F4 - Fix STM32F407VG target name
The target name of STM32F407VG should be TARGET_STM32F407VG,
rather than TARGET_F407VG.

Signed-off-by: Tony Wu <tung7970@gmail.com>
2016-08-29 20:52:11 +08:00
Sam Grove ea56684fff Merge pull request #2531 from radhika-raghavendran/master
ncs36510 from ON Semiconductor
2016-08-27 07:31:39 -05:00
Christopher Haster 022f821d0c Rewrote thread deprecation notices to help migration
User feedback indicated that the previous deprecation notices
were confusing and mislead migration from the old style of thread
spawning.

The deprecation notices were updated to emphasize the replacement
functions, and examples of correct usage were added in the doxygen.
2016-08-26 12:50:13 -05:00
Alessandro Angelino b98227c939 K64F: Revert to hardcoded stack pointer in RTX 2016-08-26 17:19:04 +01:00
Christopher Haster 45d25ed493 Added support for cv-qualifiers in Callback class
Additionally, the following changes were don to avoid combinatorial
explosion in function overloads as a result of adding cv-qualifiers:
- Added convenience function for inferred type
- Deprecated callback overloads qhere cv-qualifiers are not scalable

Supported overloads:
callback(void (*f)(A...));
callback(const Callback<R(A...)> &);
callback(T *t,                void (*f)(T*, A...));
callback(const T *t,          void (*f)(const T*, A...));
callback(volatile T *t,       void (*f)(volatile T*, A...));
callback(const volatile T *t, void (*f)(const volatile T*, A...));
callback(T *t,                void (T::*f)(A...));
callback(const T *t,          void (T::*f)(A...) const);
callback(volatile T *t,       void (T::*f)(A...) volatile);
callback(const volatile T *t, void (T::*f)(A...) const volatile);
2016-08-26 09:40:22 -05:00
Sam Grove 030261f2c4 Merge pull request #2544 from tung7970/master
Fix implicit declaration of function 'atexit'
2016-08-26 09:30:19 -05:00
Sam Grove daf4b1c6b1 Merge pull request #2528 from jeremybrodt/max32620
[MAX32620HSP] Initial release.
2016-08-26 09:25:33 -05:00
Radhika b75379f353 Adding NCS36510 support in mbed-os5.1 2016-08-26 12:00:54 +05:30
Jeremy Brodt 2604773a27 [MAX32620HSP] Added support to RTX files. 2016-08-25 16:55:42 -05:00
Tony Wu 6157563ae3 Fix implicit declaration of function 'atexit'
Silence the following compiler warning:
[Warning] RTX_CM_lib.h@807,5: implicit declaration of function 'atexit' [-Wimplicit-function-declaration]

Signed-off-by: Tony Wu <tonywu@realtek.com>
2016-08-25 18:07:54 +08:00
Michel Jaouen a1bd087380 STM32F3 : fix RTOS IAR test not compiling.
Thread_stack_main is by default too large for this target.
2016-08-24 11:53:53 +02:00
Martin Kojtal 64a30a0095 Merge pull request #2479 from geky/deprecated-until
Updated deprecation notices to match branch names
2016-08-18 09:06:39 +01:00
Martin Kojtal 8568c9eac8 Merge pull request #2394 from geky/deprecated-until
Add more well-defined garuntees on deprecation notices in mbed
2016-08-17 14:45:46 +01:00
Christopher Haster b12c27c5b4 Updated deprecation notices to match branch names
Example:

    MBED_DEPRECATED_SINCE("mbed-os-5.1", "don't foo any more, bar instead")
    void foo(int arg);
2016-08-16 20:30:20 -05:00
Christopher Haster 0f516aa8e0 Added more well-defined garuntees on deprecation notices in mbed
From the discussion on issue #2068:
Functions marked deprecated in the mbed library should notate when
the deprecation was started to allow efficient removal once a set
amount of time has expired.

Added the following macro:
MBED_DEPRECATED_SINCE("version", "message string")

Example usage:

    MBED_DEPRECATED_SINCE("v5.1", "don't foo any more, bar instead")
    void foo(int arg);

Adopted in existing deprecations:
- FunctionPointer
- RtosTimer
- Thread
2016-08-16 15:45:51 -05:00
Mahadevan Mahesh 0ad9220fb1 Add support for FRDM K66
Signed-off-by: Mahadevan Mahesh <Mahesh.Mahadevan@nxp.com>
2016-08-15 15:37:25 -05:00
Russ Butler d9ac33d0c3 Increase interrupt stack size for K64F
The config store tests use more than 2K of the interrupt stack, causing
an overflow.  This patch bumps the K64F interrupt stack size to 4K
for ARMCC and GCC. The IAR interrupt stack is left untouched since
it is 32K.
2016-08-09 14:55:05 -05:00
Russ Butler 1615dca6bd Add a test for heap and stack layout
Test the following components of the heap and stacks:
-Heap and interrupt stack are at the expected locations
-Entire heap can be used
-Heap limit is properly enforced and returns NULL when out of
  of memory
2016-08-09 14:54:17 -05:00
Russ Butler 81382ebdb2 Turn on main thread stack checking
Since the heap and stack are no longer shared, stack checking on the
main thread can be turned back on. This allows stack overflows on the
main thread to be caught quickly.
2016-08-09 14:50:17 -05:00
Russ Butler 1d3d01f000 Correctly set INITIAL_SP for K64F
With the latest K64F linker file the initial stack is out of sync
with INITIAL_SP when uVisor is not present. This patch removes
the incorrect declaration.
2016-08-09 14:49:47 -05:00
Russ Butler da4787f036 Adjust stack size for the nrf51
Decrease the main stack size for the nrf51 so there is more heap
space available.
2016-08-09 14:42:09 -05:00
Russ Butler 7cf1dc1155 Fix heap limit checking and make memory explicit
Set well defined limits for the heap and configure GCC and ARMCC to
correctly check these. IAR already correctly checked its heap.

This also statically declares the main thread stack so the
linker is responsible for its placement.
2016-08-09 13:44:33 -05:00
Russ Butler e44ab35c42 Fix joining a terminated thread
When a thread is terminated signal the join semaphore so any threads
joining the terminated thread wake up as expected.
2016-08-08 16:42:20 -05:00
Sam Grove 34caf43f5a Merge pull request #2238 from OpenNuvoton/nuc472
[NUC472] Add NUMAKER-PFM-NUC472
2016-08-04 10:37:31 -05:00
Russ Butler 191596ea57 Set thread ID to NULL after termination
After a thread has been terminated set its ID to NULL since the handle
is no longer valid. This prevents accidental use of a deleted thread.
2016-08-03 11:02:46 -05:00
Russ Butler 55d74c55ed Fix join and make Thread class thread safe
Add a mutex to the thread object to protect its internal data. Prevent
making OS calls with a thread ID that has been terminated. This thread
ID can be reused by another thread, leading to undefined behavior if it
is used after termination.

Update the function Thread::join to use a semaphore to
determine when the thread finishes. This both avoids polling and
prevents a freed TCB from being accessed.
2016-08-02 21:17:40 -05:00
ccli8 41242e3d55 Support NUMAKER_PFM_NUC472 2016-07-28 10:00:49 +08:00
Sam Grove 90fa585568 Merge pull request #2211 from pan-/nrf52_nrf51_unified_integration
NRF52 target and unification with NRF51
2016-07-27 02:35:43 -05:00
Sam Grove d1da7bc0e7 Merge pull request #2256 from NXPmicro/K22_RTOS_FIX
The core clock in run mode is 80MHz for K22F
2016-07-26 21:20:23 -05:00
Russ Butler 2d50c60a78 Fix MAIN_THREAD_ID check
In cmsis_os.h OS_TIMERS is undefined unless the timer thread is
disabled, in which case it is defined to 0. When comparing against
an undefined value, the undefined value will evaluate as if it were
0. Because of this the MAIN_THREAD_ID was always set to 0x1.
This patch fixes that problem by checking if OS_TIMERS is defined
before comparing it to 0.

This problem only effects IAR since it has a different heap/stack
layout. GCC_ARM and ARM have a dedicated stack region so
the presence of a guard word and stack checking does not cause
problems.

This problem manifested on the NRF51_DK in the pull request
https://github.com/mbedmicro/mbed/pull/2211
as a c_strings test failure on floating point. This is because the
guard word of the main stack overlapped with standard library
data used by sprintf and corrupted it.
2016-07-26 18:05:58 -05:00
Mahadevan Mahesh 5a0ad646a1 The core clock in run mode is 80MHz for K22F
Signed-off-by: Mahadevan Mahesh <Mahesh.Mahadevan@nxp.com>
2016-07-26 13:50:50 -05:00
Martin Kojtal 239f31b437 Merge pull request #2199 from neilt6/rtos-timer-update
[RTOS] Updated RtosTimer to use Callback
2016-07-22 10:17:32 +01:00
Vincent Coubard f10cf7fe16 Merge remote-tracking branch 'mbed-nordic/epr_integration' into nrf52_nrf51_unified_integration 2016-07-21 14:50:37 +01:00
Martin Kojtal dd010097ba Merge pull request #2159 from jeromecoutant/PR_dev_NUCLEO_F207ZG
New STM32 board : NUCLEO_F207ZG
2016-07-21 11:13:33 +01:00
Neil Thiessen 2133dadb63 [RTOS] Fixed missing include in RtosTimer.h
Added missing include for the MBED_DEPRECATED macro.
2016-07-20 16:14:20 -06:00
Neil Thiessen 4d4089e7bc [RTOS] Added deprecated RtosTimer constructor
Reintroduced the original RtosTimer constructor as an additional deprecated constructor for backwards compatibility.
2016-07-20 16:07:12 -06:00
neilt6 511117acdf [RTOS] Updated RtosTimer to use Callback
Updated the RtosTimer class to use Callback in order to be consistent
with the updated Thread class.
2016-07-20 10:51:45 -06:00
Sam Grove 518afae619 Merge pull request #2189 from geky/rtos-sema-default
[rtos] Add default constructor for Semaphore
2016-07-19 17:11:22 -05:00
Sam Grove d89c3c18f9 Merge pull request #2158 from c1728p9/singleton_support
Singleton support
2016-07-19 16:34:20 -05:00
0xc0170 edf015ad92 Merge branch 'master' into release
Conflicts:
	tools/export/uvision4.py
	tools/export/uvision5.py
2016-07-19 08:44:34 +01:00
Christopher Haster 0140dc2e80 Added default constructor for Semaphore
Currently Semaphore can not be instantiated without an explicit count
as a constructor argument. This limits where Semaphores can be declared
and requires explicit initialization in several annoying places, such
as in member variables and SingletonPtr targets.

This adds a default count of 0, which has shown to be the most common
initial value used for semaphores.
2016-07-18 14:51:38 -05:00
Russ Butler 348b32c3c6 Create singleton class and update code to use it
Create the wrapper class SingletonPtr.  This provides a safe way to
declare and use singletons.  This class allows both the lazy
initialization of a singleton, and allows the singleton to be
garbage collected by the linker if it is never referenced.

This patch also updates the HAL to use SingletonPtr when declaring
singleton mutexes.
2016-07-15 14:37:43 -05:00
Russ Butler d4627176da Update ARMCC pre_main to be in C
Switch pre_main from assembly to C for ARMCC.  This function does not
need to be in assembly.
2016-07-15 14:12:37 -05:00
Russ Butler 59e2f9621c Suppress warnings about deprecated __ldrex/strex
Suppress warnings about ARMCC warnings about the __ldrex and __strex
intrinsics to match CMSIS 5.
2016-07-15 11:10:38 -05:00
Vincent Coubard 9745eff74c Merge commit 'ce830296d0297a8da543c24134bf859710fd7698' into epr_integration
Merge the EPR tag and the nordic branch together.
2016-07-13 12:06:02 +01:00
jeromecoutant 9fc0a625bd rtos update to add NUCLEO_F207ZG 2016-07-12 16:38:07 +02:00
0xc0170 9a7591f21f rtos - add mbed lib version requirement 2016-07-08 13:07:38 +01:00
tomoyuki yamanaka 8331d5641c Modify the timing at which mbed_main() is called in IAR compiler.
Renesas modified the timing at which mbed_main() is called in IAR compiler.
Because we fail about test "mbed call before main" in IAR compiler.
2016-07-07 21:58:01 +09:00
Martin Kojtal fe3b80aa68 Merge pull request #2090 from jamike/fix#2089
Fix#2089
2016-07-05 08:36:13 +01:00
Laurent Meunier be889fc49b [NUCLEO_F446ZE] Add RTOS support 2016-07-04 11:47:06 +02:00
Michel JAOUEN b73fd5e6f9 Fix issue #2089 :IAR set_main_stack
i.e test RTOS_4 on NUCLEO_F303K8 with IAR fails.
(rt_stk_check detects that main_stack Magic is corrupted)
2016-07-03 23:47:08 +02:00
ohagendorf fdda915a8a [NUCLEO_F767ZI] adding target to rtos lib 2016-07-01 15:19:30 +02:00
Martin Kojtal d3f95d2f60 Merge pull request #2055 from geky/rtos-deprecate-threads
Marked thread-spawning constructors as deprecated
2016-07-01 13:31:33 +02:00
Sam Grove 26e9aa4b4e Merge pull request #2075 from 0xc0170/fix_#2059
RTOS - fix for main thread id might not be 0x02
2016-06-30 14:29:21 -05:00
svastm 505814147d [NUCLEO_L432KC] Add RTOS support 2016-06-30 15:05:09 +02:00
0xc0170 757d340b0a RTOS - fix for main thread id might not be 0x02
Fixes #2059. As reported, if timer thread is not created, the main thread
id is 0x01. We introduce MAIN_THREAD_ID macro to define the id. We shall consider,
if we keep this in a variable.

I placed MAIN_THREAD_ID in cmsis_os.h as that header is safe to include within RTX, not like
RTX_Config.h or RTX_CM_Lib.h).
2016-06-30 11:15:21 +02:00
Sam Grove dff2c313ea Merge pull request #2053 from AlessandroA/guard_svc_priority_set
RTOS: Only set the SVC priority if uVisor is not present
2016-06-29 14:26:16 -05:00
Sam Grove 76be7c185b Merge pull request #2052 from meriac/master
Add secured page allocator for uVisor
2016-06-29 14:26:03 -05:00
Sam Grove 78cef9c176 Merge pull request #2019 from TomoYamanaka/master_3
Change stack size of main thread for RZ_A1H
2016-06-28 20:46:49 -05:00
Christopher Haster fab672a05e Marked thread-spawning constructors as deprecated
Thread-spawning constructors hide errors and may lead to complex
program state when a thread is declared.

The explicit Thread::start member function should be used to spawn
a thread.
2016-06-28 14:33:22 -05:00
Alessandro Angelino e22280e684 RTOS: Only set the SVC priority if uVisor is not present
uVisor requires the SVCall to have priority 0, while RTX allows it to be
the second lowest priority level in the system (after PendSV).

This commit makes sure that the SVCall priority is not changed if uVisor
is present. The PendSV priority is not affected.
2016-06-28 18:52:11 +01:00
Niklas Hauser 5044c968dd Use the stack top defined in the linkerscript 2016-06-28 16:49:00 +00:00
tomoyuki yamanaka 287aea22ee Update the comments of stack size for main threads
We updated the comments of stack size for main threads.
2016-06-28 11:15:19 +09:00
tomoyuki yamanaka e412f20e70 Change stack size of main thread for RZ_A1H
We changed the stack size of main thread for RZ_A1H.
We changed "OS_MAINSTKSIZE" from 2048 to 4096.
Because stack shortage was found in the automatic test by the CI System .
2016-06-27 20:42:19 +09:00
tomoyuki yamanaka d6624c078a RTX - init sequence (C++ array init) for Cortex-A version
This is an update to RTX kernel for Cortex-A version to allow c++ libc array init to be called after kernel start.
Ref: https://github.com/mbedmicro/mbed/pull/1730
2016-06-27 19:40:22 +09:00
Brian Daniels 93773bad68 Calling mbed_main when using RTX and compiling with IAR 2016-06-23 17:09:38 -05:00
Jaeden Amero 409ecf6be6 Call the pre-start event unprivileged 2016-06-16 17:38:52 +00:00
Vincent Coubard aa19a973cd RTX port for nrf52 based targets. 2016-06-14 22:40:15 +01:00
Vincenzo Frascino f8d7a76128 [BEETLE] Enable RTOS on Beetle
This patch enables RTOS support on Beetle.
It contains:
* Updated Beetle Startup code for ARMCC
* Modified SysTick Driver
* RTOS specific configuration parameters
* RTOS specific test suite enablement

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
2016-06-13 16:21:19 +01:00
Russ Butler d0b7b3b497 Fix duplicate symbols for malloc lock and unlock
When the malloc lock and unlock functions are inside a library they
conflict with the standard libraries weak version of these functions.
This is because of the way weak references are handled by the linker.
This patch renames the lock and unlock functions defined inside RTX
so they do not conflict.  A thunk inside retarget.cpp then calls the
RTX functions.  This problem does not occur with retarget.cpp since
it is always build into an object file rather than a library file.
2016-06-12 18:18:41 +01:00
Russ Butler 3db2c030d2 Only allow one thread on unsafe standard libs
When using a standard library which does not support multi-threading
allow only one thread to be used.  This allows the code to remain
safe.
2016-06-12 18:18:40 +01:00
Russ Butler ba4834dcd0 Fix OS_TCB_SIZE
The define OS_TCB_SIZE does not match the real stack size.  This
leaves the system with less than OS_TASKCNT TCBs and prevents
a single thread configuration.  This updates OS_TCB_SIZE to the
correct value to fix the problem.
2016-06-12 18:18:38 +01:00
Russ Butler 2518eaeaf5 Move main stack to fix stack overflow detection
The main stack ends at the start of the heap.  In some configurations
this causes the guard word to be overwritten when memory is allocated.
This causes an OS error in RTX since it appears that the main stack
overflowed.

This patch moves the main stack to the upper 1/4th of the heap which
prevents the guard word from getting overwritten.
2016-06-12 18:18:32 +01:00
Christopher Haster 70ebb6f16b [rtos] Fixed registers clobbered SVC_Handler in IAR
The rtx SVC_Handler for IAR clobbers r0-r3 despite the number of
arguments. However, in the SVC calls, the __swi function is declared
with fewer arguments. IAR doesn't understand that the other registers are
clobbered and stores variables in r0-r3 when multiple SVCs are
dispatched in a single function.

This bug was noticed in osThreadExit, which hard-faults on IAR,
preventing any threads from exiting.
2016-06-11 19:34:20 -05:00
Sam Grove 0b3556db2f Merge pull request #1898 from pan-/fix_nrf51_stack
Adjust the main stack of nrf51 targets to the call stack of thesoftdevice.
2016-06-10 18:00:45 +01:00
Jaeden Amero 829ca3333b RTX: Actively switch to the idle thread
Prevent a switch to a NULL target thread by setting the new task to run
to be the idle task. Otherwise, we get nasty usage fault because we
would be returning from the rt_sys_init SVC with a PSP of 0x20.
2016-06-10 16:56:17 +01:00
Jaeden Amero 58336594ac RTX: Run unprivileged if uVisor is present
As priviliged threading is incompatible with uVisor
2016-06-10 16:56:17 +01:00
Jaeden Amero 43e595aec3 Wrap software_init_hook
Wrap software_init_hook so that it can be used or extended from outside the
RTOS. This is desirable so that code can be added to the software_init_hook
without making the RTOS depend on new features or libraries.
2016-06-10 16:56:17 +01:00
Niklas Hauser 61166870ed RTX: Add context to osThreadCreate/Terminate 2016-06-10 16:56:16 +01:00
Niklas Hauser 259bd28c45 RTX: Add pointer to context to task structure 2016-06-10 16:56:16 +01:00
Jaeden Amero 4cdc4a7b45 Add OsEventObserver
Add the OsEventObserver mechanism. A client interested in receiving
notifications on certain OS events can register to receive notifications
with osRegisterForOsEvents. This is useful for clients like the secure
memory allocator, which observes thread switching events in order to swap
in and out different memory allocator objects.
2016-06-10 16:56:16 +01:00
Vincent Coubard 06e2139e6a Adjust the main stack of nrf51 targets to the call stack of the
softdevice.

The call stack of the soft device can be 0x600 (1536) bytes long, by
adjusting the stack to a value of 2048 bytes, their is enough room for
the softdevice and RTX kernel to live together in the main stack.

Random issues due to stack overflow were visible with the previous value.
2016-06-10 14:57:51 +01:00
0xc0170 f3f4430b8f RTOS - add config mbed_lib.json file
Defines that rtos is present, this resolves in the macro:
"MBED_CONF_RTOS_PRESENT=1"
2016-06-08 18:41:29 +01:00
Vincent Coubard e46b659799 Merge branch 'master' of https://github.com/mbedmicro/mbed into nrf51_port 2016-06-05 20:46:42 +01:00
Vincent Coubard 000e04d768 RTOS port for nrf51.
The NRF51 doesn't have a systick. When the MCU doesn't have a systick, the
HAL has to export several functions which will be use by the kernel to
manage the tick:

  * os_tick_init provides the initialization function for the alternative
    hardware timer.
  * os_tick_val returns the current value of the alternative hardware timer.
  * os_tick_ovf returns the overflow flag of the alternative hardware timer.
  * os_tick_irqack is an interrupt acknowledge function that is called to
    confirm the alternative hardware timer interrupt.

The HAL should also call OS_Tick_Handler needs to be called as the
hardware timer interrupt function.

In the case of the NRF51, two RTCs are available:
  * RTC0: reserved for soft device
  * RTC1: used by us_ticker.

RTC1 is a 4 channels timers, channel 0 is used for us_ticker, and
in this port channel 1 is used for tick generation.

Implementation notes:
  * RTC1_IRQHandler: has to be written in assembly otherwise a stack
    overflow will occur because the function OS_Tick_Handler never
    returns. This function is called when RTC1 channel IRQ is triggered.
  * tick generation has been optimised for a tick with a duration of
    1000us.
  * us_ticker can still be compiled and used without RTX enabled.

More information about alternative timer as RTX Kernel Timer:
https://www.keil.com/pack/doc/CMSIS/RTX/html/_timer_tick.html
2016-06-03 10:13:10 +01:00
Martin Kojtal f68cdcb695 Merge pull request #1802 from theotherjimmy/callback-rtos
Adopt Callback class in rtos Threads
2016-06-02 17:08:59 +01:00
Martin Kojtal 7643399c1d Merge pull request #1835 from stevew817/feature/rtos_support_efm32
[Silicon Labs] Disable RTOS support for EFM32ZG
2016-06-02 11:51:00 +01:00
Steven Cooreman 0015943bd9 Remove RTOS support for EFM32 Zero Gecko because of too little RAM 2016-06-02 10:06:26 +02:00
Martin Kojtal 5df96fbec3 Merge pull request #1815 from stevew817/feature/rtos_support_efm32
[Silicon Labs] Provide RTOS support for EFM32 targets
2016-06-02 08:08:20 +01:00
Christopher Haster e079c2e0e9 Added support for Callback to Thread lifetime 2016-06-01 12:11:05 -05:00
Martin Kojtal 02b0267143 Merge pull request #1765 from c1728p9/thread_safe
Thread safe
2016-06-01 18:01:18 +01:00
Martin Kojtal 2db84dadcb Merge pull request #1785 from geky/thread-lifetime
Add lifetime management to threads
2016-06-01 11:42:28 +01:00
Christopher Haster 0180125293 Adopt Callback class in rtos Threads 2016-05-31 20:39:39 -05:00
Russ Butler 5b23d9b268 Remove assembler directives
Remove the assembler directives from the inline assembly in
RTX_CM_lib.h since these can have unintended side effects in
the surrounding C code.
2016-05-31 16:17:50 -05:00
Russ Butler 793f9c566a Add partial thread safety to GCC
Add lock functions so that malloc and environment variable access are
thread safe.  Add the compiler option "-o thread-safe" to use the full
version of newlib which is thread safe.

Note that this patch does NOT make file access thread safe.
2016-05-31 16:16:59 -05:00
Russ Butler bd216c37cb Make the IAR standard library thread safe
Add the locks and flags necessary to make the IAR standard library
thread safe.  These changes consist of:
-Add compiler flag "--guard_calls" to ensure C++ function-static
    variables with dynamic initializers are initialized in a
    thread safe manner
-Add the linker flag "--threaded_lib" so the thread safe version of
    the standard library is used
-Implement mutex functions required for IAR thread safety
-Create a set of stub functions in retarget.c for when the rtos is not present
2016-05-31 14:41:21 -05:00
Steven Cooreman cc34a7bada Provide initial RTOS support for EFM32 targets 2016-05-30 14:14:36 +02:00
Neil Thiessen 0fd3721d2e [RTOS] Fixed online compiler macro warnings
Added an #ifndef directive to the __MBED_CMSIS_RTOS_CM and __CMSIS_RTOS macro definitions in order to prevent "Incompatible redefinition of macro" warnings from the online compiler.
2016-05-27 10:10:52 -06:00
geky 57bc433986 Fixed NULL usage on non-pointer member in thread
per @theotherjimmy
2016-05-26 16:24:32 -05:00
Christopher Haster 1ab7d73805 Added Thread::start and Thread::join for managing lifetime of threads
- Allows threads to started separately from when they are declared,
  avoiding the need to dynamically allocate threads at runtime.
- Allows multiple threads to join without forceful termination. Allowing
  threads to synchronize on cleanup.
2016-05-25 17:23:18 -05:00
0xc0170 327bd41632 Merge branch 'master' of https://github.com/neilt6/mbed into neilt6-master 2016-05-23 10:41:32 +01:00
0xc0170 daf5c9ee86 RTX - ARM7 init sequence update 2016-05-23 09:50:24 +01:00
0xc0170 607c9d119b RTX - ARMCC pre_main - pop fix 2016-05-23 09:50:16 +01:00
0xc0170 8420e13246 RTX - pre_main for GCC C function 2016-05-23 09:50:11 +01:00
Martin Kojtal 230be00443 ARMCC ulib - initalize RTOS before the standard library C++ init
Initialize the RTOS before initializing the standard library.  This
allows C++ constructors to be called in a well defined thread context.
2016-05-23 09:50:05 +01:00
Russ Butler 87176751a8 IAR - Initialize RTOS before standard library
Initialize the RTOS before initializing the standard library.  This
allows C++ constructors to be called in a well defined thread context.
2016-05-23 09:50:00 +01:00
Russ Butler a5ace8dea0 GCC - Initialize RTOS before standard library
Initialize the RTOS before initializing the standard library.  This
allows C++ constructors to be called in a well defined thread context.
2016-05-23 09:49:55 +01:00
Russ Butler ac727e270e ARMCC - Initialize RTOS before standard library
Initialize the RTOS before initializing the standard library.  This
allows C++ constructors to be called in a well defined thread context.
2016-05-23 09:49:48 +01:00
Russ Butler a0fd520408 Remove dead CodeSourcery init code
The CodeSourcery compiler is not longer supported.  This patch removes
the CodeSourcery init code in RTX_CM_lib.h.
2016-05-23 09:49:44 +01:00
Mihail Stoyanov d9734e5a32 Simplify layout:
* /libraries/mbed -> /hal
* /libraries/rtos -> /rtos
2016-05-23 09:13:59 +01:00