10 #include "Driver_Flash.h"
15 static uint8_t write_buf[ITS_SECTOR_SIZE * ITS_SECTORS_PER_BLOCK];
27 uint32_t block_id,
size_t offset)
37 err = ((ARM_DRIVER_FLASH *)info->
flash_dev)->Initialize(NULL);
38 if (err != ARM_DRIVER_OK) {
46 uint32_t block_id, uint8_t *buff,
47 size_t offset,
size_t size)
50 uint32_t addr = get_phys_address(info, block_id, offset);
52 err = ((ARM_DRIVER_FLASH *)info->
flash_dev)->ReadData(addr, buff, size);
53 if (err != ARM_DRIVER_OK) {
61 uint32_t block_id,
const uint8_t *buff,
62 size_t offset,
size_t size)
67 buf_block_id = block_id;
68 }
else if (buf_block_id != block_id) {
73 (void)
tfm_memcpy(write_buf + offset, buff, size);
81 uint32_t addr = get_phys_address(info, buf_block_id, 0);
84 err = ((ARM_DRIVER_FLASH *)info->
flash_dev)->ProgramData(addr, write_buf,
86 if (err != ARM_DRIVER_OK) {
91 (void)
tfm_memset(write_buf, 0,
sizeof(write_buf));
105 addr = get_phys_address(info, block_id, offset);
107 err = ((ARM_DRIVER_FLASH *)info->
flash_dev)->EraseSector(addr);
108 if (err != ARM_DRIVER_OK) {
psa_status_t its_flash_nand_flush(const struct its_flash_info_t *info)
Flushes modifications to a block to flash.
#define PSA_ERROR_STORAGE_FAILURE
__STATIC_INLINE void * tfm_memset(void *ptr, int value, size_t num)
Implementations of the flash interface functions for a NAND flash device. See its_flash.h for full documentation of functions.
psa_status_t its_flash_nand_read(const struct its_flash_info_t *info, uint32_t block_id, uint8_t *buff, size_t offset, size_t size)
Reads block data from the position specified by block ID and offset.
#define PSA_ERROR_PROGRAMMER_ERROR
psa_status_t its_flash_nand_init(const struct its_flash_info_t *info)
Initialize the Flash Interface.
struct flash_fs_info_t fs_info
__STATIC_INLINE void * tfm_memcpy(void *dest, const void *src, size_t num)
psa_status_t its_flash_nand_write(const struct its_flash_info_t *info, uint32_t block_id, const uint8_t *buff, size_t offset, size_t size)
Writes block data to the position specified by block ID and offset.
psa_status_t its_flash_nand_erase(const struct its_flash_info_t *info, uint32_t block_id)
Erases block ID data.
Structure containing the required information about a flash device to be used by the ITS Flash FS...
#define ITS_BLOCK_INVALID_ID
int32_t psa_status_t
Function return status.