From 70f380eea98b1b610dbe41588fa9ea7abd660f67 Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Tue, 17 Nov 2020 11:16:28 +0100 Subject: [PATCH] tizen: amlogic: make 'dfu_alt_info' static 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 Change-Id: I37fc03fe245bfdf5229922ecfd5f0d00ef00b6e6 --- arch/arm/mach-meson/board-common.c | 2 - board/amlogic/odroid-n2/odroid-n2.c | 75 ----------------------------- board/amlogic/w400/w400.c | 72 ---------------------------- configs/khadas-vim3_defconfig | 1 - configs/odroid-c4_defconfig | 1 - configs/odroid-n2_defconfig | 1 - include/samsung/tizen_amlogic.h | 94 ++++++++++++++----------------------- 7 files changed, 34 insertions(+), 212 deletions(-) diff --git a/arch/arm/mach-meson/board-common.c b/arch/arm/mach-meson/board-common.c index b1d1fb9..a69bf52 100644 --- a/arch/arm/mach-meson/board-common.c +++ b/arch/arm/mach-meson/board-common.c @@ -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 diff --git a/board/amlogic/odroid-n2/odroid-n2.c b/board/amlogic/odroid-n2/odroid-n2.c index 636e0ca..ca2ec65 100644 --- a/board/amlogic/odroid-n2/odroid-n2.c +++ b/board/amlogic/odroid-n2/odroid-n2.c @@ -56,78 +56,3 @@ int misc_init_r(void) return 0; } - -#ifdef CONFIG_SET_DFU_ALT_INFO -#include -#include -#include -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 diff --git a/board/amlogic/w400/w400.c b/board/amlogic/w400/w400.c index 5bef026..1636415 100644 --- a/board/amlogic/w400/w400.c +++ b/board/amlogic/w400/w400.c @@ -27,75 +27,3 @@ int misc_init_r(void) return 0; } - -#ifdef CONFIG_SET_DFU_ALT_INFO -#include -#include -#include -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 diff --git a/configs/khadas-vim3_defconfig b/configs/khadas-vim3_defconfig index 55dad74..a8a3fcf 100644 --- a/configs/khadas-vim3_defconfig +++ b/configs/khadas-vim3_defconfig @@ -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 diff --git a/configs/odroid-c4_defconfig b/configs/odroid-c4_defconfig index 2c39987..3d1a254 100644 --- a/configs/odroid-c4_defconfig +++ b/configs/odroid-c4_defconfig @@ -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 diff --git a/configs/odroid-n2_defconfig b/configs/odroid-n2_defconfig index 37da609..0702082 100644 --- a/configs/odroid-n2_defconfig +++ b/configs/odroid-n2_defconfig @@ -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 diff --git a/include/samsung/tizen_amlogic.h b/include/samsung/tizen_amlogic.h index 0382ef9..0112fe7 100644 --- a/include/samsung/tizen_amlogic.h +++ b/include/samsung/tizen_amlogic.h @@ -18,72 +18,43 @@ #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 */ @@ -94,12 +65,16 @@ #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 \ @@ -117,8 +92,7 @@ "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" \ -- 2.7.4