[U-Boot] [PATCH] test: dfu: script: wrong md5sum on nand partitions

Lukasz Majewski l.majewski at samsung.com
Mon Sep 15 11:45:46 CEST 2014


Hi Heiko,

> Hello Stephen,
> 
> add Lukasz to Cc ...
> 
> Am 12.09.2014 16:53, schrieb Stephen Warren:
> > On 09/12/2014 12:27 AM, Heiko Schocher wrote:
> >> when uplaoding a file, at least from a nand partition, the complete
> >> mtd nand partition size is transferred. This leads in a wrong
> >> md5sum as the filesize is different between the downloaded file
> >> and the uploaded file. Limit the uploaded filesize to the
> >> downloaded fixes this.
> >
> > I was going to say that it'd be better to fix U-Boot's NAND code to
> > transfer the correct amount of data. However, I suppose the correct
> > amount *is* the whole partition for anything other than a
> > filesystem file. As such, I'd suggest replacing "nand" in the patch
> > description with something else, since presumably the exact same
> > issue applies to partitions on eMMC. The issue applies to any
> > partition.
> 
> Yes, you are right.

It is the case with testing "raw"/"partition" write. 

With NAND the procedure is as follows:
1. Erase NAND (0xFF on the whole partition)
2. Store the new partition (very rarely the partition.img == NAND
partition size). Very often partition.img < NAND partition.
3. The NAND code reads the whole partition (including the 0xFF padding).

This padding causes md5sum to be wrong.

> 
> > I wonder if there's a way to distinguish between file tests and
> > partition tests in dfu_gadget_test.sh, so that the $N_FILE_FULL ->
> > $N_FILE conversion can be applied only for partitions. Otherwise, a
> > file upload/download test could end up changing (increasing) the
> > file length and this bug wouldn't be detected.
> 
> Lukasz could better comment on this ... currently filesize is changed
> on a raw partition, as the test download for example 960 bytes, and
> reads back the hole partition size ... which leads in a wrong md5sum.
> 
> It would be good to have in the DFU protcol a length parameter ...
> so a device could at transfer start decide, if the filesize fits into
> the partition, if not, no need to tranfser the hole file, and detect
> this error at the end (with a broken partition now) ...

Yes, the lack of "size" parameter is very inconvenient (for example
we must then allocate bigger buffers than needed). 

However, for testing purposes we can introduce new test file name
"part_<file_size>.img" - e.g. part_32M.img.
Then this would indicate the test for the whole partition.

The legacy dat_<file_size>.img (e.g. dat_960.img) would be truncated if
needed in the script. 

This is a quick solution.

Other thoughts:

1. In the dfu-util repo there is the dfu-prefix tool. It allows
generating some special prefix for LPC and TI Stellaris SoCs. 
Maybe we could think about "u-boot" prefix and put there for example
binary size and signature data.

2. The dfu-util 0.7 on the HOST when -l is typed shows the name="" and
serial="". If it was possible to add serial, then we could extend
dfu-util to show size of the alt setting.

In this way we could always perform truncation on the uploaded file in
the host.

> 
> bye,
> Heiko



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group


More information about the U-Boot mailing list