Skip to content

Conversation

@kencphuang
Copy link

  1. For some specific ufs devices, they need flash entire fw once. So Increase chunk size from 256 KB to 512 KB.

TEST=ufs-utils ffu -t 0 -p /dev/bsg/0:0:0:0 -w FW.bin

Copy link
Contributor

@arthur-simchaev-sndk arthur-simchaev-sndk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test your change? I don't think MAX_IOCTL_BUF_SIZE definition is using in ffu.
256KB chuck size is the default value, in case you need another chunk size, use -s option.
Also in case ffu file cannot flashed by any 4k aligned chunk, is UFS spec violation

@kencphuang
Copy link
Author

kencphuang commented Oct 18, 2023

Hi arthur,

Yes, I've verify that.
Here is the limitation between 4k~256k. When setting " -s 512" it would display error.

# ufs-utils ffu -t 0 ... -s 512 

 Err: The chunk should be multiple value of 4k, between 4k and 256k

It will check chunk size when ffu in options.c method "verify_and_set_ffu_chunk_size".

#default chunk size
...
	if (options->config_type_inx == FFU_TYPE) {
		if (options->size == INVALID)
			options->size = MAX_IOCTL_BUF_SIZE; <= default chunk size
...
# if use -s
		case 's':
			if (options->config_type_inx == FFU_TYPE)
				rc = verify_and_set_ffu_chunk_size(options);
...
static int verify_and_set_ffu_chunk_size(struct tool_options *options)
{
...
options->size = chunk_size_kb * 1024;
	if ((options->size > MAX_IOCTL_BUF_SIZE) ||    <==== MAX_IOCTL_BUF_SIZE used here
		(options->size % ALIGNMENT_CHUNK_SIZE)) {
		print_error("The chunk should be multiple value of 4k, between 4k and %dk",   <=====above error message
				MAX_IOCTL_BUF_SIZE / 1024);
		goto out;
	}
...

@kencphuang kencphuang closed this Oct 18, 2023
@kencphuang kencphuang reopened this Oct 18, 2023
@kencphuang
Copy link
Author

Hi arthur,

Could we need to set default chunk size instead of using MAX_IOCTL_BUF_SIZE?

#default chunk size
...
	if (options->config_type_inx == FFU_TYPE) {
		if (options->size == INVALID)
			options->size = MAX_IOCTL_BUF_SIZE; <= default chunk size
...

Could we define like "DEFAULT_IOCTL_BUF_SIZE = 256kb" ?

#MAX_IOCTL_BUF_SIZE    (512L * 1024)
#DEFAULT_IOCTL_BUF_SIZE   (256L * 1024)

#options.c 
...
	if (options->config_type_inx == FFU_TYPE) {
		if (options->size == INVALID)
			options->size = DEFAULT_IOCTL_BUF_SIZE ; <=using "DEFAULT_IOCTL_BUF_SIZE " to set  default chunk size
...

Once we need use other chunk size, use options "-s" to set between 4K~512K.

1. For some specific ufs devices, they need flash entire fw once.
So Increase MAX chunk size from 256 KB to 512 KB.
2. Set default chunk size 256KB

TEST=ufs-utils ffu -t 0 -p /dev/bsg/0\:0\:0\:0 -w FW.bin
@kencphuang
Copy link
Author

kencphuang commented Oct 20, 2023 via email

@arthur-simchaev-sndk
Copy link
Contributor

Hi
As I mentioned, writing an ffu file in just one piece is a violation of the UFS specification. What if another device vendor defines the flash file as 1MB or more, which can be flashed only in one shot?
See the part form the spec:

UFS FFU uses the following mechanism:

Host delivers the microcode using one or more WRITE BUFFER commands through any logical unit which supports the WRITE BUFFER command. The host specifies: MODE = 0Eh, BUFFER OFFSET, which should be aligned to 4 Kbyte, BUFFER ID = 00h, and the PARAMETER LIST LENGTH field indicating the number of bytes to be transferred. All WRITE BUFFER commands should be sent to the same logical unit with task attribute set to simple or ordered. In the sequence of WRITE BUFFER commands used to deliver the microcode, the BUFFER OFFSET values should be in increasing order and it should start from zero.

@kencphuang
Copy link
Author

Hi arthur,

As I mentioned, writing an ffu file in just one piece is a violation of the UFS specification. What if another device vendor defines the flash file as 1MB or more, which can be flashed only in one shot?

In our case, the device can use one or more WRITE BUFFER commands. But I need use "-s" to set trunk size 512KB under hw restrictions.

In my patch, still set 256 KB as default trunk size. For other special cases , we can use "-s" to set trunk size between 4KB ~ 512 KB.

Is it possible to increase max trunk size from 256KB to 512KB when using -s parameter under hw restrictions ?

Or do you have any suggestions? Many thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants