Skip to content

EEPROM Error Logger

Peace Kotamnives edited this page May 27, 2023 · 7 revisions

The TM4C EEPROM is being used to implement a ring buffer to store error messages. The EEPROM has 96 blocks of 16 words each, and as of now, only block 1 is being used for other purposes. To set the block range used by the buffer, set macros EBUF_MINBLK and EBUF_MAXBLK in utils.h. The buffer will use every block in the range [EBUF_MINBLK, EBUF_MAXBLK], inclusive. After changing buffer size, or if the EEPROM is ever reset, use the CLI command errorlog_reset.

Each buffer entry is one 4-byte word, currently configured as such

2 bytes 3 bits 5 bits 8 bits
timestamp message counter error code error data

The sizes of the counter, error code and error data can be set by COUNTER_OFFSET, ERRCODE_OFFSET, and ERRDATA_OFFSET

errbuffer_put(ebuf, errcode, errdata) is used to put a new entry in the buffer.

From the CLI, errorlog_entry <code> can be used to manually add an error code, and errorlog <n> prints n past entries.

The error codes currently in use are listed below.

error code data
Restart Reason (SW/EXT/WDOG/POR)
Reset Buffer N/A
Power Off - Manual N/A
Power Off - Temp High N/A
Power On - Manual N/A
Temp Normal N/A
Hard Fault ISRNUM
Assertion Failed N/A
Stack Overflow N/A
Power Failure Failed supply mask
Temp High TM4C, FPGA, FF, DCDC temps

When adding new error codes, the macros corresponding to codes that use the data field should be greater than EBUF_WITH_DATA. This will require that 'errorlog' prints out the data field for that error code by default.

Counter

The counter keeps track of repeated entries with the same error code. The first instance of an error code is recorded in its own entry, and the second instance creates another entry in which the counter will increment for as many times as the error code is repeated. If the counter reaches its maximum value, a new entry will be made, starting again at 0.

For the sake of the EEPROM endurance, the counter is only updated in the EEPROM entry for every few messages it receives, determined by COUNTER_UPDATE. The error data and timestamp are also updated with the counter.

The (most accurate) counter, stored in software, can be viewed by calling eeprom_info.

Continue Codes

For error codes that require longer data fields than 8 bits, "continue codes" can be used. If a continue code is used in a message, it means that it's data field is a continuation of the previous message. Multiple continue codes can follow an error code in order to extend the data field to the required length, but the number of continue codes associated with each type of error code must be constant. For this reason, error codes that use continue codes should have special functions (see errbuffer_temp_high in utils.c) which send the error code and continue codes to the logger in one function call.