karo: tx6: implement secure boot support
authorLothar Waßmann <LW@KARO-electronics.de>
Fri, 21 Aug 2015 13:34:35 +0000 (15:34 +0200)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 21 Aug 2015 13:34:35 +0000 (15:34 +0200)
12 files changed:
board/karo/tx6/flash.c
board/karo/tx6/lowlevel_init.S
board/karo/tx6/tx6qdl.c
board/karo/tx6/u-boot.lds
common/Kconfig
configs/tx6q-1020_sec_defconfig [new file with mode: 0644]
configs/tx6q-10x0_sec_defconfig [new file with mode: 0644]
configs/tx6s-8034_sec_defconfig [new file with mode: 0644]
configs/tx6u-8012_sec_defconfig [new file with mode: 0644]
configs/tx6u-8033_sec_defconfig [new file with mode: 0644]
configs/tx6u-80x0_sec_defconfig [new file with mode: 0644]
drivers/misc/mxc_ocotp.c

index d0bb7c8..d57c994 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012-2014 Lothar Waßmann <LW@KARO-electronics.de>
+ * Copyright (C) 2012-2015 Lothar Waßmann <LW@KARO-electronics.de>
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -91,11 +91,27 @@ struct mx6_dbbt {
        u32 bb_num[2040 / 4];
 };
 
+struct mx6_ivt {
+       u32 magic;
+       u32 app_start_addr;
+       u32 rsrvd1;
+       void *dcd;
+       void *boot_data;
+       void *self;
+       void *csf;
+       u32 rsrvd2;
+};
+
+struct mx6_boot_data {
+       void *start;
+       u32 length;
+       u32 plugin;
+};
+
 #define BF_VAL(v, bf)          (((v) & bf##_MASK) >> bf##_OFFSET)
 
 static nand_info_t *mtd = &nand_info[0];
-
-extern void *_start;
+static bool doit;
 
 #define BIT(v,n)       (((v) >> (n)) & 0x1)
 
@@ -198,7 +214,8 @@ static int find_contig_space(int block, int num_blocks, int max_blocks)
        return -ENOSPC;
 }
 
-#define pr_fcb_val(p, n)       debug("%s=%08x(%d)\n", #n, (p)->n, (p)->n)
+#define offset_of(p, m)                ((void *)&(p)->m - (void *)(p))
+#define pr_fcb_val(p, n)       debug("%-24s[%02x]=%08x(%d)\n", #n, offset_of(p, n), (p)->n, (p)->n)
 
 static struct mx6_fcb *create_fcb(void *buf, int fw1_start_block,
                                int fw2_start_block, int fw_num_blocks)
@@ -327,84 +344,49 @@ static int write_fcb(void *buf, int block)
                return 0;
        }
 
-       ret = nand_erase(mtd, block * mtd->erasesize, mtd->erasesize);
-       if (ret) {
-               printf("Failed to erase FCB block %u\n", block);
-               return ret;
+       if (doit) {
+               ret = nand_erase(mtd, block * mtd->erasesize, mtd->erasesize);
+               if (ret) {
+                       printf("Failed to erase FCB block %u\n", block);
+                       return ret;
+               }
        }
 
        printf("Writing FCB to block %d @ %08llx\n", block,
                (u64)block * mtd->erasesize);
-       chip->select_chip(mtd, 0);
-       ret = chip->write_page(mtd, chip, 0, mtd->writesize,
-                       buf, 1, page, 0, 1);
-       if (ret) {
-               printf("Failed to write FCB to block %u: %d\n", block, ret);
+       if (doit) {
+               chip->select_chip(mtd, 0);
+               ret = chip->write_page(mtd, chip, 0, mtd->writesize,
+                               buf, 1, page, 0, 1);
+               if (ret) {
+                       printf("Failed to write FCB to block %u: %d\n", block, ret);
+               }
+               chip->select_chip(mtd, -1);
        }
-       chip->select_chip(mtd, -1);
        return ret;
 }
 
-struct mx6_ivt {
-       u32 magic;
-       u32 entry;
-       u32 rsrvd1;
-       void *dcd;
-       void *boot_data;
-       void *self;
-       void *csf;
-       u32 rsrvd2;
-};
-
-struct mx6_boot_data {
-       u32 start;
-       u32 length;
-       u32 plugin;
-};
-
-static int find_ivt(void *buf)
-{
-       struct mx6_ivt *ivt_hdr = buf + 0x400;
-
-       if ((ivt_hdr->magic & 0xff0000ff) != 0x400000d1)
-               return 0;
-
-       return 1;
-}
-
-static inline void *reloc(void *dst, void *base, void *ptr)
-{
-       return dst + (ptr - base);
-}
-
-static int patch_ivt(void *buf, size_t fsize)
-{
-       struct mx6_ivt *ivt_hdr = buf + 0x400;
-       struct mx6_boot_data *boot_data;
-
-       if (!find_ivt(buf)) {
-               printf("No IVT found in image at %p\n", buf);
-               return -EINVAL;
-       }
-       boot_data = reloc(ivt_hdr, ivt_hdr->self, ivt_hdr->boot_data);
-       boot_data->length = fsize;
-
-       return 0;
-}
-
 #define chk_overlap(a,b)                               \
        ((a##_start_block <= b##_end_block &&           \
                a##_end_block >= b##_start_block) ||    \
        (b##_start_block <= a##_end_block &&            \
                b##_end_block >= a##_start_block))
 
-#define fail_if_overlap(a,b,m1,m2) do {                                \
-       if (chk_overlap(a, b)) {                                \
+#define fail_if_overlap(a,b,m1,m2) do {                                        \
+       if (!doit)                                                      \
+               printf("check: %s[%lu..%lu] <> %s[%lu..%lu]\n",         \
+                       m1, a##_start_block, a##_end_block,             \
+                       m2, b##_start_block, b##_end_block);            \
+       if (a##_end_block < a##_start_block)                            \
+               printf("Invalid start/end block # for %s\n", m1);       \
+       if (b##_end_block < b##_start_block)                            \
+               printf("Invalid start/end block # for %s\n", m2);       \
+       if (chk_overlap(a, b)) {                                        \
                printf("%s blocks %lu..%lu overlap %s in blocks %lu..%lu!\n", \
-                       m1, a##_start_block, a##_end_block,     \
-                       m2, b##_start_block, b##_end_block);    \
-               return -EINVAL;                                 \
-       }                                                       \
+                       m1, a##_start_block, a##_end_block,             \
+                       m2, b##_start_block, b##_end_block);            \
+               return -EINVAL;                                         \
+       }                                                               \
 } while (0)
 
 static int tx6_prog_uboot(void *addr, int start_block, int skip,
@@ -422,25 +404,28 @@ static int tx6_prog_uboot(void *addr, int start_block, int skip,
 
        printf("Erasing flash @ %08llx..%08llx\n", erase_opts.offset,
                erase_opts.offset + erase_opts.length - 1);
-       ret = nand_erase_opts(mtd, &erase_opts);
-       if (ret) {
-               printf("Failed to erase flash: %d\n", ret);
-               return ret;
+       if (doit) {
+               ret = nand_erase_opts(mtd, &erase_opts);
+               if (ret) {
+                       printf("Failed to erase flash: %d\n", ret);
+                       return ret;
+               }
        }
 
-       printf("Programming flash @ %08llx..%08llx from %p\n",
-               (u64)start_block * mtd->erasesize,
-               (u64)start_block * mtd->erasesize + size - 1, addr);
-       actual = size;
-       ret = nand_write_skip_bad(mtd, prg_start, &actual, NULL,
-                               prg_length, addr, WITH_DROP_FFS);
-       if (ret) {
-               printf("Failed to program flash: %d\n", ret);
-               return ret;
-       }
-       if (actual < size) {
-               printf("Could only write %u of %u bytes\n", actual, size);
-               return -EIO;
+       printf("Programming flash @ %08x..%08x from %p\n",
+               prg_start, prg_start + size - 1, addr);
+       if (doit) {
+               actual = size;
+               ret = nand_write_skip_bad(mtd, prg_start, &actual, NULL,
+                                       prg_length, addr, WITH_DROP_FFS);
+               if (ret) {
+                       printf("Failed to program flash: %d\n", ret);
+                       return ret;
+               }
+               if (actual < size) {
+                       printf("Could only write %u of %u bytes\n", actual, size);
+                       return -EIO;
+               }
        }
        return 0;
 }
@@ -458,7 +443,6 @@ int do_update(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
        int ret;
        const unsigned long fcb_start_block = 0, fcb_end_block = 0;
        int erase_size = mtd->erasesize;
-       int page_size = mtd->writesize;
        void *buf;
        char *load_addr;
        char *file_size;
@@ -491,6 +475,7 @@ int do_update(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
        if (ret)
                return ret;
 
+       doit = true;
        for (optind = 1; optind < argc; optind++) {
                char *endp;
 
@@ -543,6 +528,8 @@ int do_update(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
                                        mtd_num_blocks - 1);
                                return -EINVAL;
                        }
+               } else if (strcmp(argv[optind], "-n") == 0) {
+                       doit = false;
                } else if (argv[optind][0] == '-') {
                        printf("Unrecognized option %s\n", argv[optind]);
                        return -EINVAL;
@@ -559,7 +546,14 @@ int do_update(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
                return -EINVAL;
        }
        if (argc - optind < 2 && file_size == NULL) {
-               printf("WARNING: Image size not specified; overwriting whole uboot partition\n");
+               if (uboot_part) {
+                       printf("WARNING: Image size not specified; overwriting whole '%s' partition\n",
+                               uboot_part);
+                       printf("This will only work, if there are no bad blocks inside this partition!\n");
+               } else {
+                       printf("ERROR: Image size must be specified\n");
+                       return -EINVAL;
+               }
        }
        if (argc > optind) {
                load_addr = NULL;
@@ -579,13 +573,10 @@ int do_update(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
                size = simple_strtoul(file_size, NULL, 16);
                printf("Using default file size %08x\n", size);
        }
-       if (size > 0) {
+       if (size > 0)
                fw_num_blocks = DIV_ROUND_UP(size, mtd->erasesize);
-       } else {
-               fw_num_blocks = part_info->size / mtd->erasesize -
-                       extra_blocks;
-               size = fw_num_blocks * mtd->erasesize;
-       }
+       else
+               fw_num_blocks = 0;
 
        if (uboot_part) {
                ret = find_dev_and_part(uboot_part, &dev, &part_num,
@@ -597,6 +588,8 @@ int do_update(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
                }
                fw1_start_block = part_info->offset / mtd->erasesize;
                max_len1 = part_info->size;
+               if (size == 0)
+                       fw_num_blocks = max_len1 / mtd->erasesize;
        } else {
                max_len1 = (fw_num_blocks + extra_blocks) * mtd->erasesize;
        }
@@ -611,6 +604,12 @@ int do_update(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
                }
                fw2_start_block = redund_part_info->offset / mtd->erasesize;
                max_len2 = redund_part_info->size;
+               if (fw2_start_block == fcb_start_block) {
+                       fw2_start_block++;
+                       max_len2 -= mtd->erasesize;
+               }
+               if (size == 0)
+                       fw_num_blocks = max_len2 / mtd->erasesize;
        } else if (fw2_set) {
                max_len2 = (fw_num_blocks + extra_blocks) * mtd->erasesize;
        } else {
@@ -620,8 +619,9 @@ int do_update(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
        fw1_skip = find_contig_space(fw1_start_block, fw_num_blocks,
                                max_len1 / mtd->erasesize);
        if (fw1_skip < 0) {
-               printf("Could not find %lu contiguous good blocks for fw image\n",
-                       fw_num_blocks);
+               printf("Could not find %lu contiguous good blocks for fw image in blocks %lu..%lu\n",
+                       fw_num_blocks, fw1_start_block,
+                       fw1_start_block + max_len1 / mtd->erasesize - 1);
                if (uboot_part) {
 #ifdef CONFIG_ENV_IS_IN_NAND
                        if (part_info->offset <= CONFIG_ENV_OFFSET + TOTAL_ENV_SIZE) {
@@ -639,7 +639,10 @@ int do_update(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
                }
                return -ENOSPC;
        }
-       fw1_end_block = fw1_start_block + fw1_skip + fw_num_blocks - 1;
+       if (extra_blocks)
+               fw1_end_block = fw1_start_block + fw_num_blocks + extra_blocks - 1;
+       else
+               fw1_end_block = fw1_start_block + fw_num_blocks + fw1_skip - 1;
 
        if (fw2_set && fw2_start_block == 0)
                fw2_start_block = fw1_end_block + 1;
@@ -647,8 +650,9 @@ int do_update(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
                fw2_skip = find_contig_space(fw2_start_block, fw_num_blocks,
                                        max_len2 / mtd->erasesize);
                if (fw2_skip < 0) {
-                       printf("Could not find %lu contiguous good blocks for redundant fw image\n",
-                               fw_num_blocks);
+                       printf("Could not find %lu contiguous good blocks for redundant fw image in blocks %lu..%lu\n",
+                               fw_num_blocks, fw2_start_block,
+                               fw2_start_block + max_len2 / mtd->erasesize - 1);
                        if (redund_part) {
                                printf("Increase the size of the '%s' partition or use a different partition\n",
                                        redund_part);
@@ -660,7 +664,10 @@ int do_update(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
        } else {
                fw2_skip = 0;
        }
-       fw2_end_block = fw2_start_block + fw2_skip + fw_num_blocks - 1;
+       if (extra_blocks)
+               fw2_end_block = fw2_start_block + fw_num_blocks + extra_blocks - 1;
+       else
+               fw2_end_block = fw2_start_block + fw_num_blocks + fw2_skip - 1;
 
 #ifdef CONFIG_ENV_IS_IN_NAND
        fail_if_overlap(fcb, env, "FCB", "Environment");
@@ -674,53 +681,44 @@ int do_update(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 #endif
                fail_if_overlap(fw1, fw2, "FW1", "FW2");
        }
+       fw1_start_block += fw1_skip;
+       fw2_start_block += fw2_skip;
 
-       buf = malloc(erase_size);
+       buf = memalign(SZ_128K, erase_size);
        if (buf == NULL) {
                printf("Failed to allocate buffer\n");
                return -ENOMEM;
        }
 
-       fcb = create_fcb(buf, fw1_start_block + fw1_skip,
-                       fw2_start_block + fw2_skip, fw_num_blocks);
+       fcb = create_fcb(buf, fw1_start_block,
+                       fw2_start_block, fw_num_blocks);
        if (IS_ERR(fcb)) {
                printf("Failed to initialize FCB: %ld\n", PTR_ERR(fcb));
-               free(buf);
-               return PTR_ERR(fcb);
+               ret = PTR_ERR(fcb);
+               goto out;
        }
        encode_hamming_13_8(fcb, (void *)fcb + 512, 512);
 
        ret = write_fcb(buf, fcb_start_block);
-       free(buf);
        if (ret) {
                printf("Failed to write FCB to block %lu\n", fcb_start_block);
                return ret;
        }
-       ret = patch_ivt(addr, size);
-       if (ret) {
-               return ret;
-       }
-
-       if (size & (page_size - 1)) {
-               memset(addr + size, 0xff, size & (page_size - 1));
-               size = ALIGN(size, page_size);
-       }
 
        printf("Programming U-Boot image from %p to block %lu @ %08llx\n",
-               addr, fw1_start_block + fw1_skip,
-               (u64)(fw1_start_block + fw1_skip) * mtd->erasesize);
+               buf, fw1_start_block, (u64)fw1_start_block * mtd->erasesize);
        ret = tx6_prog_uboot(addr, fw1_start_block, fw1_skip, size,
                        max_len1);
 
-       if (fw2_start_block == 0) {
-               return ret;
-       }
+       if (ret || fw2_start_block == 0)
+               goto out;
 
        printf("Programming redundant U-Boot image to block %lu @ %08llx\n",
-               fw2_start_block + fw2_skip,
-               (u64)(fw2_start_block + fw2_skip) * mtd->erasesize);
-       ret = tx6_prog_uboot(addr, fw2_start_block, fw2_skip, fw_num_blocks,
+               fw2_start_block, (u64)fw2_start_block * mtd->erasesize);
+       ret = tx6_prog_uboot(addr, fw2_start_block, fw2_skip, size,
                        max_len2);
+out:
+       free(buf);
        return ret;
 }
 
@@ -728,12 +726,13 @@ U_BOOT_CMD(romupdate, 11, 0, do_update,
        "Creates an FCB data structure and writes an U-Boot image to flash",
        "[-f {<part>|block#}] [-r [{<part>|block#}]] [-e #] [<address>] [<length>]\n"
        "\t-f <part>\twrite bootloader image to partition <part>\n"
-       "\t-f #\twrite bootloader image at block # (decimal)\n"
-       "\t-r\twrite redundant bootloader image at next free block after first image\n"
+       "\t-f #\t\twrite bootloader image at block # (decimal)\n"
+       "\t-r\t\twrite redundant bootloader image at next free block after first image\n"
        "\t-r <part>\twrite redundant bootloader image to partition <part>\n"
-       "\t-r #\twrite redundant bootloader image at block # (decimal)\n"
-       "\t-e #\tspecify number of redundant blocks per boot loader image\n"
-       "\t\tonly valid if -f or -r specify a flash address rather than a partition name\n"
-       "\t<address>\tRAM address of bootloader image (default: ${fileaddr}\n"
-       "\t<length>\tlength of bootloader image in RAM (default: ${filesize}"
+       "\t-r #\t\twrite redundant bootloader image at block # (decimal)\n"
+       "\t-e #\t\tspecify number of redundant blocks per boot loader image\n"
+       "\t\t\t(only valid if -f or -r specify a flash address rather than a partition name)\n"
+       "\t-n\t\tshow what would be done without actually updating the flash\n"
+       "\t<address>\tRAM address of bootloader image (default: ${fileaddr})\n"
+       "\t<length>\tlength of bootloader image in RAM (default: ${filesize})"
        );
index 16f78d3..34a7b28 100644 (file)
@@ -1,5 +1,7 @@
 #include <config.h>
+#include <asm-offsets.h>
 #include <configs/tx6.h>
+#include <linux/linkage.h>
 #include <asm/arch/imx-regs.h>
 #include <generated/asm-offsets.h>
 
@@ -87,6 +89,8 @@ dcd_start:
        .error  "DCD too large!"
        .endif
 dcd_end:
+       .section ".pad"
+       .section ".text"
        .endm
 
 #define MXC_DCD_CMD_WRT(type, flags)                                   \
@@ -329,6 +333,7 @@ CK_MAX      tCKSRE, NS_TO_CK(10), 5, 0, 7
                                (tODTLon << 12) |       \
                                (tODTLoff << 4))
 
+       .section ".ivt"
 ivt_header:
        .word   CPU_2_BE_32((0xd1 << 24) | (32 << 8) | 0x40)
 app_start_addr:
@@ -341,12 +346,16 @@ boot_data_ptr:
 self_ptr:
        .word   ivt_header
 app_code_csf:
+#ifdef CONFIG_SECURE_BOOT
+       .word   __csf_data
+#else
        .word   0x0
+#endif
        .word   0x0
 boot_data:
-       .long   _start
+       .long   CONFIG_SYS_TEXT_BASE
 image_len:
-       .long   CONFIG_U_BOOT_IMG_SIZE
+       .long   __uboot_img_len
 plugin:
        .word   0
 ivt_end:
index 5d48b2b..04a9222 100644 (file)
@@ -31,6 +31,7 @@
 #include <asm/gpio.h>
 #include <asm/arch/mx6-pins.h>
 #include <asm/arch/clock.h>
+#include <asm/arch/hab.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/crm_regs.h>
 #include <asm/arch/sys_proto.h>
@@ -70,6 +71,11 @@ enum {
        MX6_PAD_DECL(GARBAGE, 0, 0, 0, 0, 0, 0)
 };
 
+char __uboot_img_end[0] __attribute__((section(".__uboot_img_end")));
+#ifdef CONFIG_SECURE_BOOT
+char __csf_data[0] __attribute__((section(".__csf_data")));
+#endif
+
 static const iomux_v3_cfg_t const tx6qdl_pads[] = {
        /* RESET_OUT */
        MX6_PAD_GPIO_17__GPIO7_IO12,
@@ -1131,6 +1137,13 @@ int board_late_init(void)
 {
        int ret = 0;
        const char *baseboard;
+#if 1
+       /* override secure_boot fuse */
+       struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
+       struct fuse_bank0_regs *fuse = (void *)ocotp->bank[0].fuse_regs;
+
+       writel(0x12, &fuse->cfg5);
+#endif
 
        env_cleanup();
 
@@ -1277,6 +1290,8 @@ int checkboard(void)
                is_lvds(), tx6_get_mod_rev(pmic_id),
                tx6_mem_suffix());
 
+       get_hab_status();
+
        return 0;
 }
 
index 4578feb..c4e0e21 100644 (file)
@@ -27,13 +27,17 @@ SECTIONS
        . = 0x00000000;
        .text :
        {
+               __uboot_img_start = .;
+               . = 0x400;
+               __ivt_start = .;
+               KEEP(*(.ivt*))
+               . = 0x1000;
+               __ivt_end = .;
                *(.__image_copy_start)
                *(.vectors)
                CPUDIR/start.o (.text*)
-               . = 0x400;
-               KEEP(board/karo/tx6/lowlevel_init.o (.text*))
                *(.text*)
-       }
+       } = 0xadde01f0
 
        . = ALIGN(4);
        .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
@@ -41,9 +45,9 @@ SECTIONS
        . = ALIGN(4);
        .data : {
                *(.data*)
+               . = ALIGN(4);
        }
 
-       . = ALIGN(4);
        .u_boot_list : {
                KEEP(*(SORT(.u_boot_list*)));
        }
@@ -69,12 +73,28 @@ SECTIONS
                *(.__rel_dyn_end)
        }
 
-       .end :
+       .pad :
        {
-               *(.__end)
+               *(.pad)
+               . = ALIGN(4096);
+       } = 0x01f0adde
+
+       _image_binary_end = . + (__ivt_end - __uboot_img_start);
+
+       .uboot_img_end :
+       {
+               KEEP(*(.__uboot_img_end))
        }
 
-       _image_binary_end = .;
+#ifdef CONFIG_SECURE_BOOT
+       . = CONFIG_SYS_TEXT_BASE + 0x70000;
+       .csf_data :
+       {
+               *(.__csf_data)
+               . = . + 0x2000;
+       }
+#endif
+       __uboot_img_len = . - __uboot_img_start;
 
 /*
  * Compiler-generated __bss_start and __bss_end, see arch/arm/lib/bss.c
@@ -94,26 +114,18 @@ SECTIONS
        .bss_end __bss_limit (OVERLAY) : {
                KEEP(*(.__bss_end));
        }
-       .dynsym _image_binary_end : { *(.dynsym) }
-       .dynbss : { *(.dynbss) }
-       .dynstr : { *(.dynstr*) }
-       .dynamic : { *(.dynamic*) }
-       .plt : { *(.plt*) }
-       .interp : { *(.interp*) }
-       .gnu.hash : { *(.gnu.hash) }
-       .gnu : { *(.gnu*) }
-       .ARM.exidx : { *(.ARM.exidx*) }
-       .gnu.linkonce.armexidx : { *(.gnu.linkonce.armexidx.*) }
 
-/*
-       /DISCARD/ : { *(.bss*) }
+       .dynsym _image_binary_end : { *(.dynsym) }
+       /DISCARD/ : { *(.debug*) }
+       /DISCARD/ : { *(.note*) }
+       /DISCARD/ : { *(.comment*) }
+       /DISCARD/ : { *(.dynbss) }
        /DISCARD/ : { *(.dynstr*) }
-       /DISCARD/ : { *(.dynsym*) }
        /DISCARD/ : { *(.dynamic*) }
-       /DISCARD/ : { *(.hash*) }
        /DISCARD/ : { *(.plt*) }
        /DISCARD/ : { *(.interp*) }
+       /DISCARD/ : { *(.gnu.hash) }
        /DISCARD/ : { *(.gnu*) }
-*/
+       /DISCARD/ : { *(.ARM.exidx*) }
+       /DISCARD/ : { *(.gnu.linkonce.armexidx.*) }
 }
index ead783c..da18c7a 100644 (file)
@@ -440,6 +440,11 @@ config CMD_TIME
        help
          Run commands and summarize execution time.
 
+config CMD_FUSE
+       bool "fuse read/write"
+       help
+         eFuse reading and programming support
+
 # TODO: rename to CMD_SLEEP
 config CMD_MISC
        bool "sleep"
diff --git a/configs/tx6q-1020_sec_defconfig b/configs/tx6q-1020_sec_defconfig
new file mode 100644 (file)
index 0000000..66dc59b
--- /dev/null
@@ -0,0 +1,28 @@
+CONFIG_SYS_EXTRA_OPTIONS="MMC_BOOT_SIZE=4096,TX6_REV=0x2,SECURE_BOOT"
+CONFIG_ARM=y
+CONFIG_SOC_MX6Q=y
+CONFIG_TARGET_TX6=y
+CONFIG_TARGET_TX6Q_1020=y
+CONFIG_TX6_UBOOT=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_PING=y
+CONFIG_BOOTP_SUBNETMASK=y
+CONFIG_BOOTP_GATEWAY=y
+CONFIG_BOOTP_DNS=y
+CONFIG_MMC=y
+CONFIG_FSL_ESDHC=y
+CONFIG_FSL_USDHC=y
+CONFIG_LCD=y
+CONFIG_NET=y
+CONFIG_NETDEVICES=y
+CONFIG_FEC_MXC=y
+CONFIG_IMX_WATCHDOG=y
+CONFIG_CMD_I2C=y
+CONFIG_DOS_PARTITION=y
+CONFIG_ENV_IS_IN_MMC=y
+CONFIG_FEC_MXC_PHYADDR=0
+CONFIG_MXC_OCOTP=y
+CONFIG_CMD_FUSE=y
+CONFIG_PHY_SMSC=y
diff --git a/configs/tx6q-10x0_sec_defconfig b/configs/tx6q-10x0_sec_defconfig
new file mode 100644 (file)
index 0000000..f3b4fd9
--- /dev/null
@@ -0,0 +1,26 @@
+CONFIG_SYS_EXTRA_OPTIONS="SECURE_BOOT"
+CONFIG_ARM=y
+CONFIG_SOC_MX6Q=y
+CONFIG_TARGET_TX6=y
+CONFIG_TARGET_TX6Q_10X0=y
+CONFIG_TX6_UBOOT=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_PING=y
+CONFIG_BOOTP_SUBNETMASK=y
+CONFIG_BOOTP_GATEWAY=y
+CONFIG_BOOTP_DNS=y
+CONFIG_MMC=y
+CONFIG_FSL_ESDHC=y
+CONFIG_FSL_USDHC=y
+CONFIG_LCD=y
+CONFIG_NET=y
+CONFIG_NETDEVICES=y
+CONFIG_FEC_MXC=y
+CONFIG_IMX_WATCHDOG=y
+CONFIG_CMD_I2C=y
+CONFIG_DOS_PARTITION=y
+CONFIG_ENV_IS_IN_NAND=y
+CONFIG_FEC_MXC_PHYADDR=0
+CONFIG_MXC_OCOTP=y
+CONFIG_CMD_FUSE=y
diff --git a/configs/tx6s-8034_sec_defconfig b/configs/tx6s-8034_sec_defconfig
new file mode 100644 (file)
index 0000000..3462556
--- /dev/null
@@ -0,0 +1,30 @@
+CONFIG_SYS_EXTRA_OPTIONS="SYS_SDRAM_BUS_WIDTH=16,SECURE_BOOT"
+CONFIG_ARM=y
+CONFIG_SOC_MX6S=y
+CONFIG_TARGET_TX6=y
+CONFIG_TARGET_TX6S_8034=y
+CONFIG_TX6_UBOOT=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_PING=y
+CONFIG_BOOTP_SUBNETMASK=y
+CONFIG_BOOTP_GATEWAY=y
+CONFIG_BOOTP_DNS=y
+CONFIG_MMC=y
+CONFIG_FSL_ESDHC=y
+CONFIG_FSL_USDHC=y
+CONFIG_LCD=y
+CONFIG_NET=y
+CONFIG_NETDEVICES=y
+CONFIG_FEC_MXC=y
+CONFIG_IMX_WATCHDOG=y
+CONFIG_CMD_I2C=y
+CONFIG_NAND=y
+CONFIG_NAND_MXS=y
+CONFIG_DOS_PARTITION=y
+CONFIG_ENV_IS_IN_NAND=y
+CONFIG_FEC_MXC_PHYADDR=0
+CONFIG_MXC_OCOTP=y
+CONFIG_CMD_FUSE=y
+CONFIG_PHY_SMSC=y
diff --git a/configs/tx6u-8012_sec_defconfig b/configs/tx6u-8012_sec_defconfig
new file mode 100644 (file)
index 0000000..4d7e3bc
--- /dev/null
@@ -0,0 +1,26 @@
+CONFIG_SYS_EXTRA_OPTIONS="SYS_NAND_BLOCKS=2048,SECURE_BOOT"
+CONFIG_ARM=y
+CONFIG_SOC_MX6DL=y
+CONFIG_TARGET_TX6=y
+CONFIG_TARGET_TX6U_8012=y
+CONFIG_TX6_UBOOT=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_PING=y
+CONFIG_BOOTP_SUBNETMASK=y
+CONFIG_BOOTP_GATEWAY=y
+CONFIG_BOOTP_DNS=y
+CONFIG_MMC=y
+CONFIG_FSL_ESDHC=y
+CONFIG_FSL_USDHC=y
+CONFIG_LCD=y
+CONFIG_NET=y
+CONFIG_NETDEVICES=y
+CONFIG_FEC_MXC=y
+CONFIG_IMX_WATCHDOG=y
+CONFIG_CMD_I2C=y
+CONFIG_DOS_PARTITION=y
+CONFIG_ENV_IS_IN_NAND=y
+CONFIG_FEC_MXC_PHYADDR=0
+CONFIG_MXC_OCOTP=y
+CONFIG_CMD_FUSE=y
diff --git a/configs/tx6u-8033_sec_defconfig b/configs/tx6u-8033_sec_defconfig
new file mode 100644 (file)
index 0000000..566a155
--- /dev/null
@@ -0,0 +1,26 @@
+CONFIG_SYS_EXTRA_OPTIONS="MMC_BOOT_SIZE=1024,SECURE_BOOT"
+CONFIG_ARM=y
+CONFIG_SOC_MX6DL=y
+CONFIG_TARGET_TX6=y
+CONFIG_TARGET_TX6U_8033=y
+CONFIG_TX6_UBOOT=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_PING=y
+CONFIG_BOOTP_SUBNETMASK=y
+CONFIG_BOOTP_GATEWAY=y
+CONFIG_BOOTP_DNS=y
+CONFIG_MMC=y
+CONFIG_FSL_ESDHC=y
+CONFIG_FSL_USDHC=y
+CONFIG_LCD=y
+CONFIG_NET=y
+CONFIG_NETDEVICES=y
+CONFIG_FEC_MXC=y
+CONFIG_IMX_WATCHDOG=y
+CONFIG_CMD_I2C=y
+CONFIG_DOS_PARTITION=y
+CONFIG_ENV_IS_IN_MMC=y
+CONFIG_FEC_MXC_PHYADDR=0
+CONFIG_MXC_OCOTP=y
+CONFIG_CMD_FUSE=y
diff --git a/configs/tx6u-80x0_sec_defconfig b/configs/tx6u-80x0_sec_defconfig
new file mode 100644 (file)
index 0000000..f1fc096
--- /dev/null
@@ -0,0 +1,26 @@
+CONFIG_SYS_EXTRA_OPTIONS="SECURE_BOOT"
+CONFIG_ARM=y
+CONFIG_SOC_MX6DL=y
+CONFIG_TARGET_TX6=y
+CONFIG_TARGET_TX6U_80X0=y
+CONFIG_TX6_UBOOT=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_PING=y
+CONFIG_BOOTP_SUBNETMASK=y
+CONFIG_BOOTP_GATEWAY=y
+CONFIG_BOOTP_DNS=y
+CONFIG_MMC=y
+CONFIG_FSL_ESDHC=y
+CONFIG_FSL_USDHC=y
+CONFIG_LCD=y
+CONFIG_NET=y
+CONFIG_NETDEVICES=y
+CONFIG_FEC_MXC=y
+CONFIG_IMX_WATCHDOG=y
+CONFIG_CMD_I2C=y
+CONFIG_DOS_PARTITION=y
+CONFIG_ENV_IS_IN_NAND=y
+CONFIG_FEC_MXC_PHYADDR=0
+CONFIG_MXC_OCOTP=y
+CONFIG_CMD_FUSE=y
index d92044e..5fb86ca 100644 (file)
@@ -60,7 +60,7 @@ static int prepare_access(struct ocotp_regs **regs, u32 bank, u32 word,
        *regs = (struct ocotp_regs *)OCOTP_BASE_ADDR;
 
        if (bank >= ARRAY_SIZE((*regs)->bank) ||
-                       word >= ARRAY_SIZE((*regs)->bank[0].fuse_regs) >> 2 ||
+                       word >= ARRAY_SIZE((*regs)->bank[0].fuse_regs) ||
                        !assert) {
                printf("mxc_ocotp %s(): Invalid argument\n", caller);
                return -EINVAL;