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;
}
static int update_mcu_bin(struct ssp_data *data, int iBinType)
{
	int iRet = SUCCESS;

	pr_info("[SSP] ssp_change_to_bootmode\n");
	change_to_bootmode(data);
	data->client->addr = BOOTLOADER_SLAVE_ADDR;

	switch (iBinType) {
	case KERNEL_BINARY:
		iRet = load_kernel_fw_bootmode(data->client, BL_FW_NAME);
		break;
	case KERNEL_CRASHED_BINARY:
		iRet = load_kernel_fw_bootmode(data->client,
				BL_CRASHED_FW_NAME);
		break;
	case UMS_BINARY:
		iRet = load_ums_fw_bootmode(data->client, BL_UMS_FW_NAME);
		break;
	default:
		pr_err("[SSP] binary type error!!\n");
	}

	msleep(SSP_SW_RESET_TIME);

	data->client->addr = APP_SLAVE_ADDR;

	return iRet;
}
Exemple #3
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;
}
Exemple #6
0
int update_crashed_mcu_bin(struct ssp_data *data)
{
	int iRet = 0;
	pr_info("[SSP] ssp_change_to_bootmode\n");
	change_to_bootmode(data);
	data->client->addr = BOOTLOADER_SLAVE_ADDR;
	iRet = load_fw_bootmode(data->client, BL_CRASHED_FW_NAME);

	msleep(SSP_SW_RESET_TIME);

	data->client->addr = APP_SLAVE_ADDR;
	data->bBinaryChashed = true;
	return iRet;
}
static int update_mcu_bin(struct ssp_data *data, int iBinType)
{

        int iRet = SUCCESS;
        uint8_t bfr[3];

        pr_info("[SSP] ssp_change_to_bootmode\n");
        change_to_bootmode(data);

        iRet = spi_read_wait_chg(data, bfr, 3);
        if (iRet < 0) {
	        pr_err("[SSP] unable to contact bootmode = %d\n", iRet);
               return iRet;
        }

        if (bfr[1] != BL_VERSION ||
             bfr[2] != BL_EXTENDED) {
                pr_err("[SSP] unable to enter bootmode= %d\n", iRet);
                return -EIO;
        }

	switch (iBinType) {
	case KERNEL_BINARY:
#if defined(CONFIG_SENSORS_MPU6500_BMI058_DUAL)
		if (data->ap_rev < MPU6500_REV)
			iRet = load_kernel_fw_bootmode(data,	BL_BMI_FW_NAME);
		else
			iRet = load_kernel_fw_bootmode(data,	BL_FW_NAME);
#else
		iRet = load_kernel_fw_bootmode(data,	BL_FW_NAME);
#endif
		break;
	case KERNEL_CRASHED_BINARY:
		iRet = load_kernel_fw_bootmode(data,	BL_CRASHED_FW_NAME);
		break;
	case UMS_BINARY:
		iRet = load_ums_fw_bootmode(data, BL_UMS_FW_NAME);
		break;
	default:
		pr_err("[SSP] binary type error!!\n");
	}

	return iRet;
}
Exemple #8
0
int update_mcu_bin(struct ssp_data *data)
{
	int iRet = 0;

	pr_info("[SSP] ssp_change_to_bootmode\n");
	change_to_bootmode(data);
	data->client->addr = BOOTLOADER_SLAVE_ADDR;
	iRet = load_fw_bootmode(data->client, BL_FW_NAME);

	msleep(SSP_SW_RESET_TIME);

	data->client->addr = APP_SLAVE_ADDR;

	if (iRet < 0)
		data->bSspShutdown = true;
	else
		data->bSspShutdown = false;

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

	pr_info("[SSP] ssp_change_to_bootmode\n");
	change_to_bootmode(data);
	data->client->addr = BOOTLOADER_SLAVE_ADDR;

	switch (iBinType) {
	case KERNEL_BINARY:
		if (data->ssp_changes == SSP_MCU_L0)
			iRet = load_kernel_fw_bootmode(data->client,
				BL_FW_NAME_L0);
		else /* SSP_MCU_L5 */
#if defined(CONFIG_MACH_JACTIVESKT)
			iRet = load_kernel_fw_bootmode(data->client,
				BL_FW_NAME_FORTIUS); // for fortius-kor models
#else
			iRet = load_kernel_fw_bootmode(data->client,
				BL_FW_NAME_03);
#endif
		break;
	case KERNEL_CRASHED_BINARY:
		iRet = load_kernel_fw_bootmode(data->client,
		BL_CRASHED_FW_NAME);
	break;
	case UMS_BINARY:
		iRet = load_ums_fw_bootmode(data->client,
			BL_UMS_FW_NAME);
		break;
	default:
		pr_err("[SSP] binary type error!!\n");
	}

	msleep(SSP_SW_RESET_TIME);

	data->client->addr = APP_SLAVE_ADDR;

	return iRet;
}