[PATCH 02/20] net: Remove CONFIG_SYS_DIRECT_FLASH_TFTP

Ramon Fried rfried.dev at gmail.com
Sat Aug 6 19:42:09 CEST 2022


On Sat, Jul 23, 2022 at 8:05 PM Tom Rini <trini at konsulko.com> wrote:
>
> No platforms enable the functionality to tftp directly to NOR flash, and
> this is discouraged by the documentation.  Remove this code.  Further,
> this highlights an oddity of the code.  Un-indent the start of this
> function.
>
> Cc: Joe Hershberger <joe.hershberger at ni.com>
> Cc: Ramon Fried <rfried.dev at gmail.com>
> Signed-off-by: Tom Rini <trini at konsulko.com>
> ---
>  README                  | 13 -----------
>  include/configs/kzm9g.h |  2 --
>  net/tftp.c              | 52 +++++++++++------------------------------
>  3 files changed, 13 insertions(+), 54 deletions(-)
>
> diff --git a/README b/README
> index ff0df3797d21..74e37aa95cc4 100644
> --- a/README
> +++ b/README
> @@ -1775,19 +1775,6 @@ Configuration Settings:
>                 If defined, hardware flash sectors protection is used
>                 instead of U-Boot software protection.
>
> -- CONFIG_SYS_DIRECT_FLASH_TFTP:
> -
> -               Enable TFTP transfers directly to flash memory;
> -               without this option such a download has to be
> -               performed in two steps: (1) download to RAM, and (2)
> -               copy from RAM to flash.
> -
> -               The two-step approach is usually more reliable, since
> -               you can check if the download worked before you erase
> -               the flash, but in some situations (when system RAM is
> -               too limited to allow for a temporary copy of the
> -               downloaded image) this option may be very useful.
> -
>  - CONFIG_SYS_FLASH_CFI:
>                 Define if the flash driver uses extra elements in the
>                 common flash structure for storing flash geometry.
> diff --git a/include/configs/kzm9g.h b/include/configs/kzm9g.h
> index e084f87d14dd..f94cb54c7050 100644
> --- a/include/configs/kzm9g.h
> +++ b/include/configs/kzm9g.h
> @@ -53,8 +53,6 @@
>  /* Timeout for Flash clear lock bit operations (in ms) */
>  #define CONFIG_SYS_FLASH_UNLOCK_TOUT   (3 * 1000)
>
> -#undef  CONFIG_SYS_DIRECT_FLASH_TFTP
> -
>  /* GPIO / PFC */
>  #define CONFIG_SH_GPIO_PFC
>
> diff --git a/net/tftp.c b/net/tftp.c
> index bfc4c9bde9cb..451d73529f2a 100644
> --- a/net/tftp.c
> +++ b/net/tftp.c
> @@ -17,9 +17,6 @@
>  #include <asm/global_data.h>
>  #include <net/tftp.h>
>  #include "bootp.h"
> -#ifdef CONFIG_SYS_DIRECT_FLASH_TFTP
> -#include <flash.h>
> -#endif
>
>  DECLARE_GLOBAL_DATA_PTR;
>
> @@ -158,47 +155,24 @@ static inline int store_block(int block, uchar *src, unsigned int len)
>                         tftp_block_size;
>         ulong newsize = offset + len;
>         ulong store_addr = tftp_load_addr + offset;
> -#ifdef CONFIG_SYS_DIRECT_FLASH_TFTP
> -       int i, rc = 0;
> -
> -       for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; i++) {
> -               /* start address in flash? */
> -               if (flash_info[i].flash_id == FLASH_UNKNOWN)
> -                       continue;
> -               if (store_addr >= flash_info[i].start[0]) {
> -                       rc = 1;
> -                       break;
> -               }
> -       }
> -
> -       if (rc) { /* Flash is destination for this packet */
> -               rc = flash_write((char *)src, store_addr, len);
> -               if (rc) {
> -                       flash_perror(rc);
> -                       return rc;
> -               }
> -       } else
> -#endif /* CONFIG_SYS_DIRECT_FLASH_TFTP */
> -       {
> -               void *ptr;
> +       void *ptr;
>
>  #ifdef CONFIG_LMB
> -               ulong end_addr = tftp_load_addr + tftp_load_size;
> +       ulong end_addr = tftp_load_addr + tftp_load_size;
>
> -               if (!end_addr)
> -                       end_addr = ULONG_MAX;
> +       if (!end_addr)
> +               end_addr = ULONG_MAX;
>
> -               if (store_addr < tftp_load_addr ||
> -                   store_addr + len > end_addr) {
> -                       puts("\nTFTP error: ");
> -                       puts("trying to overwrite reserved memory...\n");
> -                       return -1;
> -               }
> -#endif
> -               ptr = map_sysmem(store_addr, len);
> -               memcpy(ptr, src, len);
> -               unmap_sysmem(ptr);
> +       if (store_addr < tftp_load_addr ||
> +           store_addr + len > end_addr) {
> +               puts("\nTFTP error: ");
> +               puts("trying to overwrite reserved memory...\n");
> +               return -1;
>         }
> +#endif
> +       ptr = map_sysmem(store_addr, len);
> +       memcpy(ptr, src, len);
> +       unmap_sysmem(ptr);
>
>         if (net_boot_file_size < newsize)
>                 net_boot_file_size = newsize;
> --
> 2.25.1
>
Acked-by: Ramon Fried <rfried.dev at gmail.com>


More information about the U-Boot mailing list