bootloader: work in progress

pull/25/head
Pavol Rusnak 7 years ago
parent 302f0e614a
commit 5bdfbb3469
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -60,7 +60,7 @@ TREZOR Core firmware consists of 3 parts:
###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 |
|-------:|-------:|------|-------------|

@ -83,6 +83,7 @@ SRC_C = \
bootloader/basic.c \
bootloader/bootloader.c \
bootloader/crypto.c \
bootloader/header.c \
bootloader/ui.c \
system_stm32.c \
$(wildcard boards/$(BOARD)/*.c)

@ -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;
}

@ -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 "display.h"
#include "toi_trezor.h"
#define ui_WHITE 0xFFFF
#define ui_BLACK 0x0000
#define ui_BLUE 0x24BE
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);
}
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__
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

Loading…
Cancel
Save