[U-Boot] [PATCH v6 05/12] samsung: misc: add function for setting $dfu_alt_info

Przemyslaw Marczak p.marczak at samsung.com
Fri Jul 18 17:29:14 CEST 2014


This change introduces new common function:
- set_dfu_alt_info() - put dfu system and bootloader setting
                       into $dfu_alt_info.
functions declaration:
- char *get_dfu_alt_system(void)
- char *get_dfu_alt_boot(void)
- void set_dfu_alt_info(void)
and new config:
- CONFIG_SET_DFU_ALT_INFO

This function can be used for auto setting dfu configuration on boot.
Such feature is useful for multi board support by one u-boot binary.
Each board should define two functions:
- get_dfu_alt_system()
- get_dfu_alt_boot()

Signed-off-by: Przemyslaw Marczak <p.marczak at samsung.com>
Cc: Piotr Wilczek <p.wilczek at samsung.com>
Cc: Minkyu Kang <mk7.kang at samsung.com>

---
Changes v2:
- change config names:
  CONFIG_SET_DFU_BOOT_ALT to CONFIG_DFU_ALT_BOOTLOADER and
  CONFIG_DFU_BOOT_ALT_* to CONFIG_DFU_ALT_BOOT_*
- change function name: set_dfu_boot_alt() to set_dfu_alt_boot()
- remove superfluous ifdefs

Changes v3:
- set $dfu_alt_info at every boot
- new config: CONFIG_SET_DFU_ALT_INFO
- update commit msg

Changes v4:
- set_dfu_alt_info(): add checking the pointer returned by malloc

Changes v5:
- set_dfu_alt_info(): remove malloc and declare cache aligned buffer
- set_dfu_alt_info(): introduce CONFIG_SET_DFU_ALT_BUF_LEN
---
 board/samsung/common/misc.c | 41 +++++++++++++++++++++++++++++++++++++++++
 include/samsung/misc.h      |  6 ++++++
 2 files changed, 47 insertions(+)

diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c
index a453a82..9e52452 100644
--- a/board/samsung/common/misc.c
+++ b/board/samsung/common/misc.c
@@ -11,6 +11,7 @@
 #include <samsung/misc.h>
 #include <errno.h>
 #include <version.h>
+#include <malloc.h>
 #include <linux/sizes.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/gpio.h>
@@ -21,6 +22,46 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#ifdef CONFIG_SET_DFU_ALT_INFO
+void set_dfu_alt_info(void)
+{
+	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();
+	if (alt_setting) {
+		setenv("dfu_alt_boot", alt_setting);
+		offset = snprintf(buf, buf_size, "%s", alt_setting);
+	}
+
+	alt_setting = get_dfu_alt_system();
+	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";
+	}
+
+	setenv("dfu_alt_info", alt_info);
+	puts(status);
+}
+#endif
+
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 void set_board_info(void)
 {
diff --git a/include/samsung/misc.h b/include/samsung/misc.h
index 10653a1..e82bf32 100644
--- a/include/samsung/misc.h
+++ b/include/samsung/misc.h
@@ -28,4 +28,10 @@ void check_boot_mode(void);
 void draw_logo(void);
 #endif
 
+#ifdef CONFIG_SET_DFU_ALT_INFO
+char *get_dfu_alt_system(void);
+char *get_dfu_alt_boot(void);
+void set_dfu_alt_info(void);
+#endif
+
 #endif /* __SAMSUNG_MISC_COMMON_H__ */
-- 
1.9.1



More information about the U-Boot mailing list