Skip to content

Commit ce5828b

Browse files
committed
SystemView OK
1 parent 114563d commit ce5828b

File tree

94 files changed

+34645
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+34645
-4
lines changed

Core/Src/main.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
/* USER CODE BEGIN Includes */
2626
#include "stdio.h"
2727
#include "string.h"
28+
#include "SEGGER_SYSVIEW.h"
2829
/* USER CODE END Includes */
2930

3031
/* Private typedef -----------------------------------------------------------*/
@@ -46,6 +47,8 @@
4647

4748
/* USER CODE BEGIN PV */
4849
char log_buf[50];
50+
volatile unsigned int _TestFunc0Cnt;
51+
volatile unsigned int _TestFunc1Cnt;
4952
/* USER CODE END PV */
5053

5154
/* Private function prototypes -----------------------------------------------*/
@@ -56,7 +59,30 @@ void SystemClock_Config(void);
5659

5760
/* Private user code ---------------------------------------------------------*/
5861
/* USER CODE BEGIN 0 */
62+
static char* _TestFunc2(char* str)
63+
{
64+
SEGGER_SYSVIEW_RecordString(35, str);
65+
HAL_Delay(5);
66+
SEGGER_SYSVIEW_RecordEndCall(35);
67+
return "_TestFunc2 end";
68+
}
69+
70+
static void _TestFunc1(void)
71+
{
72+
SEGGER_SYSVIEW_RecordVoid(34);
73+
_TestFunc2("_TestFunc2 start");
74+
HAL_Delay(10);
75+
SEGGER_SYSVIEW_RecordEndCall(34);
76+
}
5977

78+
static void _TestFunc0(void)
79+
{
80+
SEGGER_SYSVIEW_RecordVoid(33);
81+
HAL_Delay(10);
82+
_TestFunc1();
83+
HAL_Delay(10);
84+
SEGGER_SYSVIEW_RecordEndCall(33);
85+
}
6086
/* USER CODE END 0 */
6187

6288
/**
@@ -83,7 +109,9 @@ int main(void)
83109
SystemClock_Config();
84110

85111
/* USER CODE BEGIN SysInit */
86-
112+
SEGGER_SYSVIEW_Conf();
113+
SEGGER_SYSVIEW_Start();
114+
SEGGER_SYSVIEW_OnIdle();
87115
/* USER CODE END SysInit */
88116

89117
/* Initialize all configured peripherals */
@@ -101,6 +129,7 @@ int main(void)
101129
{
102130
HAL_Delay(1000);
103131
HAL_UART_Transmit(&huart1, (uint8_t*)log_buf, strlen(log_buf), 100);
132+
_TestFunc0();
104133
/* USER CODE END WHILE */
105134

106135
/* USER CODE BEGIN 3 */

MDK-ARM/STM32V6_systemview_demo.uvoptx

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@
476476

477477
<Group>
478478
<GroupName>Drivers/CMSIS</GroupName>
479-
<tvExp>0</tvExp>
479+
<tvExp>1</tvExp>
480480
<tvExpOptDlg>0</tvExpOptDlg>
481481
<cbSel>0</cbSel>
482482
<RteFlg>0</RteFlg>
@@ -494,6 +494,50 @@
494494
</File>
495495
</Group>
496496

497+
<Group>
498+
<GroupName>SystemView</GroupName>
499+
<tvExp>1</tvExp>
500+
<tvExpOptDlg>0</tvExpOptDlg>
501+
<cbSel>0</cbSel>
502+
<RteFlg>0</RteFlg>
503+
<File>
504+
<GroupNumber>5</GroupNumber>
505+
<FileNumber>24</FileNumber>
506+
<FileType>1</FileType>
507+
<tvExp>1</tvExp>
508+
<tvExpOptDlg>0</tvExpOptDlg>
509+
<bDave2>0</bDave2>
510+
<PathWithFileName>..\ThirdUtils\SystemView\Sample\NoOS\Config\Cortex-M\SEGGER_SYSVIEW_Config_NoOS.c</PathWithFileName>
511+
<FilenameWithoutPath>SEGGER_SYSVIEW_Config_NoOS.c</FilenameWithoutPath>
512+
<RteFlg>0</RteFlg>
513+
<bShared>0</bShared>
514+
</File>
515+
<File>
516+
<GroupNumber>5</GroupNumber>
517+
<FileNumber>25</FileNumber>
518+
<FileType>1</FileType>
519+
<tvExp>0</tvExp>
520+
<tvExpOptDlg>0</tvExpOptDlg>
521+
<bDave2>0</bDave2>
522+
<PathWithFileName>..\ThirdUtils\SystemView\SEGGER\SEGGER_RTT.c</PathWithFileName>
523+
<FilenameWithoutPath>SEGGER_RTT.c</FilenameWithoutPath>
524+
<RteFlg>0</RteFlg>
525+
<bShared>0</bShared>
526+
</File>
527+
<File>
528+
<GroupNumber>5</GroupNumber>
529+
<FileNumber>26</FileNumber>
530+
<FileType>1</FileType>
531+
<tvExp>0</tvExp>
532+
<tvExpOptDlg>0</tvExpOptDlg>
533+
<bDave2>0</bDave2>
534+
<PathWithFileName>..\ThirdUtils\SystemView\SEGGER\SEGGER_SYSVIEW.c</PathWithFileName>
535+
<FilenameWithoutPath>SEGGER_SYSVIEW.c</FilenameWithoutPath>
536+
<RteFlg>0</RteFlg>
537+
<bShared>0</bShared>
538+
</File>
539+
</Group>
540+
497541
<Group>
498542
<GroupName>::CMSIS</GroupName>
499543
<tvExp>0</tvExp>

MDK-ARM/STM32V6_systemview_demo.uvprojx

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@
327327
<uThumb>0</uThumb>
328328
<uSurpInc>0</uSurpInc>
329329
<uC99>1</uC99>
330-
<uGnu>0</uGnu>
330+
<uGnu>1</uGnu>
331331
<useXO>0</useXO>
332332
<v6Lang>5</v6Lang>
333333
<v6LangP>3</v6LangP>
@@ -340,7 +340,7 @@
340340
<MiscControls></MiscControls>
341341
<Define>USE_HAL_DRIVER,STM32F429xx</Define>
342342
<Undefine></Undefine>
343-
<IncludePath>../Core/Inc;C:/Users/dengjunde/STM32Cube/Repository/STM32Cube_FW_F4_V1.28.0/Drivers/STM32F4xx_HAL_Driver/Inc;C:/Users/dengjunde/STM32Cube/Repository/STM32Cube_FW_F4_V1.28.0/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy;C:/Users/dengjunde/STM32Cube/Repository/STM32Cube_FW_F4_V1.28.0/Drivers/CMSIS/Device/ST/STM32F4xx/Include;C:/Users/dengjunde/STM32Cube/Repository/STM32Cube_FW_F4_V1.28.0/Drivers/CMSIS/Include</IncludePath>
343+
<IncludePath>../Core/Inc;C:/Users/dengjunde/STM32Cube/Repository/STM32Cube_FW_F4_V1.28.0/Drivers/STM32F4xx_HAL_Driver/Inc;C:/Users/dengjunde/STM32Cube/Repository/STM32Cube_FW_F4_V1.28.0/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy;C:/Users/dengjunde/STM32Cube/Repository/STM32Cube_FW_F4_V1.28.0/Drivers/CMSIS/Device/ST/STM32F4xx/Include;C:/Users/dengjunde/STM32Cube/Repository/STM32Cube_FW_F4_V1.28.0/Drivers/CMSIS/Include;..\ThirdUtils\SystemView\Config;..\ThirdUtils\SystemView\SEGGER</IncludePath>
344344
</VariousControls>
345345
</Cads>
346346
<Aads>
@@ -516,6 +516,26 @@
516516
</File>
517517
</Files>
518518
</Group>
519+
<Group>
520+
<GroupName>SystemView</GroupName>
521+
<Files>
522+
<File>
523+
<FileName>SEGGER_SYSVIEW_Config_NoOS.c</FileName>
524+
<FileType>1</FileType>
525+
<FilePath>..\ThirdUtils\SystemView\Sample\NoOS\Config\Cortex-M\SEGGER_SYSVIEW_Config_NoOS.c</FilePath>
526+
</File>
527+
<File>
528+
<FileName>SEGGER_RTT.c</FileName>
529+
<FileType>1</FileType>
530+
<FilePath>..\ThirdUtils\SystemView\SEGGER\SEGGER_RTT.c</FilePath>
531+
</File>
532+
<File>
533+
<FileName>SEGGER_SYSVIEW.c</FileName>
534+
<FileType>1</FileType>
535+
<FilePath>..\ThirdUtils\SystemView\SEGGER\SEGGER_SYSVIEW.c</FilePath>
536+
</File>
537+
</Files>
538+
</Group>
519539
<Group>
520540
<GroupName>::CMSIS</GroupName>
521541
</Group>
@@ -536,4 +556,13 @@
536556
<files/>
537557
</RTE>
538558

559+
<LayerInfo>
560+
<Layers>
561+
<Layer>
562+
<LayName>STM32V6_systemview_demo</LayName>
563+
<LayPrjMark>1</LayPrjMark>
564+
</Layer>
565+
</Layers>
566+
</LayerInfo>
567+
539568
</Project>

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
## 参考
2+
1. `SystemView`安装路径: `SystemView/Doc/UM08027_SystemView.pdf`;
3+
2. [官方文档:Use_SystemView_without_RTOS](https://wiki.segger.com/Use_SystemView_without_RTOS);
4+
5+
## 移植
6+
1.`SystemView`安装路径下的`SystemView/Src`文件夹复制到工程中;
7+
2. 将如下头文件路径添加到工程:
8+
```c
9+
SystemView/Config // SystemView/Src/Config
10+
SystemView/SEGGER // SystemView/Src/SEGGER
11+
```
12+
3. 将如下源文件添加到工程:
13+
```c
14+
SystemView/Sample/NoOS/Config/Cortex-M/SEGGER_SYSVIEW_Config_NoOS.c
15+
SystemView/SEGGER/SEGGER_RTT.c
16+
SystemView/SEGGER/SEGGER_SYSVIEW.c
17+
```
18+
4.`MDK --> Options for Target --> C/C++`中,使能`GNU extensions`;
19+
5.`SEGGER_SYSVIEW_Conf.h`中添加如下定义:
20+
```c
21+
// 注意:在 SEGGER_SYSVIEW_ConfDefaults.h 文件中,已经有如下定义:
22+
// #define SEGGER_SYSVIEW_CORE_OTHER 0
23+
// #define SEGGER_SYSVIEW_CORE_CM0 1 // Cortex-M0/M0+/M1
24+
// #define SEGGER_SYSVIEW_CORE_CM3 2 // Cortex-M3/M4/M7
25+
// #define SEGGER_SYSVIEW_CORE_RX 3 // Renesas RX
26+
27+
#define SEGGER_SYSVIEW_CORE SEGGER_SYSVIEW_CORE_CM3
28+
```
29+
6. 按照`[main.c](./Core/Src/main.c)`的方式使用`SystemView``API`即可;
30+
7. 编译并烧录运行,然后在电脑上打开`SystemView`,并点击左上角工具栏中的绿色三角形即可;
31+
32+
## 说明
33+
1. 必须使用`J-Link`才能使用`SystemView`;
34+
2. `JLink`只需要通过`SWDIO``SWCLK`以及`GND`三根线和`MCU`连接;

ThirdUtils/SystemView/Config/Global.h

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*********************************************************************
2+
* SEGGER Microcontroller GmbH *
3+
* The Embedded Experts *
4+
**********************************************************************
5+
* *
6+
* (c) 1995 - 2024 SEGGER Microcontroller GmbH *
7+
* *
8+
* www.segger.com Support: [email protected] *
9+
* *
10+
**********************************************************************
11+
* *
12+
* SEGGER SystemView * Real-time application analysis *
13+
* *
14+
**********************************************************************
15+
* *
16+
* All rights reserved. *
17+
* *
18+
* SEGGER strongly recommends to not make any changes *
19+
* to or modify the source code of this software in order to stay *
20+
* compatible with the SystemView and RTT protocol, and J-Link. *
21+
* *
22+
* Redistribution and use in source and binary forms, with or *
23+
* without modification, are permitted provided that the following *
24+
* condition is met: *
25+
* *
26+
* o Redistributions of source code must retain the above copyright *
27+
* notice, this condition and the following disclaimer. *
28+
* *
29+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
30+
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
31+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
32+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
33+
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
34+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
35+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
36+
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
37+
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
38+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
39+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
40+
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
41+
* DAMAGE. *
42+
* *
43+
**********************************************************************
44+
* *
45+
* SystemView version: 3.56 *
46+
* *
47+
**********************************************************************
48+
----------------------------------------------------------------------
49+
File : Global.h
50+
Purpose : Global types
51+
In case your application already has a Global.h, you should
52+
merge the files. In order to use Segger code, the types
53+
U8, U16, U32, I8, I16, I32 need to be defined in Global.h;
54+
additional definitions do not hurt.
55+
Revision: $Rev: 12501 $
56+
---------------------------END-OF-HEADER------------------------------
57+
*/
58+
59+
#ifndef GLOBAL_H // Guard against multiple inclusion
60+
#define GLOBAL_H
61+
62+
#define U8 unsigned char
63+
#define I8 signed char
64+
#define U16 unsigned short
65+
#define I16 signed short
66+
#ifdef __x86_64__
67+
#define U32 unsigned
68+
#define I32 int
69+
#else
70+
#define U32 unsigned long
71+
#define I32 signed long
72+
#endif
73+
74+
//
75+
// CC_NO_LONG_SUPPORT can be defined to compile test
76+
// without long support for compilers that do not
77+
// support C99 and its long type.
78+
//
79+
#ifdef CC_NO_LONG_SUPPORT
80+
#define PTR_ADDR U32
81+
#else // Supports long type.
82+
#if defined(_WIN32) && !defined(__clang__) && !defined(__MINGW32__)
83+
//
84+
// Microsoft VC6 compiler related
85+
//
86+
#define U64 unsigned __int64
87+
#define U128 unsigned __int128
88+
#define I64 __int64
89+
#define I128 __int128
90+
#if _MSC_VER <= 1200
91+
#define U64_C(x) x##UI64
92+
#else
93+
#define U64_C(x) x##ULL
94+
#endif
95+
#else
96+
//
97+
// C99 compliant compiler
98+
//
99+
#define U64 unsigned long long
100+
#define I64 signed long long
101+
#define U64_C(x) x##ULL
102+
#endif
103+
104+
#if (defined(_WIN64) || defined(__LP64__)) // 64-bit symbols used by Visual Studio and GCC, maybe others as well.
105+
#define PTR_ADDR U64
106+
#else
107+
#define PTR_ADDR U32
108+
#endif
109+
#endif // Supports long type.
110+
111+
#endif // Avoid multiple inclusion
112+
113+
/*************************** End of file ****************************/

0 commit comments

Comments
 (0)