public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Lukasz Majewski <l.majewski@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3] dfu: Introduction of the "dfu_hash_algo" env variable for checksum method setting
Date: Fri, 09 May 2014 11:54:00 +0200	[thread overview]
Message-ID: <20140509115400.057053ab@amdc2363> (raw)
In-Reply-To: <20140509083154.2B66038060C@gemini.denx.de>

Hi Wolfgang,

> Dear Lukasz,
> 
> In message <20140509085203.31133238@amdc2363> you wrote:
> > 
> > For automated tests I use MD5 and compare this value before sending
> > data to target via DFU and after I read it. This testing is done
> > purely on HOST machine.
> 
> This is unsufficient.  You should always verify the image on the
> target after the download has completed.

I agree.

> 
> > Participants have agreed, that we shall optionally enable crc32 (or
> > other algorithm) calculation. 
> 
> If this is the default now, it should remain the default.
> 
> > 2. The current crc32 implementation is painfully slow (although I
> > have only L1 enabled on my target). 
> 
> This is an unrelated problem then, which should excluded from this
> discussion here.
> 
> > 3. With large files (like rootfs images) we store data (to medium)
> > with 32 MiB chunks, which means that when we calculate complete
> > crc32 the image is already written to its final destination.
> 
> You can still detect if the download was corrupted, report a proper
> error and initiate a re-download.  This would at least give you a
> chance to react to corrupted data. 

In this particular case I would need to chop the large file either at
dfu-util or on some script, where each chunk need to have the header
with its crc32. Then before storing each chunk I can assess if data
wasn't corrupted.

This would provide reliability.

Now, even that I have the crc32 calculated for a chunk, I don't have
the original one to compare.

> Just closing the eyes and hoping
> no errors will ever happen has always been a bad strategy.

+1

> 
> > 4. This patch also allows some flexibility: by setting the env
> > variable we can decide which algorithm to use (crc32, sha1, etc).
> > It is appealing since we use the hash_* code anyway.
> 
> Agreed.  This was not my point.
> 
> What I complained about is the change in behaviour.  I asked to make
> the existing behaviour the default, so unaware users will not be
> affected. Only if you intentionally want some other behaviour you can
> then enable this by setting the env variable.

Ok. I will preserve the default behavior. However, personally I think
that for a long term this proposed solution is better.

> 
> > > In any case, if you introduce this, the behaviour should be
> > > documented, and the default setting should be such as to keep the
> > > previous behaviour, i. e. CRC checking should remain on by
> > > default. then people who are willing to trade reliability for a
> > > little speed
> > 
> > I would not touch the code if the speedup wouldn't be so
> > significant. Reducing flashing time of 400 MiB file from 65 s to 25
> > s is worth its effort.
> 
> I disagree, if you pay for the speed by reduced reliability, and if
> you don't even inform the user about this new behaviour.
> 
> Also, I feel it might be worth to investigate why the checksumming is
> slow on your system.
> 
> > As I've stated previously the crc32 in the current dfu
> > implementation is only informative.
> 
> It is pretty useful information, isn't it?

It depends what do you want to do with it. If you have target
connected via serial to some test setup and log this output and process
it on HOST afterwards, then it is useful. 

Otherwise, you only see on console the CRC, which you can by hand
compare with crc calculated on your host. And this information displays
just after you stored the data to the medium (and corrupted the
previous one).

> 
> > To take the full advantage of it, we would need to modify the
> > dfu-util to wrap the sent file to some kind of header or locally
> > write some script to do that. However, this is not specified by the
> > standard and would be u-boot's extension of the DFU. 
> 
> Ok, add this to the many deficientcies of DFU :-(

The standard only allow the file which is the input to dfu-util to be
protected by CRC. Then dfu-util check this value and strips off the
header.

> 
> > Even more important issue is that it would work only for small files
> > (like uImage).
> 
> Why so? Can we not calculate CRC even when the transfer is broken
> down into several chunks?

To do that one would need to:

- chop the large file to several smaller ones (and the chunk size can
  be different for each platform and must be know for HOST utils)
- calculate crc32 for each chunk
- wrap it to some header not conforming to the DFU standard -it would
  be the u-boot extension
- send each chunk separately to target - by calling dfu-util several
  times.

Handling of this would be difficult because of the need of DFU state
machine extension.


> 
> Best regards,
> 
> Wolfgang Denk
> 



-- 
Best regards,

Lukasz Majewski

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

  reply	other threads:[~2014-05-09  9:54 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-31  8:48 [U-Boot] [PATCH 0/3] dfu: Several enhancements for dfu subsystem Lukasz Majewski
2014-03-31  8:48 ` [U-Boot] [PATCH 1/3] dfu: mmc: Provide support for eMMC boot partition access Lukasz Majewski
2014-03-31  8:59   ` Marek Vasut
2014-03-31  9:14     ` Lukasz Majewski
2014-05-09 14:58   ` [U-Boot] [PATCH v2] " Lukasz Majewski
2014-05-14 22:24     ` Marek Vasut
2014-03-31  8:48 ` [U-Boot] [PATCH 2/3] dfu: add static alt num count in dfu_config_entities() Lukasz Majewski
2014-03-31  9:01   ` Marek Vasut
2014-03-31  9:15     ` Lukasz Majewski
2014-04-01  6:47       ` Przemyslaw Marczak
2014-04-01  6:49         ` Marek Vasut
2014-04-01  7:45           ` Lukasz Majewski
2014-03-31  8:48 ` [U-Boot] [PATCH 3/3] dfu: Introduction of the "dfu_checksum_method" env variable for checksum method setting Lukasz Majewski
2014-03-31  9:04   ` Marek Vasut
2014-03-31  9:24     ` Lukasz Majewski
2014-03-31  9:29       ` Marek Vasut
2014-03-31  9:49         ` Lukasz Majewski
2014-03-31 11:19   ` Pantelis Antoniou
2014-03-31 12:04     ` Lukasz Majewski
2014-03-31 12:10       ` Pantelis Antoniou
2014-03-31 12:16       ` Pantelis Antoniou
2014-03-31 18:05   ` Tom Rini
2014-03-31 18:15     ` Marek Vasut
2014-03-31 18:26       ` Tom Rini
2014-03-31 20:44     ` Lukasz Majewski
2014-03-31 21:04       ` Tom Rini
2014-04-01  9:05         ` Lukasz Majewski
2014-03-31 21:44       ` Tormod Volden
2014-04-01  9:00         ` Lukasz Majewski
2014-04-01  9:15           ` Stefan Schmidt
2014-04-01 11:31             ` Lukasz Majewski
2014-05-05 13:16   ` [U-Boot] [PATCH v2] " Lukasz Majewski
2014-05-05 17:47     ` Marek Vasut
2014-05-08 12:27     ` [U-Boot] [PATCH v3] dfu: Introduction of the "dfu_hash_algo" " Lukasz Majewski
2014-05-08 13:07       ` Marek Vasut
2014-05-09  4:27       ` Wolfgang Denk
2014-05-09  6:52         ` Lukasz Majewski
2014-05-09  8:31           ` Wolfgang Denk
2014-05-09  9:54             ` Lukasz Majewski [this message]
2014-05-12 14:45             ` Tom Rini
2014-05-15  7:09               ` Lukasz Majewski
2014-05-15  9:27                 ` Heiko Schocher
2014-05-15 11:19                 ` Wolfgang Denk
2014-05-15 13:43                   ` Lukasz Majewski
2014-05-15 14:07                     ` Wolfgang Denk
2014-05-16  6:08                       ` Lukasz Majewski
2014-05-16  8:58                     ` Lukasz Majewski
2014-05-19 14:02                       ` Heiko Schocher
2014-05-20 17:22                         ` Lukasz Majewski
2014-05-22  9:46                         ` Lukasz Majewski
2014-05-12  8:43     ` [U-Boot] [PATCH v4] " Lukasz Majewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140509115400.057053ab@amdc2363 \
    --to=l.majewski@samsung.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox