Skip to content

Commit 7160849

Browse files
xjzBejingpkarashchenko
authored andcommitted
new feature on trace dump support segger-rtt
Signed-off-by: xiajizhong <[email protected]>
1 parent 120c4a1 commit 7160849

File tree

6 files changed

+362
-23
lines changed

6 files changed

+362
-23
lines changed

drivers/note/note_initialize.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <nuttx/note/noteram_driver.h>
2727
#include <nuttx/note/notectl_driver.h>
2828
#include <nuttx/note/notesnap_driver.h>
29+
#include <nuttx/segger/note_rtt.h>
2930
#include <nuttx/segger/sysview.h>
3031

3132
/****************************************************************************
@@ -59,6 +60,14 @@ int note_initialize(void)
5960
}
6061
#endif
6162

63+
#ifdef CONFIG_NOTE_RTT
64+
ret = notertt_register();
65+
if (ret < 0)
66+
{
67+
return ret;
68+
}
69+
#endif
70+
6271
#ifdef CONFIG_DRIVERS_NOTECTL
6372
ret = notectl_register();
6473
if (ret < 0)

drivers/segger/Kconfig

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,29 @@ config SERIAL_RTT_CONSOLE
174174
endif # SERIAL_RTT
175175

176176
if DRIVERS_NOTE
177+
178+
config NOTE_RTT
179+
bool "Note RTT driver, write note into Segger J-Link RTTLog"
180+
default n
181+
---help---
182+
If this option is selected, then jlink rtt is enabled to capture
183+
scheduler instrumentation data.
184+
185+
if NOTE_RTT
186+
187+
config NOTE_RTT_CHANNEL
188+
int "Note RTT driver, Segger J-Link stream channel"
189+
default 0
190+
---help---
191+
Channel of notertt jlink stream channel
192+
193+
config NOTE_RTT_BUFFER_SIZE_UP
194+
int "Note RTT driver, Segger J-Link buffer size"
195+
default 1024
196+
---help---
197+
Buffer size config for notertt jlink config buffer
198+
endif # NOTE_RTT
199+
177200
config SEGGER_SYSVIEW
178201
bool "Note SEGGER SystemView driver"
179202
select SEGGER_RTT
@@ -185,8 +208,6 @@ config SEGGER_SYSVIEW
185208
systems comprising multiple threads and interrupts. SystemView can ensure
186209
unintended interactions and resource conflicts.
187210

188-
endif # DRIVERS_NOTE
189-
190211
if SEGGER_SYSVIEW
191212

192213
config SEGGER_SYSVIEW_RTT_CHANNEL
@@ -206,7 +227,8 @@ config SEGGER_SYSVIEW_RAM_BASE
206227
default 0
207228
---help---
208229
The lowest RAM address used for IDs
230+
endif # SEGGER_SYSVIEW
209231

210-
endif
232+
endif # DRIVERS_NOTE
211233

212234
endmenu # Segger RTT drivers

drivers/segger/Make.defs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ ifeq ($(CONFIG_SYSLOG_RTT),y)
6565
CSRCS += segger/syslog_rtt.c
6666
endif
6767

68+
ifeq ($(CONFIG_NOTE_RTT),y)
69+
CSRCS += segger/note_rtt.c
70+
endif
71+
6872
ifeq ($(CONFIG_SERIAL_RTT),y)
6973
CSRCS += segger/serial_rtt.c
7074
endif

drivers/segger/note_rtt.c

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/****************************************************************************
2+
* drivers/segger/note_rtt.c
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one or more
5+
* contributor license agreements. See the NOTICE file distributed with
6+
* this work for additional information regarding copyright ownership. The
7+
* ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance with the
9+
* License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
* License for the specific language governing permissions and limitations
17+
* under the License.
18+
*
19+
****************************************************************************/
20+
21+
/****************************************************************************
22+
* Included Files
23+
****************************************************************************/
24+
25+
#include <nuttx/note/note_driver.h>
26+
#include <nuttx/segger/note_rtt.h>
27+
#include <nuttx/segger/rtt.h>
28+
29+
/****************************************************************************
30+
* Private Types
31+
****************************************************************************/
32+
33+
struct notertt_s
34+
{
35+
struct note_driver_s driver;
36+
struct lib_rttoutstream_s stream;
37+
};
38+
39+
/****************************************************************************
40+
* Private Function Prototypes
41+
****************************************************************************/
42+
43+
static void notertt_add(FAR struct note_driver_s *drv,
44+
FAR const void *note, size_t len);
45+
46+
/****************************************************************************
47+
* Private Data
48+
****************************************************************************/
49+
50+
static const struct note_driver_ops_s g_notertt_ops =
51+
{
52+
notertt_add,
53+
};
54+
55+
struct notertt_s g_notertt =
56+
{
57+
{
58+
&g_notertt_ops
59+
}
60+
};
61+
62+
/****************************************************************************
63+
* Private Functions
64+
****************************************************************************/
65+
66+
/****************************************************************************
67+
* Name: notertt_add
68+
*
69+
* Description:
70+
* Put the variable length note to rttoutstream
71+
*
72+
* Input Parameters:
73+
* buf - The note buffer
74+
* notelen - The buffer length
75+
*
76+
* Returned Value:
77+
* None
78+
*
79+
****************************************************************************/
80+
81+
static void notertt_add(FAR struct note_driver_s *drv,
82+
FAR const void *buf, size_t notelen)
83+
{
84+
FAR struct notertt_s *note = (FAR struct notertt_s *)drv;
85+
lib_stream_puts(&note->stream, buf, notelen);
86+
}
87+
88+
/****************************************************************************
89+
* Name: notertt_register
90+
*
91+
* Description:
92+
* Register a serial driver using note_driver_register
93+
*
94+
* Input Parameters:
95+
* None.
96+
*
97+
* Returned Value:
98+
* Zero on succress. A negated errno value is returned on a failure.
99+
*
100+
****************************************************************************/
101+
102+
int notertt_register(void)
103+
{
104+
lib_rttoutstream_open(&g_notertt.stream,
105+
CONFIG_NOTE_RTT_CHANNEL,
106+
CONFIG_NOTE_RTT_BUFFER_SIZE_UP);
107+
return note_driver_register(&g_notertt.driver);
108+
}

include/nuttx/segger/note_rtt.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/****************************************************************************
2+
* include/nuttx/segger/note_rtt.h
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one or more
5+
* contributor license agreements. See the NOTICE file distributed with
6+
* this work for additional information regarding copyright ownership. The
7+
* ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance with the
9+
* License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
* License for the specific language governing permissions and limitations
17+
* under the License.
18+
*
19+
****************************************************************************/
20+
21+
#ifndef __INCLUDE_NUTTX_SEGGER_NOTE_RTT_H
22+
#define __INCLUDE_NUTTX_SEGGER_NOTE_RTT_H
23+
24+
/****************************************************************************
25+
* Name: notertt_register
26+
*
27+
* Description:
28+
* Register RTT note driver
29+
*
30+
* Input Parameters:
31+
* None.
32+
*
33+
* Returned Value:
34+
* Zero on success. A negated errno value is returned on a failure.
35+
*
36+
****************************************************************************/
37+
38+
#ifdef CONFIG_NOTE_RTT
39+
int notertt_register(void);
40+
#endif
41+
42+
#endif /* __INCLUDE_NUTTX_SEGGER_NOTE_RTT_H */

0 commit comments

Comments
 (0)