Skip to content

Commit

Permalink
v2.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
GorgonMeducer committed Aug 29, 2023
1 parent 6923de2 commit 5660b13
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 28 deletions.
18 changes: 11 additions & 7 deletions GorgonMeducer.perf_counter.pdsc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
<repository type="git">https://github.com/GorgonMeducer/perf_counter.git</repository>

<releases>
<release date="2023-06-12" version="2.2.2" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/GorgonMeducer.perf_counter.2.2.2.pack">
<release date="2023-08-30" version="2.2.3" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/GorgonMeducer.perf_counter.2.2.3.pack">
- Mitigate time-rolling-back issue when calling get_system_ticks in exception handlers that have higher priorities than the SysTick_Handler.
- Other minor updates
</release>
<release date="2023-06-12" version="2.2.2" url="https://github.com/GorgonMeducer/perf_counter/raw/124e98b3517aa46122ec7987c7726a065491823e/cmsis-pack/GorgonMeducer.perf_counter.2.2.2.pack">
- Add __cpu_time__
- Support reconfiguring the SysTick
- Suppress warnings
Expand Down Expand Up @@ -243,7 +247,7 @@
-->

<components>
<component Cclass="Utilities" Cversion="2.2.2" Cgroup="perf_counter" Csub="Core" Cvariant="Library" condition="CMSIS-CORE">
<component Cclass="Utilities" Cversion="2.2.3" Cgroup="perf_counter" Csub="Core" Cvariant="Library" condition="CMSIS-CORE">
<description>A dedicated performance counter for Cortex-M systick.</description>
<files>
<file category="header" name="lib/perf_counter.h"/>
Expand All @@ -261,7 +265,7 @@
#define __PERF_COUNTER_CFG_USE_SYSTICK_WRAPPER__ 1
</Pre_Include_Global_h>
</component>
<component Cclass="Utilities" Cversion="2.2.2" Cgroup="perf_counter" Csub="Core" Cvariant="Source" isDefaultVariant="true" condition="CMSIS-CORE">
<component Cclass="Utilities" Cversion="2.2.3" Cgroup="perf_counter" Csub="Core" Cvariant="Source" isDefaultVariant="true" condition="CMSIS-CORE">
<description>A dedicated performance counter for Cortex-M systick.</description>
<files>
<file category="header" name="lib/perf_counter.h"/>
Expand Down Expand Up @@ -304,7 +308,7 @@
</Pre_Include_Global_h>
</component>

<component Cclass="Utilities" Cversion="2.2.2" Cgroup="perf_counter" Csub="RTX5 Patch" condition="RTX5 Patch">
<component Cclass="Utilities" Cversion="2.2.3" Cgroup="perf_counter" Csub="RTX5 Patch" condition="RTX5 Patch">
<description>A Patch for RTX5</description>
<files>
<file category="source" name="lib/perf_os_patch_rtx5.c"/>
Expand All @@ -316,7 +320,7 @@
</Pre_Include_Global_h>
</component>

<component Cclass="Utilities" Cversion="2.2.2" Cgroup="perf_counter" Csub="FreeRTOS Patch" condition="perf_counter">
<component Cclass="Utilities" Cversion="2.2.3" Cgroup="perf_counter" Csub="FreeRTOS Patch" condition="perf_counter">
<description>A Patch for FreeRTOS</description>
<files>
<file category="source" name="lib/perf_os_patch_freertos.c"/>
Expand All @@ -339,7 +343,7 @@ extern void __freertos_evr_on_task_switched_in(void *ptTCB, unsigned int uxTopPr
</Pre_Include_Global_h>
</component>

<component Cclass="Utilities" Cversion="2.2.2" Cgroup="perf_counter" Csub="RT-Thread Patch" condition="perf_counter">
<component Cclass="Utilities" Cversion="2.2.3" Cgroup="perf_counter" Csub="RT-Thread Patch" condition="perf_counter">
<description>A Patch for RT-Thread</description>
<files>
<file category="source" name="lib/perf_os_patch_rt_thread.c"/>
Expand All @@ -357,7 +361,7 @@ extern void __rt_thread_scheduler_hook(struct rt_thread *from, struct rt_thread
</Pre_Include_Global_h>
</component>

<component Cclass="Utilities" Cversion="2.2.2" Cgroup="perf_counter" Csub="ThreadX Patch" condition="perf_counter">
<component Cclass="Utilities" Cversion="2.2.3" Cgroup="perf_counter" Csub="ThreadX Patch" condition="perf_counter">
<description>A Patch for ThreadX</description>
<files>
<file category="source" name="lib/perf_os_patch_threadx.c"/>
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# perf_counter (v2.2.3-dev)
# perf_counter (v2.2.3)
A dedicated performance counter for Cortex-M Systick. It shares the SysTick with users' original SysTick function(s) without interfering with it. This library will bring new functionalities, such as performance counter,` delay_us` and `clock()` service defined in `time.h`.

### Features:
Expand Down Expand Up @@ -422,9 +422,7 @@ void SysTick_Handler(void)
### 3.2 Why do I see perf_counter in red in the MDK project manager?
Since version v2.1.0 I removed the unnecessary bundle feature from the cmsis-pack, causing this problem if you have used the older version.
To solve this problem:
Since version v2.1.0 I removed the unnecessary bundle feature from the cmsis-pack. If you have used the older version, you will encounter this issue. To solve this problem:
1. please unselect ALL the performance components in RTE, press OK and close the uVision.
2. reopen the mdk project and select the perf_counter components in RTE
Expand Down
Binary file not shown.
18 changes: 11 additions & 7 deletions cmsis-pack/GorgonMeducer.perf_counter.pdsc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
<repository type="git">https://github.com/GorgonMeducer/perf_counter.git</repository>

<releases>
<release date="2023-06-12" version="2.2.2" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/GorgonMeducer.perf_counter.2.2.2.pack">
<release date="2023-08-30" version="2.2.3" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/GorgonMeducer.perf_counter.2.2.3.pack">
- Mitigate time-rolling-back issue when calling get_system_ticks in exception handlers that have higher priorities than the SysTick_Handler.
- Other minor updates
</release>
<release date="2023-06-12" version="2.2.2" url="https://github.com/GorgonMeducer/perf_counter/raw/124e98b3517aa46122ec7987c7726a065491823e/cmsis-pack/GorgonMeducer.perf_counter.2.2.2.pack">
- Add __cpu_time__
- Support reconfiguring the SysTick
- Suppress warnings
Expand Down Expand Up @@ -243,7 +247,7 @@
-->

<components>
<component Cclass="Utilities" Cversion="2.2.2" Cgroup="perf_counter" Csub="Core" Cvariant="Library" condition="CMSIS-CORE">
<component Cclass="Utilities" Cversion="2.2.3" Cgroup="perf_counter" Csub="Core" Cvariant="Library" condition="CMSIS-CORE">
<description>A dedicated performance counter for Cortex-M systick.</description>
<files>
<file category="header" name="lib/perf_counter.h"/>
Expand All @@ -261,7 +265,7 @@
#define __PERF_COUNTER_CFG_USE_SYSTICK_WRAPPER__ 1
</Pre_Include_Global_h>
</component>
<component Cclass="Utilities" Cversion="2.2.2" Cgroup="perf_counter" Csub="Core" Cvariant="Source" isDefaultVariant="true" condition="CMSIS-CORE">
<component Cclass="Utilities" Cversion="2.2.3" Cgroup="perf_counter" Csub="Core" Cvariant="Source" isDefaultVariant="true" condition="CMSIS-CORE">
<description>A dedicated performance counter for Cortex-M systick.</description>
<files>
<file category="header" name="lib/perf_counter.h"/>
Expand Down Expand Up @@ -304,7 +308,7 @@
</Pre_Include_Global_h>
</component>

<component Cclass="Utilities" Cversion="2.2.2" Cgroup="perf_counter" Csub="RTX5 Patch" condition="RTX5 Patch">
<component Cclass="Utilities" Cversion="2.2.3" Cgroup="perf_counter" Csub="RTX5 Patch" condition="RTX5 Patch">
<description>A Patch for RTX5</description>
<files>
<file category="source" name="lib/perf_os_patch_rtx5.c"/>
Expand All @@ -316,7 +320,7 @@
</Pre_Include_Global_h>
</component>

<component Cclass="Utilities" Cversion="2.2.2" Cgroup="perf_counter" Csub="FreeRTOS Patch" condition="perf_counter">
<component Cclass="Utilities" Cversion="2.2.3" Cgroup="perf_counter" Csub="FreeRTOS Patch" condition="perf_counter">
<description>A Patch for FreeRTOS</description>
<files>
<file category="source" name="lib/perf_os_patch_freertos.c"/>
Expand All @@ -339,7 +343,7 @@ extern void __freertos_evr_on_task_switched_in(void *ptTCB, unsigned int uxTopPr
</Pre_Include_Global_h>
</component>

<component Cclass="Utilities" Cversion="2.2.2" Cgroup="perf_counter" Csub="RT-Thread Patch" condition="perf_counter">
<component Cclass="Utilities" Cversion="2.2.3" Cgroup="perf_counter" Csub="RT-Thread Patch" condition="perf_counter">
<description>A Patch for RT-Thread</description>
<files>
<file category="source" name="lib/perf_os_patch_rt_thread.c"/>
Expand All @@ -357,7 +361,7 @@ extern void __rt_thread_scheduler_hook(struct rt_thread *from, struct rt_thread
</Pre_Include_Global_h>
</component>

<component Cclass="Utilities" Cversion="2.2.2" Cgroup="perf_counter" Csub="ThreadX Patch" condition="perf_counter">
<component Cclass="Utilities" Cversion="2.2.3" Cgroup="perf_counter" Csub="ThreadX Patch" condition="perf_counter">
<description>A Patch for ThreadX</description>
<files>
<file category="source" name="lib/perf_os_patch_threadx.c"/>
Expand Down
Binary file modified lib/libperf_counter_gcc.a
Binary file not shown.
4 changes: 2 additions & 2 deletions lib/perf_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extern "C" {
*/
#define __PERF_COUNTER_VER_MAJOR__ 2
#define __PERF_COUNTER_VER_MINOR__ 2
#define __PERF_COUNTER_VER_REVISE__ 2
#define __PERF_COUNTER_VER_REVISE__ 3

#define __PERF_COUNTER_VER_STR__ ""

Expand Down Expand Up @@ -366,7 +366,7 @@ __asm(".global __ensure_systick_wrapper\n\t");
SAFE_NAME(s_lTimestamp) = 0; \
SAFE_NAME(s_lTotal) = 0; \
if (__PLOOC_VA_NUM_ARGS(__VA_ARGS__) == 0) { \
printf("CPU Usage %3.2f%%\r\n", (double)__usage__); \
__perf_counter_printf__("CPU Usage %3.2f%%\r\n", (double)__usage__); \
} else { \
__VA_ARGS__ \
} \
Expand Down
Binary file modified lib/perf_counter.lib
Binary file not shown.
5 changes: 1 addition & 4 deletions lib/perf_os_patch_rt_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ task_cycle_info_t * get_rtos_task_cycle_info(void)

void __perf_os_patch_init(void)
{
#ifdef PKG_PERF_COUNTER_USING_THREAD_STATISTIC
rt_tick_sethook(user_code_insert_to_systick_handler);
#endif

#if !defined(PKG_USING_PERF_COUNTER) || (defined(PKG_PERF_COUNTER_USING_THREAD_STATISTIC))
rt_scheduler_sethook(__rt_thread_scheduler_hook);
#endif
Expand All @@ -93,7 +92,6 @@ void __ensure_systick_wrapper(void)
{
}

#ifdef PKG_PERF_COUNTER_USING_THREAD_STATISTIC
#define DBG_TAG "perf_counter"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
Expand All @@ -106,5 +104,4 @@ static int _perf_counter_init(void)
return 0;
}
INIT_PREV_EXPORT(_perf_counter_init);
#endif /* PKG_PERF_COUNTER_USING_THREAD_STATISTIC */
#endif /* PKG_USING_PERF_COUNTER */
7 changes: 4 additions & 3 deletions lib/perf_os_patch_threadx.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@
#define ORIG_FUNC(__NAME) __ORIG_FUNC(__NAME)


#ifndef TX_ENABLE_EXECUTION_CHANGE_NOTIFY
#error In order to use perf_counter:ThreadX-Patch, please define\
TX_ENABLE_EXECUTION_CHANGE_NOTIFY in the project configuration.\
#if defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) && defined(TX_EXECUTION_PROFILE_ENABLE)
#error In order to use perf_counter:ThreadX-Patch, please define \
TX_ENABLE_EXECUTION_CHANGE_NOTIFY or TX_EXECUTION_PROFILE_ENABLE \
in the project configuration, according to the version of thread.\
If you don't want to use this patch, please un-select it in RTE\
or remove this patch from the compilation.
#endif
Expand Down
16 changes: 16 additions & 0 deletions perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ extern uint32_t SystemCoreClock;

/*============================ LOCAL VARIABLES ===============================*/
volatile int64_t g_lLastTimeStamp = 0;
volatile static int64_t s_lOldTimestamp;
volatile int32_t g_nOffset = 0;
volatile static int32_t s_nUSUnit = 1;
volatile static int32_t s_nMSUnit = 1;
Expand Down Expand Up @@ -369,6 +370,21 @@ int64_t get_system_ticks(void)

__IRQ_SAFE {
lTemp = check_systick() + s_lSystemClockCounts;

/* When calling get_system_ticks() in an exception handler that has a
* higher priority than the SysTick_Handler, in some rare cases, the
* lTemp might be temporarily smaller than the previous value (i.e.
* s_lOldTimestamp), to mitigate the adverse effects of this problem,
* we use the following code to avoid time-rolling-back issue.
*
* NOTE: the issue mentioned above doesn't accumulate or have long-lasting
* effects.
*/
if (lTemp < s_lOldTimestamp) {
lTemp = s_lOldTimestamp;
} else {
s_lOldTimestamp = lTemp;
}
}

return lTemp;
Expand Down
2 changes: 1 addition & 1 deletion perf_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extern "C" {
#define __PERF_COUNTER_VER_MINOR__ 2
#define __PERF_COUNTER_VER_REVISE__ 3

#define __PERF_COUNTER_VER_STR__ "dev"
#define __PERF_COUNTER_VER_STR__ ""

#define __PER_COUNTER_VER__ (__PERF_COUNTER_VER_MAJOR__ * 10000ul \
+__PERF_COUNTER_VER_MINOR__ * 100ul \
Expand Down

0 comments on commit 5660b13

Please sign in to comment.