mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-08-08 14:42:19 -04:00
Add filesystem code and storage syscalls
Adds syscalls: - ALLOCATE_AREA - DEALLOCATE_AREA - WRITE_DATA - READ_DATA and code to access the filesystem and the flash over SPI. Based on original work by Daniel Jobson <jobson@tillitis.see> for these files: - auth_app.[ch] - flash.[ch] - spi.[ch] - partition_table.[ch] - rng.[ch] - storage.[ch] which are used with small changes to integrate with the new syscall method. Co-authored-by: Daniel Jobson <jobson@tillitis.se> Co-authored-by: Mikael Ågren <mikael@tillitis.se>
This commit is contained in:
parent
e86e60fcfe
commit
8da9eef5d0
19 changed files with 974 additions and 7 deletions
105
hw/application_fpga/fw/tk1/partition_table.h
Normal file
105
hw/application_fpga/fw/tk1/partition_table.h
Normal file
|
@ -0,0 +1,105 @@
|
|||
// Copyright (C) 2024 - Tillitis AB
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
|
||||
#ifndef PARTITION_TABLE_H
|
||||
#define PARTITION_TABLE_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* ---- Flash ---- ---- */
|
||||
/* name size start addr */
|
||||
/* ---- ---- ---- */
|
||||
/* bitstream 128KiB 0x00 */
|
||||
/* ---- ---- ---- */
|
||||
/* Partition 64KiB 0x20000 */
|
||||
/* ---- ---- ---- */
|
||||
/* Pre load 128KiB 0x30000 */
|
||||
/* ---- ---- ---- */
|
||||
/* storage 1 128KiB 0x50000 */
|
||||
/* storage 2 128KiB 0x70000 */
|
||||
/* storage 3 128KiB 0x90000 */
|
||||
/* storage 4 128KiB 0xB0000 */
|
||||
/* ---- ---- ---- */
|
||||
|
||||
/* To simplify all blocks are aligned with the 64KiB blocks on the W25Q80DL
|
||||
* flash. */
|
||||
|
||||
#define PART_TABLE_VERSION 1
|
||||
|
||||
#define ADDR_BITSTREAM 0UL
|
||||
#define SIZE_BITSTREAM 0x20000UL // 128KiB
|
||||
|
||||
#define ADDR_PARTITION_TABLE (ADDR_BITSTREAM + SIZE_BITSTREAM)
|
||||
#define SIZE_PARTITION_TABLE \
|
||||
0x10000UL // 64KiB, 60 KiB reserved, 2 flash pages (2 x 4KiB) for the
|
||||
// partition table
|
||||
|
||||
#define ADDR_PRE_LOADED_APP (ADDR_PARTITION_TABLE + SIZE_PARTITION_TABLE)
|
||||
#define SIZE_PRE_LOADED_APP 0x20000UL // 128KiB
|
||||
|
||||
#define ADDR_STORAGE_AREA (ADDR_PRE_LOADED_APP + SIZE_PRE_LOADED_APP)
|
||||
#define SIZE_STORAGE_AREA 0x20000UL // 128KiB
|
||||
#define N_STORAGE_AREA 4
|
||||
|
||||
#define EMPTY_AREA
|
||||
|
||||
/* Partition Table */
|
||||
/*- Table header */
|
||||
/* - 1 bytes Version */
|
||||
/**/
|
||||
/*- Management device app */
|
||||
/* - Status. */
|
||||
/* - 16 byte random nonce. */
|
||||
/* - 16 byte authentication digest. */
|
||||
/**/
|
||||
/*- Pre-loaded device app */
|
||||
/* - 1 byte status. */
|
||||
/* - 4 bytes length. */
|
||||
/* - 16 bytes random nonce. */
|
||||
/* - 16 bytes authentication digest. */
|
||||
/**/
|
||||
/*- Device app storage area */
|
||||
/* - 1 byte status. */
|
||||
/* - 16 bytes random nonce. */
|
||||
/* - 16 bytes authentication tag. */
|
||||
/* - 4 bytes physical start address. */
|
||||
/* - 4 bytes physical end address. */
|
||||
|
||||
struct auth_metadata {
|
||||
uint8_t nonce[16];
|
||||
uint8_t authentication_digest[16];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct management_app_metadata {
|
||||
uint8_t status;
|
||||
struct auth_metadata auth;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct pre_loaded_app_metadata {
|
||||
uint8_t status;
|
||||
uint32_t size;
|
||||
struct auth_metadata auth;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct app_storage_area {
|
||||
uint8_t status;
|
||||
struct auth_metadata auth;
|
||||
uint32_t addr_start;
|
||||
uint32_t size;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct table_header {
|
||||
uint8_t version;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct partition_table {
|
||||
struct table_header header;
|
||||
struct management_app_metadata mgmt_app_data;
|
||||
struct pre_loaded_app_metadata pre_app_data;
|
||||
struct app_storage_area app_storage[N_STORAGE_AREA];
|
||||
} __attribute__((packed));
|
||||
|
||||
int part_table_read(struct partition_table *part_table);
|
||||
int part_table_write(struct partition_table *part_table);
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue