From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Mon, 31 Mar 2014 11:29:17 +0200 Subject: [U-Boot] [PATCH 3/3] dfu: Introduction of the "dfu_checksum_method" env variable for checksum method setting In-Reply-To: <20140331112431.1157e1c8@amdc2363> References: <1396255729-6573-1-git-send-email-l.majewski@samsung.com> <201403311104.13887.marex@denx.de> <20140331112431.1157e1c8@amdc2363> Message-ID: <201403311129.17258.marex@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Monday, March 31, 2014 at 11:24:31 AM, Lukasz Majewski wrote: > Hi Marek, > > > On Monday, March 31, 2014 at 10:48:49 AM, Lukasz Majewski wrote: > > > Up till now the CRC32 of received data was calculated > > > unconditionally. The standard crc32 implementation causes long > > > delays when large images were uploaded. > > > > You might want to check common/cmd_hash.c and include/hash.h for the > > hash_command() call. It does the resolution of the hash algorithm > > from it's name and you can operate also SHA1 and SHA256 with it. It > > would be nice if you could just extend it a bit and use that instead > > of adding another ad-hoc mechanism. > > > > Do you think it'd be possible to reuse it please ? > > I think, that crc32 shall be calculated when needed. That is why I've > added a dfu_ckecksum_method variable. > > With its help it is now possible to use different algorithms for > checking - not only crc32 (which in u-boot is the default and painfully > slow implementation). > > In the future the code: > if (dfu_checksum_method == DFU_CRC32) > crc32 calculation; > > will be changed to: > > switch (dfu_checksum_method) { > case CRC32: > crc32 calculation; > break; > case SHA1: > sha1 calculation; > break; > case MD5: > md5 calculation; > break; > } > > Moreover it is possible to dynamically change the checksum method > (between invoking dfu command) via adjusting "dfu_checksum_method" > variable. > > The default approach is to not calculate anything. I get it, but the direct calling of crc32() function can be abstracted already with the hash_command() now. You won't need to the above switch in such case. Also, you can implement a NULL hash algo, which would effectivelly model the case where you want to disable hashing. Best regards, Marek Vasut