-
Notifications
You must be signed in to change notification settings - Fork 618
os/kernel/crashlog_writer: Add crash log flash save #6899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
319bc2f
ebd15e6
ce9c49f
5abfde1
6f83078
e424bf6
c618e14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -105,6 +105,9 @@ | |
| #include "irq/irq.h" | ||
| #include "task/task.h" | ||
| #include "up_internal.h" | ||
| #ifdef CONFIG_CRASHLOG_WRITER | ||
| #include <tinyara/crashlog_writer/crashlog_writer.h>> | ||
| #endif | ||
|
|
||
| bool abort_mode = false; | ||
|
|
||
|
|
@@ -580,6 +583,7 @@ static inline void print_assert_detail(const uint8_t *filename, int lineno, stru | |
|
|
||
| void up_assert(const uint8_t *filename, int lineno) | ||
| { | ||
|
|
||
| /* ARCH_GET_RET_ADDRESS should always be | ||
| * called at the start of the function */ | ||
|
|
||
|
|
@@ -610,7 +614,14 @@ void up_assert(const uint8_t *filename, int lineno) | |
| } else { | ||
| asserted_location = kernel_assert_location; | ||
| } | ||
|
|
||
| #ifdef CONFIG_CRASHLOG_WRITER | ||
| #ifdef CONFIG_BINMGR_RECOVERY | ||
| if (IS_FAULT_IN_USER_SPACE(asserted_location)) { | ||
| /* start assert log saving */ | ||
| crashlog_writer_set_store_to_buffer_flag(1); | ||
| } | ||
| #endif | ||
| #endif | ||
| #ifdef CONFIG_SMP | ||
| /* Pause all other CPUs to avoid mix up of logs while printing assert logs */ | ||
| up_cpu_pause_all(); | ||
|
|
@@ -654,6 +665,7 @@ void up_assert(const uint8_t *filename, int lineno) | |
| if (IS_FAULT_IN_USER_SPACE(asserted_location)) { | ||
| /* Recover user fault through binary manager */ | ||
| binary_manager_recover_userfault(); | ||
| state = NORMAL_STATE; | ||
|
||
| } else | ||
| #endif | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /**************************************************************************** | ||
| * | ||
| * Copyright 2022 Samsung Electronics All Rights Reserved. | ||
|
||
| * | ||
| * Licensed 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 __CRASH_LOG_H | ||
| #define __CRASH_LOG_H | ||
|
|
||
| /**************************************************************************** | ||
| * Included Files | ||
| ****************************************************************************/ | ||
| /**************************************************************************** | ||
| * Description: | ||
| * This is used to store logs that are output via lldbg() during a user crash situation into a buffer. | ||
| * | ||
| ****************************************************************************/ | ||
| void crashlog_writer_crashlog_to_buffer(char ch); | ||
|
|
||
| /**************************************************************************** | ||
| * Description: | ||
| * If the flag is set to 1, crash logs start being stored in the buffer; if | ||
| * it is set to 0, the storage stops. | ||
| * | ||
| ****************************************************************************/ | ||
| void crashlog_writer_set_store_to_buffer_flag(int flag); | ||
|
|
||
| /**************************************************************************** | ||
| * Description: | ||
| * Saves the crash log to a file. | ||
| * If the flag is 1, the log is saved in compressed form; if it is 0, it is saved uncompressed. | ||
| * | ||
| ****************************************************************************/ | ||
| char* crashlog_writer_save_crashlog(int flag); | ||
|
|
||
| /************************************************************************************* | ||
| * Name: crashlog_writer_read | ||
| * | ||
| * Description: | ||
| * Reads a log from a file and stores it in a buffer. If the log is compresed, it is | ||
| * decompressed before being stored. | ||
| *************************************************************************************/ | ||
| int crashlog_writer_read_crashlog(char *filename, char *buf, int buf_size); | ||
|
|
||
| /************************************************************************************* | ||
| * Name: crashlog_writer_read_recent | ||
| * | ||
| * Description: | ||
| * Reads the most recent log from a file and stores it in a buffer. If the log is compresed, it is | ||
| * decompressed before being stored. | ||
| *************************************************************************************/ | ||
| int crashlog_writer_read_recent_crashlog(char *buf, int buf_size); | ||
| #endif | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,10 @@ | |
| #include "semaphore/semaphore.h" | ||
| #include "binary_manager_internal.h" | ||
|
|
||
| #ifdef CONFIG_CRASHLOG_WRITER | ||
| #include <tinyara/crashlog_writer/crashlog_writer.h> | ||
| #endif | ||
|
|
||
| /**************************************************************************** | ||
| * Pre-processor Definitions | ||
| ****************************************************************************/ | ||
|
|
@@ -345,6 +349,17 @@ void binary_manager_recovery(int bin_idx) | |
| bmlldbg("Failed to deactivate binary, bin idx %d\n", bin_idx); | ||
| goto reboot_board; | ||
| } | ||
| #endif | ||
| #ifdef CONFIG_CRASHLOG_WRITER | ||
| crashlog_writer_set_store_to_buffer_flag(0); //stop saving log to buf | ||
| #ifdef CONFIG_CLWR_COMPRESS | ||
| crashlog_writer_save_crashlog(1); | ||
| #else | ||
| crashlog_writer_save_crashlog(0); | ||
| #endif | ||
| #ifdef CONFIG_CLWR_REBOOT | ||
| binary_manager_reset_board(REBOOT_SYSTEM_BINARY_RECOVERYFAIL); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reboot Reason should not be overwritten here. /* Do not overwrite reboot reason here */
boardctl(BOARDIOC_RESET, EXIT_SUCCESS); |
||
| #endif | ||
| #endif | ||
| /* Create loader to reload binary */ | ||
| ret = binary_manager_execute_loader(LOADCMD_RELOAD, bin_idx); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need to make option to system reboot here. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # | ||
| # For a description of the syntax of this configuration file, | ||
| # see kconfig-language at https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt | ||
| # | ||
|
|
||
|
|
||
| config CRASHLOG_WRITER | ||
| bool "enable crashlog writer" | ||
| default n | ||
| depends on BINMGR_RECOVERY | ||
| ---help--- | ||
| This saves the crash log. | ||
|
|
||
| if CRASHLOG_WRITER | ||
|
|
||
| config CLWR_COMPRESS | ||
| bool "CRASHLOG_COMPRESS" | ||
| default y | ||
| ---help--- | ||
| Controls whether compression is applied. | ||
| if the value is 0 compression is not performed. | ||
|
||
|
|
||
|
|
||
| config CLWR_BUF_SIZE | ||
| int "CRASHLOG_BUF_SIZE" | ||
| default 8192 | ||
| ---help--- | ||
| Determines the size of the buffer where crash logs will be stored. | ||
| The crash log is stored in the data section. | ||
|
|
||
| config CLWR_REBOOT | ||
| bool "REBOOT_AFTER_SAVING_LOG" | ||
| default n | ||
| ---help--- | ||
| Determines whether to reboot after saving the crash log. | ||
|
|
||
| config CLWR_MAX_FILES | ||
| int "MAX_FILES" | ||
| default 5 | ||
| ---help--- | ||
| Determine the maximum number of crash log files to be stored. | ||
|
|
||
| config CLWR_RETRY_COUNT | ||
| int "CRASHLOG_RETRY_COUNT" | ||
| default 5 | ||
| depends on !REBOOT_AFTER_LOG_SAVE | ||
| ---help--- | ||
| Limit the number of crash log saves in user mode during consecutive crashes to preserve flash memory lifespan. | ||
|
|
||
| config CLWR_RECORD_TIME | ||
| bool "CRASHLOG_RECORD_TIME" | ||
| default n | ||
| ---help--- | ||
| Measure and record the time it takes to save the crash log to a file. | ||
|
|
||
| endif # CRASHLOG_SAVE | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| ########################################################################### | ||
| # | ||
| # Copyright 2022 Samsung Electronics All Rights Reserved. | ||
| # | ||
| # Licensed 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. | ||
| # | ||
| ########################################################################### | ||
|
|
||
| ifeq ($(CONFIG_CRASHLOG_WRITER),y) | ||
|
|
||
| CSRCS += crashlog_writer.c | ||
|
|
||
| DEPPATH += --dep-path crashlog_writer | ||
| VPATH += :crashlog_writer | ||
|
|
||
| endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please revert unnecessary change