-
Notifications
You must be signed in to change notification settings - Fork 0
/
Flasher.h
53 lines (44 loc) · 2.3 KB
/
Flasher.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//------------------------------------------------------------------------
// Copyright(c) 2024 Dad Design.
//
// Utility for flashing QSPIFlash memory from a PC
// Memory structure and transmission blocks
//-----------------------------------------------------------------------
#pragma once
#include <stdint.h>
namespace Dad {
#define QSPI_SIZE 8388608 // Size of the QSPI flash memory 8M = 8 * 1024 * 1024
#define QSPI_PAGE_SIZE 4096 // 4K per page
#define QSPI_PAGE_COUNT 2048 // Number of QSPI pages for the flasher 2024 * 4096 4MB
#define QSPI_ADRESSE 0x90000000
//#define TRANS_BLOCK_COUNT 4 // Number of Blocks to transmit per QSPI page (1,2,4,8,16,32)
#define TRANS_BLOCK_SIZE 1024 // Size of a transmission block
#define MAX_ENTRY_NAME 40 // Number of pages reserved at the beginning of QSPI Flash
#define DIR_FILE_COUNT 20 // Number of entries in the Directory
// Directory structure
typedef struct stFile {
char Name[MAX_ENTRY_NAME];
uint32_t Size;
uint32_t DataAddress;
} Directory[DIR_FILE_COUNT];
// Structure of the memory area in QSPI used by the flasher
typedef uint8_t Page[QSPI_PAGE_SIZE];
struct stQSPI {
Page Data[QSPI_PAGE_COUNT]; // Pages used by file data
};
static_assert(sizeof(stQSPI) <= QSPI_SIZE, "Memory used > QSPI Flash memory size");
// Structure of a transmission block on the server side
struct Bloc {
char StartMarker[4]; // Block start delimiter "BLOC"
uint16_t NumBloc; // Block number
uint8_t _CRC; // Checksum
uint8_t _EndTrans; // End of transmission identifier
uint8_t Data[TRANS_BLOCK_SIZE]; // Data
char EndMarker[3]; // Block end delimiter "END"
};
// Structure of a transmission block on the client side
struct MsgClient {
char StartMarker[4]; // Block start delimiter "BLOC", "STOP"
uint16_t NumBloc; // Expected block number
};
} //Dad