Repository navigation
rpierrorlog: Add rpierrorlog to utils to manage firmware error logging #176
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
Open
martamomotko
wants to merge
1
commit into
raspberrypi:master
Choose a base branch
from
martamomotko:add-rpierrorlog-util
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+464
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| cmake_minimum_required(VERSION 3.10...3.27) | ||
| include(GNUInstallDirs) | ||
|
|
||
| set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra") | ||
| option(ENABLE_WERROR "Treat compiler warnings as errors" OFF) | ||
| if(ENABLE_WERROR) | ||
| set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") | ||
| endif() | ||
|
|
||
| project(rpierrorlog) | ||
|
|
||
| option(BUILD_SHARED_LIBS "Build using shared libraries" ON) | ||
|
|
||
| add_library(rpierrorlog rpierrorlog.c) | ||
| target_sources(rpierrorlog PUBLIC rpierrorlog.h) | ||
| set_target_properties(rpierrorlog PROPERTIES PUBLIC_HEADER rpierrorlog.h) | ||
| set_target_properties(rpierrorlog PROPERTIES SOVERSION 0) | ||
|
|
||
| add_executable(rpi-error-log main.c) | ||
| target_link_libraries(rpi-error-log rpierrorlog) | ||
|
|
||
| install(TARGETS rpi-error-log RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
| install(TARGETS rpierrorlog | ||
| ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
| PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
|
|
||
| # rpierrorlog | ||
|
|
||
| Tool to read and clear the fatal boot errors that the bootloader logs in the | ||
| SPI EEPROM on Raspberry Pi 5 family devices. | ||
|
|
||
| The log keeps the error code of each fatal boot error, so the reason for a | ||
| failed boot can still be read after the device restarts. Installing a | ||
| bootloader update clears the log, because the errors in it came from the | ||
| previous bootloader version. The log only exists on AB-capable firmware. | ||
|
|
||
| **Build Instructions** | ||
|
|
||
| Install prerequisites with "sudo apt install cmake" - you need at least version 3.10. | ||
|
|
||
| - *mkdir build* | ||
| - *cd build* | ||
| - *cmake ..* | ||
| - *make* | ||
| - *sudo make install* | ||
|
|
||
| **Usage** | ||
|
|
||
| * rpi-error-log (Shows usage information) | ||
| * rpi-error-log get (Read and print all EEPROM error log entries - Pi 5 family boards only) | ||
| * rpi-error-log clear (Clear the EEPROM error log and verify it is empty - Pi 5 family boards only) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| #include <stdio.h> | ||
| #include <string.h> | ||
| #include "rpierrorlog.h" | ||
|
|
||
| static void usage(const char *progname) | ||
| { | ||
| fprintf(stderr, | ||
| "Usage: %s <command>\n" | ||
| "\n" | ||
| "Commands:\n" | ||
| " get Read and print all EEPROM error log entries\n" | ||
| " (Pi 5 family boards only)\n" | ||
| " clear Clear the EEPROM error log and verify it is empty\n" | ||
| " (Pi 5 family boards only)\n", | ||
| progname); | ||
| } | ||
|
|
||
| static int cmd_get(void) | ||
| { | ||
| rpi_error_log_t entries[RPI_ERROR_LOG_MAX_SIZE / RPI_ERROR_LOG_ENTRY_SIZE]; | ||
| size_t count; | ||
|
|
||
| if (rpi_error_log_get(entries, sizeof(entries) / sizeof(entries[0]), &count) < 0) { | ||
| fprintf(stderr, "Failed to read error log\n"); | ||
| return -1; | ||
| } | ||
|
|
||
| if (count == 0) { | ||
| printf("No error log entries\n"); | ||
| return 0; | ||
| } | ||
|
|
||
| for (size_t i = 0; i < count; i++) | ||
| printf("Entry %zu: 0x%08x - %s\n", i, entries[i].error_code, rpi_error_log_strerror(entries[i].error_code)); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| static int cmd_clear(void) | ||
| { | ||
| rpi_error_log_t entries[RPI_ERROR_LOG_MAX_SIZE / RPI_ERROR_LOG_ENTRY_SIZE]; | ||
| size_t count; | ||
|
|
||
| if (rpi_error_log_clear() < 0) { | ||
| fprintf(stderr, "Failed to clear error log\n"); | ||
| return -1; | ||
| } | ||
| printf("Error log cleared\n"); | ||
|
|
||
| if (rpi_error_log_get(entries, sizeof(entries) / sizeof(entries[0]), &count) < 0) { | ||
| fprintf(stderr, "Verification read failed\n"); | ||
| return -1; | ||
| } | ||
| if (count != 0) { | ||
| fprintf(stderr, "Verification failed: %zu entries still present after clear\n", count); | ||
| return -1; | ||
| } | ||
| printf("Verification OK: error log is empty\n"); | ||
| return 0; | ||
| } | ||
|
|
||
| int main(int argc, char *argv[]) | ||
| { | ||
| int rc = -1; | ||
|
|
||
| if (argc != 2) { | ||
| usage(argv[0]); | ||
| return 1; | ||
| } | ||
|
|
||
| if (strcmp(argv[1], "get") == 0) { | ||
| rc = cmd_get(); | ||
| if (rc < 0) | ||
| goto error; | ||
| return 0; | ||
| } | ||
|
|
||
| if (strcmp(argv[1], "clear") == 0) { | ||
| rc = cmd_clear(); | ||
| if (rc < 0) | ||
| goto error; | ||
| return 0; | ||
| } | ||
|
|
||
| usage(argv[0]); | ||
| return 1; | ||
|
|
||
| error: | ||
| fprintf(stderr, "Command '%s' failed\n", argv[1]); | ||
| return rc; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.