2017-03-07 14:52:19 +00:00
|
|
|
#ifndef __TREZORHAL_FLASH_H__
|
|
|
|
#define __TREZORHAL_FLASH_H__
|
|
|
|
|
2017-09-27 09:08:46 +00:00
|
|
|
#include <stdbool.h>
|
2017-06-20 17:53:24 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2017-06-20 15:32:21 +00:00
|
|
|
#define FLASH_SECTOR_BOARDLOADER_START 0
|
2017-10-11 21:53:29 +00:00
|
|
|
#define FLASH_SECTOR_BOARDLOADER_END 2
|
2017-06-20 15:32:21 +00:00
|
|
|
|
2017-10-11 21:53:29 +00:00
|
|
|
#define FLASH_SECTOR_BOOTLOADER_START 5
|
|
|
|
#define FLASH_SECTOR_BOOTLOADER_END 5
|
2017-06-20 15:32:21 +00:00
|
|
|
|
2017-10-11 21:53:29 +00:00
|
|
|
#define FLASH_SECTOR_FIRMWARE_START 6
|
2017-06-20 15:32:21 +00:00
|
|
|
#define FLASH_SECTOR_FIRMWARE_END 11
|
|
|
|
|
2017-09-27 09:08:46 +00:00
|
|
|
int flash_init(void);
|
|
|
|
|
|
|
|
void flash_set_option_bytes(void);
|
|
|
|
|
|
|
|
bool flash_unlock(void);
|
|
|
|
bool flash_lock(void);
|
|
|
|
|
|
|
|
bool flash_erase_sectors(int start, int end, void (*progress)(uint16_t val));
|
2017-09-28 09:27:58 +00:00
|
|
|
bool flash_write_byte(uint32_t address, uint8_t data);
|
|
|
|
bool flash_write_word(uint32_t address, uint32_t data);
|
2017-09-27 09:08:46 +00:00
|
|
|
|
2017-10-12 12:35:01 +00:00
|
|
|
#define FLASH_OTP_NUM_BLOCKS 16
|
|
|
|
#define FLASH_OTP_BLOCK_SIZE 32
|
|
|
|
|
2017-09-27 09:08:46 +00:00
|
|
|
bool flash_otp_read(uint8_t block, uint8_t offset, uint8_t *data, uint8_t datalen);
|
2017-09-27 10:00:35 +00:00
|
|
|
bool flash_otp_write(uint8_t block, uint8_t offset, const uint8_t *data, uint8_t datalen);
|
2017-09-27 09:08:46 +00:00
|
|
|
bool flash_otp_lock(uint8_t block);
|
|
|
|
bool flash_otp_is_locked(uint8_t block);
|
2017-06-20 15:32:21 +00:00
|
|
|
|
2017-03-07 14:52:19 +00:00
|
|
|
#endif
|