From 8f7fc603065ee40c49af8624b84062e7c4b39ee7 Mon Sep 17 00:00:00 2001
From: Dyyt587 <805207319@qq.com>
Date: Wed, 8 May 2024 17:03:56 +0800
Subject: [PATCH 1/6] add support for thread usage
---
.../stm32f427-robomaster-a/project.uvoptx | 890 +++++++++++++++++-
bsp/stm32/stm32f427-robomaster-a/rtconfig.h | 17 +-
src/Kconfig | 6 +
src/scheduler_up.c | 30 +-
4 files changed, 925 insertions(+), 18 deletions(-)
diff --git a/bsp/stm32/stm32f427-robomaster-a/project.uvoptx b/bsp/stm32/stm32f427-robomaster-a/project.uvoptx
index ba78957ed6d..34c91d7f18b 100644
--- a/bsp/stm32/stm32f427-robomaster-a/project.uvoptx
+++ b/bsp/stm32/stm32f427-robomaster-a/project.uvoptx
@@ -10,7 +10,7 @@
*.s*; *.src; *.a*
*.obj; *.o
*.lib
- *.txt; *.h; *.inc
+ *.txt; *.h; *.inc; *.md
*.plm
*.cpp
0
@@ -101,6 +101,8 @@
0
0
1
+ 0
+ 0
3
@@ -112,9 +114,14 @@
- Segger\JL2CM3.dll
+ BIN\CMSIS_AGDI.dll
+
+ 0
+ CMSIS_AGDI
+ -X"Any" -UAny -O206 -S8 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO11 -FD20000000 -FC1000 -FN1 -FF0STM32F4xx_2048.FLM -FS08000000 -FL0200000 -FP0($$Device:STM32F427IIHx$CMSIS\Flash\STM32F4xx_2048.FLM)
+
0
UL2CM3
@@ -165,8 +172,13 @@
+
+
+
+
1
+ 0
0
2
10000000
@@ -175,11 +187,883 @@
- Source Group 1
+ Applications
+ 0
+ 0
+ 0
+ 0
+
+ 1
+ 1
+ 1
+ 0
+ 0
+ 0
+ applications\main.c
+ main.c
+ 0
+ 0
+
+
+
+
+ Compiler
+ 0
+ 0
+ 0
+ 0
+
+ 2
+ 2
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\components\libc\compilers\armlibc\syscall_mem.c
+ syscall_mem.c
+ 0
+ 0
+
+
+ 2
+ 3
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\components\libc\compilers\armlibc\syscalls.c
+ syscalls.c
+ 0
+ 0
+
+
+ 2
+ 4
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\components\libc\compilers\common\cctype.c
+ cctype.c
+ 0
+ 0
+
+
+ 2
+ 5
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\components\libc\compilers\common\cstdlib.c
+ cstdlib.c
+ 0
+ 0
+
+
+ 2
+ 6
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\components\libc\compilers\common\cstring.c
+ cstring.c
+ 0
+ 0
+
+
+ 2
+ 7
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\components\libc\compilers\common\ctime.c
+ ctime.c
+ 0
+ 0
+
+
+ 2
+ 8
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\components\libc\compilers\common\cunistd.c
+ cunistd.c
+ 0
+ 0
+
+
+ 2
+ 9
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\components\libc\compilers\common\cwchar.c
+ cwchar.c
+ 0
+ 0
+
+
+
+
+ DeviceDrivers
+ 0
+ 0
+ 0
+ 0
+
+ 3
+ 10
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\components\drivers\core\device.c
+ device.c
+ 0
+ 0
+
+
+ 3
+ 11
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\components\drivers\ipc\completion.c
+ completion.c
+ 0
+ 0
+
+
+ 3
+ 12
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\components\drivers\ipc\condvar.c
+ condvar.c
+ 0
+ 0
+
+
+ 3
+ 13
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\components\drivers\ipc\dataqueue.c
+ dataqueue.c
+ 0
+ 0
+
+
+ 3
+ 14
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\components\drivers\ipc\pipe.c
+ pipe.c
+ 0
+ 0
+
+
+ 3
+ 15
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\components\drivers\ipc\ringblk_buf.c
+ ringblk_buf.c
+ 0
+ 0
+
+
+ 3
+ 16
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\components\drivers\ipc\ringbuffer.c
+ ringbuffer.c
+ 0
+ 0
+
+
+ 3
+ 17
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\components\drivers\ipc\waitqueue.c
+ waitqueue.c
+ 0
+ 0
+
+
+ 3
+ 18
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\components\drivers\ipc\workqueue.c
+ workqueue.c
+ 0
+ 0
+
+
+ 3
+ 19
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\components\drivers\pin\pin.c
+ pin.c
+ 0
+ 0
+
+
+ 3
+ 20
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\components\drivers\serial\serial.c
+ serial.c
+ 0
+ 0
+
+
+
+
+ Drivers
+ 0
+ 0
+ 0
+ 0
+
+ 4
+ 21
+ 1
+ 0
+ 0
+ 0
+ ..\libraries\HAL_Drivers\drivers\drv_gpio.c
+ drv_gpio.c
+ 0
+ 0
+
+
+ 4
+ 22
+ 1
+ 0
+ 0
+ 0
+ ..\libraries\HAL_Drivers\drivers\drv_usart.c
+ drv_usart.c
+ 0
+ 0
+
+
+ 4
+ 23
+ 1
+ 0
+ 0
+ 0
+ ..\libraries\HAL_Drivers\drv_common.c
+ drv_common.c
+ 0
+ 0
+
+
+ 4
+ 24
+ 2
+ 0
+ 0
+ 0
+ ..\libraries\STM32F4xx_HAL\CMSIS\Device\ST\STM32F4xx\Source\Templates\arm\startup_stm32f427xx.s
+ startup_stm32f427xx.s
+ 0
+ 0
+
+
+ 4
+ 25
+ 1
+ 0
+ 0
+ 0
+ board\CubeMX_Config\Src\stm32f4xx_hal_msp.c
+ stm32f4xx_hal_msp.c
+ 0
+ 0
+
+
+ 4
+ 26
+ 1
+ 0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 6
+ 40
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\src\mem.c
+ mem.c
+ 0
+ 0
+
+
+ 6
+ 41
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\src\mempool.c
+ mempool.c
+ 0
+ 0
+
+
+ 6
+ 42
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\src\object.c
+ object.c
+ 0
+ 0
+
+
+ 6
+ 43
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\src\scheduler_comm.c
+ scheduler_comm.c
+ 0
+ 0
+
+
+ 6
+ 44
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\src\scheduler_up.c
+ scheduler_up.c
+ 0
+ 0
+
+
+ 6
+ 45
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\src\thread.c
+ thread.c
+ 0
+ 0
+
+
+ 6
+ 46
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\src\timer.c
+ timer.c
+ 0
+ 0
+
+
+
+
+ libcpu
+ 0
+ 0
+ 0
+ 0
+
+ 7
+ 47
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\libcpu\arm\common\atomic_arm.c
+ atomic_arm.c
+ 0
+ 0
+
+
+ 7
+ 48
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\libcpu\arm\common\div0.c
+ div0.c
+ 0
+ 0
+
+
+ 7
+ 49
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\libcpu\arm\common\showmem.c
+ showmem.c
+ 0
+ 0
+
+
+ 7
+ 50
+ 2
+ 0
+ 0
+ 0
+ ..\..\..\libcpu\arm\cortex-m4\context_rvds.S
+ context_rvds.S
+ 0
+ 0
+
+
+ 7
+ 51
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\libcpu\arm\cortex-m4\cpuport.c
+ cpuport.c
+ 0
+ 0
+
+
+
+
+ Libraries
0
0
0
0
+
+ 8
+ 52
+ 1
+ 0
+ 0
+ 0
+ ..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_uart.c
+ stm32f4xx_hal_uart.c
+ 0
+ 0
+
+
+ 8
+ 53
+ 1
+ 0
+ 0
+ 0
+ ..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_cryp_ex.c
+ stm32f4xx_hal_cryp_ex.c
+ 0
+ 0
+
+
+ 8
+ 54
+ 1
+ 0
+ 0
+ 0
+ ..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_pwr_ex.c
+ stm32f4xx_hal_pwr_ex.c
+ 0
+ 0
+
+
+ 8
+ 55
+ 1
+ 0
+ 0
+ 0
+ ..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rng.c
+ stm32f4xx_hal_rng.c
+ 0
+ 0
+
+
+ 8
+ 56
+ 1
+ 0
+ 0
+ 0
+ ..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_dma.c
+ stm32f4xx_hal_dma.c
+ 0
+ 0
+
+
+ 8
+ 57
+ 1
+ 0
+ 0
+ 0
+ ..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal.c
+ stm32f4xx_hal.c
+ 0
+ 0
+
+
+ 8
+ 58
+ 1
+ 0
+ 0
+ 0
+ ..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rcc_ex.c
+ stm32f4xx_hal_rcc_ex.c
+ 0
+ 0
+
+
+ 8
+ 59
+ 1
+ 0
+ 0
+ 0
+ ..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_usart.c
+ stm32f4xx_hal_usart.c
+ 0
+ 0
+
+
+ 8
+ 60
+ 1
+ 0
+ 0
+ 0
+ ..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_cec.c
+ stm32f4xx_hal_cec.c
+ 0
+ 0
+
+
+ 8
+ 61
+ 1
+ 0
+ 0
+ 0
+ ..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rcc.c
+ stm32f4xx_hal_rcc.c
+ 0
+ 0
+
+
+ 8
+ 62
+ 1
+ 0
+ 0
+ 0
+ ..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_dma_ex.c
+ stm32f4xx_hal_dma_ex.c
+ 0
+ 0
+
+
+ 8
+ 63
+ 1
+ 0
+ 0
+ 0
+ ..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_pwr.c
+ stm32f4xx_hal_pwr.c
+ 0
+ 0
+
+
+ 8
+ 64
+ 1
+ 0
+ 0
+ 0
+ ..\libraries\STM32F4xx_HAL\CMSIS\Device\ST\STM32F4xx\Source\Templates\system_stm32f4xx.c
+ system_stm32f4xx.c
+ 0
+ 0
+
+
+ 8
+ 65
+ 1
+ 0
+ 0
+ 0
+ ..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_crc.c
+ stm32f4xx_hal_crc.c
+ 0
+ 0
+
+
+ 8
+ 66
+ 1
+ 0
+ 0
+ 0
+ ..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_cortex.c
+ stm32f4xx_hal_cortex.c
+ 0
+ 0
+
+
+ 8
+ 67
+ 1
+ 0
+ 0
+ 0
+ ..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_cryp.c
+ stm32f4xx_hal_cryp.c
+ 0
+ 0
+
+
+ 8
+ 68
+ 1
+ 0
+ 0
+ 0
+ ..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_gpio.c
+ stm32f4xx_hal_gpio.c
+ 0
+ 0
+
diff --git a/bsp/stm32/stm32f427-robomaster-a/rtconfig.h b/bsp/stm32/stm32f427-robomaster-a/rtconfig.h
index 0d22160731b..e72137f2432 100644
--- a/bsp/stm32/stm32f427-robomaster-a/rtconfig.h
+++ b/bsp/stm32/stm32f427-robomaster-a/rtconfig.h
@@ -23,7 +23,11 @@
/* kservice optimization */
+
+/* klibc optimization */
+
#define RT_USING_DEBUG
+#define RT_DEBUGING_ASSERT
#define RT_DEBUGING_COLOR
#define RT_DEBUGING_CONTEXT
@@ -45,7 +49,7 @@
#define RT_USING_CONSOLE
#define RT_CONSOLEBUF_SIZE 128
#define RT_CONSOLE_DEVICE_NAME "uart6"
-#define RT_VER_NUM 0x50100
+#define RT_VER_NUM 0x50200
#define RT_BACKTRACE_LEVEL_MAX_NR 32
#define RT_USING_HW_ATOMIC
#define RT_USING_CPU_FFS
@@ -184,20 +188,15 @@
/* peripheral libraries and drivers */
-/* HAL & SDK Drivers */
-
-/* STM32 HAL & SDK Drivers */
-
-
-/* Kendryte SDK */
-
-
/* sensors drivers */
/* touch drivers */
+/* Kendryte SDK */
+
+
/* AI packages */
diff --git a/src/Kconfig b/src/Kconfig
index 8a96405ed55..469373e8b93 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -119,6 +119,12 @@ config RT_USING_OVERFLOW_CHECK
Enable thread stack overflow checking. The stack overflow is checking when
each thread switch.
+config RT_USING_CPU_USAGE
+ bool "thread usage measurement"
+ default y
+ help
+ Measure thread cpu usage.
+
config RT_USING_HOOK
bool "Enable system hook"
default y
diff --git a/src/scheduler_up.c b/src/scheduler_up.c
index 822d4a80461..ba72704ebf9 100644
--- a/src/scheduler_up.c
+++ b/src/scheduler_up.c
@@ -61,6 +61,25 @@ static void (*rt_scheduler_switch_hook)(struct rt_thread *tid);
/**@{*/
+/**
+ * @brief pause usage measure
+ *
+ */
+rt_weak void rt_usage_measure_pause(void)
+{
+ /* do nothing in it */
+}
+/**
+ * @brief start usage measure
+ *
+ * @param from
+ * @param to
+ */
+rt_weak void rt_usage_measure_start(struct rt_thread *from, struct rt_thread *to)
+{
+ /* do nothing in it */
+}
+
/**
* @brief This function will set a hook function, which will be invoked when thread
* switch happens.
@@ -207,6 +226,9 @@ void rt_schedule(void)
/* disable interrupt */
level = rt_hw_interrupt_disable();
+ /*to avoid schedule interference*/
+ rt_usage_measure_pause();
+
/* check the scheduler is enabled or not */
if (rt_scheduler_lock_nest == 0)
{
@@ -276,9 +298,6 @@ void rt_schedule(void)
rt_hw_context_switch((rt_ubase_t)&from_thread->sp,
(rt_ubase_t)&to_thread->sp);
- /* enable interrupt */
- rt_hw_interrupt_enable(level);
-
#ifdef RT_USING_SIGNALS
/* check stat of thread for signal */
level = rt_hw_interrupt_disable();
@@ -295,7 +314,6 @@ void rt_schedule(void)
}
else
{
- rt_hw_interrupt_enable(level);
}
#endif /* RT_USING_SIGNALS */
goto __exit;
@@ -316,10 +334,10 @@ void rt_schedule(void)
}
}
+__exit:
+ rt_usage_measure_start(from_thread, to_thread);
/* enable interrupt */
rt_hw_interrupt_enable(level);
-
-__exit:
return;
}
From 3e1f1377a561b19fbbe610415a0f0e488f2f1470 Mon Sep 17 00:00:00 2001
From: Dyyt587 <805207319@qq.com>
Date: Wed, 8 May 2024 17:20:48 +0800
Subject: [PATCH 2/6] Update scheduler_up.c
---
src/scheduler_up.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/scheduler_up.c b/src/scheduler_up.c
index ba72704ebf9..d7ae9a49946 100644
--- a/src/scheduler_up.c
+++ b/src/scheduler_up.c
@@ -65,9 +65,12 @@ static void (*rt_scheduler_switch_hook)(struct rt_thread *tid);
* @brief pause usage measure
*
*/
-rt_weak void rt_usage_measure_pause(void)
+#if RT_USING_CPU_USAGE
+rt_weak
+#endif /* RT_USING_CPU_USAGE */
+void rt_usage_measure_pause(void)
{
- /* do nothing in it */
+ /* do nothing in it, implemented in another file */
}
/**
* @brief start usage measure
@@ -75,9 +78,12 @@ rt_weak void rt_usage_measure_pause(void)
* @param from
* @param to
*/
-rt_weak void rt_usage_measure_start(struct rt_thread *from, struct rt_thread *to)
+#if RT_USING_CPU_USAGE
+rt_weak
+#endif /* RT_USING_CPU_USAGE */
+void rt_usage_measure_start(struct rt_thread *from, struct rt_thread *to)
{
- /* do nothing in it */
+ /* do nothing in it, implemented in another file */
}
/**
From 47b4f9ef79e9752a2edf368fcb7c994abb1e2f35 Mon Sep 17 00:00:00 2001
From: Dyyt587 <805207319@qq.com>
Date: Wed, 8 May 2024 17:23:04 +0800
Subject: [PATCH 3/6] Update scheduler_up.c
---
src/scheduler_up.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/scheduler_up.c b/src/scheduler_up.c
index d7ae9a49946..796a493a533 100644
--- a/src/scheduler_up.c
+++ b/src/scheduler_up.c
@@ -63,7 +63,6 @@ static void (*rt_scheduler_switch_hook)(struct rt_thread *tid);
/**
* @brief pause usage measure
- *
*/
#if RT_USING_CPU_USAGE
rt_weak
@@ -74,7 +73,7 @@ void rt_usage_measure_pause(void)
}
/**
* @brief start usage measure
- *
+ *
* @param from
* @param to
*/
From 8c9ed5e090ef2e091f976c364312994f0ca0810d Mon Sep 17 00:00:00 2001
From: Dyyt587 <805207319@qq.com>
Date: Wed, 8 May 2024 17:24:32 +0800
Subject: [PATCH 4/6] Update scheduler_up.c
---
src/scheduler_up.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/scheduler_up.c b/src/scheduler_up.c
index 796a493a533..13a16039e6e 100644
--- a/src/scheduler_up.c
+++ b/src/scheduler_up.c
@@ -74,8 +74,8 @@ void rt_usage_measure_pause(void)
/**
* @brief start usage measure
*
- * @param from
- * @param to
+ * @param from wait to turn on
+ * @param to turn to be
*/
#if RT_USING_CPU_USAGE
rt_weak
From a960c285488df940d1871021d4c327dc0a067fe6 Mon Sep 17 00:00:00 2001
From: Dyyt587 <805207319@qq.com>
Date: Wed, 8 May 2024 17:25:49 +0800
Subject: [PATCH 5/6] Update scheduler_up.c
---
src/scheduler_up.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/scheduler_up.c b/src/scheduler_up.c
index 13a16039e6e..32e44c4308d 100644
--- a/src/scheduler_up.c
+++ b/src/scheduler_up.c
@@ -64,7 +64,7 @@ static void (*rt_scheduler_switch_hook)(struct rt_thread *tid);
/**
* @brief pause usage measure
*/
-#if RT_USING_CPU_USAGE
+#ifdef RT_USING_CPU_USAGE
rt_weak
#endif /* RT_USING_CPU_USAGE */
void rt_usage_measure_pause(void)
@@ -77,7 +77,7 @@ void rt_usage_measure_pause(void)
* @param from wait to turn on
* @param to turn to be
*/
-#if RT_USING_CPU_USAGE
+#ifdef RT_USING_CPU_USAGE
rt_weak
#endif /* RT_USING_CPU_USAGE */
void rt_usage_measure_start(struct rt_thread *from, struct rt_thread *to)
From 8c5040ab5c4825f59bba9071a476638e7421d33f Mon Sep 17 00:00:00 2001
From: Dyyt587 <805207319@qq.com>
Date: Fri, 10 May 2024 16:21:12 +0800
Subject: [PATCH 6/6] up data
---
.../stm32f427-robomaster-a/project.uvoptx | 132 +-
.../stm32f427-robomaster-a/project.uvprojx | 1201 ++++++++++++++---
components/utilities/cpuusage/cpuusage.c | 41 +
components/utilities/cpuusage/cpuusage.h | 25 +
src/scheduler_mp.c | 27 +-
5 files changed, 1181 insertions(+), 245 deletions(-)
create mode 100644 components/utilities/cpuusage/cpuusage.c
create mode 100644 components/utilities/cpuusage/cpuusage.h
diff --git a/bsp/stm32/stm32f427-robomaster-a/project.uvoptx b/bsp/stm32/stm32f427-robomaster-a/project.uvoptx
index 34c91d7f18b..dd269a361ef 100644
--- a/bsp/stm32/stm32f427-robomaster-a/project.uvoptx
+++ b/bsp/stm32/stm32f427-robomaster-a/project.uvoptx
@@ -347,18 +347,6 @@
0
0
0
- ..\..\..\components\drivers\ipc\condvar.c
- condvar.c
- 0
- 0
-
-
- 3
- 13
- 1
- 0
- 0
- 0
..\..\..\components\drivers\ipc\dataqueue.c
dataqueue.c
0
@@ -366,7 +354,7 @@
3
- 14
+ 13
1
0
0
@@ -378,7 +366,7 @@
3
- 15
+ 14
1
0
0
@@ -390,7 +378,7 @@
3
- 16
+ 15
1
0
0
@@ -402,7 +390,7 @@
3
- 17
+ 16
1
0
0
@@ -414,7 +402,7 @@
3
- 18
+ 17
1
0
0
@@ -426,7 +414,7 @@
3
- 19
+ 18
1
0
0
@@ -438,7 +426,7 @@
3
- 20
+ 19
1
0
0
@@ -458,7 +446,7 @@
0
4
- 21
+ 20
1
0
0
@@ -470,7 +458,7 @@
4
- 22
+ 21
1
0
0
@@ -482,7 +470,7 @@
4
- 23
+ 22
1
0
0
@@ -494,7 +482,7 @@
4
- 24
+ 23
2
0
0
@@ -506,7 +494,7 @@
4
- 25
+ 24
1
0
0
@@ -518,7 +506,7 @@
4
- 26
+ 25
1
0
0
@@ -538,7 +526,7 @@
0
5
- 27
+ 26
1
0
0
@@ -550,7 +538,7 @@
5
- 28
+ 27
1
0
0
@@ -562,7 +550,7 @@
5
- 29
+ 28
1
0
0
@@ -574,7 +562,7 @@
5
- 30
+ 29
1
0
0
@@ -594,7 +582,7 @@
0
6
- 31
+ 30
1
0
0
@@ -606,7 +594,7 @@
6
- 32
+ 31
1
0
0
@@ -618,19 +606,7 @@
6
- 33
- 1
- 0
- 0
- 0
- ..\..\..\src\cpu_up.c
- cpu_up.c
- 0
- 0
-
-
- 6
- 34
+ 32
1
0
0
@@ -642,7 +618,7 @@
6
- 35
+ 33
1
0
0
@@ -654,7 +630,7 @@
6
- 36
+ 34
1
0
0
@@ -666,7 +642,7 @@
6
- 37
+ 35
1
0
0
@@ -678,7 +654,7 @@
6
- 38
+ 36
1
0
0
@@ -690,7 +666,7 @@
6
- 39
+ 37
1
0
0
@@ -702,7 +678,7 @@
6
- 40
+ 38
1
0
0
@@ -714,7 +690,7 @@
6
- 41
+ 39
1
0
0
@@ -726,7 +702,7 @@
6
- 42
+ 40
1
0
0
@@ -738,7 +714,7 @@
6
- 43
+ 41
1
0
0
@@ -750,7 +726,7 @@
6
- 44
+ 42
1
0
0
@@ -762,7 +738,7 @@
6
- 45
+ 43
1
0
0
@@ -774,7 +750,7 @@
6
- 46
+ 44
1
0
0
@@ -794,7 +770,7 @@
0
7
- 47
+ 45
1
0
0
@@ -806,7 +782,7 @@
7
- 48
+ 46
1
0
0
@@ -818,7 +794,7 @@
7
- 49
+ 47
1
0
0
@@ -830,7 +806,7 @@
7
- 50
+ 48
2
0
0
@@ -842,7 +818,7 @@
7
- 51
+ 49
1
0
0
@@ -862,7 +838,7 @@
0
8
- 52
+ 50
1
0
0
@@ -874,7 +850,7 @@
8
- 53
+ 51
1
0
0
@@ -886,7 +862,7 @@
8
- 54
+ 52
1
0
0
@@ -898,7 +874,7 @@
8
- 55
+ 53
1
0
0
@@ -910,7 +886,7 @@
8
- 56
+ 54
1
0
0
@@ -922,7 +898,7 @@
8
- 57
+ 55
1
0
0
@@ -934,7 +910,7 @@
8
- 58
+ 56
1
0
0
@@ -946,7 +922,7 @@
8
- 59
+ 57
1
0
0
@@ -958,7 +934,7 @@
8
- 60
+ 58
1
0
0
@@ -970,7 +946,7 @@
8
- 61
+ 59
1
0
0
@@ -982,7 +958,7 @@
8
- 62
+ 60
1
0
0
@@ -994,7 +970,7 @@
8
- 63
+ 61
1
0
0
@@ -1006,7 +982,7 @@
8
- 64
+ 62
1
0
0
@@ -1018,7 +994,7 @@
8
- 65
+ 63
1
0
0
@@ -1030,7 +1006,7 @@
8
- 66
+ 64
1
0
0
@@ -1042,7 +1018,7 @@
8
- 67
+ 65
1
0
0
@@ -1054,7 +1030,7 @@
8
- 68
+ 66
1
0
0
diff --git a/bsp/stm32/stm32f427-robomaster-a/project.uvprojx b/bsp/stm32/stm32f427-robomaster-a/project.uvprojx
index 9be0b4dfed1..98fead41028 100644
--- a/bsp/stm32/stm32f427-robomaster-a/project.uvprojx
+++ b/bsp/stm32/stm32f427-robomaster-a/project.uvprojx
@@ -1,42 +1,46 @@
+
2.1
+
### uVision Project, (C) Keil Software
+
rt-thread
0x4
ARM-ADS
5060750::V5.06 update 6 (build 750)::ARMCC
+ 0
STM32F427IIHx
STMicroelectronics
- Keil.STM32F4xx_DFP.2.13.0
- http://www.keil.com/pack
+ Keil.STM32F4xx_DFP.2.17.1
+ https://www.keil.com/pack/
IRAM(0x20000000,0x00030000) IRAM2(0x10000000,0x00010000) IROM(0x08000000,0x00200000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE
-
-
+
+
UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F4xx_2048 -FS08000000 -FL0200000 -FP0($$Device:STM32F427IIHx$CMSIS\Flash\STM32F4xx_2048.FLM))
0
$$Device:STM32F427IIHx$Drivers\CMSIS\Device\ST\STM32F4xx\Include\stm32f4xx.h
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
$$Device:STM32F427IIHx$CMSIS\SVD\STM32F427x.svd
0
0
-
-
-
-
-
+
+
+
+
+
0
0
@@ -58,8 +62,8 @@
0
0
-
-
+
+
0
0
0
@@ -68,8 +72,8 @@
0
0
-
-
+
+
0
0
0
@@ -79,14 +83,14 @@
1
0
fromelf --bin !L --output rtthread.bin
-
+
0
0
0
0
0
-
+
0
@@ -100,8 +104,8 @@
0
0
3
-
-
+
+
1
@@ -134,11 +138,11 @@
1
BIN\UL2CM3.DLL
-
-
-
-
-
+
+
+
+
+
0
@@ -171,7 +175,7 @@
0
0
"Cortex-M4"
-
+
0
0
0
@@ -180,6 +184,9 @@
0
0
2
+ 0
+ 0
+ 0
1
0
8
@@ -303,7 +310,7 @@
0x10000
-
+
1
@@ -320,6 +327,7 @@
0
0
1
+ 0
0
1
1
@@ -329,9 +337,9 @@
0
0
-
+
__STDC_LIMIT_MACROS, RT_USING_ARMLIBC, USE_HAL_DRIVER, RT_USING_LIBC, __CLK_TCK=RT_TICK_PER_SECOND, STM32F427xx, __RTTHREAD__
-
+
..\..\..\libcpu\arm\cortex-m4;..\..\..\components\libc\compilers\common\extension\fcntl\octal;board;..\libraries\HAL_Drivers\CMSIS\Include;..\libraries\STM32F4xx_HAL\CMSIS\Device\ST\STM32F4xx\Include;..\..\..\components\libc\compilers\common\include;..\libraries\HAL_Drivers\drivers;applications;..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Inc;..\libraries\HAL_Drivers\drivers\config;..\..\..\components\finsh;.;..\..\..\components\libc\posix\io\epoll;..\..\..\libcpu\arm\common;..\libraries\HAL_Drivers;..\..\..\components\drivers\include;..\..\..\include;..\..\..\components\libc\posix\io\eventfd;..\..\..\components\libc\posix\io\poll;..\..\..\components\drivers\include;board\ports;..\..\..\components\libc\compilers\common\extension;..\..\..\components\drivers\include;..\..\..\components\drivers\include;board\CubeMX_Config\Inc;..\..\..\components\libc\posix\ipc
@@ -345,12 +353,12 @@
0
0
0
- 0
+ 4
-
-
-
-
+
+
+
+
@@ -362,13 +370,13 @@
0
0x08000000
0x20000000
-
+
.\board\linker_scripts\link.sct
-
-
-
-
-
+
+
+
+
+
@@ -391,50 +399,36 @@
1
..\..\..\components\libc\compilers\armlibc\syscall_mem.c
-
-
syscalls.c
1
..\..\..\components\libc\compilers\armlibc\syscalls.c
-
-
cctype.c
1
..\..\..\components\libc\compilers\common\cctype.c
-
-
cstdlib.c
1
..\..\..\components\libc\compilers\common\cstdlib.c
-
-
cstring.c
1
..\..\..\components\libc\compilers\common\cstring.c
-
-
ctime.c
1
..\..\..\components\libc\compilers\common\ctime.c
-
-
cunistd.c
1
..\..\..\components\libc\compilers\common\cunistd.c
-
-
cwchar.c
1
@@ -450,8 +444,47 @@
1
..\..\..\components\drivers\core\device.c
+
+ 2
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 3
+
+
+ 1
+
+ 2
+ 0
+ 2
+ 2
+ 2
+ 2
+ 2
+ 2
+ 2
+ 2
+ 0
+ 2
+ 2
+ 2
+ 2
+ 2
+ 0
+ 0
+ 2
+ 2
+ 2
+ 2
+ 2
__RT_IPC_SOURCE__
@@ -462,15 +495,52 @@
-
-
completion.c
1
..\..\..\components\drivers\ipc\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
+ 0
+ 0
+ 3
+
+
+ 1
+
+ 2
+ 0
+ 2
+ 2
+ 2
+ 2
+ 2
+ 2
+ 2
+ 2
+ 0
+ 2
+ 2
+ 2
+ 2
+ 2
+ 0
+ 0
+ 2
+ 2
+ 2
+ 2
+ 2
__RT_IPC_SOURCE__
@@ -643,36 +1009,26 @@
1
..\libraries\HAL_Drivers\drivers\drv_gpio.c
-
-
drv_usart.c
1
..\libraries\HAL_Drivers\drivers\drv_usart.c
-
-
drv_common.c
1
..\libraries\HAL_Drivers\drv_common.c
-
-
startup_stm32f427xx.s
2
..\libraries\STM32F4xx_HAL\CMSIS\Device\ST\STM32F4xx\Source\Templates\arm\startup_stm32f427xx.s
-
-
stm32f4xx_hal_msp.c
1
board\CubeMX_Config\Src\stm32f4xx_hal_msp.c
-
-
board.c
1
@@ -688,22 +1044,16 @@
1
..\..\..\components\finsh\shell.c
-
-
msh.c
1
..\..\..\components\finsh\msh.c
-
-
msh_parse.c
1
..\..\..\components\finsh\msh_parse.c
-
-
cmd.c
1
@@ -719,8 +1069,47 @@
1
..\..\..\src\clock.c
+
+ 2
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 3
+
+
+ 1
+
+ 2
+ 0
+ 2
+ 2
+ 2
+ 2
+ 2
+ 2
+ 2
+ 2
+ 0
+ 2
+ 2
+ 2
+ 2
+ 2
+ 0
+ 0
+ 2
+ 2
+ 2
+ 2
+ 2
__RT_KERNEL_SOURCE__
@@ -731,15 +1120,52 @@
-
-
components.c
1
..\..\..\src\components.c
+
+ 2
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 3
+
+
+ 1
+
+ 2
+ 0
+ 2
+ 2
+ 2
+ 2
+ 2
+ 2
+ 2
+ 2
+ 0
+ 2
+ 2
+ 2
+ 2
+ 2
+ 0
+ 0
+ 2
+ 2
+ 2
+ 2
+ 2
__RT_KERNEL_SOURCE__
@@ -750,15 +1176,52 @@
-
-
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
+ 2
+ 2
+ 0
+ 0
+ 2
+ 2
+ 2
+ 2
+ 2
__RT_KERNEL_SOURCE__
@@ -1007,29 +1914,21 @@
1
..\..\..\libcpu\arm\common\atomic_arm.c
-
-
div0.c
1
..\..\..\libcpu\arm\common\div0.c
-
-
showmem.c
1
..\..\..\libcpu\arm\common\showmem.c
-
-
context_rvds.S
2
..\..\..\libcpu\arm\cortex-m4\context_rvds.S
-
-
cpuport.c
1
@@ -1045,113 +1944,81 @@
1
..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_uart.c
-
-
stm32f4xx_hal_cryp_ex.c
1
..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_cryp_ex.c
-
-
stm32f4xx_hal_pwr_ex.c
1
..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_pwr_ex.c
-
-
stm32f4xx_hal_rng.c
1
..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rng.c
-
-
stm32f4xx_hal_dma.c
1
..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_dma.c
-
-
stm32f4xx_hal.c
1
..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal.c
-
-
stm32f4xx_hal_rcc_ex.c
1
..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rcc_ex.c
-
-
stm32f4xx_hal_usart.c
1
..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_usart.c
-
-
stm32f4xx_hal_cec.c
1
..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_cec.c
-
-
stm32f4xx_hal_rcc.c
1
..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rcc.c
-
-
stm32f4xx_hal_dma_ex.c
1
..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_dma_ex.c
-
-
stm32f4xx_hal_pwr.c
1
..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_pwr.c
-
-
system_stm32f4xx.c
1
..\libraries\STM32F4xx_HAL\CMSIS\Device\ST\STM32F4xx\Source\Templates\system_stm32f4xx.c
-
-
stm32f4xx_hal_crc.c
1
..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_crc.c
-
-
stm32f4xx_hal_cortex.c
1
..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_cortex.c
-
-
stm32f4xx_hal_cryp.c
1
..\libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_cryp.c
-
-
stm32f4xx_hal_gpio.c
1
@@ -1162,9 +2029,11 @@
+
-
-
-
+
+
+
+
diff --git a/components/utilities/cpuusage/cpuusage.c b/components/utilities/cpuusage/cpuusage.c
new file mode 100644
index 00000000000..5622e891d3a
--- /dev/null
+++ b/components/utilities/cpuusage/cpuusage.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2024-2024, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2024-05-9 Dyyt587 the first version
+ */
+
+#include "cpuusage.h"
+//#ifdef RT_USING_CPU_USAGE
+#if 1
+static rt_tick_t pause_tick = 0;
+
+/**
+ * @brief pause usage measure
+ *
+ * @note reduce scheduler time consuming
+ */
+void rt_usage_measure_pause(void)
+{
+ pause_tick = rt_tick_get();
+}
+/**
+ * @brief start usage measure
+ *
+ * @param from wait to turn on
+ * @param to turn to be
+ */
+void rt_usage_measure_start(struct rt_thread *from, struct rt_thread *to)
+{
+ /* to avoid scheduler time consuming */
+ from->duration_tick += pause_tick - from->last_start_tick;
+
+ to->last_start_tick = rt_tick_get();
+}
+
+
+
+#endif /* RT_USING_CPU_USAGE */
\ No newline at end of file
diff --git a/components/utilities/cpuusage/cpuusage.h b/components/utilities/cpuusage/cpuusage.h
new file mode 100644
index 00000000000..d796a5d3403
--- /dev/null
+++ b/components/utilities/cpuusage/cpuusage.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2024-2024, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2024-05-9 Dyyt587 the first version
+ */
+
+#ifndef CPU_USAGE_H
+#define CPU_USAGE_H
+
+#include
+#include "ulog_def.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/src/scheduler_mp.c b/src/scheduler_mp.c
index ee32d9bc609..60308312efa 100644
--- a/src/scheduler_mp.c
+++ b/src/scheduler_mp.c
@@ -137,6 +137,30 @@ static void (*rt_scheduler_switch_hook)(struct rt_thread *tid);
/**@{*/
+/**
+ * @brief pause usage measure
+ */
+#ifdef RT_USING_CPU_USAGE
+rt_weak
+#endif /* RT_USING_CPU_USAGE */
+void rt_usage_measure_pause(void)
+{
+ /* do nothing in it, implemented in another file */
+}
+/**
+ * @brief start usage measure
+ *
+ * @param from wait to turn on
+ * @param to turn to be
+ */
+#ifdef RT_USING_CPU_USAGE
+rt_weak
+#endif /* RT_USING_CPU_USAGE */
+void rt_usage_measure_start(struct rt_thread *from, struct rt_thread *to)
+{
+ /* do nothing in it, implemented in another file */
+}
+
/**
* @brief This function will set a hook function, which will be invoked when thread
* switch happens.
@@ -857,7 +881,8 @@ void rt_schedule(void)
cpu_id, RT_SCHED_PRIV(to_thread).current_priority,
RT_NAME_MAX, to_thread->parent.name, to_thread->sp,
RT_NAME_MAX, current_thread->parent.name, current_thread->sp);
-
+ rt_usage_measure_pause();
+ rt_usage_measure_start(current_thread,to_thread);
rt_hw_context_switch((rt_ubase_t)¤t_thread->sp,
(rt_ubase_t)&to_thread->sp, to_thread);
}