Ejemplo n.º 1
0
int main(void)
{
	__stack_chk_guard = random32();
	setup();
	memory_protect();
	oledInit();

	// at least one button is unpressed
	uint16_t state = gpio_port_read(BTN_PORT);
	if ((state & BTN_PIN_YES) == BTN_PIN_YES || (state & BTN_PIN_NO) == BTN_PIN_NO) {

		check_firmware_sanity();

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

		uint8_t hash[32];
		if (!signatures_ok(hash)) {
			show_unofficial_warning(hash);
		}

		load_app();

	}

	bootloader_loop();

	return 0;
}
Ejemplo n.º 2
0
/*
 *  boot() - Runs through application firmware checking, and then boots
 *
 *  INPUT
 *      none
 *  OUTPUT
 *      true/false whether boot was successful
 *
 */
static bool boot(void)
{
    if(magic_ok())
    {
        layout_home();

        if(signatures_ok() == 0) /* Signature check failed */
        {
            delay_ms(500);

            if(!confirm_without_button_request("Unofficial Firmware",
                                               "Do you want to continue booting?"))
            {
                layout_simple_message("Boot Aborted");
                goto cancel_boot;
            }

            layout_home();
        }

        led_func(CLR_RED_LED);
        cm_disable_interrupts();
        set_vector_table_application();
        application_jump();
    }
    else
    {
        layout_simple_message("Please Reinstall Firmware");
        goto cancel_boot;
    }

cancel_boot:
    return(false);
}
Ejemplo n.º 3
0
static bool canDropPrivs(void)
{
    switch (get_bootloaderKind()) {
    case BLK_v1_0_0:
    case BLK_v1_0_1:
    case BLK_v1_0_2:
    case BLK_v1_0_3:
    case BLK_v1_0_3_elf:
    case BLK_v1_0_3_sig:
    case BLK_v1_0_4:
    case BLK_UNKNOWN:
        return true;
    case BLK_v1_1_0:
        return true;
    case BLK_v2_0_0:
        return SIG_OK == signatures_ok();
    }
    __builtin_unreachable();
}
Ejemplo n.º 4
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;
}