Software APIs
flash_contents.c
1 // Copyright lowRISC contributors (OpenTitan project).
2 // Licensed under the Apache License, Version 2.0, see LICENSE for details.
3 // SPDX-License-Identifier: Apache-2.0
4 
5 #include "sw/device/lib/base/status.h"
8 #include "sw/device/silicon_creator/lib/boot_log.h"
9 #include "sw/device/silicon_creator/lib/drivers/retention_sram.h"
10 
11 #include "flash_ctrl_regs.h"
13 
14 OTTF_DEFINE_TEST_CONFIG();
15 
16 status_t flash_contents_print(boot_log_t *boot_log) {
17  TRY(boot_log_check(boot_log));
18  uint32_t *data = (uint32_t *)(TOP_EARLGREY_FLASH_CTRL_MEM_BASE_ADDR +
20  uint32_t *end = (uint32_t *)(TOP_EARLGREY_FLASH_CTRL_MEM_BASE_ADDR +
21  FLASH_CTRL_PARAM_BYTES_PER_BANK);
22  uint32_t incr = FLASH_CTRL_PARAM_BYTES_PER_PAGE / sizeof(uint32_t);
23 
24  for (; data < end; data += incr) {
25  LOG_INFO("flash %p = %x", data, *data);
26  }
27  return OK_STATUS();
28 }
29 
30 bool test_main(void) {
31  status_t sts = flash_contents_print(&retention_sram_get()->creator.boot_log);
32  if (status_err(sts)) {
33  LOG_ERROR("flash_contents_print: %r", sts);
34  }
35  return status_ok(sts);
36 }