-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-shared.h
49 lines (44 loc) · 1.61 KB
/
update-shared.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
#pragma once
typedef enum update_method {
UPDATE_V0,
UPDATE_V1,
} update_meth_t;
typedef struct board {
const char *compatible;
uint16_t modelnum;
int i2c_bus;
int i2c_chip;
uint16_t min_rev;
update_meth_t method;
} board_t;
void flash_print_error(uint8_t status);
/* Read-back status values */
/* Default value of status, closed */
#define STATUS_CLOSED 0x00
/* Once the flashwrite process is set up, but no data written */
#define STATUS_READY 0xAA
/* Flashwrite process has seen full length of data written and is considered done */
#define STATUS_DONE 0x01
/* Flashwrite is in process, meaning SOME data has been written, but not the full length */
#define STATUS_IN_PROC 0x02
/* A CRC error occurred at ANY point during data write. Note that this status
* is not set if CRC fails for open process, the system simply does not open
*/
#define STATUS_CRC_ERR 0x03
/* An error occurred while trying to erase the actual flash */
#define STATUS_ERASE_ERR 0x04
/* An error occurred at ANY point during data write. */
#define STATUS_WRITE_ERR 0x05
/* Erase was successful, but, the area to be written was not blank */
#define STATUS_NOT_BLANK 0x06
/* A BSP error opening and closing flash. Most errors are buggy code, configurations, or unrecoverable */
#define STATUS_OPEN_ERR 0x07
/* Wait state while processing a write */
#define STATUS_WAIT 0x08
/* Request the uC reboot at any time after its open status */
#define STATUS_RESET 0x55
/*
* The updates themselves are encrypted/signed, but the below key is just used to
* prevent unintentional writes to i2c causing writes to the flash.
*/
static const uint32_t magic_key = 0xf092c858;