[U-Boot] [PATCH] cfi_flash: fix bug introduced while recent change to flash_get_size()

Wolfgang Denk wd at denx.de
Sun Nov 28 19:43:40 CET 2010


Dear Anatolij Gustschin,

In message <1290906813-12017-1-git-send-email-agust at denx.de> you wrote:
> commit ec50a8e389863ac35bfd9d9a2e8b30187318e59e
> "cfi_flash: handle 'chip size exceeds address window' situation"
> added 3rd argument to flash_get_size() but didn't fix all the
> function calls from the board specific code. Many boards have
> their own flash_get_size() definitions in the board code and
> use them there, but some boards (e.g. tqm834x, tqm85xx, pdm360ng)
> use flash_get_size() from the cfi_flash.c driver.
> 
> The bug shows up if the value of the "max_size" argument (which
> is not defined when calling the function with two arguments)
> happens to be less than "info->size". In this case on the
> affected boards we end up with a bank of reduced size and
> in the worst case might even be not able to update U-Boot or
> to boot the kernel from flash:
> 
> => fli
> 
> Bank # 1: CFI conformant FLASH (32 x 16)  Size: 0 kB in 1 Sectors
>   AMD Standard command set, Manufacturer ID: 0x01, Device ID: 0x227E
>   Erase timeout: 4096 ms, write timeout: 1 ms
>   Buffer write timeout: 3 ms, buffer size: 64 bytes
> 
>   Sector Start Addresses:
>   F0000000   RO
> 
> Bank # 2: CFI conformant FLASH (32 x 16)  Size: 128 MB in 512 Sectors
>   AMD Standard command set, Manufacturer ID: 0x01, Device ID: 0x227E
>   Erase timeout: 4096 ms, write timeout: 1 ms
>   Buffer write timeout: 3 ms, buffer size: 64 bytes
> 
>   Sector Start Addresses:
>   F8000000        F8040000        F8080000        F80C0000        F8100000
>   F8140000        F8180000        F81C0000        F8200000        F8240000
>   ...
> 
> E.g., updating U-Boot is not possible now:
> 
> => protect off ${u-boot_addr} +${u-boot_size}
> Error: end address (0xf007ffff) not in flash!
> Bad address format
> => era ${u-boot_addr} +${u-boot_size}
> Error: end address (0xf007ffff) not in flash!
> Bad address format
> 
> This patch removes the 3rd argument of flash_get_size() again
> and sets "max_size" in the function itself instead of passing
> it as a function argument.
> 
> Signed-off-by: Anatolij Gustschin <agust at denx.de>
> ---
> Probably we should put the prototype of flash_get_size() into
> include/flash.h and not use prototype definitions in the
> board code. This could prevent such a nasty bug (compile time
> errors would show it). But I'm not sure here, need to look
> more at the code.
> 
>  drivers/mtd/cfi_flash.c |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)

Applied, thanks.

Hope this is ok with your, Stefan - I just wanted to have this in
-rc2.

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
C++ was an interesting and valuable experiment, but we've learned its
lessons and it's time to move on.
                            - Peter Curran in <DCqM4z.BxB at isgtec.com>


More information about the U-Boot mailing list