[U-Boot] 9g45 don't work

2013-03-18 Thread xiexiaochao




 
  hello,   my board base on  9m10g45, but mine don't work.   version   2013 
lastest .  Would you please tell me why??   I will appreciate your reply.   
 
  message below:

-- AT91bootstrap Project 3.0 --
-- AT91SAM9G45-EK
-- Compiled: Mar  5 2013 18:10:43 --
-I- Setting: MCK = 133MHz
-I- Init DDRAM
-I- Init NAND Flash
-I- Nandflash ID is 0x9500F1EC
-I- Nandflash driver initialized
-I- Size of the whole device in bytes : 0x800
-I- Size in bytes of one single block of a device : 0x2
-I- Number of blocks in the entire device : 0x400
-I- Size of the data area of a page in bytes : 0x800
-I- Number of pages in the entire device : 0x40
-I- Bus width : 8
-I- Copy  (196608 bytes) from NAND 0x0002 to 0x73f0
-I- Jump to 0x73f0

CPU   die  there !!
 
 Best regards
Terry.Xie


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] arm: at91: at91sam9n12ek: add nandflash/spiflash/mmc/lcd support

2013-03-18 Thread Bo Shen

Hi Josh,
  Miss maintainer part.

On 03/15/2013 06:17 PM, Josh Wu wrote:

This patch adds at91sam9n12ek support, it enables:
- dbgu
- nand with pmecc
- spi flash
- mmc
- lcd

TODO:
- usb
- ethernet

Signed-off-by: Josh Wujosh...@atmel.com
---
  arch/arm/cpu/arm926ejs/at91/Makefile   |1 +
  arch/arm/cpu/arm926ejs/at91/at91sam9n12_devices.c  |  137 ++
  arch/arm/cpu/arm926ejs/at91/clock.c|4 +-
  arch/arm/include/asm/arch-at91/at91sam9_matrix.h   |2 +
  arch/arm/include/asm/arch-at91/at91sam9n12.h   |  126 +
  arch/arm/include/asm/arch-at91/at91sam9x5_matrix.h |   17 +-
  arch/arm/include/asm/arch-at91/hardware.h  |2 +
  board/atmel/at91sam9n12ek/Makefile |   52 
  board/atmel/at91sam9n12ek/at91sam9n12ek.c  |  270 
  boards.cfg |3 +
  drivers/spi/atmel_spi.c|3 +-
  include/configs/at91sam9n12ek.h|  232 +
  12 files changed, 843 insertions(+), 6 deletions(-)
  create mode 100644 arch/arm/cpu/arm926ejs/at91/at91sam9n12_devices.c
  create mode 100644 arch/arm/include/asm/arch-at91/at91sam9n12.h
  create mode 100644 board/atmel/at91sam9n12ek/Makefile
  create mode 100644 board/atmel/at91sam9n12ek/at91sam9n12ek.c
  create mode 100644 include/configs/at91sam9n12ek.h

diff --git a/arch/arm/cpu/arm926ejs/at91/Makefile 
b/arch/arm/cpu/arm926ejs/at91/Makefile
index 346e58f..c4964a1 100644
--- a/arch/arm/cpu/arm926ejs/at91/Makefile
+++ b/arch/arm/cpu/arm926ejs/at91/Makefile
@@ -36,6 +36,7 @@ COBJS-$(CONFIG_AT91SAM9RL)+= at91sam9rl_devices.o
  COBJS-$(CONFIG_AT91SAM9M10G45)+= at91sam9m10g45_devices.o
  COBJS-$(CONFIG_AT91SAM9G45)   += at91sam9m10g45_devices.o
  COBJS-$(CONFIG_AT91SAM9X5)+= at91sam9x5_devices.o
+COBJS-$(CONFIG_AT91SAM9N12)+= at91sam9n12_devices.o


We should keep alpha order.


  COBJS-$(CONFIG_AT91_EFLASH)   += eflash.o
  COBJS-$(CONFIG_AT91_LED)  += led.o
  COBJS-y += clock.o
diff --git a/arch/arm/cpu/arm926ejs/at91/at91sam9n12_devices.c 
b/arch/arm/cpu/arm926ejs/at91/at91sam9n12_devices.c
new file mode 100644
index 000..5094262
--- /dev/null
+++ b/arch/arm/cpu/arm926ejs/at91/at91sam9n12_devices.c
@@ -0,0 +1,137 @@
+/*
+ * (C) Copyright 2013 Atmel Corporation
+ * Josh Wujosh...@atmel.com
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#includecommon.h
+#includeasm/io.h
+#includeasm/arch/at91_common.h
+#includeasm/arch/at91_pmc.h
+#includeasm/arch/at91_pio.h
+
+unsigned int has_lcdc()
+{
+   return 1;
+}
+
+void at91_serial0_hw_init(void)
+{
+   at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
+
+   at91_set_a_periph(AT91_PIO_PORTA, 0, 1);/* TXD0 */
+   at91_set_a_periph(AT91_PIO_PORTA, 1, 0);/* RXD0 */
+   writel(1  ATMEL_ID_USART0,pmc-pcer);
+}
+
+void at91_serial1_hw_init(void)
+{
+   at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
+
+   at91_set_a_periph(AT91_PIO_PORTA, 5, 1);/* TXD1 */
+   at91_set_a_periph(AT91_PIO_PORTA, 6, 0);/* RXD1 */
+   writel(1  ATMEL_ID_USART1,pmc-pcer);
+}
+
+void at91_serial2_hw_init(void)
+{
+   at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
+
+   at91_set_a_periph(AT91_PIO_PORTA, 7, 1);/* TXD2 */
+   at91_set_a_periph(AT91_PIO_PORTA, 8, 0);/* RXD2 */
+   writel(1  ATMEL_ID_USART2,pmc-pcer);
+}
+
+void at91_serial3_hw_init(void)
+{
+   at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
+
+   at91_set_b_periph(AT91_PIO_PORTC, 22, 1);   /* TXD3 */
+   at91_set_b_periph(AT91_PIO_PORTC, 23, 0);   /* RXD3 */
+   writel(1  ATMEL_ID_USART3,pmc-pcer);
+}
+
+void at91_seriald_hw_init(void)
+{
+   at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
+
+   at91_set_a_periph(AT91_PIO_PORTA, 9, 1);/* DRXD */
+   at91_set_a_periph(AT91_PIO_PORTA, 10, 0);   /* DTXD */
+   writel(1  ATMEL_ID_SYS,pmc-pcer);
+}
+
+#ifdef CONFIG_ATMEL_SPI
+void at91_spi0_hw_init(unsigned long cs_mask)
+{
+   at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
+
+ 

Re: [U-Boot] [PATCH] arm: at91: at91sam9n12ek: add nandflash/spiflash/mmc/lcd support

2013-03-18 Thread Bo Shen

Hi Josh,
  Miss maintainer part.

On 03/15/2013 06:17 PM, Josh Wu wrote:

This patch adds at91sam9n12ek support, it enables:
- dbgu
- nand with pmecc
- spi flash
- mmc
- lcd

TODO:
- usb
- ethernet

Signed-off-by: Josh Wujosh...@atmel.com
---
  arch/arm/cpu/arm926ejs/at91/Makefile   |1 +
  arch/arm/cpu/arm926ejs/at91/at91sam9n12_devices.c  |  137 ++
  arch/arm/cpu/arm926ejs/at91/clock.c|4 +-
  arch/arm/include/asm/arch-at91/at91sam9_matrix.h   |2 +
  arch/arm/include/asm/arch-at91/at91sam9n12.h   |  126 +
  arch/arm/include/asm/arch-at91/at91sam9x5_matrix.h |   17 +-
  arch/arm/include/asm/arch-at91/hardware.h  |2 +
  board/atmel/at91sam9n12ek/Makefile |   52 
  board/atmel/at91sam9n12ek/at91sam9n12ek.c  |  270 
  boards.cfg |3 +
  drivers/spi/atmel_spi.c|3 +-
  include/configs/at91sam9n12ek.h|  232 +
  12 files changed, 843 insertions(+), 6 deletions(-)
  create mode 100644 arch/arm/cpu/arm926ejs/at91/at91sam9n12_devices.c
  create mode 100644 arch/arm/include/asm/arch-at91/at91sam9n12.h
  create mode 100644 board/atmel/at91sam9n12ek/Makefile
  create mode 100644 board/atmel/at91sam9n12ek/at91sam9n12ek.c
  create mode 100644 include/configs/at91sam9n12ek.h

diff --git a/arch/arm/cpu/arm926ejs/at91/Makefile 
b/arch/arm/cpu/arm926ejs/at91/Makefile
index 346e58f..c4964a1 100644
--- a/arch/arm/cpu/arm926ejs/at91/Makefile
+++ b/arch/arm/cpu/arm926ejs/at91/Makefile
@@ -36,6 +36,7 @@ COBJS-$(CONFIG_AT91SAM9RL)+= at91sam9rl_devices.o
  COBJS-$(CONFIG_AT91SAM9M10G45)+= at91sam9m10g45_devices.o
  COBJS-$(CONFIG_AT91SAM9G45)   += at91sam9m10g45_devices.o
  COBJS-$(CONFIG_AT91SAM9X5)+= at91sam9x5_devices.o
+COBJS-$(CONFIG_AT91SAM9N12)+= at91sam9n12_devices.o


We should keep alpha order.


  COBJS-$(CONFIG_AT91_EFLASH)   += eflash.o
  COBJS-$(CONFIG_AT91_LED)  += led.o
  COBJS-y += clock.o
diff --git a/arch/arm/cpu/arm926ejs/at91/at91sam9n12_devices.c 
b/arch/arm/cpu/arm926ejs/at91/at91sam9n12_devices.c
new file mode 100644
index 000..5094262
--- /dev/null
+++ b/arch/arm/cpu/arm926ejs/at91/at91sam9n12_devices.c
@@ -0,0 +1,137 @@
+/*
+ * (C) Copyright 2013 Atmel Corporation
+ * Josh Wujosh...@atmel.com
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#includecommon.h
+#includeasm/io.h
+#includeasm/arch/at91_common.h
+#includeasm/arch/at91_pmc.h
+#includeasm/arch/at91_pio.h
+
+unsigned int has_lcdc()
+{
+   return 1;
+}
+
+void at91_serial0_hw_init(void)
+{
+   at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
+
+   at91_set_a_periph(AT91_PIO_PORTA, 0, 1);/* TXD0 */
+   at91_set_a_periph(AT91_PIO_PORTA, 1, 0);/* RXD0 */
+   writel(1  ATMEL_ID_USART0,pmc-pcer);
+}
+
+void at91_serial1_hw_init(void)
+{
+   at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
+
+   at91_set_a_periph(AT91_PIO_PORTA, 5, 1);/* TXD1 */
+   at91_set_a_periph(AT91_PIO_PORTA, 6, 0);/* RXD1 */
+   writel(1  ATMEL_ID_USART1,pmc-pcer);
+}
+
+void at91_serial2_hw_init(void)
+{
+   at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
+
+   at91_set_a_periph(AT91_PIO_PORTA, 7, 1);/* TXD2 */
+   at91_set_a_periph(AT91_PIO_PORTA, 8, 0);/* RXD2 */
+   writel(1  ATMEL_ID_USART2,pmc-pcer);
+}
+
+void at91_serial3_hw_init(void)
+{
+   at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
+
+   at91_set_b_periph(AT91_PIO_PORTC, 22, 1);   /* TXD3 */
+   at91_set_b_periph(AT91_PIO_PORTC, 23, 0);   /* RXD3 */
+   writel(1  ATMEL_ID_USART3,pmc-pcer);
+}
+
+void at91_seriald_hw_init(void)
+{
+   at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
+
+   at91_set_a_periph(AT91_PIO_PORTA, 9, 1);/* DRXD */
+   at91_set_a_periph(AT91_PIO_PORTA, 10, 0);   /* DTXD */
+   writel(1  ATMEL_ID_SYS,pmc-pcer);
+}
+
+#ifdef CONFIG_ATMEL_SPI
+void at91_spi0_hw_init(unsigned long cs_mask)
+{
+   at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
+
+ 

Re: [U-Boot] [PATCH] arm: at91: at91sam9n12ek: add nandflash/spiflash/mmc/lcd support

2013-03-18 Thread Wolfgang Denk
Dear Josh Wu,

In message 1363342624-2939-1-git-send-email-josh...@atmel.com you wrote:
 This patch adds at91sam9n12ek support, it enables:
 - dbgu
 - nand with pmecc
 - spi flash
 - mmc
 - lcd

It appears you are adding support for a new board - in this case the
Subject: is misleading, plrase fix.

The missing entry in MAINTAINERS has already been pointed out. Please
also make sure to run your patch through checkpatch - it complains for
example WARNING: line over 80 characters.  Please fix these, too.

Please also make sure to keep all lists sorted. Bo shen already
mentioned this for the Makefile, but this also applies to lists as
here:

 #elif defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) \
-   || defined(CONFIG_AT91SAM9X5)
+   || defined(CONFIG_AT91SAM9X5) || 
defined(CONFIG_AT91SAM9N12)



 +++ b/arch/arm/include/asm/arch-at91/at91sam9n12.h
 @@ -0,0 +1,126 @@
...
 +/*
 + * Peripheral identifiers/interrupts.
 + */
 +#define ATMEL_ID_FIQ 0   /* Advanced Interrupt Controller (FIQ) */
 +#define ATMEL_ID_SYS 1   /* System Controller Interrupt */
 +#define ATMEL_ID_PIOAB   2   /* Parallel I/O Controller A and B */
 +#define ATMEL_ID_PIOCD   3   /* Parallel I/O Controller C and D */
 +#define ATMEL_ID_FUSE4   /* FUSE Controller */
 +#define ATMEL_ID_USART0  5   /* USART 0 */
 +#define ATMEL_ID_USART1  6   /* USART 1 */
 +#define ATMEL_ID_USART2  7   /* USART 2 */
 +#define ATMEL_ID_USART3  8   /* USART 3 */
 +#define ATMEL_ID_TWI09   /* Two-Wire Interface 0 */
 +#define ATMEL_ID_TWI110  /* Two-Wire Interface 1 */
 +#define ATMEL_ID_HSMCI   12  /* High Speed Multimedia Card Interface 
 */
 +#define ATMEL_ID_SPI013  /* Serial Peripheral Interface 0 */
 +#define ATMEL_ID_SPI114  /* Serial Peripheral Interface 1 */
 +#define ATMEL_ID_UART0   15  /* UART 0 */
 +#define ATMEL_ID_UART1   16  /* UART 1 */
 +#define ATMEL_ID_TC0117  /* Timer Counter 0, 1, 2, 3, 4 and 5 */
 +#define ATMEL_ID_PWM 18  /* Pulse Width Modulation Controller */
 +#define ATMEL_ID_ADC 19  /* ADC Controller */
 +#define ATMEL_ID_DMAC20  /* DMA Controller */
 +#define ATMEL_ID_UHP 22  /* USB Host */
 +#define ATMEL_ID_UDP 23  /* USB Device */
 +#define ATMEL_ID_LCDC25  /* LCD Controller */
 +#define ATMEL_ID_SSC 28  /* Synchronous Serial Controller */
 +#define ATMEL_ID_TRNG30  /* True Random Number Generator */
 +#define ATMEL_ID_IRQ 31  /* Advanced Interrupt Controller */

We already have the very same data in
arch/arm/include/asm/arch-at91/at91sam9x5.h.

 +/*
 + * User Peripherals physical base addresses.
 + */
 +#define ATMEL_BASE_SPI0  0xf000
 +#define ATMEL_BASE_SPI1  0xf0004000
 +#define ATMEL_BASE_HSMCI 0xf0008000
 +#define ATMEL_BASE_SSC   0xf001
 +#define ATMEL_BASE_TC012 0xf8008000
 +#define ATMEL_BASE_TC345 0xf800c000
 +#define ATMEL_BASE_TWI0  0xf801
 +#define ATMEL_BASE_TWI1  0xf8014000
 +#define ATMEL_BASE_USART00xf801c000
 +#define ATMEL_BASE_USART10xf802
 +#define ATMEL_BASE_USART20xf8024000
 +#define ATMEL_BASE_USART30xf8028000
 +#define ATMEL_BASE_PWM   0xf8034000
 +#define ATMEL_BASE_LCDC  0xf8038000
 +#define ATMEL_BASE_UDP   0xf803c000
 +#define ATMEL_BASE_UART0 0xf804
 +#define ATMEL_BASE_UART1 0xf8044000
 +#define ATMEL_BASE_TRNG  0xf8048000
 +#define ATMEL_BASE_ADC   0xf804c000

Same here.


 +/*
 + * System Peripherals physical base addresses.
 + */
 +#define ATMEL_BASE_FUSE  0xdc00
 +#define ATMEL_BASE_MATRIX0xde00
 +#define ATMEL_BASE_PMECC 0xe000
 +#define ATMEL_BASE_PMERRLOC  0xe600
 +#define ATMEL_BASE_DDRSDRC   0xe800
 +#define ATMEL_BASE_SMC   0xea00
 +#define ATMEL_BASE_DMAC  0xec00
 +#define ATMEL_BASE_AIC   0xf000
 +#define ATMEL_BASE_DBGU  0xf200
 +#define ATMEL_BASE_PIOA  0xf400
 +#define ATMEL_BASE_PIOB  0xf600
 +#define ATMEL_BASE_PIOC  0xf800
 +#define ATMEL_BASE_PIOD  0xfa00
 +#define ATMEL_BASE_PMC   0xfc00
 +#define ATMEL_BASE_RSTC  0xfe00
 +#define ATMEL_BASE_SHDC  0xfe10
 +#define ATMEL_BASE_PIT   0xfe30
 +#define ATMEL_BASE_WDT   0xfe40
 +#define ATMEL_BASE_SCKCR 0xfe50
 +#define ATMEL_BASE_BSCR  0xfe54
 +#define ATMEL_BASE_GPBR  0xfe60
 +#define ATMEL_BASE_RTC   0xfeb0

And here (except for the newly added ATMEL_BASE_FUSE).

Oh, these tables are repeated in
arch/arm/include/asm/arch-at91/at91sam9x5.h,
arch/arm/include/asm/arch-at91/at91sam9rl.h and

[U-Boot] [PATCH] bootm: Add support for Plan 9

2013-03-18 Thread Steven Stallion
From 902b728b8bcacecf9e2ea7854cc1e3777c2fd4e3 Mon Sep 17 00:00:00 2001

Apologies for the second patch; I did not realize at the time that
modifications were needed for bootm to function correctly.

---
 common/cmd_bootm.c| 39 +++
 include/config_defaults.h |  1 +
 2 files changed, 40 insertions(+)

diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 5d2ce00..7438469 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -128,6 +128,9 @@ static boot_os_fn do_bootm_rtems;
 #if defined(CONFIG_BOOTM_OSE)
 static boot_os_fn do_bootm_ose;
 #endif
+#if defined(CONFIG_BOOTM_PLAN9)
+static boot_os_fn do_bootm_plan9;
+#endif
 #if defined(CONFIG_CMD_ELF)
 static boot_os_fn do_bootm_vxworks;
 static boot_os_fn do_bootm_qnxelf;
@@ -154,6 +157,9 @@ static boot_os_fn *boot_os[] = {
 #if defined(CONFIG_BOOTM_OSE)
  [IH_OS_OSE] = do_bootm_ose,
 #endif
+#if defined(CONFIG_BOOTM_PLAN9)
+ [IH_OS_PLAN9] = do_bootm_plan9,
+#endif
 #if defined(CONFIG_CMD_ELF)
  [IH_OS_VXWORKS] = do_bootm_vxworks,
  [IH_OS_QNX] = do_bootm_qnxelf,
@@ -1628,6 +1634,39 @@ static int do_bootm_ose(int flag, int argc, char *
const argv[],
 }
 #endif /* CONFIG_BOOTM_OSE */

+#if defined(CONFIG_BOOTM_PLAN9)
+static int do_bootm_plan9(int flag, int argc, char * const argv[],
+   bootm_headers_t *images)
+{
+ void (*entry_point)(void);
+
+ if ((flag != 0)  (flag != BOOTM_STATE_OS_GO))
+ return 1;
+
+#if defined(CONFIG_FIT)
+ if (!images-legacy_hdr_valid) {
+ fit_unsupported_reset(Plan 9);
+ return 1;
+ }
+#endif
+
+ entry_point = (void (*)(void))images-ep;
+
+ printf(## Transferring control to Plan 9 (at address %08lx) ...\n,
+ (ulong)entry_point);
+
+ bootstage_mark(BOOTSTAGE_ID_RUN_OS);
+
+ /*
+ * Plan 9 Parameters:
+ *   None
+ */
+ (*entry_point)();
+
+ return 1;
+}
+#endif /* CONFIG_BOOTM_PLAN9 */
+
 #if defined(CONFIG_CMD_ELF)
 static int do_bootm_vxworks(int flag, int argc, char * const argv[],
  bootm_headers_t *images)
diff --git a/include/config_defaults.h b/include/config_defaults.h
index d023c63..567b46c 100644
--- a/include/config_defaults.h
+++ b/include/config_defaults.h
@@ -12,6 +12,7 @@
 /* Support bootm-ing different OSes */
 #define CONFIG_BOOTM_LINUX 1
 #define CONFIG_BOOTM_NETBSD 1
+#define CONFIG_BOOTM_PLAN9 1
 #define CONFIG_BOOTM_RTEMS 1

 #define CONFIG_GZIP 1
-- 
1.8.2
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] bootm: Add support for Plan 9

2013-03-18 Thread Wolfgang Denk
Dear Steven,

In message cagghmkhs+j0rb8nazhtqsrecxwtnvre32kcnrhy5zc2dhso...@mail.gmail.com 
you wrote:

 From 902b728b8bcacecf9e2ea7854cc1e3777c2fd4e3 Mon Sep 17 00:00:00 2001
 
 Apologies for the second patch; I did not realize at the time that
 modifications were needed for bootm to function correctly.
 
 ---

I guess the text above is not supposed to become part of the commit
message - as you posted it, it would.  Please move such comments below
the --- separator line.

Also, your posting is missing the (mandatory) Signed-off-by: line.

And for repostings / updated versions of patches we expect a history
of changes.

I recommend you re-read the rules for patch submissions, especially
here [1] and here [2].


 +#endif
  #if defined(CONFIG_CMD_ELF)
   [IH_OS_VXWORKS] = do_bootm_vxworks,
   [IH_OS_QNX] = do_bootm_qnxelf,

And finally, your patch is white-space corerupted.  Please fix your
mailer before resubmitting.  gmail is NOT a good client to use here.
Why don't you send your patch using git send-email as recommended?

[1] http://www.denx.de/wiki/view/U-Boot/Patches#General_Patch_Submission_Rules
[2] http://www.denx.de/wiki/view/U-Boot/Patches#Sending_updated_patch_versions

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk  Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
Panic, n.: The second time you can't do it the first time.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] arm: at91: at91sam9n12ek: add nandflash/spiflash/mmc/lcd support

2013-03-18 Thread Josh Wu

Dear Wolfgang Denk

Thanks for your review.  See my comment below:

On 3/18/2013 2:58 PM, Wolfgang Denk wrote:

Dear Josh Wu,

In message 1363342624-2939-1-git-send-email-josh...@atmel.com you wrote:

This patch adds at91sam9n12ek support, it enables:
- dbgu
- nand with pmecc
- spi flash
- mmc
- lcd

It appears you are adding support for a new board - in this case the
Subject: is misleading, plrase fix.

The missing entry in MAINTAINERS has already been pointed out. Please
also make sure to run your patch through checkpatch - it complains for
example WARNING: line over 80 characters.  Please fix these, too.

Please also make sure to keep all lists sorted. Bo shen already
mentioned this for the Makefile, but this also applies to lists as
here:

 #elif defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) \
-   || defined(CONFIG_AT91SAM9X5)
+   || defined(CONFIG_AT91SAM9X5) || 
defined(CONFIG_AT91SAM9N12)



I'll fix them in next version.




+++ b/arch/arm/include/asm/arch-at91/at91sam9n12.h
@@ -0,0 +1,126 @@

...

+/*
+ * Peripheral identifiers/interrupts.
+ */
+#define ATMEL_ID_FIQ   0   /* Advanced Interrupt Controller (FIQ) */
+#define ATMEL_ID_SYS   1   /* System Controller Interrupt */
+#define ATMEL_ID_PIOAB 2   /* Parallel I/O Controller A and B */
+#define ATMEL_ID_PIOCD 3   /* Parallel I/O Controller C and D */
+#define ATMEL_ID_FUSE  4   /* FUSE Controller */
+#define ATMEL_ID_USART05   /* USART 0 */
+#define ATMEL_ID_USART16   /* USART 1 */
+#define ATMEL_ID_USART27   /* USART 2 */
+#define ATMEL_ID_USART38   /* USART 3 */
+#define ATMEL_ID_TWI0  9   /* Two-Wire Interface 0 */
+#define ATMEL_ID_TWI1  10  /* Two-Wire Interface 1 */
+#define ATMEL_ID_HSMCI 12  /* High Speed Multimedia Card Interface */
+#define ATMEL_ID_SPI0  13  /* Serial Peripheral Interface 0 */
+#define ATMEL_ID_SPI1  14  /* Serial Peripheral Interface 1 */
+#define ATMEL_ID_UART0 15  /* UART 0 */
+#define ATMEL_ID_UART1 16  /* UART 1 */
+#define ATMEL_ID_TC01  17  /* Timer Counter 0, 1, 2, 3, 4 and 5 */
+#define ATMEL_ID_PWM   18  /* Pulse Width Modulation Controller */
+#define ATMEL_ID_ADC   19  /* ADC Controller */
+#define ATMEL_ID_DMAC  20  /* DMA Controller */
+#define ATMEL_ID_UHP   22  /* USB Host */
+#define ATMEL_ID_UDP   23  /* USB Device */
+#define ATMEL_ID_LCDC  25  /* LCD Controller */
+#define ATMEL_ID_SSC   28  /* Synchronous Serial Controller */
+#define ATMEL_ID_TRNG  30  /* True Random Number Generator */
+#define ATMEL_ID_IRQ   31  /* Advanced Interrupt Controller */

We already have the very same data in
arch/arm/include/asm/arch-at91/at91sam9x5.h.


+/*
+ * User Peripherals physical base addresses.
+ */
+#define ATMEL_BASE_SPI00xf000
+#define ATMEL_BASE_SPI10xf0004000
+#define ATMEL_BASE_HSMCI   0xf0008000
+#define ATMEL_BASE_SSC 0xf001
+#define ATMEL_BASE_TC012   0xf8008000
+#define ATMEL_BASE_TC345   0xf800c000
+#define ATMEL_BASE_TWI00xf801
+#define ATMEL_BASE_TWI10xf8014000
+#define ATMEL_BASE_USART0  0xf801c000
+#define ATMEL_BASE_USART1  0xf802
+#define ATMEL_BASE_USART2  0xf8024000
+#define ATMEL_BASE_USART3  0xf8028000
+#define ATMEL_BASE_PWM 0xf8034000
+#define ATMEL_BASE_LCDC0xf8038000
+#define ATMEL_BASE_UDP 0xf803c000
+#define ATMEL_BASE_UART0   0xf804
+#define ATMEL_BASE_UART1   0xf8044000
+#define ATMEL_BASE_TRNG0xf8048000
+#define ATMEL_BASE_ADC 0xf804c000

Same here.



+/*
+ * System Peripherals physical base addresses.
+ */
+#define ATMEL_BASE_FUSE0xdc00
+#define ATMEL_BASE_MATRIX  0xde00
+#define ATMEL_BASE_PMECC   0xe000
+#define ATMEL_BASE_PMERRLOC0xe600
+#define ATMEL_BASE_DDRSDRC 0xe800
+#define ATMEL_BASE_SMC 0xea00
+#define ATMEL_BASE_DMAC0xec00
+#define ATMEL_BASE_AIC 0xf000
+#define ATMEL_BASE_DBGU0xf200
+#define ATMEL_BASE_PIOA0xf400
+#define ATMEL_BASE_PIOB0xf600
+#define ATMEL_BASE_PIOC0xf800
+#define ATMEL_BASE_PIOD0xfa00
+#define ATMEL_BASE_PMC 0xfc00
+#define ATMEL_BASE_RSTC0xfe00
+#define ATMEL_BASE_SHDC0xfe10
+#define ATMEL_BASE_PIT 0xfe30
+#define ATMEL_BASE_WDT 0xfe40
+#define ATMEL_BASE_SCKCR   0xfe50
+#define ATMEL_BASE_BSCR0xfe54
+#define ATMEL_BASE_GPBR0xfe60
+#define ATMEL_BASE_RTC 0xfeb0

And here (except for the newly added ATMEL_BASE_FUSE).


yes, the at91sam9n12 is a subset of 9x5 with little modification.
I will reuse the at91sam9x5.h for at91sam9n12.



Oh, 

Re: [U-Boot] [PATCH] arm: at91: at91sam9n12ek: add nandflash/spiflash/mmc/lcd support

2013-03-18 Thread Andreas Bießmann
Dear Josh Wu,

On 03/18/2013 10:57 AM, Josh Wu wrote:
 Dear Wolfgang Denk
 
 Thanks for your review.  See my comment below:
 
 On 3/18/2013 2:58 PM, Wolfgang Denk wrote:
 Dear Josh Wu,

 In message 1363342624-2939-1-git-send-email-josh...@atmel.com you
 wrote:
 This patch adds at91sam9n12ek support, it enables:
 - dbgu
 - nand with pmecc
 - spi flash
 - mmc
 - lcd
 It appears you are adding support for a new board - in this case the
 Subject: is misleading, plrase fix.

 The missing entry in MAINTAINERS has already been pointed out. Please
 also make sure to run your patch through checkpatch - it complains for
 example WARNING: line over 80 characters.  Please fix these, too.

 Please also make sure to keep all lists sorted. Bo shen already
 mentioned this for the Makefile, but this also applies to lists as
 here:

  #elif defined(CONFIG_AT91SAM9G45) ||
 defined(CONFIG_AT91SAM9M10G45) \
 -|| defined(CONFIG_AT91SAM9X5)
 +|| defined(CONFIG_AT91SAM9X5) || defined(CONFIG_AT91SAM9N12)

 
 I'll fix them in next version.

Can we please find another identifier instead? I will not have these
always growing list of SoC defines to distinguish between different
access modes. Can we find some common thing which all these SoC headers
export then? I mean something like 'AT91_CLOCK_IP_V2' in this case here.
If we are looking forward to a single u-boot binary for different boards
I would favor some runtime detection.

Beside that I will do a full review of the patch later this day.

Best regards

Andreas Bießmann
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] 9g45 don't work

2013-03-18 Thread Andreas Bießmann
Dear xiexiaochao,

On 03/18/2013 03:14 AM, xiexiaochao wrote:
   hello,   my board base on  9m10g45, but mine don't work.   
 version   2013 lastest .  Would you please tell me why??   

Please configure your MUA to wrap at about 80 chars per line.

 I will appreciate your reply.   
  
   message below:
 
 -- AT91bootstrap Project 3.0 --
 -- AT91SAM9G45-EK
 -- Compiled: Mar  5 2013 18:10:43 --
 -I- Setting: MCK = 133MHz
 -I- Init DDRAM
 -I- Init NAND Flash
 -I- Nandflash ID is 0x9500F1EC
 -I- Nandflash driver initialized
 -I- Size of the whole device in bytes : 0x800
 -I- Size in bytes of one single block of a device : 0x2
 -I- Number of blocks in the entire device : 0x400
 -I- Size of the data area of a page in bytes : 0x800
 -I- Number of pages in the entire device : 0x40
 -I- Bus width : 8
 -I- Copy  (196608 bytes) from NAND 0x0002 to 0x73f0
 -I- Jump to 0x73f0

These are all at91bootstap outputs. It breaks when handing over from
at91bootstrap to u-boot. It is possible that your u-boot really break
here, but cause we do not see any output from u-boot (the version line)
it is likely that you have mis configured at91bootstrap here. However it
may be some mis misconfiguration in u-boot too. The relevant parameters
are CONFIG_SKIP_LOWLEVEL_INIT, CONFIG_USART_BASE/CONFIG_USART_ID. Please
check that these are setup correctly.
Regarding the at91bootstrap please check the following questions:
 * Can you verify, that you have written your u-boot binary (the *.bin
   file) at offset 0x2 into your NAND?
 * Can you also verify that your u-boot image is not bigger than
   192 kBytes?
 * Have you checked that the ECC mechanism used when writing the u-boot
   into NAND do match the oob layout the mechanism used to read the
   u-boot out of NAND?
 * Can you please check that you have more than 64MiB SDRAM connected
   and correctly initialized by at91bootstrap?

Best regards

Andreas Bießmann
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 1/5] imx iim: Homogenize and fix register definitions

2013-03-18 Thread Stefano Babic
On 27/11/2012 14:30, Benoît Thébaudeau wrote:
 Homogenize prg_p naming (the reference manuals are not always self-consistent
 for that). Add missing registers. Fix some registers.
 
 Signed-off-by: Benoît Thébaudeau benoit.thebaud...@advansee.com
 Cc: Stefano Babic sba...@denx.de
 Cc: Wolfgang Denk w...@denx.de
 ---

Hi Benoît,

checking again which patches were left in an unknow state, I face again
with you IIM patchset. My last status was that it shouldbe better to add
some test check (as we have for nand scrub..) to avoid to destroy at the
first attempt the SOC. Anyway, it is a minor point, and can be added
later - I am convinced that who works with U-Boot must know what he is
doing.

It would be a pity if we miss to merge this patchset - so my plan is to
merge it now into u-boot-imx, asking Anatolji if he agree with 5/5
(related to MPC-5121 only). Or do you plan to submit a new version ?

Best regards,
Stefano

-- 
=
DENX Software Engineering GmbH, MD: Wolfgang Denk  Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 1/5] imx iim: Homogenize and fix register definitions

2013-03-18 Thread Benoît Thébaudeau
Hi Stefano,

On Monday, March 18, 2013 1:07:42 PM, Stefano Babic wrote:
 On 27/11/2012 14:30, Benoît Thébaudeau wrote:
  Homogenize prg_p naming (the reference manuals are not always
  self-consistent
  for that). Add missing registers. Fix some registers.
  
  Signed-off-by: Benoît Thébaudeau benoit.thebaud...@advansee.com
  Cc: Stefano Babic sba...@denx.de
  Cc: Wolfgang Denk w...@denx.de
  ---
 
 Hi Benoît,
 
 checking again which patches were left in an unknow state, I face again
 with you IIM patchset. My last status was that it shouldbe better to add
 some test check (as we have for nand scrub..) to avoid to destroy at the
 first attempt the SOC. Anyway, it is a minor point, and can be added
 later - I am convinced that who works with U-Boot must know what he is
 doing.
 
 It would be a pity if we miss to merge this patchset - so my plan is to
 merge it now into u-boot-imx, asking Anatolji if he agree with 5/5
 (related to MPC-5121 only). Or do you plan to submit a new version ?

I had a plan to send a new version: what you mention, but also some
documentation and other types of improvements that Otavio and Eric asked for. I
also wanted to add support for i.MX6 OTG, but it might take a bit longer, so
that could be done separately. I will try to send early this week the new
version with the minor improvements.

Best regards,
Benoît
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 1/5] imx iim: Homogenize and fix register definitions

2013-03-18 Thread Benoît Thébaudeau
On Monday, March 18, 2013 1:08:23 PM, Benoît Thébaudeau wrote:
 Hi Stefano,
 
 On Monday, March 18, 2013 1:07:42 PM, Stefano Babic wrote:
  On 27/11/2012 14:30, Benoît Thébaudeau wrote:
   Homogenize prg_p naming (the reference manuals are not always
   self-consistent
   for that). Add missing registers. Fix some registers.
   
   Signed-off-by: Benoît Thébaudeau benoit.thebaud...@advansee.com
   Cc: Stefano Babic sba...@denx.de
   Cc: Wolfgang Denk w...@denx.de
   ---
  
  Hi Benoît,
  
  checking again which patches were left in an unknow state, I face again
  with you IIM patchset. My last status was that it shouldbe better to add
  some test check (as we have for nand scrub..) to avoid to destroy at the
  first attempt the SOC. Anyway, it is a minor point, and can be added
  later - I am convinced that who works with U-Boot must know what he is
  doing.
  
  It would be a pity if we miss to merge this patchset - so my plan is to
  merge it now into u-boot-imx, asking Anatolji if he agree with 5/5
  (related to MPC-5121 only). Or do you plan to submit a new version ?
 
 I had a plan to send a new version: what you mention, but also some
 documentation and other types of improvements that Otavio and Eric asked for.
 I
 also wanted to add support for i.MX6 OTG, but it might take a bit longer, so
   ^ s/OTG/OTP/
 that could be done separately. I will try to send early this week the new
 version with the minor improvements.

Best regards,
Benoît
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2] mxs: spl_mem_init: Align DDR2 init with FSL bootlets source

2013-03-18 Thread Otavio Salvador
On Thu, Mar 14, 2013 at 2:09 AM, Lauri Hintsala
lauri.hints...@bluegiga.com wrote:
 Hi,


 On 03/13/2013 04:22 PM, Fabio Estevam wrote:

 Lauri,

 On Wed, Mar 13, 2013 at 11:18 AM, Fabio Estevam feste...@gmail.com
 wrote:

 Hi Stefano,

 On Wed, Mar 13, 2013 at 5:16 AM, Stefano Babic sba...@denx.de wrote:

 Apart of the fact that fixes booting old kernel, these changes affects
 all mx28 boards, not only mx28evk. Can we have a description about which
 changes are done and why they are required ?

 Else to be accepted we need at least a Tested-vy for all boards using
 it.


 Yes, having a Tested-by would be really nice.

 Currently we have the following mx28 based boards that still needs to be
 tested:

 apx4devkit, m28evk and sc_sps_1.

 Veli-Pekka/Marek,

 Could you please try this patch on your systems?


 Veli-Pekka's email bounced. Would you have a chance to test it?


 Yes, I'll test the patch.

Lauri, did you give this patch?

-- 
Otavio Salvador O.S. Systems
E-mail: ota...@ossystems.com.br  http://www.ossystems.com.br
Mobile: +55 53 9981-7854  http://projetos.ossystems.com.br
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 3/4 v7] gen: Add sha h/w acceleration to hash

2013-03-18 Thread Simon Glass
On Sun, Mar 17, 2013 at 11:06 PM, Akshay Saraswat aksha...@samsung.com wrote:
 Adding H/W acceleration support to hash which can be used
 to test SHA 256 hash algorithm.

 Signed-off-by: ARUN MANKUZHI aru...@samsung.com
 Signed-off-by: Akshay Saraswat aksha...@samsung.com

Your alphabetical order looks slightly different to mine :-) Anyway:

Acked-by: Simon Glass s...@chromium.org

 ---
 Changes since v1:
 - Added sha256 support to hash command instead of new sha256 
 command.

 Changes sice v2:
 - Added new nodes for SHA1 and SHA256 in struct hash_algo for the 
 case when ACE is enabled.
 - Added new declaration for function pointer hash_func_ws with 
 different return type.

 Changes sice v3:
 - Changed command names to lower case in algo struct.
 - Added generic ace_sha config.

 Changes sice v4:
 - Changed function names in struct algo.
 - Replaced ACE_SHA_TYPE to CHUNSZ in struct algo.

 Changes sice v5:
 - Added file hw_sha.h.
 - Changed CONFIG_ACE_SHA to CONFIG_SHA_HW_ACCEL.
 - Renamed function names ace_sha1 and ace_sha256 to hw_sha1 and 
 hw_sha256 respectively.

 Changes sice v6:
 - Changed position of hw_sha.h among includes (alpha order).
 - Rebased patch.

  common/hash.c| 18 ++
  include/hw_sha.h | 50 ++
  2 files changed, 68 insertions(+)
  create mode 100644 include/hw_sha.h

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v8] Addition of btrfs file-system to U-boot

2013-03-18 Thread Adnan Ali

Adnan Ali (1):
  Introduced btrfs file-system with btrload command

 Makefile   |1 +
 common/Makefile|1 +
 common/cmd_btr.c   |   65 +++
 fs/btrfs/Makefile  |   51 ++
 fs/btrfs/btrfs.c   | 1352 
 fs/fs.c|   10 +
 include/btrfs.h|  416 ++
 include/config_fallbacks.h |4 +
 include/crc.h  |8 +
 include/fs.h   |1 +
 lib/Makefile   |1 +
 lib/crc32_c.c  |   40 ++
 12 files changed, 1950 insertions(+)
 create mode 100644 common/cmd_btr.c
 create mode 100644 fs/btrfs/Makefile
 create mode 100644 fs/btrfs/btrfs.c
 create mode 100644 include/btrfs.h
 create mode 100644 lib/crc32_c.c

-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v8] Introduced btrfs file-system with btrload command

2013-03-18 Thread Adnan Ali
Introduces btrfs file-system to read file from
volume/sub-volumes with btrload command. This
implementation has read-only support.
This btrfs implementation is based on syslinux btrfs
code, commit 269ebc845ebc8b46ef4b0be7fa0005c7fdb95b8d.

v8: patch re-formated.
v7: patch re-formated.
v6: patch re-formated.
v5: merged with master.
v4: btrls command added.

Signed-off-by: Adnan Ali adnan@codethink.co.uk
---
 Makefile   |1 +
 common/Makefile|1 +
 common/cmd_btr.c   |   65 +++
 fs/btrfs/Makefile  |   51 ++
 fs/btrfs/btrfs.c   | 1352 
 fs/fs.c|   10 +
 include/btrfs.h|  416 ++
 include/config_fallbacks.h |4 +
 include/crc.h  |8 +
 include/fs.h   |1 +
 lib/Makefile   |1 +
 lib/crc32_c.c  |   40 ++
 12 files changed, 1950 insertions(+)
 create mode 100644 common/cmd_btr.c
 create mode 100644 fs/btrfs/Makefile
 create mode 100644 fs/btrfs/btrfs.c
 create mode 100644 include/btrfs.h
 create mode 100644 lib/crc32_c.c

diff --git a/Makefile b/Makefile
index 55bd55c..b3da594 100644
--- a/Makefile
+++ b/Makefile
@@ -257,6 +257,7 @@ endif
 LIBS-$(CONFIG_OF_EMBED) += dts/libdts.o
 LIBS-y += arch/$(ARCH)/lib/lib$(ARCH).o
 LIBS-y += fs/libfs.o \
+fs/btrfs/libbtrfs.o \
fs/cbfs/libcbfs.o \
fs/cramfs/libcramfs.o \
fs/ext4/libext4fs.o \
diff --git a/common/Makefile b/common/Makefile
index 719fc23..d1fae56 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -73,6 +73,7 @@ COBJS-$(CONFIG_CMD_BEDBUG) += bedbug.o cmd_bedbug.o
 COBJS-$(CONFIG_CMD_BMP) += cmd_bmp.o
 COBJS-$(CONFIG_CMD_BOOTLDR) += cmd_bootldr.o
 COBJS-$(CONFIG_CMD_BOOTSTAGE) += cmd_bootstage.o
+COBJS-$(CONFIG_CMD_BTR) += cmd_btr.o
 COBJS-$(CONFIG_CMD_CACHE) += cmd_cache.o
 COBJS-$(CONFIG_CMD_CBFS) += cmd_cbfs.o
 COBJS-$(CONFIG_CMD_CONSOLE) += cmd_console.o
diff --git a/common/cmd_btr.c b/common/cmd_btr.c
new file mode 100644
index 000..846c0f1
--- /dev/null
+++ b/common/cmd_btr.c
@@ -0,0 +1,65 @@
+/*
+ * (C) Copyright 2013 Codethink Limited
+ * Btrfs port to Uboot by
+ * Adnan Ali adnan@codethink.co.uk
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * Boot support
+ */
+#include fs.h
+#include btrfs.h
+
+char subvolname[BTRFS_MAX_SUBVOL_NAME];
+
+int do_btr_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+   if (argc  5)
+   strcpy(subvolname, argv[5]);
+   else
+   strcpy(subvolname, );
+
+   return do_load(cmdtp, flag, argc, argv, FS_TYPE_BTR, 16);
+}
+
+
+U_BOOT_CMD(
+   btrload,7,  0,  do_btr_fsload,
+   load binary file from a btr filesystem,
+   interface [dev[:part]]  addr filename [subvol_name]\n
+   - Load binary file 'filename' from 'dev' on 'interface'\n
+ to address 'addr' from better filesystem.\n
+ the load stops on end of file.\n
+ subvol_name is used read that file from this subvolume.\n
+ All numeric parameters are assumed to be hex.
+);
+
+static int do_btr_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+return do_ls(cmdtp, flag, argc, argv, FS_TYPE_BTR);
+}
+
+U_BOOT_CMD(
+btrls,  4,  1,  do_btr_ls,
+list files in a directory (default /),
+interface [dev[:part]] [directory]\n
+- list files from 'dev' on 'interface' in a 'directory'
+);
+
diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile
new file mode 100644
index 000..a9e2021
--- /dev/null
+++ b/fs/btrfs/Makefile
@@ -0,0 +1,51 @@
+#
+# (C) Copyright 2006
+# Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+#
+# (C) Copyright 2003
+# Pavel Bartusek, Sysgo Real-Time Solutions AG, p...@sysgo.de
+#
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is 

Re: [U-Boot] [PATCH] arm: at91: at91sam9n12ek: add nandflash/spiflash/mmc/lcd support

2013-03-18 Thread Andreas Bießmann
Dear Josh Wu,

this is an additional review. I left out MAINTAINERS, alphabetical
ordering, copyright stuff a.s.o. mentioned before.

On 03/15/2013 11:17 AM, Josh Wu wrote:
 This patch adds at91sam9n12ek support, it enables:
 - dbgu
 - nand with pmecc
 - spi flash
 - mmc
 - lcd
 
 TODO:
 - usb
 - ethernet
 
 Signed-off-by: Josh Wu josh...@atmel.com
 ---
  arch/arm/cpu/arm926ejs/at91/Makefile   |1 +
  arch/arm/cpu/arm926ejs/at91/at91sam9n12_devices.c  |  137 ++
  arch/arm/cpu/arm926ejs/at91/clock.c|4 +-
  arch/arm/include/asm/arch-at91/at91sam9_matrix.h   |2 +
  arch/arm/include/asm/arch-at91/at91sam9n12.h   |  126 +
  arch/arm/include/asm/arch-at91/at91sam9x5_matrix.h |   17 +-
  arch/arm/include/asm/arch-at91/hardware.h  |2 +
  board/atmel/at91sam9n12ek/Makefile |   52 
  board/atmel/at91sam9n12ek/at91sam9n12ek.c  |  270 
 
  boards.cfg |3 +
  drivers/spi/atmel_spi.c|3 +-
  include/configs/at91sam9n12ek.h|  232 +
  12 files changed, 843 insertions(+), 6 deletions(-)
  create mode 100644 arch/arm/cpu/arm926ejs/at91/at91sam9n12_devices.c
  create mode 100644 arch/arm/include/asm/arch-at91/at91sam9n12.h
  create mode 100644 board/atmel/at91sam9n12ek/Makefile
  create mode 100644 board/atmel/at91sam9n12ek/at91sam9n12ek.c
  create mode 100644 include/configs/at91sam9n12ek.h
 
 diff --git a/arch/arm/cpu/arm926ejs/at91/Makefile 
 b/arch/arm/cpu/arm926ejs/at91/Makefile
 index 346e58f..c4964a1 100644
 --- a/arch/arm/cpu/arm926ejs/at91/Makefile
 +++ b/arch/arm/cpu/arm926ejs/at91/Makefile
 @@ -36,6 +36,7 @@ COBJS-$(CONFIG_AT91SAM9RL)  += at91sam9rl_devices.o
  COBJS-$(CONFIG_AT91SAM9M10G45)   += at91sam9m10g45_devices.o
  COBJS-$(CONFIG_AT91SAM9G45)  += at91sam9m10g45_devices.o
  COBJS-$(CONFIG_AT91SAM9X5)   += at91sam9x5_devices.o
 +COBJS-$(CONFIG_AT91SAM9N12)  += at91sam9n12_devices.o
  COBJS-$(CONFIG_AT91_EFLASH)  += eflash.o
  COBJS-$(CONFIG_AT91_LED) += led.o
  COBJS-y += clock.o
 diff --git a/arch/arm/cpu/arm926ejs/at91/at91sam9n12_devices.c 
 b/arch/arm/cpu/arm926ejs/at91/at91sam9n12_devices.c
 new file mode 100644
 index 000..5094262
 --- /dev/null
 +++ b/arch/arm/cpu/arm926ejs/at91/at91sam9n12_devices.c
 @@ -0,0 +1,137 @@
 +/*
 + * (C) Copyright 2013 Atmel Corporation
 + * Josh Wu josh...@atmel.com
 + *
 + * See file CREDITS for list of people who contributed to this
 + * project.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License as
 + * published by the Free Software Foundation; either version 2 of
 + * the License, or (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 + * MA 02111-1307 USA
 + */
 +
 +#include common.h
 +#include asm/io.h
 +#include asm/arch/at91_common.h
 +#include asm/arch/at91_pmc.h
 +#include asm/arch/at91_pio.h
 +
 +unsigned int has_lcdc()
 +{
 + return 1;
 +}
 +
 +void at91_serial0_hw_init(void)
 +{
 + at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
 +
 + at91_set_a_periph(AT91_PIO_PORTA, 0, 1);/* TXD0 */
 + at91_set_a_periph(AT91_PIO_PORTA, 1, 0);/* RXD0 */
 + writel(1  ATMEL_ID_USART0, pmc-pcer);
 +}
 +
 +void at91_serial1_hw_init(void)
 +{
 + at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
 +
 + at91_set_a_periph(AT91_PIO_PORTA, 5, 1);/* TXD1 */
 + at91_set_a_periph(AT91_PIO_PORTA, 6, 0);/* RXD1 */
 + writel(1  ATMEL_ID_USART1, pmc-pcer);
 +}
 +
 +void at91_serial2_hw_init(void)
 +{
 + at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
 +
 + at91_set_a_periph(AT91_PIO_PORTA, 7, 1);/* TXD2 */
 + at91_set_a_periph(AT91_PIO_PORTA, 8, 0);/* RXD2 */
 + writel(1  ATMEL_ID_USART2, pmc-pcer);
 +}
 +
 +void at91_serial3_hw_init(void)
 +{
 + at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
 +
 + at91_set_b_periph(AT91_PIO_PORTC, 22, 1);   /* TXD3 */
 + at91_set_b_periph(AT91_PIO_PORTC, 23, 0);   /* RXD3 */
 + writel(1  ATMEL_ID_USART3, pmc-pcer);
 +}
 +
 +void at91_seriald_hw_init(void)
 +{
 + at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
 +
 + at91_set_a_periph(AT91_PIO_PORTA, 9, 1);/* DRXD */

The pullup should be on the TX line, please swap the both lines here to
reflect the same order as before (TX than RX).

 +

Re: [U-Boot] [PULL] u-boot-usb/master

2013-03-18 Thread Tom Warren
Marek,

 Message: 28
 Date: Sun, 17 Mar 2013 03:05:51 +0100
 From: Marek Vasut ma...@denx.de
 Subject: [U-Boot] [PULL] u-boot-usb/master
 To: Tom Rini tr...@ti.com
 Cc: u-boot@lists.denx.de u-boot@lists.denx.de
 Message-ID: 201303170305.51502.ma...@denx.de
 Content-Type: Text/Plain;  charset=us-ascii
 
 Hi Tom,
 
 let's do this ...
 
 The following changes since commit
 b5bec88434adb52413f1bc33fa63d7642cb8fd35:
 
   Use 'unsigned int' for global_data's baudrate (2013-03-15 16:14:02 -0400)
 
 are available in the git repository at:
 
   git://git.denx.de/u-boot-usb.git master
 
 for you to fetch changes up to
 d4c450334837ab8e497ae5016a03258b3cb36aa2:
 
   usb: Add multiple controllers support for EHCI PCI (2013-03-16 21:12:05
 +0100)
 
 
 Lucas Stach (5):
   tegra: usb: set USB_PORTS_MAX to correct value
   tegra: usb: make controller init functions more self contained
   tegra: usb: remove unneeded function parameter
   tegra: usb: move controller init into start_port
   tegra: usb: various small cleanups

We'd agreed (on Jan 28, for V2 of Lucas' USB patchset, and again Feb 14 for V3 
of the patchset) that these would go through the Tegra tree. Albert has already 
accepted my PR a few days ago for ARM/master, so if these go into TOT 
u-boot.git from the USB tree, we'll have a conflict. Not to mention the fact 
that you appear to be missing a couple of Lucas' patches (6/7 tegra: use: move 
implementation into right directory  7/7 tegra: usb: move [start|stop]_port 
into ehci_hcd_[init|stop]).  I've also had these 7 patches marked as 'Accepted' 
in Patchwork for some time now.

Please fix this.

Tom
 
 Lukasz Majewski (4):
   usb:composite:fix Provide function data when addressing device with only
 one interface
   usb:composite: USB Mass Storage - storage_common.c from Linux kernel
   usb:gadget: USB Mass Storage Gadget support
   arm:trats: Use new ums command
 
 Michael Spang (1):
   usb: usbeth: smsc95xx: remove EEPROM loaded check
 
 Pantelis Antoniou (5):
   dfu: Only perform DFU board_usb_init() for TRATS
   dfu: Fix crash when wrong number of arguments given
   dfu: Properly zero out timeout value
   dfu: Add a partition type target
   usb: Fix bug when both DFU  ETHER are defined
 
 Patrick Georgi (1):
   usb: ehci: Support interrupt transfers via periodic list
 
 Piotr Wilczek (1):
   usb:composite: USB Mass Storage - f_mass_storage.c from Linux kernel
 
 Shiraz Hashim (1):
   usbtty: adapt buffers for large packet support
 
 Simon Glass (1):
   x86: Enable USB features for coreboot
 
 Vincent Palatin (4):
   usb: ehci: generic PCI support
   usb: ehci: Add 64-bit controller support
   usb: ehci: Fix aliasing issue in EHCI interrupt code
   usb: Add multiple controllers support for EHCI PCI
 
 Vipin Kumar (1):
   usb/host/ehci: Add support for EHCI on spear
 
 Vivek Gautam (2):
   usb: ehci: exynos: Fix multiple FDT decode
   usb: ehci: exynos: Enable non-dt path
 
  arch/arm/cpu/armv7/tegra20/usb.c|   96 ++-
  arch/arm/include/asm/arch-tegra20/usb.h |3 -
  board/samsung/trats/trats.c |   63 ++
  common/Makefile |1 +
  common/cmd_dfu.c|5 +-
  common/cmd_usb_mass_storage.c   |   86 +++
  drivers/dfu/dfu_mmc.c   |   31 +
  drivers/serial/usbtty.c |2 +-
  drivers/usb/eth/smsc95xx.c  |4 -
  drivers/usb/gadget/Makefile |   10 +-
  drivers/usb/gadget/composite.c  |   19 +
  drivers/usb/gadget/f_dfu.c  |3 +
  drivers/usb/gadget/f_mass_storage.c | 2793
 ++
 ++
  drivers/usb/gadget/g_dnl.c  |6 +
  drivers/usb/gadget/storage_common.c |  653 +++
  drivers/usb/host/Makefile   |1 +
  drivers/usb/host/ehci-exynos.c  |   51 +-
  drivers/usb/host/ehci-hcd.c |  318 -
  drivers/usb/host/ehci-pci.c |   60 +-
  drivers/usb/host/ehci-spear.c   |   59 ++
  drivers/usb/host/ehci.h |6 +-
  include/configs/coreboot.h  |   17 +
  include/configs/trats.h |5 +
  include/usb_mass_storage.h  |   55 ++
  include/usbdevice.h |4 +-
  25 files changed, 4245 insertions(+), 106 deletions(-)
  create mode 100644 common/cmd_usb_mass_storage.c
  create mode 100644 drivers/usb/gadget/f_mass_storage.c
  create mode 100644 drivers/usb/gadget/storage_common.c
  create mode 100644 drivers/usb/host/ehci-spear.c
  create mode 100644 include/usb_mass_storage.h
 
--
nvpublic

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 4/7] cros: add LPC support for cros_ec

2013-03-18 Thread Hung-ying Tyan
This patch adds LPC support for carrying out the cros_ec protocol.

Signed-off-by: Randall Spangler rspang...@chromium.org
Signed-off-by: Simon Glass s...@chromium.org
Signed-off-by: Hung-ying Tyan ty...@chromium.org

---
Changes in v2:
- Wrapped lines to comply with the 80-char rule.

 drivers/misc/Makefile  |   1 +
 drivers/misc/cros_ec_lpc.c | 283 +
 2 files changed, 284 insertions(+)
 create mode 100644 drivers/misc/cros_ec_lpc.c

diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 18209ec..3553ff6 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -31,6 +31,7 @@ COBJS-$(CONFIG_CBMEM_CONSOLE) += cbmem_console.o
 COBJS-$(CONFIG_GPIO_LED) += gpio_led.o
 COBJS-$(CONFIG_FSL_MC9SDZ60) += mc9sdz60.o
 COBJS-$(CONFIG_CROS_EC) += cros_ec.o
+COBJS-$(CONFIG_CROS_EC_LPC) += cros_ec_lpc.o
 COBJS-$(CONFIG_CROS_EC_I2C) += cros_ec_i2c.o
 COBJS-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o
 COBJS-$(CONFIG_NS87308) += ns87308.o
diff --git a/drivers/misc/cros_ec_lpc.c b/drivers/misc/cros_ec_lpc.c
new file mode 100644
index 000..cf0435b
--- /dev/null
+++ b/drivers/misc/cros_ec_lpc.c
@@ -0,0 +1,283 @@
+/*
+ * Chromium OS cros_ec driver - LPC interface
+ *
+ * Copyright (c) 2012 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * The Matrix Keyboard Protocol driver handles talking to the keyboard
+ * controller chip. Mostly this is for keyboard functions, but some other
+ * things have slipped in, so we provide generic services to talk to the
+ * KBC.
+ */
+
+#include common.h
+#include command.h
+#include cros_ec.h
+#include asm/io.h
+
+#ifdef DEBUG_TRACE
+#define debug_trace(fmt, b...) debug(fmt, ##b)
+#else
+#define debug_trace(fmt, b...)
+#endif
+
+static int wait_for_sync(struct cros_ec_dev *dev)
+{
+   unsigned long start;
+
+   start = get_timer(0);
+   while (inb(EC_LPC_ADDR_HOST_CMD)  EC_LPC_STATUS_BUSY_MASK) {
+   if (get_timer(start)  1000) {
+   debug(%s: Timeout waiting for CROS_EC sync\n,
+ __func__);
+   return -1;
+   }
+   }
+
+   return 0;
+}
+
+/**
+ * Send a command to a LPC CROS_EC device and return the reply.
+ *
+ * The device's internal input/output buffers are used.
+ *
+ * @param dev  CROS_EC device
+ * @param cmd  Command to send (EC_CMD_...)
+ * @param cmd_version  Version of command to send (EC_VER_...)
+ * @param dout  Output data (may be NULL If dout_len=0)
+ * @param dout_len  Size of output data in bytes
+ * @param dinp  Place to put pointer to response data
+ * @param din_len   Maximum size of response in bytes
+ * @return number of bytes in response, or -1 on error
+ */
+static int old_lpc_command(struct cros_ec_dev *dev, uint8_t cmd,
+const uint8_t *dout, int dout_len,
+uint8_t **dinp, int din_len)
+{
+   int ret, i;
+
+   if (dout_len  EC_OLD_PARAM_SIZE) {
+   debug(%s: Cannot send %d bytes\n, __func__, dout_len);
+   return -1;
+   }
+
+   if (din_len  EC_OLD_PARAM_SIZE) {
+   debug(%s: Cannot receive %d bytes\n, __func__, din_len);
+   return -1;
+   }
+
+   if (wait_for_sync(dev)) {
+   debug(%s: Timeout waiting ready\n, __func__);
+   return -1;
+   }
+
+   debug_trace(cmd: %02x, , cmd);
+   for (i = 0; i  dout_len; i++) {
+   debug_trace(%02x , dout[i]);
+   outb(dout[i], EC_LPC_ADDR_OLD_PARAM + i);
+   }
+   outb(cmd, EC_LPC_ADDR_HOST_CMD);
+   debug_trace(\n);
+
+   if (wait_for_sync(dev)) {
+   debug(%s: Timeout waiting ready\n, __func__);
+   return -1;
+   }
+
+   ret = inb(EC_LPC_ADDR_HOST_DATA);
+   if (ret) {
+   debug(%s: CROS_EC result code %d\n, __func__, ret);
+   return -ret;
+   }
+
+   debug_trace(resp: %02x, , ret);
+   for (i = 0; i  din_len; i++) {
+   dev-din[i] = inb(EC_LPC_ADDR_OLD_PARAM + i);
+   debug_trace(%02x , dev-din[i]);
+   }
+   debug_trace(\n);
+   *dinp = 

[U-Boot] [PATCH v2 2/7] cros: add I2C support for cros_ec

2013-03-18 Thread Hung-ying Tyan
This patch adds I2C support for carrying out the cros_ec protocol.

Signed-off-by: Randall Spangler rspang...@chromium.org
Signed-off-by: Simon Glass s...@chromium.org
Signed-off-by: Hung-ying Tyan ty...@chromium.org

---
Changes in v2:
- Wrapped lines to comply with the 80-char rule.

 drivers/misc/Makefile  |   1 +
 drivers/misc/cros_ec_i2c.c | 199 +
 2 files changed, 200 insertions(+)
 create mode 100644 drivers/misc/cros_ec_i2c.c

diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 33fe822..9363ef9 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -31,6 +31,7 @@ COBJS-$(CONFIG_CBMEM_CONSOLE) += cbmem_console.o
 COBJS-$(CONFIG_GPIO_LED) += gpio_led.o
 COBJS-$(CONFIG_FSL_MC9SDZ60) += mc9sdz60.o
 COBJS-$(CONFIG_CROS_EC) += cros_ec.o
+COBJS-$(CONFIG_CROS_EC_I2C) += cros_ec_i2c.o
 COBJS-$(CONFIG_NS87308) += ns87308.o
 COBJS-$(CONFIG_PDSP188x) += pdsp188x.o
 COBJS-$(CONFIG_STATUS_LED) += status_led.o
diff --git a/drivers/misc/cros_ec_i2c.c b/drivers/misc/cros_ec_i2c.c
new file mode 100644
index 000..b0060ac
--- /dev/null
+++ b/drivers/misc/cros_ec_i2c.c
@@ -0,0 +1,199 @@
+/*
+ * Chromium OS cros_ec driver - I2C interface
+ *
+ * Copyright (c) 2012 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * The Matrix Keyboard Protocol driver handles talking to the keyboard
+ * controller chip. Mostly this is for keyboard functions, but some other
+ * things have slipped in, so we provide generic services to talk to the
+ * KBC.
+ */
+
+#include common.h
+#include i2c.h
+#include cros_ec.h
+
+#ifdef DEBUG_TRACE
+#define debug_trace(fmt, b...) debug(fmt, #b)
+#else
+#define debug_trace(fmt, b...)
+#endif
+
+int cros_ec_i2c_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
+const uint8_t *dout, int dout_len,
+uint8_t **dinp, int din_len)
+{
+   int old_bus = 0;
+   /* version8, cmd8, arglen8, out8[dout_len], csum8 */
+   int out_bytes = dout_len + 4;
+   /* response8, arglen8, in8[din_len], checksum8 */
+   int in_bytes = din_len + 3;
+   uint8_t *ptr;
+   /* Receive input data, so that args will be dword aligned */
+   uint8_t *in_ptr;
+   int ret;
+
+   old_bus = i2c_get_bus_num();
+
+   /*
+* Sanity-check I/O sizes given transaction overhead in internal
+* buffers.
+*/
+   if (out_bytes  sizeof(dev-dout)) {
+   debug(%s: Cannot send %d bytes\n, __func__, dout_len);
+   return -1;
+   }
+   if (in_bytes  sizeof(dev-din)) {
+   debug(%s: Cannot receive %d bytes\n, __func__, din_len);
+   return -1;
+   }
+   assert(dout_len = 0);
+   assert(dinp);
+
+   /*
+* Copy command and data into output buffer so we can do a single I2C
+* burst transaction.
+*/
+   ptr = dev-dout;
+
+   /*
+* in_ptr starts of pointing to a dword-aligned input data buffer.
+* We decrement it back by the number of header bytes we expect to
+* receive, so that the first parameter of the resulting input data
+* will be dword aligned.
+*/
+   in_ptr = dev-din + sizeof(int64_t);
+   if (!dev-cmd_version_is_supported) {
+   /* Send an old-style command */
+   *ptr++ = cmd;
+   out_bytes = dout_len + 1;
+   in_bytes = din_len + 2;
+   in_ptr--;   /* Expect just a status byte */
+   } else {
+   *ptr++ = EC_CMD_VERSION0 + cmd_version;
+   *ptr++ = cmd;
+   *ptr++ = dout_len;
+   in_ptr -= 2;/* Expect status, length bytes */
+   }
+   memcpy(ptr, dout, dout_len);
+   ptr += dout_len;
+
+   if (dev-cmd_version_is_supported)
+   *ptr++ = (uint8_t)
+cros_ec_calc_checksum(dev-dout, dout_len + 3);
+
+   /* Set to the proper i2c bus */
+   if (i2c_set_bus_num(dev-bus_num)) {
+   debug(%s: Cannot change to I2C bus %d\n, __func__,
+   dev-bus_num);
+   return -1;
+   }
+
+   /* Send output data */
+ 

[U-Boot] [PATCH v2 3/7] cros: add SPI support for cros_ec

2013-03-18 Thread Hung-ying Tyan
This patch adds SPI support for carrying out the cros_ec protocol.

Signed-off-by: Hung-ying Tyan ty...@chromium.org
Signed-off-by: Randall Spangler rspang...@chromium.org
Signed-off-by: Simon Glass s...@chromium.org

---
Changes in v2:
- Wrapped lines to comply with the 80-char rule.

 drivers/misc/Makefile  |   1 +
 drivers/misc/cros_ec_spi.c | 166 +
 drivers/spi/exynos_spi.c   |  22 ++
 include/spi.h  |  16 +
 4 files changed, 205 insertions(+)
 create mode 100644 drivers/misc/cros_ec_spi.c

diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 9363ef9..18209ec 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -32,6 +32,7 @@ COBJS-$(CONFIG_GPIO_LED) += gpio_led.o
 COBJS-$(CONFIG_FSL_MC9SDZ60) += mc9sdz60.o
 COBJS-$(CONFIG_CROS_EC) += cros_ec.o
 COBJS-$(CONFIG_CROS_EC_I2C) += cros_ec_i2c.o
+COBJS-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o
 COBJS-$(CONFIG_NS87308) += ns87308.o
 COBJS-$(CONFIG_PDSP188x) += pdsp188x.o
 COBJS-$(CONFIG_STATUS_LED) += status_led.o
diff --git a/drivers/misc/cros_ec_spi.c b/drivers/misc/cros_ec_spi.c
new file mode 100644
index 000..82cc1bb
--- /dev/null
+++ b/drivers/misc/cros_ec_spi.c
@@ -0,0 +1,166 @@
+/*
+ * Chromium OS cros_ec driver - SPI interface
+ *
+ * Copyright (c) 2012 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * The Matrix Keyboard Protocol driver handles talking to the keyboard
+ * controller chip. Mostly this is for keyboard functions, but some other
+ * things have slipped in, so we provide generic services to talk to the
+ * KBC.
+ */
+
+#include common.h
+#include cros_ec.h
+#include spi.h
+
+#ifdef CONFIG_NEW_SPI_XFER
+#error CONFIG_NEW_SPI_XFER not supported in CROS_EC
+#endif
+
+/**
+ * Send a command to a LPC CROS_EC device and return the reply.
+ *
+ * The device's internal input/output buffers are used.
+ *
+ * @param dev  CROS_EC device
+ * @param cmd  Command to send (EC_CMD_...)
+ * @param cmd_version  Version of command to send (EC_VER_...)
+ * @param dout Output data (may be NULL If dout_len=0)
+ * @param dout_len  Size of output data in bytes
+ * @param dinp Returns pointer to response data. This will be
+ * untouched unless we return a value  0.
+ * @param din_len  Maximum size of response in bytes
+ * @return number of bytes in response, or -1 on error
+ */
+int cros_ec_spi_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
+const uint8_t *dout, int dout_len,
+uint8_t **dinp, int din_len)
+{
+   int in_bytes = din_len + 4; /* status, length, checksum, trailer */
+   uint8_t *out;
+   uint8_t *p;
+   int csum, len;
+   int rv;
+
+   /*
+* Sanity-check input size to make sure it plus transaction overhead
+* fits in the internal device buffer.
+*/
+   if (in_bytes  sizeof(dev-din)) {
+   debug(%s: Cannot receive %d bytes\n, __func__, din_len);
+   return -1;
+   }
+
+   /* We represent message length as a byte */
+   if (dout_len  0xff) {
+   debug(%s: Cannot send %d bytes\n, __func__, dout_len);
+   return -1;
+   }
+
+   /*
+* TODO(s...@chromium.org): Clear input buffer so we don't get false
+* hits for MSG_HEADER
+*/
+   memset(dev-din, '\0', in_bytes);
+
+   if (spi_claim_bus(dev-spi)) {
+   debug(%s: Cannot claim SPI bus\n, __func__);
+   return -1;
+   }
+
+   out = dev-dout;
+   out[0] = cmd_version;
+   out[1] = cmd;
+   out[2] = (uint8_t)dout_len;
+   memcpy(out + 3, dout, dout_len);
+   csum = cros_ec_calc_checksum(out, 3)
+  + cros_ec_calc_checksum(dout, dout_len);
+   out[3 + dout_len] = (uint8_t)csum;
+
+   /*
+* Send output data and receive input data starting such that the
+* message body will be dword aligned.
+*/
+   p = dev-din + sizeof(int64_t) - 2;
+   len = dout_len + 4;
+   cros_ec_dump_data(out, cmd, out, len);
+   rv = spi_xfer(dev-spi, max(len, in_bytes) * 8, out, p,
+ 

[U-Boot] [PATCH v2 7/7] cros: enable cros-ec for smdk5250

2013-03-18 Thread Hung-ying Tyan
This patch initiates cros-ec in board_init() to enable it for smdk5250.

Signed-off-by: Simon Glass s...@chromium.org
Signed-off-by: Vincent Palatin vpala...@chromium.org
Signed-off-by: Hung-ying Tyan ty...@chromium.org

---
Changes in v2:
- Code moved from smdk5250.c (non-FDT) to exynos5-dt.c (FDT).
- Code moved from smdk5250.h to exynos5250-dt.h.

 board/samsung/smdk5250/exynos5-dt.c | 45 +
 include/configs/exynos5250-dt.h | 10 -
 2 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/board/samsung/smdk5250/exynos5-dt.c 
b/board/samsung/smdk5250/exynos5-dt.c
index b01fe72..8be3192 100644
--- a/board/samsung/smdk5250/exynos5-dt.c
+++ b/board/samsung/smdk5250/exynos5-dt.c
@@ -21,6 +21,7 @@
  */
 
 #include common.h
+#include cros_ec.h
 #include fdtdec.h
 #include asm/io.h
 #include errno.h
@@ -39,6 +40,13 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+struct local_info {
+   struct cros_ec_dev *cros_ec_dev;/* Pointer to cros_ec device */
+   int cros_ec_err;/* Error for cros_ec, 0 if ok */
+};
+
+static struct local_info local;
+
 #ifdef CONFIG_USB_EHCI_EXYNOS
 int board_usb_vbus_init(void)
 {
@@ -55,12 +63,30 @@ int board_usb_vbus_init(void)
 }
 #endif
 
+struct cros_ec_dev *board_get_cros_ec_dev(void)
+{
+   return local.cros_ec_dev;
+}
+
+static int board_init_cros_ec_devices(const void *blob)
+{
+   local.cros_ec_err = cros_ec_init(blob, local.cros_ec_dev);
+   if (local.cros_ec_err)
+   return -1;  /* Will report in board_late_init() */
+
+   return 0;
+}
+
 int board_init(void)
 {
gd-bd-bi_boot_params = (PHYS_SDRAM_1 + 0x100UL);
 #ifdef CONFIG_EXYNOS_SPI
spi_init();
 #endif
+
+   if (board_init_cros_ec_devices(gd-fdt_blob))
+   return -1;
+
 #ifdef CONFIG_USB_EHCI_EXYNOS
board_usb_vbus_init();
 #endif
@@ -337,3 +363,22 @@ int board_early_init_f(void)
return err;
 }
 #endif
+
+#ifdef CONFIG_BOARD_LATE_INIT
+int board_late_init(void)
+{
+   stdio_print_current_devices();
+
+   if (local.cros_ec_err) {
+   /* Force console on */
+   gd-flags = ~GD_FLG_SILENT;
+
+   printf(cros-ec communications failure %d\n,
+  local.cros_ec_err);
+   puts(\nPlease reset with Power+Refresh\n\n);
+   panic(Cannot init cros-ec device);
+   return -1;
+   }
+   return 0;
+}
+#endif
diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h
index 0721c17..80dfce7 100644
--- a/include/configs/exynos5250-dt.h
+++ b/include/configs/exynos5250-dt.h
@@ -77,11 +77,19 @@
 #define CONFIG_BAUDRATE115200
 #define EXYNOS5_DEFAULT_UART_OFFSET0x01
 
+/* Enable keyboard */
+#define CONFIG_CROS_EC /* CROS_EC protocol */
+#define CONFIG_CROS_EC_SPI /* Support CROS_EC over SPI */
+#define CONFIG_CROS_EC_I2C /* Support CROS_EC over I2C */
+#define CONFIG_CROS_EC_KEYB/* CROS_EC keyboard input */
+#define CONFIG_CMD_CROS_EC
+#define CONFIG_KEYBOARD
+
 /* Console configuration */
 #define CONFIG_CONSOLE_MUX
 #define CONFIG_SYS_CONSOLE_IS_IN_ENV
 #define EXYNOS_DEVICE_SETTINGS \
-   stdin=serial\0 \
+   stdin=serial,cros-ec-keyb\0 \
stdout=serial,lcd\0 \
stderr=serial,lcd\0
 
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 6/7] cros: exynos: add cros-ec device nodes to exynos5250-snow.dts

2013-03-18 Thread Hung-ying Tyan
Signed-off-by: Hung-ying Tyan ty...@chromium.org

---
Changes in v2:
- Add gpio node to exynos5250.dtsi.

 arch/arm/dts/exynos5250.dtsi  |  3 ++
 board/samsung/dts/exynos5250-snow.dts | 82 +++
 2 files changed, 85 insertions(+)

diff --git a/arch/arm/dts/exynos5250.dtsi b/arch/arm/dts/exynos5250.dtsi
index 6c08eb7..2644131 100644
--- a/arch/arm/dts/exynos5250.dtsi
+++ b/arch/arm/dts/exynos5250.dtsi
@@ -182,4 +182,7 @@
reg = 0x1223 0x1000;
interrupts = 0 78 0;
};
+
+   gpio: gpio {
+   };
 };
diff --git a/board/samsung/dts/exynos5250-snow.dts 
b/board/samsung/dts/exynos5250-snow.dts
index af788a6..a7526e5 100644
--- a/board/samsung/dts/exynos5250-snow.dts
+++ b/board/samsung/dts/exynos5250-snow.dts
@@ -43,6 +43,33 @@
};
};
 
+   i2c4: i2c@12ca {
+   cros-ec@1e {
+   reg = 0x1e;
+   compatible = google,cros-ec;
+   i2c-max-frequency = 10;
+   ec-interrupt = gpio 174 1;
+   };
+
+   power-regulator@48 {
+   compatible = ti,tps65090;
+   reg = 0x48;
+   };
+   };
+
+   spi@131b {
+   spi-max-frequency = 100;
+   spi-deactivate-delay = 100;
+   cros-ec@0 {
+   reg = 0;
+   compatible = google,cros-ec;
+   spi-max-frequency = 500;
+   ec-interrupt = gpio 174 1;
+   optimise-flash-write;
+   status = disabled;
+   };
+   };
+
sound@12d6 {
samsung,i2s-epll-clock-frequency = 19200;
samsung,i2s-sampling-rate = 48000;
@@ -66,4 +93,59 @@
compatible = maxim,max77686_pmic;
};
};
+
+   cros-ec-keyb {
+   compatible = google,cros-ec-keyb;
+   google,key-rows = 8;
+   google,key-columns = 13;
+   google,repeat-delay-ms = 240;
+   google,repeat-rate-ms = 30;
+   google,ghost-filter;
+   /*
+* Keymap entries take the form of 0xRRCC where
+* RR=Row CC=Column =Key Code
+* The values below are for a US keyboard layout and
+* are taken from the Linux driver. Note that the
+* 102ND key is not used for US keyboards.
+*/
+   linux,keymap = 
+   /* CAPSLCK F1 B  F10 */
+   0x0001003a 0x0002003b 0x00030030 0x00040044
+   /* N   =  R_ALT  ESC */
+   0x00060031 0x0008000d 0x000a0064 0x01010001
+   /* F4  G  F7 H   */
+   0x0102003e 0x01030022 0x01040041 0x01060023
+   /* '   F9 BKSPACEL_CTRL  */
+   0x01080028 0x01090043 0x010b000e 0x021d
+   /* TAB F3 T  F6  */
+   0x0201000f 0x0202003d 0x02030014 0x02040040
+   /* ]   Y  102ND  [   */
+   0x0205001b 0x02060015 0x02070056 0x0208001a
+   /* F8  GRAVE  F2 5   */
+   0x02090042 0x03010029 0x0302003c 0x03030006
+   /* F5  6  -  \   */
+   0x0304003f 0x03060007 0x0308000c 0x030b002b
+   /* R_CTRL  A  D  F   */
+   0x0461 0x0401001e 0x04020020 0x04030021
+   /* S   K  J  ;   */
+   0x0404001f 0x04050025 0x04060024 0x04080027
+   /* L   ENTER  Z  C   */
+   0x04090026 0x040b001c 0x0501002c 0x0502002e
+   /* V   X  ,  M   */
+   0x0503002f 0x0504002d 0x05050033 0x05060032
+   /* L_SHIFT /  .  SPACE   */
+   0x0507002a 0x05080035 0x05090034 0x050B0039
+   /* 1   3  4  2   */
+   0x06010002 0x06020004 0x06030005 0x06040003
+   /* 8   7  0  9   */
+   0x06050009 0x06060008 0x0608000b 0x0609000a
+   /* L_ALT   DOWN   RIGHT  Q   */
+   0x060a0038 0x060b006c 0x060c006a 0x07010010
+   /* E   R  W  I   */
+   0x07020012 0x07030013 0x07040011 0x07050017
+   /* U   R_SHIFTP 

[U-Boot] [PATCH v2 5/7] cros: adds cros_ec keyboard driver

2013-03-18 Thread Hung-ying Tyan
This patch adds the driver for keyboard that's controlled by ChromeOS EC.

Signed-off-by: Randall Spangler rspang...@chromium.org
Signed-off-by: Simon Glass s...@chromium.org
Signed-off-by: Vincent Palatin vpala...@chromium.org
Signed-off-by: Hung-ying Tyan ty...@chromium.org

---
Changes in v2:
- Wrapped lines to comply with the 80-char rule.

 README   |   5 +
 drivers/input/Makefile   |   1 +
 drivers/input/cros_ec_keyb.c | 264 +++
 include/fdtdec.h |   1 +
 lib/fdtdec.c |   1 +
 5 files changed, 272 insertions(+)
 create mode 100644 drivers/input/cros_ec_keyb.c

diff --git a/README b/README
index 42544ce..769d1bf 100644
--- a/README
+++ b/README
@@ -1371,6 +1371,11 @@ CBFS (Coreboot Filesystem) support
Export function i8042_kbd_init, i8042_tstc and i8042_getc
for cfb_console. Supports cursor blinking.
 
+   CONFIG_CROS_EC_KEYB
+   Enables a Chrome OS keyboard using the CROS_EC interface.
+   This uses CROS_EC to communicate with a second microcontroller
+   which provides key scans on request.
+
 - Video support:
CONFIG_VIDEO
 
diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index 0805e86..4331190 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -27,6 +27,7 @@ LIB   := $(obj)libinput.o
 
 COBJS-$(CONFIG_I8042_KBD) += i8042.o
 COBJS-$(CONFIG_TEGRA_KEYBOARD) += tegra-kbc.o
+COBJS-$(CONFIG_CROS_EC_KEYB) += cros_ec_keyb.o
 ifdef CONFIG_PS2KBD
 COBJS-y += keyboard.o pc_keyb.o
 COBJS-$(CONFIG_PS2MULT) += ps2mult.o ps2ser.o
diff --git a/drivers/input/cros_ec_keyb.c b/drivers/input/cros_ec_keyb.c
new file mode 100644
index 000..21fab15
--- /dev/null
+++ b/drivers/input/cros_ec_keyb.c
@@ -0,0 +1,264 @@
+/*
+ * Chromium OS Matrix Keyboard
+ *
+ * Copyright (c) 2012 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include common.h
+#include fdtdec.h
+#include input.h
+#include key_matrix.h
+#include cros_ec.h
+#include stdio_dev.h
+
+DECLARE_GLOBAL_DATA_PTR;
+
+enum {
+   KBC_MAX_KEYS= 8,/* Maximum keys held down at once */
+};
+
+static struct keyb {
+   struct cros_ec_dev *dev;/* The CROS_EC device */
+   struct input_config input;  /* The input layer */
+   struct key_matrix matrix;   /* The key matrix layer */
+   int key_rows;   /* Number of keyboard rows */
+   int key_cols;   /* Number of keyboard columns */
+   unsigned int repeat_delay_ms;   /* Time before autorepeat starts */
+   unsigned int repeat_rate_ms;/* Autorepeat rate in ms */
+   int ghost_filter;   /* 1 to enable ghost filter, else 0 */
+   int inited; /* 1 if keyboard is ready */
+} config;
+
+
+/**
+ * Check the keyboard controller and return a list of key matrix positions
+ * for which a key is pressed
+ *
+ * @param config   Keyboard config
+ * @param keys List of keys that we have detected
+ * @param max_countMaximum number of keys to return
+ * @return number of pressed keys, 0 for none
+ */
+static int check_for_keys(struct keyb *config,
+  struct key_matrix_key *keys, int max_count)
+{
+   struct key_matrix_key *key;
+   struct mbkp_keyscan scan;
+   unsigned int row, col, bit, data;
+   int num_keys;
+
+   if (cros_ec_scan_keyboard(config-dev, scan)) {
+   debug(%s: keyboard scan failed\n, __func__);
+   return -1;
+   }
+
+   /* TODO(sjg@chromium,org): Should perhaps optimize this algorithm */
+   for (col = num_keys = bit = 0; col  config-matrix.num_cols;
+   col++) {
+   for (row = 0; row  config-matrix.num_rows; row++) {
+   unsigned int mask = 1  (bit  7);
+
+   data = scan.data[bit / 8];
+   if ((data  mask)  num_keys  max_count) {
+   key = keys + num_keys++;
+   key-row = row;
+   key-col = col;
+ 

Re: [U-Boot] Pull request: u-boot-arm/master

2013-03-18 Thread Tom Rini
On Fri, Mar 15, 2013 at 11:01:12PM +0100, Albert ARIBAUD wrote:

 Hello Tom,
 
 Here is a PR for ARM. Note that doc/README.scrapyard will need a manual
 merge resolution due to ARM tree having a commit that reorders the
 headers and reformats the lines while mainline has a commit adding two
 new entries still in the older format.
 
 The following changes since commit
 fc959081d41aab2d6f4614c5fb3dd1b77ffcdcf4:
 
   x86: Enable CONFIG_OF_CONTROL on coreboot (2013-03-04 15:57:52 -0800)
 
 are available in the git repository at:
 
   git://git.denx.de/u-boot-arm master
 
 for you to fetch changes up to b27673ccbd3d5435319b5c09c3e7061f559f925d:
 
   Merge branch 'u-boot-tegra/master' into
   'u-boot-arm/master' (2013-03-15 20:50:43 +0100)
 
 
 
 Albert ARIBAUD (9):
   Merge 'u-boot-microblaze/mainline/arm' into 'u-boot-arm/master'
   Merge branch 'u-boot-ti/master' into 'u-boot-arm/master'
   Merge branch 'u-boot-atmel/master' into 'u-boot-arm/master'
   arm: omap: map u_boot_lists section to .sram
   Remove linker lists (LGAs) from SPL linker scripts
   arm: make __bss_start and __bss_end__ compiler-generated
   Refactor linker-generated arrays
   Merge branch 'u-boot-imx/master' into 'u-boot-arm/master'
   Merge branch 'u-boot-tegra/master' into 'u-boot-arm/master'
 
 Beno??t Th??baudeau (6):
   imx: mx6q DDR3 init: Fix tMRD
   imx: mx6q DDR3 init: Fix tXPR
   imx: mx6q DDR3 init: Fix SDE_to_RST
   imx: mx6q DDR3 init: Fix RST_to_CKE
   imx: mx6q DDR3 init: Fix MR0.PPD
   imx: mx6q DDR3 init: Benefit from available CL = 7
 
 Bo Shen (3):
   ARM: atmel: add at91sam9g20ek_2mmc nand boot support
   ARM: at91: change nand flash table
   ARM: at91sam9x5: Using CPU string directly
 
 Chase Maupin (3):
   am335x_evm: Add NAND environment variables
   am335x_evm: Add SPI environment variables
   am335x_evm: Add NET environment variables
 
 Enric Balletbo i Serra (7):
   OMAP3: igep00x0: use official board names.
   OMAP3: igep00x0: add missing include mach-types.h
   OMAP3: igep00x0: Add new IGEP COM PROTON.
   SPL: ONENAND: Fix some ONENAND related defines.
   SPL: ONENAND: Fix onenand_spl_load_image implementation.
   SPL: ONENAND: Support SPL to boot u-boot from OneNAND.
   OMAP3: Initialize gpmc if SPL_ONENAND_SUPPORT is enabled.
 
 Eric Nelson (8):
   i.MX6Q: mx6qsabre*: Configure to allow CONFIG_SYS_ALT_MEMTEST
   i.MX6: mx6qsabrelite: indent with tabs
   i.MX6: consolidate pad names for multi-CPU boards
   i.MX6: crm_regs: define CCM_CCGRx for use in board config files
   i.MX6: crm_regs: define IOMUXC_GPR4/6/7
   i.MX6DL: define IOMUX pads NANDF_CS1-3 for use as GPIO
   i.MX6: Add DDR controller registers
   Add Boundary Devices Nitrogen6X boards
 
 Fabio Estevam (6):
   mx6: Disable Power Down Bit of watchdog
   mx23evk: Remove CONFIG_SYS_BAUDRATE_TABLE
   mx23evk: Turn on caches
   common: cmd_sata: Fix usage text for 'sata init'
   mx6: Provide a structure for accessing HDMI registers
   nitrogen6x: Fix RAM size variable
 
 Fadil Berisha (2):
   mxs: timrot: Add support to i.MX23
   mxs: timrot: Rename local macros
 
 Howard Gray (1):
   omap3: mvblx: change console to ttyO0 and make silent by default.
 
 Ilya Yanok (4):
   spl: support for booting via usbeth
   am33xx: support for booting via usbeth
   am335x_evm: enable support for booting via USB
   doc/SPL/README.am335x-network: Document using ethernet (and USB)
 SPL
 
 Jesse Gilles (1):
   ARM: sam9x5: fix ethernet pins in MII mode
 
 Lars Poeschel (1):
   am33xx: pcm051: Remove wp pin mux for sd-card
 
 Lokesh Vutla (13):
   ARM: OMAP4+: emif: Detect SDRAM from SDRAM config register
   ARM: OMAP4+: Cleanup emif specific files
   ARM: OMAP4+: Make control module register structure generic
   ARM: OMAP5: Clean up iosettings code
   ARM: OMAP5: Add DDR changes required for OMAP543X ES2.0 SOCs
   ARM: OMAP5: srcomp: enable slew rate compensation cells after
 powerup arm: dra7xx: clock: Add the prcm changes
   arm: dra7xx: clock: Add the dplls data
   arm: dra7xx: Add control module changes
   arm: dra7xx: Add DDR related data for DRA752 ES1.0
   arm: dra7xx: Add board files for DRA7XX socs
   arm: dra7xx: Add dra7xx_evm build support
   arm: dra7xx: Add silicon id support for DRA752 soc
 
 Lucas Stach (7):
   tegra: usb: set USB_PORTS_MAX to correct value
   tegra: usb: make controller init functions more self contained
   tegra: usb: remove unneeded function parameter
   tegra: usb: move controller init into start_port
   tegra: usb: various small cleanups
   tegra: usb: move implementation into right directory
   tegra: usb: move [start|stop]_port into ehci_hcd_[init|stop]
 
 Marek Vasut (7):
   mxs: Reset the 

Re: [U-Boot] [RFC] Kbuild support for ARM FIT images

2013-03-18 Thread Russell King - ARM Linux
On Mon, Mar 18, 2013 at 05:36:53PM +0100, Pavel Machek wrote:
 On Fri 2013-02-22 08:00:44, Olof Johansson wrote:
  On Wed, Feb 20, 2013 at 07:37:10PM -0600, Joel A Fernandes wrote:
   Any comments on this approach? Is it better to merge mkfitsrc.sh with
   mkuboot.sh?
  
  I know this was discussed quite extensively yesterday, but here is my take 
  on
  it:
  
  Given the recent complications from multiplatform, we really saw a strong
  reason to _not_ do the final boot wrapping in the kernel build system.
  Produce the zImage and the DTB files, and have a surrounding script that
  bundles the two in a format that your particular device needs.
  
  Most distros have scripts to handle the make install step of a kernel 
  build.
  That's where this belongs, not in the actual build step.
 
 Not sure I agree here:
 
 1) zImage was designed to boot from floppy, without any kind of
 bootloader on i386

zImage on x86 != zImage on ARM.

They only share the fact that they're both compressed and self-extracting.

ARM has never supported any kind of floppy based boot - mainly because
floppies have never been executable like they are on x86; all that
previous boot loaders ever did was load the kernel into RAM using some
method and call address 0, with a data structure (formerly struct
params, later atags) at a fixed address, later passing that address to
the kernel.

The best floppies got was being able to run a script or load an executable
off the floppy under the ROM'd OS, and our zImage itself doesn't fit the
format required for that.

Our zImage has always been just a pure straight binary compressed kernel
format.  Nothing more.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 0/7] Add cros-ec protocol driver and enable it in smdk5250

2013-03-18 Thread Hung-ying Tyan
This patch series adds the drivers for the cros-ec protocol that is used to
communicate with the ChromeOS Embedded Controller (EC). The series also enables
its use in Google Snow based on smdk5250.

The series depends on the following patches:
1) http://patchwork.ozlabs.org/patch/217347 add dts file for Snow
2) mmc series: http://patchwork.ozlabs.org/patch/225008
3) power patches needed by one of the mmc patches
   http://patchwork.ozlabs.org/patch/220060 EXYNOS5: Add function to setup set 
ps hold
   http://patchwork.ozlabs.org/patch/220061 SMDK5250: Add PMIC voltage settings 
(needed by one of the mmc patches)
-
Changes in v2:
- Moved code from smdk5250.c (non-FDT) to exynos5-dt.c (FDT).
- Moved code from smdk5250.h to exynos5250-dt.h.
- Add gpio node to exynos5250.dtsi.
- Fixed warnings of exceeding 80 chars in a line.
- Added commit messages to each patch.
- Dropped the period from commit subjects.

Hung-ying Tyan (7):
  cros: add cros_ec driver
  cros: add I2C support for cros_ec
  cros: add SPI support for cros_ec
  cros: add LPC support for cros_ec
  cros: adds cros_ec keyboard driver
  cros: exynos: add cros-ec device nodes to exynos5250-snow.dts
  cros: enable cros-ec for smdk5250

 README  |5 +
 arch/arm/dts/exynos5250.dtsi|3 +
 board/samsung/dts/exynos5250-snow.dts   |   82 ++
 board/samsung/smdk5250/exynos5-dt.c |   45 +
 doc/device-tree-bindings/input/cros-ec-keyb.txt |   79 ++
 doc/device-tree-bindings/misc/cros-ec.txt   |   38 +
 doc/device-tree-bindings/spi/exynos-spi.txt |   55 +
 drivers/input/Makefile  |1 +
 drivers/input/cros_ec_keyb.c|  264 +
 drivers/misc/Makefile   |4 +
 drivers/misc/cros_ec.c  | 1304 
 drivers/misc/cros_ec_i2c.c  |  199 
 drivers/misc/cros_ec_lpc.c  |  283 +
 drivers/misc/cros_ec_spi.c  |  166 +++
 drivers/spi/exynos_spi.c|   22 +
 include/configs/exynos5250-dt.h |   10 +-
 include/cros_ec.h   |  449 +++
 include/cros_ec_message.h   |   44 +
 include/ec_commands.h   | 1440 +++
 include/fdtdec.h|2 +
 include/spi.h   |   16 +
 lib/fdtdec.c|2 +
 22 files changed, 4512 insertions(+), 1 deletion(-)
 create mode 100644 doc/device-tree-bindings/input/cros-ec-keyb.txt
 create mode 100644 doc/device-tree-bindings/misc/cros-ec.txt
 create mode 100644 doc/device-tree-bindings/spi/exynos-spi.txt
 create mode 100644 drivers/input/cros_ec_keyb.c
 create mode 100644 drivers/misc/cros_ec.c
 create mode 100644 drivers/misc/cros_ec_i2c.c
 create mode 100644 drivers/misc/cros_ec_lpc.c
 create mode 100644 drivers/misc/cros_ec_spi.c
 create mode 100644 include/cros_ec.h
 create mode 100644 include/cros_ec_message.h
 create mode 100644 include/ec_commands.h

-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] Pull request: u-boot-arm/master

2013-03-18 Thread Albert ARIBAUD
Hi Tom,

On Mon, 18 Mar 2013 13:06:06 -0400, Tom Rini tr...@ti.com wrote:

 I've merged, but not pushed this, with the following merge commit (I
 couldn't get a nice pretty print like last time):
 
 To try and explain this since diff-diffs are funny:
 - Consolidate around using __bss_end (so in a few new files, and a lot
   of changed files, add __bss_end not __bssend__ or similar).
 - Add hashes for PCIPPC2 / PCIPPC6 in scrapyard.
 - In tegra20, both CONFIG_SYS_GENERIC_BOARD and CONFIG_BOUNCE_BUFFER are
   set.
 
 commit cf0d1242c87217ba0ce5ecb2f87dfcd1b40b7892
 Merge: b5bec88 b27673c
 Author: Tom Rini tr...@ti.com
 Date:   Mon Mar 18 12:31:00 2013 -0400
 
 Merge branch 'master' of git://git.denx.de/u-boot-arm
 
 Albert's rework of the linker scripts conflicted with Simon's making
 everyone use __bss_end.  We also had a minor conflict over
 README.scrapyard being added to in mainline and enhanced in
 u-boot-arm/master with IDs for when stuff was removed.

This is ever so slightly incorrect regarding scrapyard: IDs are present
also in mainline. What ARM changes is, columns are aligned and the
order of headers is fixed wrt actual content.

Apart from that, all seems ok to me.

 Conflicts:
   arch/arm/cpu/ixp/u-boot.lds
   arch/arm/cpu/u-boot.lds
   arch/arm/lib/Makefile
   board/actux1/u-boot.lds
   board/actux2/u-boot.lds
   board/actux3/u-boot.lds
   board/dvlhost/u-boot.lds
   board/freescale/mx31ads/u-boot.lds
   doc/README.scrapyard
   include/configs/tegra-common.h
 
 Build tested for all of ARM and run-time tested on am335x_evm.
 
 Signed-off-by: Tom Rini tr...@ti.com
 
 diff --cc arch/arm/cpu/armv7/am33xx/u-boot-spl.lds
 index 000,69f6d48..b6a929f
 mode 00,100644..100644
 --- a/arch/arm/cpu/armv7/am33xx/u-boot-spl.lds
 +++ b/arch/arm/cpu/armv7/am33xx/u-boot-spl.lds
 @@@ -1,0 -1,67 +1,67 @@@
 + /*
 +  * (C) Copyright 2002
 +  * Gary Jennejohn, DENX Software Engineering, ga...@denx.de
 +  *
 +  * (C) Copyright 2010
 +  * Texas Instruments, www.ti.com
 +  *  Aneesh V ane...@ti.com
 +  *
 +  * See file CREDITS for list of people who contributed to this
 +  * project.
 +  *
 +  * This program is free software; you can redistribute it and/or
 +  * modify it under the terms of the GNU General Public License as
 +  * published by the Free Software Foundation; either version 2 of
 +  * the License, or (at your option) any later version.
 +  *
 +  * This program is distributed in the hope that it will be useful,
 +  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 +  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 +  * GNU General Public License for more details.
 +  *
 +  * You should have received a copy of the GNU General Public License
 +  * along with this program; if not, write to the Free Software
 +  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 +  * MA 02111-1307 USA
 +  */
 + 
 + MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE,\
 + LENGTH = CONFIG_SPL_MAX_SIZE }
 + MEMORY { .sdram : ORIGIN = CONFIG_SPL_BSS_START_ADDR, \
 + LENGTH = CONFIG_SPL_BSS_MAX_SIZE }
 + 
 + OUTPUT_FORMAT(elf32-littlearm, elf32-littlearm, elf32-littlearm)
 + OUTPUT_ARCH(arm)
 + ENTRY(_start)
 + SECTIONS
 + {
 + .text  :
 + {
 + __start = .;
 + arch/arm/cpu/armv7/start.o  (.text)
 + *(.text*)
 + } .sram
 + 
 + . = ALIGN(4);
 + .rodata : { *(SORT_BY_ALIGNMENT(.rodata*)) } .sram
 + 
 + . = ALIGN(4);
 + .data : { *(SORT_BY_ALIGNMENT(.data*)) } .sram
 + 
 + .u_boot_list : {
 + KEEP(*(SORT(.u_boot_list*)));
 + } .sram
 + 
 + . = ALIGN(4);
 + __image_copy_end = .;
 + _end = .;
 + 
 + .bss :
 + {
 + . = ALIGN(4);
 + __bss_start = .;
 + *(.bss*)
 + . = ALIGN(4);
  -__bss_end__ = .;
 ++__bss_end = .;
 + } .sdram
 + }
 diff --cc arch/arm/cpu/ixp/u-boot.lds
 index 2c823e1,5e66dd1..8345b55
 --- a/arch/arm/cpu/ixp/u-boot.lds
 +++ b/arch/arm/cpu/ixp/u-boot.lds
 @@@ -67,11 -67,17 +67,17 @@@ SECTION
   
   _end = .;
   
 - .bss __rel_dyn_start (OVERLAY) : {
 - __bss_start = .;
 + .bss_start __rel_dyn_start (OVERLAY) : {
 + KEEP(*(.__bss_start));
 + }
 + 
 + .bss __bss_start (OVERLAY) : {
   *(.bss*)
. = ALIGN(4);
 - __bss_end = .;
  - ___bssend___ = .;
 ++ __bss_end = .;
 + }
  -.bss_end ___bssend___ (OVERLAY) : {
  -KEEP(*(.__bss_end__));
 ++.bss_end __bss_end (OVERLAY) : {
 ++KEEP(*(__bss_end));
   }
   
   /DISCARD/ : { *(.dynstr*) }
 diff --cc arch/arm/cpu/u-boot-spl.lds
 index 000,8321afb..3c0d99c
 mode 00,100644..100644
 --- a/arch/arm/cpu/u-boot-spl.lds
 +++ b/arch/arm/cpu/u-boot-spl.lds
 @@@ -1,0 -1,93 +1,93 @@@
 + /*
 +  * Copyright (c) 

Re: [U-Boot] [RFC] Kbuild support for ARM FIT images

2013-03-18 Thread Pavel Machek
On Mon 2013-03-18 16:44:26, Russell King - ARM Linux wrote:
 On Mon, Mar 18, 2013 at 05:36:53PM +0100, Pavel Machek wrote:
  On Fri 2013-02-22 08:00:44, Olof Johansson wrote:
   On Wed, Feb 20, 2013 at 07:37:10PM -0600, Joel A Fernandes wrote:
Any comments on this approach? Is it better to merge mkfitsrc.sh with
mkuboot.sh?
   
   I know this was discussed quite extensively yesterday, but here is my 
   take on
   it:
   
   Given the recent complications from multiplatform, we really saw a strong
   reason to _not_ do the final boot wrapping in the kernel build system.
   Produce the zImage and the DTB files, and have a surrounding script that
   bundles the two in a format that your particular device needs.
   
   Most distros have scripts to handle the make install step of a kernel 
   build.
   That's where this belongs, not in the actual build step.
  
  Not sure I agree here:
  
  1) zImage was designed to boot from floppy, without any kind of
  bootloader on i386
 
 zImage on x86 != zImage on ARM.
 
 They only share the fact that they're both compressed and self-extracting.
 
 ARM has never supported any kind of floppy based boot - mainly because
 floppies have never been executable like they are on x86; all that
 previous boot loaders ever did was load the kernel into RAM using
 some

Yes, I know. That's why I said on i386. 

What I wanted to say is that kernel build traditionaly produced
something useful, something bootloader can actually boot. Currently,
make uImage produces u-boot image. Please keep that capability.
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC] Kbuild support for ARM FIT images

2013-03-18 Thread Pavel Machek
On Mon 2013-03-18 17:57:46, Russell King - ARM Linux wrote:
 On Mon, Mar 18, 2013 at 06:49:32PM +0100, Pavel Machek wrote:
  What I wanted to say is that kernel build traditionaly produced
  something useful, something bootloader can actually boot. Currently,
  make uImage produces u-boot image. Please keep that capability.
 
 Unfortunately, there is a fundamental problem with uImage.  It encodes
 the load address, and that is utterly incompatible with the goal of
 having a kernel image which boots on multiple platforms.
 
 uImage isn't going anywhere for the time being, but you will find
 that:
 
 a) recent kernels will just wrap the zImage without a DTB, so
appended DTBs can't be used with it
 b) it won't work with MULTIPLATFORM-enabled kernels, unless you
provide make with a LOADADDR= argument to tell it where the
uImage is to be loaded - which is platform specific.
 
 (b) fundamentally can't be solved in kbuild.  If you want to use
 uImage with multiple platforms from the same zImage, then you need
 to generate multiple uImage files with different load addresses.
 That's purely - and solely - down to the dysfunctional uImage format.

I know. uImage is not perfect. But solution should be adopt a better
format (ARM FIT?), not drop support for making useful images
altogether as Olof proposed before.
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC] Kbuild support for ARM FIT images

2013-03-18 Thread Stephen Warren
On 03/18/2013 12:04 PM, Pavel Machek wrote:
 On Mon 2013-03-18 17:57:46, Russell King - ARM Linux wrote:
 On Mon, Mar 18, 2013 at 06:49:32PM +0100, Pavel Machek wrote:
 What I wanted to say is that kernel build traditionaly produced
 something useful, something bootloader can actually boot. Currently,
 make uImage produces u-boot image. Please keep that capability.

 Unfortunately, there is a fundamental problem with uImage.  It encodes
 the load address, and that is utterly incompatible with the goal of
 having a kernel image which boots on multiple platforms.

 uImage isn't going anywhere for the time being, but you will find
 that:

 a) recent kernels will just wrap the zImage without a DTB, so
appended DTBs can't be used with it
 b) it won't work with MULTIPLATFORM-enabled kernels, unless you
provide make with a LOADADDR= argument to tell it where the
uImage is to be loaded - which is platform specific.

 (b) fundamentally can't be solved in kbuild.  If you want to use
 uImage with multiple platforms from the same zImage, then you need
 to generate multiple uImage files with different load addresses.
 That's purely - and solely - down to the dysfunctional uImage format.
 
 I know. uImage is not perfect. But solution should be adopt a better
 format (ARM FIT?), not drop support for making useful images
 altogether as Olof proposed before.

Raw zImage /is/ the useful format that should be adopted.

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PULL] u-boot-usb/master

2013-03-18 Thread Marek Vasut
Hi Tom,

fixed, see new PR below please. Sorry about that, it's quite a load of stuff on 
me recently.

The following changes since commit b5bec88434adb52413f1bc33fa63d7642cb8fd35:

  Use 'unsigned int' for global_data's baudrate (2013-03-15 16:14:02 -0400)

are available in the git repository at:

  git://git.denx.de/u-boot-usb.git master

for you to fetch changes up to ae003d057077d792c1f2131753a7596c94e0bba4:

  usb: Add multiple controllers support for EHCI PCI (2013-03-18 18:58:55 +0100)


Lukasz Majewski (4):
  usb:composite:fix Provide function data when addressing device with only 
one interface
  usb:composite: USB Mass Storage - storage_common.c from Linux kernel
  usb:gadget: USB Mass Storage Gadget support
  arm:trats: Use new ums command

Michael Spang (1):
  usb: usbeth: smsc95xx: remove EEPROM loaded check

Pantelis Antoniou (5):
  dfu: Only perform DFU board_usb_init() for TRATS
  dfu: Fix crash when wrong number of arguments given
  dfu: Properly zero out timeout value
  dfu: Add a partition type target
  usb: Fix bug when both DFU  ETHER are defined

Patrick Georgi (1):
  usb: ehci: Support interrupt transfers via periodic list

Piotr Wilczek (1):
  usb:composite: USB Mass Storage - f_mass_storage.c from Linux kernel

Shiraz Hashim (1):
  usbtty: adapt buffers for large packet support

Simon Glass (1):
  x86: Enable USB features for coreboot

Vincent Palatin (4):
  usb: ehci: generic PCI support
  usb: ehci: Add 64-bit controller support
  usb: ehci: Fix aliasing issue in EHCI interrupt code
  usb: Add multiple controllers support for EHCI PCI

Vipin Kumar (1):
  usb/host/ehci: Add support for EHCI on spear

Vivek Gautam (2):
  usb: ehci: exynos: Fix multiple FDT decode
  usb: ehci: exynos: Enable non-dt path

 board/samsung/trats/trats.c |   63 ++
 common/Makefile |1 +
 common/cmd_dfu.c|5 +-
 common/cmd_usb_mass_storage.c   |   86 +++
 drivers/dfu/dfu_mmc.c   |   31 +
 drivers/serial/usbtty.c |2 +-
 drivers/usb/eth/smsc95xx.c  |4 -
 drivers/usb/gadget/Makefile |   10 +-
 drivers/usb/gadget/composite.c  |   19 +
 drivers/usb/gadget/f_dfu.c  |3 +
 drivers/usb/gadget/f_mass_storage.c | 2793 

 drivers/usb/gadget/g_dnl.c  |6 +
 drivers/usb/gadget/storage_common.c |  653 
 drivers/usb/host/Makefile   |1 +
 drivers/usb/host/ehci-exynos.c  |   51 +-
 drivers/usb/host/ehci-hcd.c |  318 +-
 drivers/usb/host/ehci-pci.c |   60 +-
 drivers/usb/host/ehci-spear.c   |   59 ++
 drivers/usb/host/ehci.h |6 +-
 include/configs/coreboot.h  |   17 +
 include/configs/trats.h |5 +
 include/usb_mass_storage.h  |   55 ++
 include/usbdevice.h |4 +-
 23 files changed, 4203 insertions(+), 49 deletions(-)
 create mode 100644 common/cmd_usb_mass_storage.c
 create mode 100644 drivers/usb/gadget/f_mass_storage.c
 create mode 100644 drivers/usb/gadget/storage_common.c
 create mode 100644 drivers/usb/host/ehci-spear.c
 create mode 100644 include/usb_mass_storage.h
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC] Kbuild support for ARM FIT images

2013-03-18 Thread Tom Rini
On Mon, Mar 18, 2013 at 05:36:53PM +0100, Pavel Machek wrote:
 On Fri 2013-02-22 08:00:44, Olof Johansson wrote:
  On Wed, Feb 20, 2013 at 07:37:10PM -0600, Joel A Fernandes wrote:
   Any comments on this approach? Is it better to merge mkfitsrc.sh with
   mkuboot.sh?
  
  I know this was discussed quite extensively yesterday, but here is my take 
  on
  it:
  
  Given the recent complications from multiplatform, we really saw a strong
  reason to _not_ do the final boot wrapping in the kernel build system.
  Produce the zImage and the DTB files, and have a surrounding script that
  bundles the two in a format that your particular device needs.
  
  Most distros have scripts to handle the make install step of a kernel 
  build.
  That's where this belongs, not in the actual build step.
 
 Not sure I agree here:

Lets try and stop this again here.  I think perhaps the KVM tool example
is instructive here.  For the various reasons that close association
with the kernel can be helpful for things (the exposure and ease of
being found), it would be nice if the tooling to expand single kernel
image into single bootable image was with the kernel.  But it's not a
requirement.  And it's not even necessarily the best for the tooling
either.  So, lets drop the idea of getting this into the kernel and if
people really do wish to extend FIT such that we can easily spit out a
FIT image that works on omap* and tegra* or what have you, and add a FIT
parser to GRUB, great, get to work.  No need to be tied to the kernel
for this.

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] Pull request: u-boot-arm/master

2013-03-18 Thread Tom Rini
On Mon, Mar 18, 2013 at 06:43:00PM +0100, Albert ARIBAUD wrote:
 Hi Tom,
 
 On Mon, 18 Mar 2013 13:06:06 -0400, Tom Rini tr...@ti.com wrote:
 
  I've merged, but not pushed this, with the following merge commit (I
  couldn't get a nice pretty print like last time):
  
  To try and explain this since diff-diffs are funny:
  - Consolidate around using __bss_end (so in a few new files, and a lot
of changed files, add __bss_end not __bssend__ or similar).
  - Add hashes for PCIPPC2 / PCIPPC6 in scrapyard.
  - In tegra20, both CONFIG_SYS_GENERIC_BOARD and CONFIG_BOUNCE_BUFFER are
set.
  
  commit cf0d1242c87217ba0ce5ecb2f87dfcd1b40b7892
  Merge: b5bec88 b27673c
  Author: Tom Rini tr...@ti.com
  Date:   Mon Mar 18 12:31:00 2013 -0400
  
  Merge branch 'master' of git://git.denx.de/u-boot-arm
  
  Albert's rework of the linker scripts conflicted with Simon's making
  everyone use __bss_end.  We also had a minor conflict over
  README.scrapyard being added to in mainline and enhanced in
  u-boot-arm/master with IDs for when stuff was removed.
 
 This is ever so slightly incorrect regarding scrapyard: IDs are present
 also in mainline. What ARM changes is, columns are aligned and the
 order of headers is fixed wrt actual content.
 
 Apart from that, all seems ok to me.
 
  Conflicts:
  arch/arm/cpu/ixp/u-boot.lds
  arch/arm/cpu/u-boot.lds
  arch/arm/lib/Makefile
  board/actux1/u-boot.lds
  board/actux2/u-boot.lds
  board/actux3/u-boot.lds
  board/dvlhost/u-boot.lds
  board/freescale/mx31ads/u-boot.lds
  doc/README.scrapyard
  include/configs/tegra-common.h
  
  Build tested for all of ARM and run-time tested on am335x_evm.
  
  Signed-off-by: Tom Rini tr...@ti.com
  
  diff --cc arch/arm/cpu/armv7/am33xx/u-boot-spl.lds
  index 000,69f6d48..b6a929f
  mode 00,100644..100644
  --- a/arch/arm/cpu/armv7/am33xx/u-boot-spl.lds
  +++ b/arch/arm/cpu/armv7/am33xx/u-boot-spl.lds
  @@@ -1,0 -1,67 +1,67 @@@
  + /*
  +  * (C) Copyright 2002
  +  * Gary Jennejohn, DENX Software Engineering, ga...@denx.de
  +  *
  +  * (C) Copyright 2010
  +  * Texas Instruments, www.ti.com
  +  *Aneesh V ane...@ti.com
  +  *
  +  * See file CREDITS for list of people who contributed to this
  +  * project.
  +  *
  +  * This program is free software; you can redistribute it and/or
  +  * modify it under the terms of the GNU General Public License as
  +  * published by the Free Software Foundation; either version 2 of
  +  * the License, or (at your option) any later version.
  +  *
  +  * This program is distributed in the hope that it will be useful,
  +  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  +  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  +  * GNU General Public License for more details.
  +  *
  +  * You should have received a copy of the GNU General Public License
  +  * along with this program; if not, write to the Free Software
  +  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  +  * MA 02111-1307 USA
  +  */
  + 
  + MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE,\
  +   LENGTH = CONFIG_SPL_MAX_SIZE }
  + MEMORY { .sdram : ORIGIN = CONFIG_SPL_BSS_START_ADDR, \
  +   LENGTH = CONFIG_SPL_BSS_MAX_SIZE }
  + 
  + OUTPUT_FORMAT(elf32-littlearm, elf32-littlearm, elf32-littlearm)
  + OUTPUT_ARCH(arm)
  + ENTRY(_start)
  + SECTIONS
  + {
  +   .text  :
  +   {
  +   __start = .;
  +   arch/arm/cpu/armv7/start.o  (.text)
  +   *(.text*)
  +   } .sram
  + 
  +   . = ALIGN(4);
  +   .rodata : { *(SORT_BY_ALIGNMENT(.rodata*)) } .sram
  + 
  +   . = ALIGN(4);
  +   .data : { *(SORT_BY_ALIGNMENT(.data*)) } .sram
  + 
  +   .u_boot_list : {
  +   KEEP(*(SORT(.u_boot_list*)));
  +   } .sram
  + 
  +   . = ALIGN(4);
  +   __image_copy_end = .;
  +   _end = .;
  + 
  +   .bss :
  +   {
  +   . = ALIGN(4);
  +   __bss_start = .;
  +   *(.bss*)
  +   . = ALIGN(4);
   -  __bss_end__ = .;
  ++  __bss_end = .;
  +   } .sdram
  + }
  diff --cc arch/arm/cpu/ixp/u-boot.lds
  index 2c823e1,5e66dd1..8345b55
  --- a/arch/arm/cpu/ixp/u-boot.lds
  +++ b/arch/arm/cpu/ixp/u-boot.lds
  @@@ -67,11 -67,17 +67,17 @@@ SECTION

  _end = .;

  -   .bss __rel_dyn_start (OVERLAY) : {
  -   __bss_start = .;
  +   .bss_start __rel_dyn_start (OVERLAY) : {
  +   KEEP(*(.__bss_start));
  +   }
  + 
  +   .bss __bss_start (OVERLAY) : {
  *(.bss*)
   . = ALIGN(4);
  -   __bss_end = .;
   -   ___bssend___ = .;
  ++   __bss_end = .;
  +   }
   -  .bss_end ___bssend___ (OVERLAY) : {
   -  KEEP(*(.__bss_end__));
  ++  .bss_end __bss_end (OVERLAY) : {
  ++  KEEP(*(__bss_end));
  }

  /DISCARD/ : { *(.dynstr*) }
  diff --cc 

Re: [U-Boot] [PULL] u-boot-usb/master

2013-03-18 Thread Tom Warren
No worries.

 -Original Message-
 From: Marek Vasut [mailto:ma...@denx.de]
 Sent: Monday, March 18, 2013 11:01 AM
 To: Tom Warren
 Cc: u-boot@lists.denx.de; Lucas Stach; Albert ARIBAUD; Tom Rini; Wolfgang
 Denk
 Subject: Re: [U-Boot] [PULL] u-boot-usb/master
 
 Hi Tom,
 
 fixed, see new PR below please. Sorry about that, it's quite a load of stuff 
 on
 me recently.
 
 The following changes since commit
 b5bec88434adb52413f1bc33fa63d7642cb8fd35:
 
   Use 'unsigned int' for global_data's baudrate (2013-03-15 16:14:02 -0400)
 
 are available in the git repository at:
 
   git://git.denx.de/u-boot-usb.git master
 
 for you to fetch changes up to
 ae003d057077d792c1f2131753a7596c94e0bba4:
 
   usb: Add multiple controllers support for EHCI PCI (2013-03-18 18:58:55
 +0100)
 
 
 Lukasz Majewski (4):
   usb:composite:fix Provide function data when addressing device with only
 one interface
   usb:composite: USB Mass Storage - storage_common.c from Linux kernel
   usb:gadget: USB Mass Storage Gadget support
   arm:trats: Use new ums command
 
 Michael Spang (1):
   usb: usbeth: smsc95xx: remove EEPROM loaded check
 
 Pantelis Antoniou (5):
   dfu: Only perform DFU board_usb_init() for TRATS
   dfu: Fix crash when wrong number of arguments given
   dfu: Properly zero out timeout value
   dfu: Add a partition type target
   usb: Fix bug when both DFU  ETHER are defined
 
 Patrick Georgi (1):
   usb: ehci: Support interrupt transfers via periodic list
 
 Piotr Wilczek (1):
   usb:composite: USB Mass Storage - f_mass_storage.c from Linux kernel
 
 Shiraz Hashim (1):
   usbtty: adapt buffers for large packet support
 
 Simon Glass (1):
   x86: Enable USB features for coreboot
 
 Vincent Palatin (4):
   usb: ehci: generic PCI support
   usb: ehci: Add 64-bit controller support
   usb: ehci: Fix aliasing issue in EHCI interrupt code
   usb: Add multiple controllers support for EHCI PCI
 
 Vipin Kumar (1):
   usb/host/ehci: Add support for EHCI on spear
 
 Vivek Gautam (2):
   usb: ehci: exynos: Fix multiple FDT decode
   usb: ehci: exynos: Enable non-dt path
 
  board/samsung/trats/trats.c |   63 ++
  common/Makefile |1 +
  common/cmd_dfu.c|5 +-
  common/cmd_usb_mass_storage.c   |   86 +++
  drivers/dfu/dfu_mmc.c   |   31 +
  drivers/serial/usbtty.c |2 +-
  drivers/usb/eth/smsc95xx.c  |4 -
  drivers/usb/gadget/Makefile |   10 +-
  drivers/usb/gadget/composite.c  |   19 +
  drivers/usb/gadget/f_dfu.c  |3 +
  drivers/usb/gadget/f_mass_storage.c | 2793
 ++
 ++
  drivers/usb/gadget/g_dnl.c  |6 +
  drivers/usb/gadget/storage_common.c |  653 
  drivers/usb/host/Makefile   |1 +
  drivers/usb/host/ehci-exynos.c  |   51 +-
  drivers/usb/host/ehci-hcd.c |  318 +-
  drivers/usb/host/ehci-pci.c |   60 +-
  drivers/usb/host/ehci-spear.c   |   59 ++
  drivers/usb/host/ehci.h |6 +-
  include/configs/coreboot.h  |   17 +
  include/configs/trats.h |5 +
  include/usb_mass_storage.h  |   55 ++
  include/usbdevice.h |4 +-
  23 files changed, 4203 insertions(+), 49 deletions(-)  create mode 100644
 common/cmd_usb_mass_storage.c  create mode 100644
 drivers/usb/gadget/f_mass_storage.c
  create mode 100644 drivers/usb/gadget/storage_common.c
  create mode 100644 drivers/usb/host/ehci-spear.c  create mode 100644
 include/usb_mass_storage.h
---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 00/13] tegra114 SPI driver

2013-03-18 Thread Tom Warren
Allen,

 -Original Message-
 From: Allen Martin [mailto:amar...@nvidia.com]
 Sent: Saturday, March 16, 2013 9:58 PM
 To: Tom Warren; swar...@wwwdotorg.org; s...@chromium.org
 Cc: u-boot@lists.denx.de; Allen Martin
 Subject: [PATCH v2 00/13] tegra114 SPI driver
 
 This series pulls fdt functionality from the existing tegra20 and
 tegra30 SPI drivers into a new common fdt SPI driver front end, then adds a
 new tegra114 SPI driver as an additional client of the fdt SPI driver.

Applies cleanly to current u-boot-tegra/next. All Tegra boards build OK.
Tested on Seaboard, Cardhu and Dalmore AOK (no more 'sf' or 'sspi' on Seaboard).

For the series:
Tested-by: Tom Warren twar...@nvidia.com

I'll apply this to u-boot-tegra/next under the assumption that it won't require 
any more work.

Thanks,

Tom
 
 Changes in v2:
  - Added a patch to remove SPI/UART switch support, this was only
useful for seaboard, which was never manufactured
  - Renamed tegra_sflash and tegra_slink to tegra20_sflash and
tegra20_slink
  - Moved SPI register definitions from header files into SPI driver
files, since those are the only users of those registers.
  - Removed patch to add CAR node to dt, equivalent patch was already
upstreamed.
 
 Allen Martin (13):
   tegra: remove support for UART SPI switch
   tegra: spi: rename tegra SPI drivers
   tegra: spi: remove non fdt support
   tegra: spi: pull register structs out of headers
   tegra20: spi: move fdt probe to spi_init
   spi: add common fdt SPI driver interface
   sf: winbond: add W25Q32DW
   tegra114: fdt: add compatible string for tegra114 SPI ctrl
   tegra114: fdt: add apbdma block
   tegra114: fdt: add SPI blocks
   tegra114: dalmore: fdt: enable dalmore SPI controller
   tegra114: add SPI driver
   tegra114: dalmore: config: enable SPI
 
  arch/arm/dts/tegra114.dtsi |  109 ++
  arch/arm/include/asm/arch-tegra/board.h|3 +-
  arch/arm/include/asm/arch-tegra/tegra_slink.h  |   84 
  arch/arm/include/asm/arch-tegra/tegra_spi.h|   75 
  arch/arm/include/asm/arch-tegra114/tegra114_spi.h  |   41 ++
  arch/arm/include/asm/arch-tegra20/tegra20_sflash.h |   41 ++
  arch/arm/include/asm/arch-tegra20/tegra20_slink.h  |   41 ++
  .../arm/include/asm/arch-tegra20/uart-spi-switch.h |   46 ---
  board/nvidia/common/board.c|5 +-
  board/nvidia/common/common.mk  |1 -
  board/nvidia/common/uart-spi-switch.c  |  125 --
  board/nvidia/dts/tegra114-dalmore.dts  |5 +
  board/nvidia/seaboard/seaboard.c   |2 +-
  drivers/mtd/spi/winbond.c  |5 +
  drivers/spi/Makefile   |6 +-
  drivers/spi/fdt_spi.c  |  186 +
  drivers/spi/tegra114_spi.c |  405 
 
  drivers/spi/{tegra_spi.c = tegra20_sflash.c}  |  215 ++-
  drivers/spi/{tegra_slink.c = tegra20_slink.c} |  128 ---
  include/configs/cardhu.h   |2 +-
  include/configs/dalmore.h  |   11 +
  include/configs/tegra-common-post.h|4 +
  include/configs/trimslice.h|2 +-
  include/fdtdec.h   |1 +
  lib/fdtdec.c   |1 +
  25 files changed, 1054 insertions(+), 490 deletions(-)  delete mode 100644
 arch/arm/include/asm/arch-tegra/tegra_slink.h
  delete mode 100644 arch/arm/include/asm/arch-tegra/tegra_spi.h
  create mode 100644 arch/arm/include/asm/arch-tegra114/tegra114_spi.h
  create mode 100644 arch/arm/include/asm/arch-tegra20/tegra20_sflash.h
  create mode 100644 arch/arm/include/asm/arch-tegra20/tegra20_slink.h
  delete mode 100644 arch/arm/include/asm/arch-tegra20/uart-spi-switch.h
  delete mode 100644 board/nvidia/common/uart-spi-switch.c
  create mode 100644 drivers/spi/fdt_spi.c  create mode 100644
 drivers/spi/tegra114_spi.c  rename drivers/spi/{tegra_spi.c =
 tegra20_sflash.c} (57%)  rename drivers/spi/{tegra_slink.c = tegra20_slink.c}
 (72%)
 
 --
 1.7.10.4

---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC] Kbuild support for ARM FIT images

2013-03-18 Thread Russell King - ARM Linux
On Mon, Mar 18, 2013 at 06:49:32PM +0100, Pavel Machek wrote:
 What I wanted to say is that kernel build traditionaly produced
 something useful, something bootloader can actually boot. Currently,
 make uImage produces u-boot image. Please keep that capability.

Unfortunately, there is a fundamental problem with uImage.  It encodes
the load address, and that is utterly incompatible with the goal of
having a kernel image which boots on multiple platforms.

uImage isn't going anywhere for the time being, but you will find
that:

a) recent kernels will just wrap the zImage without a DTB, so
   appended DTBs can't be used with it
b) it won't work with MULTIPLATFORM-enabled kernels, unless you
   provide make with a LOADADDR= argument to tell it where the
   uImage is to be loaded - which is platform specific.

(b) fundamentally can't be solved in kbuild.  If you want to use
uImage with multiple platforms from the same zImage, then you need
to generate multiple uImage files with different load addresses.
That's purely - and solely - down to the dysfunctional uImage format.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC] Kbuild support for ARM FIT images

2013-03-18 Thread Wolfgang Denk
Dear Russell,

In message 20130318175746.gj30...@n2100.arm.linux.org.uk you wrote:

 Unfortunately, there is a fundamental problem with uImage.  It encodes
 the load address, and that is utterly incompatible with the goal of
 having a kernel image which boots on multiple platforms.

I'm not sure if you are aware that U-Boot supports uImages that can be
run from _any_ load address (using the IH_TYPE_KERNEL_NOLOAD image
type).  If anybody was willing to keep uImage support in the kernel
this would probably be a convenient way to go.

But in any case, the uImage format is deprecated.  Support for FIT
images was added more than five years ago, and new developments should
rather focus on supporting these.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk  Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC] Kbuild support for ARM FIT images

2013-03-18 Thread Wolfgang Denk
Dear Stephen,

In message 51475997.2060...@wwwdotorg.org you wrote:

 Raw zImage /is/ the useful format that should be adopted.

This one size fits all approch does fit everywhere.  There are a
number of users (including _big_ commercial ones, with _large_ numebrs
of systems in the field) that have simple requirements like:

- how can I find out if the image I just loaded to RAM in OK (OK
  maning some checksum is correct, or some crypto-key could be
  verified, or ...) ?

- how can I find out which version of image is installed on this
  device in the flash?  Can I print something like an ID string, or a
  build timestamp, etc?

etc. etc.

zImage may work well in many cases, but there are also many cases
where in image format that allows for additional meta-data is
mandatory.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk  Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
Minds are like parachutes - they only function when open.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC PATCH 14/44] image: Export fit_conf_get_prop_node()

2013-03-18 Thread Simon Glass
Hi Marek,

On Sat, Jan 5, 2013 at 12:12 AM, Marek Vasut ma...@denx.de wrote:
 Dear Simon Glass,

 This function will be needed by signature checking code, so export it,
 and also add docs.

 Signed-off-by: Simon Glass s...@chromium.org
 [...]

 +/**
 + * fit_conf_get_prop_node() - Get node refered to by a configuration
 + *
 + * The conf@ nodes contain references to other nodes, using properties
 + * like 'kernel = kernel@1'. Given such a property name (e.g. kernel),
 + * return the offset of the node referred to (e.g. offset of node
 + * /images/kernel@1.
 + *
 + * @fit: FIT to check
 + * @noffset: Offset of conf@xxx node to check
 + * @prop_name:   Property to read from the conf node

 This parameter list is swapped with the description.

Sorry, can you please explain that a bit more. I'm not sure what you
are pointing to.


 + */
 +int fit_conf_get_prop_node(const void *fit, int noffset,
 + const char *prop_name);
 +
  void fit_conf_print(const void *fit, int noffset, const char *p);

  int fit_check_ramdisk(const void *fit, int os_noffset,

 Best regards,
 Marek Vasut

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC PATCH 14/44] image: Export fit_conf_get_prop_node()

2013-03-18 Thread Marek Vasut
Dear Simon Glass,

 Hi Marek,
 
 On Sat, Jan 5, 2013 at 12:12 AM, Marek Vasut ma...@denx.de wrote:
  Dear Simon Glass,
  
  This function will be needed by signature checking code, so export it,
  and also add docs.
  
  Signed-off-by: Simon Glass s...@chromium.org
  
  [...]
  
  +/**
  + * fit_conf_get_prop_node() - Get node refered to by a configuration
  + *
  + * The conf@ nodes contain references to other nodes, using properties
  + * like 'kernel = kernel@1'. Given such a property name (e.g.
  kernel), + * return the offset of the node referred to (e.g. offset
  of node + * /images/kernel@1.
  + *
  + * @fit: FIT to check
  + * @noffset: Offset of conf@xxx node to check
  + * @prop_name:   Property to read from the conf node
  
  This parameter list is swapped with the description.
 
 Sorry, can you please explain that a bit more. I'm not sure what you
 are pointing to.

Tough question, especially if asked after such time ;-) I believe I meant the 
form of the comment should be like this:

/*
 * foo() - Do baz and bar
 * @parm1: Number of sharks with lasers
 * @parm2: Make the result even cooler
 *
 * Long boring description of the function doing baz and bar.
 */

I think it makes more sense to stick the function param explanation just 
underneath the function name, no?

  + */
  +int fit_conf_get_prop_node(const void *fit, int noffset,
  + const char *prop_name);
  +
  
   void fit_conf_print(const void *fit, int noffset, const char *p);
   
   int fit_check_ramdisk(const void *fit, int os_noffset,
  
  Best regards,
  Marek Vasut
 
 Regards,
 Simon

Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC PATCH 14/44] image: Export fit_conf_get_prop_node()

2013-03-18 Thread Simon Glass
Hi Marek,

On Mon, Mar 18, 2013 at 2:19 PM, Marek Vasut ma...@denx.de wrote:
 Dear Simon Glass,

 Hi Marek,

 On Sat, Jan 5, 2013 at 12:12 AM, Marek Vasut ma...@denx.de wrote:
  Dear Simon Glass,
 
  This function will be needed by signature checking code, so export it,
  and also add docs.
 
  Signed-off-by: Simon Glass s...@chromium.org
 
  [...]
 
  +/**
  + * fit_conf_get_prop_node() - Get node refered to by a configuration
  + *
  + * The conf@ nodes contain references to other nodes, using properties
  + * like 'kernel = kernel@1'. Given such a property name (e.g.
  kernel), + * return the offset of the node referred to (e.g. offset
  of node + * /images/kernel@1.
  + *
  + * @fit: FIT to check
  + * @noffset: Offset of conf@xxx node to check
  + * @prop_name:   Property to read from the conf node
 
  This parameter list is swapped with the description.

 Sorry, can you please explain that a bit more. I'm not sure what you
 are pointing to.

 Tough question, especially if asked after such time ;-) I believe I meant the
 form of the comment should be like this:

 /*
  * foo() - Do baz and bar
  * @parm1: Number of sharks with lasers
  * @parm2: Make the result even cooler
  *
  * Long boring description of the function doing baz and bar.
  */

 I think it makes more sense to stick the function param explanation just
 underneath the function name, no?

Aha I see, thank you.

Yes it has been a while - I feel people have had enough time to take a
look and raise questions and it is time for v2.

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 0/4] Tegra114: MMC: Add MMC driver for T114/Dalmore

2013-03-18 Thread Tom Warren
This patchset adds SDMMC device-tree support to the Tegra114 dts files,
and enables the Tegra MMC driver on Tegra114 Dalmore.

Tested on my Dalmore E1611 board, eMMC and SD-Card work fine, can load
a kernel off of a SD card OK, card detect works, and the env is now
stored in eMMC (end of the 2nd 'boot' sector, same as Tegra20/30).

Changes in v2:
- Remove SDIOCFG_HSM define, unused
- Remove I2C retries
- Change CONFIG_ENV_OFFSET to match Dalmore's eMMC chip boot part size
   
Tom Warren (4):
  Tegra114: fdt: Add SDMMC (sdhci) nodes for T114 boards (Dalmore for
now)
  Tegra114: Dalmore: Add SDIO3 pad config to pinctrl_config table
  Tegra114: MMC: Add SD bus power-rail init routine
  Tegra114: MMC: Enable DT MMC driver support for Tegra114 Dalmore
boards

 arch/arm/dts/tegra114.dtsi  | 32 
 arch/arm/include/asm/arch-tegra114/gp_padctrl.h |  6 +++
 board/nvidia/dalmore/dalmore.c  | 67 +
 board/nvidia/dalmore/pinmux-config-dalmore.h|  6 +++
 board/nvidia/dts/tegra114-dalmore.dts   | 13 +
 include/configs/dalmore.h   | 12 -
 6 files changed, 135 insertions(+), 1 deletion(-)

-- 
1.8.1.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 1/4] Tegra114: fdt: Add SDMMC (sdhci) nodes for T114 boards (Dalmore for now)

2013-03-18 Thread Tom Warren
Took these values directly from the kernel dts files.

Signed-off-by: Tom Warren twar...@nvidia.com
Reviewed-by: Stephen Warren swar...@nvidia.com
---
v2: No change

 arch/arm/dts/tegra114.dtsi| 32 
 board/nvidia/dts/tegra114-dalmore.dts | 13 +
 2 files changed, 45 insertions(+)

diff --git a/arch/arm/dts/tegra114.dtsi b/arch/arm/dts/tegra114.dtsi
index 3b1ca35..f86d18d 100644
--- a/arch/arm/dts/tegra114.dtsi
+++ b/arch/arm/dts/tegra114.dtsi
@@ -184,4 +184,36 @@
/* PERIPH_ID_SBC6, PLLP_OUT0 */
clocks = tegra_car 105;
};
+
+   sdhci@7800 {
+   compatible = nvidia,tegra114-sdhci, nvidia,tegra30-sdhci;
+   reg = 0x7800 0x200;
+   interrupts = 0 14 0x04;
+   clocks = tegra_car 14;
+   status = disable;
+   };
+
+   sdhci@78000200 {
+   compatible = nvidia,tegra114-sdhci, nvidia,tegra30-sdhci;
+   reg = 0x78000200 0x200;
+   interrupts = 0 15 0x04;
+   clocks = tegra_car 9;
+   status = disable;
+   };
+
+   sdhci@78000400 {
+   compatible = nvidia,tegra114-sdhci, nvidia,tegra30-sdhci;
+   reg = 0x78000400 0x200;
+   interrupts = 0 19 0x04;
+   clocks = tegra_car 69;
+   status = disable;
+   };
+
+   sdhci@78000600 {
+   compatible = nvidia,tegra114-sdhci, nvidia,tegra30-sdhci;
+   reg = 0x78000600 0x200;
+   interrupts = 0 31 0x04;
+   clocks = tegra_car 15;
+   status = disable;
+   };
 };
diff --git a/board/nvidia/dts/tegra114-dalmore.dts 
b/board/nvidia/dts/tegra114-dalmore.dts
index 87cb0ba..86e9459 100644
--- a/board/nvidia/dts/tegra114-dalmore.dts
+++ b/board/nvidia/dts/tegra114-dalmore.dts
@@ -12,6 +12,8 @@
i2c2 = /i2c@7000c400;
i2c3 = /i2c@7000c500;
i2c4 = /i2c@7000c700;
+   sdhci0 = /sdhci@78000600;
+   sdhci1 = /sdhci@78000400;
};
 
memory {
@@ -48,4 +50,15 @@
status = okay;
spi-max-frequency = 2500;
};
+
+   sdhci@78000400 {
+   cd-gpios = gpio 170 1; /* gpio PV2 */
+   bus-width = 4;
+   status = okay;
+   };
+
+   sdhci@78000600 {
+   bus-width = 8;
+   status = okay;
+   };
 };
-- 
1.8.1.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 2/4] Tegra114: Dalmore: Add SDIO3 pad config to pinctrl_config table

2013-03-18 Thread Tom Warren
SDIO1 (the SD-card slot on Dalmore) needs to have its pads setup
before the MMC driver is added.

Signed-off-by: Tom Warren twar...@nvidia.com
Reviewed-by: Stephen Warren swar...@nvidia.com
---
v2: Remove SDIOCFG_HSM define, unused.

 arch/arm/include/asm/arch-tegra114/gp_padctrl.h | 6 ++
 board/nvidia/dalmore/dalmore.c  | 4 
 board/nvidia/dalmore/pinmux-config-dalmore.h| 6 ++
 3 files changed, 16 insertions(+)

diff --git a/arch/arm/include/asm/arch-tegra114/gp_padctrl.h 
b/arch/arm/include/asm/arch-tegra114/gp_padctrl.h
index 1ef1a14..41ce677 100644
--- a/arch/arm/include/asm/arch-tegra114/gp_padctrl.h
+++ b/arch/arm/include/asm/arch-tegra114/gp_padctrl.h
@@ -74,4 +74,10 @@ struct apb_misc_gp_ctlr {
u32 aocfg0; /* 0x1AC: APB_MISC_GP_AOCFG0PADCTRL */
 };
 
+/* SDMMC1/3 settings from section 27.5 of T114 TRM */
+#define SDIOCFG_DRVUP_SLWF 0
+#define SDIOCFG_DRVDN_SLWR 0
+#define SDIOCFG_DRVUP  0x24
+#define SDIOCFG_DRVDN  0x14
+
 #endif /* _TEGRA114_GP_PADCTRL_H_ */
diff --git a/board/nvidia/dalmore/dalmore.c b/board/nvidia/dalmore/dalmore.c
index 2020a5f..7449b5b 100644
--- a/board/nvidia/dalmore/dalmore.c
+++ b/board/nvidia/dalmore/dalmore.c
@@ -16,6 +16,7 @@
 
 #include common.h
 #include asm/arch/pinmux.h
+#include asm/arch/gp_padctrl.h
 #include pinmux-config-dalmore.h
 
 /*
@@ -32,4 +33,7 @@ void pinmux_init(void)
 
pinmux_config_table(unused_pins_lowpower,
ARRAY_SIZE(unused_pins_lowpower));
+
+   /* Initialize any non-default pad configs (APB_MISC_GP regs) */
+   padgrp_config_table(dalmore_padctrl, ARRAY_SIZE(dalmore_padctrl));
 }
diff --git a/board/nvidia/dalmore/pinmux-config-dalmore.h 
b/board/nvidia/dalmore/pinmux-config-dalmore.h
index 3ef6f4e..8c05a15 100644
--- a/board/nvidia/dalmore/pinmux-config-dalmore.h
+++ b/board/nvidia/dalmore/pinmux-config-dalmore.h
@@ -361,4 +361,10 @@ static struct pingroup_config 
tegra114_pinmux_set_nontristate[] = {
 
DEFAULT_PINMUX(SDMMC3_CD_N, SDMMC3, UP,   NORMAL,   INPUT),
 };
+
+static struct padctrl_config dalmore_padctrl[] = {
+   /* (_padgrp, _slwf, _slwr, _drvup, _drvdn, _lpmd, _schmt, _hsm) */
+   DEFAULT_PADCFG(SDIO3, SDIOCFG_DRVUP_SLWF, SDIOCFG_DRVDN_SLWR, \
+   SDIOCFG_DRVUP, SDIOCFG_DRVDN, NONE, NONE, NONE),
+};
 #endif /* PINMUX_CONFIG_COMMON_H */
-- 
1.8.1.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 3/4] Tegra114: MMC: Add SD bus power-rail init routine

2013-03-18 Thread Tom Warren
T114 requires SD bus power-rail bringup for the SDIO card on SDMMC3.

Signed-off-by: Tom Warren twar...@nvidia.com
Reviewed-by: Stephen Warren swar...@nvidia.com
---
v2: Remove I2C retries

 board/nvidia/dalmore/dalmore.c | 62 ++
 1 file changed, 62 insertions(+)

diff --git a/board/nvidia/dalmore/dalmore.c b/board/nvidia/dalmore/dalmore.c
index 7449b5b..2c23a29 100644
--- a/board/nvidia/dalmore/dalmore.c
+++ b/board/nvidia/dalmore/dalmore.c
@@ -18,6 +18,10 @@
 #include asm/arch/pinmux.h
 #include asm/arch/gp_padctrl.h
 #include pinmux-config-dalmore.h
+#include i2c.h
+
+#define BAT_I2C_ADDRESS0x48/* TPS65090 charger */
+#define PMU_I2C_ADDRESS0x58/* TPS65913 PMU */
 
 /*
  * Routine: pinmux_init
@@ -37,3 +41,61 @@ void pinmux_init(void)
/* Initialize any non-default pad configs (APB_MISC_GP regs) */
padgrp_config_table(dalmore_padctrl, ARRAY_SIZE(dalmore_padctrl));
 }
+
+#if defined(CONFIG_TEGRA_MMC)
+/*
+ * Do I2C/PMU writes to bring up SD card bus power
+ *
+ */
+void board_sdmmc_voltage_init(void)
+{
+   uchar reg, data_buffer[1];
+   int ret;
+
+   ret = i2c_set_bus_num(0);/* PMU is on bus 0 */
+   if (ret)
+   printf(%s: i2c_set_bus_num returned %d\n, __func__, ret);
+
+   /* TPS65913: LDO9_VOLTAGE = 3.3V */
+   data_buffer[0] = 0x31;
+   reg = 0x61;
+
+   ret = i2c_write(PMU_I2C_ADDRESS, reg, 1, data_buffer, 1);
+   if (ret)
+   printf(%s: PMU i2c_write %02X-%02X returned %d\n,
+   __func__, reg, data_buffer[0], ret);
+
+   /* TPS65913: LDO9_CTRL = Active */
+   data_buffer[0] = 0x01;
+   reg = 0x60;
+
+   ret = i2c_write(PMU_I2C_ADDRESS, reg, 1, data_buffer, 1);
+   if (ret)
+   printf(%s: PMU i2c_write %02X-%02X returned %d\n,
+   __func__, reg, data_buffer[0], ret);
+
+   /* TPS65090: FET6_CTRL = enable output auto discharge, enable FET6 */
+   data_buffer[0] = 0x03;
+   reg = 0x14;
+
+   ret = i2c_write(BAT_I2C_ADDRESS, reg, 1, data_buffer, 1);
+   if (ret)
+   printf(%s: BAT i2c_write %02X-%02X returned %d\n,
+   __func__, reg, data_buffer[0], ret);
+}
+
+/*
+ * Routine: pin_mux_mmc
+ * Description: setup the MMC muxes, power rails, etc.
+ */
+void pin_mux_mmc(void)
+{
+   /*
+* NOTE: We don't do mmc-specific pin muxes here.
+* They were done globally in pinmux_init().
+*/
+
+   /* Bring up the SDIO3 power rail */
+   board_sdmmc_voltage_init();
+}
+#endif /* MMC */
-- 
1.8.1.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 4/4] Tegra114: MMC: Enable DT MMC driver support for Tegra114 Dalmore boards

2013-03-18 Thread Tom Warren
Tested on my Dalmore E1611 board, eMMC and SD-Card work fine, can load
a kernel off of an SD card OK, card detect works, and the env is now
stored in eMMC (end of the 2nd 'boot' sector, same as Tegra20/30).

Signed-off-by: Tom Warren twar...@nvidia.com
Reviewed-by: Stephen Warren swar...@nvidia.com
---
v2: Change CONFIG_ENV_OFFSET to match the size of Dalmore's eMMC chip

 include/configs/dalmore.h | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/configs/dalmore.h b/include/configs/dalmore.h
index c7deea5..3f4b70e 100644
--- a/include/configs/dalmore.h
+++ b/include/configs/dalmore.h
@@ -50,7 +50,17 @@
 #define CONFIG_SYS_I2C_SPEED   10
 #define CONFIG_CMD_I2C
 
-#define CONFIG_ENV_IS_NOWHERE
+/* SD/MMC */
+#define CONFIG_MMC
+#define CONFIG_GENERIC_MMC
+#define CONFIG_TEGRA_MMC
+#define CONFIG_CMD_MMC
+
+/* Environment in eMMC, at the end of 2nd boot sector */
+#define CONFIG_ENV_IS_IN_MMC
+#define CONFIG_SYS_MMC_ENV_DEV 0
+#define CONFIG_SYS_MMC_ENV_PART2
+#define CONFIG_ENV_OFFSET  (((4096 - 512) * 1024) - CONFIG_ENV_SIZE)
 
 #define MACH_TYPE_DALMORE  4304/* not yet in mach-types.h */
 
-- 
1.8.1.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 01/45] sandbox: config: Enable CONFIG_FIT and CONFIG_CMD_FIT

2013-03-18 Thread Simon Glass
Enable these options to use FITs on sandbox.

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2: None

 include/configs/sandbox.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index 406da43..67d788a 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -31,6 +31,8 @@
 #define CONFIG_OF_CONTROL
 #define CONFIG_OF_LIBFDT
 #define CONFIG_LMB
+#define CONFIG_FIT
+#define CONFIG_CMD_FDT
 
 #define CONFIG_FS_FAT
 #define CONFIG_FS_EXT4
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 02/45] bootstage: Don't build for HOSTCC

2013-03-18 Thread Simon Glass
We don't measure boot timing on the host, or with SPL, so use both
conditions in the bootstage header. This allows us to avoid using
conditional compilation around bootstage_...() calls. (#ifdef)

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2:
- Fix line continuation problem

 include/bootstage.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/bootstage.h b/include/bootstage.h
index 3b2216b..4df03ae 100644
--- a/include/bootstage.h
+++ b/include/bootstage.h
@@ -221,7 +221,7 @@ enum bootstage_id {
  */
 ulong timer_get_boot_us(void);
 
-#ifndef CONFIG_SPL_BUILD
+#if !defined(CONFIG_SPL_BUILD)  !defined(USE_HOSTCC)
 /*
  * Board code can implement show_boot_progress() if needed.
  *
@@ -233,7 +233,8 @@ void show_boot_progress(int val);
 #define show_boot_progress(val) do {} while (0)
 #endif
 
-#if defined(CONFIG_BOOTSTAGE)  !defined(CONFIG_SPL_BUILD)
+#if defined(CONFIG_BOOTSTAGE)  !defined(CONFIG_SPL_BUILD)  \
+   !defined(USE_HOSTCC)
 /* This is the full bootstage implementation */
 
 /**
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 06/45] image: Export fit_check_ramdisk()

2013-03-18 Thread Simon Glass
One we split out the FIT code from image.c we will need this function.
Export it in the header.

Signed-off-by: Simon Glass s...@chromium.org
Reviewed-by: Marek Vasut ma...@denx.de
---
Changes in v2: None

 common/image.c  | 9 ++---
 include/image.h | 3 +++
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/common/image.c b/common/image.c
index d01b8f6..af66138 100644
--- a/common/image.c
+++ b/common/image.c
@@ -49,14 +49,9 @@
 #include fdt_support.h
 #endif
 
-#if defined(CONFIG_FIT)
 #include u-boot/md5.h
 #include sha1.h
 
-static int fit_check_ramdisk(const void *fit, int os_noffset,
-   uint8_t arch, int verify);
-#endif
-
 #ifdef CONFIG_CMD_BDI
 extern int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const 
argv[]);
 #endif
@@ -3363,8 +3358,8 @@ void fit_conf_print(const void *fit, int noffset, const 
char *p)
  * 0, on failure
  */
 #ifndef USE_HOSTCC
-static int fit_check_ramdisk(const void *fit, int rd_noffset, uint8_t arch,
-   int verify)
+int fit_check_ramdisk(const void *fit, int rd_noffset, uint8_t arch,
+   int verify)
 {
fit_image_print(fit, rd_noffset,);
 
diff --git a/include/image.h b/include/image.h
index 32a961c..880ce07 100644
--- a/include/image.h
+++ b/include/image.h
@@ -632,6 +632,9 @@ int fit_conf_get_fdt_node(const void *fit, int noffset);
 
 void fit_conf_print(const void *fit, int noffset, const char *p);
 
+int fit_check_ramdisk(const void *fit, int os_noffset,
+   uint8_t arch, int verify);
+
 #ifndef USE_HOSTCC
 static inline int fit_image_check_target_arch(const void *fdt, int node)
 {
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 04/45] libfdt: Add fdt_next_subnode() to permit easy subnode iteration

2013-03-18 Thread Simon Glass
This allows use to replace code like this:

for (ndepth = 0, count = 0,
noffset = fdt_next_node(fit, images_noffset, ndepth);
 (noffset = 0)  (ndepth  0);
 noffset = fdt_next_node(fit, noffset, ndepth)) {
if (ndepth == 1)
...

with:

for (ndepth = 0,
noffset = fdt_next_subnode(fit, image_noffset, ndepth);
noffset = 0;
noffset = fdt_next_subnode(fit, noffset, ndepth)) {

which is slightly better, and doesn't require two levels of indentation for
code in the loop.

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2: None

 include/libfdt.h | 17 +
 lib/libfdt/fdt.c | 12 
 2 files changed, 29 insertions(+)

diff --git a/include/libfdt.h b/include/libfdt.h
index fc7f75b..50c90d6 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -136,6 +136,23 @@ uint32_t fdt_next_tag(const void *fdt, int offset, int 
*nextoffset);
 
 int fdt_next_node(const void *fdt, int offset, int *depth);
 
+/**
+ * fdt_next_subnode() - get offset of next direct child
+ *
+ * Set depth to 0, offset to parent, then call this function repeatedly
+ * to get direct subnodes of a parent node.
+ *
+ * @fdt:   FDT blob
+ * @offset:Set this to offset of parent for the first call. For
+ * subsquent calls, pass in the value returns from the last
+ * call.
+ * @depth: Used internally to monitor depth - set this to 0 for the
+ * first call.
+ * @return offset of next subnode, or -FDT_ERR_NOTFOUND if there are no more
+ * children
+ */
+int fdt_next_subnode(const void *fdt, int offset, int *depth);
+
 /**/
 /* General functions  */
 /**/
diff --git a/lib/libfdt/fdt.c b/lib/libfdt/fdt.c
index 387e354..cd86811 100644
--- a/lib/libfdt/fdt.c
+++ b/lib/libfdt/fdt.c
@@ -202,6 +202,18 @@ int fdt_next_node(const void *fdt, int offset, int *depth)
return offset;
 }
 
+int fdt_next_subnode(const void *fdt, int offset, int *depth)
+{
+   /* Loop until we find a direct child of the parent (depth == 1) */
+   do {
+   offset = fdt_next_node(fdt, offset, depth);
+   if (offset  0 || *depth  1)
+   return -FDT_ERR_NOTFOUND;
+   } while (*depth  1);
+
+   return offset;
+}
+
 const char *_fdt_find_string(const char *strtab, int tabsize, const char *s)
 {
int len = strlen(s) + 1;
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 17/45] sandbox: Add CONFIG_OF_HOSTFILE to read FDT from host file

2013-03-18 Thread Simon Glass
With sandbox it is tricky to add an FDT to the image at build time (or
later) since we build an ELF file, not a plain binary, and the address
space of the whole U-Boot is not accessible in the emulated memory map
of sandbox.

Sandbox can read files directly from the host, though, so add an option
to read an FDT from a host file on start-up.

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2:
- Fix checkpatch warnings about split strings
- Fix typo os defined - is defined
- Use gd-arch.ram_buf instead of gd-ram_buf (now that generic board is in)

 arch/sandbox/cpu/start.c |  7 +++
 arch/sandbox/include/asm/state.h |  1 +
 arch/sandbox/lib/board.c | 38 ++
 doc/README.fdt-control   |  6 +-
 include/configs/sandbox.h|  2 ++
 5 files changed, 49 insertions(+), 5 deletions(-)

diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index 5287fd5..2fcec8b 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -104,6 +104,13 @@ static int sb_cmdline_cb_command(struct sandbox_state 
*state, const char *arg)
 }
 SB_CMDLINE_OPT_SHORT(command, 'c', 1, Execute U-Boot command);
 
+static int sb_cmdline_cb_fdt(struct sandbox_state *state, const char *arg)
+{
+   state-fdt_fname = arg;
+   return 0;
+}
+SB_CMDLINE_OPT_SHORT(fdt, 'd', 1, Specify U-Boot's control FDT);
+
 int main(int argc, char *argv[])
 {
struct sandbox_state *state;
diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h
index 2b62b46..9552708 100644
--- a/arch/sandbox/include/asm/state.h
+++ b/arch/sandbox/include/asm/state.h
@@ -34,6 +34,7 @@ enum exit_type_id {
 /* The complete state of the test system */
 struct sandbox_state {
const char *cmd;/* Command to execute */
+   const char *fdt_fname;  /* Filename of FDT binary */
enum exit_type_id exit_type;/* How we exited U-Boot */
const char *parse_err;  /* Error to report from parsing */
int argc;   /* Program arguments */
diff --git a/arch/sandbox/lib/board.c b/arch/sandbox/lib/board.c
index 3752fab..7d12979 100644
--- a/arch/sandbox/lib/board.c
+++ b/arch/sandbox/lib/board.c
@@ -39,13 +39,15 @@
 
 #include common.h
 #include command.h
+#include fs.h
+#include fdtdec.h
 #include malloc.h
+#include os.h
 #include stdio_dev.h
 #include timestamp.h
 #include version.h
 #include serial.h
-
-#include os.h
+#include asm/state.h
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -89,6 +91,21 @@ static int display_dram_config(void)
return 0;
 }
 
+static int read_fdt_from_file(void)
+{
+   struct sandbox_state *state = state_get_current();
+   int size;
+
+   if (fs_set_blk_dev(host, NULL, FS_TYPE_SANDBOX))
+   return 1;
+   size = fs_read(state-fdt_fname, CONFIG_SYS_FDT_LOAD_ADDR, 0, 0);
+   if (size  0)
+   return 1;
+   gd-fdt_blob = map_sysmem(CONFIG_SYS_FDT_LOAD_ADDR, size);
+
+   return 0;
+}
+
 /*
  * Breathe some life into the board...
  *
@@ -127,6 +144,9 @@ init_fnc_t *init_sequence[] = {
 #if defined(CONFIG_ARCH_CPU_INIT)
arch_cpu_init,  /* basic arch cpu dependent setup */
 #endif
+#ifdef CONFIG_OF_CONTROL
+   fdtdec_check_fdt,
+#endif
 #if defined(CONFIG_BOARD_EARLY_INIT_F)
board_early_init_f,
 #endif
@@ -156,6 +176,11 @@ void board_init_f(ulong bootflag)
assert(gd);
 
memset((void *)gd, 0, sizeof(gd_t));
+   size = CONFIG_SYS_SDRAM_SIZE;
+   mem = os_malloc(CONFIG_SYS_SDRAM_SIZE);
+
+   assert(mem);
+   gd-arch.ram_buf = mem;
 
 #if defined(CONFIG_OF_EMBED)
/* Get a pointer to the FDT */
@@ -163,6 +188,8 @@ void board_init_f(ulong bootflag)
 #elif defined(CONFIG_OF_SEPARATE)
/* FDT is at end of image */
gd-fdt_blob = (void *)(_end_ofs + _TEXT_BASE);
+#elif defined(CONFIG_OF_HOSTFILE)
+   read_fdt_from_file();
 #endif
 
for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
@@ -170,8 +197,11 @@ void board_init_f(ulong bootflag)
hang();
}
 
-   size = CONFIG_SYS_SDRAM_SIZE;
-   mem = os_malloc(CONFIG_SYS_SDRAM_SIZE);
+#ifdef CONFIG_OF_CONTROL
+   /* For now, put this check after the console is ready */
+   if (fdtdec_prepare_fdt())
+   panic(** CONFIG_OF_CONTROL defined but no FDT - please see 
doc/README.fdt-control);
+#endif
 
assert(mem);
gd-arch.ram_buf = mem;
diff --git a/doc/README.fdt-control b/doc/README.fdt-control
index 85bda03..1e016d1 100644
--- a/doc/README.fdt-control
+++ b/doc/README.fdt-control
@@ -142,7 +142,11 @@ join the two:
 
 and then flash image.bin onto your board.
 
-You cannot use both of these options at the same time.
+If CONFIG_OF_HOSTFILE is defined, then it will be read from a file on
+startup. This is only useful for sandbox. Use the -d flag to U-Boot to
+specify the file to read.
+
+You cannot use 

[U-Boot] [PATCH v2 09/45] image: Split hash node processing into its own function

2013-03-18 Thread Simon Glass
This function has become quite long and much of the body is indented quite
a bit. Move it into a separate function to make it easier to work with.

Signed-off-by: Simon Glass s...@chromium.org
Acked-by: Marek Vasut ma...@denx.de
---
Changes in v2:
- Rebase on previous patches

 tools/image-host.c | 96 --
 1 file changed, 57 insertions(+), 39 deletions(-)

diff --git a/tools/image-host.c b/tools/image-host.c
index 82b6cee..6648215 100644
--- a/tools/image-host.c
+++ b/tools/image-host.c
@@ -79,6 +79,56 @@ int fit_set_hashes(void *fit)
 }
 
 /**
+ * fit_image_process_hash - Process a single subnode of the images/ node
+ *
+ * Check each subnode and process accordingly. For hash nodes we generate
+ * a hash of the supplised data and store it in the node.
+ *
+ * @fit:   pointer to the FIT format image header
+ * @image_name:name of image being processes (used to display errors)
+ * @noffset:   subnode offset
+ * @data:  data to process
+ * @size:  size of data in bytes
+ * @return 0 if ok, -1 on error
+ */
+static int fit_image_process_hash(void *fit, const char *image_name,
+   int noffset, const void *data, size_t size)
+{
+   uint8_t value[FIT_MAX_HASH_LEN];
+   int value_len;
+   char *algo;
+
+   /*
+* Check subnode name, must be equal to hash.
+* Multiple hash nodes require unique unit node
+* names, e.g. hash@1, hash@2, etc.
+*/
+   if (strncmp(fit_get_name(fit, noffset, NULL),
+   FIT_HASH_NODENAME, strlen(FIT_HASH_NODENAME)) != 0)
+   return 0;
+
+   if (fit_image_hash_get_algo(fit, noffset, algo)) {
+   printf(Can't get hash algo property for '%s' hash node in '%s' 
image node\n,
+  fit_get_name(fit, noffset, NULL), image_name);
+   return -1;
+   }
+
+   if (calculate_hash(data, size, algo, value, value_len)) {
+   printf(Unsupported hash algorithm (%s) for '%s' hash node in 
'%s' image node\n,
+  algo, fit_get_name(fit, noffset, NULL), image_name);
+   return -1;
+   }
+
+   if (fit_image_hash_set_value(fit, noffset, value, value_len)) {
+   printf(Can't set hash value for '%s' hash node in '%s' image 
node\n,
+  fit_get_name(fit, noffset, NULL), image_name);
+   return -1;
+   }
+
+   return 0;
+}
+
+/**
  * fit_image_set_hashes - calculate/set hashes for given component image node
  * @fit: pointer to the FIT format image header
  * @image_noffset: requested component image node
@@ -111,11 +161,9 @@ int fit_image_set_hashes(void *fit, int image_noffset)
 {
const void *data;
size_t size;
-   char *algo;
-   uint8_t value[FIT_MAX_HASH_LEN];
-   int value_len;
int noffset;
int ndepth;
+   const char *image_name;
 
/* Get image data and data length */
if (fit_image_get_data(fit, image_noffset, data, size)) {
@@ -123,47 +171,17 @@ int fit_image_set_hashes(void *fit, int image_noffset)
return -1;
}
 
+   image_name = fit_get_name(fit, image_noffset, NULL);
+
/* Process all hash subnodes of the component image node */
for (ndepth = 0, noffset = fdt_next_node(fit, image_noffset, ndepth);
-(noffset = 0)  (ndepth  0);
-noffset = fdt_next_node(fit, noffset, ndepth)) {
+   (noffset = 0)  (ndepth  0);
+   noffset = fdt_next_node(fit, noffset, ndepth)) {
if (ndepth == 1) {
/* Direct child node of the component image node */
-
-   /*
-* Check subnode name, must be equal to hash.
-* Multiple hash nodes require unique unit node
-* names, e.g. hash@1, hash@2, etc.
-*/
-   if (strncmp(fit_get_name(fit, noffset, NULL),
-   FIT_HASH_NODENAME,
-   strlen(FIT_HASH_NODENAME)) != 0) {
-   /* Not a hash subnode, skip it */
-   continue;
-   }
-
-   if (fit_image_hash_get_algo(fit, noffset, algo)) {
-   printf(Can't get hash algo property for '%s' 
hash node in '%s' image node\n,
-  fit_get_name(fit, noffset, NULL),
-  fit_get_name(fit, image_noffset, NULL));
-   return -1;
-   }
-
-   if (calculate_hash(data, size, algo, value,
-  value_len)) {
-   printf(Unsupported hash algorithm (%s) for 
'%s' hash node in '%s' image node\n,
-  algo, 

[U-Boot] [PATCH v2 08/45] image: Move HOSTCC image code to tools/

2013-03-18 Thread Simon Glass
This code is never compiled into U-Boot, so move it into a separate
file in tools/ to avoid the large #ifdef.

Signed-off-by: Simon Glass s...@chromium.org
Reviewed-by: Marek Vasut ma...@denx.de
---
Changes in v2:
- Rebase on previous patches

 common/image-fit.c | 171 +
 include/image.h|   3 +
 tools/Makefile |   2 +
 tools/image-host.c | 201 +
 4 files changed, 207 insertions(+), 170 deletions(-)
 create mode 100644 tools/image-host.c

diff --git a/common/image-fit.c b/common/image-fit.c
index 3ba1ad3..3e72da0 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -827,7 +827,7 @@ int fit_set_timestamp(void *fit, int noffset, time_t 
timestamp)
  * 0, on success
  *-1, when algo is unsupported
  */
-static int calculate_hash(const void *data, int data_len, const char *algo,
+int calculate_hash(const void *data, int data_len, const char *algo,
uint8_t *value, int *value_len)
 {
if (strcmp(algo, crc32) == 0) {
@@ -849,175 +849,6 @@ static int calculate_hash(const void *data, int data_len, 
const char *algo,
return 0;
 }
 
-#ifdef USE_HOSTCC
-/**
- * fit_set_hashes - process FIT component image nodes and calculate hashes
- * @fit: pointer to the FIT format image header
- *
- * fit_set_hashes() adds hash values for all component images in the FIT blob.
- * Hashes are calculated for all component images which have hash subnodes
- * with algorithm property set to one of the supported hash algorithms.
- *
- * returns
- * 0, on success
- * libfdt error code, on failure
- */
-int fit_set_hashes(void *fit)
-{
-   int images_noffset;
-   int noffset;
-   int ndepth;
-   int ret;
-
-   /* Find images parent node offset */
-   images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH);
-   if (images_noffset  0) {
-   printf(Can't find images parent node '%s' (%s)\n,
-  FIT_IMAGES_PATH, fdt_strerror(images_noffset));
-   return images_noffset;
-   }
-
-   /* Process its subnodes, print out component images details */
-   for (ndepth = 0, noffset = fdt_next_node(fit, images_noffset, ndepth);
-(noffset = 0)  (ndepth  0);
-noffset = fdt_next_node(fit, noffset, ndepth)) {
-   if (ndepth == 1) {
-   /*
-* Direct child node of the images parent node,
-* i.e. component image node.
-*/
-   ret = fit_image_set_hashes(fit, noffset);
-   if (ret)
-   return ret;
-   }
-   }
-
-   return 0;
-}
-
-/**
- * fit_image_set_hashes - calculate/set hashes for given component image node
- * @fit: pointer to the FIT format image header
- * @image_noffset: requested component image node
- *
- * fit_image_set_hashes() adds hash values for an component image node. All
- * existing hash subnodes are checked, if algorithm property is set to one of
- * the supported hash algorithms, hash value is computed and corresponding
- * hash node property is set, for example:
- *
- * Input component image node structure:
- *
- * o image@1 (at image_noffset)
- *   | - data = [binary data]
- *   o hash@1
- * |- algo = sha1
- *
- * Output component image node structure:
- *
- * o image@1 (at image_noffset)
- *   | - data = [binary data]
- *   o hash@1
- * |- algo = sha1
- * |- value = sha1(data)
- *
- * returns:
- * 0 on sucess
- *0 on failure
- */
-int fit_image_set_hashes(void *fit, int image_noffset)
-{
-   const void *data;
-   size_t size;
-   char *algo;
-   uint8_t value[FIT_MAX_HASH_LEN];
-   int value_len;
-   int noffset;
-   int ndepth;
-
-   /* Get image data and data length */
-   if (fit_image_get_data(fit, image_noffset, data, size)) {
-   printf(Can't get image data/size\n);
-   return -1;
-   }
-
-   /* Process all hash subnodes of the component image node */
-   for (ndepth = 0, noffset = fdt_next_node(fit, image_noffset, ndepth);
-(noffset = 0)  (ndepth  0);
-noffset = fdt_next_node(fit, noffset, ndepth)) {
-   if (ndepth == 1) {
-   /* Direct child node of the component image node */
-
-   /*
-* Check subnode name, must be equal to hash.
-* Multiple hash nodes require unique unit node
-* names, e.g. hash@1, hash@2, etc.
-*/
-   if (strncmp(fit_get_name(fit, noffset, NULL),
-   FIT_HASH_NODENAME,
-   strlen(FIT_HASH_NODENAME)) != 0) {
-   /* Not a hash subnode, skip it */
-   continue;
-   

[U-Boot] [PATCH v2 16/45] image: Rename hash printing to fit_image_print_verification_data()

2013-03-18 Thread Simon Glass
This function will be used to print signatures as well as hashes, so rename
it. Also make it static since it is not used outside this file.

Signed-off-by: Simon Glass s...@chromium.org
Reviewed-by: Marek Vasut ma...@denx.de
---
Changes in v2:
- Rebase on previous patches

 common/image-fit.c | 131 -
 include/image.h|   1 -
 2 files changed, 79 insertions(+), 53 deletions(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index b8a1eb4..5dcb0c6 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -229,6 +229,84 @@ void fit_print_contents(const void *fit)
 }
 
 /**
+ * fit_image_print_data() - prints out the hash node details
+ * @fit: pointer to the FIT format image header
+ * @noffset: offset of the hash node
+ * @p: pointer to prefix string
+ *
+ * fit_image_print_data() lists properies for the processed hash node
+ *
+ * returns:
+ * no returned results
+ */
+static void fit_image_print_data(const void *fit, int noffset, const char *p)
+{
+   char *algo;
+   uint8_t *value;
+   int value_len;
+   int i, ret;
+
+   /*
+* Check subnode name, must be equal to hash.
+* Multiple hash nodes require unique unit node
+* names, e.g. hash@1, hash@2, etc.
+*/
+   if (strncmp(fit_get_name(fit, noffset, NULL),
+   FIT_HASH_NODENAME,
+   strlen(FIT_HASH_NODENAME)) != 0)
+   return;
+
+   debug(%s  Hash node:'%s'\n, p,
+ fit_get_name(fit, noffset, NULL));
+
+   printf(%s  Hash algo:, p);
+   if (fit_image_hash_get_algo(fit, noffset, algo)) {
+   printf(invalid/unsupported\n);
+   return;
+   }
+   printf(%s\n, algo);
+
+   ret = fit_image_hash_get_value(fit, noffset, value,
+   value_len);
+   printf(%s  Hash value:   , p);
+   if (ret) {
+   printf(unavailable\n);
+   } else {
+   for (i = 0; i  value_len; i++)
+   printf(%02x, value[i]);
+   printf(\n);
+   }
+
+   debug(%s  Hash len: %d\n, p, value_len);
+}
+
+/**
+ * fit_image_print_verification_data() - prints out the hash/signature details
+ * @fit: pointer to the FIT format image header
+ * @noffset: offset of the hash or signature node
+ * @p: pointer to prefix string
+ *
+ * This lists properies for the processed hash node
+ *
+ * returns:
+ * no returned results
+ */
+static void fit_image_print_verification_data(const void *fit, int noffset,
+  const char *p)
+{
+   const char *name;
+
+   /*
+* Check subnode name, must be equal to hash or signature.
+* Multiple hash/signature nodes require unique unit node
+* names, e.g. hash@1, hash@2, signature@1, signature@2, etc.
+*/
+   name = fit_get_name(fit, noffset, NULL);
+   if (!strncmp(name, FIT_HASH_NODENAME, strlen(FIT_HASH_NODENAME)))
+   fit_image_print_data(fit, noffset, p);
+}
+
+/**
  * fit_image_print - prints out the FIT component image details
  * @fit: pointer to the FIT format image header
  * @image_noffset: offset of the component image node
@@ -323,63 +401,12 @@ void fit_image_print(const void *fit, int image_noffset, 
const char *p)
 noffset = fdt_next_node(fit, noffset, ndepth)) {
if (ndepth == 1) {
/* Direct child node of the component image node */
-   fit_image_print_hash(fit, noffset, p);
+   fit_image_print_verification_data(fit, noffset, p);
}
}
 }
 
 /**
- * fit_image_print_hash - prints out the hash node details
- * @fit: pointer to the FIT format image header
- * @noffset: offset of the hash node
- * @p: pointer to prefix string
- *
- * fit_image_print_hash() lists properies for the processed hash node
- *
- * returns:
- * no returned results
- */
-void fit_image_print_hash(const void *fit, int noffset, const char *p)
-{
-   char *algo;
-   uint8_t *value;
-   int value_len;
-   int i, ret;
-
-   /*
-* Check subnode name, must be equal to hash.
-* Multiple hash nodes require unique unit node
-* names, e.g. hash@1, hash@2, etc.
-*/
-   if (strncmp(fit_get_name(fit, noffset, NULL),
-   FIT_HASH_NODENAME, strlen(FIT_HASH_NODENAME)) != 0)
-   return;
-
-   debug(%s  Hash node:'%s'\n, p,
- fit_get_name(fit, noffset, NULL));
-
-   printf(%s  Hash algo:, p);
-   if (fit_image_hash_get_algo(fit, noffset, algo)) {
-   printf(invalid/unsupported\n);
-   return;
-   }
-   printf(%s\n, algo);
-
-   ret = fit_image_hash_get_value(fit, noffset, value,
-   value_len);
-   printf(%s  Hash value:   , p);
-   if (ret) {
-   

[U-Boot] [PATCH v2 05/45] image: Move timestamp #ifdefs to header file

2013-03-18 Thread Simon Glass
Rather than repeat the line
 #if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || \
defined(USE_HOSTCC)

everywhere, put this in a header file and #define IMAGE_ENABLE_TIMESTAMP
to either 1 or 0. Then we can use a plain if() in most code and avoid
the #ifdefs.

The compiler's dead code elimination ensures that the result is the same.

Signed-off-by: Simon Glass s...@chromium.org
Acked-by: Marek Vasut ma...@denx.de
---
Changes in v2: None

 common/image.c  | 50 +-
 include/image.h |  8 
 2 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/common/image.c b/common/image.c
index 6afbb40..d01b8f6 100644
--- a/common/image.c
+++ b/common/image.c
@@ -39,9 +39,7 @@
 #include logbuff.h
 #endif
 
-#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE)
 #include rtc.h
-#endif
 
 #include environment.h
 #include image.h
@@ -162,10 +160,6 @@ static const table_entry_t uimage_comp[] = {
{   -1, , , },
 };
 
-#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || 
defined(USE_HOSTCC)
-static void genimg_print_time(time_t timestamp);
-#endif
-
 /*/
 /* Legacy format routines */
 /*/
@@ -311,10 +305,10 @@ void image_print_contents(const void *ptr)
 #endif
 
printf(%sImage Name:   %.*s\n, p, IH_NMLEN, image_get_name(hdr));
-#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || 
defined(USE_HOSTCC)
-   printf(%sCreated:  , p);
-   genimg_print_time((time_t)image_get_time(hdr));
-#endif
+   if (IMAGE_ENABLE_TIMESTAMP) {
+   printf(%sCreated:  , p);
+   genimg_print_time((time_t)image_get_time(hdr));
+   }
printf(%sImage Type:   , p);
image_print_type(hdr);
printf(%sData Size:, p);
@@ -523,8 +517,8 @@ void genimg_print_size(uint32_t size)
 #endif
 }
 
-#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || 
defined(USE_HOSTCC)
-static void genimg_print_time(time_t timestamp)
+#if IMAGE_ENABLE_TIMESTAMP
+void genimg_print_time(time_t timestamp)
 {
 #ifndef USE_HOSTCC
struct rtc_time tm;
@@ -537,7 +531,7 @@ static void genimg_print_time(time_t timestamp)
printf(%s, ctime(timestamp));
 #endif
 }
-#endif /* CONFIG_TIMESTAMP || CONFIG_CMD_DATE || USE_HOSTCC */
+#endif
 
 /**
  * get_table_entry_name - translate entry id to long name
@@ -1910,9 +1904,7 @@ void fit_print_contents(const void *fit)
int count = 0;
int ret;
const char *p;
-#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || 
defined(USE_HOSTCC)
time_t timestamp;
-#endif
 
 #ifdef USE_HOSTCC
p = ;
@@ -1928,14 +1920,14 @@ void fit_print_contents(const void *fit)
else
printf(%s\n, desc);
 
-#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || 
defined(USE_HOSTCC)
-   ret = fit_get_timestamp(fit, 0, timestamp);
-   printf(%sCreated: , p);
-   if (ret)
-   printf(unavailable\n);
-   else
-   genimg_print_time(timestamp);
-#endif
+   if (IMAGE_ENABLE_TIMESTAMP) {
+   ret = fit_get_timestamp(fit, 0, timestamp);
+   printf(%sCreated: , p);
+   if (ret)
+   printf(unavailable\n);
+   else
+   genimg_print_time(timestamp);
+   }
 
/* Find images parent node offset */
images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH);
@@ -3046,13 +3038,13 @@ int fit_check_format(const void *fit)
return 0;
}
 
-#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || 
defined(USE_HOSTCC)
-   /* mandatory / node 'timestamp' property */
-   if (fdt_getprop(fit, 0, FIT_TIMESTAMP_PROP, NULL) == NULL) {
-   debug(Wrong FIT format: no timestamp\n);
-   return 0;
+   if (IMAGE_ENABLE_TIMESTAMP) {
+   /* mandatory / node 'timestamp' property */
+   if (fdt_getprop(fit, 0, FIT_TIMESTAMP_PROP, NULL) == NULL) {
+   debug(Wrong FIT format: no timestamp\n);
+   return 0;
+   }
}
-#endif
 
/* mandatory subimages parent '/images' node */
if (fdt_path_offset(fit, FIT_IMAGES_PATH)  0) {
diff --git a/include/image.h b/include/image.h
index 8e285f9..32a961c 100644
--- a/include/image.h
+++ b/include/image.h
@@ -332,6 +332,14 @@ int genimg_get_type_id(const char *name);
 int genimg_get_comp_id(const char *name);
 void genimg_print_size(uint32_t size);
 
+#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || \
+   defined(USE_HOSTCC)
+#define IMAGE_ENABLE_TIMESTAMP 1
+#else
+#define IMAGE_ENABLE_TIMESTAMP 0
+#endif
+void genimg_print_time(time_t timestamp);
+
 #ifndef USE_HOSTCC
 /* Image 

[U-Boot] [PATCH v2 13/45] image: Move error! string to common place

2013-03-18 Thread Simon Glass
The string  error\n appears in each error string. Move it out to a
common place.

Signed-off-by: Simon Glass s...@chromium.org
Reviewed-by: Marek Vasut ma...@denx.de
---
Changes in v2:
- Put err_msgp strings on a single line
- Rebase on previous patches

 common/image-fit.c | 19 ---
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index fa21f18..97f8521 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -860,8 +860,7 @@ static int fit_image_check_hash(const void *fit, int 
noffset, const void *data,
*err_msgp = NULL;
 
if (fit_image_hash_get_algo(fit, noffset, algo)) {
-   *err_msgp =  error!\nCan't get hash algo 
-   property;
+   *err_msgp = Can't get hash algo property;
return -1;
}
printf(%s, algo);
@@ -876,22 +875,20 @@ static int fit_image_check_hash(const void *fit, int 
noffset, const void *data,
 
if (fit_image_hash_get_value(fit, noffset, fit_value,
 fit_value_len)) {
-   *err_msgp =  error!\nCan't get hash value 
-   property;
+   *err_msgp = Can't get hash value property;
return -1;
}
 
if (calculate_hash(data, size, algo, value, value_len)) {
-   *err_msgp =  error!\n
-   Unsupported hash algorithm;
+   *err_msgp = Unsupported hash algorithm;
return -1;
}
 
if (value_len != fit_value_len) {
-   *err_msgp =  error !\nBad hash value len;
+   *err_msgp = Bad hash value len;
return -1;
} else if (memcmp(value, fit_value, value_len) != 0) {
-   *err_msgp =  error!\nBad hash value;
+   *err_msgp = Bad hash value;
return -1;
}
 
@@ -921,7 +918,7 @@ int fit_image_verify(const void *fit, int image_noffset)
 
/* Get image data and data length */
if (fit_image_get_data(fit, image_noffset, data, size)) {
-   printf(Can't get image data/size\n);
+   err_msg = Can't get image data/size;
return 0;
}
 
@@ -947,14 +944,14 @@ int fit_image_verify(const void *fit, int image_noffset)
}
 
if (noffset == -FDT_ERR_TRUNCATED || noffset == -FDT_ERR_BADSTRUCTURE) {
-   err_msg =  error!\nCorrupted or truncated tree;
+   err_msg = Corrupted or truncated tree;
goto error;
}
 
return 1;
 
 error:
-   printf(%s for '%s' hash node in '%s' image node\n,
+   printf( error!\n%s for '%s' hash node in '%s' image node\n,
   err_msg, fit_get_name(fit, noffset, NULL),
   fit_get_name(fit, image_noffset, NULL));
return 0;
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 21/45] sandbox: fdt: Support fdt command for sandbox

2013-03-18 Thread Simon Glass
By using map_sysmem() we can get the fdt command to work correctly with
sandbox.

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2:
- Rebase to use updated fdt_valid() function

 common/cmd_fdt.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c
index e582961..edefd77 100644
--- a/common/cmd_fdt.c
+++ b/common/cmd_fdt.c
@@ -31,6 +31,7 @@
 #include asm/global_data.h
 #include libfdt.h
 #include fdt_support.h
+#include asm/io.h
 
 #define MAX_LEVEL  32  /* how deeply nested we will go */
 #define SCRATCHPAD 1024/* bytes of scratchpad memory */
@@ -55,7 +56,10 @@ struct fdt_header *working_fdt;
 
 void set_working_fdt_addr(void *addr)
 {
-   working_fdt = addr;
+   void *buf;
+
+   buf = map_sysmem((ulong)addr, 0);
+   working_fdt = buf;
setenv_addr(fdtaddr, addr);
 }
 
@@ -129,13 +133,13 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
}
 
addr = simple_strtoul(argv[0], NULL, 16);
-   blob = (struct fdt_header *)addr;
+   blob = map_sysmem(addr, 0);
if (!fdt_valid(blob))
return 1;
if (control)
gd-fdt_blob = blob;
else
-   set_working_fdt_addr((void *)addr);
+   set_working_fdt_addr(blob);
 
if (argc = 2) {
int  len;
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 03/45] mkimage: Move ARRAY_SIZE to header file

2013-03-18 Thread Simon Glass
Move this definition from aisimage.c to mkimage.h so that it is available
more widely.

Signed-off-by: Simon Glass s...@chromium.org
Acked-by: Marek Vasut ma...@denx.de
---
Changes in v2: None

 tools/aisimage.c | 1 -
 tools/mkimage.h  | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/aisimage.c b/tools/aisimage.c
index c645708..659df8c 100644
--- a/tools/aisimage.c
+++ b/tools/aisimage.c
@@ -32,7 +32,6 @@
 #define WORD_ALIGN04
 #define WORD_ALIGN(len) (((len)+WORD_ALIGN0-1)  ~(WORD_ALIGN0-1))
 #define MAX_CMD_BUFFER 4096
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
 
 static uint32_t ais_img_size;
 
diff --git a/tools/mkimage.h b/tools/mkimage.h
index ea45f5c..e07a615 100644
--- a/tools/mkimage.h
+++ b/tools/mkimage.h
@@ -42,6 +42,8 @@
 #define debug(fmt,args...)
 #endif /* MKIMAGE_DEBUG */
 
+#define ARRAY_SIZE(x)  (sizeof(x) / sizeof((x)[0]))
+
 #define MKIMAGE_TMPFILE_SUFFIX .tmp
 #define MKIMAGE_MAX_TMPFILE_LEN256
 #define MKIMAGE_DEFAULT_DTC_OPTIONS-I dts -O dtb -p 500
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 12/45] image: Move hash checking into its own function

2013-03-18 Thread Simon Glass
The existing function is long and most of the code is indented a long
way. Before adding yet more code, split this out into its own function.

Signed-off-by: Simon Glass s...@chromium.org
Reviewed-by: Marek Vasut ma...@denx.de (v1)
---
Changes in v2:
- Add IMAGE_ENABLE_IGNORE to avoid #ifdef around ignore property handling
- Rebase on previous patches
- Rename commit message to say function instead of function

 common/image-fit.c | 128 -
 include/image.h|   8 ++--
 2 files changed, 72 insertions(+), 64 deletions(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index 9360af2..fa21f18 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -748,7 +748,6 @@ int fit_image_hash_get_value(const void *fit, int noffset, 
uint8_t **value,
return 0;
 }
 
-#ifndef USE_HOSTCC
 /**
  * fit_image_hash_get_ignore - get hash ignore flag
  * @fit: pointer to the FIT format image header
@@ -763,7 +762,7 @@ int fit_image_hash_get_value(const void *fit, int noffset, 
uint8_t **value,
  * 0, on ignore not found
  * value, on ignore found
  */
-int fit_image_hash_get_ignore(const void *fit, int noffset, int *ignore)
+static int fit_image_hash_get_ignore(const void *fit, int noffset, int *ignore)
 {
int len;
int *value;
@@ -776,7 +775,6 @@ int fit_image_hash_get_ignore(const void *fit, int noffset, 
int *ignore)
 
return 0;
 }
-#endif
 
 /**
  * fit_set_timestamp - set node timestamp property
@@ -849,6 +847,57 @@ int calculate_hash(const void *data, int data_len, const 
char *algo,
return 0;
 }
 
+static int fit_image_check_hash(const void *fit, int noffset, const void *data,
+   size_t size, char **err_msgp)
+{
+   uint8_t value[FIT_MAX_HASH_LEN];
+   int value_len;
+   char *algo;
+   uint8_t *fit_value;
+   int fit_value_len;
+   int ignore;
+
+   *err_msgp = NULL;
+
+   if (fit_image_hash_get_algo(fit, noffset, algo)) {
+   *err_msgp =  error!\nCan't get hash algo 
+   property;
+   return -1;
+   }
+   printf(%s, algo);
+
+   if (IMAGE_ENABLE_IGNORE) {
+   fit_image_hash_get_ignore(fit, noffset, ignore);
+   if (ignore) {
+   printf(-skipped );
+   return 0;
+   }
+   }
+
+   if (fit_image_hash_get_value(fit, noffset, fit_value,
+fit_value_len)) {
+   *err_msgp =  error!\nCan't get hash value 
+   property;
+   return -1;
+   }
+
+   if (calculate_hash(data, size, algo, value, value_len)) {
+   *err_msgp =  error!\n
+   Unsupported hash algorithm;
+   return -1;
+   }
+
+   if (value_len != fit_value_len) {
+   *err_msgp =  error !\nBad hash value len;
+   return -1;
+   } else if (memcmp(value, fit_value, value_len) != 0) {
+   *err_msgp =  error!\nBad hash value;
+   return -1;
+   }
+
+   return 0;
+}
+
 /**
  * fit_image_verify - verify data intergity
  * @fit: pointer to the FIT format image header
@@ -866,14 +915,6 @@ int fit_image_verify(const void *fit, int image_noffset)
 {
const void  *data;
size_t  size;
-   char*algo;
-   uint8_t *fit_value;
-   int fit_value_len;
-#ifndef USE_HOSTCC
-   int ignore;
-#endif
-   uint8_t value[FIT_MAX_HASH_LEN];
-   int value_len;
int noffset;
int ndepth;
char*err_msg = ;
@@ -885,58 +926,23 @@ int fit_image_verify(const void *fit, int image_noffset)
}
 
/* Process all hash subnodes of the component image node */
-   for (ndepth = 0, noffset = fdt_next_node(fit, image_noffset, ndepth);
-(noffset = 0)  (ndepth  0);
-noffset = fdt_next_node(fit, noffset, ndepth)) {
-   if (ndepth == 1) {
-   /* Direct child node of the component image node */
+   for (ndepth = 0,
+   noffset = fdt_next_subnode(fit, image_noffset, ndepth);
+   noffset = 0;
+   noffset = fdt_next_subnode(fit, noffset, ndepth)) {
+   const char *name = fit_get_name(fit, noffset, NULL);
 
-   /*
-* Check subnode name, must be equal to hash.
-* Multiple hash nodes require unique unit node
-* names, e.g. hash@1, hash@2, etc.
-*/
-   if (strncmp(fit_get_name(fit, noffset, NULL),
-   FIT_HASH_NODENAME,
-   strlen(FIT_HASH_NODENAME)) != 0)
-   

[U-Boot] [PATCH v2 23/45] fdt: Skip checking FDT if the pointer is NULL

2013-03-18 Thread Simon Glass
If we have no FDT, don't attempt to read from it. This allows sandbox to
run without an FDT if required.

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2:
- Fix checkpatch checks about parenthesis alignment

 lib/fdtdec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 3ae348d..8e1542b 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -329,7 +329,8 @@ int fdtdec_check_fdt(void)
  */
 int fdtdec_prepare_fdt(void)
 {
-   if (((uintptr_t)gd-fdt_blob  3) || fdt_check_header(gd-fdt_blob)) {
+   if (!gd-fdt_blob || ((uintptr_t)gd-fdt_blob  3) ||
+   fdt_check_header(gd-fdt_blob)) {
printf(No valid FDT found - please append one to U-Boot 
binary, use u-boot-dtb.bin or define 
CONFIG_OF_EMBED\n);
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 15/45] image: Rename fit_add_hashes() to fit_add_verification_data()

2013-03-18 Thread Simon Glass
We intend to add signatures to FITs also, so rename this function so that
it is not specific to hashing. Also rename fit_image_set_hashes() and
make it static since it is not used outside this file.

Signed-off-by: Simon Glass s...@chromium.org
Reviewed-by: Marek Vasut ma...@denx.de
---
Changes in v2:
- Rebase on previous patches

 include/image.h|  10 +++-
 tools/fit_image.c  |   2 +-
 tools/image-host.c | 146 +
 3 files changed, 79 insertions(+), 79 deletions(-)

diff --git a/include/image.h b/include/image.h
index c5e8844..4901ce7 100644
--- a/include/image.h
+++ b/include/image.h
@@ -613,8 +613,14 @@ int fit_image_hash_get_value(const void *fit, int noffset, 
uint8_t **value,
int *value_len);
 
 int fit_set_timestamp(void *fit, int noffset, time_t timestamp);
-int fit_set_hashes(void *fit);
-int fit_image_set_hashes(void *fit, int image_noffset);
+
+/**
+ * fit_add_verification_data() - Calculate and add hashes to FIT
+ *
+ * @fit:   Fit image to process
+ * @return 0 if ok, 0 for error
+ */
+int fit_add_verification_data(void *fit);
 
 int fit_image_verify(const void *fit, int noffset);
 int fit_all_image_verify(const void *fit);
diff --git a/tools/fit_image.c b/tools/fit_image.c
index 76bbba1..8f51159 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -125,7 +125,7 @@ static int fit_handle_file (struct mkimage_params *params)
}
 
/* set hashes for images in the blob */
-   if (fit_set_hashes (ptr)) {
+   if (fit_add_verification_data(ptr)) {
fprintf (stderr, %s Can't add hashes to FIT blob,
params-cmdname);
unlink (tmpfile);
diff --git a/tools/image-host.c b/tools/image-host.c
index a6b4f6b..3ba05de 100644
--- a/tools/image-host.c
+++ b/tools/image-host.c
@@ -34,51 +34,6 @@
 #include u-boot/md5.h
 
 /**
- * fit_set_hashes - process FIT component image nodes and calculate hashes
- * @fit: pointer to the FIT format image header
- *
- * fit_set_hashes() adds hash values for all component images in the FIT blob.
- * Hashes are calculated for all component images which have hash subnodes
- * with algorithm property set to one of the supported hash algorithms.
- *
- * returns
- * 0, on success
- * libfdt error code, on failure
- */
-int fit_set_hashes(void *fit)
-{
-   int images_noffset;
-   int noffset;
-   int ndepth;
-   int ret;
-
-   /* Find images parent node offset */
-   images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH);
-   if (images_noffset  0) {
-   printf(Can't find images parent node '%s' (%s)\n,
-  FIT_IMAGES_PATH, fdt_strerror(images_noffset));
-   return images_noffset;
-   }
-
-   /* Process its subnodes, print out component images details */
-   for (ndepth = 0, noffset = fdt_next_node(fit, images_noffset, ndepth);
-(noffset = 0)  (ndepth  0);
-noffset = fdt_next_node(fit, noffset, ndepth)) {
-   if (ndepth == 1) {
-   /*
-* Direct child node of the images parent node,
-* i.e. component image node.
-*/
-   ret = fit_image_set_hashes(fit, noffset);
-   if (ret)
-   return ret;
-   }
-   }
-
-   return 0;
-}
-
-/**
  * fit_set_hash_value - set hash value in requested has node
  * @fit: pointer to the FIT format image header
  * @noffset: hash node offset
@@ -125,33 +80,27 @@ static int fit_image_process_hash(void *fit, const char 
*image_name,
int noffset, const void *data, size_t size)
 {
uint8_t value[FIT_MAX_HASH_LEN];
+   const char *node_name;
int value_len;
char *algo;
 
-   /*
-* Check subnode name, must be equal to hash.
-* Multiple hash nodes require unique unit node
-* names, e.g. hash@1, hash@2, etc.
-*/
-   if (strncmp(fit_get_name(fit, noffset, NULL),
-   FIT_HASH_NODENAME, strlen(FIT_HASH_NODENAME)) != 0)
-   return 0;
+   node_name = fit_get_name(fit, noffset, NULL);
 
if (fit_image_hash_get_algo(fit, noffset, algo)) {
printf(Can't get hash algo property for '%s' hash node in '%s' 
image node\n,
-  fit_get_name(fit, noffset, NULL), image_name);
+  node_name, image_name);
return -1;
}
 
if (calculate_hash(data, size, algo, value, value_len)) {
printf(Unsupported hash algorithm (%s) for '%s' hash node in 
'%s' image node\n,
-  algo, fit_get_name(fit, noffset, NULL), image_name);
+  algo, node_name, image_name);
return -1;
}
 
if (fit_set_hash_value(fit, noffset, value, value_len)) {

[U-Boot] [PATCH v2 18/45] fdt: Add a parameter to fdt_valid()

2013-03-18 Thread Simon Glass
At present this only checks working_fdt, but we want to check other FDTs
also. So add the FDT to check as a parameter to fdt_valid().

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2:
- Allow the control FDT to be set even if there is currently no control FDT
- fdt_valid() sets the FDT pointer to NULL on error, to simplify callers

 common/cmd_fdt.c | 38 --
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c
index ac77a08..07072f3 100644
--- a/common/cmd_fdt.c
+++ b/common/cmd_fdt.c
@@ -43,7 +43,7 @@
  */
 DECLARE_GLOBAL_DATA_PTR;
 
-static int fdt_valid(void);
+static int fdt_valid(struct fdt_header **blobp);
 static int fdt_parse_prop(char *const*newval, int count, char *data, int *len);
 static int fdt_print(const char *pathp, char *prop, int depth);
 static int is_printable_string(const void *data, int len);
@@ -104,9 +104,8 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
 * Set the address [and length] of the fdt.
 */
if (argc == 2) {
-   if (!fdt_valid()) {
+   if (!fdt_valid(working_fdt))
return 1;
-   }
printf(The address of the fdt is %p\n, working_fdt);
return 0;
}
@@ -114,9 +113,8 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
addr = simple_strtoul(argv[2], NULL, 16);
set_working_fdt_addr((void *)addr);
 
-   if (!fdt_valid()) {
+   if (!fdt_valid(working_fdt))
return 1;
-   }
 
if (argc = 4) {
int  len;
@@ -167,9 +165,8 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
 * Set the address and length of the fdt.
 */
working_fdt = (struct fdt_header *)simple_strtoul(argv[2], 
NULL, 16);
-   if (!fdt_valid()) {
+   if (!fdt_valid(working_fdt))
return 1;
-   }
 
newaddr = (struct fdt_header *)simple_strtoul(argv[3],NULL,16);
 
@@ -592,16 +589,23 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
 
 //
 
-static int fdt_valid(void)
+/**
+ * fdt_valid() - Check if an FDT is valid. If not, change it to NULL
+ *
+ * @blobp: Pointer to FDT pointer
+ * @return 1 if OK, 0 if bad (in which case *blobp is set to NULL)
+ */
+static int fdt_valid(struct fdt_header **blobp)
 {
-   int  err;
+   const void *blob = *blobp;
+   int err;
 
-   if (working_fdt == NULL) {
+   if (blob == NULL) {
printf (The address of the fdt is invalid (NULL).\n);
return 0;
}
 
-   err = fdt_check_header(working_fdt);
+   err = fdt_check_header(blob);
if (err == 0)
return 1;   /* valid */
 
@@ -611,23 +615,21 @@ static int fdt_valid(void)
 * Be more informative on bad version.
 */
if (err == -FDT_ERR_BADVERSION) {
-   if (fdt_version(working_fdt) 
+   if (fdt_version(blob) 
FDT_FIRST_SUPPORTED_VERSION) {
printf ( - too old, fdt %d  %d,
-   fdt_version(working_fdt),
+   fdt_version(blob),
FDT_FIRST_SUPPORTED_VERSION);
-   working_fdt = NULL;
}
-   if (fdt_last_comp_version(working_fdt) 
+   if (fdt_last_comp_version(blob) 
FDT_LAST_SUPPORTED_VERSION) {
printf ( - too new, fdt %d  %d,
-   fdt_version(working_fdt),
+   fdt_version(blob),
FDT_LAST_SUPPORTED_VERSION);
-   working_fdt = NULL;
}
-   return 0;
}
printf(\n);
+   *blobp = NULL;
return 0;
}
return 1;
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 20/45] fdt: Allow fdt command to check and update control FDT

2013-03-18 Thread Simon Glass
There is an existing fdt command to deal with the working FDT. Enhance this
to support the control FDT also (CONFIG_OF_CONTROL).

Some nasty #ifdefs are added here - they are required until we move to
generic board and every arch has an fdt_blob.

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2:
- Correct bug in setting control FDT
- Fix checkpatch checks about parenthesis alignment

 common/cmd_fdt.c | 47 ++-
 1 file changed, 34 insertions(+), 13 deletions(-)

diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c
index 07072f3..e582961 100644
--- a/common/cmd_fdt.c
+++ b/common/cmd_fdt.c
@@ -100,38 +100,59 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
 */
if (argv[1][0] == 'a') {
unsigned long addr;
+   int control = 0;
+   struct fdt_header *blob;
/*
 * Set the address [and length] of the fdt.
 */
-   if (argc == 2) {
-   if (!fdt_valid(working_fdt))
+   argc -= 2;
+   argv += 2;
+/* Temporary #ifdef - some archs don't have fdt_blob yet */
+#ifdef CONFIG_OF_CONTROL
+   if (argc  !strcmp(*argv, -c)) {
+   control = 1;
+   argc--;
+   argv++;
+   }
+#endif
+   if (argc == 0) {
+   if (control)
+   blob = (struct fdt_header *)gd-fdt_blob;
+   else
+   blob = working_fdt;
+   if (!blob || !fdt_valid(blob))
return 1;
-   printf(The address of the fdt is %p\n, working_fdt);
+   printf(The address of the fdt is %#08lx\n,
+  control ? (ulong)blob :
+   getenv_hex(fdtaddr, 0));
return 0;
}
 
-   addr = simple_strtoul(argv[2], NULL, 16);
-   set_working_fdt_addr((void *)addr);
-
-   if (!fdt_valid(working_fdt))
+   addr = simple_strtoul(argv[0], NULL, 16);
+   blob = (struct fdt_header *)addr;
+   if (!fdt_valid(blob))
return 1;
+   if (control)
+   gd-fdt_blob = blob;
+   else
+   set_working_fdt_addr((void *)addr);
 
-   if (argc = 4) {
+   if (argc = 2) {
int  len;
int  err;
/*
 * Optional new length
 */
-   len = simple_strtoul(argv[3], NULL, 16);
-   if (len  fdt_totalsize(working_fdt)) {
+   len = simple_strtoul(argv[1], NULL, 16);
+   if (len  fdt_totalsize(blob)) {
printf (New length %d  existing length %d, 
ignoring.\n,
-   len, fdt_totalsize(working_fdt));
+   len, fdt_totalsize(blob));
} else {
/*
 * Open in place with a new length.
 */
-   err = fdt_open_into(working_fdt, working_fdt, 
len);
+   err = fdt_open_into(blob, blob, len);
if (err != 0) {
printf (libfdt fdt_open_into(): %s\n,
fdt_strerror(err));
@@ -960,7 +981,7 @@ static int fdt_print(const char *pathp, char *prop, int 
depth)
 //
 #ifdef CONFIG_SYS_LONGHELP
 static char fdt_help_text[] =
-   addr   addr [length]- Set the fdt location to addr\n
+   addr [-c]  addr [length]   - Set the [control] fdt location to 
addr\n
 #ifdef CONFIG_OF_BOARD_SETUP
fdt boardsetup  - Do board-specific set up\n
 #endif
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 10/45] image: Convert fit_image_hash_set_value() to static, and rename

2013-03-18 Thread Simon Glass
This function doesn't need to be exported, and with verification
we want to use it for setting the 'value' property in any node,
so rename it.

Signed-off-by: Simon Glass s...@chromium.org
Reviewed-by: Marek Vasut ma...@denx.de
---
Changes in v2:
- Rebase on previous patches

 include/image.h|  2 --
 tools/image-host.c | 62 +++---
 2 files changed, 31 insertions(+), 33 deletions(-)

diff --git a/include/image.h b/include/image.h
index 8b02998..9bb9071 100644
--- a/include/image.h
+++ b/include/image.h
@@ -613,8 +613,6 @@ int fit_image_hash_get_ignore(const void *fit, int noffset, 
int *ignore);
 int fit_set_timestamp(void *fit, int noffset, time_t timestamp);
 int fit_set_hashes(void *fit);
 int fit_image_set_hashes(void *fit, int image_noffset);
-int fit_image_hash_set_value(void *fit, int noffset, uint8_t *value,
-   int value_len);
 
 int fit_image_check_hashes(const void *fit, int noffset);
 int fit_all_image_check_hashes(const void *fit);
diff --git a/tools/image-host.c b/tools/image-host.c
index 6648215..a6b4f6b 100644
--- a/tools/image-host.c
+++ b/tools/image-host.c
@@ -79,6 +79,36 @@ int fit_set_hashes(void *fit)
 }
 
 /**
+ * fit_set_hash_value - set hash value in requested has node
+ * @fit: pointer to the FIT format image header
+ * @noffset: hash node offset
+ * @value: hash value to be set
+ * @value_len: hash value length
+ *
+ * fit_set_hash_value() attempts to set hash value in a node at offset
+ * given and returns operation status to the caller.
+ *
+ * returns
+ * 0, on success
+ * -1, on failure
+ */
+static int fit_set_hash_value(void *fit, int noffset, uint8_t *value,
+   int value_len)
+{
+   int ret;
+
+   ret = fdt_setprop(fit, noffset, FIT_VALUE_PROP, value, value_len);
+   if (ret) {
+   printf(Can't set hash '%s' property for '%s' node(%s)\n,
+  FIT_VALUE_PROP, fit_get_name(fit, noffset, NULL),
+  fdt_strerror(ret));
+   return -1;
+   }
+
+   return 0;
+}
+
+/**
  * fit_image_process_hash - Process a single subnode of the images/ node
  *
  * Check each subnode and process accordingly. For hash nodes we generate
@@ -119,7 +149,7 @@ static int fit_image_process_hash(void *fit, const char 
*image_name,
return -1;
}
 
-   if (fit_image_hash_set_value(fit, noffset, value, value_len)) {
+   if (fit_set_hash_value(fit, noffset, value, value_len)) {
printf(Can't set hash value for '%s' hash node in '%s' image 
node\n,
   fit_get_name(fit, noffset, NULL), image_name);
return -1;
@@ -187,33 +217,3 @@ int fit_image_set_hashes(void *fit, int image_noffset)
 
return 0;
 }
-
-/**
- * fit_image_hash_set_value - set hash value in requested has node
- * @fit: pointer to the FIT format image header
- * @noffset: hash node offset
- * @value: hash value to be set
- * @value_len: hash value length
- *
- * fit_image_hash_set_value() attempts to set hash value in a node at offset
- * given and returns operation status to the caller.
- *
- * returns
- * 0, on success
- * -1, on failure
- */
-int fit_image_hash_set_value(void *fit, int noffset, uint8_t *value,
-   int value_len)
-{
-   int ret;
-
-   ret = fdt_setprop(fit, noffset, FIT_VALUE_PROP, value, value_len);
-   if (ret) {
-   printf(Can't set hash '%s' property for '%s' node(%s)\n,
-  FIT_VALUE_PROP, fit_get_name(fit, noffset, NULL),
-  fdt_strerror(ret));
-   return -1;
-   }
-
-   return 0;
-}
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 19/45] Add getenv_hex() to return an environment variable as hex

2013-03-18 Thread Simon Glass
This conversion is required in a number of places in U-Boot. Add a
standard function to provide this feature, so we avoid all the different
variations in the way it is coded.

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2: None

 common/cmd_nvedit.c | 15 +++
 include/common.h| 13 +
 2 files changed, 28 insertions(+)

diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 947d6c4..967d8b1 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -309,6 +309,21 @@ int setenv_hex(const char *varname, ulong value)
return setenv(varname, str);
 }
 
+ulong getenv_hex(const char *varname, ulong default_val)
+{
+   const char *s;
+   ulong value;
+   char *endp;
+
+   s = getenv(varname);
+   if (s)
+   value = simple_strtoul(s, endp, 16);
+   if (!s || endp == s)
+   return default_val;
+
+   return value;
+}
+
 #ifndef CONFIG_SPL_BUILD
 static int do_env_set(cmd_tbl_t *cmdtp, int flag, int argc, char * const 
argv[])
 {
diff --git a/include/common.h b/include/common.h
index d41aeb4..52f2b33 100644
--- a/include/common.h
+++ b/include/common.h
@@ -352,6 +352,19 @@ intenvmatch (uchar *, int);
 char   *getenv  (const char *);
 intgetenv_f (const char *name, char *buf, unsigned len);
 ulong getenv_ulong(const char *name, int base, ulong default_val);
+
+/**
+ * getenv_hex() - Return an environment variable as a hex value
+ *
+ * Decode an environment as a hex number (it may or may not have a 0x
+ * prefix). If the environment variable cannot be found, or does not start
+ * with hex digits, the default value is returned.
+ *
+ * @varname:   Variable to decode
+ * @default_val:   Value to return on error
+ */
+ulong getenv_hex(const char *varname, ulong default_val);
+
 /*
  * Read an environment variable as a boolean
  * Return -1 if variable does not exist (default to true)
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 22/45] env: Fix minor comment typos in cmd_nvedit

2013-03-18 Thread Simon Glass
This should say 'environmnent'.

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2: None

 common/cmd_nvedit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 967d8b1..b95b942 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -282,7 +282,7 @@ int setenv(const char *varname, const char *varvalue)
 /**
  * Set an environment variable to an integer value
  *
- * @param varname  Environmet variable to set
+ * @param varname  Environment variable to set
  * @param valueValue to set it to
  * @return 0 if ok, 1 on error
  */
@@ -297,7 +297,7 @@ int setenv_ulong(const char *varname, ulong value)
 /**
  * Set an environment variable to an value in hex
  *
- * @param varname  Environmet variable to set
+ * @param varname  Environment variable to set
  * @param valueValue to set it to
  * @return 0 if ok, 1 on error
  */
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 11/45] image: Rename fit_image_check_hashes() to fit_image_verify()

2013-03-18 Thread Simon Glass
This is the main entry point to the FIT image verification code. We will
be using it to handle image verification with signatures, so rename the
function.

Signed-off-by: Simon Glass s...@chromium.org
Reviewed-by: Marek Vasut ma...@denx.de
---
Changes in v2: None

 common/cmd_bootm.c  |  4 ++--
 common/cmd_fpga.c   |  2 +-
 common/cmd_source.c |  2 +-
 common/cmd_ximg.c   |  2 +-
 common/image-fit.c  | 16 
 common/image.c  |  2 +-
 common/update.c |  2 +-
 include/image.h |  4 ++--
 8 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 5d2ce00..f6eb7a6 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -809,7 +809,7 @@ static int fit_check_kernel(const void *fit, int 
os_noffset, int verify)
 
if (verify) {
puts(   Verifying Hash Integrity ... );
-   if (!fit_image_check_hashes(fit, os_noffset)) {
+   if (!fit_image_verify(fit, os_noffset)) {
puts(Bad Data Hash\n);
bootstage_error(BOOTSTAGE_ID_FIT_CHECK_HASH);
return 0;
@@ -1163,7 +1163,7 @@ static int image_info(ulong addr)
 
fit_print_contents(hdr);
 
-   if (!fit_all_image_check_hashes(hdr)) {
+   if (!fit_all_image_verify(hdr)) {
puts(Bad hash in FIT image!\n);
return 1;
}
diff --git a/common/cmd_fpga.c b/common/cmd_fpga.c
index 1834246..1341604 100644
--- a/common/cmd_fpga.c
+++ b/common/cmd_fpga.c
@@ -306,7 +306,7 @@ int do_fpga (cmd_tbl_t * cmdtp, int flag, int argc, char * 
const argv[])
}
 
/* verify integrity */
-   if (!fit_image_check_hashes (fit_hdr, noffset)) 
{
+   if (!fit_image_verify(fit_hdr, noffset)) {
puts (Bad Data Hash\n);
return 1;
}
diff --git a/common/cmd_source.c b/common/cmd_source.c
index 02a862c..6a82fb2 100644
--- a/common/cmd_source.c
+++ b/common/cmd_source.c
@@ -124,7 +124,7 @@ source (ulong addr, const char *fit_uname)
 
/* verify integrity */
if (verify) {
-   if (!fit_image_check_hashes (fit_hdr, noffset)) {
+   if (!fit_image_verify(fit_hdr, noffset)) {
puts (Bad Data Hash\n);
return 1;
}
diff --git a/common/cmd_ximg.c b/common/cmd_ximg.c
index ea0a26e..f8722a0 100644
--- a/common/cmd_ximg.c
+++ b/common/cmd_ximg.c
@@ -160,7 +160,7 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * 
const argv[])
 
/* verify integrity */
if (verify) {
-   if (!fit_image_check_hashes(fit_hdr, noffset)) {
+   if (!fit_image_verify(fit_hdr, noffset)) {
puts(Bad Data Hash\n);
return 1;
}
diff --git a/common/image-fit.c b/common/image-fit.c
index 3e72da0..9360af2 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -850,11 +850,11 @@ int calculate_hash(const void *data, int data_len, const 
char *algo,
 }
 
 /**
- * fit_image_check_hashes - verify data intergity
+ * fit_image_verify - verify data intergity
  * @fit: pointer to the FIT format image header
  * @image_noffset: component image node offset
  *
- * fit_image_check_hashes() goes over component image hash nodes,
+ * fit_image_verify() goes over component image hash nodes,
  * re-calculates each data hash and compares with the value stored in hash
  * node.
  *
@@ -862,7 +862,7 @@ int calculate_hash(const void *data, int data_len, const 
char *algo,
  * 1, if all hashes are valid
  * 0, otherwise (or on error)
  */
-int fit_image_check_hashes(const void *fit, int image_noffset)
+int fit_image_verify(const void *fit, int image_noffset)
 {
const void  *data;
size_t  size;
@@ -955,17 +955,17 @@ error:
 }
 
 /**
- * fit_all_image_check_hashes - verify data intergity for all images
+ * fit_all_image_verify - verify data intergity for all images
  * @fit: pointer to the FIT format image header
  *
- * fit_all_image_check_hashes() goes over all images in the FIT and
+ * fit_all_image_verify() goes over all images in the FIT and
  * for every images checks if all it's hashes are valid.
  *
  * returns:
  * 1, if all hashes of all images are valid
  * 0, otherwise (or on error)
  */
-int fit_all_image_check_hashes(const void *fit)
+int fit_all_image_verify(const void *fit)
 {
int images_noffset;
int noffset;
@@ -995,7 +995,7 @@ int fit_all_image_check_hashes(const void *fit)
printf(   Hash(es) for Image %u (%s): , count++,
  

[U-Boot] [PATCH v2 25/45] Add stdarg to vsprintf.h

2013-03-18 Thread Simon Glass
This file uses varargs, so add the header file so that it can be used when
common has not been included.

TODO: Probably should drop this patch?

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2: None

 include/vsprintf.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/vsprintf.h b/include/vsprintf.h
index 651077c..704b8cd 100644
--- a/include/vsprintf.h
+++ b/include/vsprintf.h
@@ -24,6 +24,8 @@
 #ifndef __VSPRINTF_H
 #define __VSPRINTF_H
 
+#include stdarg.h
+
 ulong simple_strtoul(const char *cp, char **endp, unsigned int base);
 
 /**
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 27/45] hash: Add a way to calculate a hash for any algortihm

2013-03-18 Thread Simon Glass
Rather than needing to call one of many hashing algorithms in U-Boot,
provide a function hash_block() which handles this, and can support all
available hash algorithms.

Once we have md5 supported within hashing, we can use this function in
the FIT image code.

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2:
- Change hash_block() to use an unsigned int len
- Clarify use of output_size parameter to hash_block()

 common/hash.c  | 23 +++
 include/hash.h | 22 ++
 2 files changed, 45 insertions(+)

diff --git a/common/hash.c b/common/hash.c
index f5badcb..10ed2cb 100644
--- a/common/hash.c
+++ b/common/hash.c
@@ -29,6 +29,7 @@
 #include sha1.h
 #include sha256.h
 #include asm/io.h
+#include asm/errno.h
 
 /*
  * These are the hash algorithms we support. Chips which support accelerated
@@ -220,6 +221,28 @@ static void show_hash(struct hash_algo *algo, ulong addr, 
ulong len,
printf(%02x, output[i]);
 }
 
+int hash_block(const char *algo_name, const void *data, unsigned int len,
+  uint8_t *output, int *output_size)
+{
+   struct hash_algo *algo;
+
+   algo = find_hash_algo(algo_name);
+   if (!algo) {
+   debug(Unknown hash algorithm '%s'\n, algo_name);
+   return -EPROTONOSUPPORT;
+   }
+   if (output_size  *output_size  algo-digest_size) {
+   debug(Output buffer size %d too small (need %d bytes),
+ *output_size, algo-digest_size);
+   return -ENOSPC;
+   }
+   if (output_size)
+   *output_size = algo-digest_size;
+   algo-hash_func_ws(data, len, output, algo-chunk_size);
+
+   return 0;
+}
+
 int hash_command(const char *algo_name, int flags, cmd_tbl_t *cmdtp, int flag,
 int argc, char * const argv[])
 {
diff --git a/include/hash.h b/include/hash.h
index 2dbbd9b..c402067 100644
--- a/include/hash.h
+++ b/include/hash.h
@@ -71,4 +71,26 @@ enum {
 int hash_command(const char *algo_name, int flags, cmd_tbl_t *cmdtp, int flag,
 int argc, char * const argv[]);
 
+/**
+ * hash_block() - Hash a block according to the requested algorithm
+ *
+ * The caller probably knows the hash length for the chosen algorithm, but
+ * in order to provide a general interface, and output_size parameter is
+ * provided.
+ *
+ * @algo_name: Hash algorithm to use
+ * @data:  Data to hash
+ * @len:   Lengh of data to hash in bytes
+ * @output:Place to put hash value
+ * @output_size:   On entry, pointer to the number of bytes available in
+ * output. On exit, pointer to the number of bytes used.
+ * If NULL, then it is assumed that the caller has
+ * allocated enough space for the hash. This is possible
+ * since the caller is selecting the algorithm.
+ * @return 0 if ok, -ve on error: -EPROTONOSUPPORT for an unknown algorithm,
+ * -ENOSPC if the output buffer is not large enough.
+ */
+int hash_block(const char *algo_name, const void *data, unsigned int len,
+  uint8_t *output, int *output_size);
+
 #endif
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 14/45] image: Export fit_conf_get_prop_node()

2013-03-18 Thread Simon Glass
This function will be needed by signature checking code, so export it,
and also add docs.

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2:
- Put params before description in fit_conf_get_prop_node() comment

 common/image-fit.c |  8 
 include/image.h| 14 ++
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index 97f8521..b8a1eb4 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -1310,7 +1310,7 @@ int fit_conf_get_node(const void *fit, const char 
*conf_uname)
return noffset;
 }
 
-static int __fit_conf_get_prop_node(const void *fit, int noffset,
+int fit_conf_get_prop_node(const void *fit, int noffset,
const char *prop_name)
 {
char *uname;
@@ -1340,7 +1340,7 @@ static int __fit_conf_get_prop_node(const void *fit, int 
noffset,
  */
 int fit_conf_get_kernel_node(const void *fit, int noffset)
 {
-   return __fit_conf_get_prop_node(fit, noffset, FIT_KERNEL_PROP);
+   return fit_conf_get_prop_node(fit, noffset, FIT_KERNEL_PROP);
 }
 
 /**
@@ -1359,7 +1359,7 @@ int fit_conf_get_kernel_node(const void *fit, int noffset)
  */
 int fit_conf_get_ramdisk_node(const void *fit, int noffset)
 {
-   return __fit_conf_get_prop_node(fit, noffset, FIT_RAMDISK_PROP);
+   return fit_conf_get_prop_node(fit, noffset, FIT_RAMDISK_PROP);
 }
 
 /**
@@ -1378,7 +1378,7 @@ int fit_conf_get_ramdisk_node(const void *fit, int 
noffset)
  */
 int fit_conf_get_fdt_node(const void *fit, int noffset)
 {
-   return __fit_conf_get_prop_node(fit, noffset, FIT_FDT_PROP);
+   return fit_conf_get_prop_node(fit, noffset, FIT_FDT_PROP);
 }
 
 /**
diff --git a/include/image.h b/include/image.h
index 0d3d1db..c5e8844 100644
--- a/include/image.h
+++ b/include/image.h
@@ -630,6 +630,20 @@ int fit_conf_get_kernel_node(const void *fit, int noffset);
 int fit_conf_get_ramdisk_node(const void *fit, int noffset);
 int fit_conf_get_fdt_node(const void *fit, int noffset);
 
+/**
+ * fit_conf_get_prop_node() - Get node refered to by a configuration
+ * @fit:   FIT to check
+ * @noffset:   Offset of conf@xxx node to check
+ * @prop_name: Property to read from the conf node
+ *
+ * The conf@ nodes contain references to other nodes, using properties
+ * like 'kernel = kernel@1'. Given such a property name (e.g. kernel),
+ * return the offset of the node referred to (e.g. offset of node
+ * /images/kernel@1.
+ */
+int fit_conf_get_prop_node(const void *fit, int noffset,
+   const char *prop_name);
+
 void fit_conf_print(const void *fit, int noffset, const char *p);
 
 int fit_check_ramdisk(const void *fit, int os_noffset,
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 26/45] Add minor updates to README.fdt-control

2013-03-18 Thread Simon Glass
A few things have changed since this doc was written, so update it to
match the current state of things.

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2: None

 doc/README.fdt-control | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/doc/README.fdt-control b/doc/README.fdt-control
index 1e016d1..01b31fe 100644
--- a/doc/README.fdt-control
+++ b/doc/README.fdt-control
@@ -49,6 +49,10 @@ the features of each board in the device tree file, and have 
a single
 generic source base.
 
 To enable this feature, add CONFIG_OF_CONTROL to your board config file.
+It is currently supported on ARM, x86 and Microblaze - other architectures
+will need to add code to their arch/xxx/lib/board.c file to locate the
+FDT, at least until generic board support is complete. For ARM, Tegra and
+Exynos5 have device trees available for common devices.
 
 
 What is a Flat Device Tree?
@@ -99,7 +103,8 @@ Then run the compiler (your version will vary):
*   Bad configuration:  0
* Strange test result:  0
 
-You will also find a useful ftdump utility for decoding a binary file.
+You will also find a useful fdtdump utility for decoding a binary file, as
+well as fdtget/fdtput for reading and writing properties in a binary file.
 
 
 Where do I get an fdt file for my board?
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 39/45] mkimage: Add -r option to specify keys that must be verified

2013-03-18 Thread Simon Glass
Normally, multiple public keys can be provided and U-Boot is not
required to use all of them for verification. This is because some
images may not be signed, or may be optionally signed.

But we still need a mechanism to determine when a key must be used.
This feature cannot be implemented in the FIT itself, since anyone
could change it to mark a key as optional. The requirement for
key verification must go in with the public keys, in a place that
is protected from modification.

Add a -r option which tells mkimage to mark all keys that it uses
for signing as 'required'.

If some keys are optional and some are required, run mkimage several
times (perhaps with different key directories if some keys are very
secret) using the -F flag to update an existing FIT.

Signed-off-by: Simon Glass s...@chromium.org
Reviewed-by: Marek Vasut ma...@denx.de
---
Changes in v2:
- Adjust mkimage help to separate out signing options
- Rebase on previous patches

 doc/mkimage.1 | 6 ++
 tools/fit_image.c | 9 +
 tools/mkimage.c   | 8 ++--
 tools/mkimage.h   | 1 +
 4 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/doc/mkimage.1 b/doc/mkimage.1
index b67a351..14374da 100644
--- a/doc/mkimage.1
+++ b/doc/mkimage.1
@@ -133,6 +133,12 @@ the corresponding public key is written into this file for 
for run-time
 verification. Typically the file here is the device tree binary used by
 CONFIG_OF_CONTROL in U-Boot.
 
+.TP
+.BI \-r
+Specifies that keys used to sign the FIT are required. This means that they
+must be verified for the image to boot. Without this option, the verification
+will be optional (useful for testing but not for release).
+
 .SH EXAMPLES
 
 List image information:
diff --git a/tools/fit_image.c b/tools/fit_image.c
index d48f571..281c2bd 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -152,10 +152,11 @@ static int fit_handle_file (struct mkimage_params *params)
goto err_mmap;
 
/* set hashes for images in the blob */
-   if (fit_add_verification_data(params-keydir, dest_blob, ptr,
- params-comment, 0)) {
-   fprintf (stderr, %s Can't add hashes to FIT blob,
-params-cmdname);
+   if (fit_add_verification_data(params-keydir,
+ dest_blob, ptr, params-comment,
+ params-require_keys)) {
+   fprintf(stderr, %s Can't add hashes to FIT blob\n,
+   params-cmdname);
goto err_add_hashes;
}
 
diff --git a/tools/mkimage.c b/tools/mkimage.c
index b3b45a4..d312844 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -270,6 +270,9 @@ main (int argc, char **argv)
usage ();
params.imagename = *++argv;
goto NXTARG;
+   case 'r':
+   params.require_keys = 1;
+   break;
case 'R':
if (--argc = 0)
usage();
@@ -645,11 +648,12 @@ usage ()
fprintf(stderr,   -D = set options for device tree compiler\n
  -f = input filename for FIT source\n);
 #ifdef CONFIG_FIT_SIGNATURE
-   fprintf(stderr, Signing / verified boot options: [-k keydir] [-K dtb] 
[ -c comment]\n
+   fprintf(stderr, Signing / verified boot options: [-k keydir] [-K dtb] 
[ -c comment] [-r]\n
  -k = set directory containing private 
keys\n
  -K = write public keys to this .dtb file\n
  -c = add comment in signature node\n
- -F = re-sign existing FIT image\n);
+ -F = re-sign existing FIT image\n
+ -r = mark keys used as 'required' in 
dtb\n);
 #else
fprintf(stderr, Signing / verified boot not supported 
(CONFIG_FIT_SIGNATURE undefined)\n);
 #endif
diff --git a/tools/mkimage.h b/tools/mkimage.h
index 4391ca8..d82be17 100644
--- a/tools/mkimage.h
+++ b/tools/mkimage.h
@@ -78,6 +78,7 @@ struct mkimage_params {
const char *keydir; /* Directory holding private keys */
const char *keydest;/* Destination .dtb for public key */
const char *comment;/* Comment to add to signature node */
+   int require_keys;   /* 1 to mark signing keys as 'required' */
 };
 
 /*
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 29/45] sandbox: Provide a way to map from host RAM to U-Boot RAM

2013-03-18 Thread Simon Glass
In many cases, pointers to memory are passed around, and these pointers
refer to U-Boot memory, not host memory. This in itself is not a
problem.

However, in a few places, we cast that pointer back to a ulong (being
a U-Boot memory address). It is possible to convert many of these cases
to avoid this. However there are data structures (e.g. struct
bootm_headers) which use pointers. We could with a lot of effort adjust
the structs and all code that uses them to use ulong instead of pointers.

This seems like an unacceptable cost, since our objective with sandbox
is to minimise the impact on U-Boot code while maximising the features
available to sandbox.

Therefore, create a map_to_sysmem() function which converts from a
pointer to a U-Boot address. This can be used sparingly when needed.

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2:
- Use gd-arch.ram_buf instead of gd-ram_buf (now that generic board is in)

 arch/sandbox/cpu/cpu.c| 5 +
 arch/sandbox/include/asm/io.h | 2 ++
 include/common.h  | 5 +
 3 files changed, 12 insertions(+)

diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index b2788d5..dd8d495 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -57,6 +57,11 @@ void *map_physmem(phys_addr_t paddr, unsigned long len, 
unsigned long flags)
return (void *)(gd-arch.ram_buf + paddr);
 }
 
+phys_addr_t map_to_sysmem(void *ptr)
+{
+   return (u8 *)ptr - gd-arch.ram_buf;
+}
+
 void flush_dcache_range(unsigned long start, unsigned long stop)
 {
 }
diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h
index d8c0236..4ce7a84 100644
--- a/arch/sandbox/include/asm/io.h
+++ b/arch/sandbox/include/asm/io.h
@@ -49,3 +49,5 @@ static inline void *map_sysmem(phys_addr_t paddr, unsigned 
long len)
 static inline void unmap_sysmem(const void *vaddr)
 {
 }
+
+phys_addr_t map_to_sysmem(void *ptr);
diff --git a/include/common.h b/include/common.h
index 52f2b33..58fccd3 100644
--- a/include/common.h
+++ b/include/common.h
@@ -907,6 +907,11 @@ static inline void *map_sysmem(phys_addr_t paddr, unsigned 
long len)
 static inline void unmap_sysmem(const void *vaddr)
 {
 }
+
+static inline phys_addr_t map_to_sysmem(void *ptr)
+{
+   return (phys_addr_t)(uintptr_t)ptr;
+}
 # endif
 
 #endif /* __ASSEMBLY__ */
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 40/45] libfdt: Add fdt_find_regions()

2013-03-18 Thread Simon Glass
Add a function to find regions in device tree given a list of nodes to
include and properties to exclude.

See the header file for full documentation.

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2:
- Fix checkpatch checks about parenthesis alignment

 include/libfdt.h |  64 +
 lib/libfdt/fdt_wip.c | 129 +++
 2 files changed, 193 insertions(+)

diff --git a/include/libfdt.h b/include/libfdt.h
index 50c90d6..3e96fe1 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -1492,4 +1492,68 @@ int fdt_del_node(void *fdt, int nodeoffset);
 
 const char *fdt_strerror(int errval);
 
+struct fdt_region {
+   int offset;
+   int size;
+};
+
+/**
+ * fdt_find_regions() - find regions in device tree
+ *
+ * Given a list of nodes to include and properties to exclude, find
+ * the regions of the device tree which describe those included parts.
+ *
+ * The intent is to get a list of regions which will be invariant provided
+ * those parts are invariant. For example, if you request a list of regions
+ * for all nodes but exclude the property data, then you will get the
+ * same region contents regardless of any change to data properties.
+ *
+ * This function can be used to produce a byte-stream to send to a hashing
+ * function to verify that critical parts of the FDT have not changed.
+ *
+ * Nodes which are given in 'inc' are included in the region list, as
+ * are the names of the immediate subnodes nodes (but not the properties
+ * or subnodes of those subnodes).
+ *
+ * For eaxample / means to include the root node, all root properties
+ * and the FDT_BEGIN_NODE and FDT_END_NODE of all subnodes of /. The latter
+ * ensures that we capture the names of the subnodes. In a hashing situation
+ * it prevents the root node from changing at all Any change to non-excluded
+ * properties, names of subnodes or number of subnodes would be detected.
+ *
+ * When used with FITs this provides the ability to hash and sign parts of
+ * the FIT based on different configurations in the FIT. Then it is
+ * impossible to change anything about that configuration (include images
+ * attached to the configuration), but it may be possible to add new
+ * configurations, new images or new signatures within the existing
+ * framework.
+ *
+ * Adding new properties to a device tree may result in the string table
+ * being extended (if the new property names are different from those
+ * already added). This function can optionally include a region for
+ * the string table so that this can be part of the hash too.
+ *
+ * The device tree header is not included in the list.
+ *
+ * @fdt:   Device tree to check
+ * @inc:   List of node paths to included
+ * @inc_count: Number of node paths in list
+ * @exc_prop:  List of properties names to exclude
+ * @exc_prop_count:Number of properties in exclude list
+ * @region:Returns list of regions
+ * @max_region:Maximum length of region list
+ * @path:  Pointer to a temporary string for the function to use for
+ * building path names
+ * @path_len:  Length of path, must be large enough to hold the longest
+ * path in the tree
+ * @add_string_tab:1 to add a region for the string table
+ * @return number of regions in list. If this is max_regions then the
+ * region array was exhausted. You should increase max_regions and try
+ * the call again.
+ */
+int fdt_find_regions(const void *fdt, char * const inc[], int inc_count,
+char * const exc_prop[], int exc_prop_count,
+struct fdt_region region[], int max_regions,
+char *path, int path_len, int add_string_tab);
+
 #endif /* _LIBFDT_H */
diff --git a/lib/libfdt/fdt_wip.c b/lib/libfdt/fdt_wip.c
index 63e67b7..b9e3c4a 100644
--- a/lib/libfdt/fdt_wip.c
+++ b/lib/libfdt/fdt_wip.c
@@ -120,3 +120,132 @@ int fdt_nop_node(void *fdt, int nodeoffset)
endoffset - nodeoffset);
return 0;
 }
+
+#define FDT_MAX_DEPTH  32
+
+static int str_in_list(const char *str, char * const list[], int count)
+{
+   int i;
+
+   for (i = 0; i  count; i++)
+   if (!strcmp(list[i], str))
+   return 1;
+
+   return 0;
+}
+
+int fdt_find_regions(const void *fdt, char * const inc[], int inc_count,
+char * const exc_prop[], int exc_prop_count,
+struct fdt_region region[], int max_regions,
+char *path, int path_len, int add_string_tab)
+{
+   int stack[FDT_MAX_DEPTH];
+   char *end;
+   int nextoffset = 0;
+   uint32_t tag;
+   int count = 0;
+   int start = -1;
+   int depth = -1;
+   int want = 0;
+   int base = fdt_off_dt_struct(fdt);
+
+   end = path;
+   *end = '\0';
+   do {
+   const struct fdt_property *prop;
+   const char *name;
+   const char *str;
+

[U-Boot] [PATCH v2 28/45] sandbox: config: Enable FIT signatures with RSA

2013-03-18 Thread Simon Glass
We want to sign and verify images using sandbox, so enable these options.

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2: None

 include/configs/sandbox.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index 1c7bbe1..fb1c583 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -33,6 +33,8 @@
 #define CONFIG_OF_LIBFDT
 #define CONFIG_LMB
 #define CONFIG_FIT
+#define CONFIG_FIT_SIGNATURE
+#define CONFIG_RSA
 #define CONFIG_CMD_FDT
 
 #define CONFIG_FS_FAT
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 30/45] sandbox: image: Add support for booting images in sandbox

2013-03-18 Thread Simon Glass
Much of the image code uses addresses as ulongs and pointers interchangeably,
casting between the two forms as needed.

This doesn't work with sandbox, which has a U-Boot RAM buffer which is
separate from the host machine's memory.

Adjust the cost so that translating from a U-Boot address to a pointer uses
map_sysmem(). This allows bootm to work correctly on sandbox.

Note that there are no exhaustive tests for this code on sandbox, so it is
possible that some dark corners remain.

Signed-off-by: Simon Glass s...@chromium.org
Reviewed-by: Marek Vasut ma...@denx.de (v1)
---
Changes in v2:
- Fix checkpatch checks about parenthesis alignment

 common/cmd_bootm.c | 21 -
 common/image.c | 48 
 include/image.h|  2 +-
 3 files changed, 41 insertions(+), 30 deletions(-)

diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index f6eb7a6..c03e88f 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -36,6 +36,7 @@
 #include lmb.h
 #include linux/ctype.h
 #include asm/byteorder.h
+#include asm/io.h
 #include linux/compiler.h
 
 #if defined(CONFIG_CMD_USB)
@@ -97,7 +98,7 @@ static image_header_t *image_get_kernel(ulong img_addr, int 
verify);
 static int fit_check_kernel(const void *fit, int os_noffset, int verify);
 #endif
 
-static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
+static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[], bootm_headers_t *images,
ulong *os_data, ulong *os_len);
 
@@ -197,8 +198,8 @@ static inline void boot_start_lmb(bootm_headers_t *images) 
{ }
 
 static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const 
argv[])
 {
-   void*os_hdr;
-   int ret;
+   const void *os_hdr;
+   int ret;
 
memset((void *)images, 0, sizeof(images));
images.verify = getenv_yesno(verify);
@@ -849,14 +850,15 @@ static int fit_check_kernel(const void *fit, int 
os_noffset, int verify)
  * pointer to image header if valid image was found, plus kernel start
  * address and length, otherwise NULL
  */
-static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
+static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[], bootm_headers_t *images, ulong *os_data,
ulong *os_len)
 {
image_header_t  *hdr;
ulong   img_addr;
+   const void *buf;
 #if defined(CONFIG_FIT)
-   void*fit_hdr;
+   const void  *fit_hdr;
const char  *fit_uname_config = NULL;
const char  *fit_uname_kernel = NULL;
const void  *data;
@@ -892,7 +894,8 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, 
int argc,
 
/* check image type, for FIT images get FIT kernel node */
*os_data = *os_len = 0;
-   switch (genimg_get_format((void *)img_addr)) {
+   buf = map_sysmem(img_addr, 0);
+   switch (genimg_get_format(buf)) {
case IMAGE_FORMAT_LEGACY:
printf(## Booting kernel from Legacy Image at %08lx ...\n,
img_addr);
@@ -937,7 +940,7 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, 
int argc,
break;
 #if defined(CONFIG_FIT)
case IMAGE_FORMAT_FIT:
-   fit_hdr = (void *)img_addr;
+   fit_hdr = buf;
printf(## Booting kernel from FIT Image at %08lx ...\n,
img_addr);
 
@@ -1014,7 +1017,7 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, 
int argc,
 
*os_len = len;
*os_data = (ulong)data;
-   images-fit_hdr_os = fit_hdr;
+   images-fit_hdr_os = (void *)fit_hdr;
images-fit_uname_os = fit_uname_kernel;
images-fit_noffset_os = os_noffset;
break;
@@ -1028,7 +1031,7 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, 
int argc,
debug(   kernel data at 0x%08lx, len = 0x%08lx (%ld)\n,
*os_data, *os_len, *os_len);
 
-   return (void *)img_addr;
+   return buf;
 }
 
 #ifdef CONFIG_SYS_LONGHELP
diff --git a/common/image.c b/common/image.c
index 3fbdd9b..14d1c48 100644
--- a/common/image.c
+++ b/common/image.c
@@ -51,6 +51,7 @@
 
 #include u-boot/md5.h
 #include sha1.h
+#include asm/io.h
 
 #ifdef CONFIG_CMD_BDI
 extern int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const 
argv[]);
@@ -90,6 +91,7 @@ static const table_entry_t uimage_arch[] = {
{   IH_ARCH_AVR32,  avr32,AVR32,},
{   IH_ARCH_NDS32,  nds32,NDS32,},
{   IH_ARCH_OPENRISC,   or1k, OpenRISC 1000,},
+   {   IH_ARCH_SANDBOX,sandbox,  Sandbox,  },
{   -1, , 

[U-Boot] [PATCH v2 43/45] image: Add CONFIG_FIT_SPL_PRINT to control FIT image printing in SPL

2013-03-18 Thread Simon Glass
This code is very large, and in SPL it isn't always useful to print
out image information (in fact there might not even be a console
active). So disable this feature unless this option is set.

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2:
- Add new patch to control FIT image printing in SPL
- Fix checkpatch warnings about space after cast

 README |  6 ++
 common/image-fit.c |  8 +---
 include/image.h| 33 +++--
 3 files changed, 42 insertions(+), 5 deletions(-)

diff --git a/README b/README
index d8ccc3e..d98fd98 100644
--- a/README
+++ b/README
@@ -2909,6 +2909,12 @@ FIT uImage format:
use an arch-specific makefile fragment instead, for
example if more than one image needs to be produced.
 
+   CONFIG_FIT_SPL_PRINT
+   Printing information about a FIT image adds quite a bit of
+   code to SPL. So this is normally disabled in SPL. Use this
+   option to re-enable it. This will affect the output of the
+   bootm command when booting a FIT image.
+
 Modem Support:
 --
 
diff --git a/common/image-fit.c b/common/image-fit.c
index 29ea4c9..b7ff0da 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -126,6 +126,7 @@ static void fit_get_debug(const void *fit, int noffset,
  fdt_strerror(err));
 }
 
+#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_FIT_SPL_PRINT)
 /**
  * fit_print_contents - prints out the contents of the FIT format image
  * @fit: pointer to the FIT format image header
@@ -422,6 +423,7 @@ void fit_image_print(const void *fit, int image_noffset, 
const char *p)
}
}
 }
+#endif
 
 /**
  * fit_get_desc - get node description property
@@ -872,16 +874,16 @@ int fit_set_timestamp(void *fit, int noffset, time_t 
timestamp)
 int calculate_hash(const void *data, int data_len, const char *algo,
uint8_t *value, int *value_len)
 {
-   if (strcmp(algo, crc32) == 0) {
+   if (IMAGE_ENABLE_CRC32  strcmp(algo, crc32) == 0) {
*((uint32_t *)value) = crc32_wd(0, data, data_len,
CHUNKSZ_CRC32);
*((uint32_t *)value) = cpu_to_uimage(*((uint32_t *)value));
*value_len = 4;
-   } else if (strcmp(algo, sha1) == 0) {
+   } else if (IMAGE_ENABLE_SHA1  strcmp(algo, sha1) == 0) {
sha1_csum_wd((unsigned char *)data, data_len,
 (unsigned char *)value, CHUNKSZ_SHA1);
*value_len = 20;
-   } else if (strcmp(algo, md5) == 0) {
+   } else if (IMAGE_ENABLE_MD5  strcmp(algo, md5) == 0) {
md5_wd((unsigned char *)data, data_len, value, CHUNKSZ_MD5);
*value_len = 16;
} else {
diff --git a/include/image.h b/include/image.h
index 5766b58..3a70404 100644
--- a/include/image.h
+++ b/include/image.h
@@ -64,8 +64,37 @@
 #if defined(CONFIG_FIT)
 #include libfdt.h
 #include fdt_support.h
-#define CONFIG_MD5 /* FIT images need MD5 support */
-#define CONFIG_SHA1/* and SHA1 */
+# ifdef CONFIG_SPL_BUILD
+#  ifdef CONFIG_SPL_CRC32_SUPPORT
+#   define IMAGE_ENABLE_CRC32  1
+#  endif
+#  ifdef CONFIG_SPL_MD5_SUPPORT
+#   define IMAGE_ENABLE_MD51
+#  endif
+#  ifdef CONFIG_SPL_SHA1_SUPPORT
+#   define IMAGE_ENABLE_SHA1   1
+#  endif
+# else
+#  define CONFIG_CRC32 /* FIT images need CRC32 support */
+#  define CONFIG_MD5   /* and MD5 */
+#  define CONFIG_SHA1  /* and SHA1 */
+#  define IMAGE_ENABLE_CRC32   1
+#  define IMAGE_ENABLE_MD5 1
+#  define IMAGE_ENABLE_SHA11
+# endif
+
+#ifndef IMAGE_ENABLE_CRC32
+#define IMAGE_ENABLE_CRC32 0
+#endif
+
+#ifndef IMAGE_ENABLE_MD5
+#define IMAGE_ENABLE_MD5   0
+#endif
+
+#ifndef IMAGE_ENABLE_SHA1
+#define IMAGE_ENABLE_SHA1  0
+#endif
+
 #endif
 
 /*
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 37/45] mkimage: Add -F option to modify an existing .fit file

2013-03-18 Thread Simon Glass
When signing images it is sometimes necessary to sign with different keys
at different times, or make the signer entirely separate from the FIT
creation to avoid needing the private keys to be publicly available in
the system.

Add a -F option so that key signing can be a separate step, and possibly
done multiple times as different keys are avaiable.

Signed-off-by: Simon Glass s...@chromium.org
Reviewed-by: Marek Vasut ma...@denx.de
---
Changes in v2:
- Adjust mkimage help to separate out signing options
- Fix checkpatch checks about parenthesis alignment
- Rebase on previous patches

 doc/mkimage.1 | 20 
 tools/fit_image.c | 18 --
 tools/mkimage.c   |  9 ++---
 3 files changed, 38 insertions(+), 9 deletions(-)

diff --git a/doc/mkimage.1 b/doc/mkimage.1
index 8185ff5..f9c733a 100644
--- a/doc/mkimage.1
+++ b/doc/mkimage.1
@@ -10,6 +10,9 @@ mkimage \- Generate image for U-Boot
 .RB [\fIoptions\fP]  \-f [ image tree source file ]  [ uimage file 
name ]
 
 .B mkimage
+.RB [\fIoptions\fP]  \-F [ uimage file name ]
+
+.B mkimage
 .RB [\fIoptions\fP]  (legacy mode)
 
 .SH DESCRIPTION
@@ -104,6 +107,13 @@ Image tree source file that describes the structure and 
contents of the
 FIT image.
 
 .TP
+.BI \-F
+Indicates that an existing FIT image should be modified. No dtc
+compilation is performed and the -f flag should not be given.
+This can be used to sign images with additional keys after initial image
+creation.
+
+.TP
 .BI \-k [ key_directory ]
 Specifies the directory containing keys to use for signing. This directory
 should contain a private key file name.key for use with signing and a
@@ -144,6 +154,16 @@ skipping those for which keys cannot be found. Also add a 
comment.
 -c Kernel 3.8 image for production devices kernel.itb
 .fi
 
+.P
+Update an existing FIT image, signing it with additional keys.
+Add corresponding public keys into u-boot.dtb. This will resign all images
+with keys that are available in the new directory. Images that request signing
+with unavailable keys are skipped.
+.nf
+.B mkimage -F -k /secret/signing-keys -K u-boot.dtb 
+-c Kernel 3.8 image for production devices kernel.itb
+.fi
+
 .SH HOMEPAGE
 http://www.denx.de/wiki/U-Boot/WebHome
 .PP
diff --git a/tools/fit_image.c b/tools/fit_image.c
index b17fa2d..645e93c 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -124,10 +124,16 @@ static int fit_handle_file (struct mkimage_params *params)
}
sprintf (tmpfile, %s%s, params-imagefile, MKIMAGE_TMPFILE_SUFFIX);
 
-   /* dtc -I dts -O dtb -p 500 datafile  tmpfile */
-   sprintf (cmd, %s %s %s  %s,
-   MKIMAGE_DTC, params-dtc, params-datafile, tmpfile);
-   debug (Trying to execute \%s\\n, cmd);
+   /* We either compile the source file, or use the existing FIT image */
+   if (params-datafile) {
+   /* dtc -I dts -O dtb -p 500 datafile  tmpfile */
+   snprintf(cmd, sizeof(cmd), %s %s %s  %s,
+MKIMAGE_DTC, params-dtc, params-datafile, tmpfile);
+   debug(Trying to execute \%s\\n, cmd);
+   } else {
+   snprintf(cmd, sizeof(cmd), cp %s %s,
+params-imagefile, tmpfile);
+   }
if (system (cmd) == -1) {
fprintf (stderr, %s: system(%s) failed: %s\n,
params-cmdname, cmd, strerror(errno));
@@ -153,8 +159,8 @@ static int fit_handle_file (struct mkimage_params *params)
goto err_add_hashes;
}
 
-   /* add a timestamp at offset 0 i.e., root  */
-   if (fit_set_timestamp (ptr, 0, sbuf.st_mtime)) {
+   /* for first image creation, add a timestamp at offset 0 i.e., root  */
+   if (params-datafile  fit_set_timestamp(ptr, 0, sbuf.st_mtime)) {
fprintf (stderr, %s: Can't add image timestamp\n,
params-cmdname);
goto err_add_timestamp;
diff --git a/tools/mkimage.c b/tools/mkimage.c
index 3760392..e2b82d0 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -240,12 +240,14 @@ main (int argc, char **argv)
case 'f':
if (--argc = 0)
usage ();
+   params.datafile = *++argv;
+   /* no break */
+   case 'F':
/*
 * The flattened image tree (FIT) format
 * requires a flattened device tree image type
 */
params.type = IH_TYPE_FLATDT;
-   params.datafile = *++argv;
params.fflag = 1;
goto NXTARG;
case 'k':
@@ -633,14 +635,15 @@ usage ()
   -d == use image data from 'datafile'\n
  

[U-Boot] [PATCH v2 31/45] image: Add signing infrastructure

2013-03-18 Thread Simon Glass
Add a structure to describe an algorithm which can sign and (later) verify
images.

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2:
- Adjust how signing enable works in image.h
- Rebase on previous patches
- Tweak tools/Makefile to make image signing optional
- Update README to fix typos and clarify some points
- gd-fdt_blob is now available on all archs (generic board landed)

 README   |   5 +
 common/Makefile  |   1 +
 common/image-sig.c   |  42 +
 doc/uImage.FIT/signature.txt | 216 +++
 include/image.h  | 107 -
 tools/Makefile   |   6 ++
 6 files changed, 376 insertions(+), 1 deletion(-)
 create mode 100644 common/image-sig.c
 create mode 100644 doc/uImage.FIT/signature.txt

diff --git a/README b/README
index a620f0a..de753f3 100644
--- a/README
+++ b/README
@@ -2705,6 +2705,11 @@ FIT uImage format:
most specific compatibility entry of U-Boot's fdt's root node.
The order of entries in the configuration's fdt is ignored.
 
+   CONFIG_FIT_SIGNATURE
+   This option enables signature verification of FIT uImages,
+   using a hash signed and verified using RSA. See
+   doc/uImage.FIT/signature.txt for more details.
+
 - Standalone program support:
CONFIG_STANDALONE_LOAD_ADDR
 
diff --git a/common/Makefile b/common/Makefile
index 36b4ffc..32cfe70 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -228,6 +228,7 @@ COBJS-y += console.o
 COBJS-y += dlmalloc.o
 COBJS-y += image.o
 COBJS-$(CONFIG_FIT) += image-fit.o
+COBJS-$(CONFIG_FIT_SIGNATURE) += image-sig.o
 COBJS-y += memsize.o
 COBJS-y += stdio.o
 
diff --git a/common/image-sig.c b/common/image-sig.c
new file mode 100644
index 000..841c662
--- /dev/null
+++ b/common/image-sig.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2013, Google Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifdef USE_HOSTCC
+#include mkimage.h
+#include time.h
+#else
+#include common.h
+#endif /* !USE_HOSTCC*/
+#include errno.h
+#include image.h
+
+struct image_sig_algo image_sig_algos[] = {
+};
+
+struct image_sig_algo *image_get_sig_algo(const char *name)
+{
+   int i;
+
+   for (i = 0; i  ARRAY_SIZE(image_sig_algos); i++) {
+   if (!strcmp(image_sig_algos[i].name, name))
+   return image_sig_algos[i];
+   }
+
+   return NULL;
+}
diff --git a/doc/uImage.FIT/signature.txt b/doc/uImage.FIT/signature.txt
new file mode 100644
index 000..0d145e0
--- /dev/null
+++ b/doc/uImage.FIT/signature.txt
@@ -0,0 +1,216 @@
+U-Boot FIT Signature Verification
+=
+
+Introduction
+
+FIT supports hashing of images so that these hashes can be checked on
+loading. This protects against corruption of the image. However it does not
+prevent the substitution of one image for another.
+
+The signature feature allows the hash to be signed with a private key such
+that it can be verified using a public key later. Provided that the private
+key is kept secret and the public key is stored in a non-volatile place,
+any image can be verified in this way.
+
+See verified-boot.txt for more general information on verified boot.
+
+
+Concepts
+
+Some familiarity with public key cryptography is assumed in this section.
+
+The procedure for signing is as follows:
+
+   - hash an image in the FIT
+   - sign the hash with a private key to produce a signature
+   - store the resulting signature in the FIT
+
+The procedure for verification is:
+
+   - read the FIT
+   - obtain the public key
+   - extract the signature from the FIT
+   - hash the image from the FIT
+   - verify (with the public key) that the extracted signature matches the
+   hash
+
+The signing is generally performed by mkimage, as part of making a firmware
+image for the device. The verification is normally done in U-Boot on the
+device.
+
+
+Algorithms
+--
+In principle any suitable algorithm can be used to sign and verify a hash.
+At present only one class of algorithms is supported: SHA1 hashing with RSA.
+This works by hashing the image to produce a 20-byte hash.
+
+While it is acceptable to bring in large 

[U-Boot] [PATCH v2 35/45] mkimage: Add -k option to specify key directory

2013-03-18 Thread Simon Glass
Keys required for signing images will be in a specific directory. Add a
-k option to specify that directory.

Also update the mkimage man page with this information and a clearer list
of available commands.

Signed-off-by: Simon Glass s...@chromium.org
Reviewed-by: Marek Vasut ma...@denx.de (v1)
---
Changes in v2:
- Adjust mkimage help to separate out signing options
- Fix checkpatch warnings about split strings

 doc/mkimage.1 | 25 ++---
 tools/fit_image.c |  2 +-
 tools/mkimage.c   | 15 ++-
 tools/mkimage.h   |  1 +
 4 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/doc/mkimage.1 b/doc/mkimage.1
index 39652c8..6740fb1 100644
--- a/doc/mkimage.1
+++ b/doc/mkimage.1
@@ -4,7 +4,14 @@
 mkimage \- Generate image for U-Boot
 .SH SYNOPSIS
 .B mkimage
-.RB [\fIoptions\fP]
+.RB \-l [ uimage file name ]
+
+.B mkimage
+.RB [\fIoptions\fP]  \-f [ image tree source file ]  [ uimage file 
name ]
+
+.B mkimage
+.RB [\fIoptions\fP]  (legacy mode)
+
 .SH DESCRIPTION
 The
 .B mkimage
@@ -26,7 +33,8 @@ etc.
 The new
 .I FIT (Flattened Image Tree) format
 allows for more flexibility in handling images of various types and also
-enhances integrity protection of images with stronger checksums.
+enhances integrity protection of images with stronger checksums. It also
+supports verified boot.
 
 .SH OPTIONS
 
@@ -67,6 +75,10 @@ Set load address with a hex number.
 Set entry point with a hex number.
 
 .TP
+.BI \-l
+List the contents of an image.
+
+.TP
 .BI \-n [ image name ]
 Set image name to 'image name'.
 
@@ -91,6 +103,12 @@ create the image.
 Image tree source file that describes the structure and contents of the
 FIT image.
 
+.TP
+.BI \-k [ key_directory ]
+Specifies the directory containing keys to use for signing. This directory
+should contain a private key file name.key for use with signing and a
+certificate name.crt (containing the public key) for use with verification.
+
 .SH EXAMPLES
 
 List image information:
@@ -115,4 +133,5 @@ http://www.denx.de/wiki/U-Boot/WebHome
 .PP
 .SH AUTHOR
 This manual page was written by Nobuhiro Iwamatsu iwama...@nigauri.org
-and Wolfgang Denk w...@denx.de
+and Wolfgang Denk w...@denx.de. It was updated for image signing by
+Simon Glass s...@chromium.org.
diff --git a/tools/fit_image.c b/tools/fit_image.c
index ef6ef44..339e0f8 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -137,7 +137,7 @@ static int fit_handle_file (struct mkimage_params *params)
goto err_mmap;
 
/* set hashes for images in the blob */
-   if (fit_add_verification_data(NULL, NULL, ptr, NULL, 0)) {
+   if (fit_add_verification_data(params-keydir, NULL, ptr, NULL, 0)) {
fprintf (stderr, %s Can't add hashes to FIT blob,
params-cmdname);
goto err_add_hashes;
diff --git a/tools/mkimage.c b/tools/mkimage.c
index e43b09f..def7df2 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -248,6 +248,11 @@ main (int argc, char **argv)
params.datafile = *++argv;
params.fflag = 1;
goto NXTARG;
+   case 'k':
+   if (--argc = 0)
+   usage();
+   params.keydir = *++argv;
+   goto NXTARG;
case 'n':
if (--argc = 0)
usage ();
@@ -623,8 +628,16 @@ usage ()
   -d == use image data from 'datafile'\n
   -x == set XIP (execute in place)\n,
params.cmdname);
-   fprintf (stderr,%s [-D dtc_options] -f fit-image.its 
fit-image\n,
+   fprintf(stderr,%s [-D dtc_options] -f fit-image.its 
fit-image\n,
params.cmdname);
+   fprintf(stderr,   -D = set options for device tree compiler\n
+ -f = input filename for FIT source\n);
+#ifdef CONFIG_FIT_SIGNATURE
+   fprintf(stderr, Signing / verified boot options: [-k keydir]\n
+ -k = set directory containing private 
keys\n);
+#else
+   fprintf(stderr, Signing / verified boot not supported 
(CONFIG_FIT_SIGNATURE undefined)\n);
+#endif
fprintf (stderr,%s -V == print version information and 
exit\n,
params.cmdname);
 
diff --git a/tools/mkimage.h b/tools/mkimage.h
index e07a615..2a5f115 100644
--- a/tools/mkimage.h
+++ b/tools/mkimage.h
@@ -75,6 +75,7 @@ struct mkimage_params {
char *datafile;
char *imagefile;
char *cmdname;
+   const char *keydir; /* Directory holding private keys */
 };
 
 /*
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 24/45] Revert fdt- Tell the FDT library where the device tree is

2013-03-18 Thread Simon Glass
This reverts commit 3b73459ea3421e9f8c6c8c62e1d3fe458ca5bc56.

In practice it doesn't seem like a good idea to make the the working
FDT point to the control FDT. Now that we can access the control FDT
using the 'fdt' command, there is no need for this feature. Remove it.

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2:
- Revert the whole change including the set_working_fdt_addr() part

 common/main.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/common/main.c b/common/main.c
index a15f020..953ef29 100644
--- a/common/main.c
+++ b/common/main.c
@@ -45,10 +45,6 @@
 #include fdtdec.h
 #endif
 
-#ifdef CONFIG_OF_LIBFDT
-#include fdt_support.h
-#endif /* CONFIG_OF_LIBFDT */
-
 #include post.h
 #include linux/ctype.h
 #include menu.h
@@ -376,10 +372,6 @@ void main_loop (void)
 
bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, main_loop);
 
-#if defined CONFIG_OF_CONTROL
-   set_working_fdt_addr((void *)gd-fdt_blob);
-#endif /* CONFIG_OF_CONTROL */
-
 #ifdef CONFIG_BOOTCOUNT_LIMIT
bootcount = bootcount_load();
bootcount++;
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 32/45] image: Support signing of images

2013-03-18 Thread Simon Glass
Add support for signing images using a new signature node. The process
is handled by fdt_add_verification_data() which now takes parameters to
provide the keys and related information.

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2:
- Adjust how signing enable works in image.h
- Fix FDT error handling in fit_image_write_sig()
- Fix checkpatch checks about parenthesis alignment
- Fix checkpatch warnings about split strings
- Require CONFIG_FIT_SIGNATURE in image.h for mkimage to support signing

 common/image-fit.c |  85 ++-
 common/image-sig.c | 148 
 doc/uImage.FIT/sign-images.its |  42 ++
 include/image.h|  59 -
 tools/fit_image.c  |   2 +-
 tools/image-host.c | 186 ++---
 6 files changed, 484 insertions(+), 38 deletions(-)
 create mode 100644 doc/uImage.FIT/sign-images.its

diff --git a/common/image-fit.c b/common/image-fit.c
index 5dcb0c6..30790d3 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -31,6 +31,8 @@
 #include time.h
 #else
 #include common.h
+#include errno.h
+DECLARE_GLOBAL_DATA_PTR;
 #endif /* !USE_HOSTCC*/
 
 #include bootstage.h
@@ -233,42 +235,45 @@ void fit_print_contents(const void *fit)
  * @fit: pointer to the FIT format image header
  * @noffset: offset of the hash node
  * @p: pointer to prefix string
+ * @type: Type of information to print (hash or sign)
  *
  * fit_image_print_data() lists properies for the processed hash node
  *
+ * This function avoid using puts() since it prints a newline on the host
+ * but does not in U-Boot.
+ *
  * returns:
  * no returned results
  */
-static void fit_image_print_data(const void *fit, int noffset, const char *p)
+static void fit_image_print_data(const void *fit, int noffset, const char *p,
+const char *type)
 {
-   char *algo;
+   const char *keyname;
uint8_t *value;
int value_len;
-   int i, ret;
-
-   /*
-* Check subnode name, must be equal to hash.
-* Multiple hash nodes require unique unit node
-* names, e.g. hash@1, hash@2, etc.
-*/
-   if (strncmp(fit_get_name(fit, noffset, NULL),
-   FIT_HASH_NODENAME,
-   strlen(FIT_HASH_NODENAME)) != 0)
-   return;
+   char *algo;
+   int required;
+   int ret, i;
 
-   debug(%s  Hash node:'%s'\n, p,
+   debug(%s  %s node:'%s'\n, p, type,
  fit_get_name(fit, noffset, NULL));
-
-   printf(%s  Hash algo:, p);
+   printf(%s  %s algo:, p, type);
if (fit_image_hash_get_algo(fit, noffset, algo)) {
printf(invalid/unsupported\n);
return;
}
-   printf(%s\n, algo);
+   printf(%s, algo);
+   keyname = fdt_getprop(fit, noffset, key-name-hint, NULL);
+   required = fdt_getprop(fit, noffset, required, NULL) != NULL;
+   if (keyname)
+   printf(:%s, keyname);
+   if (required)
+   printf( (required));
+   printf(\n);
 
ret = fit_image_hash_get_value(fit, noffset, value,
value_len);
-   printf(%s  Hash value:   , p);
+   printf(%s  %s value:   , p, type);
if (ret) {
printf(unavailable\n);
} else {
@@ -277,7 +282,18 @@ static void fit_image_print_data(const void *fit, int 
noffset, const char *p)
printf(\n);
}
 
-   debug(%s  Hash len: %d\n, p, value_len);
+   debug(%s  %s len: %d\n, p, type, value_len);
+
+   /* Signatures have a time stamp */
+   if (IMAGE_ENABLE_TIMESTAMP  keyname) {
+   time_t timestamp;
+
+   printf(%s  Timestamp:, p);
+   if (fit_get_timestamp(fit, noffset, timestamp))
+   printf(unavailable\n);
+   else
+   genimg_print_time(timestamp);
+   }
 }
 
 /**
@@ -302,8 +318,12 @@ static void fit_image_print_verification_data(const void 
*fit, int noffset,
 * names, e.g. hash@1, hash@2, signature@1, signature@2, etc.
 */
name = fit_get_name(fit, noffset, NULL);
-   if (!strncmp(name, FIT_HASH_NODENAME, strlen(FIT_HASH_NODENAME)))
-   fit_image_print_data(fit, noffset, p);
+   if (!strncmp(name, FIT_HASH_NODENAME, strlen(FIT_HASH_NODENAME))) {
+   fit_image_print_data(fit, noffset, p, Hash);
+   } else if (!strncmp(name, FIT_SIG_NODENAME,
+   strlen(FIT_SIG_NODENAME))) {
+   fit_image_print_data(fit, noffset, p, Sign);
+   }
 }
 
 /**
@@ -939,14 +959,24 @@ int fit_image_verify(const void *fit, int image_noffset)
 {
const void  *data;
size_t  size;
-   int noffset;
+   int noffset = 0;
int ndepth;
 

[U-Boot] [PATCH v2 38/45] mkimage: Add -c option to specify a comment for key signing

2013-03-18 Thread Simon Glass
When signing an image, it is useful to add some details about which tool
or person is authorising the signing. Add a comment field which can take
care of miscellaneous requirements.

Signed-off-by: Simon Glass s...@chromium.org
Reviewed-by: Marek Vasut ma...@denx.de
---
Changes in v2:
- Adjust mkimage help to separate out signing options
- Rebase on previous patches

 doc/mkimage.1 | 6 ++
 tools/fit_image.c | 4 ++--
 tools/mkimage.c   | 8 +++-
 tools/mkimage.h   | 1 +
 4 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/doc/mkimage.1 b/doc/mkimage.1
index f9c733a..b67a351 100644
--- a/doc/mkimage.1
+++ b/doc/mkimage.1
@@ -97,6 +97,12 @@ Set XIP (execute in place) flag.
 .B Create FIT image:
 
 .TP
+.BI \-c [ comment ]
+Specifies a comment to be added when signing. This is typically a useful
+message which describes how the image was signed or some other useful
+information.
+
+.TP
 .BI \-D [ dtc options ]
 Provide special options to the device tree compiler that is used to
 create the image.
diff --git a/tools/fit_image.c b/tools/fit_image.c
index 645e93c..d48f571 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -153,9 +153,9 @@ static int fit_handle_file (struct mkimage_params *params)
 
/* set hashes for images in the blob */
if (fit_add_verification_data(params-keydir, dest_blob, ptr,
- NULL, 0)) {
+ params-comment, 0)) {
fprintf (stderr, %s Can't add hashes to FIT blob,
-   params-cmdname);
+params-cmdname);
goto err_add_hashes;
}
 
diff --git a/tools/mkimage.c b/tools/mkimage.c
index e2b82d0..b3b45a4 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -183,6 +183,11 @@ main (int argc, char **argv)
genimg_get_arch_id (*++argv))  0)
usage ();
goto NXTARG;
+   case 'c':
+   if (--argc = 0)
+   usage();
+   params.comment = *++argv;
+   goto NXTARG;
case 'C':
if ((--argc = 0) ||
(params.comp =
@@ -640,9 +645,10 @@ usage ()
fprintf(stderr,   -D = set options for device tree compiler\n
  -f = input filename for FIT source\n);
 #ifdef CONFIG_FIT_SIGNATURE
-   fprintf(stderr, Signing / verified boot options: [-k keydir] [-K 
dtb]\n
+   fprintf(stderr, Signing / verified boot options: [-k keydir] [-K dtb] 
[ -c comment]\n
  -k = set directory containing private 
keys\n
  -K = write public keys to this .dtb file\n
+ -c = add comment in signature node\n
  -F = re-sign existing FIT image\n);
 #else
fprintf(stderr, Signing / verified boot not supported 
(CONFIG_FIT_SIGNATURE undefined)\n);
diff --git a/tools/mkimage.h b/tools/mkimage.h
index 41bec21..4391ca8 100644
--- a/tools/mkimage.h
+++ b/tools/mkimage.h
@@ -77,6 +77,7 @@ struct mkimage_params {
char *cmdname;
const char *keydir; /* Directory holding private keys */
const char *keydest;/* Destination .dtb for public key */
+   const char *comment;/* Comment to add to signature node */
 };
 
 /*
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 45/45] Add verified boot information and test

2013-03-18 Thread Simon Glass
Add a description of how to implement verified boot using signed FIT images,
and a simple test which verifies operation on sandbox.

The test signs a FIT image and verifies it, then signs a FIT configuration
and verifies it. Then it corrupts the signature to check that this is
detected.

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2:
- Update README to fix typos
- Use U-Boot's -c option instead of hard-coding a boot script

 doc/uImage.FIT/verified-boot.txt | 104 
 test/vboot/.gitignore|   3 +
 test/vboot/sandbox-kernel.dts|   7 +++
 test/vboot/sandbox-u-boot.dts|   7 +++
 test/vboot/sign-configs.its  |  45 ++
 test/vboot/sign-images.its   |  42 +
 test/vboot/vboot_test.sh | 126 +++
 7 files changed, 334 insertions(+)
 create mode 100644 doc/uImage.FIT/verified-boot.txt
 create mode 100644 test/vboot/.gitignore
 create mode 100644 test/vboot/sandbox-kernel.dts
 create mode 100644 test/vboot/sandbox-u-boot.dts
 create mode 100644 test/vboot/sign-configs.its
 create mode 100644 test/vboot/sign-images.its
 create mode 100755 test/vboot/vboot_test.sh

diff --git a/doc/uImage.FIT/verified-boot.txt b/doc/uImage.FIT/verified-boot.txt
new file mode 100644
index 000..3c83fbc
--- /dev/null
+++ b/doc/uImage.FIT/verified-boot.txt
@@ -0,0 +1,104 @@
+U-Boot Verified Boot
+
+
+Introduction
+
+Verified boot here means the verification of all software loaded into a
+machine during the boot process to ensure that it is authorised and correct
+for that machine.
+
+Verified boot extends from the moment of system reset to as far as you wish
+into the boot process. An example might be loading U-Boot from read-only
+memory, then loading a signed kernel, then using the kernel's dm-verity
+driver to mount a signed root filesystem.
+
+A key point is that it is possible to field-upgrade the software on machines
+which use verified boot. Since the machine will only run software that has
+been correctly signed, it is safe to read software from an updatable medium.
+It is also possible to add a secondary signed firmware image, in read-write
+memory, so that firmware can easily be upgraded in a secure manner.
+
+
+Signing
+---
+Verified boot uses cryptographic algorithms to 'sign' software images.
+Images are signed using a private key known only to the signer, but can
+be verified using a public key. As its name suggests the public key can be
+made available without risk to the verification process. The private and
+public keys are mathematically related. For more information on how this
+works look up public key cryptography and RSA (a particular algorithm).
+
+The signing and verification process looks something like this:
+
+
+  Signing  Verification
+  ===  
+
+ +--+   *
+ | RSA key pair |   * +---+
+ | .key  .crt   |   * | Public key in |
+ +--+   +-- public key -| trusted place |
+   ||   * +---+
+   ||   *|
+   v|   *v
+   +-+  |   *  +--+
+   | |--+   *  |  |
+   | signer  |  *  |U-Boot|
+   | |--+   *  |  signature   |-- yes/no
+   +-+  |   *  | verification |
+  ^ |   *  |  |
+  | |   *  +--+
+  | |   *^
+ +--+   |   *|
+ | Software |   + signed image -+
+ |  image   |   *
+ +--+   *
+
+
+The signature algorithm relies only on the public key to do its work. Using
+this key it checks the signature that it finds in the image. If it verifies
+then we know that the image is OK.
+
+The public key from the signer allows us to verify and therefore trust
+software from updatable memory.
+
+It is critical that the public key be secure and cannot be tampered with.
+It can be stored in read-only memory, or perhaps protected by other on-chip
+crypto provided by some modern SOCs. If the public key can ben changed, then
+the verification is worthless.
+
+
+Chaining Images
+---
+The above method works for a signer providing images to a run-time U-Boot.
+It is also possible to extend this scheme to a second level, like this:
+
+1. Master private key is used by the signer to sign a first-stage image.
+2. Master public key is 

[U-Boot] [PATCH v2 44/45] sandbox: Allow -c argument to provide a command list

2013-03-18 Thread Simon Glass
This allows passing of entire scripts to sandbox with the -c argument,
which is useful for testing. Commands can be delimited with a newline
or semicolon.

Signed-off-by: Simon Glass s...@chromium.org
Reviewed-by: Marek Vasut ma...@denx.de
---
Changes in v2:
- Move sandbox's command list patch from a later series

 arch/sandbox/cpu/start.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index 2fcec8b..ae6e16c 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -90,7 +90,7 @@ int sandbox_main_loop_init(void)
 
/* Execute command if required */
if (state-cmd) {
-   run_command(state-cmd, 0);
+   run_command_list(state-cmd, -1, 0);
os_exit(state-exit_type);
}
 
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 33/45] image: Add RSA support for image signing

2013-03-18 Thread Simon Glass
RSA provides a public key encryption facility which is ideal for image
signing and verification.

Images are signed using a private key by mkimage. Then at run-time, the
images are verified using a private key.

This implementation uses openssl for the host part (mkimage). To avoid
bringing large libraries into the U-Boot binary, the RSA public key
is encoded using a simple numeric representation in the device tree.

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2:
- Add sanity checks on key sizes in RSA (improves security)
- Avoid using malloc in RSA routines (for smaller SPL code size)
- Build signing support unconditionally in mkimage
- Fix checkpatch checks about parenthesis alignment
- Fix spelling of multiply in rsa-verify.c
- Only build RSA support into mkimage if CONFIG_RSA is defined
- Support RSA library version without ERR_remove_thread_state()

 Makefile |   1 +
 README   |  10 ++
 common/image-sig.c   |   7 +
 config.mk|   1 +
 include/rsa.h| 108 
 lib/rsa/Makefile |  48 ++
 lib/rsa/rsa-sign.c   | 460 +++
 lib/rsa/rsa-verify.c | 385 ++
 tools/Makefile   |  13 +-
 9 files changed, 1031 insertions(+), 2 deletions(-)
 create mode 100644 include/rsa.h
 create mode 100644 lib/rsa/Makefile
 create mode 100644 lib/rsa/rsa-sign.c
 create mode 100644 lib/rsa/rsa-verify.c

diff --git a/Makefile b/Makefile
index 55bd55c..b6397b9 100644
--- a/Makefile
+++ b/Makefile
@@ -242,6 +242,7 @@ OBJS := $(addprefix $(obj),$(OBJS))
 HAVE_VENDOR_COMMON_LIB = $(if $(wildcard board/$(VENDOR)/common/Makefile),y,n)
 
 LIBS-y += lib/libgeneric.o
+LIBS-y += lib/rsa/librsa.o
 LIBS-y += lib/lzma/liblzma.o
 LIBS-y += lib/lzo/liblzo.o
 LIBS-y += lib/zlib/libz.o
diff --git a/README b/README
index de753f3..d8ccc3e 100644
--- a/README
+++ b/README
@@ -2481,6 +2481,16 @@ CBFS (Coreboot Filesystem) support
Note: There is also a sha1sum command, which should perhaps
be deprecated in favour of 'hash sha1'.
 
+- Signing support:
+   CONFIG_RSA
+
+   This enables the RSA algorithm used for FIT image verification
+   in U-Boot. See doc/uImage/signature for more information.
+
+   The signing part is build into mkimage regardless of this
+   option.
+
+
 - Show boot progress:
CONFIG_SHOW_BOOT_PROGRESS
 
diff --git a/common/image-sig.c b/common/image-sig.c
index 1401c75..1bdb4bf 100644
--- a/common/image-sig.c
+++ b/common/image-sig.c
@@ -27,8 +27,15 @@ DECLARE_GLOBAL_DATA_PTR;
 #endif /* !USE_HOSTCC*/
 #include errno.h
 #include image.h
+#include rsa.h
 
 struct image_sig_algo image_sig_algos[] = {
+   {
+   sha1,rsa2048,
+   rsa_sign,
+   rsa_add_verify_data,
+   rsa_verify,
+   }
 };
 
 struct image_sig_algo *image_get_sig_algo(const char *name)
diff --git a/config.mk b/config.mk
index 9886415..1542e66 100644
--- a/config.mk
+++ b/config.mk
@@ -91,6 +91,7 @@ HOSTCFLAGS+= $(call os_x_before, 10, 4, 
-traditional-cpp)
 HOSTLDFLAGS+= $(call os_x_before, 10, 5, -multiply_defined suppress)
 else
 HOSTCC = gcc
+HOSTLIBS   += -lssl -lcrypto
 endif
 
 ifeq ($(HOSTOS),cygwin)
diff --git a/include/rsa.h b/include/rsa.h
new file mode 100644
index 000..a5dd676
--- /dev/null
+++ b/include/rsa.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2013, Google Inc.
+ *
+ * (C) Copyright 2008 Semihalf
+ *
+ * (C) Copyright 2000-2006
+ * Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _RSA_H
+#define _RSA_H
+
+#include errno.h
+#include image.h
+
+#if IMAGE_ENABLE_SIGN
+/**
+ * sign() - calculate and return signature for given input data
+ *
+ * @info:  Specifies key and FIT information
+ * @data:  Pointer to the input data
+ * @data_len:  Data length
+ * @sigp:  Set to an allocated buffer holding the signature
+ * @sig_len:   Set to length of the calculated hash
+ *
+ * This computes input data signature according to selected algorithm.
+ * Resulting signature value is placed 

[U-Boot] [PATCH v2 34/45] mkimage: Put FIT loading in function and tidy error handling

2013-03-18 Thread Simon Glass
The fit_handle_file() function is quite long - split out the part that
loads and checks a FIT into its own function. We will use this
function for storing public keys into a destination FDT file.

The error handling is currently a bit repetitive - tidy it.

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2:
- Add comment about why mkimage needs to open FIT with O_RDWR
- Fix checkpatch checks about parenthesis alignment
- Fix spelling of quite

 tools/fit_image.c | 96 +--
 1 file changed, 57 insertions(+), 39 deletions(-)

diff --git a/tools/fit_image.c b/tools/fit_image.c
index e0675d7..ef6ef44 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -47,6 +47,48 @@ static int fit_check_image_types (uint8_t type)
return EXIT_FAILURE;
 }
 
+int mmap_fdt(struct mkimage_params *params, const char *fname, void **blobp,
+   struct stat *sbuf)
+{
+   void *ptr;
+   int fd;
+
+   /* Load FIT blob into memory (we need to write hashes/signatures) */
+   fd = open(fname, O_RDWR | O_BINARY);
+
+   if (fd  0) {
+   fprintf(stderr, %s: Can't open %s: %s\n,
+   params-cmdname, fname, strerror(errno));
+   unlink(fname);
+   return -1;
+   }
+
+   if (fstat(fd, sbuf)  0) {
+   fprintf(stderr, %s: Can't stat %s: %s\n,
+   params-cmdname, fname, strerror(errno));
+   unlink(fname);
+   return -1;
+   }
+
+   ptr = mmap(0, sbuf-st_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+   if (ptr == MAP_FAILED) {
+   fprintf(stderr, %s: Can't read %s: %s\n,
+   params-cmdname, fname, strerror(errno));
+   unlink(fname);
+   return -1;
+   }
+
+   /* check if ptr has a valid blob */
+   if (fdt_check_header(ptr)) {
+   fprintf(stderr, %s: Invalid FIT blob\n, params-cmdname);
+   unlink(fname);
+   return -1;
+   }
+
+   *blobp = ptr;
+   return fd;
+}
+
 /**
  * fit_handle_file - main FIT file processing function
  *
@@ -65,7 +107,7 @@ static int fit_handle_file (struct mkimage_params *params)
char cmd[MKIMAGE_MAX_DTC_CMDLINE_LEN];
int tfd;
struct stat sbuf;
-   unsigned char *ptr;
+   void *ptr;
 
/* Flattened Image Tree (FIT) format  handling */
debug (FIT format handling\n);
@@ -87,57 +129,25 @@ static int fit_handle_file (struct mkimage_params *params)
if (system (cmd) == -1) {
fprintf (stderr, %s: system(%s) failed: %s\n,
params-cmdname, cmd, strerror(errno));
-   unlink (tmpfile);
-   return (EXIT_FAILURE);
-   }
-
-   /* load FIT blob into memory */
-   tfd = open (tmpfile, O_RDWR|O_BINARY);
-
-   if (tfd  0) {
-   fprintf (stderr, %s: Can't open %s: %s\n,
-   params-cmdname, tmpfile, strerror(errno));
-   unlink (tmpfile);
-   return (EXIT_FAILURE);
-   }
-
-   if (fstat (tfd, sbuf)  0) {
-   fprintf (stderr, %s: Can't stat %s: %s\n,
-   params-cmdname, tmpfile, strerror(errno));
-   unlink (tmpfile);
-   return (EXIT_FAILURE);
-   }
-
-   ptr = mmap (0, sbuf.st_size, PROT_READ|PROT_WRITE, MAP_SHARED,
-   tfd, 0);
-   if (ptr == MAP_FAILED) {
-   fprintf (stderr, %s: Can't read %s: %s\n,
-   params-cmdname, tmpfile, strerror(errno));
-   unlink (tmpfile);
-   return (EXIT_FAILURE);
+   goto err_system;
}
 
-   /* check if ptr has a valid blob */
-   if (fdt_check_header (ptr)) {
-   fprintf (stderr, %s: Invalid FIT blob\n, params-cmdname);
-   unlink (tmpfile);
-   return (EXIT_FAILURE);
-   }
+   tfd = mmap_fdt(params, tmpfile, ptr, sbuf);
+   if (tfd  0)
+   goto err_mmap;
 
/* set hashes for images in the blob */
if (fit_add_verification_data(NULL, NULL, ptr, NULL, 0)) {
fprintf (stderr, %s Can't add hashes to FIT blob,
params-cmdname);
-   unlink (tmpfile);
-   return (EXIT_FAILURE);
+   goto err_add_hashes;
}
 
/* add a timestamp at offset 0 i.e., root  */
if (fit_set_timestamp (ptr, 0, sbuf.st_mtime)) {
fprintf (stderr, %s: Can't add image timestamp\n,
params-cmdname);
-   unlink (tmpfile);
-   return (EXIT_FAILURE);
+   goto err_add_timestamp;
}
debug (Added timestamp successfully\n);
 
@@ -153,6 +163,14 @@ static int fit_handle_file (struct mkimage_params *params)
  

[U-Boot] [PATCH v2 41/45] image: Add support for signing of FIT configurations

2013-03-18 Thread Simon Glass
While signing images is useful, it does not provide complete protection
against several types of attack. For example, it it possible to create a
FIT with the same signed images, but with the configuration changed such
that a different one is selected (mix and match attack). It is also possible
to substitute a signed image from an older FIT version into a newer FIT
(roll-back attack).

Add support for signing of FIT configurations using the libfdt's region
support.

Please see doc/uImage.FIT/signature.txt for more information.

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2:
- Fix checkpatch checks about parenthesis alignment
- Fix checkpatch warnings about split strings
- Require CONFIG_FIT_SIGNATURE in image.h for mkimage to support signing
- Update README to fix typos and clarify some points
- Use stack instead of calloc() within U-Boot's signature verification code

 common/cmd_bootm.c  |  12 ++
 common/image-sig.c  | 235 ++-
 doc/uImage.FIT/sign-configs.its |  45 ++
 doc/uImage.FIT/signature.txt| 168 ++-
 include/image.h |  17 ++
 tools/image-host.c  | 345 +++-
 6 files changed, 819 insertions(+), 3 deletions(-)
 create mode 100644 doc/uImage.FIT/sign-configs.its

diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index c03e88f..1f33ee6 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -984,6 +984,18 @@ static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int 
flag, int argc,
NULL);
printf(   Using '%s' configuration\n,
images-fit_uname_cfg);
+   if (IMAGE_ENABLE_VERIFY  images-verify) {
+   puts(   Verifying Hash Integrity ... );
+   if (!fit_config_verify(fit_hdr,
+  cfg_noffset)) {
+   puts(Bad Data Hash\n);
+   bootstage_error(
+   BOOTSTAGE_ID_FIT_CHECK_HASH);
+   return NULL;
+   }
+   puts(OK\n);
+   }
+
bootstage_mark(BOOTSTAGE_ID_FIT_CONFIG);
 
os_noffset = fit_conf_get_kernel_node(fit_hdr,
diff --git a/common/image-sig.c b/common/image-sig.c
index 1bdb4bf..dc783b2 100644
--- a/common/image-sig.c
+++ b/common/image-sig.c
@@ -25,10 +25,11 @@
 #include malloc.h
 DECLARE_GLOBAL_DATA_PTR;
 #endif /* !USE_HOSTCC*/
-#include errno.h
 #include image.h
 #include rsa.h
 
+#define IMAGE_MAX_HASHED_NODES 100
+
 struct image_sig_algo image_sig_algos[] = {
{
sha1,rsa2048,
@@ -50,6 +51,50 @@ struct image_sig_algo *image_get_sig_algo(const char *name)
return NULL;
 }
 
+/**
+ * fit_region_make_list() - Make a list of image regions
+ *
+ * Given a list of fdt_regions, create a list of image_regions. This is a
+ * simple conversion routine since the FDT and image code use different
+ * structures.
+ *
+ * @fit: FIT image
+ * @fdt_regions: Pointer to FDT regions
+ * @count: Number of FDT regions
+ * @region: Pointer to image regions, which must hold @count records. If
+ * region is NULL, then (except for an SPL build) the array will be
+ * allocated.
+ * @return: Pointer to image regions
+ */
+struct image_region *fit_region_make_list(const void *fit,
+   struct fdt_region *fdt_regions, int count,
+   struct image_region *region)
+{
+   int i;
+
+   debug(Hash regions:\n);
+   debug(%10s %10s\n, Offset, Size);
+
+   /*
+* Use malloc() except in SPL (to save code size). In SPL the caller
+* must allocate the array.
+*/
+#ifndef CONFIG_SPL_BUILD
+   if (!region)
+   region = calloc(sizeof(*region), count);
+#endif
+   if (!region)
+   return NULL;
+   for (i = 0; i  count; i++) {
+   debug(%10x %10x\n, fdt_regions[i].offset,
+ fdt_regions[i].size);
+   region[i].data = fit + fdt_regions[i].offset;
+   region[i].size = fdt_regions[i].size;
+   }
+
+   return region;
+}
+
 static int fit_image_setup_verify(struct image_sign_info *info,
const void *fit, int noffset, int required_keynode,
char **err_msgp)
@@ -195,3 +240,191 @@ int fit_image_verify_required_sigs(const void *fit, int 
image_noffset,
 
return 0;
 }
+
+int fit_config_check_sig(const void *fit, int noffset, int required_keynode,
+char **err_msgp)
+{
+   char * const exc_prop[] = {data};
+   const char *prop, *end, *name;
+   struct image_sign_info info;
+   const uint32_t *strings;
+   uint8_t 

[U-Boot] [PATCH v2 36/45] mkimage: Add -K to write public keys to an FDT blob

2013-03-18 Thread Simon Glass
FIT image verification requires public keys. Add a convenient option to
mkimage to write the public keys to an FDT blob when it uses then for
signing an image. This allows us to use:

   mkimage -f test.its -K dest.dtb -k keys test.fit

and have the signatures written to test.fit and the corresponding public
keys written to dest.dtb. Then dest.dtb can be used as the control FDT
for U-Boot (CONFIG_OF_CONTROL), thus providing U-Boot with access to the
public keys it needs.

Signed-off-by: Simon Glass s...@chromium.org
Reviewed-by: Marek Vasut ma...@denx.de
---
Changes in v2:
- Adjust mkimage help to separate out signing options
- Rebase on previous patches

 doc/mkimage.1 | 16 
 tools/fit_image.c | 21 +++--
 tools/mkimage.c   | 10 --
 tools/mkimage.h   |  1 +
 4 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/doc/mkimage.1 b/doc/mkimage.1
index 6740fb1..8185ff5 100644
--- a/doc/mkimage.1
+++ b/doc/mkimage.1
@@ -109,6 +109,14 @@ Specifies the directory containing keys to use for 
signing. This directory
 should contain a private key file name.key for use with signing and a
 certificate name.crt (containing the public key) for use with verification.
 
+.TP
+.BI \-K [ key_destination ]
+Specifies a compiled device tree binary file (typically .dtb) to write
+public key information into. When a private key is used to sign an image,
+the corresponding public key is written into this file for for run-time
+verification. Typically the file here is the device tree binary used by
+CONFIG_OF_CONTROL in U-Boot.
+
 .SH EXAMPLES
 
 List image information:
@@ -127,6 +135,14 @@ Create FIT image with compressed PowerPC Linux kernel:
 .nf
 .B mkimage -f kernel.its kernel.itb
 .fi
+.P
+Create FIT image with compressed kernel and sign it with keys in the
+/public/signing-keys directory. Add corresponding public keys into u-boot.dtb,
+skipping those for which keys cannot be found. Also add a comment.
+.nf
+.B mkimage -f kernel.its -k /public/signing-keys -K u-boot.dtb 
+-c Kernel 3.8 image for production devices kernel.itb
+.fi
 
 .SH HOMEPAGE
 http://www.denx.de/wiki/U-Boot/WebHome
diff --git a/tools/fit_image.c b/tools/fit_image.c
index 339e0f8..b17fa2d 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -105,9 +105,11 @@ static int fit_handle_file (struct mkimage_params *params)
 {
char tmpfile[MKIMAGE_MAX_TMPFILE_LEN];
char cmd[MKIMAGE_MAX_DTC_CMDLINE_LEN];
-   int tfd;
+   int tfd, destfd = 0;
+   void *dest_blob = NULL;
struct stat sbuf;
void *ptr;
+   off_t destfd_size = 0;
 
/* Flattened Image Tree (FIT) format  handling */
debug (FIT format handling\n);
@@ -132,12 +134,20 @@ static int fit_handle_file (struct mkimage_params *params)
goto err_system;
}
 
+   if (params-keydest) {
+   destfd = mmap_fdt(params, params-keydest, dest_blob, sbuf);
+   if (destfd  0)
+   goto err_keydest;
+   destfd_size = sbuf.st_size;
+   }
+
tfd = mmap_fdt(params, tmpfile, ptr, sbuf);
if (tfd  0)
goto err_mmap;
 
/* set hashes for images in the blob */
-   if (fit_add_verification_data(params-keydir, NULL, ptr, NULL, 0)) {
+   if (fit_add_verification_data(params-keydir, dest_blob, ptr,
+ NULL, 0)) {
fprintf (stderr, %s Can't add hashes to FIT blob,
params-cmdname);
goto err_add_hashes;
@@ -153,6 +163,10 @@ static int fit_handle_file (struct mkimage_params *params)
 
munmap ((void *)ptr, sbuf.st_size);
close (tfd);
+   if (dest_blob) {
+   munmap(dest_blob, destfd_size);
+   close(destfd);
+   }
 
if (rename (tmpfile, params-imagefile) == -1) {
fprintf (stderr, %s: Can't rename %s to %s: %s\n,
@@ -168,6 +182,9 @@ err_add_timestamp:
 err_add_hashes:
munmap(ptr, sbuf.st_size);
 err_mmap:
+   if (dest_blob)
+   munmap(dest_blob, destfd_size);
+err_keydest:
 err_system:
unlink(tmpfile);
return -1;
diff --git a/tools/mkimage.c b/tools/mkimage.c
index def7df2..3760392 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -253,6 +253,11 @@ main (int argc, char **argv)
usage();
params.keydir = *++argv;
goto NXTARG;
+   case 'K':
+   if (--argc = 0)
+   usage();
+   params.keydest = *++argv;
+   goto NXTARG;
case 'n':
if (--argc = 0)
usage ();
@@ -633,8 +638,9 @@ usage ()
fprintf(stderr,   -D = set options for device tree 

[U-Boot] [PATCH v2 42/45] image: Remove remaining #ifdefs in image-fit.c

2013-03-18 Thread Simon Glass
There are only two left. One is unnecessary and the other can be moved
to the header file.

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v2:
- Add new patch to remove #ifdefs in image-fit.c

 common/image-fit.c | 9 ++---
 common/image.c | 7 +--
 include/image.h| 2 ++
 3 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index 30790d3..29ea4c9 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -151,11 +151,8 @@ void fit_print_contents(const void *fit)
const char *p;
time_t timestamp;
 
-#ifdef USE_HOSTCC
-   p = ;
-#else
-   p =;
-#endif
+   /* Indent string is defined in header image.h */
+   p = IMAGE_INDENT_STRING;
 
/* Root node properties */
ret = fit_get_desc(fit, 0, desc);
@@ -1504,7 +1501,6 @@ void fit_conf_print(const void *fit, int noffset, const 
char *p)
  * 1, on success
  * 0, on failure
  */
-#ifndef USE_HOSTCC
 int fit_check_ramdisk(const void *fit, int rd_noffset, uint8_t arch,
int verify)
 {
@@ -1533,4 +1529,3 @@ int fit_check_ramdisk(const void *fit, int rd_noffset, 
uint8_t arch,
bootstage_mark(BOOTSTAGE_ID_FIT_RD_CHECK_ALL_OK);
return 1;
 }
-#endif /* USE_HOSTCC */
diff --git a/common/image.c b/common/image.c
index 14d1c48..f013fdc 100644
--- a/common/image.c
+++ b/common/image.c
@@ -295,12 +295,7 @@ void image_print_contents(const void *ptr)
const image_header_t *hdr = (const image_header_t *)ptr;
const char *p;
 
-#ifdef USE_HOSTCC
-   p = ;
-#else
-   p =;
-#endif
-
+   p = IMAGE_INDENT_STRING;
printf(%sImage Name:   %.*s\n, p, IH_NMLEN, image_get_name(hdr));
if (IMAGE_ENABLE_TIMESTAMP) {
printf(%sCreated:  , p);
diff --git a/include/image.h b/include/image.h
index cbbc17e..5766b58 100644
--- a/include/image.h
+++ b/include/image.h
@@ -47,6 +47,7 @@
 #define CONFIG_FIT_SIGNATURE
 
 #define IMAGE_ENABLE_IGNORE0
+#define IMAGE_INDENT_STRING
 
 #else
 
@@ -56,6 +57,7 @@
 
 /* Take notice of the 'ignore' property for hashes */
 #define IMAGE_ENABLE_IGNORE1
+#define IMAGE_INDENT_STRING   
 
 #endif /* USE_HOSTCC */
 
-- 
1.8.1.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] freescale imx bootlets vs u-boot for i.MX28

2013-03-18 Thread Paul B. Henson
I'm working on a fairly simple project that needs to boot linux from 
NAND on a freescale i.MX28 platform, and there's a lack of consensus on 
how to handle the boot loader.


One option would be to simply use the stock freescale imx bootlets to 
load the linux kernel, the other to leverage u-boot.


Clearly u-boot has a lot more functionality and feature set than the 
basic bootlets, but for this project there's really nothing more needed 
from the bootloader then to load the kernel from nand and pass control 
to it, and one faction thinks it would be more efficient just to use the 
bootlets rather than adding u-boot to the mix.


Assuming a scenario where the boot loader is expected to just load a 
linux kernel and nothing else, what advantages would u-boot provide over 
the basic bootlets? I know that on some platforms the IPL isn't very 
good at handling bad blocks or other issues, and having it load a very 
small u-boot which would then be used to load the larger kernel is 
beneficial, but I'm not sure if that's the case for the bootlets.


I'd appreciate any opinions or reasoning I could take back to the team 
to help make a decision, thanks…

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] freescale i.MX28 mxsboot NAND booting on mx28evk bad blocks

2013-03-18 Thread Paul B. Henson
I'm prototyping a project that's going to need to boot linux from NAND 
on a mx28evk board.


I was able to successfully use the u-boot mxsboot utility to generate a 
nand image and burn it, then boot from it. I noticed one anomaly though, 
when using mxsboot/u-boot to generate and burn the bootstream to NAND, 
when the linux kernel boots it finds bad blocks:


[1.09] NAND device: Manufacturer ID: 0x2c, Chip ID: 0xf1 (Micron 
MT29F14

[1.10] Scanning device for bad blocks
[1.11] Bad eraseblock 0 at 0x
[1.11] Bad eraseblock 1 at 0x0002
[1.12] Bad eraseblock 2 at 0x0004
[1.12] Bad eraseblock 3 at 0x0006

When I burn the exact same bootstream with kobs-ng, linux does not find 
any bad blocks, so it seems to be a byproduct of either the image 
generated by mxsboot or the u-boot burning.


I don't think this is having any functional impact, as the scrub 
component of burning a new nand image wipes out the bad blocks, and once 
linux is booted it really has no need to read the bootstream from the 
bootloader mtd partition.


However, it seems anomalous, and I was wondering if other people are 
have seen it, and whether or not it is something that might be fixed.


Thanks much…
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 0/45] Verified boot implementation based on FIT

2013-03-18 Thread Simon Glass
This series implemented a verified boot system based around FIT images
as discussed on the U-Boot mailing list, including on this thread:

http://permalink.gmane.org/gmane.comp.boot-loaders.u-boot/147830

RSA is used to implement the encryption. Images are signed by mkimage
using private keys created by the user. Public keys are written into
U-Boot control FDT (CONFIG_OF_CONTROL) for access by bootm etc. at
run-time. The control FDT must be stored in a secure place where it
cannot be changed after manufacture. Some notes are provided in the
documentaion on how this can be achieved. The implementation is fairly
efficient and fits nicely into U-Boot. FIT plus RSA adds around 18KB
to SPL size which is manageable on modern SoCs.

When images are loaded, they are verified with the public keys.

Some minor restructuring of the image code is included in this series,
since we now support signatures as well as hashes.

It is important to have a test framework for this series. For this, sandbox
is used, and a script is provided which signs images and gets sandbox to
load them using a script, to check that all is well. So some of the patches
here related to adding image support for sandbox. A follow-on series is
somewhat more agressive in further refactoring the FIT image support to
clean it up improve maintainability.

Rollback prevention has been added in a separate TPM patch. This ensures
that an attacker cannot boot your system with an old image that has been
compromised. Support for this is not built into bootm, but instead must
be scripted in U-Boot. It is possible that a standard scheme for this could
be devised by adding version number tags to the signing procedure. However
scripts do provide more flexibility. The TPM patch is here:

http://patchwork.ozlabs.org/patch/224163/

This series is available at:

http://git.denx.de/u-boot-x86.git

in the branch 'vboot'.

I have received a number of off-list comments - please do copy the list when
replying so that everyone can see your comments.

Changes in v2:
- Add IMAGE_ENABLE_IGNORE to avoid #ifdef around ignore property handling
- Add comment about why mkimage needs to open FIT with O_RDWR
- Add new patch to control FIT image printing in SPL
- Add new patch to remove #ifdefs in image-fit.c
- Add sanity checks on key sizes in RSA (improves security)
- Adjust how signing enable works in image.h
- Adjust mkimage help to separate out signing options
- Allow the control FDT to be set even if there is currently no control FDT
- Avoid using malloc in RSA routines (for smaller SPL code size)
- Build signing support unconditionally in mkimage
- Change hash_block() to use an unsigned int len
- Clarify use of output_size parameter to hash_block()
- Correct bug in setting control FDT
- Fix FDT error handling in fit_image_write_sig()
- Fix checkpatch checks about parenthesis alignment
- Fix checkpatch warnings about space after cast
- Fix checkpatch warnings about split strings
- Fix line continuation problem
- Fix spelling of multiply in rsa-verify.c
- Fix spelling of quite
- Fix typo os defined - is defined
- Move sandbox's command list patch from a later series
- Only build RSA support into mkimage if CONFIG_RSA is defined
- Put err_msgp strings on a single line
- Put params before description in fit_conf_get_prop_node() comment
- Rebase on previous patches
- Rebase to use updated fdt_valid() function
- Rename commit message to say function instead of function
- Require CONFIG_FIT_SIGNATURE in image.h for mkimage to support signing
- Revert the whole change including the set_working_fdt_addr() part
- Support RSA library version without ERR_remove_thread_state()
- Tweak tools/Makefile to make image signing optional
- Update README to fix typos
- Update README to fix typos and clarify some points
- Use U-Boot's -c option instead of hard-coding a boot script
- Use gd-arch.ram_buf instead of gd-ram_buf (now that generic board is in)
- Use stack instead of calloc() within U-Boot's signature verification code
- fdt_valid() sets the FDT pointer to NULL on error, to simplify callers
- gd-fdt_blob is now available on all archs (generic board landed)

Simon Glass (45):
  sandbox: config: Enable CONFIG_FIT and CONFIG_CMD_FIT
  bootstage: Don't build for HOSTCC
  mkimage: Move ARRAY_SIZE to header file
  libfdt: Add fdt_next_subnode() to permit easy subnode iteration
  image: Move timestamp #ifdefs to header file
  image: Export fit_check_ramdisk()
  image: Split FIT code into new image-fit.c
  image: Move HOSTCC image code to tools/
  image: Split hash node processing into its own function
  image: Convert fit_image_hash_set_value() to static, and rename
  image: Rename fit_image_check_hashes() to fit_image_verify()
  image: Move hash checking into its own function
  image: Move error! string to common place
  image: Export fit_conf_get_prop_node()
  image: Rename fit_add_hashes() to fit_add_verification_data()
  image: Rename hash printing to fit_image_print_verification_data()
  

[U-Boot] [PATCH v3 03/15] spi: Use spi_alloc_slave() in each SPI driver

2013-03-18 Thread Simon Glass
Rather than each driver having its own way to allocate a SPI slave,
use the new allocation function everywhere. This will make it easier
to extend the interface without breaking drivers.

Signed-off-by: Simon Glass s...@chromium.org
---
Changes in v3:
- Rebase to master

Changes in v2:
- Use spi_alloc_slave() in bfin_spi6xx.c
- Use spi_alloc_slave() in exynos_spi.c

 drivers/spi/altera_spi.c|  4 +---
 drivers/spi/andes_spi.c |  4 +---
 drivers/spi/armada100_spi.c |  4 +---
 drivers/spi/atmel_spi.c |  4 +---
 drivers/spi/bfin_spi.c  |  4 +---
 drivers/spi/bfin_spi6xx.c   |  4 +---
 drivers/spi/cf_qspi.c   |  4 +---
 drivers/spi/cf_spi.c|  4 +---
 drivers/spi/davinci_spi.c   |  4 +---
 drivers/spi/exynos_spi.c|  4 +---
 drivers/spi/fsl_espi.c  |  4 +---
 drivers/spi/kirkwood_spi.c  |  5 +
 drivers/spi/mpc52xx_spi.c   |  5 +
 drivers/spi/mpc8xxx_spi.c   |  5 +
 drivers/spi/mxc_spi.c   |  4 +---
 drivers/spi/mxs_spi.c   |  4 +---
 drivers/spi/oc_tiny_spi.c   |  5 +
 drivers/spi/omap3_spi.c | 27 ++-
 drivers/spi/sh_spi.c|  4 +---
 drivers/spi/soft_spi.c  |  4 +---
 drivers/spi/tegra_slink.c   |  4 +---
 drivers/spi/tegra_spi.c |  4 +---
 drivers/spi/xilinx_spi.c|  4 +---
 23 files changed, 36 insertions(+), 83 deletions(-)

diff --git a/drivers/spi/altera_spi.c b/drivers/spi/altera_spi.c
index 138d6f4..b53607a 100644
--- a/drivers/spi/altera_spi.c
+++ b/drivers/spi/altera_spi.c
@@ -83,12 +83,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, 
unsigned int cs,
if (!spi_cs_is_valid(bus, cs))
return NULL;
 
-   altspi = malloc(sizeof(*altspi));
+   altspi = spi_alloc_slave(struct altera_spi_slave, bus, cs);
if (!altspi)
return NULL;
 
-   altspi-slave.bus = bus;
-   altspi-slave.cs = cs;
altspi-base = altera_spi_base_list[bus];
debug(%s: bus:%i cs:%i base:%lx\n, __func__,
bus, cs, altspi-base);
diff --git a/drivers/spi/andes_spi.c b/drivers/spi/andes_spi.c
index fdde139..c56377b 100644
--- a/drivers/spi/andes_spi.c
+++ b/drivers/spi/andes_spi.c
@@ -53,12 +53,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, 
unsigned int cs,
if (!spi_cs_is_valid(bus, cs))
return NULL;
 
-   ds = malloc(sizeof(*ds));
+   ds = spi_alloc_slave(struct andes_spi_slave, bus, cs);
if (!ds)
return NULL;
 
-   ds-slave.bus = bus;
-   ds-slave.cs = cs;
ds-regs = (struct andes_spi_regs *)CONFIG_SYS_SPI_BASE;
 
/*
diff --git a/drivers/spi/armada100_spi.c b/drivers/spi/armada100_spi.c
index 7384c9c..afdbe05 100644
--- a/drivers/spi/armada100_spi.c
+++ b/drivers/spi/armada100_spi.c
@@ -120,12 +120,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, 
unsigned int cs,
 {
struct armd_spi_slave *pss;
 
-   pss = malloc(sizeof(*pss));
+   pss = spi_alloc_slave(struct armd_spi_slave, bus, cs);
if (!pss)
return NULL;
 
-   pss-slave.bus = bus;
-   pss-slave.cs = cs;
pss-spi_reg = (struct ssp_reg *)SSP_REG_BASE(CONFIG_SYS_SSP_PORT);
 
pss-cr0 = SSCR0_MOTO | SSCR0_DATASIZE(DEFAULT_WORD_LEN) | SSCR0_SSE;
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index ce7d460..f4b1bad 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -84,12 +84,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, 
unsigned int cs,
if (mode  SPI_CPOL)
csrx |= ATMEL_SPI_CSRx_CPOL;
 
-   as = malloc(sizeof(struct atmel_spi_slave));
+   as = spi_alloc_slave(struct atmel_spi_slave, bus, cs);
if (!as)
return NULL;
 
-   as-slave.bus = bus;
-   as-slave.cs = cs;
as-regs = regs;
as-mr = ATMEL_SPI_MR_MSTR | ATMEL_SPI_MR_MODFDIS
 #if defined(CONFIG_AT91SAM9X5) || defined(CONFIG_AT91SAM9M10G45)
diff --git a/drivers/spi/bfin_spi.c b/drivers/spi/bfin_spi.c
index e080bec..ab2e8b9 100644
--- a/drivers/spi/bfin_spi.c
+++ b/drivers/spi/bfin_spi.c
@@ -182,12 +182,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, 
unsigned int cs,
default: return NULL;
}
 
-   bss = malloc(sizeof(*bss));
+   bss = spi_alloc_slave(struct bfin_spi_slave, bus, cs);
if (!bss)
return NULL;
 
-   bss-slave.bus = bus;
-   bss-slave.cs = cs;
bss-mmr_base = (void *)mmr_base;
bss-ctl = SPE | MSTR | TDBR_CORE;
if (mode  SPI_CPHA) bss-ctl |= CPHA;
diff --git a/drivers/spi/bfin_spi6xx.c b/drivers/spi/bfin_spi6xx.c
index fde3447..c25c4a9 100644
--- a/drivers/spi/bfin_spi6xx.c
+++ b/drivers/spi/bfin_spi6xx.c
@@ -178,12 +178,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, 
unsigned int cs,
return NULL;
}
 
-   bss = malloc(sizeof(*bss));
+   bss = spi_alloc_slave(struct bfin_spi_slave, bus, cs);
if (!bss)