ALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%)
endif
ALL-$(CONFIG_REMAKE_ELF) += u-boot.elf
+ALL-$(CONFIG_SIG) += u-boot-sig.bin
# enable combined SPL/u-boot/dtb rules for tegra
ifneq ($(CONFIG_TEGRA),)
@echo >&2 "=================================================="
@echo >&2
+u-boot-sig.bin: u-boot.bin
+ @echo -n "BoOt" > sig-magic
+ @echo -n `date +%Y%m%d%H` > sig-date
+ @echo -n "none" > sig-product
+ifeq ($(BOARD),trats)
+ @echo -n "slp_u1" > sig-board
+else
+ @echo -n "slp_midasq" > sig-board
+endif
+ @cat sig-magic /dev/zero | head -c 12 > sig-tmp
+ @cat sig-tmp sig-date /dev/zero | head -c 24 > sig-tmp2
+ @cat sig-tmp2 sig-product /dev/zero | head -c 48 > sig-tmp
+ @cat sig-tmp sig-board /dev/zero | head -c 512 > sig-hdr
+ @cat u-boot.bin /dev/zero | head -c 1048064 > u-boot-pad.bin
+ @cat u-boot-pad.bin sig-hdr > u-boot-mmc.bin
+
+ @rm -f sig-* u-boot-pad.bin
+
nand_spl/u-boot-spl-16k.bin: nand_spl
@:
obj-$(CONFIG_THOR_FUNCTION) += thor.o
obj-$(CONFIG_CMD_USB_MASS_STORAGE) += ums.o
obj-$(CONFIG_MISC_COMMON) += misc.o
+obj-$(CONFIG_SIG) += sig_header.o
ifndef CONFIG_SPL_BUILD
obj-$(CONFIG_BOARD_COMMON) += board.o
--- /dev/null
+#include <common.h>
+#include <samsung/sighdr.h>
+
+static struct sig_header *
+get_image_signature(phys_addr_t base_addr, phys_size_t size)
+{
+ struct sig_header *hdr;
+
+ hdr = (struct sig_header *)(base_addr + size - HDR_SIZE);
+ if (hdr->magic != HDR_BOOT_MAGIC) {
+ debug("can't found signature\n");
+ return NULL;
+ }
+
+ return hdr;
+}
+
+int check_board_signature(char *fname, phys_addr_t dn_addr, phys_size_t size)
+{
+ struct sig_header *bh_target;
+ struct sig_header *bh_addr;
+
+ /* u-boot-mmc.bin */
+ if (strcmp(fname, "u-boot-mmc.bin"))
+ return 0;
+
+ /* can't found signature in target - download continue */
+ bh_target = get_image_signature((phys_addr_t)CONFIG_SYS_TEXT_BASE,
+ size);
+ if (!bh_target)
+ return 0;
+
+ /* can't found signature in address - download stop */
+ bh_addr = get_image_signature(dn_addr, size);
+ if (!bh_addr)
+ return -1;
+
+ if (strncmp(bh_target->bd_name, bh_addr->bd_name,
+ ARRAY_SIZE(bh_target->bd_name))) {
+ debug("board name Inconsistency\n");
+ return -1;
+ }
+
+ debug("board signature check OK\n");
+
+ return 0;
+}
#include <linux/usb/cdc.h>
#include <g_dnl.h>
#include <dfu.h>
+#include <samsung/sighdr.h>
#include <libtizen.h>
#include <samsung/misc.h>
#include <usb.h>
debug("%s: left: %llu cnt: %d\n", __func__, left, cnt);
+#ifdef CONFIG_SIG
+ /* check board signature when download u-boot-mmc.bin */
+ ret = check_board_signature(f_name, (phys_addr_t)transfer_buffer,
+ (phys_size_t)thor_file_size);
+ if (ret) {
+ printf("Wrong board signature in file: %s.\n", f_name);
+ return ret;
+ }
+#endif
+
if (left) {
ret = dfu_write(dfu_get_entity(alt_setting_num),
transfer_buffer, left, cnt++);
--- /dev/null
+#ifndef __HEADER_H__
+#define __HEADER_H__
+
+#define HDR_BOOT_MAGIC 0x744f6f42 /* BoOt */
+
+#define HDR_SIZE sizeof(struct sig_header)
+
+/* HDR_SIZE - 512 */
+struct sig_header {
+ uint32_t magic; /* image magic number */
+ uint32_t size; /* image data size */
+ uint32_t valid; /* valid flag */
+ char date[12]; /* image creation timestamp - YYMMDDHH */
+ char version[24]; /* image version */
+ char bd_name[16]; /* target board name */
+ char reserved[448]; /* reserved */
+};
+
+int check_board_signature(char *fname, phys_addr_t dn_addr, phys_size_t size);
+#endif