From 000e04d76842a6e928f1086e6650dc4d3b3a8fb2 Mon Sep 17 00:00:00 2001 From: Vincent Coubard Date: Fri, 27 May 2016 09:33:37 +0100 Subject: [PATCH 1/6] 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 --- .../TARGET_MCU_NRF51822/us_ticker.c | 355 +++++++++++++++++- rtos/rtx/TARGET_CORTEX_M/RTX_CM_lib.h | 7 +- rtos/rtx/TARGET_CORTEX_M/RTX_Conf_CM.c | 37 +- 3 files changed, 374 insertions(+), 25 deletions(-) diff --git a/hal/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/us_ticker.c b/hal/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/us_ticker.c index 78f966ab7f9..06e879551b5 100644 --- a/hal/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/us_ticker.c +++ b/hal/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/us_ticker.c @@ -55,6 +55,34 @@ static bool us_ticker_inited = false; static volatile uint32_t overflowCount; /**< The number of times the 24-bit RTC counter has overflowed. */ static volatile bool us_ticker_callbackPending = false; static uint32_t us_ticker_callbackTimestamp; +static bool os_tick_started = false; /**< flag indicating if the os_tick has started */ +/** + * The value previously set in the capture compare register of channel 1 + */ +static uint32_t previous_tick_cc_value = 0; + +/* + RTX provide the following definitions which are used by the tick code: + * os_trv: The number (minus 1) of clock cycle between two tick. + * os_clockrate: Time duration between two ticks (in us). + * OS_Tick_Handler: The function which handle a tick event. + This function is special because it never returns. + Those definitions are used by the code which handle the os tick. + To allow compilation of us_ticker programs without RTOS, those symbols are + exported from this module as weak ones. + */ +#if defined (__CC_ARM) /* ARMCC Compiler */ +__attribute__((weak)) uint32_t const os_trv; +__attribute__((weak)) uint32_t const os_clockrate; +__attribute__((weak)) void OS_Tick_Handler() { } +#elif defined (__GNUC__) /* GNU Compiler */ +__attribute__((weak)) uint32_t const os_trv = 31; +__attribute__((weak)) uint32_t const os_clockrate = 1000; +__attribute__((noreturn, naked, weak)) void OS_Tick_Handler() { } +#else +#error Compiler not supported. +#error Weak definitions of os_trv, os_clockrate and OS_Tick_Handler should be provided. +#endif static inline void rtc1_enableCompareInterrupt(void) { @@ -110,15 +138,22 @@ static void rtc1_start() */ void rtc1_stop(void) { - NVIC_DisableIRQ(RTC1_IRQn); - rtc1_disableCompareInterrupt(); - rtc1_disableOverflowInterrupt(); + // If the os tick has been started, RTC1 shouldn't be stopped + // In that case, us ticker and overflow interrupt are disabled. + if (os_tick_started) { + rtc1_disableCompareInterrupt(); + rtc1_disableOverflowInterrupt(); + } else { + NVIC_DisableIRQ(RTC1_IRQn); + rtc1_disableCompareInterrupt(); + rtc1_disableOverflowInterrupt(); - NRF_RTC1->TASKS_STOP = 1; - nrf_delay_us(MAX_RTC_TASKS_DELAY); + NRF_RTC1->TASKS_STOP = 1; + nrf_delay_us(MAX_RTC_TASKS_DELAY); - NRF_RTC1->TASKS_CLEAR = 1; - nrf_delay_us(MAX_RTC_TASKS_DELAY); + NRF_RTC1->TASKS_CLEAR = 1; + nrf_delay_us(MAX_RTC_TASKS_DELAY); + } } /** @@ -148,11 +183,11 @@ static inline uint32_t rtc1_getCounter(void) } /** - * @brief Function for handling the RTC1 interrupt. + * @brief Function for handling the RTC1 interrupt for us ticker (capture compare channel 0 and overflow). * * @details Checks for timeouts, and executes timeout handlers for expired timers. */ -void RTC1_IRQHandler(void) +void us_ticker_handler(void) { if (NRF_RTC1->EVENTS_OVRFLW) { overflowCount++; @@ -271,3 +306,305 @@ void us_ticker_clear_interrupt(void) NRF_RTC1->EVENTS_OVRFLW = 0; NRF_RTC1->EVENTS_COMPARE[0] = 0; } + + +#if defined (__CC_ARM) /* ARMCC Compiler */ + +__asm void RTC1_IRQHandler(void) +{ + IMPORT OS_Tick_Handler + IMPORT us_ticker_handler + + /** + * Chanel 1 of RTC1 is used by RTX as a systick. + * If the compare event on channel 1 is set, then branch to OS_Tick_Handler. + * Otherwise, just execute us_ticker_handler. + * This function has to be written in assembly and tagged as naked because OS_Tick_Handler + * will never return. + * A c function would put lr on the stack before calling OS_Tick_Handler and this value + * would never been dequeued. + * + * \code + * void RTC1_IRQHandler(void) { + if(NRF_RTC1->EVENTS_COMPARE[1]) { + // never return... + OS_Tick_Handler(); + } else { + us_ticker_handler(); + } + } + * \endcode + */ + ldr r0,=0x40011144 + ldr r1, [r0, #0] + cmp r1, #0 + beq US_TICKER_HANDLER + bl OS_Tick_Handler +US_TICKER_HANDLER + push {r3, lr} + bl us_ticker_handler + pop {r3, pc} + nop /* padding */ +} + +#elif defined (__GNUC__) /* GNU Compiler */ + +__attribute__((naked)) void RTC1_IRQHandler(void) +{ + /** + * Chanel 1 of RTC1 is used by RTX as a systick. + * If the compare event on channel 1 is set, then branch to OS_Tick_Handler. + * Otherwise, just execute us_ticker_handler. + * This function has to be written in assembly and tagged as naked because OS_Tick_Handler + * will never return. + * A c function would put lr on the stack before calling OS_Tick_Handler and this value + * would never been dequeued. + * + * \code + * void RTC1_IRQHandler(void) { + if(NRF_RTC1->EVENTS_COMPARE[1]) { + // never return... + OS_Tick_Handler(); + } else { + us_ticker_handler(); + } + } + * \endcode + */ + __asm__ ( + "ldr r0,=0x40011144\n" + "ldr r1, [r0, #0]\n" + "cmp r1, #0\n" + "beq US_TICKER_HANDLER\n" + "bl OS_Tick_Handler\n" + "US_TICKER_HANDLER:\n" + "push {r3, lr}\n" + "bl us_ticker_handler\n" + "pop {r3, pc}\n" + "nop" + ); +} + +#else + +#error Compiler not supported. +#error Provide a definition of RTC1_IRQHandler. + +/* + * Chanel 1 of RTC1 is used by RTX as a systick. + * If the compare event on channel 1 is set, then branch to OS_Tick_Handler. + * Otherwise, just execute us_ticker_handler. + * This function has to be written in assembly and tagged as naked because OS_Tick_Handler + * will never return. + * A c function would put lr on the stack before calling OS_Tick_Handler and this value + * will never been dequeued. After a certain time a stack overflow will happen. + * + * \code + * void RTC1_IRQHandler(void) { + if(NRF_RTC1->EVENTS_COMPARE[1]) { + // never return... + OS_Tick_Handler(); + } else { + us_ticker_handler(); + } + } + * \endcode + */ + +#endif + +/** + * Return the next number of clock cycle needed for the next tick. + * @note This function has been carrefuly optimized for a systick occuring every 1000us. + */ +static uint32_t get_next_tick_cc_delta() { + uint32_t delta = 0; + + if (os_clockrate != 1000) { + // In RTX, by default SYSTICK is is used. + // A tick event is generated every os_trv + 1 clock cycles of the system timer. + delta = os_trv + 1; + } else { + // If the clockrate is set to 1000us then 1000 tick should happen every second. + // Unfortunatelly, when clockrate is set to 1000, os_trv is equal to 31. + // If (os_trv + 1) is used as the delta value between two ticks, 1000 ticks will be + // generated in 32000 clock cycle instead of 32768 clock cycles. + // As a result, if a user schedule an OS timer to start in 100s, the timer will start + // instead after 97.656s + // The code below fix this issue, a clock rate of 1000s will generate 1000 ticks in 32768 + // clock cycles. + // The strategy is simple, for 1000 ticks: + // * 768 ticks will occur 33 clock cycles after the previous tick + // * 232 ticks will occur 32 clock cycles after the previous tick + // By default every delta is equal to 33. + // Every five ticks (20%, 200 delta in one second), the delta is equal to 32 + // The remaining (32) deltas equal to 32 are distributed using primes numbers. + static uint32_t counter = 0; + if ((counter % 5) == 0 || (counter % 31) == 0 || (counter % 139) == 0 || (counter == 503)) { + delta = 32; + } else { + delta = 33; + } + ++counter; + if (counter == 1000) { + counter = 0; + } + } + return delta; +} + +static inline void clear_tick_interrupt() { + NRF_RTC1->EVENTS_COMPARE[1] = 0; + NRF_RTC1->EVTENCLR = (1 << 17); +} + +/** + * Indicate if a value is included in a range which can be wrapped. + * @param begin start of the range + * @param end end of the range + * @param val value to check + * @return true if the value is included in the range and false otherwise. + */ +static inline bool is_in_wrapped_range(uint32_t begin, uint32_t end, uint32_t val) { + // regular case, begin < end + // return true if begin <= val < end + if (begin < end) { + if (begin <= val && val < end) { + return false; + } else { + return true; + } + } else { + // In this case end < begin because it has wrap around the limits + // return false if end < val < begin + if (end < val && val < begin) { + return false; + } else { + return true; + } + } + +} + +/** + * Register the next tick. + */ +static void register_next_tick() { + previous_tick_cc_value = NRF_RTC1->CC[1]; + uint32_t delta = get_next_tick_cc_delta(); + uint32_t new_compare_value = (previous_tick_cc_value + delta) & MAX_RTC_COUNTER_VAL; + + // Disable irq directly for few cycles, + // Validation of the new CC value against the COUNTER, + // Setting the new CC value and enabling CC IRQ should be an atomic operation + // Otherwise, there is a possibility to set an invalid CC value because + // the RTC1 keeps running. + // This code is very short 20-38 cycles in the worst case, it shouldn't + // disturb softdevice. + __disable_irq(); + uint32_t current_counter = NRF_RTC1->COUNTER; + + // If an overflow occur, set the next tick in COUNTER + delta clock cycles + if (is_in_wrapped_range(previous_tick_cc_value, new_compare_value, current_counter) == false) { + new_compare_value = current_counter + delta; + } + NRF_RTC1->CC[1] = new_compare_value; + + // set the interrupt of CC channel 1 and reenable IRQs + NRF_RTC1->INTENSET = RTC_INTENSET_COMPARE1_Msk; + __enable_irq(); +} + +/** + * Initialize alternative hardware timer as RTX kernel timer + * This function is directly called by RTX. + * @note this function shouldn't be called directly. + * @return IRQ number of the alternative hardware timer + */ +int os_tick_init (void) +{ + NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos); + NRF_CLOCK->EVENTS_LFCLKSTARTED = 0; + NRF_CLOCK->TASKS_LFCLKSTART = 1; + + while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0) { + // wait for the low frequency clock start + } + + NRF_RTC1->PRESCALER = 0; /* for no pre-scaling. */ + + NVIC_SetPriority(RTC1_IRQn, RTC1_IRQ_PRI); + NVIC_ClearPendingIRQ(RTC1_IRQn); + NVIC_EnableIRQ(RTC1_IRQn); + + NRF_RTC1->TASKS_START = 1; + nrf_delay_us(MAX_RTC_TASKS_DELAY); + + NRF_RTC1->CC[1] = 0; + clear_tick_interrupt(); + register_next_tick(); + + os_tick_started = true; + + return RTC1_IRQn; +} + +/** + * Acknowledge the tick interrupt. + * This function is called by the function OS_Tick_Handler of RTX. + * @note this function shouldn't be called directly. + */ +void os_tick_irqack(void) +{ + clear_tick_interrupt(); + register_next_tick(); +} + +/** + * Returns the overflow flag of the alternative hardware timer. + * @note This function is exposed by RTX kernel. + * @return 1 if the timer has overflowed and 0 otherwise. + */ +uint32_t os_tick_ovf(void) { + uint32_t current_counter = NRF_RTC1->COUNTER; + uint32_t next_tick_cc_value = NRF_RTC1->CC[1]; + + return is_in_wrapped_range(previous_tick_cc_value, next_tick_cc_value, current_counter) ? 0 : 1; +} + +/** + * Return the value of the alternative hardware timer. + * @note The documentation is not very clear about what is expected as a result, + * is it an ascending counter, a descending one ? + * None of this is specified. + * The default systick is a descending counter and this function return values in + * descending order, even if the internal counter used is an ascending one. + * @return the value of the alternative hardware timer. + */ +uint32_t os_tick_val(void) { + uint32_t current_counter = NRF_RTC1->COUNTER; + uint32_t next_tick_cc_value = NRF_RTC1->CC[1]; + + // do not use os_tick_ovf because its counter value can be different + if(is_in_wrapped_range(previous_tick_cc_value, next_tick_cc_value, current_counter)) { + if (next_tick_cc_value > previous_tick_cc_value) { + return next_tick_cc_value - current_counter; + } else if(current_counter <= next_tick_cc_value) { + return next_tick_cc_value - current_counter; + } else { + return next_tick_cc_value + (MAX_RTC_COUNTER_VAL - current_counter); + } + } else { + // use (os_trv + 1) has the base step, can be totally inacurate ... + uint32_t clock_cycles_by_tick = os_trv + 1; + + // if current counter has wrap arround, add the limit to it. + if (current_counter < next_tick_cc_value) { + current_counter = current_counter + MAX_RTC_COUNTER_VAL; + } + + return clock_cycles_by_tick - ((current_counter - next_tick_cc_value) % clock_cycles_by_tick); + } + + return 0; +} diff --git a/rtos/rtx/TARGET_CORTEX_M/RTX_CM_lib.h b/rtos/rtx/TARGET_CORTEX_M/RTX_CM_lib.h index f642ff43c1a..6a04fbbfcdd 100755 --- a/rtos/rtx/TARGET_CORTEX_M/RTX_CM_lib.h +++ b/rtos/rtx/TARGET_CORTEX_M/RTX_CM_lib.h @@ -178,7 +178,7 @@ osMessageQId osMessageQId_osTimerMessageQ; #endif /* Legacy RTX User Timers not used */ -uint32_t os_tmr = 0U; +uint32_t os_tmr = 0U; uint32_t const *m_tmr = NULL; uint16_t const mp_tmr_size = 0U; @@ -420,6 +420,11 @@ osThreadDef_t os_thread_def_main = {(os_pthread)pre_main, osPriorityNormal, 1U, #elif defined(TARGET_STM32L152RC) #define INITIAL_SP (0x20008000UL) +#elif defined(TARGET_MCU_NORDIC_32K) +#define INITIAL_SP (0x20008000UL) + +#elif defined(TARGET_MCU_NORDIC_16K) +#define INITIAL_SP (0x20004000UL) #else #error "no target defined" diff --git a/rtos/rtx/TARGET_CORTEX_M/RTX_Conf_CM.c b/rtos/rtx/TARGET_CORTEX_M/RTX_Conf_CM.c index 6a24d7cb02e..b5dfb09a859 100755 --- a/rtos/rtx/TARGET_CORTEX_M/RTX_Conf_CM.c +++ b/rtos/rtx/TARGET_CORTEX_M/RTX_Conf_CM.c @@ -57,7 +57,7 @@ || defined(TARGET_LPC812) || defined(TARGET_KL25Z) || defined(TARGET_KL26Z) || defined(TARGET_KL27Z) || defined(TARGET_KL05Z) || defined(TARGET_STM32F100RB) || defined(TARGET_STM32F051R8) \ || defined(TARGET_STM32F103RB) || defined(TARGET_LPC824) || defined(TARGET_STM32F302R8) || defined(TARGET_STM32F334R8) || defined(TARGET_STM32F334C8) \ || defined(TARGET_STM32L031K6) || defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8) || defined(TARGET_STM32L073RZ) || defined(TARGET_STM32F072RB) || defined(TARGET_STM32F091RC) || defined(TARGET_NZ32_SC151) \ - || defined(TARGET_SSCI824) || defined(TARGET_STM32F030R8) || defined(TARGET_STM32F070RB) + || defined(TARGET_SSCI824) || defined(TARGET_STM32F030R8) || defined(TARGET_STM32F070RB) || defined(TARGET_MCU_NRF51822) # define OS_TASKCNT 6 # else # error "no target defined" @@ -91,7 +91,7 @@ || defined(TARGET_STM32F103RB) || defined(TARGET_LPC824) || defined(TARGET_STM32F302R8) || defined(TARGET_STM32F072RB) || defined(TARGET_STM32F091RC) || defined(TARGET_NZ32_SC151) \ || defined(TARGET_SSCI824) || defined(TARGET_STM32F030R8) || defined(TARGET_STM32F070RB) # define OS_MAINSTKSIZE 128 -# elif defined(TARGET_STM32F334R8) || defined(TARGET_STM32F303RE) || defined(TARGET_STM32F303K8) || defined(TARGET_STM32F334C8) || defined(TARGET_STM32L031K6) || defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8) || defined(TARGET_STM32L073RZ) +# elif defined(TARGET_STM32F334R8) || defined(TARGET_STM32F303RE) || defined(TARGET_STM32F303K8) || defined(TARGET_STM32F334C8) || defined(TARGET_STM32L031K6) || defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8) || defined(TARGET_STM32L073RZ) || defined(TARGET_MCU_NRF51822) # define OS_MAINSTKSIZE 112 # else # error "no target defined" @@ -105,7 +105,7 @@ #ifndef OS_PRIVCNT #define OS_PRIVCNT 0 #endif - + // Total stack size [bytes] for threads with user-provided stack size <0-1048576:8><#/4> // Defines the combined stack size for threads with user-provided stack size. // Default: 0 @@ -120,16 +120,16 @@ #ifndef OS_STKCHECK #define OS_STKCHECK 1 #endif - + // Stack usage watermark // Initialize thread stack with watermark pattern for analyzing stack usage (current/maximum) in System and Thread Viewer. // Enabling this option increases significantly the execution time of osThreadCreate. #ifndef OS_STKINIT #define OS_STKINIT 0 #endif - -// Processor mode for thread execution -// <0=> Unprivileged mode + +// Processor mode for thread execution +// <0=> Unprivileged mode // <1=> Privileged mode // Default: Privileged mode #ifndef OS_RUNPRIV @@ -137,19 +137,23 @@ #endif // - + // RTX Kernel Timer Tick Configuration // ====================================== // Use Cortex-M SysTick timer as RTX Kernel Timer -// Cortex-M processors provide in most cases a SysTick timer that can be used as +// Cortex-M processors provide in most cases a SysTick timer that can be used as // as time-base for RTX. #ifndef OS_SYSTICK - #define OS_SYSTICK 1 +# if defined(TARGET_MCU_NRF51822) +# define OS_SYSTICK 0 +# else +# define OS_SYSTICK 1 +# endif #endif // // RTOS Kernel Timer input clock frequency [Hz] <1-1000000000> -// Defines the input frequency of the RTOS Kernel Timer. -// When the Cortex-M SysTick timer is used, the input clock +// Defines the input frequency of the RTOS Kernel Timer. +// When the Cortex-M SysTick timer is used, the input clock // is on most systems identical with the core clock. #ifndef OS_CLOCK # if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) || defined(TARGET_TEENSY3_1) @@ -240,11 +244,14 @@ #elif defined(TARGET_STM32L152RC) # define OS_CLOCK 24000000 +#elif defined(TARGET_MCU_NRF51822) +# define OS_CLOCK 32768 + # else # error "no target defined" # endif #endif - + // RTX Timer tick interval value [us] <1-1000000> // The RTX Timer tick interval value is used to calculate timeout values. // When the Cortex-M SysTick timer is enabled, the value also configures the SysTick timer. @@ -292,14 +299,14 @@ #ifndef OS_TIMERPRIO #define OS_TIMERPRIO 5 #endif - + // Timer Thread stack size [bytes] <64-4096:8><#/4> // Defines stack size for Timer thread. // Default: 200 #ifndef OS_TIMERSTKSZ #define OS_TIMERSTKSZ 200 #endif - + // Timer Callback Queue size <1-32> // Number of concurrent active timer callback functions. // Default: 4 From c0a6c7c6d4ac25c1e3a73002a678f3493fa43e71 Mon Sep 17 00:00:00 2001 From: Vincent Coubard Date: Sun, 5 Jun 2016 17:56:01 +0100 Subject: [PATCH 2/6] Better generation of heap section. With this change, the heap section occupy the whole space from the end of the bss section to the start of the stack section instead of taking a fixed size in RAM. This change allows applications to make a more efficient use of the RAM available and allows application to be compiled if the space between end of bss and start of stack is less than 2048 bytes. --- .../TARGET_MCU_NORDIC_32K/NRF51822.ld | 6 ++-- .../TARGET_MCU_NRF51_16K_S110/NRF51822.ld | 6 ++-- .../TARGET_MCU_NRF51_16K_S130/NRF51822.ld | 6 ++-- .../TOOLCHAIN_GCC_ARM/startup_NRF51822.S | 28 ++++++------------- 4 files changed, 20 insertions(+), 26 deletions(-) diff --git a/hal/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/TARGET_MCU_NORDIC_32K/NRF51822.ld b/hal/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/TARGET_MCU_NORDIC_32K/NRF51822.ld index 0b9c664fc41..913b2108474 100644 --- a/hal/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/TARGET_MCU_NORDIC_32K/NRF51822.ld +++ b/hal/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/TARGET_MCU_NORDIC_32K/NRF51822.ld @@ -124,18 +124,20 @@ SECTIONS __bss_end__ = .; } > RAM - .heap (COPY): + .heap (NOLOAD): { __end__ = .; end = __end__; + __HeapBase = .; *(.heap*) + . = ORIGIN(RAM) + LENGTH(RAM) - Stack_Size; __HeapLimit = .; } > RAM /* .stack_dummy section doesn't contains any symbols. It is only * used for linker to calculate size of stack sections, and assign * values to stack symbols later */ - .stack_dummy (COPY): + .stack_dummy (NOLOAD): { *(.stack*) } > RAM diff --git a/hal/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S110/NRF51822.ld b/hal/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S110/NRF51822.ld index cb472e56404..d0ed81d84e7 100644 --- a/hal/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S110/NRF51822.ld +++ b/hal/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S110/NRF51822.ld @@ -124,18 +124,20 @@ SECTIONS __bss_end__ = .; } > RAM - .heap (COPY): + .heap (NOLOAD): { __end__ = .; end = __end__; + __HeapBase = .; *(.heap*) + . = ORIGIN(RAM) + LENGTH(RAM) - Stack_Size; __HeapLimit = .; } > RAM /* .stack_dummy section doesn't contains any symbols. It is only * used for linker to calculate size of stack sections, and assign * values to stack symbols later */ - .stack_dummy (COPY): + .stack_dummy (NOLOAD): { *(.stack*) } > RAM diff --git a/hal/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S130/NRF51822.ld b/hal/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S130/NRF51822.ld index c334dbb3cd8..237ab159854 100644 --- a/hal/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S130/NRF51822.ld +++ b/hal/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/TARGET_MCU_NRF51_16K_S130/NRF51822.ld @@ -124,18 +124,20 @@ SECTIONS __bss_end__ = .; } > RAM - .heap (COPY): + .heap (NOLOAD): { __end__ = .; end = __end__; + __HeapBase = .; *(.heap*) + . = ORIGIN(RAM) + LENGTH(RAM) - Stack_Size; __HeapLimit = .; } > RAM /* .stack_dummy section doesn't contains any symbols. It is only * used for linker to calculate size of stack sections, and assign * values to stack symbols later */ - .stack_dummy (COPY): + .stack_dummy (NOLOAD): { *(.stack*) } > RAM diff --git a/hal/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/startup_NRF51822.S b/hal/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/startup_NRF51822.S index e5de3f95fb1..7fb929dd26b 100644 --- a/hal/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/startup_NRF51822.S +++ b/hal/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/startup_NRF51822.S @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 2013, Nordic Semiconductor ASA All rights reserved. @@ -28,8 +28,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* -NOTE: Template files (including this one) are application specific and therefore +/* +NOTE: Template files (including this one) are application specific and therefore expected to be copied into the application project folder prior to its use! */ @@ -43,6 +43,7 @@ expected to be copied into the application project folder prior to its use! #else .equ Stack_Size, 2048 #endif + .globl Stack_Size .globl __StackTop .globl __StackLimit __StackLimit: @@ -53,21 +54,9 @@ __StackTop: .section .heap .align 3 -#ifdef __HEAP_SIZE - .equ Heap_Size, __HEAP_SIZE -#else - .equ Heap_Size, 2048 -#endif .globl __HeapBase .globl __HeapLimit -__HeapBase: - .if Heap_Size - .space Heap_Size - .endif - .size __HeapBase, . - __HeapBase -__HeapLimit: - .size __HeapLimit, . - __HeapLimit - + .section .Vectors .align 2 .globl __Vectors @@ -129,7 +118,7 @@ __Vectors: /* Reset Handler */ .equ NRF_POWER_RAMON_ADDRESS, 0x40000524 - .equ NRF_POWER_RAMON_RAMxON_ONMODE_Msk, 0x3 + .equ NRF_POWER_RAMON_RAMxON_ONMODE_Msk, 0x3 .text .thumb @@ -148,7 +137,7 @@ Reset_Handler: STR R2, [R0] /* Loop to copy data from read only memory to RAM. The ranges - * of copy from/to are specified by following symbols evaluated in + * of copy from/to are specified by following symbols evaluated in * linker script. * __etext: End of code section, i.e., begin of data sections to copy from. * __data_start__/__data_end__: RAM address range that data should be @@ -167,7 +156,7 @@ Reset_Handler: str r0, [r2,r3] bgt .LC1 .LC0: - + LDR R0, =SystemInit BLX R0 LDR R0, =_start @@ -259,4 +248,3 @@ Default_Handler: .end - From 39a459f4b6188392a6abcd396134a896844de599 Mon Sep 17 00:00:00 2001 From: Vincent Coubard Date: Sun, 5 Jun 2016 18:32:47 +0100 Subject: [PATCH 3/6] Port RTOS tests to nrf51. Provide fixed stack stize for nrf51 targets. Disable memory allocation for stdout otherwise tests fail on mkit target. --- libraries/tests/rtos/mbed/basic/main.cpp | 4 ++++ libraries/tests/rtos/mbed/isr/main.cpp | 4 ++++ libraries/tests/rtos/mbed/mail/main.cpp | 4 ++++ libraries/tests/rtos/mbed/mutex/main.cpp | 12 ++++++++---- libraries/tests/rtos/mbed/queue/main.cpp | 4 ++++ libraries/tests/rtos/mbed/semaphore/main.cpp | 12 ++++++++---- libraries/tests/rtos/mbed/signals/main.cpp | 4 ++++ libraries/tests/rtos/mbed/timer/main.cpp | 2 ++ 8 files changed, 38 insertions(+), 8 deletions(-) diff --git a/libraries/tests/rtos/mbed/basic/main.cpp b/libraries/tests/rtos/mbed/basic/main.cpp index 6f0f23597bc..cf7c64c94e9 100644 --- a/libraries/tests/rtos/mbed/basic/main.cpp +++ b/libraries/tests/rtos/mbed/basic/main.cpp @@ -13,6 +13,8 @@ #define STACK_SIZE DEFAULT_STACK_SIZE/2 #elif (defined(TARGET_STM32F030R8)) && defined(TOOLCHAIN_IAR) #define STACK_SIZE DEFAULT_STACK_SIZE/2 +#elif defined(TARGET_MCU_NRF51822) +#define STACK_SIZE 512 #else #define STACK_SIZE DEFAULT_STACK_SIZE #endif @@ -34,6 +36,8 @@ void led2_thread(void const *argument) { } int main() { + setbuf(stdout, NULL); + MBED_HOSTTEST_TIMEOUT(15); MBED_HOSTTEST_SELECT(wait_us_auto); MBED_HOSTTEST_DESCRIPTION(Basic thread); diff --git a/libraries/tests/rtos/mbed/isr/main.cpp b/libraries/tests/rtos/mbed/isr/main.cpp index 346152ec8e9..ba01a96df7f 100644 --- a/libraries/tests/rtos/mbed/isr/main.cpp +++ b/libraries/tests/rtos/mbed/isr/main.cpp @@ -16,6 +16,8 @@ #define STACK_SIZE DEFAULT_STACK_SIZE/4 #elif (defined(TARGET_STM32F030R8)) && defined(TOOLCHAIN_IAR) #define STACK_SIZE DEFAULT_STACK_SIZE/2 +#elif defined(TARGET_MCU_NRF51822) + #define STACK_SIZE 512 #else #define STACK_SIZE DEFAULT_STACK_SIZE #endif @@ -38,6 +40,8 @@ void queue_thread(void const *argument) { } int main (void) { + setbuf(stdout, NULL); + MBED_HOSTTEST_TIMEOUT(20); MBED_HOSTTEST_SELECT(default_auto); MBED_HOSTTEST_DESCRIPTION(ISR (Queue)); diff --git a/libraries/tests/rtos/mbed/mail/main.cpp b/libraries/tests/rtos/mbed/mail/main.cpp index 35d02fa70d7..2ef06c092da 100644 --- a/libraries/tests/rtos/mbed/mail/main.cpp +++ b/libraries/tests/rtos/mbed/mail/main.cpp @@ -24,6 +24,8 @@ typedef struct { #define STACK_SIZE DEFAULT_STACK_SIZE/2 #elif (defined(TARGET_STM32F030R8)) && defined(TOOLCHAIN_IAR) #define STACK_SIZE DEFAULT_STACK_SIZE/2 +#elif defined(TARGET_MCU_NRF51822) + #define STACK_SIZE 512 #else #define STACK_SIZE DEFAULT_STACK_SIZE #endif @@ -44,6 +46,8 @@ void send_thread (void const *argument) { } int main (void) { + setbuf(stdout, NULL); + MBED_HOSTTEST_TIMEOUT(20); MBED_HOSTTEST_SELECT(default_auto); MBED_HOSTTEST_DESCRIPTION(Mail messaging); diff --git a/libraries/tests/rtos/mbed/mutex/main.cpp b/libraries/tests/rtos/mbed/mutex/main.cpp index 17d99867ce5..fa863ce28fd 100644 --- a/libraries/tests/rtos/mbed/mutex/main.cpp +++ b/libraries/tests/rtos/mbed/mutex/main.cpp @@ -17,15 +17,17 @@ #elif defined(TARGET_STM32F334R8) && defined(TOOLCHAIN_IAR) #define STACK_SIZE DEFAULT_STACK_SIZE/4 #elif defined(TARGET_STM32F030R8) && defined(TOOLCHAIN_IAR) - #define STACK_SIZE DEFAULT_STACK_SIZE/4 + #define STACK_SIZE DEFAULT_STACK_SIZE/4 #elif defined(TARGET_STM32F070RB) && defined(TOOLCHAIN_IAR) - #define STACK_SIZE DEFAULT_STACK_SIZE/2 + #define STACK_SIZE DEFAULT_STACK_SIZE/2 #elif defined(TARGET_STM32F072RB) && defined(TOOLCHAIN_IAR) - #define STACK_SIZE DEFAULT_STACK_SIZE/2 + #define STACK_SIZE DEFAULT_STACK_SIZE/2 #elif defined(TARGET_STM32F302R8) && defined(TOOLCHAIN_IAR) - #define STACK_SIZE DEFAULT_STACK_SIZE/2 + #define STACK_SIZE DEFAULT_STACK_SIZE/2 #elif defined(TARGET_STM32F303K8) && defined(TOOLCHAIN_IAR) #define STACK_SIZE DEFAULT_STACK_SIZE/2 +#elif defined(TARGET_MCU_NRF51822) + #define STACK_SIZE 512 #else #define STACK_SIZE DEFAULT_STACK_SIZE #endif @@ -73,6 +75,8 @@ void test_thread(void const *args) { } int main() { + setbuf(stdout, NULL); + MBED_HOSTTEST_TIMEOUT(20); MBED_HOSTTEST_SELECT(default); MBED_HOSTTEST_DESCRIPTION(Mutex resource lock); diff --git a/libraries/tests/rtos/mbed/queue/main.cpp b/libraries/tests/rtos/mbed/queue/main.cpp index f9a5361020a..6491064fcca 100644 --- a/libraries/tests/rtos/mbed/queue/main.cpp +++ b/libraries/tests/rtos/mbed/queue/main.cpp @@ -24,6 +24,8 @@ typedef struct { #define STACK_SIZE DEFAULT_STACK_SIZE/4 #elif (defined(TARGET_STM32F030R8)) && defined(TOOLCHAIN_IAR) #define STACK_SIZE DEFAULT_STACK_SIZE/2 +#elif defined(TARGET_MCU_NRF51822) + #define STACK_SIZE 512 #else #define STACK_SIZE DEFAULT_STACK_SIZE #endif @@ -46,6 +48,8 @@ void send_thread (void const *argument) { } int main (void) { + setbuf(stdout, NULL); + MBED_HOSTTEST_TIMEOUT(20); MBED_HOSTTEST_SELECT(default_auto); MBED_HOSTTEST_DESCRIPTION(Queue messaging); diff --git a/libraries/tests/rtos/mbed/semaphore/main.cpp b/libraries/tests/rtos/mbed/semaphore/main.cpp index 51534c7bbda..9ae9b368ffb 100644 --- a/libraries/tests/rtos/mbed/semaphore/main.cpp +++ b/libraries/tests/rtos/mbed/semaphore/main.cpp @@ -20,15 +20,17 @@ #elif defined(TARGET_STM32F103RB) && defined(TOOLCHAIN_IAR) #define STACK_SIZE DEFAULT_STACK_SIZE/4 #elif defined(TARGET_STM32F030R8) && defined(TOOLCHAIN_IAR) - #define STACK_SIZE DEFAULT_STACK_SIZE/4 + #define STACK_SIZE DEFAULT_STACK_SIZE/4 #elif defined(TARGET_STM32F070RB) && defined(TOOLCHAIN_IAR) - #define STACK_SIZE DEFAULT_STACK_SIZE/2 + #define STACK_SIZE DEFAULT_STACK_SIZE/2 #elif defined(TARGET_STM32F072RB) && defined(TOOLCHAIN_IAR) - #define STACK_SIZE DEFAULT_STACK_SIZE/2 + #define STACK_SIZE DEFAULT_STACK_SIZE/2 #elif defined(TARGET_STM32F302R8) && defined(TOOLCHAIN_IAR) - #define STACK_SIZE DEFAULT_STACK_SIZE/2 + #define STACK_SIZE DEFAULT_STACK_SIZE/2 #elif defined(TARGET_STM32F303K8) && defined(TOOLCHAIN_IAR) #define STACK_SIZE DEFAULT_STACK_SIZE/4 +#elif defined(TARGET_MCU_NRF51822) + #define STACK_SIZE 512 #else #define STACK_SIZE DEFAULT_STACK_SIZE #endif @@ -64,6 +66,8 @@ void test_thread(void const *delay) { } int main (void) { + setbuf(stdout, NULL); + MBED_HOSTTEST_TIMEOUT(20); MBED_HOSTTEST_SELECT(default_auto); MBED_HOSTTEST_DESCRIPTION(Semaphore resource lock); diff --git a/libraries/tests/rtos/mbed/signals/main.cpp b/libraries/tests/rtos/mbed/signals/main.cpp index 00808c34059..d3d54454819 100644 --- a/libraries/tests/rtos/mbed/signals/main.cpp +++ b/libraries/tests/rtos/mbed/signals/main.cpp @@ -15,6 +15,8 @@ #define STACK_SIZE DEFAULT_STACK_SIZE/4 #elif (defined(TARGET_STM32F030R8)) && defined(TOOLCHAIN_IAR) #define STACK_SIZE DEFAULT_STACK_SIZE/2 +#elif defined(TARGET_MCU_NRF51822) + #define STACK_SIZE 512 #else #define STACK_SIZE DEFAULT_STACK_SIZE #endif @@ -32,6 +34,8 @@ void led_thread(void const *argument) { } int main (void) { + setbuf(stdout, NULL); + MBED_HOSTTEST_TIMEOUT(20); MBED_HOSTTEST_SELECT(default_auto); MBED_HOSTTEST_DESCRIPTION(Signals messaging); diff --git a/libraries/tests/rtos/mbed/timer/main.cpp b/libraries/tests/rtos/mbed/timer/main.cpp index 3c33551b0a6..405981a9d26 100644 --- a/libraries/tests/rtos/mbed/timer/main.cpp +++ b/libraries/tests/rtos/mbed/timer/main.cpp @@ -23,6 +23,8 @@ void blink(void const *n) { } int main(void) { + setbuf(stdout, NULL); + MBED_HOSTTEST_TIMEOUT(15); MBED_HOSTTEST_SELECT(wait_us_auto); MBED_HOSTTEST_DESCRIPTION(Timer); From c854d0180f8de2455330ef352bd050166145e8c0 Mon Sep 17 00:00:00 2001 From: Vincent Coubard Date: Sun, 5 Jun 2016 19:55:16 +0100 Subject: [PATCH 4/6] Build RTOS tests on nrf51 based targets. --- workspace_tools/build_travis.py | 6 +++--- workspace_tools/tests.py | 30 +++++++++++++++++------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/workspace_tools/build_travis.py b/workspace_tools/build_travis.py index 233cc1ea0f1..9367f9c2e97 100644 --- a/workspace_tools/build_travis.py +++ b/workspace_tools/build_travis.py @@ -92,10 +92,10 @@ { "target": "LPC4088", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "usb", "fat"] }, { "target": "ARCH_PRO", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "fat"] }, { "target": "LPC1549", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "fat"] }, - { "target": "NRF51822", "toolchains": "GCC_ARM", "libs": ["dsp", "fat"] }, + { "target": "NRF51822", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "fat"] }, { "target": "DELTA_DFCM_NNN40", "toolchains": "GCC_ARM", "libs": ["dsp", "fat"] }, - { "target": "NRF51_DK", "toolchains": "GCC_ARM", "libs": ["dsp", "fat"] }, - { "target": "NRF51_MICROBIT", "toolchains": "GCC_ARM", "libs": ["dsp", "fat"] }, + { "target": "NRF51_DK", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "fat"] }, + { "target": "NRF51_MICROBIT", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "fat"] }, { "target": "EFM32ZG_STK3200", "toolchains": "GCC_ARM", "libs": ["dsp"] }, { "target": "EFM32HG_STK3400", "toolchains": "GCC_ARM", "libs": ["dsp", "usb"] }, diff --git a/workspace_tools/tests.py b/workspace_tools/tests.py index 9a3ef7197c3..2a36ca383e0 100644 --- a/workspace_tools/tests.py +++ b/workspace_tools/tests.py @@ -692,7 +692,7 @@ "RZ_A1H", "VK_RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "DISCO_F469NI", "NUCLEO_F410RB", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_F030R8", "NUCLEO_F070RB", "NUCLEO_L031K6", "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_L073RZ", "NUCLEO_F072RB", "NUCLEO_F091RC", "DISCO_L476VG", "NUCLEO_L476RG", - "DISCO_F401VC", "NUCLEO_F303RE", "NUCLEO_F303K8", "MAXWSNENV", "MAX32600MBED", "NUCLEO_L152RE", "NUCLEO_F446RE", "NUCLEO_F103RB", "DISCO_F746NG", "NUCLEO_F746ZG", "MOTE_L152RC", "B96B_F446VE"], + "DISCO_F401VC", "NUCLEO_F303RE", "NUCLEO_F303K8", "MAXWSNENV", "MAX32600MBED", "NUCLEO_L152RE", "NUCLEO_F446RE", "NUCLEO_F103RB", "DISCO_F746NG", "NUCLEO_F746ZG", "MOTE_L152RC", "B96B_F446VE", "NRF51822", "NRF51_DK", "NRF51_MICROBIT", "SEEED_TINY_BLE"], }, { "id": "RTOS_2", "description": "Mutex resource lock", @@ -705,8 +705,8 @@ "RZ_A1H", "VK_RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "DISCO_F469NI", "NUCLEO_F410RB", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_F030R8", "NUCLEO_F070RB", "NUCLEO_L031K6", "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_L073RZ", "NUCLEO_F072RB", "NUCLEO_F091RC", "DISCO_L476VG", "NUCLEO_L476RG", - "DISCO_F401VC", "NUCLEO_F303RE", "NUCLEO_F303K8", "MAXWSNENV", "MAX32600MBED", "NUCLEO_L152RE", "NUCLEO_F446RE", "NUCLEO_F103RB", "DISCO_F746NG", - "NUCLEO_F746ZG", "MOTE_L152RC", "B96B_F446VE"], + "DISCO_F401VC", "NUCLEO_F303RE", "NUCLEO_F303K8", "MAXWSNENV", "MAX32600MBED", "NUCLEO_L152RE", "NUCLEO_F446RE", "NUCLEO_F103RB", "DISCO_F746NG", + "NUCLEO_F746ZG", "MOTE_L152RC", "B96B_F446VE", "NRF51822", "NRF51_DK", "NRF51_MICROBIT", "SEEED_TINY_BLE"], }, { "id": "RTOS_3", "description": "Semaphore resource lock", @@ -720,7 +720,7 @@ "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_F030R8", "NUCLEO_F070RB", "NUCLEO_L031K6", "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_L073RZ", "NUCLEO_F072RB", "NUCLEO_F091RC", "DISCO_L476VG", "NUCLEO_L476RG", "DISCO_F401VC", "NUCLEO_F303RE", "NUCLEO_F303K8", "MAXWSNENV", "MAX32600MBED", "NUCLEO_L152RE", "NUCLEO_F446RE", "NUCLEO_F103RB", "DISCO_F746NG", - "NUCLEO_F746ZG", "MOTE_L152RC", "B96B_F446VE"], + "NUCLEO_F746ZG", "MOTE_L152RC", "B96B_F446VE", "NRF51822", "NRF51_DK", "NRF51_MICROBIT", "SEEED_TINY_BLE"], }, { "id": "RTOS_4", "description": "Signals messaging", @@ -733,7 +733,7 @@ "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_F030R8", "NUCLEO_F070RB", "NUCLEO_L031K6", "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_L073RZ", "NUCLEO_F072RB", "NUCLEO_F091RC", "DISCO_L476VG", "NUCLEO_L476RG", "DISCO_F401VC", "NUCLEO_F303RE", "NUCLEO_F303K8", "MAXWSNENV", "MAX32600MBED", "NUCLEO_L152RE", "NUCLEO_F446RE", "NUCLEO_F103RB", "DISCO_F746NG", - "NUCLEO_F746ZG", "MOTE_L152RC", "B96B_F446VE"], + "NUCLEO_F746ZG", "MOTE_L152RC", "B96B_F446VE", "NRF51822", "NRF51_DK", "NRF51_MICROBIT", "SEEED_TINY_BLE"], }, { "id": "RTOS_5", "description": "Queue messaging", @@ -745,8 +745,9 @@ "RZ_A1H", "VK_RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "DISCO_F469NI", "NUCLEO_F410RB", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_F030R8", "NUCLEO_F070RB", "NUCLEO_L031K6", "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_L073RZ", "NUCLEO_F072RB", "NUCLEO_F091RC", "DISCO_L476VG", "NUCLEO_L476RG", - "DISCO_F401VC", "NUCLEO_F303RE", "NUCLEO_F303K8", "MAXWSNENV", "MAX32600MBED", "NUCLEO_L152RE", - "NUCLEO_F446RE", "NUCLEO_F103RB", "DISCO_F746NG", "NUCLEO_F746ZG", "MOTE_L152RC", "B96B_F446VE"], + "DISCO_F401VC", "NUCLEO_F303RE", "NUCLEO_F303K8", "MAXWSNENV", "MAX32600MBED", "NUCLEO_L152RE", + "NUCLEO_F446RE", "NUCLEO_F103RB", "DISCO_F746NG", "NUCLEO_F746ZG", "MOTE_L152RC", "B96B_F446VE", + "NRF51822", "NRF51_DK", "NRF51_MICROBIT", "SEEED_TINY_BLE"], }, { "id": "RTOS_6", "description": "Mail messaging", @@ -758,8 +759,9 @@ "RZ_A1H", "VK_RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "DISCO_F469NI", "NUCLEO_F410RB", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_F030R8", "NUCLEO_F070RB", "NUCLEO_L031K6", "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_L073RZ", "NUCLEO_F072RB", "NUCLEO_F091RC", "DISCO_L476VG", "NUCLEO_L476RG", - "DISCO_F401VC", "NUCLEO_F303RE", "NUCLEO_F303K8", "MAXWSNENV", "MAX32600MBED", "NUCLEO_L152RE", - "NUCLEO_F446RE", "NUCLEO_F103RB", "DISCO_F746NG", "NUCLEO_F746ZG", "MOTE_L152RC", "B96B_F446VE"], + "DISCO_F401VC", "NUCLEO_F303RE", "NUCLEO_F303K8", "MAXWSNENV", "MAX32600MBED", "NUCLEO_L152RE", + "NUCLEO_F446RE", "NUCLEO_F103RB", "DISCO_F746NG", "NUCLEO_F746ZG", "MOTE_L152RC", "B96B_F446VE", + "NRF51822", "NRF51_DK", "NRF51_MICROBIT", "SEEED_TINY_BLE"], }, { "id": "RTOS_7", "description": "Timer", @@ -773,8 +775,9 @@ "RZ_A1H", "VK_RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "DISCO_F469NI", "NUCLEO_F410RB", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_F030R8", "NUCLEO_F070RB", "NUCLEO_L031K6", "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_L073RZ", "NUCLEO_F072RB", "NUCLEO_F091RC", "DISCO_L476VG", "NUCLEO_L476RG", - "DISCO_F401VC", "NUCLEO_F303RE", "NUCLEO_F303K8", "MAXWSNENV", "MAX32600MBED", "NUCLEO_L152RE", - "NUCLEO_F446RE", "NUCLEO_F103RB", "DISCO_F746NG", "NUCLEO_F746ZG", "MOTE_L152RC", "B96B_F446VE"], + "DISCO_F401VC", "NUCLEO_F303RE", "NUCLEO_F303K8", "MAXWSNENV", "MAX32600MBED", "NUCLEO_L152RE", + "NUCLEO_F446RE", "NUCLEO_F103RB", "DISCO_F746NG", "NUCLEO_F746ZG", "MOTE_L152RC", "B96B_F446VE", + "NRF51822", "NRF51_DK", "NRF51_MICROBIT", "SEEED_TINY_BLE"], }, { "id": "RTOS_8", "description": "ISR (Queue)", @@ -786,8 +789,9 @@ "RZ_A1H", "VK_RZ_A1H", "DISCO_F407VG", "DISCO_F429ZI", "NUCLEO_F411RE", "DISCO_F469NI", "NUCLEO_F410RB", "NUCLEO_F401RE", "NUCLEO_F334R8", "DISCO_F334C8", "NUCLEO_F302R8", "NUCLEO_F030R8", "NUCLEO_F070RB", "NUCLEO_L031K6", "NUCLEO_L053R8", "DISCO_L053C8", "NUCLEO_L073RZ", "NUCLEO_F072RB", "NUCLEO_F091RC", "DISCO_L476VG", "NUCLEO_L476RG", - "DISCO_F401VC", "NUCLEO_F303RE", "NUCLEO_F303K8", "MAXWSNENV", "MAX32600MBED", "NUCLEO_L152RE", - "NUCLEO_F446RE", "NUCLEO_F103RB", "DISCO_F746NG", "NUCLEO_F746ZG", "MOTE_L152RC", "B96B_F446VE"], + "DISCO_F401VC", "NUCLEO_F303RE", "NUCLEO_F303K8", "MAXWSNENV", "MAX32600MBED", "NUCLEO_L152RE", + "NUCLEO_F446RE", "NUCLEO_F103RB", "DISCO_F746NG", "NUCLEO_F746ZG", "MOTE_L152RC", "B96B_F446VE", + "NRF51822", "NRF51_DK", "NRF51_MICROBIT", "SEEED_TINY_BLE"], }, { "id": "RTOS_9", "description": "SD File write-read", From 55a35f9b9b0ab359ccd64bc9eb11715a66383bb3 Mon Sep 17 00:00:00 2001 From: Vincent Coubard Date: Mon, 6 Jun 2016 13:59:17 +0100 Subject: [PATCH 5/6] Use attributes from toolchain.h instead of compiler specific declaration. --- .../TARGET_MCU_NRF51822/us_ticker.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/hal/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/us_ticker.c b/hal/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/us_ticker.c index 06e879551b5..11aebbe1483 100644 --- a/hal/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/us_ticker.c +++ b/hal/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/us_ticker.c @@ -19,6 +19,7 @@ #include "cmsis.h" #include "PeripheralNames.h" #include "nrf_delay.h" +#include "toolchain.h" /* * Note: The micro-second timer API on the nRF51 platform is implemented using @@ -71,18 +72,9 @@ static uint32_t previous_tick_cc_value = 0; To allow compilation of us_ticker programs without RTOS, those symbols are exported from this module as weak ones. */ -#if defined (__CC_ARM) /* ARMCC Compiler */ -__attribute__((weak)) uint32_t const os_trv; -__attribute__((weak)) uint32_t const os_clockrate; -__attribute__((weak)) void OS_Tick_Handler() { } -#elif defined (__GNUC__) /* GNU Compiler */ -__attribute__((weak)) uint32_t const os_trv = 31; -__attribute__((weak)) uint32_t const os_clockrate = 1000; -__attribute__((noreturn, naked, weak)) void OS_Tick_Handler() { } -#else -#error Compiler not supported. -#error Weak definitions of os_trv, os_clockrate and OS_Tick_Handler should be provided. -#endif +MBED_WEAK uint32_t const os_trv; +MBED_WEAK uint32_t const os_clockrate; +MBED_WEAK void OS_Tick_Handler() { } static inline void rtc1_enableCompareInterrupt(void) { From c58198e52bfece54e3ac31d1b4a9842ca03869c4 Mon Sep 17 00:00:00 2001 From: Vincent Coubard Date: Tue, 7 Jun 2016 17:50:00 +0100 Subject: [PATCH 6/6] Remove setbuf from rtos tests. --- libraries/tests/rtos/mbed/basic/main.cpp | 2 -- libraries/tests/rtos/mbed/isr/main.cpp | 2 -- libraries/tests/rtos/mbed/mail/main.cpp | 2 -- libraries/tests/rtos/mbed/mutex/main.cpp | 2 -- libraries/tests/rtos/mbed/queue/main.cpp | 2 -- libraries/tests/rtos/mbed/semaphore/main.cpp | 2 -- libraries/tests/rtos/mbed/signals/main.cpp | 2 -- libraries/tests/rtos/mbed/timer/main.cpp | 2 -- 8 files changed, 16 deletions(-) diff --git a/libraries/tests/rtos/mbed/basic/main.cpp b/libraries/tests/rtos/mbed/basic/main.cpp index 2364d7cca62..5ad41b661d6 100644 --- a/libraries/tests/rtos/mbed/basic/main.cpp +++ b/libraries/tests/rtos/mbed/basic/main.cpp @@ -42,8 +42,6 @@ void led2_thread(void const *argument) { } int main() { - setbuf(stdout, NULL); - MBED_HOSTTEST_TIMEOUT(15); MBED_HOSTTEST_SELECT(wait_us_auto); MBED_HOSTTEST_DESCRIPTION(Basic thread); diff --git a/libraries/tests/rtos/mbed/isr/main.cpp b/libraries/tests/rtos/mbed/isr/main.cpp index 7f5ebfbd4ad..da89bccab8e 100644 --- a/libraries/tests/rtos/mbed/isr/main.cpp +++ b/libraries/tests/rtos/mbed/isr/main.cpp @@ -46,8 +46,6 @@ void queue_thread(void const *argument) { } int main (void) { - setbuf(stdout, NULL); - MBED_HOSTTEST_TIMEOUT(20); MBED_HOSTTEST_SELECT(default_auto); MBED_HOSTTEST_DESCRIPTION(ISR (Queue)); diff --git a/libraries/tests/rtos/mbed/mail/main.cpp b/libraries/tests/rtos/mbed/mail/main.cpp index 7a0026a6c5f..3e7e0f0ea1e 100644 --- a/libraries/tests/rtos/mbed/mail/main.cpp +++ b/libraries/tests/rtos/mbed/mail/main.cpp @@ -52,8 +52,6 @@ void send_thread (void const *argument) { } int main (void) { - setbuf(stdout, NULL); - MBED_HOSTTEST_TIMEOUT(20); MBED_HOSTTEST_SELECT(default_auto); MBED_HOSTTEST_DESCRIPTION(Mail messaging); diff --git a/libraries/tests/rtos/mbed/mutex/main.cpp b/libraries/tests/rtos/mbed/mutex/main.cpp index 558ead2fb3d..7edd0a6ccfe 100644 --- a/libraries/tests/rtos/mbed/mutex/main.cpp +++ b/libraries/tests/rtos/mbed/mutex/main.cpp @@ -81,8 +81,6 @@ void test_thread(void const *args) { } int main() { - setbuf(stdout, NULL); - MBED_HOSTTEST_TIMEOUT(20); MBED_HOSTTEST_SELECT(default); MBED_HOSTTEST_DESCRIPTION(Mutex resource lock); diff --git a/libraries/tests/rtos/mbed/queue/main.cpp b/libraries/tests/rtos/mbed/queue/main.cpp index fe81f263ddf..e44021f392c 100644 --- a/libraries/tests/rtos/mbed/queue/main.cpp +++ b/libraries/tests/rtos/mbed/queue/main.cpp @@ -54,8 +54,6 @@ void send_thread (void const *argument) { } int main (void) { - setbuf(stdout, NULL); - MBED_HOSTTEST_TIMEOUT(20); MBED_HOSTTEST_SELECT(default_auto); MBED_HOSTTEST_DESCRIPTION(Queue messaging); diff --git a/libraries/tests/rtos/mbed/semaphore/main.cpp b/libraries/tests/rtos/mbed/semaphore/main.cpp index 2b9e221e95d..cc57aca08ec 100644 --- a/libraries/tests/rtos/mbed/semaphore/main.cpp +++ b/libraries/tests/rtos/mbed/semaphore/main.cpp @@ -72,8 +72,6 @@ void test_thread(void const *delay) { } int main (void) { - setbuf(stdout, NULL); - MBED_HOSTTEST_TIMEOUT(20); MBED_HOSTTEST_SELECT(default_auto); MBED_HOSTTEST_DESCRIPTION(Semaphore resource lock); diff --git a/libraries/tests/rtos/mbed/signals/main.cpp b/libraries/tests/rtos/mbed/signals/main.cpp index bdaed3e9105..51bff164f23 100644 --- a/libraries/tests/rtos/mbed/signals/main.cpp +++ b/libraries/tests/rtos/mbed/signals/main.cpp @@ -40,8 +40,6 @@ void led_thread(void const *argument) { } int main (void) { - setbuf(stdout, NULL); - MBED_HOSTTEST_TIMEOUT(20); MBED_HOSTTEST_SELECT(default_auto); MBED_HOSTTEST_DESCRIPTION(Signals messaging); diff --git a/libraries/tests/rtos/mbed/timer/main.cpp b/libraries/tests/rtos/mbed/timer/main.cpp index 405981a9d26..3c33551b0a6 100644 --- a/libraries/tests/rtos/mbed/timer/main.cpp +++ b/libraries/tests/rtos/mbed/timer/main.cpp @@ -23,8 +23,6 @@ void blink(void const *n) { } int main(void) { - setbuf(stdout, NULL); - MBED_HOSTTEST_TIMEOUT(15); MBED_HOSTTEST_SELECT(wait_us_auto); MBED_HOSTTEST_DESCRIPTION(Timer);