Skip to content

Commit 81694a2

Browse files
ccoenenatbaumercarlescufi
authored andcommitted
segger: Resolve circular include dependencies
Zephyr kernel is dependent on trace. Trace is dependent on segger rtt. Segger rtt MUST NOT be dependent on zephyr kernel. Move lock functions from header into c file to avoid circular dependency. This fix needs an update of the segger repository. Fixes #43887. Signed-off-by: Christoph Coenen <[email protected]>
1 parent 3c35faa commit 81694a2

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

drivers/serial/uart_rtt.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
#define DT_DRV_COMPAT segger_rtt_uart
1111

12+
extern struct k_mutex rtt_term_mutex;
13+
1214
struct uart_rtt_config {
1315
void *up_buffer;
1416
size_t up_size;

modules/segger/SEGGER_RTT_zephyr.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
#include <zephyr/kernel.h>
8+
#include <zephyr/irq.h>
89
#include <zephyr/init.h>
910
#include "SEGGER_RTT.h"
1011

@@ -30,4 +31,30 @@ static int rtt_init(const struct device *unused)
3031
return 0;
3132
}
3233

34+
#ifdef CONFIG_MULTITHREADING
35+
36+
void zephyr_rtt_mutex_lock(void)
37+
{
38+
k_mutex_lock(&rtt_term_mutex, K_FOREVER);
39+
}
40+
41+
void zephyr_rtt_mutex_unlock(void)
42+
{
43+
k_mutex_unlock(&rtt_term_mutex);
44+
}
45+
46+
#endif /* CONFIG_MULTITHREADING */
47+
48+
unsigned int zephyr_rtt_irq_lock(void)
49+
{
50+
return irq_lock();
51+
}
52+
53+
void zephyr_rtt_irq_unlock(unsigned int key)
54+
{
55+
irq_unlock(key);
56+
}
57+
58+
59+
3360
SYS_INIT(rtt_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_OBJECTS);

modules/segger/SEGGER_SYSVIEW_Conf.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#define SEGGER_SEGGER_SYSVIEW_CONF_H_
99

1010
#include <stdint.h>
11-
#include <zephyr/irq.h>
1211

1312
#define SEGGER_SYSVIEW_GET_TIMESTAMP sysview_get_timestamp
1413
#define SEGGER_SYSVIEW_GET_INTERRUPT_ID sysview_get_interrupt
@@ -23,13 +22,16 @@ uint32_t sysview_get_interrupt(void);
2322
#define SEGGER_SYSVIEW_SECTION ".dtcm_data"
2423
#endif
2524

25+
extern unsigned int zephyr_rtt_irq_lock(void);
26+
extern void zephyr_rtt_irq_unlock(unsigned int key);
27+
2628
/* Lock SystemView (nestable) */
2729
#define SEGGER_SYSVIEW_LOCK() { \
2830
unsigned int __sysview_irq_key = \
29-
irq_lock()
31+
zephyr_rtt_irq_lock()
3032

3133
/* Unlock SystemView (nestable) */
32-
#define SEGGER_SYSVIEW_UNLOCK() irq_unlock(__sysview_irq_key); \
34+
#define SEGGER_SYSVIEW_UNLOCK() zephyr_rtt_irq_unlock(__sysview_irq_key); \
3335
}
3436

3537
#endif /* SEGGER_SEGGER_SYSVIEW_CONF_H_ */

west.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ manifest:
200200
path: modules/lib/picolibc
201201
revision: e87b2fc37345a62361478f0a6efd140e14180ba5
202202
- name: segger
203-
revision: 3a52ab222133193802d3c3b4d21730b9b1f1d2f6
203+
revision: d4e568a920b4bd087886170a5624c167b2d0665e
204204
path: modules/debug/segger
205205
groups:
206206
- debug

0 commit comments

Comments
 (0)