示例#1
0
int str9xpec_handle_flash_options_read_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
	flash_bank_t *bank;
	u8 status;
	str9xpec_flash_controller_t *str9xpec_info = NULL;

	if (argc < 1)
	{
		command_print(cmd_ctx, "str9xpec options_read <bank>");
		return ERROR_OK;
	}

	bank = get_flash_bank_by_num(strtoul(args[0], NULL, 0));
	if (!bank)
	{
		command_print(cmd_ctx, "flash bank '#%s' is out of bounds", args[0]);
		return ERROR_OK;
	}

	str9xpec_info = bank->driver_priv;

	status = str9xpec_read_config(bank);

	if ((status & ISC_STATUS_ERROR) != STR9XPEC_ISC_SUCCESS)
		return ERROR_FLASH_OPERATION_FAILED;

	/* boot bank */
	if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_CSMAPBIT, 1))
		command_print(cmd_ctx, "CS Map: bank1");
	else
		command_print(cmd_ctx, "CS Map: bank0");

	/* OTP lock */
	if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_OTPBIT, 1))
		command_print(cmd_ctx, "OTP Lock: OTP Locked");
	else
		command_print(cmd_ctx, "OTP Lock: OTP Unlocked");

	/* LVD Threshold */
	if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_LVDTHRESBIT, 1))
		command_print(cmd_ctx, "LVD Threshold: 2.7v");
	else
		command_print(cmd_ctx, "LVD Threshold: 2.4v");

	/* LVD reset warning */
	if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_LVDWARNBIT, 1))
		command_print(cmd_ctx, "LVD Reset Warning: VDD or VDDQ Inputs");
	else
		command_print(cmd_ctx, "LVD Reset Warning: VDD Input Only");

	/* LVD reset select */
	if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_LVDSELBIT, 1))
		command_print(cmd_ctx, "LVD Reset Selection: VDD or VDDQ Inputs");
	else
		command_print(cmd_ctx, "LVD Reset Selection: VDD Input Only");

	return ERROR_OK;
}
示例#2
0
int str9xpec_protect(struct flash_bank_s *bank, int set, int first, int last)
{
	u8 status;
	int i;

	str9xpec_flash_controller_t *str9xpec_info = bank->driver_priv;

	status = str9xpec_read_config(bank);

	if ((status & ISC_STATUS_ERROR) != STR9XPEC_ISC_SUCCESS)
		return ERROR_FLASH_OPERATION_FAILED;

	LOG_DEBUG("protect: first_bank: %i, last_bank: %i", first, last);

	/* last bank: 0xFF signals a full device protect */
	if (last == 0xFF)
	{
		if( set )
		{
			status = str9xpec_lock_device(bank);
		}
		else
		{
			/* perform full erase to unlock device */
			status = str9xpec_unlock_device(bank);
		}
	}
	else
	{
		for (i = first; i <= last; i++)
		{
			if( set )
				buf_set_u32(str9xpec_info->options, str9xpec_info->sector_bits[i], 1, 1);
			else
				buf_set_u32(str9xpec_info->options, str9xpec_info->sector_bits[i], 1, 0);
		}

		status = str9xpec_write_options(bank);
	}

	if ((status & ISC_STATUS_ERROR) != STR9XPEC_ISC_SUCCESS)
		return ERROR_FLASH_OPERATION_FAILED;

	return ERROR_OK;
}
示例#3
0
static int str9xpec_protect_check(struct flash_bank *bank)
{
	uint8_t status;
	int i;

	struct str9xpec_flash_controller *str9xpec_info = bank->driver_priv;

	status = str9xpec_read_config(bank);

	for (i = 0; i < bank->num_sectors; i++) {
		if (buf_get_u32(str9xpec_info->options, str9xpec_info->sector_bits[i], 1))
			bank->sectors[i].is_protected = 1;
		else
			bank->sectors[i].is_protected = 0;
	}

	if ((status & ISC_STATUS_ERROR) != STR9XPEC_ISC_SUCCESS)
		return ERROR_FLASH_OPERATION_FAILED;
	return ERROR_OK;
}