From a8d12f6d37d46732011e008ac8252c4a3183e182 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 12 Feb 2012 20:27:49 +0000 Subject: Fix a small RAM log bug (the RAM log still does not work) git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4385 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/TODO | 34 ++++++++++-------- nuttx/arch/arm/src/common/up_internal.h | 2 +- nuttx/arch/avr/src/at32uc3/at32uc3_config.h | 2 +- nuttx/arch/avr/src/at90usb/at90usb_config.h | 2 +- nuttx/arch/avr/src/atmega/atmega_config.h | 2 +- nuttx/arch/avr/src/common/up_initialize.c | 2 +- nuttx/arch/hc/src/common/up_internal.h | 2 +- nuttx/arch/mips/src/common/up_internal.h | 2 +- nuttx/arch/sh/src/common/up_internal.h | 2 +- nuttx/arch/sim/src/up_initialize.c | 2 +- nuttx/arch/x86/src/common/up_internal.h | 2 +- nuttx/arch/z16/src/common/up_internal.h | 2 +- nuttx/configs/stm3240g-eval/nsh/defconfig | 32 +++++++++++++++++ nuttx/configs/stm3240g-eval/nsh2/defconfig | 4 +-- nuttx/drivers/ramlog.c | 55 +++++++++++++---------------- nuttx/lib/stdio/lib_syslogstream.c | 2 +- 16 files changed, 90 insertions(+), 59 deletions(-) diff --git a/nuttx/TODO b/nuttx/TODO index 09e24221f..8b66c4975 100644 --- a/nuttx/TODO +++ b/nuttx/TODO @@ -1,4 +1,4 @@ -NuttX TODO List (Last updated February 2, 2012) +NuttX TODO List (Last updated February 12, 2012) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This file summarizes known NuttX bugs, limitations, inconsistencies with @@ -13,7 +13,7 @@ nuttx/ (1) pthreads (sched/) (2) C++ Support (5) Binary loaders (binfmt/) - (16) Network (net/, drivers/net) + (17) Network (net/, drivers/net) (2) USB (drivers/usbdev, drivers/usbhost) (8) Libraries (lib/) (10) File system/Generic drivers (fs/, drivers/) @@ -390,13 +390,6 @@ o Network (net/, drivers/net) Status: Open Priority: Low unless you need it. - Title: UNFINISHED ENC28J60 DRIVER - Description: So far, I have not come up with a usable hardware platform to - verify the ENC28J60 Ethernet driver (drivers/net/enc28j60.c). - So it is untested. - Status: Open - Priority: Low unless you need it. - Title: UNTESTED IGMPv2 Description: Support for client-side IGMPv2 multicast has been added but not yet tested (because I don't have a proper environment for multicast testing). @@ -437,6 +430,13 @@ o Network (net/, drivers/net) Status: Open Priority: Low... fix defconfig files as necessary. + Title: UNFINISHED ENC28J60 DRIVER + Description: So far, I have not come up with a usable hardware platform to + verify the ENC28J60 Ethernet driver (drivers/net/enc28j60.c). + So it is untested. + Status: Open + Priority: Low unless you need it. + o USB (drivers/usbdev, drivers/usbhost) ^^^^^^^^^^^^^^^^^^^^ @@ -584,12 +584,6 @@ o File system / Generic drivers (fs/, drivers/) Status: Open Priority: Low - Title: ENC29J60 DRIVER UNTESTED - Description: ENC28J60 driver is complete, but untested (I still haven't got - a good ENC28J60 test platform). - Status: Open - Priority: Low - Title: SERIAL DRIVER DOES NOT RETURN WHEN SIGNAL RECEIVED Description: The serial driver (drivers/serial) should return with an error and errno=EINTR when an interrupt is received. However, @@ -611,6 +605,16 @@ o File system / Generic drivers (fs/, drivers/) Status: Open Priority: Medium-Low + Title: CONFIG_RAMLOG_CONSOLE/SYSLOG DOES NOT WORK + Description: When I enable CONFIG_RAMLOG_CONSOLE, the system does not come up + property (using configuration stm3240g-eval/nsh2). Apparently the + RAM logging console is non-functional(and difficult to debug with + no console). If I enabled CONFIG_RAMLOG_SYSLOG, the system comes + up, but If I enable CONFIG_DEBUG, it again hangs. Apparently any + kind of early output is fatal. + Status: Open + Priority: Medium/high + o Graphics subystem (graphics/) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/nuttx/arch/arm/src/common/up_internal.h b/nuttx/arch/arm/src/common/up_internal.h index c1c7ed9a6..79dc3f7d9 100644 --- a/nuttx/arch/arm/src/common/up_internal.h +++ b/nuttx/arch/arm/src/common/up_internal.h @@ -81,7 +81,7 @@ # endif #endif -/* Determine which device to use as the system loggin device */ +/* Determine which device to use as the system logging device */ #ifndef CONFIG_SYSLOG # undef CONFIG_RAMLOG_SYSLOG diff --git a/nuttx/arch/avr/src/at32uc3/at32uc3_config.h b/nuttx/arch/avr/src/at32uc3/at32uc3_config.h index 543b4e752..edd19985a 100644 --- a/nuttx/arch/avr/src/at32uc3/at32uc3_config.h +++ b/nuttx/arch/avr/src/at32uc3/at32uc3_config.h @@ -168,7 +168,7 @@ # endif #endif -/* Determine which device to use as the system loggin device */ +/* Determine which device to use as the system logging device */ #ifndef CONFIG_SYSLOG # undef CONFIG_RAMLOG_SYSLOG diff --git a/nuttx/arch/avr/src/at90usb/at90usb_config.h b/nuttx/arch/avr/src/at90usb/at90usb_config.h index 644005d5b..8beef94bc 100644 --- a/nuttx/arch/avr/src/at90usb/at90usb_config.h +++ b/nuttx/arch/avr/src/at90usb/at90usb_config.h @@ -87,7 +87,7 @@ # endif #endif -/* Determine which device to use as the system loggin device */ +/* Determine which device to use as the system logging device */ #ifndef CONFIG_SYSLOG # undef CONFIG_RAMLOG_SYSLOG diff --git a/nuttx/arch/avr/src/atmega/atmega_config.h b/nuttx/arch/avr/src/atmega/atmega_config.h index 39ab53e4b..be89234c9 100644 --- a/nuttx/arch/avr/src/atmega/atmega_config.h +++ b/nuttx/arch/avr/src/atmega/atmega_config.h @@ -92,7 +92,7 @@ # endif #endif -/* Determine which device to use as the system loggin device */ +/* Determine which device to use as the system logging device */ #ifndef CONFIG_SYSLOG # undef CONFIG_RAMLOG_SYSLOG diff --git a/nuttx/arch/avr/src/common/up_initialize.c b/nuttx/arch/avr/src/common/up_initialize.c index 7f53ab8ae..58d243ee5 100644 --- a/nuttx/arch/avr/src/common/up_initialize.c +++ b/nuttx/arch/avr/src/common/up_initialize.c @@ -78,7 +78,7 @@ # endif #endif -/* Determine which device to use as the system loggin device */ +/* Determine which device to use as the system logging device */ #ifndef CONFIG_SYSLOG # undef CONFIG_RAMLOG_SYSLOG diff --git a/nuttx/arch/hc/src/common/up_internal.h b/nuttx/arch/hc/src/common/up_internal.h index f4574bf20..5c22e50a1 100755 --- a/nuttx/arch/hc/src/common/up_internal.h +++ b/nuttx/arch/hc/src/common/up_internal.h @@ -81,7 +81,7 @@ # endif #endif -/* Determine which device to use as the system loggin device */ +/* Determine which device to use as the system logging device */ #ifndef CONFIG_SYSLOG # undef CONFIG_RAMLOG_SYSLOG diff --git a/nuttx/arch/mips/src/common/up_internal.h b/nuttx/arch/mips/src/common/up_internal.h index bdc8bace1..62f9b8402 100755 --- a/nuttx/arch/mips/src/common/up_internal.h +++ b/nuttx/arch/mips/src/common/up_internal.h @@ -81,7 +81,7 @@ # endif #endif -/* Determine which device to use as the system loggin device */ +/* Determine which device to use as the system logging device */ #ifndef CONFIG_SYSLOG # undef CONFIG_RAMLOG_SYSLOG diff --git a/nuttx/arch/sh/src/common/up_internal.h b/nuttx/arch/sh/src/common/up_internal.h index 9d0517c8b..083beea59 100644 --- a/nuttx/arch/sh/src/common/up_internal.h +++ b/nuttx/arch/sh/src/common/up_internal.h @@ -85,7 +85,7 @@ # endif #endif -/* Determine which device to use as the system loggin device */ +/* Determine which device to use as the system logging device */ #ifndef CONFIG_SYSLOG # undef CONFIG_RAMLOG_SYSLOG diff --git a/nuttx/arch/sim/src/up_initialize.c b/nuttx/arch/sim/src/up_initialize.c index a850d7c69..488f2431e 100644 --- a/nuttx/arch/sim/src/up_initialize.c +++ b/nuttx/arch/sim/src/up_initialize.c @@ -51,7 +51,7 @@ * Private Definitions ****************************************************************************/ -/* Determine which device to use as the system loggin device */ +/* Determine which device to use as the system logging device */ #ifndef CONFIG_SYSLOG # undef CONFIG_RAMLOG_SYSLOG diff --git a/nuttx/arch/x86/src/common/up_internal.h b/nuttx/arch/x86/src/common/up_internal.h index 4fa98e0b3..f6aa649a5 100644 --- a/nuttx/arch/x86/src/common/up_internal.h +++ b/nuttx/arch/x86/src/common/up_internal.h @@ -80,7 +80,7 @@ # endif #endif -/* Determine which device to use as the system loggin device */ +/* Determine which device to use as the system logging device */ #ifndef CONFIG_SYSLOG # undef CONFIG_RAMLOG_SYSLOG diff --git a/nuttx/arch/z16/src/common/up_internal.h b/nuttx/arch/z16/src/common/up_internal.h index 7d0aaaec8..13c524c8f 100644 --- a/nuttx/arch/z16/src/common/up_internal.h +++ b/nuttx/arch/z16/src/common/up_internal.h @@ -71,7 +71,7 @@ # define USE_EARLYSERIALINIT 1 #endif -/* Determine which device to use as the system loggin device */ +/* Determine which device to use as the system logging device */ #ifndef CONFIG_SYSLOG # undef CONFIG_RAMLOG_SYSLOG diff --git a/nuttx/configs/stm3240g-eval/nsh/defconfig b/nuttx/configs/stm3240g-eval/nsh/defconfig index 3aee571a4..712d25458 100644 --- a/nuttx/configs/stm3240g-eval/nsh/defconfig +++ b/nuttx/configs/stm3240g-eval/nsh/defconfig @@ -526,6 +526,38 @@ CONFIG_SIG_SIGWORK=4 CONFIG_SCHED_WAITPID=y CONFIG_SCHED_ATEXIT=n +# +# System Logging +# +# CONFIG_SYSLOG - Enables the System Logging feature. +# CONFIG_RAMLOG - Enables the RAM logging feature +# CONFIG_RAMLOG_CONSOLE - Use the RAM logging device as a system console. +# If this feature is enabled (along with CONFIG_DEV_CONSOLE), then all +# console output will be re-directed to a circular buffer in RAM. This +# is useful, for example, if the only console is a Telnet console. Then +# in that case, console output from non-Telnet threads will go to the +# circular buffer and can be viewed using the NSH 'dmesg' command. +# CONFIG_RAMLOG_SYSLOG - Use the RAM logging device for the syslogging +# interface. If this feature is enabled (along with CONFIG_SYSLOG), +# then all debug output (only) will be re-directed to the circular +# buffer in RAM. This RAM log can be view from NSH using the 'dmesg' +# command. +# CONFIG_RAMLOG_NPOLLWAITERS - The number of threads than can be waiting +# for this driver on poll(). Default: 4 +# +# If CONFIG_RAMLOG_CONSOLE or CONFIG_RAMLOG_SYSLOG is selected, then the +# following may also be provided: +# +# CONFIG_RAMLOG_CONSOLE_BUFSIZE - Size of the console RAM log. Default: 1024 +# + +CONFIG_SYSLOG=n +CONFIG_RAMLOG=n +CONFIG_RAMLOG_CONSOLE=n +CONFIG_RAMLOG_SYSLOG=n +#CONFIG_RAMLOG_NPOLLWAITERS +#CONFIG_RAMLOG_CONSOLE_BUFSIZE + # # Settings for NXFLAT # diff --git a/nuttx/configs/stm3240g-eval/nsh2/defconfig b/nuttx/configs/stm3240g-eval/nsh2/defconfig index bdcf5c888..3afb83151 100644 --- a/nuttx/configs/stm3240g-eval/nsh2/defconfig +++ b/nuttx/configs/stm3240g-eval/nsh2/defconfig @@ -553,8 +553,8 @@ CONFIG_SCHED_ATEXIT=n CONFIG_SYSLOG=y CONFIG_RAMLOG=y -CONFIG_RAMLOG_CONSOLE=y -CONFIG_RAMLOG_SYSLOG=y= +CONFIG_RAMLOG_CONSOLE=n +CONFIG_RAMLOG_SYSLOG=y #CONFIG_RAMLOG_NPOLLWAITERS #CONFIG_RAMLOG_CONSOLE_BUFSIZE diff --git a/nuttx/drivers/ramlog.c b/nuttx/drivers/ramlog.c index 6c24b0f95..b3dd81b65 100644 --- a/nuttx/drivers/ramlog.c +++ b/nuttx/drivers/ramlog.c @@ -136,8 +136,27 @@ static const struct file_operations g_ramlogfops = */ #if defined(CONFIG_RAMLOG_CONSOLE) || defined(CONFIG_RAMLOG_SYSLOG) -static struct ramlog_dev_s g_sysdev; -static char g_sysbuffer[CONFIG_RAMLOG_CONSOLE_BUFSIZE]; +static char g_sysbuffer[CONFIG_RAMLOG_CONSOLE_BUFSIZE]; + +/* This is the device structure for the console or syslogging function. It + * must be statically initialized because the ramlog_putc function could be + * called before the driver initialization logic executes. + */ + +static struct ramlog_dev_s g_sysdev = +{ +#ifndef CONFIG_RAMLOG_NONBLOCKING + 0, /* rl_nwaiters */ +#endif + 0, /* rl_head */ + 0, /* rl_tail */ + SEM_INITIALIZER(1), /* rl_exclsem */ +#ifndef CONFIG_RAMLOG_NONBLOCKING + SEM_INITIALIZER(0), /* rl_waitsem */ +#endif + CONFIG_RAMLOG_CONSOLE_BUFSIZE, /* rl_bufsize */ + g_sysbuffer /* rl_buffer */ +}; #endif /**************************************************************************** @@ -202,10 +221,9 @@ static int ramlog_addchar(FAR struct ramlog_dev_s *priv, char ch) if (nexthead == priv->rl_tail) { - /* Yes... then break out of the loop to return an indication that - * nothing was saved in the buffer. - */ + /* Yes... Return an indication that nothing was saved in the buffer. */ + irqrestore(flags); return -EBUSY; } @@ -667,15 +685,6 @@ int ramlog_consoleinit(void) FAR struct ramlog_dev_s *priv = &g_sysdev; int ret; - /* Initialize the RAM loggin device structure */ - - sem_init(&priv->rl_exclsem, 0, 1); -#ifndef CONFIG_RAMLOG_NONBLOCKING - sem_init(&priv->rl_waitsem, 0, 0); -#endif - priv->rl_bufsize = CONFIG_RAMLOG_CONSOLE_BUFSIZE; - priv->rl_buffer = g_sysbuffer; - /* Register the console character driver */ ret = register_driver("/dev/console", &g_ramlogfops, 0666, priv); @@ -707,18 +716,7 @@ int ramlog_consoleinit(void) #if !defined(CONFIG_RAMLOG_CONSOLE) && defined(CONFIG_RAMLOG_SYSLOG) int ramlog_sysloginit(void) { - FAR struct ramlog_dev_s *priv = &g_sysdev; - - /* Initialize the RAM loggin device structure */ - - sem_init(&priv->rl_exclsem, 0, 1); -#ifndef CONFIG_RAMLOG_NONBLOCKING - sem_init(&priv->rl_waitsem, 0, 0); -#endif - priv->rl_bufsize = CONFIG_RAMLOG_CONSOLE_BUFSIZE; - priv->rl_buffer = g_sysbuffer; - - return register_driver("/dev/syslog", &g_ramlogfops, 0666, priv); + return register_driver("/dev/syslog", &g_ramlogfops, 0666, &g_sysdev); } #endif @@ -756,10 +754,7 @@ int ramlog_putc(int ch) ret = ramlog_addchar(priv, '\r'); if (ret < 0) { - /* The buffer is full and nothing was saved. Break out of the - * loop to return the number of bytes written up to this point. - * The data to be written is dropped on the floor. - */ + /* The buffer is full and nothing was saved. */ return ch; } diff --git a/nuttx/lib/stdio/lib_syslogstream.c b/nuttx/lib/stdio/lib_syslogstream.c index 3da066408..9cfb15367 100644 --- a/nuttx/lib/stdio/lib_syslogstream.c +++ b/nuttx/lib/stdio/lib_syslogstream.c @@ -1,7 +1,7 @@ /**************************************************************************** * lib/stdio/lib_syslogstream.c * - * Copyright (C) 2023 Gregory Nutt. All rights reserved. + * Copyright (C) 2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without -- cgit v1.2.3