mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-05-02 06:59:01 +00:00
bootloader: work in progress
This commit is contained in:
parent
302f0e614a
commit
5bdfbb3469
@ -60,7 +60,7 @@ TREZOR Core firmware consists of 3 parts:
|
|||||||
|
|
||||||
###Vendor Header
|
###Vendor Header
|
||||||
|
|
||||||
Total length of vendor header is 82 + 32 * (number of pubkeys) + (length of vendor string) + (length of vendor image) bytes rounded up to the closest multiply of 256 bytes.
|
Total length of vendor header is 84 + 32 * (number of pubkeys) + (length of vendor string) + (length of vendor image) bytes rounded up to the closest multiply of 256 bytes.
|
||||||
|
|
||||||
| offset | length | name | description |
|
| offset | length | name | description |
|
||||||
|-------:|-------:|------|-------------|
|
|-------:|-------:|------|-------------|
|
||||||
|
@ -83,6 +83,7 @@ SRC_C = \
|
|||||||
bootloader/basic.c \
|
bootloader/basic.c \
|
||||||
bootloader/bootloader.c \
|
bootloader/bootloader.c \
|
||||||
bootloader/crypto.c \
|
bootloader/crypto.c \
|
||||||
|
bootloader/header.c \
|
||||||
bootloader/ui.c \
|
bootloader/ui.c \
|
||||||
system_stm32.c \
|
system_stm32.c \
|
||||||
$(wildcard boards/$(BOARD)/*.c)
|
$(wildcard boards/$(BOARD)/*.c)
|
||||||
|
29
micropython/stmhal/bootloader/header.c
Normal file
29
micropython/stmhal/bootloader/header.c
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#include <string.h>
|
||||||
|
#include "header.h"
|
||||||
|
|
||||||
|
bool read_header(const uint8_t *data, uint32_t *expiry, uint32_t *version, uint8_t *sigidx, uint8_t *sig)
|
||||||
|
{
|
||||||
|
uint32_t magic;
|
||||||
|
memcpy(&magic, data, 4);
|
||||||
|
if (magic != 0x425A5254) return false; // TRZB
|
||||||
|
|
||||||
|
uint32_t hdrlen;
|
||||||
|
memcpy(&hdrlen, data + 4, 4);
|
||||||
|
if (hdrlen != 256) return false;
|
||||||
|
|
||||||
|
memcpy(expiry, data + 8, 4);
|
||||||
|
|
||||||
|
uint32_t codelen;
|
||||||
|
memcpy(&codelen, data + 12, 4);
|
||||||
|
if (codelen != 64 * 1024) return false;
|
||||||
|
|
||||||
|
memcpy(version, data + 16, 4);
|
||||||
|
|
||||||
|
// reserved
|
||||||
|
|
||||||
|
memcpy(sigidx, data + 0x00BF, 1);
|
||||||
|
|
||||||
|
memcpy(sig, data + 0x00C0, 64);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
9
micropython/stmhal/bootloader/header.h
Normal file
9
micropython/stmhal/bootloader/header.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#ifndef __BOOTLOADER_HEADER_H__
|
||||||
|
#define __BOOTLOADER_HEADER_H__
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
bool read_header(const uint8_t *data, uint32_t *expiry, uint32_t *version, uint8_t *sigidx, uint8_t *sig);
|
||||||
|
|
||||||
|
#endif
|
File diff suppressed because one or more lines are too long
@ -1,43 +1,10 @@
|
|||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
|
||||||
#include "toi_trezor.h"
|
|
||||||
|
|
||||||
#define ui_WHITE 0xFFFF
|
#define ui_WHITE 0xFFFF
|
||||||
#define ui_BLACK 0x0000
|
#define ui_BLACK 0x0000
|
||||||
#define ui_BLUE 0x24BE
|
|
||||||
|
|
||||||
void screen_welcome(void)
|
void screen_welcome(void)
|
||||||
{
|
{
|
||||||
display_icon(0, 0, 240, 240, toi_trezor, sizeof(toi_trezor), ui_WHITE, ui_BLACK);
|
|
||||||
display_text(0, 240, "bootloader", 10, FONT_MONO, ui_WHITE, ui_BLACK);
|
display_text(0, 240, "bootloader", 10, FONT_MONO, ui_WHITE, ui_BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
void screen_info(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void screen_upload_request(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void screen_upload_progress(int permil)
|
|
||||||
{
|
|
||||||
char label[5] = "100%";
|
|
||||||
char *plabel = label;
|
|
||||||
// TODO: convert permil -> plabel
|
|
||||||
display_text_center(120, 192 + 32, "Uploading firmware", -1, FONT_NORMAL, ui_WHITE, ui_BLACK);
|
|
||||||
display_loader(permil, 0, ui_BLUE, ui_BLACK, 0, 0, 0);
|
|
||||||
display_text_center(120, 192 / 2 + 14 / 2, plabel, -1, FONT_BOLD, ui_WHITE, ui_BLACK);
|
|
||||||
display_refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
void screen_upload_success(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void screen_upload_abort(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
@ -2,10 +2,5 @@
|
|||||||
#define __BOOTLOADER_UI_H__
|
#define __BOOTLOADER_UI_H__
|
||||||
|
|
||||||
void screen_welcome(void);
|
void screen_welcome(void);
|
||||||
void screen_info(void);
|
|
||||||
void screen_upload_request(void);
|
|
||||||
void screen_upload_progress(int permil);
|
|
||||||
void screen_upload_success(void);
|
|
||||||
void screen_upload_abort(void);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user