コード例 #1
0
int main(void)
{
#ifndef APPVER
	setup();
#endif
	__stack_chk_guard = random32(); // this supports compiler provided unpredictable stack protection checks
#ifndef APPVER
	memory_protect();
	oledInit();
#endif

#ifndef APPVER
	// at least one button is unpressed
	uint16_t state = gpio_port_read(BTN_PORT);
	int unpressed = ((state & BTN_PIN_YES) == BTN_PIN_YES || (state & BTN_PIN_NO) == BTN_PIN_NO);

	if (firmware_present() && unpressed) {

		oledClear();
		oledDrawBitmap(40, 0, &bmp_logo64_empty);
		oledRefresh();

		uint8_t hash[32];
		int signed_firmware = signatures_ok(hash);
		if (SIG_OK != signed_firmware) {
			show_unofficial_warning(hash);
			timer_init();
		}

		load_app(signed_firmware);
	}
#endif

	bootloader_loop();

	return 0;
}
コード例 #2
0
ファイル: layout.c プロジェクト: dashpay/trezor-mcu
void layoutDialog(const BITMAP *icon, const char *btnNo, const char *btnYes, const char *desc, const char *line1, const char *line2, const char *line3, const char *line4, const char *line5, const char *line6)
{
	int left = 0;
	oledClear();
	if (icon) {
		oledDrawBitmap(0, 0, icon);
		left = icon->width + 4;
	}
	if (line1) oledDrawString(left, 0 * 9, line1);
	if (line2) oledDrawString(left, 1 * 9, line2);
	if (line3) oledDrawString(left, 2 * 9, line3);
	if (line4) oledDrawString(left, 3 * 9, line4);
	if (desc) {
		oledDrawStringCenter(OLED_HEIGHT - 2 * 9 - 1, desc);
		if (btnYes || btnNo) {
			oledHLine(OLED_HEIGHT - 21);
		}
	} else {
		if (line5) oledDrawString(left, 4 * 9, line5);
		if (line6) oledDrawString(left, 5 * 9, line6);
		if (btnYes || btnNo) {
			oledHLine(OLED_HEIGHT - 13);
		}
	}
	if (btnNo) {
		oledDrawString(1, OLED_HEIGHT - 8, "\x15");
		oledDrawString(fontCharWidth('\x15') + 3, OLED_HEIGHT - 8, btnNo);
		oledInvert(0, OLED_HEIGHT - 9, fontCharWidth('\x15') + oledStringWidth(btnNo) + 2, OLED_HEIGHT - 1);
	}
	if (btnYes) {
		oledDrawString(OLED_WIDTH - fontCharWidth('\x06') - 1, OLED_HEIGHT - 8, "\x06");
		oledDrawString(OLED_WIDTH - oledStringWidth(btnYes) - fontCharWidth('\x06') - 3, OLED_HEIGHT - 8, btnYes);
		oledInvert(OLED_WIDTH - oledStringWidth(btnYes) - fontCharWidth('\x06') - 4, OLED_HEIGHT - 9, OLED_WIDTH - 1, OLED_HEIGHT - 1);
	}
	oledRefresh();
}
コード例 #3
0
ファイル: oled.c プロジェクト: ddworken/trezor-mcu
void oledSetDebug(char set)
{
	is_debug_mode = set;
	oledRefresh();
}
コード例 #4
0
ファイル: oled.c プロジェクト: axic/trezor-mcu
void oledSetDebug(bool set)
{
	is_debug_mode = set;
	oledRefresh();
}
コード例 #5
0
ファイル: oled.c プロジェクト: trezor/trezor-mcu
void oledSetDebugLink(bool set) {
  is_debug_link = set;
  oledRefresh();
}
コード例 #6
0
ファイル: layout2.c プロジェクト: antonio-fr/trezor-mcu-hid
void layoutAddress(const char *address, const char *desc, bool qrcode, bool ignorecase, const uint32_t *address_n, size_t address_n_count, bool address_is_account)
{
	if (layoutLast != layoutAddress) {
		layoutSwipe();
	} else {
		oledClear();
	}
	layoutLast = layoutAddress;

	uint32_t addrlen = strlen(address);
	if (qrcode) {
		static unsigned char bitdata[QR_MAX_BITDATA];
		char address_upcase[addrlen + 1];
		if (ignorecase) {
			for (uint32_t i = 0; i < addrlen + 1; i++) {
				address_upcase[i] = address[i] >= 'a' && address[i] <= 'z' ?
					address[i] + 'A' - 'a' : address[i];
			}
		}
		int side = qr_encode(addrlen <= (ignorecase ? 60 : 40) ? QR_LEVEL_M : QR_LEVEL_L, 0,
							 ignorecase ? address_upcase : address, 0, bitdata);

		oledInvert(0, 0, 63, 63);
		if (side > 0 && side <= 29) {
			int offset = 32 - side;
			for (int i = 0; i < side; i++) {
				for (int j = 0; j< side; j++) {
					int a = j * side + i;
					if (bitdata[a / 8] & (1 << (7 - a % 8))) {
						oledBox(offset + i * 2, offset + j * 2,
								offset + 1 + i * 2, offset + 1 + j * 2, false);
					}
				}
			}
		} else if (side > 0 && side <= 60) {
			int offset = 32 - (side / 2); 
			for (int i = 0; i < side; i++) {
				for (int j = 0; j< side; j++) {
					int a = j * side + i;
					if (bitdata[a / 8] & (1 << (7 - a % 8))) {
						oledClearPixel(offset + i, offset + j);
					}
				}
			}
		}
	} else {
		if (desc) {
			oledDrawString(0, 0 * 9, desc, FONT_STANDARD);
		}
		if (addrlen > 10) { // don't split short addresses
			uint32_t rowlen = (addrlen - 1) / (addrlen <= 42 ? 2 : addrlen <= 63 ? 3 : 4) + 1;
			const char **str = split_message((const uint8_t *)address, addrlen, rowlen);
			for (int i = 0; i < 4; i++) {
				oledDrawString(0, (i + 1) * 9 + 4, str[i], FONT_FIXED);
			}
		} else {
			oledDrawString(0, (0 + 1) * 9 + 4, address, FONT_FIXED);
		}
		oledDrawString(0, 42, address_n_str(address_n, address_n_count, address_is_account), FONT_STANDARD);
	}

	if (!qrcode) {
		layoutButtonNo(_("QR Code"));
	}

	layoutButtonYes(_("Continue"));
	oledRefresh();
}
コード例 #7
0
ファイル: layout2.c プロジェクト: antonio-fr/trezor-mcu-hid
void layoutScreensaver(void)
{
	layoutLast = layoutScreensaver;
	oledClear();
	oledRefresh();
}