Merge branch '2020-05-01-master-imports'
authorTom Rini <trini@konsulko.com>
Fri, 1 May 2020 20:43:15 +0000 (16:43 -0400)
committerTom Rini <trini@konsulko.com>
Fri, 1 May 2020 20:43:15 +0000 (16:43 -0400)
- Assorted bug fixes
- Framework for enabling D-CACHE in SPL on ARM

32 files changed:
.readthedocs.yml
Kconfig
arch/arm/Kconfig
arch/arm/include/asm/iproc-common/configs.h
arch/arm/include/asm/system.h
arch/arm/lib/cache-cp15.c
arch/arm/lib/interrupts.c
arch/arm/lib/interrupts_64.c
arch/arm/lib/interrupts_m.c
cmd/bedbug.c
cmd/gpt.c
common/board_r.c
common/cli_hush.c
common/dlmalloc.c
common/image-fit-sig.c
configs/mt7623n_bpir2_defconfig
doc/develop/crash_dumps.rst [new file with mode: 0644]
doc/develop/index.rst [new file with mode: 0644]
doc/index.rst
drivers/rtc/pcf2127.c
drivers/timer/mtk_timer.c
drivers/watchdog/mtk_wdt.c
fs/ext4/ext4_journal.c
include/bedbug/type.h
include/configs/grpeach.h
include/configs/mt7623.h
include/configs/pxa-common.h
lib/tiny-printf.c
scripts/config_whitelist.txt
test/py/tests/test_vboot.py
tools/fit_image.c
tools/mkimage.h

index f3fb5ed..44949ea 100644 (file)
@@ -7,7 +7,7 @@ version: 2
 
 # Build documentation in the docs/ directory with Sphinx
 sphinx:
-  configuration: docs/conf.py
+  configuration: doc/conf.py
 
 # Optionally build your docs in additional formats such as PDF and ePub
 formats: []
diff --git a/Kconfig b/Kconfig
index 9a5e600..15f1a75 100644 (file)
--- a/Kconfig
+++ b/Kconfig
@@ -209,6 +209,20 @@ if EXPERT
          When disabling this, please check if malloc calls, maybe
          should be replaced by calloc - if one expects zeroed memory.
 
+config SYS_MALLOC_DEFAULT_TO_INIT
+       bool "Default malloc to init while reserving the memory for it"
+       default n
+       help
+         It may happen that one needs to move the dynamic allocation
+         from one to another memory range, eg. when moving the malloc
+         from the limited static to a potentially large dynamic (DDR)
+         memory.
+
+         If so then on top of setting the updated memory aside one
+         needs to bring the malloc init.
+
+         If such a scenario is sought choose yes.
+
 config TOOLS_DEBUG
        bool "Enable debug information for tools"
        help
index 8e67e1c..b494bca 100644 (file)
@@ -340,6 +340,34 @@ config SYS_CACHELINE_SIZE
        default 64 if SYS_CACHE_SHIFT_6
        default 32 if SYS_CACHE_SHIFT_5
 
+choice
+       prompt "Select the ARM data write cache policy"
+       default SYS_ARM_CACHE_WRITETHROUGH if TARGET_BCMCYGNUS || \
+                                             TARGET_BCMNSP || CPU_PXA || RZA1
+       default SYS_ARM_CACHE_WRITEBACK
+
+config SYS_ARM_CACHE_WRITEBACK
+       bool "Write-back (WB)"
+       help
+         A write updates the cache only and marks the cache line as dirty.
+         External memory is updated only when the line is evicted or explicitly
+         cleaned.
+
+config SYS_ARM_CACHE_WRITETHROUGH
+       bool "Write-through (WT)"
+       help
+         A write updates both the cache and the external memory system.
+         This does not mark the cache line as dirty.
+
+config SYS_ARM_CACHE_WRITEALLOC
+       bool "Write allocation (WA)"
+       help
+         A cache line is allocated on a write miss. This means that executing a
+         store instruction on the processor might cause a burst read to occur.
+         There is a linefill to obtain the data for the cache line, before the
+         write is performed.
+endchoice
+
 config ARCH_CPU_INIT
        bool "Enable ARCH_CPU_INIT"
        help
@@ -881,7 +909,7 @@ config ARCH_OWL
        select CLK
        select CLK_OWL
        select OF_CONTROL
-       select CONFIG_SYS_RELOC_GD_ENV_ADDR
+       select SYS_RELOC_GD_ENV_ADDR
        imply CMD_DM
 
 config ARCH_QEMU
index 96c4f54..4733c07 100644 (file)
@@ -10,7 +10,6 @@
 
 /* Architecture, CPU, chip, etc */
 #define CONFIG_IPROC
-#define CONFIG_SYS_ARM_CACHE_WRITETHROUGH
 
 /* Memory Info */
 #define CONFIG_SYS_SDRAM_BASE          0x61000000
index 81ccead..a3147fd 100644 (file)
@@ -485,6 +485,14 @@ enum dcache_option {
 };
 #endif
 
+#if defined(CONFIG_SYS_ARM_CACHE_WRITETHROUGH)
+#define DCACHE_DEFAULT_OPTION  DCACHE_WRITETHROUGH
+#elif defined(CONFIG_SYS_ARM_CACHE_WRITEALLOC)
+#define DCACHE_DEFAULT_OPTION  DCACHE_WRITEALLOC
+#elif defined(CONFIG_SYS_ARM_CACHE_WRITEBACK)
+#define DCACHE_DEFAULT_OPTION  DCACHE_WRITEBACK
+#endif
+
 /* Size of an MMU section */
 enum {
 #ifdef CONFIG_ARMV7_LPAE
index f8d2096..f803d6f 100644 (file)
@@ -61,8 +61,11 @@ void mmu_set_region_dcache_behaviour(phys_addr_t start, size_t size,
        unsigned long startpt, stoppt;
        unsigned long upto, end;
 
-       end = ALIGN(start + size, MMU_SECTION_SIZE) >> MMU_SECTION_SHIFT;
+       /* div by 2 before start + size to avoid phys_addr_t overflow */
+       end = ALIGN((start / 2) + (size / 2), MMU_SECTION_SIZE / 2)
+             >> (MMU_SECTION_SHIFT - 1);
        start = start >> MMU_SECTION_SHIFT;
+
 #ifdef CONFIG_ARMV7_LPAE
        debug("%s: start=%pa, size=%zu, option=%llx\n", __func__, &start, size,
              option);
@@ -91,19 +94,16 @@ __weak void dram_bank_mmu_setup(int bank)
        bd_t *bd = gd->bd;
        int     i;
 
+       /* bd->bi_dram is available only after relocation */
+       if ((gd->flags & GD_FLG_RELOC) == 0)
+               return;
+
        debug("%s: bank: %d\n", __func__, bank);
        for (i = bd->bi_dram[bank].start >> MMU_SECTION_SHIFT;
             i < (bd->bi_dram[bank].start >> MMU_SECTION_SHIFT) +
                 (bd->bi_dram[bank].size >> MMU_SECTION_SHIFT);
-            i++) {
-#if defined(CONFIG_SYS_ARM_CACHE_WRITETHROUGH)
-               set_section_dcache(i, DCACHE_WRITETHROUGH);
-#elif defined(CONFIG_SYS_ARM_CACHE_WRITEALLOC)
-               set_section_dcache(i, DCACHE_WRITEALLOC);
-#else
-               set_section_dcache(i, DCACHE_WRITEBACK);
-#endif
-       }
+            i++)
+               set_section_dcache(i, DCACHE_DEFAULT_OPTION);
 }
 
 /* to activate the MMU we need to set up virtual memory: use 1M areas */
index 6dbf03b..36299d6 100644 (file)
@@ -34,6 +34,8 @@ int interrupt_init(void)
         */
        IRQ_STACK_START_IN = gd->irq_sp + 8;
 
+       enable_interrupts();
+
        return 0;
 }
 
index dffdf57..a2df7cf 100644 (file)
@@ -13,6 +13,8 @@ DECLARE_GLOBAL_DATA_PTR;
 
 int interrupt_init(void)
 {
+       enable_interrupts();
+
        return 0;
 }
 
index 1f6fdf2..2ae1c5b 100644 (file)
@@ -31,6 +31,8 @@ struct autosave_regs {
 
 int interrupt_init(void)
 {
+       enable_interrupts();
+
        return 0;
 }
 
index 9fee528..d3e3121 100644 (file)
@@ -44,10 +44,10 @@ int bedbug_puts (const char *str)
  * settings.
  * ====================================================================== */
 
-void bedbug_init (void)
+int bedbug_init(void)
 {
        /* -------------------------------------------------- */
-       return;
+       return 0;
 }                              /* bedbug_init */
 
 
index b94f005..b8d11c1 100644 (file)
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -772,11 +772,9 @@ static int do_rename_gpt_parts(struct blk_desc *dev_desc, char *subcomm,
  out:
        del_gpt_info();
 #ifdef CONFIG_RANDOM_UUID
-       if (str_disk_guid)
-               free(str_disk_guid);
+       free(str_disk_guid);
 #endif
-       if (new_partitions)
-               free(new_partitions);
+       free(new_partitions);
        free(partitions_list);
        return ret;
 }
index 0bbeaa7..d9015cd 100644 (file)
@@ -518,15 +518,6 @@ static int initr_api(void)
 }
 #endif
 
-/* enable exceptions */
-#ifdef CONFIG_ARM
-static int initr_enable_interrupts(void)
-{
-       enable_interrupts();
-       return 0;
-}
-#endif
-
 #ifdef CONFIG_CMD_NET
 static int initr_ethaddr(void)
 {
@@ -646,15 +637,6 @@ int initr_mem(void)
 }
 #endif
 
-#ifdef CONFIG_CMD_BEDBUG
-static int initr_bedbug(void)
-{
-       bedbug_init();
-
-       return 0;
-}
-#endif
-
 static int run_main_loop(void)
 {
 #ifdef CONFIG_SANDBOX
@@ -813,9 +795,6 @@ static init_fnc_t init_sequence_r[] = {
        initr_kgdb,
 #endif
        interrupt_init,
-#ifdef CONFIG_ARM
-       initr_enable_interrupts,
-#endif
 #if defined(CONFIG_MICROBLAZE) || defined(CONFIG_M68K)
        timer_init,             /* initialize timer */
 #endif
@@ -860,7 +839,7 @@ static init_fnc_t init_sequence_r[] = {
 #endif
 #ifdef CONFIG_CMD_BEDBUG
        INIT_FUNC_WATCHDOG_RESET
-       initr_bedbug,
+       bedbug_init,
 #endif
 #if defined(CONFIG_PRAM)
        initr_mem,
index cf1e273..a62af07 100644 (file)
@@ -1849,8 +1849,7 @@ static int run_list_real(struct pipe *pi)
                                continue;
                        } else {
                                /* insert new value from list for variable */
-                               if (pi->progs->argv[0])
-                                       free(pi->progs->argv[0]);
+                               free(pi->progs->argv[0]);
                                pi->progs->argv[0] = *list++;
 #ifndef __U_BOOT__
                                pi->progs->glob_result.gl_pathv[0] =
index db5ab55..e8f07f1 100644 (file)
@@ -280,6 +280,7 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             Unused space (may be 0 bytes long)                .
            .                                                               .
            .                                                               |
+
 nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     `foot:' |             Size of chunk, in bytes                           |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -574,6 +575,10 @@ static void malloc_bin_reloc(void)
 static inline void malloc_bin_reloc(void) {}
 #endif
 
+#ifdef CONFIG_SYS_MALLOC_DEFAULT_TO_INIT
+static void malloc_init(void);
+#endif
+
 ulong mem_malloc_start = 0;
 ulong mem_malloc_end = 0;
 ulong mem_malloc_brk = 0;
@@ -604,6 +609,10 @@ void mem_malloc_init(ulong start, ulong size)
        mem_malloc_end = start + size;
        mem_malloc_brk = start;
 
+#ifdef CONFIG_SYS_MALLOC_DEFAULT_TO_INIT
+       malloc_init();
+#endif
+
        debug("using memory %#lx-%#lx for malloc()\n", mem_malloc_start,
              mem_malloc_end);
 #ifdef CONFIG_SYS_MALLOC_CLEAR_ON_INIT
@@ -708,7 +717,36 @@ static unsigned int max_n_mmaps = 0;
 static unsigned long max_mmapped_mem = 0;
 #endif
 
+#ifdef CONFIG_SYS_MALLOC_DEFAULT_TO_INIT
+static void malloc_init(void)
+{
+       int i, j;
+
+       debug("bins (av_ array) are at %p\n", (void *)av_);
+
+       av_[0] = NULL; av_[1] = NULL;
+       for (i = 2, j = 2; i < NAV * 2 + 2; i += 2, j++) {
+               av_[i] = bin_at(j - 2);
+               av_[i + 1] = bin_at(j - 2);
+
+               /* Just print the first few bins so that
+                * we can see there are alright.
+                */
+               if (i < 10)
+                       debug("av_[%d]=%lx av_[%d]=%lx\n",
+                             i, (ulong)av_[i],
+                             i + 1, (ulong)av_[i + 1]);
+       }
 
+       /* Init the static bookkeeping as well */
+       sbrk_base = (char *)(-1);
+       max_sbrked_mem = 0;
+       max_total_mem = 0;
+#ifdef DEBUG
+       memset((void *)&current_mallinfo, 0, sizeof(struct mallinfo));
+#endif
+}
+#endif
 
 /*
   Debugging support
@@ -1051,9 +1089,6 @@ static mchunkptr mremap_chunk(p, new_size) mchunkptr p; size_t new_size;
 
 #endif /* HAVE_MMAP */
 
-
-
-
 /*
   Extend the top-most chunk by obtaining memory from system.
   Main interface to sbrk (but see also malloc_trim).
index 3e73578..a3a0c61 100644 (file)
@@ -249,7 +249,7 @@ static int fit_config_check_sig(const void *fit, int noffset,
                                int required_keynode, int conf_noffset,
                                char **err_msgp)
 {
-       char * const exc_prop[] = {"data"};
+       char * const exc_prop[] = {"data", "data-size", "data-position"};
        const char *prop, *end, *name;
        struct image_sign_info info;
        const uint32_t *strings;
index 07ddade..fe28f37 100644 (file)
@@ -7,6 +7,7 @@ CONFIG_ENV_SIZE=0x1000
 CONFIG_ENV_OFFSET=0x100000
 CONFIG_TARGET_MT7623=y
 CONFIG_NR_DRAM_BANKS=1
+CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_BOOTDELAY=3
@@ -56,4 +57,4 @@ CONFIG_TIMER=y
 CONFIG_MTK_TIMER=y
 CONFIG_WDT_MTK=y
 CONFIG_LZMA=y
-# CONFIG_EFI_LOADER is not set
+CONFIG_EFI_LOADER=y
diff --git a/doc/develop/crash_dumps.rst b/doc/develop/crash_dumps.rst
new file mode 100644 (file)
index 0000000..1869637
--- /dev/null
@@ -0,0 +1,122 @@
+.. SPDX-License-Identifier: GPL-2.0+
+.. Copyright (c) 2020 Heinrich Schuchardt
+
+Analyzing crash dumps
+=====================
+
+When the CPU detects an instruction that it cannot execute it raises an
+interrupt. U-Boot than writes a crash dump. This chapter describes how such
+dump can be analyzed.
+
+Creating a crash dump voluntarily
+---------------------------------
+
+For describing the analysis of a crash dump we need an example. U-Boot comes
+with a command 'exception' that comes in handy here. The command is enabled
+by::
+
+    CONFIG_CMD_EXCEPTION=y
+
+The example output below was recorded when running qemu\_arm64\_defconfig on
+QEMU::
+
+    => exception undefined
+    "Synchronous Abort" handler, esr 0x02000000
+    elr: 00000000000101fc lr : 00000000000214ec (reloc)
+    elr: 000000007ff291fc lr : 000000007ff3a4ec
+    x0 : 000000007ffbd7f8 x1 : 0000000000000000
+    x2 : 0000000000000001 x3 : 000000007eedce18
+    x4 : 000000007ff291fc x5 : 000000007eedce50
+    x6 : 0000000000000064 x7 : 000000007eedce10
+    x8 : 0000000000000000 x9 : 0000000000000004
+    x10: 6db6db6db6db6db7 x11: 000000000000000d
+    x12: 0000000000000006 x13: 000000000001869f
+    x14: 000000007edd7dc0 x15: 0000000000000002
+    x16: 000000007ff291fc x17: 0000000000000000
+    x18: 000000007eed8dc0 x19: 0000000000000000
+    x20: 000000007ffbd7f8 x21: 0000000000000000
+    x22: 000000007eedce10 x23: 0000000000000002
+    x24: 000000007ffd4c80 x25: 0000000000000000
+    x26: 0000000000000000 x27: 0000000000000000
+    x28: 000000007eedce70 x29: 000000007edd7b40
+
+    Code: b00003c0 912ad000 940029d6 17ffff52 (e7f7defb)
+    Resetting CPU ...
+
+    resetting ...
+
+The first line provides us with the type of interrupt that occurred.
+(On ARMv8 a synchronous abort is an exception where the return address stored
+in the ESR register indicates the instruction that caused the exception.)
+
+The second line provides the contents of the elr and the lr register after
+subtracting the relocation offset. - U-Boot relocates itself after being
+loaded. - The relocation offset can also be displayed using the bdinfo command.
+
+After the contents of the registers we get a line indicating the machine
+code of the instructions preceding the crash and in parentheses the instruction
+leading to the dump.
+
+Analyzing the code location
+---------------------------
+
+We can convert the instructions in the line starting with 'Code:' into mnemonics
+using the objdump command. To make things easier scripts/decodecode is
+supplied::
+
+    $echo 'Code: b00003c0 912ad000 940029d6 17ffff52 (e7f7defb)' | \
+      CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 scripts/decodecode
+    Code: b00003c0 912ad000 940029d6 17ffff52 (e7f7defb)
+    All code
+    ========
+       0:   b00003c0     adrp   x0, 0x79000
+       4:   912ad000     add    x0, x0, #0xab4
+       8:   940029d6     bl     0xa760
+       c:   17ffff52     b      0xfffffffffffffd54
+      10:*  e7f7defb     .inst  0xe7f7defb ; undefined <-- trapping instruction
+
+    Code starting with the faulting instruction
+    ===========================================
+       0:   e7f7defb     .inst  0xe7f7defb ; undefined
+
+Now lets use the locations provided by the elr and lr registers after
+subtracting the relocation offset to find out where in the code the crash
+occurred and from where it was invoked.
+
+File u-boot.map contains the memory layout of the U-Boot binary. Here we find
+these lines::
+
+   .text.do_undefined
+                  0x00000000000101fc        0xc cmd/built-in.o
+   .text.exception_complete
+                  0x0000000000010208       0x90 cmd/built-in.o
+   ...
+   .text.cmd_process
+                  0x00000000000213b8      0x164 common/built-in.o
+                  0x00000000000213b8                cmd_process
+   .text.cmd_process_error
+                  0x000000000002151c       0x40 common/built-in.o
+                  0x000000000002151c                cmd_process_error
+
+So the error occurred at the start of function do\_undefined() and this
+function was invoked from somewhere inside function cmd\_process().
+
+If we want to dive deeper, we can disassemble the U-Boot binary::
+
+    $ aarch64-linux-gnu-objdump -S -D u-boot | less
+
+    00000000000101fc <do_undefined>:
+    {
+            /*
+             * 0xe7f...f.   is undefined in ARM mode
+             * 0xde..       is undefined in Thumb mode
+            */
+            asm volatile (".word 0xe7f7defb\n");
+       101fc:       e7f7defb        .inst   0xe7f7defb ; undefined
+            return CMD_RET_FAILURE;
+    }
+    10200:       52800020        mov     w0, #0x1        // #1
+    10204:       d65f03c0        ret
+
+This example is based on the ARMv8 architecture but the same procedures can be
+used on other architectures as well.
diff --git a/doc/develop/index.rst b/doc/develop/index.rst
new file mode 100644 (file)
index 0000000..072db63
--- /dev/null
@@ -0,0 +1,10 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Develop U-Boot
+==============
+
+
+.. toctree::
+   :maxdepth: 2
+
+   crash_dumps
index cd98be6..fd9f10f 100644 (file)
@@ -26,6 +26,17 @@ trying to get it to work optimally on a given system.
 
    build/index
 
+Developer-oriented documentation
+--------------------------------
+
+The following manuals are written for *developers* of the U-Boot - those who
+want to contribute to U-Boot.
+
+.. toctree::
+   :maxdepth: 2
+
+   develop/index
+
 Unified Extensible Firmware (UEFI)
 ----------------------------------
 
index f695350..b34ed63 100644 (file)
@@ -56,7 +56,7 @@ static int pcf2127_rtc_set(struct udevice *dev, const struct rtc_time *tm)
        buf[i++] = tm->tm_wday & 0x07;
 
        /* month, 1 - 12 */
-       buf[i++] = bin2bcd(tm->tm_mon + 1);
+       buf[i++] = bin2bcd(tm->tm_mon);
 
        /* year */
        buf[i++] = bin2bcd(tm->tm_year % 100);
@@ -83,7 +83,7 @@ static int pcf2127_rtc_get(struct udevice *dev, struct rtc_time *tm)
        tm->tm_min  = bcd2bin(buf[PCF2127_REG_MN] & 0x7F);
        tm->tm_hour = bcd2bin(buf[PCF2127_REG_HR] & 0x3F);
        tm->tm_mday = bcd2bin(buf[PCF2127_REG_DM] & 0x3F);
-       tm->tm_mon  = bcd2bin(buf[PCF2127_REG_MO] & 0x1F) - 1;
+       tm->tm_mon  = bcd2bin(buf[PCF2127_REG_MO] & 0x1F);
        tm->tm_year = bcd2bin(buf[PCF2127_REG_YR]) + 1900;
        if (tm->tm_year < 1970)
                tm->tm_year += 100;     /* assume we are in 1970...2069 */
index b5e76bd..e99135e 100644 (file)
@@ -71,6 +71,7 @@ static const struct timer_ops mtk_timer_ops = {
 
 static const struct udevice_id mtk_timer_ids[] = {
        { .compatible = "mediatek,timer" },
+       { .compatible = "mediatek,mt6577-timer" },
        { }
 };
 
index 669a323..b3c597e 100644 (file)
@@ -143,6 +143,7 @@ static const struct wdt_ops mtk_wdt_ops = {
 
 static const struct udevice_id mtk_wdt_ids[] = {
        { .compatible = "mediatek,wdt"},
+       { .compatible = "mediatek,mt6589-wdt"},
        {}
 };
 
index f8524e5..0ceb73d 100644 (file)
@@ -107,22 +107,18 @@ void ext4fs_free_journal(void)
        for (i = 0; i < MAX_JOURNAL_ENTRIES; i++) {
                if (dirty_block_ptr[i]->blknr == -1)
                        break;
-               if (dirty_block_ptr[i]->buf)
-                       free(dirty_block_ptr[i]->buf);
+               free(dirty_block_ptr[i]->buf);
        }
 
        for (i = 0; i < MAX_JOURNAL_ENTRIES; i++) {
                if (journal_ptr[i]->blknr == -1)
                        break;
-               if (journal_ptr[i]->buf)
-                       free(journal_ptr[i]->buf);
+               free(journal_ptr[i]->buf);
        }
 
        for (i = 0; i < MAX_JOURNAL_ENTRIES; i++) {
-               if (journal_ptr[i])
-                       free(journal_ptr[i]);
-               if (dirty_block_ptr[i])
-                       free(dirty_block_ptr[i]);
+               free(journal_ptr[i]);
+               free(dirty_block_ptr[i]);
        }
        gindex = 0;
        gd_index = 0;
@@ -272,8 +268,7 @@ void ext4fs_free_revoke_blks(void)
        struct revoke_blk_list *next_node = NULL;
 
        while (tmp_node != NULL) {
-               if (tmp_node->content)
-                       free(tmp_node->content);
+               free(tmp_node->content);
                tmp_node = tmp_node->next;
        }
 
index b7b447b..3754c7f 100644 (file)
@@ -3,7 +3,7 @@
 
 /* Supporting routines */
 int bedbug_puts (const char *);
-void bedbug_init (void);
+int bedbug_init(void);
 void bedbug860_init (void);
 void do_bedbug_breakpoint (struct pt_regs *);
 void bedbug_main_loop (unsigned long, struct pt_regs *);
index f1ea729..001e9d3 100644 (file)
@@ -16,7 +16,6 @@
 
 /* Miscellaneous */
 #define CONFIG_SYS_PBSIZE      256
-#define CONFIG_SYS_ARM_CACHE_WRITETHROUGH
 #define CONFIG_CMDLINE_TAG
 
 /* Internal RAM Size (RZ/A1=3M, RZ/A1M=5M, RZ/A1H=10M) */
index faab091..fe436cc 100644 (file)
 #define CONFIG_SYS_SDRAM_BASE          0x80000000
 
 /* This is needed for kernel booting */
-#define FDT_HIGH                       "fdt_high=0xac000000\0"
+#define FDT_HIGH                       "0xac000000"
 
-/* Extra environment variables */
-#define CONFIG_EXTRA_ENV_SETTINGS      \
-       FDT_HIGH
+#define ENV_MEM_LAYOUT_SETTINGS                                \
+       "fdt_high=" FDT_HIGH "\0"                       \
+       "kernel_addr_r=0x84000000\0"                    \
+       "fdt_addr_r=" FDT_HIGH "\0"                     \
+       "fdtfile=mt7623n-bananapi-bpi-r2.dtb" "\0"
 
 /* Ethernet */
 #define CONFIG_IPADDR                  192.168.1.1
 
 #define CONFIG_SYS_MMC_ENV_DEV         0
 
+#ifdef CONFIG_DISTRO_DEFAULTS
+
+#define BOOT_TARGET_DEVICES(func)      \
+               func(MMC, mmc, 1)
+
+#include <config_distro_bootcmd.h>
+
+/* Extra environment variables */
+#define CONFIG_EXTRA_ENV_SETTINGS      \
+       ENV_MEM_LAYOUT_SETTINGS         \
+       BOOTENV
+
+#endif /* ifdef CONFIG_DISTRO_DEFAULTS*/
+
 #endif
index e25800a..2632d48 100644 (file)
@@ -8,8 +8,6 @@
 #ifndef        __CONFIG_PXA_COMMON_H__
 #define        __CONFIG_PXA_COMMON_H__
 
-#define        CONFIG_SYS_ARM_CACHE_WRITETHROUGH
-
 /*
  * KGDB
  */
index 1138c70..8fc7e48 100644 (file)
@@ -242,6 +242,7 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
                                goto abort;
                        case 'u':
                        case 'd':
+                       case 'i':
                                div = 1000000000;
                                if (islong) {
                                        num = va_arg(va, unsigned long);
@@ -251,7 +252,7 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
                                        num = va_arg(va, unsigned int);
                                }
 
-                               if (ch == 'd') {
+                               if (ch != 'u') {
                                        if (islong && (long)num < 0) {
                                                num = -(long)num;
                                                out(info, '-');
index 12a6698..7a5da9d 100644 (file)
@@ -1770,7 +1770,6 @@ CONFIG_SYS_AMASK4
 CONFIG_SYS_AMASK5
 CONFIG_SYS_AMASK6
 CONFIG_SYS_AMASK7
-CONFIG_SYS_ARM_CACHE_WRITETHROUGH
 CONFIG_SYS_AT91_CPU_NAME
 CONFIG_SYS_AT91_MAIN_CLOCK
 CONFIG_SYS_AT91_PLLA
index e67f2b3..6b998cf 100644 (file)
@@ -30,11 +30,16 @@ import u_boot_utils as util
 import vboot_forge
 
 TESTDATA = [
-    ['sha1', '', False],
-    ['sha1', '-pss', False],
-    ['sha256', '', False],
-    ['sha256', '-pss', False],
-    ['sha256', '-pss', True],
+    ['sha1', '', None, False],
+    ['sha1', '', '-E -p 0x10000', False],
+    ['sha1', '-pss', None, False],
+    ['sha1', '-pss', '-E -p 0x10000', False],
+    ['sha256', '', None, False],
+    ['sha256', '', '-E -p 0x10000', False],
+    ['sha256', '-pss', None, False],
+    ['sha256', '-pss', '-E -p 0x10000', False],
+    ['sha256', '-pss', None, True],
+    ['sha256', '-pss', '-E -p 0x10000', True],
 ]
 
 @pytest.mark.boardspec('sandbox')
@@ -43,8 +48,8 @@ TESTDATA = [
 @pytest.mark.requiredtool('fdtget')
 @pytest.mark.requiredtool('fdtput')
 @pytest.mark.requiredtool('openssl')
-@pytest.mark.parametrize("sha_algo,padding,required", TESTDATA)
-def test_vboot(u_boot_console, sha_algo, padding, required):
+@pytest.mark.parametrize("sha_algo,padding,sign_options,required", TESTDATA)
+def test_vboot(u_boot_console, sha_algo, padding, sign_options, required):
     """Test verified boot signing with mkimage and verification with 'bootm'.
 
     This works using sandbox only as it needs to update the device tree used
@@ -104,7 +109,7 @@ def test_vboot(u_boot_console, sha_algo, padding, required):
         util.run_and_log(cons, [mkimage, '-D', dtc_args, '-f',
                                 '%s%s' % (datadir, its), fit])
 
-    def sign_fit(sha_algo):
+    def sign_fit(sha_algo, options):
         """Sign the FIT
 
         Signs the FIT and writes the signature into it. It also writes the
@@ -113,10 +118,13 @@ def test_vboot(u_boot_console, sha_algo, padding, required):
         Args:
             sha_algo: Either 'sha1' or 'sha256', to select the algorithm to
                     use.
+            options: Options to provide to mkimage.
         """
+        args = [mkimage, '-F', '-k', tmpdir, '-K', dtb, '-r', fit]
+        if options:
+            args += options.split(' ')
         cons.log.action('%s: Sign images' % sha_algo)
-        util.run_and_log(cons, [mkimage, '-F', '-k', tmpdir, '-K', dtb,
-                                '-r', fit])
+        util.run_and_log(cons, args)
 
     def replace_fit_totalsize(size):
         """Replace FIT header's totalsize with something greater.
@@ -154,7 +162,7 @@ def test_vboot(u_boot_console, sha_algo, padding, required):
         util.run_and_log(cons, 'openssl req -batch -new -x509 -key %s%s.key '
                          '-out %s%s.crt' % (tmpdir, name, tmpdir, name))
 
-    def test_with_algo(sha_algo, padding):
+    def test_with_algo(sha_algo, padding, sign_options):
         """Test verified boot with the given hash algorithm.
 
         This is the main part of the test code. The same procedure is followed
@@ -163,6 +171,9 @@ def test_vboot(u_boot_console, sha_algo, padding, required):
         Args:
             sha_algo: Either 'sha1' or 'sha256', to select the algorithm to
                     use.
+            padding: Either '' or '-pss', to select the padding to use for the
+                    rsa signature algorithm.
+            sign_options: Options to mkimage when signing a fit image.
         """
         # Compile our device tree files for kernel and U-Boot. These are
         # regenerated here since mkimage will modify them (by adding a
@@ -176,7 +187,7 @@ def test_vboot(u_boot_console, sha_algo, padding, required):
         run_bootm(sha_algo, 'unsigned images', 'dev-', True)
 
         # Sign images with our dev keys
-        sign_fit(sha_algo)
+        sign_fit(sha_algo, sign_options)
         run_bootm(sha_algo, 'signed images', 'dev+', True)
 
         # Create a fresh .dtb without the public keys
@@ -187,7 +198,7 @@ def test_vboot(u_boot_console, sha_algo, padding, required):
         run_bootm(sha_algo, 'unsigned config', '%s+ OK' % sha_algo, True)
 
         # Sign images with our dev keys
-        sign_fit(sha_algo)
+        sign_fit(sha_algo, sign_options)
         run_bootm(sha_algo, 'signed config', 'dev+', True)
 
         cons.log.action('%s: Check signed config on the host' % sha_algo)
@@ -209,7 +220,7 @@ def test_vboot(u_boot_console, sha_algo, padding, required):
 
         # Create a new properly signed fit and replace header bytes
         make_fit('sign-configs-%s%s.its' % (sha_algo, padding))
-        sign_fit(sha_algo)
+        sign_fit(sha_algo, sign_options)
         bcfg = u_boot_console.config.buildconfig
         max_size = int(bcfg.get('config_fit_signature_max_size', 0x10000000), 0)
         existing_size = replace_fit_totalsize(max_size + 1)
@@ -240,7 +251,7 @@ def test_vboot(u_boot_console, sha_algo, padding, required):
             cons, [fit_check_sign, '-f', fit, '-k', dtb],
             1, 'Failed to verify required signature')
 
-    def test_required_key(sha_algo, padding):
+    def test_required_key(sha_algo, padding, sign_options):
         """Test verified boot with the given hash algorithm.
 
         This function tests if U-Boot rejects an image when a required key isn't
@@ -248,6 +259,9 @@ def test_vboot(u_boot_console, sha_algo, padding, required):
 
         Args:
             sha_algo: Either 'sha1' or 'sha256', to select the algorithm to use
+            padding: Either '' or '-pss', to select the padding to use for the
+                    rsa signature algorithm.
+            sign_options: Options to mkimage when signing a fit image.
         """
         # Compile our device tree files for kernel and U-Boot. These are
         # regenerated here since mkimage will modify them (by adding a
@@ -260,12 +274,12 @@ def test_vboot(u_boot_console, sha_algo, padding, required):
         # Build the FIT with prod key (keys required) and sign it. This puts the
         # signature into sandbox-u-boot.dtb, marked 'required'
         make_fit('sign-configs-%s%s-prod.its' % (sha_algo, padding))
-        sign_fit(sha_algo)
+        sign_fit(sha_algo, sign_options)
 
         # Build the FIT with dev key (keys NOT required). This adds the
         # signature into sandbox-u-boot.dtb, NOT marked 'required'.
         make_fit('sign-configs-%s%s.its' % (sha_algo, padding))
-        sign_fit(sha_algo)
+        sign_fit(sha_algo, sign_options)
 
         # So now sandbox-u-boot.dtb two signatures, for the prod and dev keys.
         # Only the prod key is set as 'required'. But FIT we just built has
@@ -297,9 +311,9 @@ def test_vboot(u_boot_console, sha_algo, padding, required):
         old_dtb = cons.config.dtb
         cons.config.dtb = dtb
         if required:
-            test_required_key(sha_algo, padding)
+            test_required_key(sha_algo, padding, sign_options)
         else:
-            test_with_algo(sha_algo, padding)
+            test_with_algo(sha_algo, padding, sign_options)
     finally:
         # Go back to the original U-Boot with the correct dtb.
         cons.config.dtb = old_dtb
index 4aeabbc..88ff093 100644 (file)
@@ -17,6 +17,7 @@
 #include "fit_common.h"
 #include "mkimage.h"
 #include <image.h>
+#include <string.h>
 #include <stdarg.h>
 #include <version.h>
 #include <u-boot/crc.h>
@@ -744,6 +745,9 @@ static int fit_handle_file(struct image_tool_params *params)
                snprintf(cmd, sizeof(cmd), "cp \"%s\" \"%s\"",
                         params->imagefile, tmpfile);
        }
+       if (strlen(cmd) >= MKIMAGE_MAX_DTC_CMDLINE_LEN - 1) {
+               fprintf(stderr, "WARNING: command-line for FIT creation might be truncated and will probably fail.\n");
+       }
 
        if (*cmd && system(cmd) == -1) {
                fprintf (stderr, "%s: system(%s) failed: %s\n",
index 0254af5..5b096a5 100644 (file)
@@ -42,6 +42,6 @@ static inline ulong map_to_sysmem(void *ptr)
 #define MKIMAGE_TMPFILE_SUFFIX         ".tmp"
 #define MKIMAGE_MAX_TMPFILE_LEN                256
 #define MKIMAGE_DEFAULT_DTC_OPTIONS    "-I dts -O dtb -p 500"
-#define MKIMAGE_MAX_DTC_CMDLINE_LEN    512
+#define MKIMAGE_MAX_DTC_CMDLINE_LEN    2 * MKIMAGE_MAX_TMPFILE_LEN + 35
 
 #endif /* _MKIIMAGE_H_ */