admin管理员组

文章数量:1577824

硬件平台:高通8x10

基线版本:QRD8x12_KK_1903411

在完成了寄存器初始化、display 设备初始化之后,系统准备开始启动,在aboot.c文件中

void aboot_init(const struct app_descriptor *app)
{
	unsigned reboot_mode = 0;
	bool boot_into_fastboot = false;

	/* Setup page size information for nand/emmc reads */
	if (target_is_emmc_boot())
	{
		page_size = 2048;
		page_mask = page_size - 1;
	}
	else
	{
		page_size = flash_page_size();
		page_mask = page_size - 1;
	}

	ASSERT((MEMBASE + MEMSIZE) > MEMBASE);

	read_device_info(&device);

	target_serialno((unsigned char *) sn_buf);
	dprintf(SPEW,"serial number: %s\n",sn_buf);

	memset(display_panel_buf, '\0', MAX_PANEL_BUF_SIZE);

	/* Check if we should do something other than booting up */
	<span style="color:#000099;">if (keys_get_state(KEY_VOLUMEUP) && keys_get_state(KEY_VOLUMEDOWN))   //音量上下键选择进入emergency download mode,但在此之前需要配置这两个GPIO
	{
		dprintf(ALWAYS,"dload mode key sequence detected\n");
		if (set_download_mode(EMERGENCY_DLOAD))
		{
			dprintf(CRITICAL,"dload mode not supported by target\n");
		}
		else
		{
			reboot_device(0);
			dprintf(CRITICAL,"Failed to reboot into dload mode\n");
		}
		boot_into_fastboot = true;
	}</span>
	if (!boot_into_fastboot)
	{
		if (keys_get_state(KEY_HOME) || keys_get_state(KEY_VOLUMEUP))
			boot_into_recovery = 1;
		if (!boot_into_recovery &&
			(keys_get_state(KEY_BACK) || keys_get_state(KEY_VOLUMEDOWN)))
			boot_into_fastboot = true;
	}


在 target/msm8610/init.c中配置这两个音量键

#if MSM8610_C199
#define TLMM_VOL_UP_BTN_GPIO    72
#define TLMM_VOL_DOWN_BTN_GPIO  73
#else
#define TLMM_VOL_UP_BTN_GPIO    -1
#define TLMM_VOL_DOWN_BTN_GPIO  -1

/* Return 1 if vol_up pressed */
static int target_volume_up()
{
	uint8_t status = 0;

	gpio_tlmm_config(TLMM_VOL_UP_BTN_GPIO, 0, GPIO_INPUT, GPIO_PULL_UP, GPIO_2MA, GPIO_ENABLE);

	/* Wait for the configuration to complete.*/
	thread_sleep(1);
	/* Get status of GPIO */
	status = gpio_status(TLMM_VOL_UP_BTN_GPIO);
	/* Active low signal. */
	return !status;
}

/* Return 1 if vol_down pressed */
uint32_t target_volume_down()
{
#if 1
		uint8_t status = 0;
	
		if(TLMM_VOL_DOWN_BTN_GPIO == -1)
			return 0;
	
		gpio_tlmm_config(TLMM_VOL_DOWN_BTN_GPIO, 0, GPIO_INPUT, GPIO_PULL_UP, GPIO_2MA, GPIO_ENABLE);
	
		/* Wait for the configuration to complete.*/
		thread_sleep(1);
		/* Get status of GPIO */
		status = gpio_status(TLMM_VOL_DOWN_BTN_GPIO);

		/* Active low signal. */
		return !status;
#else

	/* Volume down button tied in with PMIC RESIN. */
	return pm8x41_resin_status();
#endif
}

int set_download_mode(enum dload_mode mode)   //这个函数在这个文件中是没有的,可以参考别的文件中
{
	
	dload_util_write_cookie(mode == NORMAL_DLOAD ?
		DLOAD_MODE_ADDR : EMERGENCY_DLOAD_MODE_ADDR, mode);
	
	pm8x41_clear_pmic_watchdog();
	return 0;
}



本文标签: EmergencyBootLoaderModeDownload