mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 14:28:07 +00:00
embed: refactor sector_count constants
This commit is contained in:
parent
815d30f41a
commit
e7b761e66f
@ -28,7 +28,6 @@
|
||||
#define USB_PACKET_SIZE 64
|
||||
|
||||
#define FIRMWARE_UPLOAD_CHUNK_RETRY_COUNT 2
|
||||
#define FIRMWARE_SECTORS_COUNT 13
|
||||
extern const uint8_t firmware_sectors[FIRMWARE_SECTORS_COUNT];
|
||||
|
||||
secbool msg_parse_header(const uint8_t *buf, uint16_t *msg_id, uint32_t *msg_size);
|
||||
|
@ -27,15 +27,18 @@
|
||||
#define BOOTLOADER_START 0x08020000
|
||||
#define FIRMWARE_START 0x08040000
|
||||
|
||||
#define BOOTLOADER_SECTORS_COUNT (1)
|
||||
#define FIRMWARE_SECTORS_COUNT (6 + 7)
|
||||
|
||||
#define IMAGE_HEADER_SIZE 0x400
|
||||
#define IMAGE_SIG_SIZE 65
|
||||
#define IMAGE_CHUNK_SIZE (128 * 1024)
|
||||
|
||||
#define BOOTLOADER_IMAGE_MAGIC 0x425A5254 // TRZB
|
||||
#define BOOTLOADER_IMAGE_MAXSIZE (1 * IMAGE_CHUNK_SIZE)
|
||||
#define BOOTLOADER_IMAGE_MAXSIZE (BOOTLOADER_SECTORS_COUNT * IMAGE_CHUNK_SIZE)
|
||||
|
||||
#define FIRMWARE_IMAGE_MAGIC 0x465A5254 // TRZF
|
||||
#define FIRMWARE_IMAGE_MAXSIZE (13 * IMAGE_CHUNK_SIZE)
|
||||
#define FIRMWARE_IMAGE_MAXSIZE (FIRMWARE_SECTORS_COUNT * IMAGE_CHUNK_SIZE)
|
||||
|
||||
typedef struct {
|
||||
uint32_t magic;
|
||||
|
@ -37,6 +37,8 @@ def format_vtrust(vtrust):
|
||||
IMAGE_HEADER_SIZE = 1024
|
||||
IMAGE_SIG_SIZE = 65
|
||||
IMAGE_CHUNK_SIZE = 128 * 1024
|
||||
BOOTLOADER_SECTORS_COUNT = 1
|
||||
FIRMWARE_SECTORS_COUNT = 6 + 7
|
||||
|
||||
|
||||
class BinImage(object):
|
||||
@ -152,7 +154,7 @@ class BinImage(object):
|
||||
class FirmwareImage(BinImage):
|
||||
|
||||
def __init__(self, data, vhdrlen):
|
||||
super(FirmwareImage, self).__init__(data[vhdrlen:], magic=b'TRZF', max_size=6 * IMAGE_CHUNK_SIZE)
|
||||
super(FirmwareImage, self).__init__(data[vhdrlen:], magic=b'TRZF', max_size=FIRMWARE_SECTORS_COUNT * IMAGE_CHUNK_SIZE)
|
||||
self.vhdrlen = vhdrlen
|
||||
self.vheader = data[:vhdrlen]
|
||||
|
||||
@ -166,7 +168,7 @@ class FirmwareImage(BinImage):
|
||||
class BootloaderImage(BinImage):
|
||||
|
||||
def __init__(self, data):
|
||||
super(BootloaderImage, self).__init__(data, magic=b'TRZB', max_size=1 * IMAGE_CHUNK_SIZE)
|
||||
super(BootloaderImage, self).__init__(data, magic=b'TRZB', max_size=BOOTLOADER_SECTORS_COUNT * IMAGE_CHUNK_SIZE)
|
||||
|
||||
|
||||
class VendorHeader(object):
|
||||
|
Loading…
Reference in New Issue
Block a user