xiaoxiang781216 commented on code in PR #7764: URL: https://github.com/apache/nuttx/pull/7764#discussion_r1038688787
########## libs/libc/assert/lib_assert.c: ########## @@ -23,16 +23,24 @@ ****************************************************************************/ #include <nuttx/arch.h> +#include <nuttx/notifier.h> #include <assert.h> #include <stdlib.h> +/**************************************************************************** + * Private Data + ****************************************************************************/ + +ATOMIC_NOTIFIER_HEAD(g_assert_notifier_list); + /**************************************************************************** * Public Functions ****************************************************************************/ void _assert(FAR const char *filename, int linenum) { + atomic_notifier_call_chain(&g_assert_notifier_list, 0, NULL); Review Comment: need move to up_assert ########## libs/libc/assert/lib_assert.c: ########## @@ -23,16 +23,24 @@ ****************************************************************************/ #include <nuttx/arch.h> +#include <nuttx/notifier.h> Review Comment: Let's create a new patch for reboot notify https://elixir.bootlin.com/linux/latest/C/ident/reboot_notifier_list ########## drivers/syslog/Kconfig: ########## @@ -370,4 +370,20 @@ config SYSLOG_CHARDEV byte output with no time-stamping or any other SYSLOG features supported. +config SYSLOG_CRASHLOG Review Comment: don't need add a new channel, we can simply: 1. Create mtdstream and register assert callback in esp32c3_bringup 2. Initialize and register stream syslog in assert callback ########## libs/libc/assert/lib_assert.c: ########## @@ -23,16 +23,24 @@ ****************************************************************************/ #include <nuttx/arch.h> +#include <nuttx/notifier.h> #include <assert.h> #include <stdlib.h> +/**************************************************************************** + * Private Data + ****************************************************************************/ + +ATOMIC_NOTIFIER_HEAD(g_assert_notifier_list); Review Comment: let's name it panic_notify_list like Linux: https://elixir.bootlin.com/linux/latest/C/ident/panic_notifier_list ########## boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c: ########## @@ -159,6 +160,13 @@ int esp32c3_bringup(void) syslog(LOG_ERR, "ERROR: Failed to initialize partition error=%d\n", ret); } + +#ifdef CONFIG_SYSLOG_CRASHLOG + if (syslog_crashlog_channel("/dev/bt") == NULL) Review Comment: let's split crash log init and register to new patch ########## drivers/syslog/syslog_crashlog.c: ########## @@ -0,0 +1,172 @@ +/**************************************************************************** + * drivers/syslog/syslog_crashlog.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 <sys/stat.h> +#include <fcntl.h> +#include <errno.h> + +#include <nuttx/syslog/syslog.h> +#include <nuttx/kmalloc.h> +#include <nuttx/fs/fs.h> +#include <nuttx/streams.h> +#include <nuttx/notifier.h> + +#include "syslog.h" + +#ifdef CONFIG_SYSLOG_CRASHLOG + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define OPEN_FLAGS (O_WRONLY | O_CREAT) +#define OPEN_MODE (S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR) + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +FAR struct syslog_channel_s *g_crashlog_channel = NULL; + +static struct notifier_block g_crashlog_block; + +extern struct atomic_notifier_head g_assert_notifier_list; Review Comment: move the declaration near up_assert -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org