Example #1
0
int fastboot_init(void *base, unsigned size)
{
	thread_t *thr;
	dprintf(INFO, "fastboot_init()\n");

	download_base = base;
	download_max = size;

	event_init(&usb_online, 0, EVENT_FLAG_AUTOUNSIGNAL);
	event_init(&txn_done, 0, EVENT_FLAG_AUTOUNSIGNAL);

	in = udc_endpoint_alloc(UDC_TYPE_BULK_IN, 512);
	if (!in)
		goto fail_alloc_in;
	out = udc_endpoint_alloc(UDC_TYPE_BULK_OUT, 512);
	if (!out)
		goto fail_alloc_out;

	fastboot_endpoints[0] = in;
	fastboot_endpoints[1] = out;

	req = udc_request_alloc();
	if (!req)
		goto fail_alloc_req;

	if (udc_register_gadget(&fastboot_gadget))
		goto fail_udc_register;

	fastboot_register("getvar:", cmd_getvar);
	fastboot_register("download:", cmd_download);
	fastboot_publish("version", "0.5");

	thr = thread_create("fastboot", fastboot_handler, 0, DEFAULT_PRIORITY, 4096);
	if (!thr)
	{
		goto fail_alloc_in;
	}
	thread_resume(thr);
	return 0;

fail_udc_register:
	udc_request_free(req);
fail_alloc_req:
	udc_endpoint_free(out);	
fail_alloc_out:
	udc_endpoint_free(in);
fail_alloc_in:
	return -1;
}
Example #2
0
int fastboot_init(void *base, unsigned size)
{
	thread_t *thr;

	dprintf(ALWAYS, "fastboot_init()\n");

	download_base = base;
	download_max = size;

	mtk_wdt_disable(); /*It will re-enable during continue boot*/

	fastboot_register("getvar:", cmd_getvar, FALSE);
	fastboot_publish("version", "0.5");
#ifndef USER_BUILD
	fastboot_register("boot", cmd_boot, FALSE);
#endif
	fastboot_register("signature", cmd_install_sig, FALSE);

#ifdef MTK_EMMC_SUPPORT
	fastboot_register("flash:", cmd_flash_emmc, TRUE);
	#ifndef USER_BUILD
	fastboot_register("erase:", cmd_erase_emmc, FALSE);
	#endif
#else
	fastboot_register("flash:", cmd_flash_nand, TRUE);
	#ifndef USER_BUILD
	fastboot_register("erase:", cmd_erase_nand, FALSE);
	#endif
#endif

	fastboot_register("continue", cmd_continue, FALSE);
	fastboot_register("reboot", cmd_reboot, FALSE);
	fastboot_register("reboot-bootloader", cmd_reboot_bootloader, FALSE);
	fastboot_publish("product", TARGET(BOARD));
	fastboot_publish("kernel", "lk");
	//fastboot_publish("serialno", sn_buf);

	register_parition_var();


	/*LXO: Download related command*/
	fastboot_register("download:", cmd_download, TRUE);

	/*LXO: END!Download related command*/

	fastboot_oem_register();

    fastboot_register("oem p2u", cmd_oem_p2u, FALSE);
    fastboot_register("oem reboot-recovery",cmd_oem_reboot2recovery, FALSE);
	event_init(&usb_online, 0, EVENT_FLAG_AUTOUNSIGNAL);
	event_init(&txn_done, 0, EVENT_FLAG_AUTOUNSIGNAL);

	in = udc_endpoint_alloc(UDC_TYPE_BULK_IN, 512);
	if (!in)
		goto fail_alloc_in;
	out = udc_endpoint_alloc(UDC_TYPE_BULK_OUT, 512);
	if (!out)
		goto fail_alloc_out;

	fastboot_endpoints[0] = in;
	fastboot_endpoints[1] = out;

	req = udc_request_alloc();
	if (!req)
		goto fail_alloc_req;

	if (udc_register_gadget(&fastboot_gadget))
		goto fail_udc_register;

	thr = thread_create("fastboot", fastboot_handler, 0, DEFAULT_PRIORITY, 4096);
	if (!thr)
	{
		goto fail_alloc_in;
	}
	thread_resume(thr);
	return 0;

fail_udc_register:
	udc_request_free(req);
fail_alloc_req:
	udc_endpoint_free(out);
fail_alloc_out:
	udc_endpoint_free(in);
fail_alloc_in:
	return -1;
}
Example #3
0
int fastboot_init(void *base, unsigned size)
{
	thread_t *thr;

	dprintf(ALWAYS, "fastboot_init()\n");

	download_base = base;
	download_max = size;

	//mtk_wdt_disable(); /*It will re-enable during continue boot*/
	timer_initialize(&wdt_timer);
	timer_set_periodic(&wdt_timer, 5000, (timer_callback)mtk_wdt_restart, NULL);

	fastboot_register("getvar:", cmd_getvar, TRUE);
	fastboot_publish("version", "0.5");
#ifndef USER_BUILD
	fastboot_register("boot", cmd_boot, FALSE);
#endif
	fastboot_register("signature", cmd_install_sig, FALSE);
#ifdef USE_G_ORIGINAL_PROTOCOL

	fastboot_register("flash:", cmd_flash_mmc, TRUE);
	#ifndef USER_BUILD
	fastboot_register("erase:", cmd_erase_mmc, TRUE);
	#endif
#else
#ifdef MTK_EMMC_SUPPORT
	fastboot_register("flash:", cmd_flash_emmc, TRUE);
	#ifndef USER_BUILD
	fastboot_register("erase:", cmd_erase_emmc, TRUE);
	#endif
#else
	fastboot_register("flash:", cmd_flash_nand, TRUE);
	#ifndef USER_BUILD
	fastboot_register("erase:", cmd_erase_nand, TRUE);
	#endif
#endif

#endif


	fastboot_register("continue", cmd_continue, FALSE);
	fastboot_register("reboot", cmd_reboot, FALSE);
	fastboot_register("reboot-bootloader", cmd_reboot_bootloader, FALSE);
	fastboot_publish("product", TARGET(BOARD));
	fastboot_publish("kernel", "lk");
	register_secure_unlocked_var();
#ifdef MTK_OFF_MODE_CHARGE_SUPPORT
	register_off_mode_charge_var();
#endif
	//fastboot_publish("serialno", sn_buf);

	register_parition_var();


	/*LXO: Download related command*/
	fastboot_register("download:", cmd_download, TRUE);
	fastboot_publish("max-download-size", "0x8000000"); //128M = 134217728
	/*LXO: END!Download related command*/

	fastboot_oem_register();

    fastboot_register("oem p2u", cmd_oem_p2u, FALSE);
    fastboot_register("oem reboot-recovery",cmd_oem_reboot2recovery, FALSE);
    fastboot_register("oem append-cmdline",cmd_oem_append_cmdline,FALSE);
#ifdef MTK_OFF_MODE_CHARGE_SUPPORT
	fastboot_register("oem off-mode-charge",cmd_oem_off_mode_charge,FALSE);
#endif
    #ifdef MTK_TC7_COMMON_DEVICE_INTERFACE
    fastboot_register("oem auto-ADB",cmd_oem_ADB_Auto_Enable,FALSE);
    #endif
#if defined(MTK_SECURITY_SW_SUPPORT) && defined(MTK_SEC_FASTBOOT_UNLOCK_SUPPORT)
    fastboot_register("oem unlock",fastboot_oem_unlock, TRUE);
    fastboot_register("oem lock",fastboot_oem_lock, TRUE);
    fastboot_register("oem key",fastboot_oem_key,TRUE);
    fastboot_register("oem lks",fastboot_oem_query_lock_state,TRUE);
#endif
	event_init(&usb_online, 0, EVENT_FLAG_AUTOUNSIGNAL);
	event_init(&txn_done, 0, EVENT_FLAG_AUTOUNSIGNAL);

	in = udc_endpoint_alloc(UDC_TYPE_BULK_IN, 512);
	if (!in)
		goto fail_alloc_in;
	out = udc_endpoint_alloc(UDC_TYPE_BULK_OUT, 512);
	if (!out)
		goto fail_alloc_out;

	fastboot_endpoints[0] = in;
	fastboot_endpoints[1] = out;

	req = udc_request_alloc();
	if (!req)
		goto fail_alloc_req;

	if (udc_register_gadget(&fastboot_gadget))
		goto fail_udc_register;

	thr = thread_create("fastboot", fastboot_handler, 0, DEFAULT_PRIORITY, 4096);
	if (!thr)
	{
		goto fail_alloc_in;
	}
	thread_resume(thr);
	return 0;

fail_udc_register:
	udc_request_free(req);
fail_alloc_req:
	udc_endpoint_free(out);
fail_alloc_out:
	udc_endpoint_free(in);
fail_alloc_in:
	return -1;
}