1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-24 23:38:09 +00:00
trezor-firmware/embed/trezorhal/flash.h

63 lines
2.0 KiB
C
Raw Normal View History

2017-03-07 14:52:19 +00:00
#ifndef __TREZORHAL_FLASH_H__
#define __TREZORHAL_FLASH_H__
#include <stdint.h>
#include "secbool.h"
// see docs/memory.md for more information
2017-06-20 15:32:21 +00:00
#define FLASH_SECTOR_BOARDLOADER_START 0
// 1
#define FLASH_SECTOR_BOARDLOADER_END 2
2017-06-20 15:32:21 +00:00
#define FLASH_SECTOR_PIN_AREA 3
#define FLASH_SECTOR_STORAGE_1 4
#define FLASH_SECTOR_BOOTLOADER 5
#define FLASH_SECTOR_FIRMWARE_START 6
// 7
// 8
// 9
// 10
#define FLASH_SECTOR_FIRMWARE_END 11
#define FLASH_SECTOR_UNUSED_START 12
// 13
// 14
#define FLASH_SECTOR_UNUSED_END 15
#define FLASH_SECTOR_STORAGE_2 16
#define FLASH_SECTOR_FIRMWARE_EXTRA_START 17
// 18
// 19
// 20
// 21
// 22
#define FLASH_SECTOR_FIRMWARE_EXTRA_END 23
2017-06-20 15:32:21 +00:00
#define FLASH_SECTOR_COUNT 24
extern const uint32_t FLASH_SECTOR_TABLE[FLASH_SECTOR_COUNT + 1];
2017-09-27 09:08:46 +00:00
void flash_set_option_bytes(void);
secbool flash_unlock(void);
secbool flash_lock(void);
2017-09-27 09:08:46 +00:00
secbool flash_erase_sectors(const uint8_t *sectors, int len, void (*progress)(int pos, int len));
secbool flash_write_byte(uint32_t address, uint8_t data);
secbool flash_write_word(uint32_t address, uint32_t data);
2017-09-27 09:08:46 +00:00
#define FLASH_OTP_NUM_BLOCKS 16
#define FLASH_OTP_BLOCK_SIZE 32
secbool flash_otp_read(uint8_t block, uint8_t offset, uint8_t *data, uint8_t datalen);
secbool flash_otp_write(uint8_t block, uint8_t offset, const uint8_t *data, uint8_t datalen);
secbool flash_otp_lock(uint8_t block);
secbool flash_otp_is_locked(uint8_t block);
2017-06-20 15:32:21 +00:00
2017-03-07 14:52:19 +00:00
#endif