tizen: amlogic: make 'dfu_alt_info' static 49/247849/2
authorMarek Szyprowski <m.szyprowski@samsung.com>
Tue, 17 Nov 2020 10:16:28 +0000 (11:16 +0100)
committerMarek Szyprowski <m.szyprowski@samsung.com>
Tue, 17 Nov 2020 10:55:12 +0000 (11:55 +0100)
The data layout on the storage device is the same for both eMMC and SD
card, so after switching to the default boot MMC device, the 'dfu_alt_info'
string is static, fully known during the compile time. Use this simple
approach, which is a bit more error proof for future changes. It also
obsoletes the custom code added to Amlogic boards.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Change-Id: I37fc03fe245bfdf5229922ecfd5f0d00ef00b6e6

arch/arm/mach-meson/board-common.c
board/amlogic/odroid-n2/odroid-n2.c
board/amlogic/w400/w400.c
configs/khadas-vim3_defconfig
configs/odroid-c4_defconfig
configs/odroid-n2_defconfig
include/samsung/tizen_amlogic.h

index b1d1fb9..a69bf52 100644 (file)
@@ -116,7 +116,6 @@ static void meson_set_boot_source(void)
                source = "emmc";
 #ifdef CONFIG_TIZEN
                env_set("dfu_device", "1");
-               env_set("devnum", "1");
                env_set("mmcbootdev", "1");
                env_set("mmcrootdev", "1");
 #endif
@@ -134,7 +133,6 @@ static void meson_set_boot_source(void)
                source = "sd";
 #ifdef CONFIG_TIZEN
                env_set("dfu_device", "0");
-               env_set("devnum", "0");
                env_set("mmcbootdev", "0");
                env_set("mmcrootdev", "0");
 #endif
index 636e0ca..ca2ec65 100644 (file)
@@ -56,78 +56,3 @@ int misc_init_r(void)
 
        return 0;
 }
-
-#ifdef CONFIG_SET_DFU_ALT_INFO
-#include <mmc.h>
-#include <config.h>
-#include <memalign.h>
-static char *get_dfu_alt_system(char *interface, char *devstr)
-{
-       if (!strncmp(devstr, "0", 1))
-               return env_get("dfu_alt_system_sd");
-       else
-               return env_get("dfu_alt_system");
-}
-
-static char *get_dfu_alt_boot(char *interface, char *devstr)
-{
-       struct mmc *mmc;
-       char *alt_boot;
-       int dev_num;
-
-       dev_num = simple_strtoul(devstr, NULL, 10);
-
-       mmc = find_mmc_device(dev_num);
-       if (!mmc)
-               return NULL;
-
-       if (mmc_init(mmc))
-               return NULL;
-
-       if (CONFIG_IS_ENABLED(TIZEN_CONFIG_N2))
-               alt_boot = DFU_ALT_BOOT_EMMC_ODROID_N2;
-       else
-               alt_boot = DFU_ALT_BOOT_EMMC_ODROID_C4;
-
-       return alt_boot;
-}
-
-void set_dfu_alt_info(char *interface, char *devstr)
-{
-       size_t buf_size = CONFIG_SET_DFU_ALT_BUF_LEN;
-       ALLOC_CACHE_ALIGN_BUFFER(char, buf, buf_size);
-       char *alt_info = "Settings not found!";
-       char *status = "error!\n";
-       char *alt_setting;
-       char *alt_sep;
-       int offset = 0;
-
-       puts("DFU alt info setting: ");
-
-       alt_setting = get_dfu_alt_boot(interface, devstr);
-       if (alt_setting) {
-               env_set("dfu_alt_boot", alt_setting);
-               offset = snprintf(buf, buf_size, "%s", alt_setting);
-       }
-
-       alt_setting = get_dfu_alt_system(interface, devstr);
-       if (alt_setting) {
-               if (offset)
-                       alt_sep = ";";
-               else
-                       alt_sep = "";
-
-               offset += snprintf(buf + offset, buf_size - offset,
-                                   "%s%s", alt_sep, alt_setting);
-       }
-
-       if (offset) {
-               alt_info = buf;
-               status = "done\n";
-       }
-
-       env_set("dfu_alt_info", alt_info);
-
-       puts(status);
-}
-#endif
index 5bef026..1636415 100644 (file)
@@ -27,75 +27,3 @@ int misc_init_r(void)
 
        return 0;
 }
-
-#ifdef CONFIG_SET_DFU_ALT_INFO
-#include <mmc.h>
-#include <config.h>
-#include <memalign.h>
-static char *get_dfu_alt_system(char *interface, char *devstr)
-{
-       if (!strncmp(devstr, "0", 1))
-               return env_get("dfu_alt_system_sd");
-       else
-               return env_get("dfu_alt_system");
-}
-
-static char *get_dfu_alt_boot(char *interface, char *devstr)
-{
-       struct mmc *mmc;
-       char *alt_boot;
-       int dev_num;
-
-       dev_num = simple_strtoul(devstr, NULL, 10);
-
-       mmc = find_mmc_device(dev_num);
-       if (!mmc)
-               return NULL;
-
-       if (mmc_init(mmc))
-               return NULL;
-
-       alt_boot = DFU_ALT_BOOT_EMMC_KVIM3;
-
-       return alt_boot;
-}
-
-void set_dfu_alt_info(char *interface, char *devstr)
-{
-       size_t buf_size = CONFIG_SET_DFU_ALT_BUF_LEN;
-       ALLOC_CACHE_ALIGN_BUFFER(char, buf, buf_size);
-       char *alt_info = "Settings not found!";
-       char *status = "error!\n";
-       char *alt_setting;
-       char *alt_sep;
-       int offset = 0;
-
-       puts("DFU alt info setting: ");
-
-       alt_setting = get_dfu_alt_boot(interface, devstr);
-       if (alt_setting) {
-               env_set("dfu_alt_boot", alt_setting);
-               offset = snprintf(buf, buf_size, "%s", alt_setting);
-       }
-
-       alt_setting = get_dfu_alt_system(interface, devstr);
-       if (alt_setting) {
-               if (offset)
-                       alt_sep = ";";
-               else
-                       alt_sep = "";
-
-               offset += snprintf(buf + offset, buf_size - offset,
-                                   "%s%s", alt_sep, alt_setting);
-       }
-
-       if (offset) {
-               alt_info = buf;
-               status = "done\n";
-       }
-
-       env_set("dfu_alt_info", alt_info);
-
-       puts(status);
-}
-#endif
index 55dad74..a8a3fcf 100644 (file)
@@ -38,7 +38,6 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_DFU_MMC=y
-CONFIG_SET_DFU_ALT_INFO=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_MESON_GX=y
 CONFIG_MTD=y
index 2c39987..3d1a254 100644 (file)
@@ -35,7 +35,6 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_DFU_MMC=y
-CONFIG_SET_DFU_ALT_INFO=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_MESON_GX=y
 CONFIG_PHY_REALTEK=y
index 37da609..0702082 100644 (file)
@@ -35,7 +35,6 @@ CONFIG_ENV_FAT_FILE="odroid-n2/params.bin"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_DFU_MMC=y
-CONFIG_SET_DFU_ALT_INFO=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_MESON_GX=y
 CONFIG_PHY_REALTEK=y
index 0382ef9..0112fe7 100644 (file)
 #define CONFIG_SYS_MEM_TOP_HIDE                0x08000000
 
 /* DFU */
-/* For SD */
-#define DFU_ALT_SYSTEM_SD              \
-       "Image.gz fat 0 1;"                     \
-       "meson64_odroidn2_drm.dtb fat 0 1;"             \
-       "meson64_odroidn2.dtb fat 0 1;"         \
-       "meson64_odroidc4.dtb fat 0 1;"         \
-       "kvim3_linux.dtb fat 0 1;"              \
-       "boot.scr.uimg fat 0 1;"                \
-       "params.bin fat 0 1;"                   \
-       "vim3/Image.gz fat 0 1;"                        \
-       "odroid-n2/Image.gz fat 0 1;"                   \
-       "odroid-c4/Image.gz fat 0 1;"                   \
-       "vim3/params.bin fat 0 1;"                      \
-       "odroid-n2/params.bin fat 0 1;"         \
-       "odroid-c4/params.bin fat 0 1;"         \
-       "vim3/boot.scr.uimg fat 0 1;"           \
-       "odroid-n2/boot.scr.uimg fat 0 1;"              \
-       "odroid-c4/boot.scr.uimg fat 0 1;"              \
-       "boot.img part 0 1;"                    \
-       "rootfs part 0 2;"                      \
-       "system-data part 0 3;"                 \
-       "user part 0 5;"                        \
-       "module part 0 6;"                      \
-       "ramdisk.img part 0 7;"                 \
-       "ramdisk-recovery.img part 0 8\0"
+#define DFU_ALT_SYSTEM                         \
+       "Image.gz fat -1 1;"                    \
+       "meson64_odroidn2_drm.dtb fat -1 1;"    \
+       "meson64_odroidn2.dtb fat -1 1;"        \
+       "meson64_odroidc4.dtb fat -1 1;"        \
+       "kvim3_linux.dtb fat -1 1;"             \
+       "boot.scr.uimg fat -1 1;"               \
+       "params.bin fat -1 1;"                  \
+       "vim3/Image.gz fat -1 1;"               \
+       "odroid-n2/Image.gz fat -1 1;"          \
+       "odroid-c4/Image.gz fat -1 1;"          \
+       "vim3/params.bin fat -1 1;"             \
+       "odroid-n2/params.bin fat -1 1;"        \
+       "odroid-c4/params.bin fat -1 1;"        \
+       "vim3/boot.scr.uimg fat -1 1;"          \
+       "odroid-n2/boot.scr.uimg fat -1 1;"     \
+       "odroid-c4/boot.scr.uimg fat -1 1;"     \
+       "boot.img part -1 1;"                   \
+       "rootfs part -1 2;"                     \
+       "system-data part -1 3;"                \
+       "user part -1 5;"                       \
+       "module part -1 6;"                     \
+       "ramdisk.img part -1 7;"                \
+       "ramdisk-recovery.img part -1 8"
 
-/* For eMMC */
-#define DFU_ALT_SYSTEM                 \
-       "Image.gz fat 1 1;"                     \
-       "meson64_odroidn2_drm.dtb fat 1 1;"             \
-       "meson64_odroidn2.dtb fat 1 1;"         \
-       "meson64_odroidc4.dtb fat 1 1;"         \
-       "kvim3_linux.dtb fat 1 1;"              \
-       "boot.scr.uimg fat 1 1;"                \
-       "boot.img part 1 1;"                    \
-       "params.bin fat 1 1;"                   \
-       "vim3/Image.gz fat 1 1;"                        \
-       "odroid-n2/Image.gz fat 1 1;"                   \
-       "odroid-c4/Image.gz fat 1 1;"                   \
-       "vim3/params.bin fat 1 1;"                      \
-       "odroid-n2/params.bin fat 1 1;"         \
-       "odroid-c4/params.bin fat 1 1;"         \
-       "vim3/boot.scr.uimg fat 1 1;"           \
-       "odroid-n2/boot.scr.uimg fat 1 1;"              \
-       "odroid-c4/boot.scr.uimg fat 1 1;"              \
-       "rootfs part 1 2;"                      \
-       "system-data part 1 3;"                 \
-       "user part 1 5;"                        \
-       "module part 1 6;"                      \
-       "ramdisk.img part 1 7;"                 \
-       "ramdisk-recovery.img part 1 8\0"
-
-
-#define DFU_ALT_BOOT_EMMC_ODROID_N2    "u-boot.bin raw 0x1 0x850;"     \
-                               "u-boot-n2.bin raw 0x1 0x850;"          \
+#define DFU_ALT_BOOT_ODROID_N2 "u-boot.bin raw 0x1 0x850;"     \
+                               "u-boot-n2.bin raw 0x1 0x850;"  \
                                "u-boot-c4.bin skip 0 0;"       \
                                "u-boot-kvim3.bin skip 0 0"
-#define DFU_ALT_BOOT_EMMC_KVIM3        "u-boot.bin raw 0x1 0x850;"     \
-                               "u-boot-kvim3.bin raw 0x1 0x850;"       \
+#define DFU_ALT_BOOT_KVIM3     "u-boot.bin raw 0x1 0x850;"     \
+                               "u-boot-kvim3.bin raw 0x1 0x850;" \
                                "u-boot-c4.bin skip 0 0;"       \
                                "u-boot-n2.bin skip 0 0"
-#define DFU_ALT_BOOT_EMMC_ODROID_C4    "u-boot.bin raw 0x1 0x850;"     \
+#define DFU_ALT_BOOT_ODROID_C4 "u-boot.bin raw 0x1 0x850;"     \
                                "u-boot-c4.bin raw 0x1 0x850;"  \
                                "u-boot-kvim3.bin skip 0 0;"    \
                                "u-boot-n2.bin skip 0 0"
-#define DFU_ALT_BOOT_SD        ""
 #define CONFIG_SET_DFU_ALT_BUF_LEN     (SZ_1K)
 
 /* DFU over USB/UDC */
 
 #ifdef CONFIG_TIZEN_KHADAS_VIM3
 #define TIZEN_BOOT_PREFIX "/vim3/ /"
+#define DFU_ALT_BOOT   DFU_ALT_BOOT_VIM3
 #elif CONFIG_TIZEN_ODROID_N2
 #define TIZEN_BOOT_PREFIX "/odroid-n2/ /"
+#define DFU_ALT_BOOT   DFU_ALT_BOOT_ODROID_N2
 #elif CONFIG_TIZEN_ODROID_C4
 #define TIZEN_BOOT_PREFIX "/odroid-c4/ /"
+#define DFU_ALT_BOOT   DFU_ALT_BOOT_ODROID_C4
 #else
 #define TIZEN_BOOT_PREFIX "/ /boot/"
+#define DFU_ALT_BOOT   "u-boot.bin skip 0 0"
 #endif
 
 #define TIZEN_ENV_SETTING \
        "bootmode=ramdisk\0"                    \
        "bootdev=mmc\0"                         \
        "tfm=setenv bootmode download; run bootcmd\0"   \
-       "dfu_alt_system="DFU_ALT_SYSTEM                 \
-       "dfu_alt_system_sd="DFU_ALT_SYSTEM_SD                   \
+       "dfu_alt_info=" DFU_ALT_SYSTEM ";" DFU_ALT_BOOT "\0"\
        "fdt_high=0x20000000\0"                 \
        "initrd_high=0x3d800000\0"              \
        "opts=loglevel=4\0"                     \