static int update_mcu_bin(struct ssp_data *data, int iBinType)
{
	int retry = BLMODE_RETRYCOUNT;
	int iRet = SUCCESS;
	struct stm32fwu_spi_cmd cmd;

	cmd.cmd = GO_COMMAND;
	cmd.xor_cmd = XOR_GO_COMMAND;
	cmd.timeout = 1000;
	cmd.ack_pad = (u8)((STM_APP_ADDR >> 24) & 0xFF);

    // 1. Start system boot mode
	do {
		iRet = change_to_bootmode(data);
		pr_info("[ssp] bootmode %d retry: %d\n", iRet, 3 - retry);
	} while (retry-- > 0 && iRet != BL_ACK );

	if(iRet != BL_ACK) {
		pr_err("[SSP]: %s - change_to_bootmode %d\n",
			__func__, iRet);
		return iRet;
	}

    // 2. Flash erase all
	iRet = fw_erase_stm(data->spi);
	if (iRet < 0) {
		pr_err("[SSP]: %s - fw_erase_stm %d\n",
			__func__, iRet);
		return iRet;
	}

	switch (iBinType) {
	case KERNEL_BINARY:
	 /* HW request: I2C line is reversed */
#if defined(CONFIG_SEC_KSPORTS_PROJECT)
		iRet = load_kernel_fw_bootmode(data->spi, BL_FW_NAME_TASMAN);
#else
		iRet = load_kernel_fw_bootmode(data->spi, BL_FW_NAME);
#endif
		break;
	case KERNEL_CRASHED_BINARY:
		iRet = load_kernel_fw_bootmode(data->spi, BL_CRASHED_FW_NAME);
		break;
	case UMS_BINARY:
		iRet = load_ums_fw_bootmode(data->spi, BL_UMS_FW_NAME);
		break;
	default:
		pr_err("[SSP] binary type error!!\n");
	}
/* STM : GO USER ADDR */
	stm32fwu_spi_send_cmd(data->spi, &cmd);
	send_addr(data->spi, STM_APP_ADDR, 0);

	data->spi->mode = SPI_MODE_1;
	if (spi_setup(data->spi))
		pr_err("failed to setup spi mode for app\n");
	usleep_range(1000, 1100);

	return iRet;
}
Exemple #2
0
static int update_mcu_bin(struct ssp_data *data, int iBinType)
{
	int retry = BLMODE_RETRYCOUNT;
	int iRet = SUCCESS;
	struct stm32fwu_spi_cmd cmd;

	cmd.cmd = GO_COMMAND;
	cmd.xor_cmd = XOR_GO_COMMAND;
	cmd.timeout = 1000;
	cmd.ack_pad = (u8)((STM_APP_ADDR >> 24) & 0xFF);

	do {
		iRet = change_to_bootmode(data);
		pr_info("[ssp] bootmode %d retry: %d\n", iRet, 3 - retry);
	} while (retry-- > 0 && iRet != BL_ACK );

	if(iRet != BL_ACK) {
		pr_err("[SSP]: %s - change_to_bootmode %d\n",
			__func__, iRet);
		return iRet;
	}

	iRet = fw_erase_stm(data->spi);
	if (iRet < 0) {
		pr_err("[SSP]: %s - fw_erase_stm %d\n",
			__func__, iRet);
		return iRet;
	}

	switch (iBinType) {
	case KERNEL_BINARY:
	 /* HW request: I2C line is reversed */
	iRet = load_kernel_fw_bootmode(data->spi,
		BL_FW_NAME);
		break;
	case KERNEL_CRASHED_BINARY:
		iRet = load_kernel_fw_bootmode(data->spi,
		BL_CRASHED_FW_NAME);
	break;
	case UMS_BINARY:
		iRet = load_ums_fw_bootmode(data->spi,
			BL_UMS_FW_NAME);
		break;

	default:
		pr_err("[SSP] binary type error!!\n");
	}
/* STM : GO USER ADDR */
	stm32fwu_spi_send_cmd(data->spi, &cmd);
	if (cmd.ack_loops > 0)
		send_addr(data->spi, STM_APP_ADDR, 1);
	else
		send_addr(data->spi, STM_APP_ADDR, 0);

	msleep(SSP_SW_RESET_TIME);

	return iRet;
}
static int update_mcu_bin(struct ssp_data *data, int iBinType)
{
	int retry = BLMODE_RETRYCOUNT;
	int iRet = SUCCESS;
	struct stm32fwu_spi_cmd cmd;

	cmd.cmd = GO_COMMAND;
	cmd.xor_cmd = XOR_GO_COMMAND;
	cmd.timeout = 1000;
	cmd.ack_pad = (u8)((STM_APP_ADDR >> 24) & 0xFF);

	pr_info("[SSP] update_mcu_bin\n");
	
    // 1. Start system boot mode
	do {
		iRet = change_to_bootmode(data);
		pr_info("[SSP] bootmode %d, retry = %d\n", iRet, 3 - retry);
	} while (retry-- > 0 && iRet != BL_ACK);

	if(iRet != BL_ACK) {
		pr_err("[SSP] %s, change_to_bootmode failed %d\n", __func__, iRet);
		return iRet;
	}
    // 2. Flash erase all
	iRet = fw_erase_stm(data->spi);
	if (iRet < 0) {
		pr_err("[SSP] %s, fw_erase_stm failed %d\n", __func__, iRet);
		return iRet;
	}
	pr_info("======[SSP] SCHEDULE!!!!!\n");
	schedule(); /*Defence for cpu schedule blocking watchdog*/
	msleep(3);
	
	switch (iBinType) {
	case KERNEL_BINARY:
	 /* HW request: I2C line is reversed */
		iRet = load_kernel_fw_bootmode(data->spi, BL_FW_NAME);
		break;
	case KERNEL_CRASHED_BINARY:
		iRet = load_kernel_fw_bootmode(data->spi, BL_CRASHED_FW_NAME);
		break;
	case UMS_BINARY:
		iRet = load_ums_fw_bootmode(data->spi, BL_UMS_FW_NAME);
		break;
	default:
		pr_err("[SSP] binary type error!!\n");
	}
	pr_info("======[SSP] SCHEDULE!!!!!\n");
	schedule(); /*Defence for cpu schedule blocking watchdog*/
	msleep(3);

/* STM : GO USER ADDR */
	stm32fwu_spi_send_cmd(data->spi, &cmd);
	send_addr(data->spi, STM_APP_ADDR, 0);

	return iRet;
}
static int update_mcu_bin(struct ssp_data *data, int iBinType)
{
	int retry = BLMODE_RETRYCOUNT;
	int iRet = SUCCESS;
	struct stm32fwu_spi_cmd cmd;

	cmd.cmd = GO_COMMAND;
	cmd.xor_cmd = XOR_GO_COMMAND;
	cmd.timeout = 1000;
	cmd.ack_pad = (u8)((STM_APP_ADDR >> 24) & 0xFF);

	/* 1. Start system boot mode */
	do {
		iRet = change_to_bootmode(data);
		ssp_info("bootmode %d retry: %d", iRet, 3 - retry);
	} while (retry-- > 0 && iRet != BL_ACK);

	if (iRet != BL_ACK) {
		ssp_errf("change_to_bootmode %d", iRet);
		return iRet;
	}

	/* 2. Flash erase all */
	iRet = fw_erase_stm(data->spi);
	if (iRet < 0) {
		ssp_errf("fw_erase_stm %d", iRet);
		return iRet;
	}

	switch (iBinType) {
	case KERNEL_BINARY:
	/* HW request: I2C line is reversed */
		iRet = load_kernel_fw_bootmode(data->spi, BL_FW_NAME);
		break;
	case KERNEL_CRASHED_BINARY:
		iRet = load_kernel_fw_bootmode(data->spi, BL_CRASHED_FW_NAME);
		break;
	case UMS_BINARY:
		iRet = load_ums_fw_bootmode(data->spi, BL_UMS_FW_NAME);
		break;
	default:
		ssp_err("binary type error!!");
	}

	/* STM : GO USER ADDR */
	stm32fwu_spi_send_cmd(data->spi, &cmd);
	send_addr(data->spi, STM_APP_ADDR, 0);

	data->spi->mode = SPI_MODE_1;
	if (spi_setup(data->spi))
		ssp_err("failed to setup spi mode for app");
	usleep_range(1000, 1100);

	return iRet;
}