drivers/syslog: Implement RTT based log channel
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
95542f193b
commit
01b791d773
@ -38,7 +38,8 @@ config SEGGER_RTT_MAX_NUM_DOWN_BUFFERS
|
|||||||
|
|
||||||
config SEGGER_RTT_BUFFER_SIZE_UP
|
config SEGGER_RTT_BUFFER_SIZE_UP
|
||||||
int "Segger RTT UP Buffer Size"
|
int "Segger RTT UP Buffer Size"
|
||||||
default 1024
|
default 1024 if SYSLOG_RTT
|
||||||
|
default 1 if !SYSLOG_RTT
|
||||||
---help---
|
---help---
|
||||||
Size of the buffer for terminal output of target, up to host
|
Size of the buffer for terminal output of target, up to host
|
||||||
|
|
||||||
|
@ -45,6 +45,10 @@ TARGET_ZIP += $(SGDIR)/RTT.zip
|
|||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_SYSLOG_RTT),y)
|
||||||
|
CSRCS += segger/syslog_rtt.c
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_SEGGER_SYSVIEW),y)
|
ifeq ($(CONFIG_SEGGER_SYSVIEW),y)
|
||||||
CSRCS += segger/note_sysview.c
|
CSRCS += segger/note_sysview.c
|
||||||
CSRCS += segger/SystemView/SYSVIEW/SEGGER_SYSVIEW.c
|
CSRCS += segger/SystemView/SYSVIEW/SEGGER_SYSVIEW.c
|
||||||
|
45
drivers/segger/syslog_rtt.c
Normal file
45
drivers/segger/syslog_rtt.c
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* drivers/segger/syslog_rtt.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <nuttx/syslog/syslog_rtt.h>
|
||||||
|
|
||||||
|
#include <SEGGER_RTT.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int syslog_rtt_putc(FAR struct syslog_channel_s *channel, int ch)
|
||||||
|
{
|
||||||
|
SEGGER_RTT_PutChar(0, ch);
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
ssize_t syslog_rtt_write(FAR struct syslog_channel_s *channel,
|
||||||
|
FAR const char *buffer, size_t buflen)
|
||||||
|
{
|
||||||
|
return SEGGER_RTT_Write(0, buffer, buflen);
|
||||||
|
}
|
@ -203,16 +203,23 @@ config SYSLOG_RPMSG
|
|||||||
---help---
|
---help---
|
||||||
Use the rpmsg as a SYSLOG output device, send message to remote proc.
|
Use the rpmsg as a SYSLOG output device, send message to remote proc.
|
||||||
|
|
||||||
|
config SYSLOG_RTT
|
||||||
|
bool "Log to Segger J-Link RTT"
|
||||||
|
select SEGGER_RTT
|
||||||
|
default n
|
||||||
|
---help---
|
||||||
|
Use Segger J-Link RTT as a SYSLOG output device.
|
||||||
|
|
||||||
config SYSLOG_CONSOLE
|
config SYSLOG_CONSOLE
|
||||||
bool "Log to /dev/console"
|
bool "Log to /dev/console"
|
||||||
default !ARCH_LOWPUTC && !SYSLOG_CHAR && !RAMLOG_SYSLOG && !SYSLOG_RPMSG
|
default !ARCH_LOWPUTC && !SYSLOG_CHAR && !RAMLOG_SYSLOG && !SYSLOG_RPMSG && !SYSLOG_RTT
|
||||||
depends on DEV_CONSOLE
|
depends on DEV_CONSOLE
|
||||||
---help---
|
---help---
|
||||||
Use the system console as a SYSLOG output device.
|
Use the system console as a SYSLOG output device.
|
||||||
|
|
||||||
config SYSLOG_DEFAULT
|
config SYSLOG_DEFAULT
|
||||||
bool "Default SYSLOG device"
|
bool "Default SYSLOG device"
|
||||||
default ARCH_LOWPUTC && !SYSLOG_CHAR && !RAMLOG_SYSLOG && !SYSLOG_RPMSG && !SYSLOG_CONSOLE
|
default ARCH_LOWPUTC && !SYSLOG_CHAR && !RAMLOG_SYSLOG && !SYSLOG_RPMSG && !SYSLOG_RTT && !SYSLOG_CONSOLE
|
||||||
---help---
|
---help---
|
||||||
syslog() interfaces will be present, but all output will go to the
|
syslog() interfaces will be present, but all output will go to the
|
||||||
up_putc(ARCH_LOWPUTC == y) or bit-bucket(ARCH_LOWPUTC == n).
|
up_putc(ARCH_LOWPUTC == y) or bit-bucket(ARCH_LOWPUTC == n).
|
||||||
|
@ -40,6 +40,10 @@
|
|||||||
# include <nuttx/syslog/syslog_rpmsg.h>
|
# include <nuttx/syslog/syslog_rpmsg.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_SYSLOG_RTT
|
||||||
|
# include <nuttx/syslog/syslog_rtt.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_LOWPUTC
|
#ifdef CONFIG_ARCH_LOWPUTC
|
||||||
# include <nuttx/arch.h>
|
# include <nuttx/arch.h>
|
||||||
#endif
|
#endif
|
||||||
@ -95,6 +99,21 @@ static struct syslog_channel_s g_rpmsg_channel =
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_SYSLOG_RTT)
|
||||||
|
static const struct syslog_channel_ops_s g_rtt_channel_ops =
|
||||||
|
{
|
||||||
|
syslog_rtt_putc,
|
||||||
|
syslog_rtt_putc,
|
||||||
|
NULL,
|
||||||
|
syslog_rtt_write
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct syslog_channel_s g_rtt_channel =
|
||||||
|
{
|
||||||
|
&g_rtt_channel_ops
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_SYSLOG_DEFAULT)
|
#if defined(CONFIG_SYSLOG_DEFAULT)
|
||||||
# if defined(CONFIG_ARCH_LOWPUTC)
|
# if defined(CONFIG_ARCH_LOWPUTC)
|
||||||
static sem_t g_syslog_default_sem = SEM_INITIALIZER(1);
|
static sem_t g_syslog_default_sem = SEM_INITIALIZER(1);
|
||||||
@ -128,7 +147,11 @@ FAR struct syslog_channel_s
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_SYSLOG_RPMSG)
|
#if defined(CONFIG_SYSLOG_RPMSG)
|
||||||
&g_rpmsg_channel
|
&g_rpmsg_channel,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_SYSLOG_RTT)
|
||||||
|
&g_rtt_channel
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
54
include/nuttx/syslog/syslog_rtt.h
Normal file
54
include/nuttx/syslog/syslog_rtt.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* include/nuttx/syslog/syslog_rtt.h
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __INCLUDE_NUTTX_SYSLOG_SYSLOG_RTT_H
|
||||||
|
#define __INCLUDE_NUTTX_SYSLOG_SYSLOG_RTT_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
#include <nuttx/syslog/syslog.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define EXTERN extern "C"
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#else
|
||||||
|
#define EXTERN extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_SYSLOG_RTT
|
||||||
|
int syslog_rtt_putc(FAR struct syslog_channel_s *channel, int ch);
|
||||||
|
ssize_t syslog_rtt_write(FAR struct syslog_channel_s *channel,
|
||||||
|
FAR const char *buffer, size_t buflen);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef EXTERN
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __INCLUDE_NUTTX_SYSLOG_SYSLOG_RTT_H */
|
Loading…
x
Reference in New Issue
Block a user