summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2019-03-14 10:14:20 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-03-26 21:45:38 -0700
commit53b44b301d2d5000c7b73b04276b4ffa6d2e8efa (patch)
tree9fc3d6b915ecc3876df190f4f6dfb7bb1606faf2 /chip
parent05e9ae7330cfa6144cbc29c30065a58f667fd48e (diff)
downloadchrome-ec-53b44b301d2d5000c7b73b04276b4ffa6d2e8efa.tar.gz
common: add flash event log facility
This patch adds implementation and test for a generic logger saving log entries in the flash. The entries payload are limited to 64 bytes in size, each entry starts with a header, which includes - 8 bit type type to allow to interpret the payload - 6 bit size field (two top bits of the byte are left for user flags, not yet used) - 32 bit timestamp to allow to identify newer log entries (presently this is just a monotonically increasing number) - 8 bit crc field protecting the entire entry The entries are padded to make sure that they are ending on the flash write boundary. The location of the log is defined by the platform using it. There is a provision for allowing the platform to register a callback which is needed to be called to allow write access to the log (as is the case on H1). While the device is running, the log is growing until the allotted flash space is 90% full. If there is an attempt save another entry after that the log is compacted, namely the last 25% worth of flash space is preserved, the log space is erased and the saved contents written back. On restarts the log is compacted if its size exceeds 75% of the allotted flash space. An API is provided to add entries to the log and to retrieve an entry newer than a certain timestamp value. Thus starting with timestamp zero will result in reading the very first log entry. To read the next entry, the read function needs to be called with the timestamp value of the current entry. This allows to browse the entire log, one entry at a time. A CLI command compiled in when CONFIG_CMD_FLASH_LOG is defined, allows to add log and retrieve log entries. BUG=b:63760920 BRANCH=cr50, cr50-mp TEST=the included test case can be invoked by make run-flash_log and it passes. More tests are done when the rest of the patch stack is added. Change-Id: I3dcdf2704a1e08fd3101183e434ac4a4e4cf1b9a Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1525143 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r--chip/g/config_chip.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/chip/g/config_chip.h b/chip/g/config_chip.h
index a79ecf2ee0..365154fd5b 100644
--- a/chip/g/config_chip.h
+++ b/chip/g/config_chip.h
@@ -28,6 +28,7 @@
/* Describe the flash layout */
#define CONFIG_PROGRAM_MEMORY_BASE 0x40000
#define CONFIG_FLASH_SIZE (512 * 1024)
+#define CONFIG_FLASH_ERASED_VALUE32 (-1U)
#define CONFIG_RO_HEAD_ROOM 1024 /* Room for ROM signature. */
#define CONFIG_RW_HEAD_ROOM CONFIG_RO_HEAD_ROOM /* same for RW */