Software APIs
sw
device
silicon_creator
lib
bootstrap.h
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
#ifndef OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_BOOTSTRAP_H_
5
#define OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_BOOTSTRAP_H_
6
7
#include "
sw/device/lib/base/hardened.h
"
8
#include "sw/device/silicon_creator/lib/error.h"
9
10
#ifdef __cplusplus
11
extern
"C"
{
12
#endif
13
14
/**
15
* @public
16
* Enters flash programming mode. This function initializes the SPI device and
17
* uses incoming SPI commands to drive an internal state machine.
18
*
19
* Dependent code should use this function as the main entry point to bootstrap.
20
* The dependent code must provide implementations for the following functions:
21
* - `bootstrap_chip_erase()`
22
* - `bootstrap_erase_verify()`
23
*
24
* Bootstrapping uses the typical SPI flash EEPROM commands. A typical session
25
* involves:
26
* - Asserting bootstrap pins to enter bootstrap mode,
27
* - Erasing the chip (WREN, CHIP_ERASE, busy loop ...),
28
* - Programming the chip (WREN, PAGE_PROGRAM, busy loop ...), and
29
* - Resetting the chip (RESET).
30
*
31
* This function only returns on error; a successful session ends with a chip
32
* reset.
33
*
34
* @return The result of the flash loop.
35
*/
36
OT_WARN_UNUSED_RESULT
37
rom_error_t enter_bootstrap(
void
);
38
39
/**
40
* @private @pure
41
* Handles access permissions and erases both data banks of the embedded flash.
42
*
43
* NOTE: This abstract function must be implemented by dependent code.
44
*
45
* @return Result of the operation.
46
*/
47
OT_WARN_UNUSED_RESULT
48
rom_error_t bootstrap_chip_erase(
void
);
49
50
/**
51
* @private @pure
52
* Verify that all data banks have been erased.
53
*
54
* This function also clears the WIP and WEN bits of the flash status register.
55
*
56
* NOTE: This abstract function must be implemented by dependent code.
57
*
58
* @return Result of the operation.
59
*/
60
OT_WARN_UNUSED_RESULT
61
rom_error_t bootstrap_erase_verify(
void
);
62
63
#ifdef __cplusplus
64
}
65
#endif
66
67
#endif
// OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_BOOTSTRAP_H_
Return to
OpenTitan Documentation