[U-Boot] [PATCH v2 16/21] hash: Add a flag to support saving hashes in the environment

Simon Glass sjg at chromium.org
Mon Feb 25 07:21:17 CET 2013


Hi Wolfgang,

On Thu, Feb 21, 2013 at 4:04 AM, Wolfgang Denk <wd at denx.de> wrote:
> Dear Simon Glass,
>
> In message <1361379515-23802-17-git-send-email-sjg at chromium.org> you wrote:
>> Some hashing commands permit saving the hash in an environment variable,
>> and verifying a hash from there. But the crc32 command does not support
>> this. In order to permit crc32 to use the generic hashing infrastructure,
>> add a flag to select which behaviour to use.
>
> <nitpick>
>
> ...
>> +     /*
>> +      * If environment variables are allowed, then we assume that 'dest'
>> +      * is an environment variable, unless it starts with *, in which
>> +      * case we assume it is an address. If not allowed, it ia always an
>
> s/it ia/it is/
>
> </nitpick>
>
> What's the impact of these changes on the memory footprint?

Overall it is pretty neutral, although there are some variations. For
powerpc the overall affect is to save an average of 13.9 bytes across
the whole image. arm does a bit better:

24: hash: Use lower case for hash algorithm names
   sandbox:    sandbox
       x86: (for 1/1 boards)  all -74.0  data +16.0  rodata +10.0  text -100.0
      m68k: (for 41/50 boards)  all -44.7  bss +0.5  data +0.8  rodata
-1.0  text -44.9
   powerpc: (for 633/635 boards)  all -13.9  bss +14.4  data -3.6
rodata -19.6  text -5.1
   sandbox: (for 1/1 boards)  all +24336.0  bss +48.0  data +168.0
rodata +432.0  text +23688.0
        sh: (for 16/21 boards)  all +18.8  rodata -1.2  text +20.0
     nios2: (for 3/3 boards)  all +277.3  text +277.3
microblaze: (for 1/1 boards)  all -832.0  bss +8.0  data -16.0  rodata
-120.0  text -704.0
       arm: (for 292/292 boards)  all -277.8  bss +0.4  data +0.3
rodata -3.8  spl/u-boot-spl:all -0.2  spl/u-boot-spl:rodata -0.1
spl/u-boot-spl:text -0.1  text -274.7
     nds32: (for 3/3 boards)  all -116.0  data +4.0  rodata -16.0  text -104.0

Bad boards define CONFIG_CMD_CRC32 along with CONFIG_CRC32_VERIFY,
thus bringing in the hash code, but they don't enable the hash command
or have sha1, so this is the worst case. Good boards benefit from the
getenv/setenv helpers and use the small version of the hash code
(since they only define CONFIG_CMD_CRC32). The vast majority of boards
show a slight improvement overall.

This is the worst powerpc board:

   powerpc: (for 2/2 boards)  all +284.5  bss +12.0  rodata -13.5  text +286.0
            stxxtc         :  all +941  bss +24  data +16  rodata +89  text +812
               u-boot: add: 8/0, grow: 3/-10 bytes: 1254/-432 (822)
                 function                                   old     new   delta
                 hash_command                                 -     740    +740
                 show_hash                                    -     108    +108
                 simple_itoa                                  -     104    +104
                 crc32_wd_buf                                 -      76     +76
                 setenv_hex                                   -      64     +64
                 setenv_ulong                                 -      52     +52
                 do_mem_mtest                               468     512     +44
                 static.local                                 -      22     +22
                 do_mem_loop                                268     288     +20
                 hash_algo                                    -      16     +16
                 do_mem_cmp                                 356     364      +8
                 do_mem_mw                                  224     220      -4
                 set_working_fdt_addr                        68      52     -16
                 load_serial_ymodem                         288     272     -16
                 load_serial                                504     488     -16
                 do_load_serial_bin                        1812    1796     -16
                 do_imgextract                              656     620     -36
                 NetLoop                                    784     748     -36
                 do_bootm                                  1216    1164     -52
                 do_mem_cp                                  344     288     -56
                 do_mem_crc                                 308     124    -184

This is the best powerpc board:

            P2041RDB_SRIO_PCIE_BOOT:  all -372  data -16  rodata -116  text -240
               u-boot: add: 5/-1, grow: 2/-15 bytes: 446/-640 (-194)
                 function                                   old     new   delta
                 hash_command                                 -     176    +176
                 simple_itoa                                  -     104    +104
                 setenv_hex                                   -      64     +64
                 setenv_ulong                                 -      52     +52
                 static.local                                 -      22     +22
                 do_mem_loop                                268     288     +20
                 do_mem_cmp                                 324     332      +8
                 do_mem_mw                                  224     220      -4
                 set_working_fdt_addr                        68      52     -16
                 load_serial_ymodem                         228     212     -16
                 load_serial                                460     444     -16
                 hash_algo                                   16       -     -16
                 fm_init_common                            1336    1320     -16
                 do_load_serial_bin                        1812    1796     -16
                 do_load                                    460     444     -16
                 do_imgextract                              864     828     -36
                 NetLoop                                    780     744     -36
                 nand_print_and_set_info                    224     172     -52
                 do_bootm                                  1236    1184     -52
                 do_setexpr                                 436     376     -60
                 do_mem_cp                                  244     156     -88
                 do_mem_crc                                 184      88     -96
                 do_mem_mtest                              1400    1296    -104

This is tricky because I am trying to bring in a generic
infrastructure for hashing and make use of it everywhere, but
unfortunately those boards that don't really make much use of it still
have to pay a price. That said, only 15 powerpc boards are in the
'bad' camp and none is as bad as stxxtc.

There is also some saving to be had by changing simple_itoa() to use
the existing put_dec() if we want to. Overall I'm hoping that the
crc32 patch is worth the trouble.

Regards,
Simon

>
> Best regards,
>
> Wolfgang Denk
>
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
> Let us not look back in anger or  forward  in  fear,  but  around  in
> awareness.                                            - James Thurber


More information about the U-Boot mailing list