[U-Boot] buildman failures and toolchains

2018-07-06 Thread Adam Ford
I am going to sound stupid, but I'm struggling to install all the
toolchains and use them with buildroot.  I upgraded to Ubuntu 18.04
and whenever try to run buildman, or attempt to build the moveconfig
database I get failures.

i get the following error on every architecture type:
 cc1: error while loading shared libraries: libmpfr.so.4: cannot
open shared object file: No such
 file or directory

I  have confirmed that I have libmpfr installed on my host machine.
Does anyone have any suggestions?

I want to work on migrating more Kconfigs.

:-)

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


Re: [U-Boot] [PATCH 0/5] Fix Falcon Boot from internal eMMC on RK3288 Vyasa

2018-07-06 Thread Shyam Saini
> This patchest fixes booting Linux Kernel in falcon mode for Vyasa board.
> What happen is that CPU hangs on SPL while loading kernel from
> internal eMMC.
>
> This issue has been already addressed here [1] but with a wrong approach:
> it is a clear case of memory corruption and first patch of this serie helps
> a lot in profiling the same issue in the future.
>
> [1]: https://patchwork.ozlabs.org/patch/833821/
>
> Alberto Panizzo (5):
>   mmc: dw_mmc: prevent silent memory corruption when stack and heap are
> too small
>   mmc: dw_mmc: increase cmd timeout to fix eMMC enumeration error
>   rockchip: rk3288-vyasa: increase heap space after relocation
>   rk3288: vyasa: Allow booting from internal eMMC
>   rk3288: vyasa: Fixup indentation

Tested-by: Shyam Saini 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] SoCFPGA PL330 DMA driver and ECC scrubbing

2018-07-06 Thread Jason Rush
On 7/5/2018 6:10 PM, Marek Vasut wrote:
> On 07/06/2018 01:11 AM, Jason Rush wrote:
>> On 7/4/2018 2:23 AM, Marek Vasut wrote:
>>> On 07/04/2018 01:45 AM, Jason Rush wrote:
 On 7/3/2018 9:08 AM, Marek Vasut wrote:
> On 07/03/2018 03:58 PM, Jason Rush wrote:
>> On 6/29/2018 10:17 AM, Marek Vasut wrote:
>>> On 06/29/2018 05:06 PM, Jason Rush wrote:
 On 6/29/2018 9:52 AM, Marek Vasut wrote:
> On 06/29/2018 04:44 PM, Jason Rush wrote:
>> On 6/29/2018 9:34 AM, Marek Vasut wrote:
>>> On 06/29/2018 04:31 PM, Jason Rush wrote:
 Dinh,
>>> Hi,
>>>
 A while ago, you posted the following patchset for SoCFPGA to add 
 the PL330
 DMA driver, and updated the SoCFPGA SDRAM init to write zeros to 
 SDRAM to
 initialize the ECC bits if ECC was enabled:

 https://lists.denx.de/pipermail/u-boot/2016-October/269643.html

 I know it's been a long time, so I'll summarize some of the 
 conversation...

 At the time, you had a problem with the patchset causing the SPL 
 to fail to
 find the MMC.  You had tracked it down to an issue with the 
 following commit
 "a78cd8613204 ARM: Rework and correct barrier definitions".  You 
 and Marek
 discussed it a bit, but I don't think there was a real conclusion. 
  You
 submitted a second version of the patchset asking for advice on 
 debugging
 the issue:

 https://lists.denx.de/pipermail/u-boot/2016-December/275822.html

 No real conversation came from the second patchset, and that was 
 the end of
 the patch.

 I was hoping we could revisit adding your patchset again. I am 
 working on a
 custom SoCFPGA board with a Cyclone V and ECC SDRAM. I rebased 
 your patchset
 against v2018.05 and it is working on my custom board (although I 
 don't have
 an MMC). I also tested it on a SoCKit booting from an MMC (I 
 forced it to
 scrub the SDRAM on the SoCKit, because it doesn't have ECC RAM), 
 and the
 SoCKit finds the MMC and boots.

 I don't have any suggestions on why it is working now on my board 
 and not
 back when you first submitted the patchset.  Maybe something else 
 was fixed
 in the MMC? I was hoping you and Marek could test this patch again 
 on some
 different SoCFPGA boards to see if you get the same results.
>>> Look at this patch
>>> http://git.denx.de/?p=u-boot/u-boot-socfpga.git;a=commit;h=9bb8a249b292d26f152c20e3641600b3d7b3924b
>>>
>>> You likely want similar approach, it's faster then the DMA and much 
>>> simpler.
>>>
>> Thanks Marek.  I'll give it a try.  Would you be interested in a 
>> similar patch for the Gen 5?
> I don't have any Gen5 board which uses ECC, do you ?
> If so, yes, prepare a patch, it should be very similar.
>
> Make sure to measure how long it takes to scrub the memory and how 
> much
> memory you have, I'd be interested in the numbers.
>
 Looking at the master branch, it doesn't look like that code is ever 
 being called?
 The sdram_init_ecc_bits() function is called from the 
 ddr_calibration_sequence function(),
 but I can't find where ddr_calibration_sequence is called().
>>> git grep for it, it's called from somewhere in the 
>>> arch/arm/mach-socfpga/
>>>
 Either way, I can test it. I have a custom Cyclone V board with ECC, 
 and the Intel Arria V SoC
 Dev Kit I can test it on too which I think has ECC.
>>> Please do.
>>>
>> I implemented a similar memset approach for the gen 5 socfpga.  It's 
>> basically the same
>> code as in that patch; however, when I performed a single memset the 
>> processor would
>> reset for some reason.  I changed it to loop over calling memset with a 
>> size of 32MB over
>> the entire address the address, and that worked as opposed to doing a 
>> single memset on
>> the RAM.
> Can you do grep MEMSET .config in your U-Boot build dir ? The arch
> memset is implemented in assembler and doesn't trigger WDT , so if it
> takes too long, it could be that the WDT resets the platform.
 Both CONFIG_USE_ARCH_MEMSET and CONFIG_SPL_USE_ARCH_MEMSET
 are set in my .config, so it must be the WDT triggering as you suspect.

>> I started on a SoCKit because it was handy, I know it doesn't have ECC
> It doesn't by default.

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

2018-07-06 Thread Tom Rini
On Fri, Jul 06, 2018 at 01:11:00PM -0700, Tom Warren wrote:

>  Tom,
> 
> Please pull u-boot-tegra/master into U-Boot/master. Thanks!
> 
> All Tegra builds are OK, and Stephen's automated test system reports that
> all tests pass.
> 
> The following changes since commit 4ac5df4b41ba46d7e635bdd8d500721c642b0a0d:
> 
>   Merge branch 'master' of git://git.denx.de/u-boot-sunxi (2018-07-03
> 23:09:34 -0400)
> 
> are available in the git repository at:
> 
>   git://git.denx.de/u-boot-tegra.git master
> 
> for you to fetch changes up to 84996795c2f81cbfac210b6f2c168c5fb06a7a20:
> 
>   tegra: nyan-big: Update CONFIG_SYS_TEXT to the default in README.chromium
> (2018-07-06 09:12:39 -0700)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] doc: driver-model: Fix typo

2018-07-06 Thread Simon Glass
On 6 July 2018 at 04:29, Chris Packham  wrote:
>
> Signed-off-by: Chris Packham 
> ---
>
>  doc/driver-model/README.txt | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] Pull request, u-boot-tegra/master

2018-07-06 Thread Tom Warren
 Tom,

Please pull u-boot-tegra/master into U-Boot/master. Thanks!

All Tegra builds are OK, and Stephen's automated test system reports that
all tests pass.

The following changes since commit 4ac5df4b41ba46d7e635bdd8d500721c642b0a0d:

  Merge branch 'master' of git://git.denx.de/u-boot-sunxi (2018-07-03
23:09:34 -0400)

are available in the git repository at:

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

for you to fetch changes up to 84996795c2f81cbfac210b6f2c168c5fb06a7a20:

  tegra: nyan-big: Update CONFIG_SYS_TEXT to the default in README.chromium
(2018-07-06 09:12:39 -0700)


Peter Robinson (1):
  tegra: nyan-big: Update CONFIG_SYS_TEXT to the default in
README.chromium

 configs/nyan-big_defconfig |  2 +-
 doc/README.chromium| 27 +++
 2 files changed, 8 insertions(+), 21 deletions(-)
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


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

2018-07-06 Thread Tom Rini
On Fri, Jul 06, 2018 at 02:41:54PM +0200, Marek Vasut wrote:

> The following changes since commit 4ac5df4b41ba46d7e635bdd8d500721c642b0a0d:
> 
>   Merge branch 'master' of git://git.denx.de/u-boot-sunxi (2018-07-03
> 23:09:34 -0400)
> 
> are available in the Git repository at:
> 
>   git://git.denx.de/u-boot-usb.git master
> 
> for you to fetch changes up to 0bc846a769d43810af9e4622473b85ffaead3dea:
> 
>   sunxi: A64: OHCI: prevent turning off shared USB clock (2018-07-05
> 11:25:50 +0200)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3] tegra: nyan-big: Update CONFIG_SYS_TEXT to the default in README.chromium

2018-07-06 Thread Tom Rini
On Fri, Jul 06, 2018 at 05:31:00PM +, Tom Warren wrote:

> Applied to tegra-master, just waiting on our automated build/test framework 
> to give it a green light, then I'll issue a PR to TomR.  Sorry for the delay.

Please note that the release is scheduled for Monday, so if you have
stuff that should be in the release, that's OK, but otherwise it'll be
taken after.  Thanks!

> 
> Tom
> 
> -Original Message-
> From: Peter Robinson  
> Sent: Thursday, July 5, 2018 11:38 PM
> To: Allen Martin ; Simon Glass ; Tom 
> Warren ; u-boot@lists.denx.de
> Cc: Peter Robinson 
> Subject: Re: [PATCH v3] tegra: nyan-big: Update CONFIG_SYS_TEXT to the 
> default in README.chromium
> 
> Tom,
> 
> Ping, could we get this applied please?
> 
> Peter
> 
> On Sun, Jun 10, 2018 at 6:17 AM, Peter Robinson  wrote:
> > To build U-Boot on a Nyan Big Chromebook the docs outline adjusting 
> > the Tegra124 defined CONFIG_SYS_TEXT_BASE but this has since been 
> > moved to individual config files. We should have the default required 
> > for U-Boot chain loading on the chromebook as the default 
> > CONFIG_SYS_TEXT_BASE and update the docs to remove this now non required 
> > step.
> >
> > Signed-off-by: Peter Robinson 
> > ---
> >
> > v3: Update commit message
> > v2: Update to 2018.07 RC1
> >
> >  configs/nyan-big_defconfig |  2 +-
> >  doc/README.chromium| 27 +++
> >  2 files changed, 8 insertions(+), 21 deletions(-)
> >
> > diff --git a/configs/nyan-big_defconfig b/configs/nyan-big_defconfig 
> > index 8868d1f9e10..3b64c643716 100644
> > --- a/configs/nyan-big_defconfig
> > +++ b/configs/nyan-big_defconfig
> > @@ -1,6 +1,6 @@
> >  CONFIG_ARM=y
> >  CONFIG_TEGRA=y
> > -CONFIG_SYS_TEXT_BASE=0x8011
> > +CONFIG_SYS_TEXT_BASE=0x81000100
> >  CONFIG_DEBUG_UART_BASE=0x70006000
> >  CONFIG_DEBUG_UART_CLOCK=40800
> >  CONFIG_TEGRA124=y
> > diff --git a/doc/README.chromium b/doc/README.chromium index 
> > 7bf4d874474..45eaeced2da 100644
> > --- a/doc/README.chromium
> > +++ b/doc/README.chromium
> > @@ -43,26 +43,13 @@ 
> > https://git.collabora.com/cgit/user/tomeu/u-boot.git/commit/?h=nyan-bi
> > g  https://lists.denx.de/pipermail/u-boot/2017-May/289491.html
> >  
> > https://github.com/chromeos-nvidia-androidtv/gnu-linux-on-acer-chromeb
> > ook-13#copy-data-to-the-sd-card
> >
> > -1. Patch U-Boot
> > -
> > -Open include/configs/tegra124-common.h
> > -
> > -Change:
> > -
> > -#define CONFIG_SYS_TEXT_BASE   0x8011
> > -
> > -to:
> > -
> > -#define CONFIG_SYS_TEXT_BASE   0x81000100
> > -
> > -
> > -2. Build U-Boot
> > +1. Build U-Boot
> >
> > mkdir b
> > make -j8 O=b/nyan-big CROSS_COMPILE=arm-linux-gnueabi- 
> > nyan-big_defconfig all
> >
> >
> > -3. Select a .its file
> > +2. Select a .its file
> >
> >  Select something from doc/chromium which matches your board, or 
> > create your  own.
> > @@ -72,7 +59,7 @@ used by U-Boot. This is because the Chromebook 
> > expects to pass it to the  kernel, and crashes if it is not present.
> >
> >
> > -4. Build and sign an image
> > +3. Build and sign an image
> >
> > ./b/nyan-big/tools/mkimage -f doc/chromium/nyan-big.its 
> > u-boot-chromium.fit
> > echo test >dummy.txt
> > @@ -82,7 +69,7 @@ kernel, and crashes if it is not present.
> > --bootloader dummy.txt --pack u-boot.kpart
> >
> >
> > -5. Prepare an SD card
> > +4. Prepare an SD card
> >
> > DISK=/dev/sdc   # Replace with your actual SD card device
> > sudo cgpt create $DISK
> > @@ -91,12 +78,12 @@ kernel, and crashes if it is not present.
> > sudo gdisk $DISK   # Enter command 'w' to write a protective MBR to the 
> > disk
> >
> >
> > -6. Write U-Boot to the SD card
> > +5. Write U-Boot to the SD card
> >
> > sudo dd if=u-boot.kpart of=/dev/sdc1; sync
> >
> >
> > -7. Start it up
> > +6. Start it up
> >
> >  Reboot the device in dev mode. Make sure that you have USB booting 
> > enabled. To  do this, login as root (via Ctrl-Alt-forward_arrow) and 
> > type @@ -115,7 +102,7 @@ mode screen. It should show something like the 
> > following on the display:
> > Tegra124 (Nyan-big) #
> >
> >
> > -8. Known problems
> > +7. Known problems
> >
> >  On the serial console the word MMC is chopped at the start of the line:
> >
> > --
> > 2.17.1
> >
> --
> nvpublic
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [RFC PATCH 00/20] SPI-NAND support

2018-07-06 Thread Tom Rini
On Fri, Jul 06, 2018 at 05:45:02PM +0530, Jagan Teki wrote:
> On Fri, Jul 6, 2018 at 5:36 PM, Miquel Raynal  
> wrote:
> > Hi Jagan,
> >
> > Jagan Teki  wrote on Fri, 6 Jul 2018
> > 17:13:21 +0530:
> >
> >> On Wed, Jun 6, 2018 at 9:00 PM, Miquel Raynal  
> >> wrote:
> >> > During the last months, Boris Brezillon shared his work to support
> >> > serial flashes within Linux. First, he delivered (and merged) a new
> >> > layer called spi-mem. He also initiated in Linux MTD subsystem the move
> >> > of all 'raw' NAND related code to a raw/ subdirectory, adding at the
> >> > same time a NAND core that would be shared with all NAND devices. Then,
> >> > he contributed a generic SPI-NAND driver, making use of this NAND core,
> >> > as well as some vendor code to drive a few chips.
> >> >
> >> > On top of this work, I added an 'mtd' U-Boot command to handle all sort
> >> > of MTD devices. This should become the default command instead of having
> >> > one per flash flavor ('sf', 'nand', 'spi-nand' ?).
> >> >
> >> > The series has been tested on an Ocelot board PCB123 (VSC7514),
> >> > featuring a Macronix SPI NAND chip.
> >> >
> >> > TL;DR: the series contains:
> >> > - Various fixes and re-organization of the MTD subsystem.
> >> > - The introduction of the SPI-mem interface.
> >> > - The addition of the generic SPI-NAND driver (and its bindings).
> >> > - Several SPI NAND chip drivers (Macronix, Micron, Winbond).
> >> > - A new 'mtd' command.
> >> > - DT changes to make use of a SPI NAND on the Ocelot board.
> >> >
> >> > Any comments on the code, the organization and the respect of U-Boot
> >> > driver model will be welcome.
> >> >
> >> > Thanks,
> >> > Miquèl
> >> >
> >> >
> >> > Boris Brezillon (6):
> >> >   mtd: Fallback to ->_read/write_oob() when ->_read/write() is missing
> >> >   mtd: nand: Add core infrastructure to deal with NAND devices
> >> >   mtd: nand: Pass mode information to nand_page_io_req
> >> >   spi: Extend the core to ease integration of SPI memory controllers
> >> >   mtd: spinand: Add initial support for the MX35LF1GE4AB chip
> >> >   dt-bindings: Add bindings for SPI NAND devices
> >> >
> >> > Brian Norris (1):
> >> >   mtd: add get/set of_node/flash_node helpers
> >> >
> >> > Frieder Schrempf (1):
> >> >   mtd: spinand: Add initial support for Winbond W25M02GV
> >> >
> >> > Miquel Raynal (10):
> >> >   mtd: fix build issue with includes
> >> >   mtd: move definitions to enlarge their range
> >> >   mtd: move all flash categories inside MTD submenu
> >> >   mtd: move NAND fiels into a raw/ subdirectory
> >> >   mtd: rename nand into rawnand in Kconfig prompt
> >> >   mtd: spinand: Add initial support for the MX35LF2GE4AB chip
> >> >   mtd: uclass: add probe function
> >> >   cmd: mtd: add 'mtd' command
> >> >   mips: dts: ocelot: describe SPI CS pins
> >> >   mips: dts: ocelot: add the SPI NAND node
> >> >
> >> > Peter Pan (2):
> >> >   mtd: nand: Add core infrastructure to support SPI NANDs
> >> >   mtd: spinand: Add initial support for Micron MT29F2G01ABAGD
> >>
> >> I have reviewed and commented most of the stuff that are in my
> >> control, except few spi-nand code, which I would like to give a try to
> >> other people in the list. Hope to seen the fine-tuning patches on next
> >> version.
> >
> > Thanks for taking the time to review all this; I'm on it.
> >
> > About spi-nand, reviews from other contributors are welcome, but it's
> > mostly a copy from Linux framework that I just applied to nand/next.
> > There have been 9 versions of it before that so I think it's pretty
> > well reviewed.
> 
> OK, that's fine then.

If everyone is agreeable I would like to see this in the v2018.09
release.  Thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3] tegra: nyan-big: Update CONFIG_SYS_TEXT to the default in README.chromium

2018-07-06 Thread Tom Warren
Applied to tegra-master, just waiting on our automated build/test framework to 
give it a green light, then I'll issue a PR to TomR.  Sorry for the delay.

Tom

-Original Message-
From: Peter Robinson  
Sent: Thursday, July 5, 2018 11:38 PM
To: Allen Martin ; Simon Glass ; Tom 
Warren ; u-boot@lists.denx.de
Cc: Peter Robinson 
Subject: Re: [PATCH v3] tegra: nyan-big: Update CONFIG_SYS_TEXT to the default 
in README.chromium

Tom,

Ping, could we get this applied please?

Peter

On Sun, Jun 10, 2018 at 6:17 AM, Peter Robinson  wrote:
> To build U-Boot on a Nyan Big Chromebook the docs outline adjusting 
> the Tegra124 defined CONFIG_SYS_TEXT_BASE but this has since been 
> moved to individual config files. We should have the default required 
> for U-Boot chain loading on the chromebook as the default 
> CONFIG_SYS_TEXT_BASE and update the docs to remove this now non required step.
>
> Signed-off-by: Peter Robinson 
> ---
>
> v3: Update commit message
> v2: Update to 2018.07 RC1
>
>  configs/nyan-big_defconfig |  2 +-
>  doc/README.chromium| 27 +++
>  2 files changed, 8 insertions(+), 21 deletions(-)
>
> diff --git a/configs/nyan-big_defconfig b/configs/nyan-big_defconfig 
> index 8868d1f9e10..3b64c643716 100644
> --- a/configs/nyan-big_defconfig
> +++ b/configs/nyan-big_defconfig
> @@ -1,6 +1,6 @@
>  CONFIG_ARM=y
>  CONFIG_TEGRA=y
> -CONFIG_SYS_TEXT_BASE=0x8011
> +CONFIG_SYS_TEXT_BASE=0x81000100
>  CONFIG_DEBUG_UART_BASE=0x70006000
>  CONFIG_DEBUG_UART_CLOCK=40800
>  CONFIG_TEGRA124=y
> diff --git a/doc/README.chromium b/doc/README.chromium index 
> 7bf4d874474..45eaeced2da 100644
> --- a/doc/README.chromium
> +++ b/doc/README.chromium
> @@ -43,26 +43,13 @@ 
> https://git.collabora.com/cgit/user/tomeu/u-boot.git/commit/?h=nyan-bi
> g  https://lists.denx.de/pipermail/u-boot/2017-May/289491.html
>  
> https://github.com/chromeos-nvidia-androidtv/gnu-linux-on-acer-chromeb
> ook-13#copy-data-to-the-sd-card
>
> -1. Patch U-Boot
> -
> -Open include/configs/tegra124-common.h
> -
> -Change:
> -
> -#define CONFIG_SYS_TEXT_BASE   0x8011
> -
> -to:
> -
> -#define CONFIG_SYS_TEXT_BASE   0x81000100
> -
> -
> -2. Build U-Boot
> +1. Build U-Boot
>
> mkdir b
> make -j8 O=b/nyan-big CROSS_COMPILE=arm-linux-gnueabi- 
> nyan-big_defconfig all
>
>
> -3. Select a .its file
> +2. Select a .its file
>
>  Select something from doc/chromium which matches your board, or 
> create your  own.
> @@ -72,7 +59,7 @@ used by U-Boot. This is because the Chromebook 
> expects to pass it to the  kernel, and crashes if it is not present.
>
>
> -4. Build and sign an image
> +3. Build and sign an image
>
> ./b/nyan-big/tools/mkimage -f doc/chromium/nyan-big.its 
> u-boot-chromium.fit
> echo test >dummy.txt
> @@ -82,7 +69,7 @@ kernel, and crashes if it is not present.
> --bootloader dummy.txt --pack u-boot.kpart
>
>
> -5. Prepare an SD card
> +4. Prepare an SD card
>
> DISK=/dev/sdc   # Replace with your actual SD card device
> sudo cgpt create $DISK
> @@ -91,12 +78,12 @@ kernel, and crashes if it is not present.
> sudo gdisk $DISK   # Enter command 'w' to write a protective MBR to the 
> disk
>
>
> -6. Write U-Boot to the SD card
> +5. Write U-Boot to the SD card
>
> sudo dd if=u-boot.kpart of=/dev/sdc1; sync
>
>
> -7. Start it up
> +6. Start it up
>
>  Reboot the device in dev mode. Make sure that you have USB booting 
> enabled. To  do this, login as root (via Ctrl-Alt-forward_arrow) and 
> type @@ -115,7 +102,7 @@ mode screen. It should show something like the 
> following on the display:
> Tegra124 (Nyan-big) #
>
>
> -8. Known problems
> +7. Known problems
>
>  On the serial console the word MMC is chopped at the start of the line:
>
> --
> 2.17.1
>
--
nvpublic
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v6 0/5] drivers: Add reset ctrl to drivers

2018-07-06 Thread Tom Rini
On Fri, Jul 06, 2018 at 10:45:18AM +0800, Ley Foon Tan wrote:
> On Thu, Jun 14, 2018 at 6:45 PM, Ley Foon Tan  wrote:
> > Add reset ctrl to dwmmc socfpga, designware Ethernet and ns16550 serial 
> > drivers.
> >
> > A reset property is an optional feature, so only print out a warning and
> > do not fail if a reset property is not present.
> >
> > If a reset property is discovered, then use it to deassert, thus bringing 
> > the
> > IP out of reset.
> >
> > v6:
> > - Include change history to patches and cover letter
> > - Added Joe's Acked-by in designware emac patch.
> >
> > v5: https://patchwork.ozlabs.org/cover/924857/
> > - Rename CONFIG_SPL_RESET_SUPPORT to CONFIG_SPL_DM_RESET
> > - Change to use CONFIG_IS_ENABLED(DM_RESET) in reset.h
> > - Added Simon's Reviewed-by in dwmmc, 16550 serial and designware emac 
> > patches.
> >
> > v4: https://patchwork.ozlabs.org/cover/923883/
> > - Add patch to check CONFIG_SPL_RESET_SUPPORT in reset.h
> >
> > v3: https://patchwork.ozlabs.org/cover/910018/
> > - remove #ifdef CONFIG_DM_RESET switch
> > - add maintainer emails
> >
> > v2: https://patchwork.ozlabs.org/cover/908667/
> > - remove 'return' in designware emac driver
> > - keep reset control in socfpga_dw_mmc.c because it didn't call to common 
> > dwmmc probe
> >   function when in SPL.
> > - add reviewed-by in ns16550 patch
> >
> > v1: https://patchwork.ozlabs.org/cover/905519/
> >
> > Ley Foon Tan (5):
> >   reset: Rename CONFIG_SPL_RESET_SUPPORT to CONFIG_SPL_DM_RESET
> >   include: reset: Change to use CONFIG_IS_ENABLED(DM_RESET)
> >   mmc: dwmmc: socfpga: Add reset ctrl to driver
> >   serial: ns16550: Add reset ctrl to driver
> >   net: designware: Add reset ctrl to driver
> >
> >  arch/arm/mach-stm32mp/Kconfig |  2 +-
> >  common/spl/Kconfig|  2 +-
> >  drivers/Makefile  |  2 +-
> >  drivers/mmc/socfpga_dw_mmc.c  | 17 +
> >  drivers/net/designware.c  |  8 
> >  drivers/serial/ns16550.c  |  8 
> >  include/reset.h   |  2 +-
> >  7 files changed, 37 insertions(+), 4 deletions(-)
> >
> > --
> > 2.2.2
> >
> 
> Hi Tom
> 
> Can help to merge this series of patches?

I suspect I will take these shortly after the release, thanks for being
patient!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 17/29] dtoc: Fix Fdt.GetNode() to handle a missing node

2018-07-06 Thread Simon Glass
At present the algortihm is not correct since it will return the root node
if the requested node is not found and there are no slashes in the
requested node name. Fix this and add a test.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/dtoc/fdt.py  | 5 -
 tools/dtoc/test_fdt.py | 3 +++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py
index 274c142e7a..c1d04d48e8 100644
--- a/tools/dtoc/fdt.py
+++ b/tools/dtoc/fdt.py
@@ -318,7 +318,10 @@ class Fdt:
 Node object, or None if not found
 """
 node = self._root
-for part in path.split('/')[1:]:
+parts = path.split('/')
+if len(parts) < 2:
+return None
+for part in parts[1:]:
 node = node._FindNode(part)
 if not node:
 return None
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index e57298dbe7..9fef8ed549 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -205,6 +205,9 @@ class TestProp(unittest.TestCase):
 self.node = self.dtb.GetNode('/spl-test')
 self.fdt = self.dtb.GetFdtObj()
 
+def testMissingNode(self):
+self.assertEqual(None, self.dtb.GetNode('missing'))
+
 def testPhandle(self):
 dtb = fdt.FdtScan('tools/dtoc/dtoc_test_phandle.dts')
 node = dtb.GetNode('/phandle-source')
-- 
2.18.0.203.gfac676dfb9-goog

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


[U-Boot] [PATCH v2 27/29] binman: Add a ProcessFdt() method

2018-07-06 Thread Simon Glass
Some entry types modify the device tree, e.g. to remove microcode or add a
property. So far this just modifies their local copy and does not affect
a 'shared' device tree.

Rather than doing this modification in the ObtainContents() method, and a
new ProcessFdt() method which is specifically designed to modify this
shared device tree.

Move the existing device-tree code over to use this method, reducing
ObtainContents() to the goal of just obtaining the contents without any
processing, even for device tree.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/binman/README | 23 +
 tools/binman/bsection.py| 15 ++
 tools/binman/control.py | 52 -
 tools/binman/entry.py   |  3 ++
 tools/binman/etype/section.py   |  3 ++
 tools/binman/etype/u_boot_dtb_with_ucode.py | 47 ++-
 tools/binman/etype/u_boot_ucode.py  |  2 +-
 tools/binman/etype/u_boot_with_ucode_ptr.py |  7 ++-
 tools/binman/image.py   |  3 ++
 9 files changed, 118 insertions(+), 37 deletions(-)

diff --git a/tools/binman/README b/tools/binman/README
index 3cfcf84d92..008d575052 100644
--- a/tools/binman/README
+++ b/tools/binman/README
@@ -462,7 +462,14 @@ Order of image creation
 
 Image creation proceeds in the following order, for each entry in the image.
 
-1. GetEntryContents() - the contents of each entry are obtained, normally by
+1. ProcessFdt() - process the device tree information as required by the
+particular entry. This may involve adding or deleting properties. If the
+processing is complete, this method should return True. If the processing
+cannot complete because it needs the ProcessFdt() method of another entry to
+run first, this method should return False, in which case it will be called
+again later.
+
+2. GetEntryContents() - the contents of each entry are obtained, normally by
 reading from a file. This calls the Entry.ObtainContents() to read the
 contents. The default version of Entry.ObtainContents() calls
 Entry.GetDefaultFilename() and then reads that file. So a common mechanism
@@ -471,35 +478,35 @@ functions must return True when they have read the 
contents. Binman will
 retry calling the functions a few times if False is returned, allowing
 dependencies between the contents of different entries.
 
-2. GetEntryPositions() - calls Entry.GetPositions() for each entry. This can
+3. GetEntryPositions() - calls Entry.GetPositions() for each entry. This can
 return a dict containing entries that need updating. The key should be the
 entry name and the value is a tuple (pos, size). This allows an entry to
 provide the position and size for other entries. The default implementation
 of GetEntryPositions() returns {}.
 
-3. PackEntries() - calls Entry.Pack() which figures out the position and
+4. PackEntries() - calls Entry.Pack() which figures out the position and
 size of an entry. The 'current' image position is passed in, and the function
 returns the position immediately after the entry being packed. The default
 implementation of Pack() is usually sufficient.
 
-4. CheckSize() - checks that the contents of all the entries fits within
+5. CheckSize() - checks that the contents of all the entries fits within
 the image size. If the image does not have a defined size, the size is set
 large enough to hold all the entries.
 
-5. CheckEntries() - checks that the entries do not overlap, nor extend
+6. CheckEntries() - checks that the entries do not overlap, nor extend
 outside the image.
 
-6. ProcessEntryContents() - this calls Entry.ProcessContents() on each entry.
+7. ProcessEntryContents() - this calls Entry.ProcessContents() on each entry.
 The default implementatoin does nothing. This can be overriden to adjust the
 contents of an entry in some way. For example, it would be possible to create
 an entry containing a hash of the contents of some other entries. At this
 stage the position and size of entries should not be adjusted.
 
-7. WriteSymbols() - write the value of symbols into the U-Boot SPL binary.
+8. WriteSymbols() - write the value of symbols into the U-Boot SPL binary.
 See 'Access to binman entry positions at run time' below for a description of
 what happens in this stage.
 
-8. BuildImage() - builds the image and writes it to a file. This is the final
+9. BuildImage() - builds the image and writes it to a file. This is the final
 step.
 
 
diff --git a/tools/binman/bsection.py b/tools/binman/bsection.py
index 06a6711350..3ed361d69a 100644
--- a/tools/binman/bsection.py
+++ b/tools/binman/bsection.py
@@ -90,6 +90,21 @@ class Section(object):
 entry.SetPrefix(self._name_prefix)
 self._entries[node.name] = entry
 
+def ProcessFdt(self, fdt):
+todo = self._entries.values()
+for passnum in range(3):
+next_todo = []
+for entry in todo:
+if not 

[U-Boot] [PATCH v2 23/29] test: Enable cover-coverage tests for dtoc and fdt

2018-07-06 Thread Simon Glass
Now that we have 100% code coverage we can enable these tests in the test
script also.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Add new patch to enable cover-coverage tests for dtoc and fdt

 test/run | 4 
 1 file changed, 4 insertions(+)

diff --git a/test/run b/test/run
index 0b9188eaa8..d77a1c371b 100755
--- a/test/run
+++ b/test/run
@@ -29,6 +29,10 @@ PYTHONPATH=${DTC_DIR}/pylibfdt DTC=${DTC_DIR}/dtc run_test 
./tools/dtoc/dtoc -t
 #   $ sudo apt-get install python-pytest python-coverage
 PYTHONPATH=${DTC_DIR}/pylibfdt DTC=${DTC_DIR}/dtc run_test \
./tools/binman/binman -T
+PYTHONPATH=${DTC_DIR}/pylibfdt DTC=${DTC_DIR}/dtc run_test \
+   ./tools/dtoc/dtoc -T
+PYTHONPATH=${DTC_DIR}/pylibfdt DTC=${DTC_DIR}/dtc run_test \
+   ./tools/dtoc/test_fdt -T
 
 if [ $result == 0 ]; then
echo "Tests passed!"
-- 
2.18.0.203.gfac676dfb9-goog

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


[U-Boot] [PATCH v2 19/29] dtoc: Fix some minor errors

2018-07-06 Thread Simon Glass
Fix some comments and a printf string which is incorrect.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/dtoc/dtb_platdata.py | 3 ++-
 tools/dtoc/dtoc.py | 4 ++--
 tools/dtoc/fdt.py  | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index b1323aef19..6cb1259446 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -316,7 +316,8 @@ class DtbPlatdata(object):
 total = na + ns
 
 if reg.type != fdt.TYPE_INT:
-raise ValueError("Node '%s' reg property is not an int")
+raise ValueError("Node '%s' reg property is not an int" %
+ node.name)
 if len(reg.value) % total:
 raise ValueError("Node '%s' reg property has %d cells "
 'which is not a multiple of na + ns = %d + %d)' %
diff --git a/tools/dtoc/dtoc.py b/tools/dtoc/dtoc.py
index c891b06380..2e6a4db8bc 100755
--- a/tools/dtoc/dtoc.py
+++ b/tools/dtoc/dtoc.py
@@ -40,8 +40,8 @@ def run_tests(args):
 """Run all the test we have for dtoc
 
 Args:
-args: List of positional args provided to binman. This can hold a test
-name to execute (as in 'binman -t testSections', for example)
+args: List of positional args provided to dtoc. This can hold a test
+name to execute (as in 'dtoc -t test_empty_file', for example)
 """
 import test_dtoc
 
diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py
index c1d04d48e8..e7703c1c75 100644
--- a/tools/dtoc/fdt.py
+++ b/tools/dtoc/fdt.py
@@ -428,7 +428,7 @@ class Fdt:
 return node
 
 def FdtScan(fname):
-"""Returns a new Fdt object from the implementation we are using"""
+"""Returns a new Fdt object"""
 dtb = Fdt(fname)
 dtb.Scan()
 return dtb
-- 
2.18.0.203.gfac676dfb9-goog

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


[U-Boot] [PATCH v2 13/29] dtoc: Make use of the new pylibfdt methods

2018-07-06 Thread Simon Glass
Now that pylibfdt supports a fuller API we don't need to directly call
the libfdt stubs. Update the code to use the Fdt methods instead.

Some other cases remain which will be tidied up in a later commit, since
they need larger changes.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/dtoc/fdt.py | 26 ++
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py
index 5cde8c125a..18cde2604f 100644
--- a/tools/dtoc/fdt.py
+++ b/tools/dtoc/fdt.py
@@ -10,6 +10,7 @@ import sys
 
 import fdt_util
 import libfdt
+from libfdt import QUIET_NOTFOUND
 
 # This deals with a device tree, presenting it as an assortment of Node and
 # Prop objects, representing nodes and properties, respectively. This file
@@ -211,22 +212,22 @@ class Node:
 This fills in the props and subnodes properties, recursively
 searching into subnodes so that the entire tree is built.
 """
+fdt_obj = self._fdt._fdt_obj
 self.props = self._fdt.GetProps(self)
-phandle = self.props.get('phandle')
+phandle = fdt_obj.get_phandle(self.Offset())
 if phandle:
-val = fdt_util.fdt32_to_cpu(phandle.value)
-self._fdt.phandle_to_node[val] = self
+self._fdt.phandle_to_node[phandle] = self
 
-offset = libfdt.fdt_first_subnode(self._fdt.GetFdt(), self.Offset())
+offset = fdt_obj.first_subnode(self.Offset(), QUIET_NOTFOUND)
 while offset >= 0:
 sep = '' if self.path[-1] == '/' else '/'
-name = self._fdt._fdt_obj.get_name(offset)
+name = fdt_obj.get_name(offset)
 path = self.path + sep + name
 node = Node(self._fdt, self, offset, name, path)
 self.subnodes.append(node)
 
 node.Scan()
-offset = libfdt.fdt_next_subnode(self._fdt.GetFdt(), offset)
+offset = fdt_obj.next_subnode(offset, QUIET_NOTFOUND)
 
 def Refresh(self, my_offset):
 """Fix up the _offset for each node, recursively
@@ -324,9 +325,8 @@ class Fdt:
 When nodes and properties shrink or are deleted, wasted space can
 build up in the device tree binary.
 """
-CheckErr(libfdt.fdt_pack(self._fdt), 'pack')
-fdt_len = libfdt.fdt_totalsize(self._fdt)
-del self._fdt[fdt_len:]
+CheckErr(self._fdt_obj.pack(), 'pack')
+self.Invalidate()
 
 def GetFdt(self):
 """Get the contents of the FDT
@@ -363,13 +363,15 @@ class Fdt:
 ValueError: if the node does not exist.
 """
 props_dict = {}
-poffset = libfdt.fdt_first_property_offset(self._fdt, node._offset)
+poffset = self._fdt_obj.first_property_offset(node._offset,
+  QUIET_NOTFOUND)
 while poffset >= 0:
 p = self._fdt_obj.get_property_by_offset(poffset)
 prop = Prop(node, poffset, p.name, p)
 props_dict[prop.name] = prop
 
-poffset = libfdt.fdt_next_property_offset(self._fdt, poffset)
+poffset = self._fdt_obj.next_property_offset(poffset,
+ QUIET_NOTFOUND)
 return props_dict
 
 def Invalidate(self):
@@ -395,7 +397,7 @@ class Fdt:
 Returns:
 Position of @offset within the device tree binary
 """
-return libfdt.fdt_off_dt_struct(self._fdt) + offset
+return self._fdt_obj.off_dt_struct() + offset
 
 @classmethod
 def Node(self, fdt, parent, offset, name, path):
-- 
2.18.0.203.gfac676dfb9-goog

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


[U-Boot] [PATCH v2 29/29] binman: Support updating the device tree with calc'd info

2018-07-06 Thread Simon Glass
It is useful to write the position and size of each entry back to the
device tree so that U-Boot can access this at runtime. Add a feature to
support this, along with associated tests.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Update tests to main 100% code coverage

 tools/binman/README |  6 +-
 tools/binman/control.py |  2 +
 tools/binman/etype/_testing.py  | 10 
 tools/binman/ftest.py   | 77 +
 tools/binman/test/60_fdt_update.dts | 31 ++
 tools/binman/test/61_fdt_update_bad.dts | 32 ++
 6 files changed, 144 insertions(+), 14 deletions(-)
 create mode 100644 tools/binman/test/60_fdt_update.dts
 create mode 100644 tools/binman/test/61_fdt_update_bad.dts

diff --git a/tools/binman/README b/tools/binman/README
index 8b598a75c8..207928aa95 100644
--- a/tools/binman/README
+++ b/tools/binman/README
@@ -669,13 +669,11 @@ To do
 -
 
 Some ideas:
-- Fill out the device tree to include the final position and size of each
-  entry (since the input file may not always specify these). See also
-  'Access to binman entry positions at run time' above
 - Use of-platdata to make the information available to code that is unable
   to use device tree (such as a very small SPL image)
 - Allow easy building of images by specifying just the board name
-- Produce a full Python binding for libfdt (for upstream)
+- Produce a full Python binding for libfdt (for upstream). This is nearing
+completion but some work remains
 - Add an option to decode an image into the constituent binaries
 - Support building an image for a board (-b) more completely, with a
   configurable build directory
diff --git a/tools/binman/control.py b/tools/binman/control.py
index eafabf05c7..a40b300fda 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -168,6 +168,8 @@ def Binman(options, args):
 image.BuildImage()
 if options.map:
 image.WriteMap()
+with open(fname, 'wb') as outfd:
+outfd.write(dtb.GetContents())
 finally:
 tools.FinaliseOutputDir()
 finally:
diff --git a/tools/binman/etype/_testing.py b/tools/binman/etype/_testing.py
index 04bdc6c532..6a1af57798 100644
--- a/tools/binman/etype/_testing.py
+++ b/tools/binman/etype/_testing.py
@@ -24,6 +24,9 @@ class Entry__testing(Entry):
  'return-unknown-contents')
 self.bad_update_contents = fdt_util.GetBool(self._node,
 'bad-update-contents')
+self.process_fdt_ready = False
+self.never_complete_process_fdt = fdt_util.GetBool(self._node,
+'never-complete-process-fdt')
 
 def ObtainContents(self):
 if self.return_unknown_contents:
@@ -42,3 +45,10 @@ class Entry__testing(Entry):
 # Request to update the conents with something larger, to cause a
 # failure.
 self.ProcessContentsUpdate('aa')
+
+def ProcessFdt(self, fdt):
+"""Force reprocessing the first time"""
+ready = self.process_fdt_ready
+if not self.never_complete_process_fdt:
+self.process_fdt_ready = True
+return ready
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index af3b4dc3e5..12164a85b4 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -146,19 +146,23 @@ class TestFunctional(unittest.TestCase):
 # options.verbosity = tout.DEBUG
 return control.Binman(options, args)
 
-def _DoTestFile(self, fname, debug=False, map=False):
+def _DoTestFile(self, fname, debug=False, map=False, update_dtb=False):
 """Run binman with a given test file
 
 Args:
 fname: Device-tree source filename to use (e.g. 05_simple.dts)
 debug: True to enable debugging output
 map: True to output map files for the images
+update_dtb: Update the position and size of each entry in the 
device
+tree before packing it into the image
 """
 args = ['-p', '-I', self._indir, '-d', self.TestFile(fname)]
 if debug:
 args.append('-D')
 if map:
 args.append('-m')
+if update_dtb:
+args.append('-up')
 return self._DoBinman(*args)
 
 def _SetupDtb(self, fname, outfile='u-boot.dtb'):
@@ -183,7 +187,8 @@ class TestFunctional(unittest.TestCase):
 TestFunctional._MakeInputFile(outfile, data)
 return data
 
-def _DoReadFileDtb(self, fname, use_real_dtb=False, map=False):
+def _DoReadFileDtb(self, fname, use_real_dtb=False, map=False,
+   update_dtb=False):
 """Run binman and return the resulting image
 
 This runs binman with a given test file and then reads the resulting
@@ -199,6 +204,8 @@ class 

[U-Boot] [PATCH v2 26/29] binman: Complete documentation of stages

2018-07-06 Thread Simon Glass
At present one of the stages is badly numbered and not described. Fix
this.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/binman/README | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/binman/README b/tools/binman/README
index f74e39242f..3cfcf84d92 100644
--- a/tools/binman/README
+++ b/tools/binman/README
@@ -495,9 +495,11 @@ contents of an entry in some way. For example, it would be 
possible to create
 an entry containing a hash of the contents of some other entries. At this
 stage the position and size of entries should not be adjusted.
 
-6. WriteEntryInfo()
+7. WriteSymbols() - write the value of symbols into the U-Boot SPL binary.
+See 'Access to binman entry positions at run time' below for a description of
+what happens in this stage.
 
-7. BuildImage() - builds the image and writes it to a file. This is the final
+8. BuildImage() - builds the image and writes it to a file. This is the final
 step.
 
 
-- 
2.18.0.203.gfac676dfb9-goog

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


[U-Boot] [PATCH v2 14/29] dtoc: Drop use of a local dtb buffer

2018-07-06 Thread Simon Glass
At present the Fdt class has its own copy of the device tree. This is
confusing an unnecessary now that pylibfdt has its own. Drop it and
provide access functions to the buffer.

This allows us to move the rest of the implementation to use pylibfdt
methods instead of directly calling libfdt stubs.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/dtoc/fdt.py  | 16 
 tools/dtoc/test_fdt.py |  4 ++--
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py
index 18cde2604f..e24acf1280 100644
--- a/tools/dtoc/fdt.py
+++ b/tools/dtoc/fdt.py
@@ -235,12 +235,13 @@ class Node:
 Note: This does not take account of property offsets - these will not
 be updated.
 """
+fdt_obj = self._fdt._fdt_obj
 if self._offset != my_offset:
 self._offset = my_offset
-offset = libfdt.fdt_first_subnode(self._fdt.GetFdt(), self._offset)
+offset = fdt_obj.first_subnode(self._offset, QUIET_NOTFOUND)
 for subnode in self.subnodes:
 subnode.Refresh(offset)
-offset = libfdt.fdt_next_subnode(self._fdt.GetFdt(), offset)
+offset = fdt_obj.next_subnode(offset, QUIET_NOTFOUND)
 
 def DeleteProp(self, prop_name):
 """Delete a property of a node
@@ -252,7 +253,7 @@ class Node:
 Raises:
 ValueError if the property does not exist
 """
-CheckErr(libfdt.fdt_delprop(self._fdt.GetFdt(), self.Offset(), 
prop_name),
+CheckErr(self._fdt._fdt_obj.delprop(self.Offset(), prop_name),
  "Node '%s': delete property: '%s'" % (self.path, prop_name))
 del self.props[prop_name]
 self._fdt.Invalidate()
@@ -272,8 +273,7 @@ class Fdt:
 self._fname = fdt_util.EnsureCompiled(self._fname)
 
 with open(self._fname) as fd:
-self._fdt = bytearray(fd.read())
-self._fdt_obj = libfdt.Fdt(self._fdt)
+self._fdt_obj = libfdt.Fdt(fd.read())
 
 def Scan(self, root='/'):
 """Scan a device tree, building up a tree of Node objects
@@ -317,7 +317,7 @@ class Fdt:
 If the device tree has changed in memory, write it back to the file.
 """
 with open(self._fname, 'wb') as fd:
-fd.write(self._fdt)
+fd.write(self._fdt_obj.as_bytearray())
 
 def Pack(self):
 """Pack the device tree down to its minimum size
@@ -328,13 +328,13 @@ class Fdt:
 CheckErr(self._fdt_obj.pack(), 'pack')
 self.Invalidate()
 
-def GetFdt(self):
+def GetContents(self):
 """Get the contents of the FDT
 
 Returns:
 The FDT contents as a string of bytes
 """
-return self._fdt
+return self._fdt_obj.as_bytearray()
 
 def GetFdtObj(self):
 """Get the contents of the FDT
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index ba660ca9b7..daa9d128b5 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -72,7 +72,7 @@ class TestFdt(unittest.TestCase):
 
 def testGetFdt(self):
 """Tetst that we can access the raw device-tree data"""
-self.assertTrue(isinstance(self.dtb.GetFdt(), bytearray))
+self.assertTrue(isinstance(self.dtb.GetContents(), bytearray))
 
 def testGetProps(self):
 """Tests obtaining a list of properties"""
@@ -157,7 +157,7 @@ class TestProp(unittest.TestCase):
 
 # Add 12, which is sizeof(struct fdt_property), to get to start of data
 offset = prop.GetOffset() + 12
-data = self.dtb._fdt[offset:offset + len(prop.value)]
+data = self.dtb.GetContents()[offset:offset + len(prop.value)]
 bytes = [chr(x) for x in data]
 self.assertEqual(bytes, prop.value)
 
-- 
2.18.0.203.gfac676dfb9-goog

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


[U-Boot] [PATCH v2 25/29] dtoc: Add functions to add integer properties

2018-07-06 Thread Simon Glass
Add a few simple functions to add a placeholder integer property, and
set its value.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/dtoc/fdt.py  | 27 +++
 tools/dtoc/test_fdt.py | 20 
 2 files changed, 47 insertions(+)

diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py
index e7703c1c75..9d69b426c1 100644
--- a/tools/dtoc/fdt.py
+++ b/tools/dtoc/fdt.py
@@ -270,6 +270,33 @@ class Node:
 del self.props[prop_name]
 self._fdt.Invalidate()
 
+def AddZeroProp(self, prop_name):
+"""Add a new property to the device tree with an integer value of 0.
+
+Args:
+prop_name: Name of property
+"""
+fdt_obj = self._fdt._fdt_obj
+if fdt_obj.setprop_u32(self.Offset(), prop_name, 0,
+   (libfdt.NOSPACE,)) == -libfdt.NOSPACE:
+fdt_obj.open_into(fdt_obj.totalsize() + 1024)
+fdt_obj.setprop_u32(self.Offset(), prop_name, 0)
+self.props[prop_name] = Prop(self, -1, prop_name, '\0' * 4)
+self._fdt.Invalidate()
+
+def SetInt(self, prop_name, val):
+"""Update an integer property int the device tree.
+
+This is not allowed to change the size of the FDT.
+
+Args:
+prop_name: Name of property
+val: Value to set
+"""
+fdt_obj = self._fdt._fdt_obj
+fdt_obj.setprop_u32(self.Offset(), prop_name, val)
+
+
 class Fdt:
 """Provides simple access to a flat device tree blob using libfdts.
 
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index 49d188b1c1..f085b1dd1a 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -319,6 +319,26 @@ class TestProp(unittest.TestCase):
 self.assertTrue(isinstance(prop.value, list))
 self.assertEqual(3, len(prop.value))
 
+def testAdd(self):
+"""Test adding properties"""
+self.fdt.pack()
+# This function should automatically expand the device tree
+self.node.AddZeroProp('one')
+self.node.AddZeroProp('two')
+self.node.AddZeroProp('three')
+
+# Updating existing properties should be OK, since the device-tree size
+# does not change
+self.fdt.pack()
+self.node.SetInt('one', 1)
+self.node.SetInt('two', 2)
+self.node.SetInt('three', 3)
+
+# This should fail since it would need to increase the device-tree size
+with self.assertRaises(libfdt.FdtException) as e:
+self.node.SetInt('four', 4)
+self.assertIn('FDT_ERR_NOSPACE', str(e.exception))
+
 
 class TestFdtUtil(unittest.TestCase):
 """Tests for the fdt_util module
-- 
2.18.0.203.gfac676dfb9-goog

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


[U-Boot] [PATCH v2 22/29] dtoc: Increase code coverage to 100%

2018-07-06 Thread Simon Glass
Add more tests to increase dtoc code coverage to 100%.

Correct a whitespace error in some test .dts files at the same time.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/dtoc/dtoc_test_add_prop.dts|  24 
 tools/dtoc/dtoc_test_addr32_64.dts   |   2 +-
 tools/dtoc/dtoc_test_addr64_32.dts   |   2 +-
 tools/dtoc/dtoc_test_bad_reg.dts |  17 +++
 tools/dtoc/dtoc_test_bad_reg2.dts|  17 +++
 tools/dtoc/dtoc_test_phandle_bad.dts |  16 +++
 tools/dtoc/dtoc_test_phandle_bad2.dts|  22 
 tools/dtoc/dtoc_test_phandle_reorder.dts |  23 
 tools/dtoc/dtoc_test_phandle_single.dts  |  23 
 tools/dtoc/test_dtoc.py  | 142 +++
 10 files changed, 286 insertions(+), 2 deletions(-)
 create mode 100644 tools/dtoc/dtoc_test_add_prop.dts
 create mode 100644 tools/dtoc/dtoc_test_bad_reg.dts
 create mode 100644 tools/dtoc/dtoc_test_bad_reg2.dts
 create mode 100644 tools/dtoc/dtoc_test_phandle_bad.dts
 create mode 100644 tools/dtoc/dtoc_test_phandle_bad2.dts
 create mode 100644 tools/dtoc/dtoc_test_phandle_reorder.dts
 create mode 100644 tools/dtoc/dtoc_test_phandle_single.dts

diff --git a/tools/dtoc/dtoc_test_add_prop.dts 
b/tools/dtoc/dtoc_test_add_prop.dts
new file mode 100644
index 00..fa296e5552
--- /dev/null
+++ b/tools/dtoc/dtoc_test_add_prop.dts
@@ -0,0 +1,24 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test device tree file for dtoc
+ *
+ * Copyright 2018 Google, Inc
+ */
+
+/dts-v1/;
+
+/ {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   spl-test {
+   u-boot,dm-pre-reloc;
+   compatible = "sandbox,spl-test";
+   intval = <1>;
+   };
+
+   spl-test2 {
+   u-boot,dm-pre-reloc;
+   compatible = "sandbox,spl-test";
+   intarray = <5>;
+   };
+};
diff --git a/tools/dtoc/dtoc_test_addr32_64.dts 
b/tools/dtoc/dtoc_test_addr32_64.dts
index 7891ee59fa..7599d5b0a5 100644
--- a/tools/dtoc/dtoc_test_addr32_64.dts
+++ b/tools/dtoc/dtoc_test_addr32_64.dts
@@ -5,7 +5,7 @@
  * Copyright 2017 Google, Inc
  */
 
- /dts-v1/;
+/dts-v1/;
 
 / {
#address-cells = <1>;
diff --git a/tools/dtoc/dtoc_test_addr64_32.dts 
b/tools/dtoc/dtoc_test_addr64_32.dts
index 759a7e8e26..85e4f5fdae 100644
--- a/tools/dtoc/dtoc_test_addr64_32.dts
+++ b/tools/dtoc/dtoc_test_addr64_32.dts
@@ -5,7 +5,7 @@
  * Copyright 2017 Google, Inc
  */
 
- /dts-v1/;
+/dts-v1/;
 
 / {
#address-cells = <2>;
diff --git a/tools/dtoc/dtoc_test_bad_reg.dts b/tools/dtoc/dtoc_test_bad_reg.dts
new file mode 100644
index 00..1312acb619
--- /dev/null
+++ b/tools/dtoc/dtoc_test_bad_reg.dts
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test device tree file for dtoc
+ *
+ * Copyright 2018 Google, Inc
+ */
+
+/dts-v1/;
+
+/ {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   spl-test {
+   compatible = "test";
+   reg = "fre";
+   };
+};
diff --git a/tools/dtoc/dtoc_test_bad_reg2.dts 
b/tools/dtoc/dtoc_test_bad_reg2.dts
new file mode 100644
index 00..3e9efa43af
--- /dev/null
+++ b/tools/dtoc/dtoc_test_bad_reg2.dts
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test device tree file for dtoc
+ *
+ * Copyright 2018 Google, Inc
+ */
+
+/dts-v1/;
+
+/ {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   spl-test {
+   compatible = "test";
+   reg = <1 2 3>;
+   };
+};
diff --git a/tools/dtoc/dtoc_test_phandle_bad.dts 
b/tools/dtoc/dtoc_test_phandle_bad.dts
new file mode 100644
index 00..a3ddc59585
--- /dev/null
+++ b/tools/dtoc/dtoc_test_phandle_bad.dts
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test device tree file for dtoc
+ *
+ * Copyright 2018 Google, Inc
+ */
+
+/dts-v1/;
+
+/ {
+   phandle-source {
+   u-boot,dm-pre-reloc;
+   compatible = "source";
+   clocks = <20>;/* Invalid phandle */
+   };
+};
diff --git a/tools/dtoc/dtoc_test_phandle_bad2.dts 
b/tools/dtoc/dtoc_test_phandle_bad2.dts
new file mode 100644
index 00..fe25f565fb
--- /dev/null
+++ b/tools/dtoc/dtoc_test_phandle_bad2.dts
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test device tree file for dtoc
+ *
+ * Copyright 2018 Google, Inc
+ */
+
+/dts-v1/;
+
+/ {
+   phandle: phandle-target {
+   u-boot,dm-pre-reloc;
+   compatible = "target";
+   intval = <0>;
+   };
+
+   phandle-source2 {
+   u-boot,dm-pre-reloc;
+   compatible = "source";
+   clocks = <>;
+   };
+};
diff --git a/tools/dtoc/dtoc_test_phandle_reorder.dts 
b/tools/dtoc/dtoc_test_phandle_reorder.dts
new file mode 100644
index 00..aa71d56f27
--- /dev/null
+++ b/tools/dtoc/dtoc_test_phandle_reorder.dts
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test device tree file for dtoc
+ *
+ * Copyright 2018 Google, 

[U-Boot] [PATCH v2 20/29] dtoc: Add a test for code coverage

2018-07-06 Thread Simon Glass
Add a -T option to run a code-coverage test on dtoc. At present this is
about 96%. Future work will increase it to 100%.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Update coverage to only include dtb_platdata.py

 tools/dtoc/dtoc.py | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/tools/dtoc/dtoc.py b/tools/dtoc/dtoc.py
index 2e6a4db8bc..827094e72a 100755
--- a/tools/dtoc/dtoc.py
+++ b/tools/dtoc/dtoc.py
@@ -35,6 +35,7 @@ our_path = os.path.dirname(os.path.realpath(__file__))
 sys.path.append(os.path.join(our_path, '../patman'))
 
 import dtb_platdata
+import test_util
 
 def run_tests(args):
 """Run all the test we have for dtoc
@@ -64,10 +65,19 @@ def run_tests(args):
 for _, err in result.failures:
 print err
 
+def RunTestCoverage():
+"""Run the tests and check that we get 100% coverage"""
+sys.argv = [sys.argv[0]]
+test_util.RunTestCoverage('tools/dtoc/dtoc.py', '/dtoc.py',
+['tools/patman/*.py', '*/fdt*', '*test*'], options.build_dir)
+
+
 if __name__ != '__main__':
 sys.exit(1)
 
 parser = OptionParser()
+parser.add_option('-B', '--build-dir', type='string', default='b',
+help='Directory containing the build output')
 parser.add_option('-d', '--dtb-file', action='store',
   help='Specify the .dtb input file')
 parser.add_option('--include-disabled', action='store_true',
@@ -76,12 +86,17 @@ parser.add_option('-o', '--output', action='store', 
default='-',
   help='Select output filename')
 parser.add_option('-t', '--test', action='store_true', dest='test',
   default=False, help='run tests')
+parser.add_option('-T', '--test-coverage', action='store_true',
+default=False, help='run tests and check for 100% coverage')
 (options, args) = parser.parse_args()
 
 # Run our meagre tests
 if options.test:
 run_tests(args)
 
+elif options.test_coverage:
+RunTestCoverage()
+
 else:
 dtb_platdata.run_steps(args, options.dtb_file, options.include_disabled,
options.output)
-- 
2.18.0.203.gfac676dfb9-goog

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


[U-Boot] [PATCH v2 08/29] libfdt: Fix the Python pack() function

2018-07-06 Thread Simon Glass
This currently fails to reduce the device-tree bytearray size. Fix this.

This stands in for a pending upstream change.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 scripts/dtc/pylibfdt/libfdt.i_shipped | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/dtc/pylibfdt/libfdt.i_shipped 
b/scripts/dtc/pylibfdt/libfdt.i_shipped
index 6774b93b2c..5b38e63b26 100644
--- a/scripts/dtc/pylibfdt/libfdt.i_shipped
+++ b/scripts/dtc/pylibfdt/libfdt.i_shipped
@@ -442,7 +442,11 @@ class Fdt:
 Raises:
 FdtException if any error occurs
 """
-return check_err(fdt_pack(self._fdt), quiet)
+err = check_err(fdt_pack(self._fdt), quiet)
+if err:
+return err
+del self._fdt[self.totalsize():]
+return err
 
 def getprop(self, nodeoffset, prop_name, quiet=()):
 """Get a property from a node
-- 
2.18.0.203.gfac676dfb9-goog

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


[U-Boot] [PATCH v2 15/29] dtoc: Update fdt tests to increase code coverage

2018-07-06 Thread Simon Glass
At present only some of the fdt functionality is tested. Add more tests to
cover the rest of it. Also turn on test coverage, which is now 100% with
a small exclusion for a Python 3 feature.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Expand tests to increase code coverage to 100%

 tools/dtoc/dtoc_test_simple.dts |   1 +
 tools/dtoc/fdt.py   |  12 ---
 tools/dtoc/fdt_util.py  |  25 +++---
 tools/dtoc/test_dtoc.py |   2 +
 tools/dtoc/test_fdt.py  | 134 +++-
 5 files changed, 150 insertions(+), 24 deletions(-)

diff --git a/tools/dtoc/dtoc_test_simple.dts b/tools/dtoc/dtoc_test_simple.dts
index 895cc1fea2..165680bd4b 100644
--- a/tools/dtoc/dtoc_test_simple.dts
+++ b/tools/dtoc/dtoc_test_simple.dts
@@ -21,6 +21,7 @@
longbytearray = [09 0a 0b 0c 0d 0e 0f 10 11];
stringval = "message";
stringarray = "multi-word", "message";
+   notstring = [20 21 22 10 00];
};
 
spl-test2 {
diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py
index e24acf1280..fd016bb8ce 100644
--- a/tools/dtoc/fdt.py
+++ b/tools/dtoc/fdt.py
@@ -49,13 +49,6 @@ class Prop:
 return
 self.type, self.value = self.BytesToValue(bytes)
 
-def GetPhandle(self):
-"""Get a (single) phandle value from a property
-
-Gets the phandle valuie from a property and returns it as an integer
-"""
-return fdt_util.fdt32_to_cpu(self.value[:4])
-
 def Widen(self, newprop):
 """Figure out which property type is more general
 
@@ -344,11 +337,6 @@ class Fdt:
 """
 return self._fdt_obj
 
-def CheckErr(self, errnum, msg):
-if errnum:
-raise ValueError('Error %d: %s: %s' %
-(errnum, libfdt.fdt_strerror(errnum), msg))
-
 def GetProps(self, node):
 """Get all properties from a node.
 
diff --git a/tools/dtoc/fdt_util.py b/tools/dtoc/fdt_util.py
index 2d09649f72..88fc318383 100644
--- a/tools/dtoc/fdt_util.py
+++ b/tools/dtoc/fdt_util.py
@@ -13,6 +13,14 @@ import tempfile
 import command
 import tools
 
+VERSION3 = sys.version_info > (3, 0)
+
+def get_plain_bytes(val):
+"""Handle Python 3 strings"""
+if isinstance(val, bytes):
+val = val.decode('utf-8')
+return val.encode('raw_unicode_escape')
+
 def fdt32_to_cpu(val):
 """Convert a device tree cell to an integer
 
@@ -22,10 +30,9 @@ def fdt32_to_cpu(val):
 Return:
 A native-endian integer value
 """
-if sys.version_info > (3, 0):
-if isinstance(val, bytes):
-val = val.decode('utf-8')
-val = val.encode('raw_unicode_escape')
+if VERSION3:
+# This code is not reached in Python 2
+val = get_plain_bytes(val)  # pragma: no cover
 return struct.unpack('>I', val)[0]
 
 def fdt_cells_to_cpu(val, cells):
@@ -86,10 +93,10 @@ def GetInt(node, propname, default=None):
 prop = node.props.get(propname)
 if not prop:
 return default
-value = fdt32_to_cpu(prop.value)
-if type(value) == type(list):
-raise ValueError("Node '%s' property '%' has list value: expecting"
+if isinstance(prop.value, list):
+raise ValueError("Node '%s' property '%s' has list value: expecting "
  "a single integer" % (node.name, propname))
+value = fdt32_to_cpu(prop.value)
 return value
 
 def GetString(node, propname, default=None):
@@ -97,8 +104,8 @@ def GetString(node, propname, default=None):
 if not prop:
 return default
 value = prop.value
-if type(value) == type(list):
-raise ValueError("Node '%s' property '%' has list value: expecting"
+if isinstance(value, list):
+raise ValueError("Node '%s' property '%s' has list value: expecting "
  "a single string" % (node.name, propname))
 return value
 
diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py
index ce6d2585a4..20fea522c4 100644
--- a/tools/dtoc/test_dtoc.py
+++ b/tools/dtoc/test_dtoc.py
@@ -180,6 +180,7 @@ struct dtd_sandbox_spl_test {
 \tfdt32_t\t\tintarray[4];
 \tfdt32_t\t\tintval;
 \tunsigned char\tlongbytearray[9];
+\tunsigned char\tnotstring[5];
 \tconst char *\tstringarray[3];
 \tconst char *\tstringval;
 };
@@ -195,6 +196,7 @@ static struct dtd_sandbox_spl_test dtv_spl_test = {
 \t.bytearray\t\t= {0x6, 0x0, 0x0},
 \t.byteval\t\t= 0x5,
 \t.intval\t\t\t= 0x1,
+\t.notstring\t\t= {0x20, 0x21, 0x22, 0x10, 0x0},
 \t.longbytearray\t\t= {0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10,
 \t\t0x11},
 \t.stringval\t\t= "message",
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index daa9d128b5..d44e4dd842 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -18,6 +18,7 @@ for dirname in ['../patman', '..']:
 import command
 import fdt
 from fdt import TYPE_BYTE, TYPE_INT, TYPE_STRING, TYPE_BOOL
+import fdt_util
 from fdt_util import fdt32_to_cpu
 import libfdt
 import 

[U-Boot] [PATCH v2 21/29] binman: Move capture_sys_output() to test_util

2018-07-06 Thread Simon Glass
This function is useful in various tests. Move it into the common test
utility module.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/binman/elf_test.py   | 22 ++
 tools/binman/image_test.py |  2 +-
 tools/patman/test_util.py  | 21 +
 3 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/tools/binman/elf_test.py b/tools/binman/elf_test.py
index fb6e451cf0..9c8f1feca8 100644
--- a/tools/binman/elf_test.py
+++ b/tools/binman/elf_test.py
@@ -4,33 +4,15 @@
 #
 # Test for the elf module
 
-from contextlib import contextmanager
 import os
 import sys
 import unittest
 
-try:
-  from StringIO import StringIO
-except ImportError:
-  from io import StringIO
-
 import elf
+import test_util
 
 binman_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
 
-# Use this to suppress stdout/stderr output:
-# with capture_sys_output() as (stdout, stderr)
-#   ...do something...
-@contextmanager
-def capture_sys_output():
-  capture_out, capture_err = StringIO(), StringIO()
-  old_out, old_err = sys.stdout, sys.stderr
-  try:
-sys.stdout, sys.stderr = capture_out, capture_err
-yield capture_out, capture_err
-  finally:
-sys.stdout, sys.stderr = old_out, old_err
-
 
 class FakeEntry:
 def __init__(self, contents_size):
@@ -110,7 +92,7 @@ class TestElf(unittest.TestCase):
 entry = FakeEntry(20)
 section = FakeSection()
 elf_fname = os.path.join(binman_dir, 'test', 'u_boot_binman_syms')
-with capture_sys_output() as (stdout, stderr):
+with test_util.capture_sys_output() as (stdout, stderr):
 syms = elf.LookupAndWriteSymbols(elf_fname, entry, section)
 elf.debug = False
 self.assertTrue(len(stdout.getvalue()) > 0)
diff --git a/tools/binman/image_test.py b/tools/binman/image_test.py
index 45dd2378c8..3775e1afb0 100644
--- a/tools/binman/image_test.py
+++ b/tools/binman/image_test.py
@@ -7,7 +7,7 @@
 import unittest
 
 from image import Image
-from elf_test import capture_sys_output
+from test_util import capture_sys_output
 
 class TestImage(unittest.TestCase):
 def testInvalidFormat(self):
diff --git a/tools/patman/test_util.py b/tools/patman/test_util.py
index 1a33c997c4..0e79af871a 100644
--- a/tools/patman/test_util.py
+++ b/tools/patman/test_util.py
@@ -3,12 +3,19 @@
 # Copyright (c) 2016 Google, Inc
 #
 
+from contextlib import contextmanager
 import glob
 import os
 import sys
 
 import command
 
+try:
+  from StringIO import StringIO
+except ImportError:
+  from io import StringIO
+
+
 def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, 
required=None):
 """Run tests and check that we get 100% coverage
 
@@ -62,3 +69,17 @@ def RunTestCoverage(prog, filter_fname, exclude_list, 
build_dir, required=None):
 ok = False
 if not ok:
 raise ValueError('Test coverage failure')
+
+
+# Use this to suppress stdout/stderr output:
+# with capture_sys_output() as (stdout, stderr)
+#   ...do something...
+@contextmanager
+def capture_sys_output():
+capture_out, capture_err = StringIO(), StringIO()
+old_out, old_err = sys.stdout, sys.stderr
+try:
+sys.stdout, sys.stderr = capture_out, capture_err
+yield capture_out, capture_err
+finally:
+sys.stdout, sys.stderr = old_out, old_err
-- 
2.18.0.203.gfac676dfb9-goog

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


[U-Boot] [PATCH v2 07/29] libfdt: Bring in proposed pylibfdt changes

2018-07-06 Thread Simon Glass
This provides various patches sent to the devicetree-compiler mailing list
to enhance the Python bindings. A final version of this patch may be
created once upstreaming is complete, but if it takes too long, this can
act as a placeholder.

New pylibfdt features:
- Support for most remaining, relevant libfdt functions
- Support for sequential-write functions

Changes are applied to existing U-Boot tools as needed.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 scripts/dtc/libfdt/libfdt.h   |   3 +
 scripts/dtc/pylibfdt/libfdt.i_shipped | 705 +++---
 tools/dtoc/dtoc.py|  20 +-
 tools/dtoc/fdt.py |   3 +-
 tools/dtoc/test_dtoc.py   |   3 +-
 5 files changed, 663 insertions(+), 71 deletions(-)

diff --git a/scripts/dtc/libfdt/libfdt.h b/scripts/dtc/libfdt/libfdt.h
index 1e27780e11..fd73688f9e 100644
--- a/scripts/dtc/libfdt/libfdt.h
+++ b/scripts/dtc/libfdt/libfdt.h
@@ -1313,10 +1313,13 @@ static inline int fdt_property_u64(void *fdt, const 
char *name, uint64_t val)
fdt64_t tmp = cpu_to_fdt64(val);
return fdt_property(fdt, name, , sizeof(tmp));
 }
+
+#ifndef SWIG /* Not available in Python */
 static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val)
 {
return fdt_property_u32(fdt, name, val);
 }
+#endif
 
 /**
  * fdt_property_placeholder - add a new property and return a ptr to its value
diff --git a/scripts/dtc/pylibfdt/libfdt.i_shipped 
b/scripts/dtc/pylibfdt/libfdt.i_shipped
index 2c1c987c1d..6774b93b2c 100644
--- a/scripts/dtc/pylibfdt/libfdt.i_shipped
+++ b/scripts/dtc/pylibfdt/libfdt.i_shipped
@@ -12,6 +12,17 @@
 %{
 #define SWIG_FILE_WITH_INIT
 #include "libfdt.h"
+
+/*
+ * We rename this function here to avoid problems with swig, since we also have
+ * a struct called fdt_property. That struct causes swig to create a class in
+ * libfdt.py called fdt_property(), which confuses things.
+ */
+static int _fdt_property(void *fdt, const char *name, const char *val, int len)
+{
+return fdt_property(fdt, name, val, len);
+}
+
 %}
 
 %pythoncode %{
@@ -108,6 +119,7 @@ def check_err_null(val, quiet=()):
 raise FdtException(val)
 return val
 
+
 class Fdt:
 """Device tree class, supporting all operations
 
@@ -129,6 +141,163 @@ class Fdt:
 self._fdt = bytearray(data)
 check_err(fdt_check_header(self._fdt));
 
+def as_bytearray(self):
+"""Get the device tree contents as a bytearray
+
+This can be passed directly to libfdt functions that access a
+const void * for the device tree.
+
+Returns:
+bytearray containing the device tree
+"""
+return bytearray(self._fdt)
+
+def next_node(self, nodeoffset, depth, quiet=()):
+"""Find the next subnode
+
+Args:
+nodeoffset: Node offset of previous node
+depth: On input, the depth of the node at nodeoffset. On output, 
the
+   depth of the returned node
+quiet: Errors to ignore (empty to raise on all errors)
+
+Returns:
+The offset of the next node, if any
+
+Raises:
+FdtException if no more nodes found or other error occurs
+"""
+return check_err(fdt_next_node(self._fdt, nodeoffset, depth), quiet)
+
+def first_subnode(self, nodeoffset, quiet=()):
+"""Find the first subnode of a parent node
+
+Args:
+nodeoffset: Node offset of parent node
+quiet: Errors to ignore (empty to raise on all errors)
+
+Returns:
+The offset of the first subnode, if any
+
+Raises:
+FdtException if no subnodes found or other error occurs
+"""
+return check_err(fdt_first_subnode(self._fdt, nodeoffset), quiet)
+
+def next_subnode(self, nodeoffset, quiet=()):
+"""Find the next subnode
+
+Args:
+nodeoffset: Node offset of previous subnode
+quiet: Errors to ignore (empty to raise on all errors)
+
+Returns:
+The offset of the next subnode, if any
+
+Raises:
+FdtException if no more subnodes found or other error occurs
+"""
+return check_err(fdt_next_subnode(self._fdt, nodeoffset), quiet)
+
+def magic(self):
+"""Return the magic word from the header
+
+Returns:
+Magic word
+"""
+return fdt_magic(self._fdt) & 0x
+
+def totalsize(self):
+"""Return the total size of the device tree
+
+Returns:
+Total tree size in bytes
+"""
+return check_err(fdt_totalsize(self._fdt))
+
+def off_dt_struct(self):
+"""Return the start of the device-tree struct area
+
+Returns:
+Start offset of struct area
+"""
+return check_err(fdt_off_dt_struct(self._fdt))
+
+def off_dt_strings(self):
+"""Return the start of the 

[U-Boot] [PATCH v2 28/29] binman: Add a SetCalculatedProperties() method

2018-07-06 Thread Simon Glass
Once binman has packed the image, the position and size of each entry is
known. It is then possible for binman to update the device tree with these
positions. Since placeholder values have been added, this does not affect
the size of the device tree and therefore the packing does not need to be
performed again.

Add a new SetCalculatedProperties method to handle this.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/binman/README   | 29 -
 tools/binman/bsection.py  |  8 
 tools/binman/cmdline.py   |  2 ++
 tools/binman/control.py   |  4 
 tools/binman/entry.py | 11 +++
 tools/binman/etype/section.py |  8 
 tools/binman/image.py | 14 ++
 7 files changed, 67 insertions(+), 9 deletions(-)

diff --git a/tools/binman/README b/tools/binman/README
index 008d575052..8b598a75c8 100644
--- a/tools/binman/README
+++ b/tools/binman/README
@@ -462,14 +462,22 @@ Order of image creation
 
 Image creation proceeds in the following order, for each entry in the image.
 
-1. ProcessFdt() - process the device tree information as required by the
+1. AddMissingProperties() - binman can add calculated values to the device
+tree as part of its processing, for example the position and size of each
+entry. This method adds any properties associated with this, expanding the
+device tree as needed. These properties can have placeholder values which are
+set later by SetCalculatedProperties(). By that stage the size of sections
+cannot be changed (since it would cause the images to need to be repacked),
+but the correct values can be inserted.
+
+2. ProcessFdt() - process the device tree information as required by the
 particular entry. This may involve adding or deleting properties. If the
 processing is complete, this method should return True. If the processing
 cannot complete because it needs the ProcessFdt() method of another entry to
 run first, this method should return False, in which case it will be called
 again later.
 
-2. GetEntryContents() - the contents of each entry are obtained, normally by
+3. GetEntryContents() - the contents of each entry are obtained, normally by
 reading from a file. This calls the Entry.ObtainContents() to read the
 contents. The default version of Entry.ObtainContents() calls
 Entry.GetDefaultFilename() and then reads that file. So a common mechanism
@@ -478,35 +486,38 @@ functions must return True when they have read the 
contents. Binman will
 retry calling the functions a few times if False is returned, allowing
 dependencies between the contents of different entries.
 
-3. GetEntryPositions() - calls Entry.GetPositions() for each entry. This can
+4. GetEntryPositions() - calls Entry.GetPositions() for each entry. This can
 return a dict containing entries that need updating. The key should be the
 entry name and the value is a tuple (pos, size). This allows an entry to
 provide the position and size for other entries. The default implementation
 of GetEntryPositions() returns {}.
 
-4. PackEntries() - calls Entry.Pack() which figures out the position and
+5. PackEntries() - calls Entry.Pack() which figures out the position and
 size of an entry. The 'current' image position is passed in, and the function
 returns the position immediately after the entry being packed. The default
 implementation of Pack() is usually sufficient.
 
-5. CheckSize() - checks that the contents of all the entries fits within
+6. CheckSize() - checks that the contents of all the entries fits within
 the image size. If the image does not have a defined size, the size is set
 large enough to hold all the entries.
 
-6. CheckEntries() - checks that the entries do not overlap, nor extend
+7. CheckEntries() - checks that the entries do not overlap, nor extend
 outside the image.
 
-7. ProcessEntryContents() - this calls Entry.ProcessContents() on each entry.
+8. SetCalculatedProperties() - update any calculated properties in the device
+tree. This sets the correct 'pos' and 'size' vaues, for example.
+
+9. ProcessEntryContents() - this calls Entry.ProcessContents() on each entry.
 The default implementatoin does nothing. This can be overriden to adjust the
 contents of an entry in some way. For example, it would be possible to create
 an entry containing a hash of the contents of some other entries. At this
 stage the position and size of entries should not be adjusted.
 
-8. WriteSymbols() - write the value of symbols into the U-Boot SPL binary.
+10. WriteSymbols() - write the value of symbols into the U-Boot SPL binary.
 See 'Access to binman entry positions at run time' below for a description of
 what happens in this stage.
 
-9. BuildImage() - builds the image and writes it to a file. This is the final
+11. BuildImage() - builds the image and writes it to a file. This is the final
 step.
 
 
diff --git a/tools/binman/bsection.py b/tools/binman/bsection.py
index 3ed361d69a..de439ef625 100644
--- 

[U-Boot] [PATCH v2 24/29] dtoc: Avoid unwanted output during tests

2018-07-06 Thread Simon Glass
At present some warnings are printed to indicate failures which are a
known part of running the tests. Suppress these.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/dtoc/fdt_util.py  |  4 ++--
 tools/dtoc/test_dtoc.py | 13 +
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/tools/dtoc/fdt_util.py b/tools/dtoc/fdt_util.py
index 88fc318383..5b631419a9 100644
--- a/tools/dtoc/fdt_util.py
+++ b/tools/dtoc/fdt_util.py
@@ -51,7 +51,7 @@ def fdt_cells_to_cpu(val, cells):
 out = out << 32 | fdt32_to_cpu(val[1])
 return out
 
-def EnsureCompiled(fname):
+def EnsureCompiled(fname, capture_stderr=False):
 """Compile an fdt .dts source file into a .dtb binary blob if needed.
 
 Args:
@@ -86,7 +86,7 @@ def EnsureCompiled(fname):
 args.extend(search_list)
 args.append(dts_input)
 dtc = os.environ.get('DTC') or 'dtc'
-command.Run(dtc, *args)
+command.Run(dtc, *args, capture_stderr=capture_stderr)
 return dtb_output
 
 def GetInt(node, propname, default=None):
diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py
index adf60a05d2..9da32fa049 100644
--- a/tools/dtoc/test_dtoc.py
+++ b/tools/dtoc/test_dtoc.py
@@ -47,16 +47,19 @@ C_HEADER = '''/*
 '''
 
 
-def get_dtb_file(dts_fname):
+
+def get_dtb_file(dts_fname, capture_stderr=False):
 """Compile a .dts file to a .dtb
 
 Args:
 dts_fname: Filename of .dts file in the current directory
+capture_stderr: True to capture and discard stderr output
 
 Returns:
 Filename of compiled file in output directory
 """
-return fdt_util.EnsureCompiled(os.path.join(our_path, dts_fname))
+return fdt_util.EnsureCompiled(os.path.join(our_path, dts_fname),
+   capture_stderr=capture_stderr)
 
 
 class TestDtoc(unittest.TestCase):
@@ -626,7 +629,8 @@ U_BOOT_DEVICE(test3) = {
 
 def test_bad_reg(self):
 """Test that a reg property with an invalid type generates an error"""
-dtb_file = get_dtb_file('dtoc_test_bad_reg.dts')
+# Capture stderr since dtc will emit warnings for this file
+dtb_file = get_dtb_file('dtoc_test_bad_reg.dts', capture_stderr=True)
 output = tools.GetOutputFilename('output')
 with self.assertRaises(ValueError) as e:
 dtb_platdata.run_steps(['struct'], dtb_file, False, output)
@@ -635,7 +639,8 @@ U_BOOT_DEVICE(test3) = {
 
 def test_bad_reg2(self):
 """Test that a reg property with an invalid cell count is detected"""
-dtb_file = get_dtb_file('dtoc_test_bad_reg2.dts')
+# Capture stderr since dtc will emit warnings for this file
+dtb_file = get_dtb_file('dtoc_test_bad_reg2.dts', capture_stderr=True)
 output = tools.GetOutputFilename('output')
 with self.assertRaises(ValueError) as e:
 dtb_platdata.run_steps(['struct'], dtb_file, False, output)
-- 
2.18.0.203.gfac676dfb9-goog

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


[U-Boot] [PATCH v2 12/29] dtoc: Update tests to write failures to /tmp

2018-07-06 Thread Simon Glass
When a test fails due to an output mismatch (e.g. due to a new property
being adding to a test file) it is currently hard to update the test to
the new output. In particular the tabs in the file are written as \t in
the Python tests.

To make this easier, write both the expected and actual results to /tmp
to allow use of meld, and copying into the test.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/dtoc/test_dtoc.py | 56 ++---
 1 file changed, 42 insertions(+), 14 deletions(-)

diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py
index e475a7eb14..ce6d2585a4 100644
--- a/tools/dtoc/test_dtoc.py
+++ b/tools/dtoc/test_dtoc.py
@@ -68,6 +68,34 @@ class TestDtoc(unittest.TestCase):
 def tearDownClass(cls):
 tools._RemoveOutputDir()
 
+def _WritePythonString(self, fname, data):
+"""Write a string with tabs expanded as done in this Python file
+
+Args:
+fname: Filename to write to
+data: Raw string to convert
+"""
+data = data.replace('\t', '\\t')
+with open(fname, 'w') as fd:
+fd.write(data)
+
+def _CheckStrings(self, expected, actual):
+"""Check that a string matches its expected value
+
+If the strings do not match, they are written to the /tmp directory in
+the same Python format as is used here in the test. This allows for
+easy comparison and update of the tests.
+
+Args:
+expected: Expected string
+actual: Actual string
+"""
+if expected != actual:
+self._WritePythonString('/tmp/binman.expected', expected)
+self._WritePythonString('/tmp/binman.actual', actual)
+print 'Failures written to /tmp/binman.{expected,actual}'
+self.assertEquals(expected, actual)
+
 def test_name(self):
 """Test conversion of device tree names to C identifiers"""
 self.assertEqual('serial_at_0x12', conv_name_to_c('serial@0x12'))
@@ -138,7 +166,7 @@ class TestDtoc(unittest.TestCase):
 dtb_platdata.run_steps(['struct'], dtb_file, False, output)
 with open(output) as infile:
 data = infile.read()
-self.assertEqual(HEADER + '''
+self._CheckStrings(HEADER + '''
 struct dtd_sandbox_i2c_test {
 };
 struct dtd_sandbox_pmic_test {
@@ -162,7 +190,7 @@ struct dtd_sandbox_spl_test_2 {
 dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
 with open(output) as infile:
 data = infile.read()
-self.assertEqual(C_HEADER + '''
+self._CheckStrings(C_HEADER + '''
 static struct dtd_sandbox_spl_test dtv_spl_test = {
 \t.bytearray\t\t= {0x6, 0x0, 0x0},
 \t.byteval\t\t= 0x5,
@@ -240,7 +268,7 @@ U_BOOT_DEVICE(pmic_at_9) = {
 dtb_platdata.run_steps(['struct'], dtb_file, False, output)
 with open(output) as infile:
 data = infile.read()
-self.assertEqual(HEADER + '''
+self._CheckStrings(HEADER + '''
 struct dtd_source {
 \tstruct phandle_2_arg clocks[4];
 };
@@ -252,7 +280,7 @@ struct dtd_target {
 dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
 with open(output) as infile:
 data = infile.read()
-self.assertEqual(C_HEADER + '''
+self._CheckStrings(C_HEADER + '''
 static struct dtd_target dtv_phandle_target = {
 \t.intval\t\t\t= 0x0,
 };
@@ -302,7 +330,7 @@ U_BOOT_DEVICE(phandle_source) = {
 dtb_platdata.run_steps(['struct'], dtb_file, False, output)
 with open(output) as infile:
 data = infile.read()
-self.assertEqual(HEADER + '''
+self._CheckStrings(HEADER + '''
 struct dtd_compat1 {
 \tfdt32_t\t\tintval;
 };
@@ -313,7 +341,7 @@ struct dtd_compat1 {
 dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
 with open(output) as infile:
 data = infile.read()
-self.assertEqual(C_HEADER + '''
+self._CheckStrings(C_HEADER + '''
 static struct dtd_compat1 dtv_spl_test = {
 \t.intval\t\t\t= 0x1,
 };
@@ -332,7 +360,7 @@ U_BOOT_DEVICE(spl_test) = {
 dtb_platdata.run_steps(['struct'], dtb_file, False, output)
 with open(output) as infile:
 data = infile.read()
-self.assertEqual(HEADER + '''
+self._CheckStrings(HEADER + '''
 struct dtd_test1 {
 \tfdt64_t\t\treg[2];
 };
@@ -347,7 +375,7 @@ struct dtd_test3 {
 dtb_platdata.run_steps(['platdata'], dtb_file, False, output)
 with open(output) as infile:
 data = infile.read()
-self.assertEqual(C_HEADER + '''
+self._CheckStrings(C_HEADER + '''
 static struct dtd_test1 dtv_test1 = {
 \t.reg\t\t\t= {0x1234, 0x5678},
 };
@@ -384,7 +412,7 @@ U_BOOT_DEVICE(test3) = {
 dtb_platdata.run_steps(['struct'], dtb_file, False, output)
 with open(output) as infile:
 data = infile.read()
-self.assertEqual(HEADER + '''
+

[U-Boot] [PATCH v2 16/29] dtoc: Keep track of property offsets

2018-07-06 Thread Simon Glass
At present the Fdt class does not keep track of property offsets if they
change due to removal of properties. Update the code to handle this, and
add a test.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/dtoc/fdt.py  | 20 +
 tools/dtoc/test_fdt.py | 65 +-
 2 files changed, 78 insertions(+), 7 deletions(-)

diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py
index fd016bb8ce..274c142e7a 100644
--- a/tools/dtoc/fdt.py
+++ b/tools/dtoc/fdt.py
@@ -49,6 +49,9 @@ class Prop:
 return
 self.type, self.value = self.BytesToValue(bytes)
 
+def RefreshOffset(self, poffset):
+self._offset = poffset
+
 def Widen(self, newprop):
 """Figure out which property type is more general
 
@@ -154,6 +157,7 @@ class Prop:
 Returns:
 The offset of the property (struct fdt_property) within the file
 """
+self._node._fdt.CheckCache()
 return self._node._fdt.GetStructOffset(self._offset)
 
 class Node:
@@ -233,8 +237,23 @@ class Node:
 self._offset = my_offset
 offset = fdt_obj.first_subnode(self._offset, QUIET_NOTFOUND)
 for subnode in self.subnodes:
+if subnode.name != fdt_obj.get_name(offset):
+raise ValueError('Internal error, node name mismatch %s != %s' 
%
+ (subnode.name, fdt_obj.get_name(offset)))
 subnode.Refresh(offset)
 offset = fdt_obj.next_subnode(offset, QUIET_NOTFOUND)
+if offset != -libfdt.FDT_ERR_NOTFOUND:
+raise ValueError('Internal error, offset == %d' % offset)
+
+poffset = fdt_obj.first_property_offset(self._offset, QUIET_NOTFOUND)
+while poffset >= 0:
+p = fdt_obj.get_property_by_offset(poffset)
+prop = self.props.get(p.name)
+if not prop:
+raise ValueError("Internal error, property '%s' missing, "
+ 'offset %d' % (p.name, poffset))
+prop.RefreshOffset(poffset)
+poffset = fdt_obj.next_property_offset(poffset, QUIET_NOTFOUND)
 
 def DeleteProp(self, prop_name):
 """Delete a property of a node
@@ -278,6 +297,7 @@ class Fdt:
 
 TODO(s...@chromium.org): Implement the 'root' parameter
 """
+self._cached_offsets = True
 self._root = self.Node(self, None, 0, '/', '/')
 self._root.Scan()
 
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index d44e4dd842..e57298dbe7 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -24,6 +24,30 @@ import libfdt
 import test_util
 import tools
 
+def _GetPropertyValue(dtb, node, prop_name):
+"""Low-level function to get the property value based on its offset
+
+This looks directly in the device tree at the property's offset to find
+its value. It is useful as a check that the property is in the correct
+place.
+
+Args:
+node: Node to look in
+prop_name: Property name to find
+
+Returns:
+Tuple:
+Prop object found
+Value of property as a string (found using property offset)
+"""
+prop = node.props[prop_name]
+
+# Add 12, which is sizeof(struct fdt_property), to get to start of data
+offset = prop.GetOffset() + 12
+data = dtb.GetContents()[offset:offset + len(prop.value)]
+return prop, [chr(x) for x in data]
+
+
 class TestFdt(unittest.TestCase):
 """Tests for the Fdt module
 
@@ -124,6 +148,12 @@ class TestNode(unittest.TestCase):
 with self.assertRaises(libfdt.FdtException):
 self.node.DeleteProp('missing')
 
+def testDeleteGetOffset(self):
+"""Test that property offset update when properties are deleted"""
+self.node.DeleteProp('intval')
+prop, value = _GetPropertyValue(self.dtb, self.node, 'longbytearray')
+self.assertEqual(prop.value, value)
+
 def testFindNode(self):
 """Tests that we can find a node using the _FindNode() functoin"""
 node = self.dtb.GetRoot()._FindNode('i2c@0')
@@ -132,6 +162,32 @@ class TestNode(unittest.TestCase):
 self.assertEqual('pmic@9', subnode.name)
 self.assertEqual(None, node._FindNode('missing'))
 
+def testRefreshMissingNode(self):
+"""Test refreshing offsets when an extra node is present in dtb"""
+# Delete it from our tables, not the device tree
+del self.dtb._root.subnodes[-1]
+with self.assertRaises(ValueError) as e:
+self.dtb.Refresh()
+self.assertIn('Internal error, offset', str(e.exception))
+
+def testRefreshExtraNode(self):
+"""Test refreshing offsets when an expected node is missing"""
+# Delete it from the device tre, not our tables
+self.dtb.GetFdtObj().del_node(self.node.Offset())
+with self.assertRaises(ValueError) as e:
+self.dtb.Refresh()
+

[U-Boot] [PATCH v2 18/29] dtoc: Fix properties with a single zero-arg phandle

2018-07-06 Thread Simon Glass
At present a property with a single phandle looks like an integer value
to dtoc. Correct this by adjusting it in the phandle-processing code.

Add a test for this.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Update to cope with GetPhandle() being removed

 tools/dtoc/dtb_platdata.py   | 12 
 tools/dtoc/dtoc_test_phandle.dts |  6 ++
 tools/dtoc/test_dtoc.py  | 10 ++
 tools/dtoc/test_fdt.py   |  4 +++-
 4 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index 2f7302e529..b1323aef19 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -211,15 +211,21 @@ class DtbPlatdata(object):
 Number of argument cells is this is a phandle, else None
 """
 if prop.name in ['clocks']:
+if not isinstance(prop.value, list):
+prop.value = [prop.value]
 val = prop.value
-if not isinstance(val, list):
-val = [val]
 i = 0
 
 max_args = 0
 args = []
 while i < len(val):
 phandle = fdt_util.fdt32_to_cpu(val[i])
+# If we get to the end of the list, stop. This can happen
+# since some nodes have more phandles in the list than others,
+# but we allocate enough space for the largest list. So those
+# nodes with shorter lists end up with zeroes at the end.
+if not phandle:
+break
 target = self._fdt.phandle_to_node.get(phandle)
 if not target:
 raise ValueError("Cannot parse '%s' in node '%s'" %
@@ -400,8 +406,6 @@ class DtbPlatdata(object):
 continue
 info = self.get_phandle_argc(prop, node.name)
 if info:
-if not isinstance(prop.value, list):
-prop.value = [prop.value]
 # Process the list as pairs of (phandle, id)
 pos = 0
 for args in info.args:
diff --git a/tools/dtoc/dtoc_test_phandle.dts b/tools/dtoc/dtoc_test_phandle.dts
index 91dfec5c63..a71acffc69 100644
--- a/tools/dtoc/dtoc_test_phandle.dts
+++ b/tools/dtoc/dtoc_test_phandle.dts
@@ -33,4 +33,10 @@
compatible = "source";
clocks = < _1 11 _2 12 13 >;
};
+
+   phandle-source2 {
+   u-boot,dm-pre-reloc;
+   compatible = "source";
+   clocks = <>;
+   };
 };
diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py
index 20fea522c4..11cac3fc7a 100644
--- a/tools/dtoc/test_dtoc.py
+++ b/tools/dtoc/test_dtoc.py
@@ -323,6 +323,16 @@ U_BOOT_DEVICE(phandle_source) = {
 \t.platdata_size\t= sizeof(dtv_phandle_source),
 };
 
+static struct dtd_source dtv_phandle_source2 = {
+\t.clocks\t\t\t= {
+\t\t\t{_phandle_target, {}},},
+};
+U_BOOT_DEVICE(phandle_source2) = {
+\t.name\t\t= "source",
+\t.platdata\t= _phandle_source2,
+\t.platdata_size\t= sizeof(dtv_phandle_source2),
+};
+
 ''', data)
 
 def test_aliases(self):
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index 9fef8ed549..49d188b1c1 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -210,7 +210,9 @@ class TestProp(unittest.TestCase):
 
 def testPhandle(self):
 dtb = fdt.FdtScan('tools/dtoc/dtoc_test_phandle.dts')
-node = dtb.GetNode('/phandle-source')
+node = dtb.GetNode('/phandle-source2')
+prop = node.props['clocks']
+self.assertTrue(fdt32_to_cpu(prop.value) > 0)
 
 def _ConvertProp(self, prop_name):
 """Helper function to look up a property in self.node and return it
-- 
2.18.0.203.gfac676dfb9-goog

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


[U-Boot] [PATCH v2 11/29] dtoc: Add some tests for the fdt module

2018-07-06 Thread Simon Glass
At present this module is tested via the dtoc tests. This is a bit painful
since the tests are at a higher level and so failures are more difficult
to diagnose.

Add some tests that exercise the fdt module directly.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/dtoc/fdt.py  |  12 +-
 tools/dtoc/test_fdt|   1 +
 tools/dtoc/test_fdt.py | 246 +
 3 files changed, 257 insertions(+), 2 deletions(-)
 create mode 12 tools/dtoc/test_fdt
 create mode 100755 tools/dtoc/test_fdt.py

diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py
index d08b0b53e6..5cde8c125a 100644
--- a/tools/dtoc/fdt.py
+++ b/tools/dtoc/fdt.py
@@ -138,6 +138,7 @@ class Prop:
 else:
 return TYPE_INT, val
 
+@classmethod
 def GetEmpty(self, type):
 """Get an empty / zero value of the given type
 
@@ -335,12 +336,19 @@ class Fdt:
 """
 return self._fdt
 
-def CheckErr(errnum, msg):
+def GetFdtObj(self):
+"""Get the contents of the FDT
+
+Returns:
+The FDT contents as a libfdt.Fdt object
+"""
+return self._fdt_obj
+
+def CheckErr(self, errnum, msg):
 if errnum:
 raise ValueError('Error %d: %s: %s' %
 (errnum, libfdt.fdt_strerror(errnum), msg))
 
-
 def GetProps(self, node):
 """Get all properties from a node.
 
diff --git a/tools/dtoc/test_fdt b/tools/dtoc/test_fdt
new file mode 12
index 00..7c3b23031f
--- /dev/null
+++ b/tools/dtoc/test_fdt
@@ -0,0 +1 @@
+test_fdt.py
\ No newline at end of file
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
new file mode 100755
index 00..ba660ca9b7
--- /dev/null
+++ b/tools/dtoc/test_fdt.py
@@ -0,0 +1,246 @@
+#!/usr/bin/python
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2018 Google, Inc
+# Written by Simon Glass 
+#
+
+from optparse import OptionParser
+import glob
+import os
+import sys
+import unittest
+
+# Bring in the patman libraries
+our_path = os.path.dirname(os.path.realpath(__file__))
+for dirname in ['../patman', '..']:
+sys.path.insert(0, os.path.join(our_path, dirname))
+
+import command
+import fdt
+from fdt import TYPE_BYTE, TYPE_INT, TYPE_STRING, TYPE_BOOL
+from fdt_util import fdt32_to_cpu
+import libfdt
+import test_util
+import tools
+
+class TestFdt(unittest.TestCase):
+"""Tests for the Fdt module
+
+This includes unit tests for some functions and functional tests for the 
fdt
+module.
+"""
+@classmethod
+def setUpClass(cls):
+tools.PrepareOutputDir(None)
+
+@classmethod
+def tearDownClass(cls):
+tools._FinaliseForTest()
+
+def setUp(self):
+self.dtb = fdt.FdtScan('tools/dtoc/dtoc_test_simple.dts')
+
+def testFdt(self):
+"""Test that we can open an Fdt"""
+self.dtb.Scan()
+root = self.dtb.GetRoot()
+self.assertTrue(isinstance(root, fdt.Node))
+
+def testGetNode(self):
+"""Test the GetNode() method"""
+node = self.dtb.GetNode('/spl-test')
+self.assertTrue(isinstance(node, fdt.Node))
+node = self.dtb.GetNode('/i2c@0/pmic@9')
+self.assertTrue(isinstance(node, fdt.Node))
+self.assertEqual('pmic@9', node.name)
+
+def testFlush(self):
+"""Check that we can flush the device tree out to its file"""
+fname = self.dtb._fname
+with open(fname) as fd:
+data = fd.read()
+os.remove(fname)
+with self.assertRaises(IOError):
+open(fname)
+self.dtb.Flush()
+with open(fname) as fd:
+data = fd.read()
+
+def testPack(self):
+"""Test that packing a device tree works"""
+self.dtb.Pack()
+
+def testGetFdt(self):
+"""Tetst that we can access the raw device-tree data"""
+self.assertTrue(isinstance(self.dtb.GetFdt(), bytearray))
+
+def testGetProps(self):
+"""Tests obtaining a list of properties"""
+node = self.dtb.GetNode('/spl-test')
+props = self.dtb.GetProps(node)
+self.assertEqual(['boolval', 'bytearray', 'byteval', 'compatible',
+  'intarray', 'intval', 'longbytearray',
+  'stringarray', 'stringval', 'u-boot,dm-pre-reloc'],
+ sorted(props.keys()))
+
+def testCheckError(self):
+"""Tests the ChecKError() function"""
+with self.assertRaises(ValueError) as e:
+self.dtb.CheckErr(-libfdt.NOTFOUND, 'hello')
+self.assertIn('FDT_ERR_NOTFOUND: hello', str(e.exception))
+
+
+class TestNode(unittest.TestCase):
+"""Test operation of the Node class"""
+
+@classmethod
+def setUpClass(cls):
+tools.PrepareOutputDir(None)
+
+@classmethod
+def tearDownClass(cls):
+tools._FinaliseForTest()
+
+def setUp(self):
+self.dtb = fdt.FdtScan('tools/dtoc/dtoc_test_simple.dts')
+self.node = 

[U-Boot] [PATCH v2 09/29] libfdt: Add get_property() and del_node()

2018-07-06 Thread Simon Glass
Add support for these functions in the Python binding. This patch stands
in for a pending upstream change.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 scripts/dtc/pylibfdt/libfdt.i_shipped | 32 +++
 1 file changed, 32 insertions(+)

diff --git a/scripts/dtc/pylibfdt/libfdt.i_shipped 
b/scripts/dtc/pylibfdt/libfdt.i_shipped
index 5b38e63b26..e180ee9308 100644
--- a/scripts/dtc/pylibfdt/libfdt.i_shipped
+++ b/scripts/dtc/pylibfdt/libfdt.i_shipped
@@ -398,6 +398,27 @@ class Fdt:
 return pdata
 return Property(pdata[0], pdata[1])
 
+def get_property(self, nodeoffset, prop_name, quiet=()):
+"""Obtains a property by name
+
+Args:
+nodeoffset: Offset to the node to check
+prop_name: Name of property to get
+quiet: Errors to ignore (empty to raise on all errors)
+
+Returns:
+Property object, or None if not found
+
+Raises:
+FdtException on error (e.g. invalid prop_offset or device
+tree format)
+"""
+pdata = check_err_null(
+fdt_get_property(self._fdt, nodeoffset, prop_name), quiet)
+if isinstance(pdata, (int)):
+return pdata
+return Property(pdata[0], pdata[1])
+
 @staticmethod
 def create_empty_tree(size, quiet=()):
 """Create an empty device tree ready for use
@@ -632,6 +653,17 @@ class Fdt:
 """
 return check_err(fdt_node_offset_by_phandle(self._fdt, phandle), quiet)
 
+def del_node(self, nodeoffset):
+"""Delete a node
+
+Args:
+nodeoffset: Node offset containing property to delete
+
+Raises:
+FdtError if the node does not exist, or another error occurs
+"""
+return check_err(fdt_del_node(self._fdt, nodeoffset))
+
 
 class Property(bytearray):
 """Holds a device tree property name and value.
-- 
2.18.0.203.gfac676dfb9-goog

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


[U-Boot] [PATCH v2 04/29] binman: Correct operation of ObtainContents()

2018-07-06 Thread Simon Glass
This method is supposed to return the contents of an entry. However at
present there is no check that it actually does. Also some implementations
do not return 'True' to indicate success, as required.

Add a check for things working as expected, and correct the
implementations.

This requires some additional test cases to cover things which were missed
originally. Add these at the same time.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/binman/bsection.py  |  4 ++
 tools/binman/etype/_testing.py|  5 ++
 tools/binman/etype/section.py |  2 +-
 tools/binman/etype/u_boot_spl_bss_pad.py  |  1 +
 tools/binman/etype/u_boot_ucode.py|  9 ++-
 tools/binman/ftest.py | 57 +++
 tools/binman/test/57_unknown_contents.dts | 14 +
 .../test/58_x86_ucode_spl_needs_retry.dts | 36 
 8 files changed, 114 insertions(+), 14 deletions(-)
 create mode 100644 tools/binman/test/57_unknown_contents.dts
 create mode 100644 tools/binman/test/58_x86_ucode_spl_needs_retry.dts

diff --git a/tools/binman/bsection.py b/tools/binman/bsection.py
index 3f30f6e4fe..06a6711350 100644
--- a/tools/binman/bsection.py
+++ b/tools/binman/bsection.py
@@ -162,6 +162,10 @@ class Section(object):
 todo = next_todo
 if not todo:
 break
+if todo:
+self._Raise('Internal error: Could not complete processing of '
+'contents: remaining %s' % todo)
+return True
 
 def _SetEntryPosSize(self, name, pos, size):
 """Set the position and size of an entry
diff --git a/tools/binman/etype/_testing.py b/tools/binman/etype/_testing.py
index 0b1eaefc3c..c075c3ff0d 100644
--- a/tools/binman/etype/_testing.py
+++ b/tools/binman/etype/_testing.py
@@ -9,6 +9,7 @@ from entry import Entry
 import fdt_util
 import tools
 
+
 class Entry__testing(Entry):
 """A fake entry used for testing
 
@@ -19,8 +20,12 @@ class Entry__testing(Entry):
 Entry.__init__(self, section, etype, node)
 self.return_invalid_entry = fdt_util.GetBool(self._node,
  'return-invalid-entry')
+self.return_unknown_contents = fdt_util.GetBool(self._node,
+ 'return-unknown-contents')
 
 def ObtainContents(self):
+if self.return_unknown_contents:
+return False
 self.data = 'a'
 self.contents_size = len(self.data)
 return True
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index 139fcad51a..36b31a849f 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -18,7 +18,7 @@ class Entry_section(Entry):
 self._section = bsection.Section(node.name, node)
 
 def ObtainContents(self):
-self._section.GetEntryContents()
+return self._section.GetEntryContents()
 
 def GetData(self):
 return self._section.GetData()
diff --git a/tools/binman/etype/u_boot_spl_bss_pad.py 
b/tools/binman/etype/u_boot_spl_bss_pad.py
index 3d2dea2e0d..6c397957e3 100644
--- a/tools/binman/etype/u_boot_spl_bss_pad.py
+++ b/tools/binman/etype/u_boot_spl_bss_pad.py
@@ -24,3 +24,4 @@ class Entry_u_boot_spl_bss_pad(Entry_blob):
 self.Raise('Expected __bss_size symbol in spl/u-boot-spl')
 self.data = chr(0) * bss_size
 self.contents_size = bss_size
+return True
diff --git a/tools/binman/etype/u_boot_ucode.py 
b/tools/binman/etype/u_boot_ucode.py
index 3a0cff7c3a..8cae7deed3 100644
--- a/tools/binman/etype/u_boot_ucode.py
+++ b/tools/binman/etype/u_boot_ucode.py
@@ -64,9 +64,14 @@ class Entry_u_boot_ucode(Entry_blob):
 self.data = ''
 return True
 
-# Get the microcode from the device tree entry
+# Get the microcode from the device tree entry. If it is not available
+# yet, return False so we will be called later. If the section simply
+# doesn't exist, then we may as well return True, since we are going to
+# get an error anyway.
 fdt_entry = self.section.FindEntryType('u-boot-dtb-with-ucode')
-if not fdt_entry or not fdt_entry.ucode_data:
+if not fdt_entry:
+return True
+if not fdt_entry.ucode_data:
 return False
 
 if not fdt_entry.collate:
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 80eadeffab..ca9d158eef 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -688,12 +688,14 @@ class TestFunctional(unittest.TestCase):
 data = self._DoReadFile('33_x86-start16.dts')
 self.assertEqual(X86_START16_DATA, data[:len(X86_START16_DATA)])
 
-def _RunMicrocodeTest(self, dts_fname, nodtb_data):
+def _RunMicrocodeTest(self, dts_fname, nodtb_data, ucode_second=False):
 """Handle running a test for insertion of microcode
 
  

[U-Boot] [PATCH v2 03/29] binman: Tidy up variables in _RunMicrocodeTest()

2018-07-06 Thread Simon Glass
At present we call the three entries first, second and third. Rename them
to reflect their contents instead, for clarity.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/binman/ftest.py | 25 ++---
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index eb8a0793cb..80eadeffab 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -689,29 +689,40 @@ class TestFunctional(unittest.TestCase):
 self.assertEqual(X86_START16_DATA, data[:len(X86_START16_DATA)])
 
 def _RunMicrocodeTest(self, dts_fname, nodtb_data):
+"""Handle running a test for insertion of microcode
+
+Args:
+dts_fname: Name of test .dts file
+nodtb_data: Data that we expect in the first section
+
+Returns:
+Tuple:
+Contents of first region (U-Boot or SPL)
+Position and size components of microcode pointer, as inserted
+in the above (two 4-byte words)
+"""
 data = self._DoReadFile(dts_fname, True)
 
 # Now check the device tree has no microcode
-second = data[len(nodtb_data):]
+dtb_with_ucode = data[len(nodtb_data):]
+fdt_len = self.GetFdtLen(dtb_with_ucode)
+ucode_content = dtb_with_ucode[fdt_len:]
+ucode_pos = len(nodtb_data) + fdt_len
 fname = tools.GetOutputFilename('test.dtb')
 with open(fname, 'wb') as fd:
-fd.write(second)
+fd.write(dtb_with_ucode)
 dtb = fdt.FdtScan(fname)
 ucode = dtb.GetNode('/microcode')
 self.assertTrue(ucode)
 for node in ucode.subnodes:
 self.assertFalse(node.props.get('data'))
 
-fdt_len = self.GetFdtLen(second)
-third = second[fdt_len:]
-
 # Check that the microcode appears immediately after the Fdt
 # This matches the concatenation of the data properties in
 # the /microcode/update@xxx nodes in 34_x86_ucode.dts.
 ucode_data = struct.pack('>4L', 0x12345678, 0x12345679, 0xabcd,
  0x78235609)
-self.assertEqual(ucode_data, third[:len(ucode_data)])
-ucode_pos = len(nodtb_data) + fdt_len
+self.assertEqual(ucode_data, ucode_content[:len(ucode_data)])
 
 # Check that the microcode pointer was inserted. It should match the
 # expected position and size
-- 
2.18.0.203.gfac676dfb9-goog

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


[U-Boot] [PATCH v2 05/29] binman: Tidy up execution of tests

2018-07-06 Thread Simon Glass
Move all the test execution into the same mechanism so that we can request
a particular test (from any suite) by passing it as an argument to
'binman -t'.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/binman/binman.py | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/tools/binman/binman.py b/tools/binman/binman.py
index 944fd5d7ba..74862b1146 100755
--- a/tools/binman/binman.py
+++ b/tools/binman/binman.py
@@ -54,14 +54,12 @@ def RunTests(debug, args):
 
 # Run the entry tests first ,since these need to be the first to import the
 # 'entry' module.
-suite = unittest.TestLoader().loadTestsFromTestCase(entry_test.TestEntry)
-suite.run(result)
 test_name = args and args[0] or None
-for module in (ftest.TestFunctional, fdt_test.TestFdt, elf_test.TestElf,
-   image_test.TestImage):
+for module in (entry_test.TestEntry, ftest.TestFunctional, 
fdt_test.TestFdt,
+   elf_test.TestElf, image_test.TestImage):
 if test_name:
 try:
-suite = unittest.TestLoader().loadTestsFromName(args[0], 
module)
+suite = unittest.TestLoader().loadTestsFromName(test_name, 
module)
 except AttributeError:
 continue
 else:
-- 
2.18.0.203.gfac676dfb9-goog

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


[U-Boot] [PATCH v2 10/29] binman: Move coverage logic into a new test_util file

2018-07-06 Thread Simon Glass
At present only binman has the logic for determining Python test coverage
but this is useful for other tools also. Move it out into a separate file
so it can be used by other tools.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Allow specifying modules which must be tested
- Test that this works whether coverage shows a .py extension or not

 tools/binman/binman.py| 29 +++---
 tools/patman/test_util.py | 64 +++
 2 files changed, 68 insertions(+), 25 deletions(-)
 create mode 100644 tools/patman/test_util.py

diff --git a/tools/binman/binman.py b/tools/binman/binman.py
index 74862b1146..52e02ed91b 100755
--- a/tools/binman/binman.py
+++ b/tools/binman/binman.py
@@ -26,6 +26,7 @@ sys.path.insert(0, 'scripts/dtc/pylibfdt')
 import cmdline
 import command
 import control
+import test_util
 
 def RunTests(debug, args):
 """Run the functional tests and any embedded doctests
@@ -78,34 +79,12 @@ def RunTests(debug, args):
 
 def RunTestCoverage():
 """Run the tests and check that we get 100% coverage"""
-# This uses the build output from sandbox_spl to get _libfdt.so
-cmd = ('PYTHONPATH=$PYTHONPATH:%s/sandbox_spl/tools python-coverage run '
-'--include "tools/binman/*.py" --omit "*test*,*binman.py" '
-'tools/binman/binman.py -t' % options.build_dir)
-os.system(cmd)
-stdout = command.Output('python-coverage', 'report')
-lines = stdout.splitlines()
-
-test_set= set([os.path.basename(line.split()[0])
- for line in lines if '/etype/' in line])
 glob_list = glob.glob(os.path.join(our_path, 'etype/*.py'))
 all_set = set([os.path.splitext(os.path.basename(item))[0]
for item in glob_list if '_testing' not in item])
-missing_list = all_set
-missing_list.difference_update(test_set)
-coverage = lines[-1].split(' ')[-1]
-ok = True
-if missing_list:
-print 'Missing tests for %s' % (', '.join(missing_list))
-print stdout
-ok = False
-if coverage != '100%':
-print stdout
-print "Type 'coverage html' to get a report in htmlcov/index.html"
-print 'Coverage error: %s, but should be 100%%' % coverage
-ok = False
-if not ok:
-  raise ValueError('Test coverage failure')
+test_util.RunTestCoverage('tools/binman/binman.py', None,
+['*test*', '*binman.py', 'tools/patman/*', 'tools/dtoc/*'],
+options.build_dir, all_set)
 
 def RunBinman(options, args):
 """Main entry point to binman once arguments are parsed
diff --git a/tools/patman/test_util.py b/tools/patman/test_util.py
new file mode 100644
index 00..1a33c997c4
--- /dev/null
+++ b/tools/patman/test_util.py
@@ -0,0 +1,64 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (c) 2016 Google, Inc
+#
+
+import glob
+import os
+import sys
+
+import command
+
+def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, 
required=None):
+"""Run tests and check that we get 100% coverage
+
+Args:
+prog: Program to run (with be passed a '-t' argument to run tests
+filter_fname: Normally all *.py files in the program's directory will
+be included. If this is not None, then it is used to filter the
+list so that only filenames that don't contain filter_fname are
+included.
+exclude_list: List of file patterns to exclude from the coverage
+calculation
+build_dir: Build directory, used to locate libfdt.py
+required: List of modules which must be in the coverage report
+
+Raises:
+ValueError if the code coverage is not 100%
+"""
+# This uses the build output from sandbox_spl to get _libfdt.so
+path = os.path.dirname(prog)
+if filter_fname:
+glob_list = glob.glob(os.path.join(path, '*.py'))
+glob_list = [fname for fname in glob_list if filter_fname in fname]
+else:
+glob_list = []
+glob_list += exclude_list
+glob_list += ['*libfdt.py', '*site-packages*']
+cmd = ('PYTHONPATH=$PYTHONPATH:%s/sandbox_spl/tools python-coverage run '
+   '--omit "%s" %s -t' % (build_dir, ','.join(glob_list), prog))
+os.system(cmd)
+stdout = command.Output('python-coverage', 'report')
+lines = stdout.splitlines()
+if required:
+# Convert '/path/to/name.py' just the module name 'name'
+test_set = set([os.path.splitext(os.path.basename(line.split()[0]))[0]
+for line in lines if '/etype/' in line])
+missing_list = required
+missing_list.difference_update(test_set)
+if missing_list:
+print 'Missing tests for %s' % (', '.join(missing_list))
+print stdout
+ok = False
+
+coverage = lines[-1].split(' ')[-1]
+ok = True
+print coverage
+if coverage != '100%':
+print stdout
+print ("Type 'python-coverage html' to get a report in 

[U-Boot] [PATCH v2 06/29] binman: Tidy up setting of entry contents

2018-07-06 Thread Simon Glass
At present the contents of an entry are set in subclasses simply by
assigning to the data and content_size properties. Add some methods to do
this, so that we have more control. In particular, add a method to set the
contents without changing its size, so we can validate that case.

Add a test case for trying to change the size when this is not allowed.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/binman/entry.py   | 28 +
 tools/binman/etype/_testing.py  |  8 ++
 tools/binman/etype/blob.py  |  3 +--
 tools/binman/etype/u_boot_spl_bss_pad.py|  3 +--
 tools/binman/etype/u_boot_with_ucode_ptr.py |  4 +--
 tools/binman/ftest.py   |  8 ++
 tools/binman/test/59_change_size.dts| 14 +++
 7 files changed, 62 insertions(+), 6 deletions(-)
 create mode 100644 tools/binman/test/59_change_size.dts

diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index e4d688c91f..303c992e37 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -55,6 +55,7 @@ class Entry(object):
 self.name = node and (name_prefix + node.name) or 'none'
 self.pos = None
 self.size = None
+self.data = ''
 self.contents_size = 0
 self.align = None
 self.align_size = None
@@ -138,6 +139,33 @@ class Entry(object):
 if prefix:
 self.name = prefix + self.name
 
+def SetContents(self, data):
+"""Set the contents of an entry
+
+This sets both the data and content_size properties
+
+Args:
+data: Data to set to the contents (string)
+"""
+self.data = data
+self.contents_size = len(self.data)
+
+def ProcessContentsUpdate(self, data):
+"""Update the contens of an entry, after the size is fixed
+
+This checks that the new data is the same size as the old.
+
+Args:
+data: Data to set to the contents (string)
+
+Raises:
+ValueError if the new data size is not the same as the old
+"""
+if len(data) != self.contents_size:
+self.Raise('Cannot update entry size from %d to %d' %
+   (len(data), self.contents_size))
+self.SetContents(data)
+
 def ObtainContents(self):
 """Figure out the contents of an entry.
 
diff --git a/tools/binman/etype/_testing.py b/tools/binman/etype/_testing.py
index c075c3ff0d..04bdc6c532 100644
--- a/tools/binman/etype/_testing.py
+++ b/tools/binman/etype/_testing.py
@@ -22,6 +22,8 @@ class Entry__testing(Entry):
  'return-invalid-entry')
 self.return_unknown_contents = fdt_util.GetBool(self._node,
  'return-unknown-contents')
+self.bad_update_contents = fdt_util.GetBool(self._node,
+'bad-update-contents')
 
 def ObtainContents(self):
 if self.return_unknown_contents:
@@ -34,3 +36,9 @@ class Entry__testing(Entry):
 if self.return_invalid_entry :
 return {'invalid-entry': [1, 2]}
 return {}
+
+def ProcessContents(self):
+if self.bad_update_contents:
+# Request to update the conents with something larger, to cause a
+# failure.
+self.ProcessContentsUpdate('aa')
diff --git a/tools/binman/etype/blob.py b/tools/binman/etype/blob.py
index 16b1e5f64d..28e6651a93 100644
--- a/tools/binman/etype/blob.py
+++ b/tools/binman/etype/blob.py
@@ -28,8 +28,7 @@ class Entry_blob(Entry):
 # new Entry method which can read in chunks. Then we could copy
 # the data in chunks and avoid reading it all at once. For now
 # this seems like an unnecessary complication.
-self.data = fd.read()
-self.contents_size = len(self.data)
+self.SetContents(fd.read())
 return True
 
 def GetDefaultFilename(self):
diff --git a/tools/binman/etype/u_boot_spl_bss_pad.py 
b/tools/binman/etype/u_boot_spl_bss_pad.py
index 6c397957e3..65f631d3c5 100644
--- a/tools/binman/etype/u_boot_spl_bss_pad.py
+++ b/tools/binman/etype/u_boot_spl_bss_pad.py
@@ -22,6 +22,5 @@ class Entry_u_boot_spl_bss_pad(Entry_blob):
 bss_size = elf.GetSymbolAddress(fname, '__bss_size')
 if not bss_size:
 self.Raise('Expected __bss_size symbol in spl/u-boot-spl')
-self.data = chr(0) * bss_size
-self.contents_size = bss_size
+self.SetContents(chr(0) * bss_size)
 return True
diff --git a/tools/binman/etype/u_boot_with_ucode_ptr.py 
b/tools/binman/etype/u_boot_with_ucode_ptr.py
index 41c2ded2fe..86945f3318 100644
--- a/tools/binman/etype/u_boot_with_ucode_ptr.py
+++ b/tools/binman/etype/u_boot_with_ucode_ptr.py
@@ -81,5 +81,5 @@ class Entry_u_boot_with_ucode_ptr(Entry_blob):
 # Write the microcode 

[U-Boot] [PATCH v2 02/29] binman: Make the operation of Entry__testing explicit

2018-07-06 Thread Simon Glass
This fake entry is used for testing. At present it only has one behaviour
which is to return an invalid set of entry positions, to cause an error.

The fake entry will need to be used for other things too. Allow the test
.dts file to specify the behaviour of the fake entry, so we can control
its behaviour easily.

While we are here, drop the ReadContents() method, since this only applies
to subclasses of Entry_blob, which Entry__testing is not.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/binman/etype/_testing.py| 14 ++
 tools/binman/test/41_unknown_pos_size.dts |  1 +
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/tools/binman/etype/_testing.py b/tools/binman/etype/_testing.py
index c376dd5c9c..0b1eaefc3c 100644
--- a/tools/binman/etype/_testing.py
+++ b/tools/binman/etype/_testing.py
@@ -10,16 +10,22 @@ import fdt_util
 import tools
 
 class Entry__testing(Entry):
+"""A fake entry used for testing
+
+Properties:
+return_invalid_entry: Return an invalid entry from GetPositions()
+"""
 def __init__(self, section, etype, node):
 Entry.__init__(self, section, etype, node)
+self.return_invalid_entry = fdt_util.GetBool(self._node,
+ 'return-invalid-entry')
 
 def ObtainContents(self):
 self.data = 'a'
 self.contents_size = len(self.data)
 return True
 
-def ReadContents(self):
-return True
-
 def GetPositions(self):
-return {'invalid-entry': [1, 2]}
+if self.return_invalid_entry :
+return {'invalid-entry': [1, 2]}
+return {}
diff --git a/tools/binman/test/41_unknown_pos_size.dts 
b/tools/binman/test/41_unknown_pos_size.dts
index a8e7d8aa22..94fe821c47 100644
--- a/tools/binman/test/41_unknown_pos_size.dts
+++ b/tools/binman/test/41_unknown_pos_size.dts
@@ -6,6 +6,7 @@
 
binman {
_testing {
+   return-invalid-entry;
};
 };
 };
-- 
2.18.0.203.gfac676dfb9-goog

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


[U-Boot] [PATCH v2 01/29] binman: Switch to 'python-coverage'

2018-07-06 Thread Simon Glass
From: Tom Rini 

The most portable way to get access to coverage is to invoke it as
'python-coverage'.

Cc: Simon Glass 
Signed-off-by: Tom Rini 
Signed-off-by: Simon Glass 
---

Changes in v2:
- Correct logic for detecting python modules (changed with python-coverage)
- Show the full output when some modules are not tested
- Update text in test/run script also

 test/run   | 3 +--
 tools/binman/README| 3 +--
 tools/binman/binman.py | 9 +
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/test/run b/test/run
index eb1563d13e..0b9188eaa8 100755
--- a/test/run
+++ b/test/run
@@ -26,8 +26,7 @@ PYTHONPATH=${DTC_DIR}/pylibfdt DTC=${DTC_DIR}/dtc run_test 
./tools/dtoc/dtoc -t
 
 # This needs you to set up Python test coverage tools.
 # To enable Python test coverage on Debian-type distributions (e.g. Ubuntu):
-#   $ sudo apt-get install python-pip python-pytest
-#   $ sudo pip install coverage
+#   $ sudo apt-get install python-pytest python-coverage
 PYTHONPATH=${DTC_DIR}/pylibfdt DTC=${DTC_DIR}/dtc run_test \
./tools/binman/binman -T
 
diff --git a/tools/binman/README b/tools/binman/README
index 22f21bc5b4..f74e39242f 100644
--- a/tools/binman/README
+++ b/tools/binman/README
@@ -583,8 +583,7 @@ implementations target 100% test coverage. Run 'binman -T' 
to check this.
 
 To enable Python test coverage on Debian-type distributions (e.g. Ubuntu):
 
-   $ sudo apt-get install python-pip python-pytest
-   $ sudo pip install coverage
+   $ sudo apt-get install python-coverage python-pytest
 
 
 Advanced Features / Technical docs
diff --git a/tools/binman/binman.py b/tools/binman/binman.py
index 31b045337d..944fd5d7ba 100755
--- a/tools/binman/binman.py
+++ b/tools/binman/binman.py
@@ -81,24 +81,25 @@ def RunTests(debug, args):
 def RunTestCoverage():
 """Run the tests and check that we get 100% coverage"""
 # This uses the build output from sandbox_spl to get _libfdt.so
-cmd = ('PYTHONPATH=$PYTHONPATH:%s/sandbox_spl/tools coverage run '
+cmd = ('PYTHONPATH=$PYTHONPATH:%s/sandbox_spl/tools python-coverage run '
 '--include "tools/binman/*.py" --omit "*test*,*binman.py" '
 'tools/binman/binman.py -t' % options.build_dir)
 os.system(cmd)
-stdout = command.Output('coverage', 'report')
+stdout = command.Output('python-coverage', 'report')
 lines = stdout.splitlines()
 
 test_set= set([os.path.basename(line.split()[0])
  for line in lines if '/etype/' in line])
 glob_list = glob.glob(os.path.join(our_path, 'etype/*.py'))
-all_set = set([os.path.basename(item) for item in glob_list])
+all_set = set([os.path.splitext(os.path.basename(item))[0]
+   for item in glob_list if '_testing' not in item])
 missing_list = all_set
 missing_list.difference_update(test_set)
-missing_list.remove('_testing.py')
 coverage = lines[-1].split(' ')[-1]
 ok = True
 if missing_list:
 print 'Missing tests for %s' % (', '.join(missing_list))
+print stdout
 ok = False
 if coverage != '100%':
 print stdout
-- 
2.18.0.203.gfac676dfb9-goog

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


[U-Boot] [PATCH v2 00/29] binman: Add more tests and support for updating the device tree

2018-07-06 Thread Simon Glass
At present we have 100% code coverage for binman. This series adds the
same for dtoc (which converts device-tree data to C) and the Fdt class
(which provides convenient Python access to the device tree).

Binman already support writing a map file showing the location of each
entry in the images in produces. But, with the exception of automatic
linker symbols in SPL, this information is not available to U-Boot
itself. The series adds support for this, by writing the updated entry
position and size back to the device tree for inclusion in the image.
With this, U-Boot can easily read this information and locate image
entries at runtime.

Note: At present the access to device-tree values is more clumbsy than
it could be. Once pylibfdt support is finished, this needs another look.

Changes in v2:
- Correct logic for detecting python modules (changed with python-coverage)
- Show the full output when some modules are not tested
- Update text in test/run script also
- Allow specifying modules which must be tested
- Test that this works whether coverage shows a .py extension or not
- Expand tests to increase code coverage to 100%
- Update to cope with GetPhandle() being removed
- Update coverage to only include dtb_platdata.py
- Add new patch to enable cover-coverage tests for dtoc and fdt
- Update tests to main 100% code coverage

Simon Glass (28):
  binman: Make the operation of Entry__testing explicit
  binman: Tidy up variables in _RunMicrocodeTest()
  binman: Correct operation of ObtainContents()
  binman: Tidy up execution of tests
  binman: Tidy up setting of entry contents
  libfdt: Bring in proposed pylibfdt changes
  libfdt: Fix the Python pack() function
  libfdt: Add get_property() and del_node()
  binman: Move coverage logic into a new test_util file
  dtoc: Add some tests for the fdt module
  dtoc: Update tests to write failures to /tmp
  dtoc: Make use of the new pylibfdt methods
  dtoc: Drop use of a local dtb buffer
  dtoc: Update fdt tests to increase code coverage
  dtoc: Keep track of property offsets
  dtoc: Fix Fdt.GetNode() to handle a missing node
  dtoc: Fix properties with a single zero-arg phandle
  dtoc: Fix some minor errors
  dtoc: Add a test for code coverage
  binman: Move capture_sys_output() to test_util
  dtoc: Increase code coverage to 100%
  test: Enable cover-coverage tests for dtoc and fdt
  dtoc: Avoid unwanted output during tests
  dtoc: Add functions to add integer properties
  binman: Complete documentation of stages
  binman: Add a ProcessFdt() method
  binman: Add a SetCalculatedProperties() method
  binman: Support updating the device tree with calc'd info

Tom Rini (1):
  binman: Switch to 'python-coverage'

 scripts/dtc/libfdt/libfdt.h   |   3 +
 scripts/dtc/pylibfdt/libfdt.i_shipped | 725 --
 test/run  |   7 +-
 tools/binman/README   |  45 +-
 tools/binman/binman.py|  40 +-
 tools/binman/bsection.py  |  27 +
 tools/binman/cmdline.py   |   2 +
 tools/binman/control.py   |  58 +-
 tools/binman/elf_test.py  |  22 +-
 tools/binman/entry.py |  42 +
 tools/binman/etype/_testing.py|  37 +-
 tools/binman/etype/blob.py|   3 +-
 tools/binman/etype/section.py |  13 +-
 tools/binman/etype/u_boot_dtb_with_ucode.py   |  47 +-
 tools/binman/etype/u_boot_spl_bss_pad.py  |   4 +-
 tools/binman/etype/u_boot_ucode.py|   9 +-
 tools/binman/etype/u_boot_with_ucode_ptr.py   |  11 +-
 tools/binman/ftest.py | 159 +++-
 tools/binman/image.py |  17 +
 tools/binman/image_test.py|   2 +-
 tools/binman/test/41_unknown_pos_size.dts |   1 +
 tools/binman/test/57_unknown_contents.dts |  14 +
 .../test/58_x86_ucode_spl_needs_retry.dts |  36 +
 tools/binman/test/59_change_size.dts  |  14 +
 tools/binman/test/60_fdt_update.dts   |  31 +
 tools/binman/test/61_fdt_update_bad.dts   |  32 +
 tools/dtoc/dtb_platdata.py|  15 +-
 tools/dtoc/dtoc.py|  35 +-
 tools/dtoc/dtoc_test_add_prop.dts |  24 +
 tools/dtoc/dtoc_test_addr32_64.dts|   2 +-
 tools/dtoc/dtoc_test_addr64_32.dts|   2 +-
 tools/dtoc/dtoc_test_bad_reg.dts  |  17 +
 tools/dtoc/dtoc_test_bad_reg2.dts |  17 +
 tools/dtoc/dtoc_test_phandle.dts  |   6 +
 tools/dtoc/dtoc_test_phandle_bad.dts  |  16 +
 tools/dtoc/dtoc_test_phandle_bad2.dts |  22 +
 tools/dtoc/dtoc_test_phandle_reorder.dts  |  23 +
 tools/dtoc/dtoc_test_phandle_single.dts   |  23 +
 tools/dtoc/dtoc_test_simple.dts   |   1 +
 tools/dtoc/fdt.py | 115 ++-
 tools/dtoc/fdt_util.py|  29 +-
 

[U-Boot] [PATCH V3 1/2] spl: Fix redundant image of uboot

2018-07-06 Thread Michael Trimarchi
We need to address the redundat image case and undestand if the
image is corrupted or not. In error case we need to try the fallback copy.
The function used before was always return 0 without any evaluation of the
error. We try to make it work properly

Signed-off-by: Michael Trimarchi 
---
Changes V2->V3:
Fix patch mistake due the a wrong edit of it
Changes V1->V2:
Address the comments on using the err variable
---
 common/spl/spl_nand.c | 34 +-
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
index 9a52500..f00246d 100644
--- a/common/spl/spl_nand.c
+++ b/common/spl/spl_nand.c
@@ -44,9 +44,7 @@ static int spl_nand_load_element(struct spl_image_info 
*spl_image,
 {
int err;
 
-   err = nand_spl_load_image(offset, sizeof(*header), (void *)header);
-   if (err)
-   return err;
+   nand_spl_load_image(offset, sizeof(*header), (void *)header);
 
if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
image_get_magic(header) == FDT_MAGIC) {
@@ -59,13 +57,31 @@ static int spl_nand_load_element(struct spl_image_info 
*spl_image,
load.bl_len = 1;
load.read = spl_nand_fit_read;
return spl_load_simple_fit(spl_image, , offset, header);
-   } else {
-   err = spl_parse_image_header(spl_image, header);
-   if (err)
-   return err;
-   return nand_spl_load_image(offset, spl_image->size,
-  (void *)(ulong)spl_image->load_addr);
}
+   err = spl_parse_image_header(spl_image, header);
+   if (err)
+   return err;
+
+   nand_spl_load_image(offset, spl_image->size,
+  (void *)(ulong)spl_image->load_addr);
+
+   /*
+* Verify the crc of the header
+*/
+   if (!image_check_hcrc((const image_header_t *)spl_image->load_addr)) {
+   debug("Header checksum failed\n");
+   return -EINVAL;
+   }
+
+   /*
+* Verify the crc of the data
+*/
+   if (!image_check_dcrc((const image_header_t *)spl_image->load_addr)) {
+   debug("Image checksum failed\n");
+   return -EINVAL;
+   }
+
+   return 0;
 }
 
 static int spl_nand_load_image(struct spl_image_info *spl_image,
-- 
2.7.4

-- 
| Michael Nazzareno Trimarchi Amarula Solutions BV |
| COO  -  Founder  Cruquiuskade 47 |
| +31(0)851119172 Amsterdam 1018 AM NL |
|  [`as] http://www.amarulasolutions.com   |
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [RFC PATCH 17/20] cmd: mtd: add 'mtd' command

2018-07-06 Thread Stefan Roese

Hi Miquel,

On 06.07.2018 15:42, Miquel Raynal wrote:

Hi Stefan,

Stefan Roese  wrote on Fri, 6 Jul 2018 15:21:20 +0200:


Hi Miquel,

On 06.07.2018 14:26, Miquel Raynal wrote:

Jagan Teki  wrote on Fri, 6 Jul 2018 17:08:57
+0530:

On Wed, Jun 6, 2018 at 9:00 PM, Miquel Raynal  wrote:
There should not be a 'nand' command, a 'sf' command and certainly not
another 'spi-nand'. Write a 'mtd' command instead to manage all MTD
devices at once. This should be the preferred way to access any MTD
device.


So are you planning to integrate sf, nand command in future, adding
them dm conversion of many stuff. I would like to reommend to go with
spinand command. I have been through this and finally added spinor
command, which I will going to in soon. once all are converted to dm,
it would be easy and meaningfull to have common command.
I'm not sure we are in sync about this. The whole point of the previous

discussion was to decide whether or not we should make full use of
the MTD stack or not. I think it was pretty clear on the fact that
people prefer to be close to Linux's architecture on this regard.

MTD being an abstraction of the type of memory, I don't get the

point in creating yet another command each time a new type of
device is supported. The fact that all the drivers of these devices
register to the MTD layer makes it trivial to interact with. So why
should we wait?


Yes, please don't add new commands for each subsystem / device-type.
I like the idea of adding one new command-set (your mtd command) and
extending this one to all other device-types over the time.

BTW: I'm testing your SPI NAND patches right now (still struggling
with some Gigadevice SPI NAND) and found that the "mtd" command is
not really in-line with the usual U-Boot commands. Here some
comments:

- Use hex values per default (addresses, sizes and soffset)
- "mtd read" just prints the read values. It makes more sense
to read into memory instead (similar to the "mtd write")


I absolutely agree with this! I sent this series to show people what I
planned to contribute but this mtd command is still a WIP and there are
plenty of things to address.



I have some patches to address these issues in the queue (still
need some massaging), which you can fold into your patchset, once
we agree on this.


I am currently working on a new iteration of this series in which the
mtd.c file will change quite a bit. I plan to send a new version early
next week. I suppose this one will be much more stable to base your
fixes/enhancements on.


That sound really great. Looking forward to seeing the new version
next week. :)

Thanks,
Stefan
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [RFC PATCH 17/20] cmd: mtd: add 'mtd' command

2018-07-06 Thread Miquel Raynal
Hi Stefan,

Stefan Roese  wrote on Fri, 6 Jul 2018 15:21:20 +0200:

> Hi Miquel,
> 
> On 06.07.2018 14:26, Miquel Raynal wrote:
> > Jagan Teki  wrote on Fri, 6 Jul 2018 17:08:57
> > +0530:  
> > >> On Wed, Jun 6, 2018 at 9:00 PM, Miquel Raynal 
> > >>  wrote:
> >>> There should not be a 'nand' command, a 'sf' command and certainly not
> >>> another 'spi-nand'. Write a 'mtd' command instead to manage all MTD
> >>> devices at once. This should be the preferred way to access any MTD
> >>> device.  
> >>
> >> So are you planning to integrate sf, nand command in future, adding
> >> them dm conversion of many stuff. I would like to reommend to go with
> >> spinand command. I have been through this and finally added spinor
> >> command, which I will going to in soon. once all are converted to dm,
> >> it would be easy and meaningfull to have common command.
> > > I'm not sure we are in sync about this. The whole point of the previous  
> > discussion was to decide whether or not we should make full use of
> > the MTD stack or not. I think it was pretty clear on the fact that
> > people prefer to be close to Linux's architecture on this regard.  
> > > MTD being an abstraction of the type of memory, I don't get the  
> > point in creating yet another command each time a new type of
> > device is supported. The fact that all the drivers of these devices
> > register to the MTD layer makes it trivial to interact with. So why
> > should we wait?  
> 
> Yes, please don't add new commands for each subsystem / device-type.
> I like the idea of adding one new command-set (your mtd command) and
> extending this one to all other device-types over the time.
> 
> BTW: I'm testing your SPI NAND patches right now (still struggling
> with some Gigadevice SPI NAND) and found that the "mtd" command is
> not really in-line with the usual U-Boot commands. Here some
> comments:
> 
> - Use hex values per default (addresses, sizes and soffset)
> - "mtd read" just prints the read values. It makes more sense
>to read into memory instead (similar to the "mtd write")

I absolutely agree with this! I sent this series to show people what I
planned to contribute but this mtd command is still a WIP and there are
plenty of things to address.

> 
> I have some patches to address these issues in the queue (still
> need some massaging), which you can fold into your patchset, once
> we agree on this.

I am currently working on a new iteration of this series in which the
mtd.c file will change quite a bit. I plan to send a new version early
next week. I suppose this one will be much more stable to base your
fixes/enhancements on.

Thanks,
Miquèl
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 12/12] board/BuR/brppt1: add makerule for generating production files

2018-07-06 Thread Hannes Schmelzer
Signed-off-by: Hannes Schmelzer 
---

 board/BuR/brppt1/config.mk | 36 
 1 file changed, 36 insertions(+)
 create mode 100644 board/BuR/brppt1/config.mk

diff --git a/board/BuR/brppt1/config.mk b/board/BuR/brppt1/config.mk
new file mode 100644
index 000..b11b544
--- /dev/null
+++ b/board/BuR/brppt1/config.mk
@@ -0,0 +1,36 @@
+#
+# Copyright (C) 2018 Hannes Schmelzer  -
+# B Industrial Automation GmbH - http://www.br-automation.com
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+hw-platform-y :=$(shell echo $(CONFIG_DEFAULT_DEVICE_TREE) | sed -e 
's/am335x-//')
+
+payload_off :=$(shell printf "%d" $(CONFIG_SYS_SPI_U_BOOT_OFFS))
+
+quiet_cmd_prodbin = PRODBIN $@ $(payload_off)
+cmd_prodbin =  \
+   dd if=/dev/zero ibs=1M count=2 2>/dev/null | tr "\000" "\377" >$@ && \
+   dd conv=notrunc bs=1 if=MLO.byteswap of=$@ seek=0 2>/dev/null && \
+   dd bs=1 if=u-boot-dtb.img of=$@ seek=$(payload_off) 2>/dev/null
+
+quiet_cmd_prodzip = SAPZIP  $@
+cmd_prodzip =  \
+   test -d misc && rm -r misc; \
+   mkdir misc &&   \
+   cp MLO.byteswap misc/ &&\
+   cp spl/u-boot-spl.bin misc/ &&  \
+   cp u-boot-dtb.img misc/ &&  \
+   zip -9 -r $@ misc/* >/dev/null $<
+
+ifeq ($(hw-platform-y),brppt1-spi)
+ALL-y += $(hw-platform-y)_prog.bin
+ALL-y += $(hw-platform-y)_prod.zip
+endif
+
+$(hw-platform-y)_prog.bin: u-boot-dtb.img spl/u-boot-spl.bin
+   $(call if_changed,prodbin)
+
+$(hw-platform-y)_prod.zip: $(hw-platform-y)_prog.bin
+   $(call if_changed,prodzip)
-- 
2.7.4

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


[U-Boot] [PATCH 11/12] board/BuR/brppt1: convert brppt1 boards to driver model

2018-07-06 Thread Hannes Schmelzer
- add a devicetree for each variant (mmc, spi, nand)
- drop unneeded code from board and bur/common
- drop unneeded stuff from config header files
- minor adaptions to be compliant with driver model (requesting gpio,..)
- harmonize the commandset over all brppt1 targets

Signed-off-by: Hannes Schmelzer 
---

 arch/arm/dts/am335x-brppt1-mmc.dts  | 345 +
 arch/arm/dts/am335x-brppt1-nand.dts | 363 +++
 arch/arm/dts/am335x-brppt1-spi.dts  | 366 
 board/BuR/brppt1/board.c|  24 ++-
 board/BuR/common/common.c   | 101 +-
 configs/brppt1_mmc_defconfig|  45 -
 configs/brppt1_nand_defconfig   |  45 -
 configs/brppt1_spi_defconfig|  50 -
 include/configs/brppt1.h|  37 ++--
 include/configs/bur_am335x_common.h |  26 +--
 10 files changed, 1248 insertions(+), 154 deletions(-)
 create mode 100644 arch/arm/dts/am335x-brppt1-mmc.dts
 create mode 100644 arch/arm/dts/am335x-brppt1-nand.dts
 create mode 100644 arch/arm/dts/am335x-brppt1-spi.dts

diff --git a/arch/arm/dts/am335x-brppt1-mmc.dts 
b/arch/arm/dts/am335x-brppt1-mmc.dts
new file mode 100644
index 000..9be34d9
--- /dev/null
+++ b/arch/arm/dts/am335x-brppt1-mmc.dts
@@ -0,0 +1,345 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 B Industrial Automation GmbH
+ * http://www.br-automation.com
+ *
+ */
+/dts-v1/;
+
+#include "am33xx.dtsi"
+
+/ {
+   model = "BRPPT1 (MMC) Panel";
+   compatible = "ti,am33xx";
+
+   fset: factory-settings {
+   bl-version  = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456890";
+   version = <0x0100>;
+   order-no= "6PPT30 (MMC)";
+   hw-revision = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456890";
+   serial-no   = "0";
+   device-id   = <0x0>;
+   parent-id   = <0x0>;
+   hw-variant  = <0x1>;
+   };
+
+   aliases {
+   ds1bkl0 = 
+   ds1bkl1 = _bl;
+   ds1timing = 
+   ds1ctrl = 
+   gpmc = 
+   mmc = 
+   fset = 
+   };
+
+   chosen {
+   bootargs = "console=ttyO0,115200 earlyprintk";
+   stdout-path = 
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0x8000 0x1000>; /* 256 MB */
+   };
+
+   panel {
+   status = "disabled";
+
+   compatible = "ti,tilcdc,panel";
+   enable-gpios = < 6 GPIO_ACTIVE_LOW>;
+
+   backlight = <>;
+   bkl-pwm = <>;
+   bkl-tps = <_bl>;
+
+   panel-info {
+   ac-bias = <255>;
+   ac-bias-intrpt  = <0>;
+   dma-burst-sz= <16>;
+   bpp = <32>;
+   fdd = <0x80>;
+   sync-edge   = <0>;
+   sync-ctrl   = <1>;
+   raster-order= <0>;
+   fifo-th = <0>;
+   };
+
+   display-timings {
+   native-mode = <>;
+   timing0: lcd {
+   clock-frequency = <3200>;
+   hactive = <800>;
+   vactive = <480>;
+   hfront-porch= <2>;
+   hback-porch = <192>;
+   hsync-len   = <1>;
+   vfront-porch= <20>;
+   vback-porch = <2>;
+   vsync-len   = <1>;
+   hsync-active= <1>;
+   vsync-active= <1>;
+   pupdelay= <10>;
+   pondelay= <10>;
+   };
+   };
+   };
+
+   vmmcsd_fixed: fixedregulator@0 {
+   compatible = "regulator-fixed";
+   regulator-name = "vmmcsd_fixed";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   };
+
+   pwm0: omap-pwm@timer5 {
+   compatible = "ti,omap-dmtimer-pwm";
+   ti,timers = <>;
+   #pwm-cells = <3>;
+   };
+
+   pwm1: omap-pwm@timer6 {
+   compatible = "ti,omap-dmtimer-pwm";
+   ti,timers = <>;
+   #pwm-cells = <3>;
+   };
+
+   beeper: pwm-beep {
+   compatible = "pwm-beeper";
+   pwms = < 0 0 0>;
+   };
+
+   pwmbacklight: pwm-bkl {
+   compatible = "pwm-backlight";
+   pwms = < 0 500 0>;
+
+   default-brightness-level = <255>;
+ 

[U-Boot] [PATCH 04/12] board/BuR/brppt1: drop LCD-support

2018-07-06 Thread Hannes Schmelzer
On this linux target long time ago the OS is using DRM driver for
handling video output, the pre initialization of u-boot and the display
summary screen is obsolete. With this patch we drop the LCD-support from
thisd board.

Signed-off-by: Hannes Schmelzer 
---

 board/BuR/brppt1/board.c  | 4 
 configs/brppt1_mmc_defconfig  | 3 ---
 configs/brppt1_nand_defconfig | 3 ---
 configs/brppt1_spi_defconfig  | 3 ---
 include/configs/brppt1.h  | 5 -
 5 files changed, 18 deletions(-)

diff --git a/board/BuR/brppt1/board.c b/board/BuR/brppt1/board.c
index 41db449..ff2a3a2 100644
--- a/board/BuR/brppt1/board.c
+++ b/board/BuR/brppt1/board.c
@@ -26,7 +26,6 @@
 #include 
 #include 
 #include "../common/bur_common.h"
-#include 
 #include 
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -160,9 +159,6 @@ int board_init(void)
 int board_late_init(void)
 {
if (0 == gpio_get_value(REPSWITCH)) {
-   lcd_position_cursor(1, 8);
-   lcd_puts(
-   "switching to network-console ...   ");
env_set("bootcmd", "run netconsole");
}
return 0;
diff --git a/configs/brppt1_mmc_defconfig b/configs/brppt1_mmc_defconfig
index a9d0f71..b8db509 100644
--- a/configs/brppt1_mmc_defconfig
+++ b/configs/brppt1_mmc_defconfig
@@ -11,7 +11,6 @@ CONFIG_SPL=y
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_SYS_EXTRA_OPTIONS="SERIAL1,CONS_INDEX=1,EMMC_BOOT"
 CONFIG_BOOTDELAY=-2
-# CONFIG_CONSOLE_MUX is not set
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
@@ -57,7 +56,5 @@ CONFIG_USB=y
 CONFIG_USB_MUSB_HOST=y
 CONFIG_USB_MUSB_DSPS=y
 CONFIG_USB_STORAGE=y
-CONFIG_SYS_WHITE_ON_BLACK=y
-CONFIG_LCD=y
 CONFIG_FAT_WRITE=y
 CONFIG_OF_LIBFDT=y
diff --git a/configs/brppt1_nand_defconfig b/configs/brppt1_nand_defconfig
index ac50abc..907ce71 100644
--- a/configs/brppt1_nand_defconfig
+++ b/configs/brppt1_nand_defconfig
@@ -10,7 +10,6 @@ CONFIG_SPL=y
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_SYS_EXTRA_OPTIONS="SERIAL1,CONS_INDEX=1"
 CONFIG_BOOTDELAY=-2
-# CONFIG_CONSOLE_MUX is not set
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
@@ -59,7 +58,5 @@ CONFIG_USB=y
 CONFIG_USB_MUSB_HOST=y
 CONFIG_USB_MUSB_DSPS=y
 CONFIG_USB_STORAGE=y
-CONFIG_SYS_WHITE_ON_BLACK=y
-CONFIG_LCD=y
 CONFIG_FAT_WRITE=y
 CONFIG_OF_LIBFDT=y
diff --git a/configs/brppt1_spi_defconfig b/configs/brppt1_spi_defconfig
index 140a7dd..90054aa 100644
--- a/configs/brppt1_spi_defconfig
+++ b/configs/brppt1_spi_defconfig
@@ -14,7 +14,6 @@ CONFIG_OF_BOARD_SETUP=y
 CONFIG_SYS_EXTRA_OPTIONS="SERIAL1,CONS_INDEX=1,SPI_BOOT,EMMC_BOOT"
 CONFIG_SPI_BOOT=y
 CONFIG_BOOTDELAY=-2
-# CONFIG_CONSOLE_MUX is not set
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
@@ -69,7 +68,5 @@ CONFIG_USB=y
 CONFIG_USB_MUSB_HOST=y
 CONFIG_USB_MUSB_DSPS=y
 CONFIG_USB_STORAGE=y
-CONFIG_SYS_WHITE_ON_BLACK=y
-CONFIG_LCD=y
 CONFIG_FAT_WRITE=y
 CONFIG_OF_LIBFDT=y
diff --git a/include/configs/brppt1.h b/include/configs/brppt1.h
index a6cf9ac..6a210b7 100644
--- a/include/configs/brppt1.h
+++ b/include/configs/brppt1.h
@@ -14,11 +14,6 @@
 #include 
 #include 
 /* - */
-#define CONFIG_AM335X_LCD
-#define CONFIG_LCD_ROTATION
-#define CONFIG_LCD_DT_SIMPLEFB
-#define LCD_BPPLCD_COLOR32
-
 /* memory */
 #define CONFIG_SYS_MALLOC_LEN  (5 * 1024 * 1024)
 
-- 
2.7.4

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


[U-Boot] [PATCH 06/12] board/BuR/common: fix PMIC mpu-pll setup

2018-07-06 Thread Hannes Schmelzer
If a board-code calls the  pmicsetup(u32 mpupll) with a mpupll value
!= 0 it wants to force some frequency with the value provided by mpupll.
Setting up 1 GHz is wrong here.

Nobody did take notice about that yet, since every board calls this
function with zero.

Signed-off-by: Hannes Schmelzer 
---

 board/BuR/common/common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/BuR/common/common.c b/board/BuR/common/common.c
index 1e14a90..38da36d 100644
--- a/board/BuR/common/common.c
+++ b/board/BuR/common/common.c
@@ -280,7 +280,7 @@ void pmicsetup(u32 mpupll)
printf("detected max. frequency: %d - ", dpll_mpu_opp100.m);
 
if (0 != mpupll) {
-   dpll_mpu_opp100.m = MPUPLL_M_1000;
+   dpll_mpu_opp100.m = mpupll;
printf("retuning MPU-PLL to: %d MHz.\n", dpll_mpu_opp100.m);
} else {
puts("ok.\n");
-- 
2.7.4

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


[U-Boot] [PATCH 05/12] board/BuR/common: remove interface Label from summary screen

2018-07-06 Thread Hannes Schmelzer
This interface names may vary over different products, to consider this
fact we replace the interface label "IF1" and "IF2" on the summary
screen with some more generic wording "MAC1" and "MAC2".

Signed-off-by: Hannes Schmelzer 
---

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

diff --git a/board/BuR/common/common.c b/board/BuR/common/common.c
index e1ac6c4..1e14a90 100644
--- a/board/BuR/common/common.c
+++ b/board/BuR/common/common.c
@@ -176,8 +176,8 @@ void br_summaryscreen(void)
 {
br_summaryscreen_printenv(" - B -", "br_orderno", 0, "-\n");
br_summaryscreen_printenv(" Serial/Rev :", "br_serial", 0, "\n");
-   br_summaryscreen_printenv(" MAC (IF1)  :", "br_mac1", "ethaddr", "\n");
-   br_summaryscreen_printenv(" MAC (IF2)  :", "br_mac2", 0, "\n");
+   br_summaryscreen_printenv(" MAC1   :", "br_mac1", "ethaddr", "\n");
+   br_summaryscreen_printenv(" MAC2   :", "br_mac2", 0, "\n");
lcd_puts(" Bootloader : " PLAIN_VERSION "\n");
lcd_puts("\n");
 }
-- 
2.7.4

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


[U-Boot] [PATCH 08/12] board/BuR/common: refactor ft_board_setup(...)

2018-07-06 Thread Hannes Schmelzer
On other OS, not one provided by B, it is not guaranteed that there
are factory-settings within a devicetree. So we must not treat the
absence of them as error.
Further we've the fact that on different version of the device-tree
files there are different namings of the factory-settings, we consider
this with searching for an alternative name.

changing things as following:

- don't treat as error if the bootloader version cannot written into
devicetree.

- since the naming of the factory-settings are different in different
versions of the provided device-tree we search for the alternate name
"/fset"

Signed-off-by: Hannes Schmelzer 
---

 board/BuR/common/common.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/board/BuR/common/common.c b/board/BuR/common/common.c
index 38da36d..01e3078 100644
--- a/board/BuR/common/common.c
+++ b/board/BuR/common/common.c
@@ -252,15 +252,20 @@ int ft_board_setup(void *blob, bd_t *bd)
 
nodeoffset = fdt_path_offset(blob, "/factory-settings");
if (nodeoffset < 0) {
-   puts("set bootloader version 'factory-settings' not in dtb!\n");
-   return -1;
+   printf("%s: cannot find /factory-settings, trying /fset\n",
+  __func__);
+   nodeoffset = fdt_path_offset(blob, "/fset");
+   if (nodeoffset < 0) {
+   printf("%s: cannot find /fset.\n", __func__);
+   return 0;
+   }
}
+
if (fdt_setprop(blob, nodeoffset, "bl-version",
PLAIN_VERSION, strlen(PLAIN_VERSION)) != 0) {
-   puts("set bootloader version 'bl-version' prop. not in dtb!\n");
-   return -1;
+   printf("%s: no 'bl-version' prop in fdt!\n", __func__);
+   return 0;
}
-
return 0;
 }
 
-- 
2.7.4

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


[U-Boot] [PATCH 07/12] board/BuR/brppt1: drop dead code (CONFIG_SPL_OS_BOOT)

2018-07-06 Thread Hannes Schmelzer
The falcon mode was never used on this board, there is also no plan to
use it. So drop this dead code.

Signed-off-by: Hannes Schmelzer 
---

 board/BuR/brppt1/board.c | 16 
 include/configs/brppt1.h | 14 --
 2 files changed, 30 deletions(-)

diff --git a/board/BuR/brppt1/board.c b/board/BuR/brppt1/board.c
index ff2a3a2..f970f98 100644
--- a/board/BuR/brppt1/board.c
+++ b/board/BuR/brppt1/board.c
@@ -72,22 +72,6 @@ static const struct ctrl_ioregs ddr3_ioregs = {
.dt1ioctl = MT41K256M16HA125E_IOCTRL_VALUE,
 };
 
-#ifdef CONFIG_SPL_OS_BOOT
-/*
- * called from spl_nand.c
- * return 0 for loading linux, return 1 for loading u-boot
- */
-int spl_start_uboot(void)
-{
-   if (0 == gpio_get_value(REPSWITCH)) {
-   mdelay(1000);
-   printf("SPL: entering u-boot instead kernel image.\n");
-   return 1;
-   }
-   return 0;
-}
-#endif /* CONFIG_SPL_OS_BOOT */
-
 #define OSC(V_OSCK/100)
 static const struct dpll_params dpll_ddr3 = { 400, OSC-1, 1, -1, -1, -1, -1};
 
diff --git a/include/configs/brppt1.h b/include/configs/brppt1.h
index 6a210b7..32bb83c 100644
--- a/include/configs/brppt1.h
+++ b/include/configs/brppt1.h
@@ -44,20 +44,6 @@
 #define CONFIG_MTD_DEVICE  /* Required for mtdparts */
 #endif /* CONFIG_SPI_BOOT, ... */
 
-#ifdef CONFIG_SPL_OS_BOOT
-#define CONFIG_SYS_SPL_ARGS_ADDR   0x80F8
-
-/* RAW SD card / eMMC */
-#define CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR0x900   /* address 
0x12 */
-#define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR  0x80/* address 0x1 */
-#define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS 0x80/* 64KiB */
-
-/* NAND */
-#ifdef CONFIG_NAND
-#define CONFIG_SYS_NAND_SPL_KERNEL_OFFS0x14
-#endif /* CONFIG_NAND */
-#endif /* CONFIG_SPL_OS_BOOT */
-
 #ifdef CONFIG_NAND
 #define CONFIG_SPL_NAND_BASE
 #define CONFIG_SPL_NAND_DRIVERS
-- 
2.7.4

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


[U-Boot] [PATCH 10/12] dts: am33xx: add u-boot, dm-spl to ocp bus

2018-07-06 Thread Hannes Schmelzer
This is needed for having access to the devices below this bus, most
important is uart and boot-device (spi, mmc, ...) in SPL stage.

Signed-off-by: Hannes Schmelzer 
---

 arch/arm/dts/am33xx.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/dts/am33xx.dtsi b/arch/arm/dts/am33xx.dtsi
index 14caee7..4234537 100644
--- a/arch/arm/dts/am33xx.dtsi
+++ b/arch/arm/dts/am33xx.dtsi
@@ -91,6 +91,7 @@
 * the whole bus hierarchy.
 */
ocp {
+   u-boot,dm-spl;
compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
-- 
2.7.4

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


[U-Boot] [PATCH 09/12] board/BuR/brppt1: implement more flexible boot process

2018-07-06 Thread Hannes Schmelzer
With this commit we do:

- set the bootdelay in all brppt1 defconfigs to 0, this makes
development easier, since we can break into serial console.

- move CONFIG_BOOTCOMMAND from header file to defconfig

- introduce b_mode variable for selecting the final boot-target.
This b_mode represents the boot-switch, which can found on most b
targets. On the brppt1 this boot-switch is derived from some gpio and
the bootcounter within the RTC block, making it so possible to force
a boot-target (as example for repair-case).

- refactor the environment for booting new flexible way
primary we want to get some bootscr.img within the mass-storage,
this script then loads everything needed for the boot.
For legacy reason we implement the t30lgcy#x boot targets, booting the
already delivered linux-images.

- make space for the cfgscr within mtdparts on brppt1_nand

Signed-off-by: Hannes Schmelzer 
---

 board/BuR/brppt1/board.c  |  28 +++-
 configs/brppt1_mmc_defconfig  |   4 +-
 configs/brppt1_nand_defconfig |   6 +-
 configs/brppt1_spi_defconfig  |   4 +-
 include/configs/brppt1.h  | 145 +++---
 5 files changed, 102 insertions(+), 85 deletions(-)

diff --git a/board/BuR/brppt1/board.c b/board/BuR/brppt1/board.c
index f970f98..87b76a6 100644
--- a/board/BuR/brppt1/board.c
+++ b/board/BuR/brppt1/board.c
@@ -140,11 +140,33 @@ int board_init(void)
 }
 
 #ifdef CONFIG_BOARD_LATE_INIT
+static char *bootmodeascii[16] = {
+   "BOOT", "reserved", "reserved", "reserved",
+   "RUN",  "reserved", "reserved", "reserved",
+   "reserved", "reserved", "reserved", "reserved",
+   "PME",  "reserved", "reserved", "DIAG",
+};
+
 int board_late_init(void)
 {
-   if (0 == gpio_get_value(REPSWITCH)) {
-   env_set("bootcmd", "run netconsole");
-   }
+   unsigned char bmode = 0;
+   ulong bootcount = 0;
+
+   bootcount = bootcount_load() & 0xF;
+
+   if (gpio_get_value(REPSWITCH) == 0 || bootcount == 12)
+   bmode = 12;
+   else if (bootcount > 0)
+   bmode = 0;
+   else
+   bmode = 4;
+
+   printf("Mode:  %s\n", bootmodeascii[bmode & 0x0F]);
+   env_set_ulong("b_mode", bmode);
+
+   /* get sure that bootcmd isn't affected by any bootcount value */
+   env_set_ulong("bootlimit", 0);
+
return 0;
 }
 #endif /* CONFIG_BOARD_LATE_INIT */
diff --git a/configs/brppt1_mmc_defconfig b/configs/brppt1_mmc_defconfig
index b8db509..6bb4657 100644
--- a/configs/brppt1_mmc_defconfig
+++ b/configs/brppt1_mmc_defconfig
@@ -10,7 +10,9 @@ CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL=y
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_SYS_EXTRA_OPTIONS="SERIAL1,CONS_INDEX=1,EMMC_BOOT"
-CONFIG_BOOTDELAY=-2
+CONFIG_BOOTDELAY=0
+CONFIG_USE_BOOTCOMMAND=y
+CONFIG_BOOTCOMMAND="run b_default"
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
diff --git a/configs/brppt1_nand_defconfig b/configs/brppt1_nand_defconfig
index 907ce71..7846e55 100644
--- a/configs/brppt1_nand_defconfig
+++ b/configs/brppt1_nand_defconfig
@@ -9,7 +9,9 @@ CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL=y
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_SYS_EXTRA_OPTIONS="SERIAL1,CONS_INDEX=1"
-CONFIG_BOOTDELAY=-2
+CONFIG_BOOTDELAY=0
+CONFIG_USE_BOOTCOMMAND=y
+CONFIG_BOOTCOMMAND="run b_default"
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
@@ -46,7 +48,7 @@ CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_CMD_MTDPARTS=y
 CONFIG_MTDIDS_DEFAULT="nand0=omap2-nand.0"
-CONFIG_MTDPARTS_DEFAULT="mtdparts=omap2-nand.0:128k(MLO),128k(MLO.backup),128k(dtb),128k(u-boot-env),512k(u-boot),4m(kernel),128m(rootfs),-(user)"
+CONFIG_MTDPARTS_DEFAULT="mtdparts=omap2-nand.0:128k(MLO),128k(cfgscr),128k(dtb),128k(u-boot-env),512k(u-boot),4m(kernel),128m(rootfs),-(user)"
 CONFIG_ENV_IS_IN_NAND=y
 CONFIG_NETCONSOLE=y
 CONFIG_BOOTCOUNT_LIMIT=y
diff --git a/configs/brppt1_spi_defconfig b/configs/brppt1_spi_defconfig
index 90054aa..f4197c4 100644
--- a/configs/brppt1_spi_defconfig
+++ b/configs/brppt1_spi_defconfig
@@ -13,7 +13,9 @@ CONFIG_SPL_SPI_SUPPORT=y
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_SYS_EXTRA_OPTIONS="SERIAL1,CONS_INDEX=1,SPI_BOOT,EMMC_BOOT"
 CONFIG_SPI_BOOT=y
-CONFIG_BOOTDELAY=-2
+CONFIG_BOOTDELAY=0
+CONFIG_USE_BOOTCOMMAND=y
+CONFIG_BOOTCOMMAND="run b_default"
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
diff --git a/include/configs/brppt1.h b/include/configs/brppt1.h
index 32bb83c..d5b2573 100644
--- a/include/configs/brppt1.h
+++ b/include/configs/brppt1.h
@@ -16,6 +16,7 @@
 /* - */
 /* memory */
 #define CONFIG_SYS_MALLOC_LEN  (5 * 1024 * 1024)
+#define CONFIG_SYS_BOOTM_LEN   SZ_32M
 
 /* Clock Defines */
 #define V_OSCK 2600  /* Clock output from 

[U-Boot] [PATCH 03/12] board/BuR/common: make CONFIG_LCD optional

2018-07-06 Thread Hannes Schmelzer
Since we're going to drop LCD-support on brppt1 boards, we have to make
this stuff here optional and remove the #error path.

We also move out the ft_board_setup(...) from this #ifdef because
there's no relationship with the LCD-code and on the other hand this is
still needed in future even with LCD-support off.

Signed-off-by: Hannes Schmelzer 
---

 board/BuR/common/common.c | 39 ++-
 1 file changed, 18 insertions(+), 21 deletions(-)

diff --git a/board/BuR/common/common.c b/board/BuR/common/common.c
index 29430e9..e1ac6c4 100644
--- a/board/BuR/common/common.c
+++ b/board/BuR/common/common.c
@@ -156,24 +156,6 @@ int load_lcdtiming(struct am335x_lcdpanel *panel)
return 0;
 }
 
-int ft_board_setup(void *blob, bd_t *bd)
-{
-   int nodeoffset;
-
-   nodeoffset = fdt_path_offset(blob, "/factory-settings");
-   if (nodeoffset < 0) {
-   puts("set bootloader version 'factory-settings' not in dtb!\n");
-   return -1;
-   }
-   if (fdt_setprop(blob, nodeoffset, "bl-version",
-   PLAIN_VERSION, strlen(PLAIN_VERSION)) != 0) {
-   puts("set bootloader version 'bl-version' prop. not in dtb!\n");
-   return -1;
-   }
-
-   return 0;
-}
-
 static void br_summaryscreen_printenv(char *prefix,
   char *name, char *altname,
   char *suffix)
@@ -262,11 +244,26 @@ void lcd_enable(void)
br_summaryscreen();
lcdbacklight(1);
 }
-#elif CONFIG_SPL_BUILD
-#else
-#error "LCD-support with a suitable FB-Driver is mandatory !"
 #endif /* CONFIG_LCD */
 
+int ft_board_setup(void *blob, bd_t *bd)
+{
+   int nodeoffset;
+
+   nodeoffset = fdt_path_offset(blob, "/factory-settings");
+   if (nodeoffset < 0) {
+   puts("set bootloader version 'factory-settings' not in dtb!\n");
+   return -1;
+   }
+   if (fdt_setprop(blob, nodeoffset, "bl-version",
+   PLAIN_VERSION, strlen(PLAIN_VERSION)) != 0) {
+   puts("set bootloader version 'bl-version' prop. not in dtb!\n");
+   return -1;
+   }
+
+   return 0;
+}
+
 #ifdef CONFIG_SPL_BUILD
 void pmicsetup(u32 mpupll)
 {
-- 
2.7.4

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


[U-Boot] [PATCH 02/12] board/BuR/common: drop simple-framebuffer setup

2018-07-06 Thread Hannes Schmelzer
The linux systems running on the brppt1 targets are using modern DRM
drivers since long time ago. Further we are going to drop the LCD
support completely on this board, so the simple-framebuffer setup
becomes obsolete.

Signed-off-by: Hannes Schmelzer 
---

 board/BuR/common/common.c | 26 --
 1 file changed, 26 deletions(-)

diff --git a/board/BuR/common/common.c b/board/BuR/common/common.c
index 98132b7..29430e9 100644
--- a/board/BuR/common/common.c
+++ b/board/BuR/common/common.c
@@ -28,7 +28,6 @@
 #include 
 #include "bur_common.h"
 #include "../../../drivers/video/am335x-fb.h"
-#include 
 
 static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
 
@@ -171,31 +170,6 @@ int ft_board_setup(void *blob, bd_t *bd)
puts("set bootloader version 'bl-version' prop. not in dtb!\n");
return -1;
}
-   /*
-* if no simplefb is requested through environment, we don't set up
-* one, instead we turn off backlight.
-*/
-   if (env_get_ulong("simplefb", 10, 0) == 0) {
-   lcdbacklight(0);
-   return 0;
-   }
-   /* Setup simplefb devicetree node, also adapt memory-node,
-* upper limit for kernel e.g. linux is memtop-framebuffer alligned
-* to a full megabyte.
-*/
-   u64 start = gd->bd->bi_dram[0].start;
-   u64 size = (gd->fb_base - start) & ~0xF;
-   int rc = fdt_fixup_memory_banks(blob, , , 1);
-
-   if (rc) {
-   puts("cannot setup simplefb: Error reserving memory!\n");
-   return rc;
-   }
-   rc = lcd_dt_simplefb_enable_existing_node(blob);
-   if (rc) {
-   puts("cannot setup simplefb: error enabling simplefb node!\n");
-   return rc;
-   }
 
return 0;
 }
-- 
2.7.4

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


[U-Boot] [PATCH 01/12] board/BuR: drop devicetree loading and lcd setup for linux-targets

2018-07-06 Thread Hannes Schmelzer
This patch  drops the lcd-screen setup, the summary screen and getting
mac-addresses based on a previous loaded device-tree for linux targets.
Selecting those linux target is simple, since we have only the brppt1.

In detail we do:
- drop the common lcd-setup code which relys on a fdt_blob
- drop the common dtb loading mechanism
- drop the now obsolete CONFIG_USE_FDT from board header and whitelist.

Signed-off-by: Hannes Schmelzer 
---

 board/BuR/common/common.c| 230 ++-
 include/configs/brppt1.h |   1 -
 scripts/config_whitelist.txt |   1 -
 3 files changed, 6 insertions(+), 226 deletions(-)

diff --git a/board/BuR/common/common.c b/board/BuR/common/common.c
index 9df1979..98132b7 100644
--- a/board/BuR/common/common.c
+++ b/board/BuR/common/common.c
@@ -26,42 +26,22 @@
 #include 
 #include 
 #include 
-#include 
-#ifdef CONFIG_USE_FDT
-  #include 
-#endif
 #include "bur_common.h"
 #include "../../../drivers/video/am335x-fb.h"
-#include 
 #include 
 
 static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#ifdef CONFIG_USE_FDT
-  #define FDTPROP(b, c) fdt_getprop_u32_default(gd->fdt_blob, b, c, ~0UL)
-  #define PATHTIM "/panel/display-timings/default"
-  #define PATHINF "/panel/panel-info"
-#endif
 /* --*/
 #if defined(CONFIG_LCD) && defined(CONFIG_AM335X_LCD) && \
!defined(CONFIG_SPL_BUILD)
 void lcdbacklight(int on)
 {
-#ifdef CONFIG_USE_FDT
-   if (gd->fdt_blob == NULL) {
-   printf("%s: don't have a valid gd->fdt_blob!\n", __func__);
-   return;
-   }
-   unsigned int driver = FDTPROP(PATHINF, "brightdrv");
-   unsigned int bright = FDTPROP(PATHINF, "brightdef");
-   unsigned int pwmfrq = FDTPROP(PATHINF, "brightfdim");
-#else
unsigned int driver = env_get_ulong("ds1_bright_drv", 16, 0UL);
unsigned int bright = env_get_ulong("ds1_bright_def", 10, 50);
unsigned int pwmfrq = env_get_ulong("ds1_pwmfreq", 10, ~0UL);
-#endif
unsigned int tmp;
struct gptimer *timerhw;
 
@@ -116,70 +96,7 @@ void lcdbacklight(int on)
 int load_lcdtiming(struct am335x_lcdpanel *panel)
 {
struct am335x_lcdpanel pnltmp;
-#ifdef CONFIG_USE_FDT
-   u32 dtbprop;
-   char buf[32];
-   const char *nodep = 0;
-   int nodeoff;
-
-   if (gd->fdt_blob == NULL) {
-   printf("%s: don't have a valid gd->fdt_blob!\n", __func__);
-   return -1;
-   }
-   memcpy(, (void *)panel, sizeof(struct am335x_lcdpanel));
-
-   pnltmp.hactive = FDTPROP(PATHTIM, "hactive");
-   pnltmp.vactive = FDTPROP(PATHTIM, "vactive");
-   pnltmp.bpp = FDTPROP(PATHINF, "bpp");
-   pnltmp.hfp = FDTPROP(PATHTIM, "hfront-porch");
-   pnltmp.hbp = FDTPROP(PATHTIM, "hback-porch");
-   pnltmp.hsw = FDTPROP(PATHTIM, "hsync-len");
-   pnltmp.vfp = FDTPROP(PATHTIM, "vfront-porch");
-   pnltmp.vbp = FDTPROP(PATHTIM, "vback-porch");
-   pnltmp.vsw = FDTPROP(PATHTIM, "vsync-len");
-   pnltmp.pup_delay = FDTPROP(PATHTIM, "pupdelay");
-   pnltmp.pon_delay = FDTPROP(PATHTIM, "pondelay");
-   pnltmp.pxl_clk = FDTPROP(PATHTIM, "clock-frequency");
-
-   /* check polarity of control-signals */
-   dtbprop = FDTPROP(PATHTIM, "hsync-active");
-   if (dtbprop == 0)
-   pnltmp.pol |= HSYNC_INVERT;
-   dtbprop = FDTPROP(PATHTIM, "vsync-active");
-   if (dtbprop == 0)
-   pnltmp.pol |= VSYNC_INVERT;
-   dtbprop = FDTPROP(PATHINF, "sync-ctrl");
-   if (dtbprop == 1)
-   pnltmp.pol |= HSVS_CONTROL;
-   dtbprop = FDTPROP(PATHINF, "sync-edge");
-   if (dtbprop == 1)
-   pnltmp.pol |= HSVS_RISEFALL;
-   dtbprop = FDTPROP(PATHTIM, "pixelclk-active");
-   if (dtbprop == 0)
-   pnltmp.pol |= PXCLK_INVERT;
-   dtbprop = FDTPROP(PATHTIM, "de-active");
-   if (dtbprop == 0)
-   pnltmp.pol |= DE_INVERT;
-
-   nodeoff = fdt_path_offset(gd->fdt_blob, "/factory-settings");
-   if (nodeoff >= 0) {
-   nodep = fdt_getprop(gd->fdt_blob, nodeoff, "rotation", NULL);
-   if (nodep != 0) {
-   if (strcmp(nodep, "cw") == 0)
-   panel_info.vl_rot = 1;
-   else if (strcmp(nodep, "ud") == 0)
-   panel_info.vl_rot = 2;
-   else if (strcmp(nodep, "ccw") == 0)
-   panel_info.vl_rot = 3;
-   else
-   panel_info.vl_rot = 0;
-   }
-   } else {
-   puts("no 'factory-settings / rotation' in dtb!\n");
-   }
-   snprintf(buf, sizeof(buf), "fbcon=rotate:%d", panel_info.vl_rot);
-   env_set("optargs_rot", buf);
-#else
+
pnltmp.hactive = env_get_ulong("ds1_hactive", 10, ~0UL);
  

[U-Boot] [PATCH 00/12] Refactor bur board/common code

2018-07-06 Thread Hannes Schmelzer

This patch series has the intention of preparing the move of all bur
boards to driver-model, cleaning up the over years growed code, make os
boot more flexible.

In another series we will make the move to DM with all its consequences
(adapting drivers, )

For doing all this there are several things todo and some decisions
regarding design were made.

decisions:
- move all boards to driver model
- no need for displaying splash/summary on linux targets
- more flexible boot process

todos:
- drop device-tree loading in common code
in future we can rely on the u-boot devicetree
- drop the device-tree based lcd initialization code
- use standard mechanism for getting mac-addresses
- new default-environment for more flexible boot



Hannes Schmelzer (12):
  board/BuR: drop devicetree loading and lcd setup for linux-targets
  board/BuR/common: drop simple-framebuffer setup
  board/BuR/common: make CONFIG_LCD optional
  board/BuR/brppt1: drop LCD-support
  board/BuR/common: remove interface Label from summary screen
  board/BuR/common: fix PMIC mpu-pll setup
  board/BuR/brppt1: drop dead code (CONFIG_SPL_OS_BOOT)
  board/BuR/common: refactor ft_board_setup(...)
  board/BuR/brppt1: implement more flexible boot process
  dts: am33xx: add u-boot, dm-spl to ocp bus
  board/BuR/brppt1: convert brppt1 boards to driver model
  board/BuR/brppt1: add makerule for generating production files

 arch/arm/dts/am335x-brppt1-mmc.dts  | 345 ++
 arch/arm/dts/am335x-brppt1-nand.dts | 363 
 arch/arm/dts/am335x-brppt1-spi.dts  | 366 
 arch/arm/dts/am33xx.dtsi|   1 +
 board/BuR/brppt1/board.c|  70 ---
 board/BuR/brppt1/config.mk  |  36 
 board/BuR/common/common.c   | 407 
 configs/brppt1_mmc_defconfig|  52 -
 configs/brppt1_nand_defconfig   |  54 -
 configs/brppt1_spi_defconfig|  57 +++--
 include/configs/brppt1.h| 202 --
 include/configs/bur_am335x_common.h |  26 +--
 scripts/config_whitelist.txt|   1 -
 13 files changed, 1418 insertions(+), 562 deletions(-)
 create mode 100644 arch/arm/dts/am335x-brppt1-mmc.dts
 create mode 100644 arch/arm/dts/am335x-brppt1-nand.dts
 create mode 100644 arch/arm/dts/am335x-brppt1-spi.dts
 create mode 100644 board/BuR/brppt1/config.mk

-- 
2.7.4

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


Re: [U-Boot] [RFC PATCH 17/20] cmd: mtd: add 'mtd' command

2018-07-06 Thread Stefan Roese

Hi Miquel,

On 06.07.2018 14:26, Miquel Raynal wrote:

Jagan Teki  wrote on Fri, 6 Jul 2018 17:08:57
+0530:


On Wed, Jun 6, 2018 at 9:00 PM, Miquel Raynal  wrote:

There should not be a 'nand' command, a 'sf' command and certainly not
another 'spi-nand'. Write a 'mtd' command instead to manage all MTD
devices at once. This should be the preferred way to access any MTD
device.


So are you planning to integrate sf, nand command in future, adding
them dm conversion of many stuff. I would like to reommend to go with
spinand command. I have been through this and finally added spinor
command, which I will going to in soon. once all are converted to dm,
it would be easy and meaningfull to have common command.


I'm not sure we are in sync about this. The whole point of the previous
discussion was to decide whether or not we should make full use of
the MTD stack or not. I think it was pretty clear on the fact that
people prefer to be close to Linux's architecture on this regard.

MTD being an abstraction of the type of memory, I don't get the
point in creating yet another command each time a new type of
device is supported. The fact that all the drivers of these devices
register to the MTD layer makes it trivial to interact with. So why
should we wait?


Yes, please don't add new commands for each subsystem / device-type.
I like the idea of adding one new command-set (your mtd command) and
extending this one to all other device-types over the time.

BTW: I'm testing your SPI NAND patches right now (still struggling
with some Gigadevice SPI NAND) and found that the "mtd" command is
not really in-line with the usual U-Boot commands. Here some
comments:

- Use hex values per default (addresses, sizes and soffset)
- "mtd read" just prints the read values. It makes more sense
  to read into memory instead (similar to the "mtd write")

I have some patches to address these issues in the queue (still
need some massaging), which you can fold into your patchset, once
we agree on this.

Thanks,
Stefan
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [ANN] travis-ci opt-in for now

2018-07-06 Thread Tom Rini
Hey all,

While I like what travis-ci has done for parts of my workflow, they're
experiencing one of their sustained periods where network connectivity
fails at least once per job.  And since broken CI is worse than no CI,
I'm saying until further notice that if you don't want to fight with
travis to get a green build, that's OK.  Thanks all!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


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

2018-07-06 Thread Marek Vasut
The following changes since commit 4ac5df4b41ba46d7e635bdd8d500721c642b0a0d:

  Merge branch 'master' of git://git.denx.de/u-boot-sunxi (2018-07-03
23:09:34 -0400)

are available in the Git repository at:

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

for you to fetch changes up to 0bc846a769d43810af9e4622473b85ffaead3dea:

  sunxi: A64: OHCI: prevent turning off shared USB clock (2018-07-05
11:25:50 +0200)


Andre Przywara (1):
  sunxi: A64: OHCI: prevent turning off shared USB clock

Emmanuel Vadot (1):
  usb: dwc2: Add brcm,bcm2708-usb compatible

 drivers/usb/host/dwc2.c   |  1 +
 drivers/usb/host/ohci-sunxi.c | 19 ++-
 2 files changed, 19 insertions(+), 1 deletion(-)
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] dm: Force to enable DM_SPI and DM_SPI_FLASH

2018-07-06 Thread Tom Rini
On Fri, Jul 06, 2018 at 05:41:01PM +0530, Jagan Teki wrote:

> v2018.09 is migration deadline for SPI/SPI_FLASH dm
> converion.
> 
> So move on and true it has significant fallout
> at present.
> 
> Signed-off-by: Jagan Teki 
> ---
> Note:
> Trying to copy all people who involve this change, but
> list is too much..hope everyone notice this.

Please send an email with everyone that has things failing in the to
line, and yes, it will be a bit of work, but it's the only way.  If
needed, you can break the email up into a few instances.  Thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] Problem with Travis-Ci

2018-07-06 Thread Tom Rini
On Fri, Jul 06, 2018 at 11:20:01AM +0200, Lukasz Majewski wrote:

> Hi Tom,
> 
> I've performed the travis-ci build for some USB gadget related code:
> 
> https://travis-ci.org/lmajewski/u-boot-dfu/jobs/400649043
> 
> And for some tasks (e.g. BUILDMAN="sun50i") I do see following errors:
> 
> The following NEW packages will be installed:
>   libisl15
> 0 upgraded, 1 newly installed, 0 to remove and 220 not upgraded.
> Need to get 507 kB of archives.
> After this operation, 1,691 kB of additional disk space will be used.
> WARNING: The following packages cannot be authenticated!
>   libisl15
> E: There were unauthenticated packages and -y was used without
> --allow-unauthenticated The command "sudo apt-get install libisl15 -y"
> failed and exited with 100 during .
> 
> Have you seen them before?

Yes, this happens all too frequently of late, sadly.  Just click on the
retry this job button (the one for the individual parts that fail, not
the whole job itself).

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [RFC PATCH 17/20] cmd: mtd: add 'mtd' command

2018-07-06 Thread Miquel Raynal
Hi Jagan,

Jagan Teki  wrote on Fri, 6 Jul 2018 17:08:57
+0530:

> On Wed, Jun 6, 2018 at 9:00 PM, Miquel Raynal  
> wrote:
> > There should not be a 'nand' command, a 'sf' command and certainly not
> > another 'spi-nand'. Write a 'mtd' command instead to manage all MTD
> > devices at once. This should be the preferred way to access any MTD
> > device.  
> 
> So are you planning to integrate sf, nand command in future, adding
> them dm conversion of many stuff. I would like to reommend to go with
> spinand command. I have been through this and finally added spinor
> command, which I will going to in soon. once all are converted to dm,
> it would be easy and meaningfull to have common command.

I'm not sure we are in sync about this. The whole point of the previous
discussion was to decide whether or not we should make full use of
the MTD stack or not. I think it was pretty clear on the fact that
people prefer to be close to Linux's architecture on this regard.

MTD being an abstraction of the type of memory, I don't get the
point in creating yet another command each time a new type of
device is supported. The fact that all the drivers of these devices
register to the MTD layer makes it trivial to interact with. So why
should we wait?


Thanks,
Miquèl
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [RFC PATCH 00/20] SPI-NAND support

2018-07-06 Thread Jagan Teki
On Fri, Jul 6, 2018 at 5:36 PM, Miquel Raynal  wrote:
> Hi Jagan,
>
> Jagan Teki  wrote on Fri, 6 Jul 2018
> 17:13:21 +0530:
>
>> On Wed, Jun 6, 2018 at 9:00 PM, Miquel Raynal  
>> wrote:
>> > During the last months, Boris Brezillon shared his work to support
>> > serial flashes within Linux. First, he delivered (and merged) a new
>> > layer called spi-mem. He also initiated in Linux MTD subsystem the move
>> > of all 'raw' NAND related code to a raw/ subdirectory, adding at the
>> > same time a NAND core that would be shared with all NAND devices. Then,
>> > he contributed a generic SPI-NAND driver, making use of this NAND core,
>> > as well as some vendor code to drive a few chips.
>> >
>> > On top of this work, I added an 'mtd' U-Boot command to handle all sort
>> > of MTD devices. This should become the default command instead of having
>> > one per flash flavor ('sf', 'nand', 'spi-nand' ?).
>> >
>> > The series has been tested on an Ocelot board PCB123 (VSC7514),
>> > featuring a Macronix SPI NAND chip.
>> >
>> > TL;DR: the series contains:
>> > - Various fixes and re-organization of the MTD subsystem.
>> > - The introduction of the SPI-mem interface.
>> > - The addition of the generic SPI-NAND driver (and its bindings).
>> > - Several SPI NAND chip drivers (Macronix, Micron, Winbond).
>> > - A new 'mtd' command.
>> > - DT changes to make use of a SPI NAND on the Ocelot board.
>> >
>> > Any comments on the code, the organization and the respect of U-Boot
>> > driver model will be welcome.
>> >
>> > Thanks,
>> > Miquèl
>> >
>> >
>> > Boris Brezillon (6):
>> >   mtd: Fallback to ->_read/write_oob() when ->_read/write() is missing
>> >   mtd: nand: Add core infrastructure to deal with NAND devices
>> >   mtd: nand: Pass mode information to nand_page_io_req
>> >   spi: Extend the core to ease integration of SPI memory controllers
>> >   mtd: spinand: Add initial support for the MX35LF1GE4AB chip
>> >   dt-bindings: Add bindings for SPI NAND devices
>> >
>> > Brian Norris (1):
>> >   mtd: add get/set of_node/flash_node helpers
>> >
>> > Frieder Schrempf (1):
>> >   mtd: spinand: Add initial support for Winbond W25M02GV
>> >
>> > Miquel Raynal (10):
>> >   mtd: fix build issue with includes
>> >   mtd: move definitions to enlarge their range
>> >   mtd: move all flash categories inside MTD submenu
>> >   mtd: move NAND fiels into a raw/ subdirectory
>> >   mtd: rename nand into rawnand in Kconfig prompt
>> >   mtd: spinand: Add initial support for the MX35LF2GE4AB chip
>> >   mtd: uclass: add probe function
>> >   cmd: mtd: add 'mtd' command
>> >   mips: dts: ocelot: describe SPI CS pins
>> >   mips: dts: ocelot: add the SPI NAND node
>> >
>> > Peter Pan (2):
>> >   mtd: nand: Add core infrastructure to support SPI NANDs
>> >   mtd: spinand: Add initial support for Micron MT29F2G01ABAGD
>>
>> I have reviewed and commented most of the stuff that are in my
>> control, except few spi-nand code, which I would like to give a try to
>> other people in the list. Hope to seen the fine-tuning patches on next
>> version.
>
> Thanks for taking the time to review all this; I'm on it.
>
> About spi-nand, reviews from other contributors are welcome, but it's
> mostly a copy from Linux framework that I just applied to nand/next.
> There have been 9 versions of it before that so I think it's pretty
> well reviewed.

OK, that's fine then.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] dm: Force to enable DM_SPI and DM_SPI_FLASH

2018-07-06 Thread Jagan Teki
v2018.09 is migration deadline for SPI/SPI_FLASH dm
converion.

So move on and true it has significant fallout
at present.

Signed-off-by: Jagan Teki 
---
Note:
Trying to copy all people who involve this change, but
list is too much..hope everyone notice this.

 drivers/core/Kconfig | 1 +
 drivers/spi/Kconfig  | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/core/Kconfig b/drivers/core/Kconfig
index e8ba20ca82..b702dec7d7 100644
--- a/drivers/core/Kconfig
+++ b/drivers/core/Kconfig
@@ -2,6 +2,7 @@ menu "Generic Driver Options"
 
 config DM
bool "Enable Driver Model"
+   select DM_SPI
help
  This config option enables Driver Model. This brings in the core
  support, including scanning of platform data on start-up. If
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 3532c2ad46..b160073540 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -6,6 +6,7 @@ if SPI
 config DM_SPI
bool "Enable Driver Model for SPI drivers"
depends on DM
+   select DM_SPI_FLASH
help
  Enable driver model for SPI. The SPI slave interface
  (spi_setup_slave(), spi_xfer(), etc.) is then implemented by
-- 
2.17.1

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


Re: [U-Boot] [RFC PATCH 00/20] SPI-NAND support

2018-07-06 Thread Miquel Raynal
Hi Jagan,

Jagan Teki  wrote on Fri, 6 Jul 2018
17:13:21 +0530:

> On Wed, Jun 6, 2018 at 9:00 PM, Miquel Raynal  
> wrote:
> > During the last months, Boris Brezillon shared his work to support
> > serial flashes within Linux. First, he delivered (and merged) a new
> > layer called spi-mem. He also initiated in Linux MTD subsystem the move
> > of all 'raw' NAND related code to a raw/ subdirectory, adding at the
> > same time a NAND core that would be shared with all NAND devices. Then,
> > he contributed a generic SPI-NAND driver, making use of this NAND core,
> > as well as some vendor code to drive a few chips.
> >
> > On top of this work, I added an 'mtd' U-Boot command to handle all sort
> > of MTD devices. This should become the default command instead of having
> > one per flash flavor ('sf', 'nand', 'spi-nand' ?).
> >
> > The series has been tested on an Ocelot board PCB123 (VSC7514),
> > featuring a Macronix SPI NAND chip.
> >
> > TL;DR: the series contains:
> > - Various fixes and re-organization of the MTD subsystem.
> > - The introduction of the SPI-mem interface.
> > - The addition of the generic SPI-NAND driver (and its bindings).
> > - Several SPI NAND chip drivers (Macronix, Micron, Winbond).
> > - A new 'mtd' command.
> > - DT changes to make use of a SPI NAND on the Ocelot board.
> >
> > Any comments on the code, the organization and the respect of U-Boot
> > driver model will be welcome.
> >
> > Thanks,
> > Miquèl
> >
> >
> > Boris Brezillon (6):
> >   mtd: Fallback to ->_read/write_oob() when ->_read/write() is missing
> >   mtd: nand: Add core infrastructure to deal with NAND devices
> >   mtd: nand: Pass mode information to nand_page_io_req
> >   spi: Extend the core to ease integration of SPI memory controllers
> >   mtd: spinand: Add initial support for the MX35LF1GE4AB chip
> >   dt-bindings: Add bindings for SPI NAND devices
> >
> > Brian Norris (1):
> >   mtd: add get/set of_node/flash_node helpers
> >
> > Frieder Schrempf (1):
> >   mtd: spinand: Add initial support for Winbond W25M02GV
> >
> > Miquel Raynal (10):
> >   mtd: fix build issue with includes
> >   mtd: move definitions to enlarge their range
> >   mtd: move all flash categories inside MTD submenu
> >   mtd: move NAND fiels into a raw/ subdirectory
> >   mtd: rename nand into rawnand in Kconfig prompt
> >   mtd: spinand: Add initial support for the MX35LF2GE4AB chip
> >   mtd: uclass: add probe function
> >   cmd: mtd: add 'mtd' command
> >   mips: dts: ocelot: describe SPI CS pins
> >   mips: dts: ocelot: add the SPI NAND node
> >
> > Peter Pan (2):
> >   mtd: nand: Add core infrastructure to support SPI NANDs
> >   mtd: spinand: Add initial support for Micron MT29F2G01ABAGD  
> 
> I have reviewed and commented most of the stuff that are in my
> control, except few spi-nand code, which I would like to give a try to
> other people in the list. Hope to seen the fine-tuning patches on next
> version.

Thanks for taking the time to review all this; I'm on it.

About spi-nand, reviews from other contributors are welcome, but it's
mostly a copy from Linux framework that I just applied to nand/next.
There have been 9 versions of it before that so I think it's pretty
well reviewed.

Thanks,
Miquèl
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 5/5] rk3288: vyasa: Fixup indentation

2018-07-06 Thread Jagan Teki
On Thu, Jul 5, 2018 at 1:11 AM, Alberto Panizzo
 wrote:
> Indent file using tabs
>
> Signed-off-by: Alberto Panizzo 
> ---

 Reviewed-by: Jagan Teki 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 4/5] rk3288: vyasa: Allow booting from internal eMMC

2018-07-06 Thread Jagan Teki
On Thu, Jul 5, 2018 at 1:11 AM, Alberto Panizzo
 wrote:
> Keeping SD-Card as priority for easy board recovery
>
> Signed-off-by: Alberto Panizzo 
> ---

Reviewed-by: Jagan Teki 

>  include/configs/vyasa-rk3288.h | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/include/configs/vyasa-rk3288.h b/include/configs/vyasa-rk3288.h
> index 382fdac..4114bf0 100644
> --- a/include/configs/vyasa-rk3288.h
> +++ b/include/configs/vyasa-rk3288.h
> @@ -15,6 +15,7 @@
>
>  #define BOOT_TARGET_DEVICES(func) \
> func(MMC, mmc, 1) \
> +   func(MMC, mmc, 0)
>
>  #define CONFIG_SYS_MMC_ENV_DEV 1

I think we even need to take care env device wrt boot mode.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] spi: Zap fsl_espi driver

2018-07-06 Thread Jagan Teki
On Fri, May 11, 2018 at 11:51 AM, Jagan Teki  wrote:
> Dropped becuase
> - No proper changes related to since from 2015
> - no dm conversion.
>
> Signed-off-by: Jagan Teki 
> ---
> Note: Right now only drived removed, if there is no further
> update on this will remove respective code which is using
> this driver.

Any further response on this?
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [RFC PATCH 00/20] SPI-NAND support

2018-07-06 Thread Jagan Teki
On Wed, Jun 6, 2018 at 9:00 PM, Miquel Raynal  wrote:
> During the last months, Boris Brezillon shared his work to support
> serial flashes within Linux. First, he delivered (and merged) a new
> layer called spi-mem. He also initiated in Linux MTD subsystem the move
> of all 'raw' NAND related code to a raw/ subdirectory, adding at the
> same time a NAND core that would be shared with all NAND devices. Then,
> he contributed a generic SPI-NAND driver, making use of this NAND core,
> as well as some vendor code to drive a few chips.
>
> On top of this work, I added an 'mtd' U-Boot command to handle all sort
> of MTD devices. This should become the default command instead of having
> one per flash flavor ('sf', 'nand', 'spi-nand' ?).
>
> The series has been tested on an Ocelot board PCB123 (VSC7514),
> featuring a Macronix SPI NAND chip.
>
> TL;DR: the series contains:
> - Various fixes and re-organization of the MTD subsystem.
> - The introduction of the SPI-mem interface.
> - The addition of the generic SPI-NAND driver (and its bindings).
> - Several SPI NAND chip drivers (Macronix, Micron, Winbond).
> - A new 'mtd' command.
> - DT changes to make use of a SPI NAND on the Ocelot board.
>
> Any comments on the code, the organization and the respect of U-Boot
> driver model will be welcome.
>
> Thanks,
> Miquèl
>
>
> Boris Brezillon (6):
>   mtd: Fallback to ->_read/write_oob() when ->_read/write() is missing
>   mtd: nand: Add core infrastructure to deal with NAND devices
>   mtd: nand: Pass mode information to nand_page_io_req
>   spi: Extend the core to ease integration of SPI memory controllers
>   mtd: spinand: Add initial support for the MX35LF1GE4AB chip
>   dt-bindings: Add bindings for SPI NAND devices
>
> Brian Norris (1):
>   mtd: add get/set of_node/flash_node helpers
>
> Frieder Schrempf (1):
>   mtd: spinand: Add initial support for Winbond W25M02GV
>
> Miquel Raynal (10):
>   mtd: fix build issue with includes
>   mtd: move definitions to enlarge their range
>   mtd: move all flash categories inside MTD submenu
>   mtd: move NAND fiels into a raw/ subdirectory
>   mtd: rename nand into rawnand in Kconfig prompt
>   mtd: spinand: Add initial support for the MX35LF2GE4AB chip
>   mtd: uclass: add probe function
>   cmd: mtd: add 'mtd' command
>   mips: dts: ocelot: describe SPI CS pins
>   mips: dts: ocelot: add the SPI NAND node
>
> Peter Pan (2):
>   mtd: nand: Add core infrastructure to support SPI NANDs
>   mtd: spinand: Add initial support for Micron MT29F2G01ABAGD

I have reviewed and commented most of the stuff that are in my
control, except few spi-nand code, which I would like to give a try to
other people in the list. Hope to seen the fine-tuning patches on next
version.

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


Re: [U-Boot] [RFC PATCH 17/20] cmd: mtd: add 'mtd' command

2018-07-06 Thread Jagan Teki
On Wed, Jun 6, 2018 at 9:00 PM, Miquel Raynal  wrote:
> There should not be a 'nand' command, a 'sf' command and certainly not
> another 'spi-nand'. Write a 'mtd' command instead to manage all MTD
> devices at once. This should be the preferred way to access any MTD
> device.

So are you planning to integrate sf, nand command in future, adding
them dm conversion of many stuff. I would like to reommend to go with
spinand command. I have been through this and finally added spinor
command, which I will going to in soon. once all are converted to dm,
it would be easy and meaningfull to have common command.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [RFC PATCH 10/20] spi: Extend the core to ease integration of SPI memory controllers

2018-07-06 Thread Jagan Teki
On Wed, Jun 6, 2018 at 9:00 PM, Miquel Raynal  wrote:
> From: Boris Brezillon 
>
> Some controllers are exposing high-level interfaces to access various
> kind of SPI memories. Unfortunately they do not fit in the current
> spi_controller model and usually have drivers placed in
> drivers/mtd/spi-nor which are only supporting SPI NORs and not SPI
> memories in general.
>
> This is an attempt at defining a SPI memory interface which works for
> all kinds of SPI memories (NORs, NANDs, SRAMs).
>
> Signed-off-by: Boris Brezillon 
> Signed-off-by: Miquel Raynal 
> ---
>  drivers/spi/Kconfig   |   7 +
>  drivers/spi/Makefile  |   1 +
>  drivers/spi/spi-mem.c | 500 
> ++
>  include/spi-mem.h | 258 ++
>  include/spi.h |  11 ++
>  5 files changed, 777 insertions(+)
>  create mode 100644 drivers/spi/spi-mem.c
>  create mode 100644 include/spi-mem.h
>
> diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
> index 235a8c7d73..0ee371b2d9 100644
> --- a/drivers/spi/Kconfig
> +++ b/drivers/spi/Kconfig
> @@ -15,6 +15,13 @@ config DM_SPI
>
>  if DM_SPI
>
> +config SPI_MEM
> +   bool "SPI memory extension"
> +   help
> + Enable this option if you want to enable the SPI memory extension.
> + This extension is meant to simplify interaction with SPI memories
> + by providing an high-level interface to send memory-like commands.
> +
>  config ALTERA_SPI
> bool "Altera SPI driver"
> help
> diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
> index 4b6000fd9a..982529a0e6 100644
> --- a/drivers/spi/Makefile
> +++ b/drivers/spi/Makefile
> @@ -10,6 +10,7 @@ ifdef CONFIG_DM_SPI
>  obj-y += spi-uclass.o
>  obj-$(CONFIG_SANDBOX) += spi-emul-uclass.o
>  obj-$(CONFIG_SOFT_SPI) += soft_spi.o
> +obj-$(CONFIG_SPI_MEM) += spi-mem.o
>  else
>  obj-y += spi.o
>  obj-$(CONFIG_SOFT_SPI) += soft_spi_legacy.o
> diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
> new file mode 100644
> index 00..1aabe56819
> --- /dev/null
> +++ b/drivers/spi/spi-mem.c
> @@ -0,0 +1,500 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2018 Exceet Electronics GmbH
> + * Copyright (C) 2018 Bootlin
> + *
> + * Author: Boris Brezillon 
> + */
> +
> +#ifndef __UBOOT__
> +#include 
> +#include 
> +#include "internals.h"
> +#else
> +#include 
> +#include 
> +#endif
> +
> +#ifndef __UBOOT__

I would like remove Linux stuff atleast on this file becuase it's
difficult for me to read or review the code and also driver/spi have
fully u-boot dm stuff. I know it's easy for Linux sync but for this we
can do manual sync what ever need. I'm on something what from Linux.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] ARM: dh_imx6: enable GigaDevice, Macronix, and Winbond SPI Flash support in Kconfig

2018-07-06 Thread lzenz
From: Ludwig Zenz 

In preparation for delivery bottlenecks, enable support for GigaDevice, 
Macronix, and Winbond nor flash chips.

Signed-off-by: Ludwig Zenz 
---
 configs/dh_imx6_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/configs/dh_imx6_defconfig b/configs/dh_imx6_defconfig
index db1460b..8f45531 100644
--- a/configs/dh_imx6_defconfig
+++ b/configs/dh_imx6_defconfig
@@ -39,7 +39,10 @@ CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_SYS_BOOTCOUNT_ADDR=0x0090
 CONFIG_FSL_ESDHC=y
 CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_GIGADEVICE=y
+CONFIG_SPI_FLASH_MACRONIX=y
 CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_PHYLIB=y
 CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
-- 
2.7.4

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


Re: [U-Boot] adout specification ram size before boot linux

2018-07-06 Thread Lukasz Majewski
On Thu, 5 Jul 2018 10:38:47 +0800
 wrote:

> Hello!!
> 
>  
> 
> We using zenq_7z010 board,  
> 
> We have some question,  
> 
> How setting RAM size to 64M for linux kernel before linux kenerl ?

You may modify the bootargs variable in u-boot to pass mem=

https://www.kernel.org/doc/html/v4.14/admin-guide/kernel-parameters.html

> 
>  
> 
> Thanks !
> 
>  
> 
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de


pgpei55FX1LBs.pgp
Description: OpenPGP digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] doc: driver-model: Fix typo

2018-07-06 Thread Chris Packham
Signed-off-by: Chris Packham 
---

 doc/driver-model/README.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/driver-model/README.txt b/doc/driver-model/README.txt
index 0853477578ac..d6fa5c485793 100644
--- a/doc/driver-model/README.txt
+++ b/doc/driver-model/README.txt
@@ -695,7 +695,7 @@ steps (see device_probe()):
allocate it yourself in ofdata_to_platdata(). Note that it is preferable
to do all the device tree decoding in ofdata_to_platdata() rather than
in probe(). (Apart from the ugliness of mixing configuration and run-time
-   data, one day it is possible that U-Boot will cache platformat data for
+   data, one day it is possible that U-Boot will cache platform data for
devices which are regularly de/activated).
 
h. The device's probe() method is called. This should do anything that
-- 
2.18.0

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


[U-Boot] [PATCH] tegra: p2771: Add CONFIG_EFI_LOADER_BOUNCE_BUFFER

2018-07-06 Thread Peter Robinson
The Jetson TX2 needs EFI loader bounce buffer enabled otherwise grub doesn't see
the storage when it loads.

Signed-off-by: Peter Robinson 
---
 configs/p2771--000_defconfig | 1 +
 configs/p2771--500_defconfig | 1 +
 2 files changed, 2 insertions(+)

diff --git a/configs/p2771--000_defconfig b/configs/p2771--000_defconfig
index 29e1edcd68f..7ed036dc4ce 100644
--- a/configs/p2771--000_defconfig
+++ b/configs/p2771--000_defconfig
@@ -4,6 +4,7 @@ CONFIG_SYS_TEXT_BASE=0x8008
 CONFIG_TEGRA186=y
 CONFIG_DEFAULT_DEVICE_TREE="tegra186-p2771--000"
 CONFIG_OF_SYSTEM_SETUP=y
+CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
 CONFIG_CONSOLE_MUX=y
 CONFIG_SYS_STDIO_DEREGISTER=y
 CONFIG_SYS_PROMPT="Tegra186 (P2771--000) # "
diff --git a/configs/p2771--500_defconfig b/configs/p2771--500_defconfig
index cc10669608f..9ae61263b5d 100644
--- a/configs/p2771--500_defconfig
+++ b/configs/p2771--500_defconfig
@@ -4,6 +4,7 @@ CONFIG_SYS_TEXT_BASE=0x8008
 CONFIG_TEGRA186=y
 CONFIG_DEFAULT_DEVICE_TREE="tegra186-p2771--500"
 CONFIG_OF_SYSTEM_SETUP=y
+CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
 CONFIG_CONSOLE_MUX=y
 CONFIG_SYS_STDIO_DEREGISTER=y
 CONFIG_SYS_PROMPT="Tegra186 (P2771--500) # "
-- 
2.17.1

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


[U-Boot] [PATCH 3/3] net: zynq_gem: convert to use livetree

2018-07-06 Thread Siva Durga Prasad Paladugu
This patch updates the zynq gem driver to support
livetree.

Signed-off-by: Siva Durga Prasad Paladugu 
Signed-off-by: Vipul Kumar 
---
 drivers/net/zynq_gem.c | 29 ++---
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c
index a817f2e..b9858e4 100644
--- a/drivers/net/zynq_gem.c
+++ b/drivers/net/zynq_gem.c
@@ -178,7 +178,7 @@ struct zynq_gem_priv {
struct zynq_gem_regs *iobase;
phy_interface_t interface;
struct phy_device *phydev;
-   int phy_of_handle;
+   ofnode phy_of_node;
struct mii_dev *bus;
struct clk clk;
u32 max_speed;
@@ -349,8 +349,7 @@ static int zynq_phy_init(struct udevice *dev)
 
priv->phydev->advertising = priv->phydev->supported;
 
-   if (priv->phy_of_handle > 0)
-   dev_set_of_offset(priv->phydev->dev, priv->phy_of_handle);
+   priv->phydev->dev->node = priv->phy_of_node;
 
return phy_config(priv->phydev);
 }
@@ -693,21 +692,23 @@ static int zynq_gem_ofdata_to_platdata(struct udevice 
*dev)
 {
struct eth_pdata *pdata = dev_get_platdata(dev);
struct zynq_gem_priv *priv = dev_get_priv(dev);
-   int node = dev_of_offset(dev);
+   struct ofnode_phandle_args phandle_args;
const char *phy_mode;
 
-   pdata->iobase = (phys_addr_t)devfdt_get_addr(dev);
+   pdata->iobase = (phys_addr_t)dev_read_addr(dev);
priv->iobase = (struct zynq_gem_regs *)pdata->iobase;
/* Hardcode for now */
priv->phyaddr = -1;
 
-   priv->phy_of_handle = fdtdec_lookup_phandle(gd->fdt_blob, node,
-   "phy-handle");
-   if (priv->phy_of_handle > 0)
-   priv->phyaddr = fdtdec_get_int(gd->fdt_blob,
-   priv->phy_of_handle, "reg", -1);
+   if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
+  _args)) {
+   debug("phy-handle does not exist %s\n", dev->name);
+   return -ENOENT;
+   }
 
-   phy_mode = fdt_getprop(gd->fdt_blob, node, "phy-mode", NULL);
+   priv->phyaddr = ofnode_read_u32_default(phandle_args.node, "reg", -1);
+   priv->phy_of_node = phandle_args.node;
+   phy_mode = dev_read_prop(dev, "phy-mode", NULL);
if (phy_mode)
pdata->phy_interface = phy_get_interface_by_name(phy_mode);
if (pdata->phy_interface == -1) {
@@ -716,10 +717,8 @@ static int zynq_gem_ofdata_to_platdata(struct udevice *dev)
}
priv->interface = pdata->phy_interface;
 
-   priv->max_speed = fdtdec_get_uint(gd->fdt_blob, priv->phy_of_handle,
- "max-speed", SPEED_1000);
-   priv->int_pcs = fdtdec_get_bool(gd->fdt_blob, node,
-   "is-internal-pcspma");
+   priv->max_speed = dev_read_u32_default(dev, "max-speed", SPEED_1000);
+   priv->int_pcs = dev_read_bool(dev, "is-internal-pcspma");
 
printf("ZYNQ GEM: %lx, phyaddr %x, interface %s\n", (ulong)priv->iobase,
   priv->phyaddr, phy_string_for_interface(priv->interface));
-- 
2.7.4

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


[U-Boot] [PATCH 1/3] net: phy: ti: Modify to support livetree

2018-07-06 Thread Siva Durga Prasad Paladugu
This patch adds support for livetree by using
dev_.. calls instead of fdtdec_..

Signed-off-by: Siva Durga Prasad Paladugu 
---
 drivers/net/phy/ti.c | 16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/net/phy/ti.c b/drivers/net/phy/ti.c
index 8f3ed8a..945d9e9 100644
--- a/drivers/net/phy/ti.c
+++ b/drivers/net/phy/ti.c
@@ -173,24 +173,22 @@ static int dp83867_of_init(struct phy_device *phydev)
 {
struct dp83867_private *dp83867 = phydev->priv;
struct udevice *dev = phydev->dev;
-   int node = dev_of_offset(dev);
const void *fdt = gd->fdt_blob;
 
-   if (fdtdec_get_bool(fdt, node, "ti,max-output-impedance"))
+   if (dev_read_bool(dev, "ti,max-output-impedance"))
dp83867->io_impedance = DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX;
-   else if (fdtdec_get_bool(fdt, node, "ti,min-output-impedance"))
+   else if (dev_read_bool(dev, "ti,min-output-impedance"))
dp83867->io_impedance = DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN;
else
dp83867->io_impedance = -EINVAL;
 
-   dp83867->rx_id_delay = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
-"ti,rx-internal-delay", -1);
+   dp83867->rx_id_delay = dev_read_u32_default(dev, "ti,rx-internal-delay",
+   -1);
 
-   dp83867->tx_id_delay = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
-"ti,tx-internal-delay", -1);
+   dp83867->tx_id_delay = dev_read_u32_default(dev, "ti,tx-internal-delay",
+   -1);
 
-   dp83867->fifo_depth = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
-"ti,fifo-depth", -1);
+   dp83867->fifo_depth = dev_read_u32_default(dev, "ti,fifo-depth", -1);
 
return 0;
 }
-- 
2.7.4

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


[U-Boot] [PATCH 2/3] net: phy: xilinx_phy: Add suuport for livetree

2018-07-06 Thread Siva Durga Prasad Paladugu
This patch adds support for livetree by using dev_..
calls instead of fdtdec_.. .

Signed-off-by: Siva Durga Prasad Paladugu 
---
 drivers/net/phy/xilinx_phy.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/xilinx_phy.c b/drivers/net/phy/xilinx_phy.c
index 004cfcf..2e2a5cd 100644
--- a/drivers/net/phy/xilinx_phy.c
+++ b/drivers/net/phy/xilinx_phy.c
@@ -103,8 +103,8 @@ static int xilinxphy_of_init(struct phy_device *phydev)
u32 phytype;
 
debug("%s\n", __func__);
-   phytype = fdtdec_get_int(gd->fdt_blob, dev_of_offset(phydev->dev),
-"xlnx,phy-type", -1);
+   phytype = dev_read_u32_default(phydev->dev,
+  "xlnx,phy-type", -1);
if (phytype == XAE_PHY_TYPE_1000BASE_X)
phydev->flags |= XAE_PHY_TYPE_1000BASE_X;
 
-- 
2.7.4

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


[U-Boot] Problem with Travis-Ci

2018-07-06 Thread Lukasz Majewski
Hi Tom,

I've performed the travis-ci build for some USB gadget related code:

https://travis-ci.org/lmajewski/u-boot-dfu/jobs/400649043

And for some tasks (e.g. BUILDMAN="sun50i") I do see following errors:

The following NEW packages will be installed:
  libisl15
0 upgraded, 1 newly installed, 0 to remove and 220 not upgraded.
Need to get 507 kB of archives.
After this operation, 1,691 kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
  libisl15
E: There were unauthenticated packages and -y was used without
--allow-unauthenticated The command "sudo apt-get install libisl15 -y"
failed and exited with 100 during .

Have you seen them before?


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de


pgpwHo4NZJ3QF.pgp
Description: OpenPGP digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 6/6] common: Generic loader for file system

2018-07-06 Thread tien . fong . chee
From: Tien Fong Chee 

This is file system generic loader which can be used to load
the file image from the storage into target such as memory.
The consumer driver would then use this loader to program whatever,
ie. the FPGA device.

Signed-off-by: Tien Fong Chee 
---
 drivers/misc/Kconfig |  10 ++
 drivers/misc/Makefile|   1 +
 drivers/misc/fs_loader.c | 295 +++
 include/dm/uclass-id.h   |   1 +
 include/fs_loader.h  |  79 +
 5 files changed, 386 insertions(+)
 create mode 100644 drivers/misc/fs_loader.c
 create mode 100644 include/fs_loader.h

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 17b3a80..4163b4f 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -277,4 +277,14 @@ config GDSYS_RXAUI_CTRL
depends on MISC
help
  Support gdsys FPGA's RXAUI control.
+
+config FS_LOADER
+   bool "Enable loader driver for file system"
+   help
+ This is file system generic loader which can be used to load
+ the file image from the storage into target such as memory.
+
+ The consumer driver would then use this loader to program whatever,
+ ie. the FPGA device.
+
 endmenu
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 4ce9d21..67a36f8 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -54,3 +54,4 @@ obj-$(CONFIG_STM32_RCC) += stm32_rcc.o
 obj-$(CONFIG_STM32MP_FUSE) += stm32mp_fuse.o
 obj-$(CONFIG_SYS_DPAA_QBMAN) += fsl_portals.o
 obj-$(CONFIG_GDSYS_RXAUI_CTRL) += gdsys_rxaui_ctrl.o
+obj-$(CONFIG_FS_LOADER) += fs_loader.o
diff --git a/drivers/misc/fs_loader.c b/drivers/misc/fs_loader.c
new file mode 100644
index 000..5fe642b
--- /dev/null
+++ b/drivers/misc/fs_loader.c
@@ -0,0 +1,295 @@
+/*
+ * Copyright (C) 2018 Intel Corporation 
+ *
+ * SPDX-License-Identifier:GPL-2.0
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct firmware_priv {
+   const char *name;   /* Filename */
+   u32 offset; /* Offset of reading a file */
+};
+
+#ifdef CONFIG_CMD_UBIFS
+static int mount_ubifs(char *mtdpart, char *ubivol)
+{
+   int ret = ubi_part(mtdpart, NULL);
+
+   if (ret) {
+   debug("Cannot find mtd partition %s\n", mtdpart);
+   return ret;
+   }
+
+   return cmd_ubifs_mount(ubivol);
+}
+
+static int umount_ubifs(void)
+{
+   return cmd_ubifs_umount();
+}
+#else
+static int mount_ubifs(char *mtdpart, char *ubivol)
+{
+   debug("Error: Cannot load image: no UBIFS support\n");
+   return -ENOSYS;
+}
+#endif
+
+static int select_fs_dev(struct device_platdata *plat)
+{
+   int ret;
+
+   if (plat->phandlepart.phandle) {
+   ofnode node;
+
+   node = ofnode_get_by_phandle(plat->phandlepart.phandle);
+
+   int of_offset = ofnode_to_offset(node);
+
+   struct udevice *dev;
+
+   ret = device_get_global_by_of_offset(of_offset, );
+   if (!ret) {
+   struct blk_desc *desc = blk_get_by_device(dev);
+   if (desc) {
+   ret = fs_set_blk_dev_with_part(desc,
+   plat->phandlepart.partition);
+   } else {
+   debug("%s: No device found\n", __func__);
+   return -ENODEV;
+   }
+   }
+   } else if (plat->mtdpart && plat->ubivol) {
+   ret = mount_ubifs(plat->mtdpart, plat->ubivol);
+   if (ret)
+   return ret;
+
+   ret = fs_set_blk_dev("ubi", NULL, FS_TYPE_UBIFS);
+   } else {
+   debug("Error: unsupported storage device.\n");
+   return -ENODEV;
+   }
+
+   if (ret)
+   debug("Error: could not access storage.\n");
+
+   return ret;
+}
+
+/**
+ * _request_firmware_prepare - Prepare firmware struct.
+ *
+ * @name: Name of firmware file.
+ * @dbuf: Address of buffer to load firmware into.
+ * @size: Size of buffer.
+ * @offset: Offset of a file for start reading into buffer.
+ * @firmwarep: Pointer to pointer to firmware image.
+ *
+ * Return: Negative value if fail, 0 for successful.
+ */
+static int _request_firmware_prepare(const char *name, void *dbuf,
+   size_t size, u32 offset,
+   struct firmware **firmwarep)
+{
+   if (!name || name[0] == '\0')
+   return -EINVAL;
+
+   /* No memory allocation is required if *firmwarep is allocated */
+   if (!(*firmwarep)) {
+   (*firmwarep) = calloc(1, sizeof(struct firmware));
+   if (!(*firmwarep))
+   return -ENOMEM;
+
+   (*firmwarep)->priv = calloc(1, sizeof(struct firmware_priv));
+  

[U-Boot] [PATCH v4 5/6] doc: dtbinding: Add file system firmware loader binding document

2018-07-06 Thread tien . fong . chee
From: Tien Fong Chee 

Add a document to describe file system firmware loader binding
information.

Signed-off-by: Tien Fong Chee 
---
 doc/device-tree-bindings/chosen.txt | 21 +
 doc/device-tree-bindings/misc/fs_loader.txt | 48 +
 2 files changed, 69 insertions(+)
 create mode 100644 doc/device-tree-bindings/misc/fs_loader.txt

diff --git a/doc/device-tree-bindings/chosen.txt 
b/doc/device-tree-bindings/chosen.txt
index c96b8f7..dbce047 100644
--- a/doc/device-tree-bindings/chosen.txt
+++ b/doc/device-tree-bindings/chosen.txt
@@ -73,3 +73,24 @@ Example
u-boot,spl-boot-order = "same-as-spl", , 
"/sdhci@fe33";
};
 };
+
+firmware-loader property
+
+Multiple file system firmware loader nodes could be defined in device trees for
+multiple storage type and their default partition, then a property
+"firmware-loader" can be used to pass default firmware loader
+node(default storage type) to the firmware loader driver.
+
+Example
+---
+/ {
+   chosen {
+   firmware-loader = _loader0;
+   };
+
+   fs_loader0: fs-loader@0 {
+   u-boot,dm-pre-reloc;
+   compatible = "u-boot,fs-loader";
+   phandlepart = < 1>;
+   };
+};
diff --git a/doc/device-tree-bindings/misc/fs_loader.txt 
b/doc/device-tree-bindings/misc/fs_loader.txt
new file mode 100644
index 000..884fbf4
--- /dev/null
+++ b/doc/device-tree-bindings/misc/fs_loader.txt
@@ -0,0 +1,48 @@
+* File system firmware loader
+
+Required properties:
+
+
+- compatible: should contain "u-boot,fs-loader"
+- phandlepart: which block storage device and partition the image loading from,
+  this property is required for mmc, usb and sata. This is unsigned
+  32-bit array. For example phandlepart=<_0 1>, meaning use
+  that MMC0 node pointer, partition 1.
+- mdtpart: which partition of ubi the image loading from, this property is
+  required for ubi and mounting.
+- ubivol: which volume of ubi the image loading from, this property is required
+ for ubi and mounting.
+
+Example of storage device and partition search set for mmc, usb, sata and
+ubi in device tree source as shown in below:
+
+   Example of storage type and device partition search set for mmc, usb,
+   sata and ubi as shown in below:
+   Example for mmc:
+   fs_loader0: fs-loader@0 {
+   u-boot,dm-pre-reloc;
+   compatible = "u-boot,fs-loader";
+   phandlepart = <_0 1>;
+   };
+
+   Example for usb:
+   fs_loader1: fs-loader@1 {
+   u-boot,dm-pre-reloc;
+   compatible = "u-boot,fs-loader";
+   phandlepart = < 1>;
+   };
+
+   Example for sata:
+   fs_loader2: fs-loader@2 {
+   u-boot,dm-pre-reloc;
+   compatible = "u-boot,fs-loader";
+   phandlepart = < 1>;
+   };
+
+   Example for ubi:
+   fs_loader3: fs-loader@3 {
+   u-boot,dm-pre-reloc;
+   compatible = "u-boot,fs-loader";
+   mtdpart = "UBI",
+   ubivol = "ubi0";
+   };
-- 
2.2.0

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


[U-Boot] [PATCH v4 3/6] block: Add a function to find block device descriptor

2018-07-06 Thread tien . fong . chee
From: Tien Fong Chee 

Add a function to find the block device descriptor of the parent
device.

Signed-off-by: Tien Fong Chee 
---
 drivers/block/blk-uclass.c | 23 +++
 include/blk.h  |  9 +
 2 files changed, 32 insertions(+)

diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 9e0c823..facf527 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -132,6 +132,29 @@ struct blk_desc *blk_get_devnum_by_typename(const char 
*if_typename, int devnum)
 }
 
 /**
+ * blk_get_by_device() - Get the block device descriptor for the given device
+ * @dev:   Instance of a storage device
+ *
+ * Return: With block device descriptor on success , NULL if there is no such
+ *block device.
+ */
+struct blk_desc *blk_get_by_device(struct udevice *dev)
+{
+   struct udevice *child_dev, *next;
+
+   device_foreach_child_safe(child_dev, next, dev) {
+   if (device_get_uclass_id(child_dev) != UCLASS_BLK)
+   continue;
+
+   return dev_get_uclass_platdata(child_dev);
+   }
+
+   debug("%s: No block device found\n", __func__);
+
+   return NULL;
+}
+
+/**
  * get_desc() - Get the block device descriptor for the given device number
  *
  * @if_type:   Interface type
diff --git a/include/blk.h b/include/blk.h
index 86f6d50..8ba9ab9 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -541,6 +541,15 @@ struct blk_desc *blk_get_devnum_by_typename(const char 
*if_typename,
int devnum);
 
 /**
+ * blk_get_by_device() - Get the block device descriptor for the given device
+ * @dev:   Instance of a storage device
+ *
+ * Return: With block device descriptor on success , NULL if there is no such
+ *block device.
+ */
+struct blk_desc *blk_get_by_device(struct udevice *dev);
+
+/**
  * blk_dselect_hwpart() - select a hardware partition
  *
  * This selects a hardware partition (such as is supported by MMC). The block
-- 
2.2.0

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


[U-Boot] [PATCH v4 4/6] doc: Add new doc for file system firmware loader driver model

2018-07-06 Thread tien . fong . chee
From: Tien Fong Chee 

Provide information about

- overview of file system firmware loader driver model
- describe storage device and partition in device tree source
- describe fie system firmware loader API

Signed-off-by: Tien Fong Chee 
---
 doc/driver-model/fs_firmware_loader.txt | 133 
 1 file changed, 133 insertions(+)
 create mode 100644 doc/driver-model/fs_firmware_loader.txt

diff --git a/doc/driver-model/fs_firmware_loader.txt 
b/doc/driver-model/fs_firmware_loader.txt
new file mode 100644
index 000..290915a
--- /dev/null
+++ b/doc/driver-model/fs_firmware_loader.txt
@@ -0,0 +1,133 @@
+# Copyright (C) 2018 Intel Corporation 
+#
+# SPDX-License-Identifier:GPL-2.0
+
+Introduction
+
+
+This is file system firmware loader for U-Boot framework, which has very close
+to some Linux Firmware API. For the details of Linux Firmware API, you can 
refer
+to https://01.org/linuxgraphics/gfx-docs/drm/driver-api/firmware/index.html.
+
+File system firmware loader can be used to load whatever(firmware, image,
+and binary) from the storage device in file system format into target location
+such as memory, then consumer driver such as FPGA driver can program FPGA image
+from the target location into FPGA.
+
+To enable firmware loader, CONFIG_FS_LOADER need to be set at
+_defconfig such as "CONFIG_FS_LOADER=y".
+
+Firmware Loader API core features
+-
+
+Firmware storage device described in device tree source
+---
+   For passing data like storage device phandle and partition where the
+   firmware loading from to the firmware loader driver, those data could be
+   defined in fs-loader node as shown in below:
+
+   Example for block device:
+   fs_loader0: fs-loader@0 {
+   u-boot,dm-pre-reloc;
+   compatible = "u-boot,fs-loader";
+   phandlepart = < 1>;
+   };
+
+   < 1> means block storage device pointer and its partition.
+
+   Above example is a description for block storage, but for UBI storage
+   device, it can be described in FDT as shown in below:
+
+   Example for ubi:
+   fs_loader1: fs-loader@1 {
+   u-boot,dm-pre-reloc;
+   compatible = "u-boot,fs-loader";
+   mtdpart = "UBI",
+   ubivol = "ubi0";
+   };
+
+   Then, firmware_loader property would be set with the path of fs_loader
+   node under /chosen node such as:
+   /{
+   chosen {
+   firmware_loader = _loader0;
+   };
+   };
+
+   However, this driver is also designed to support U-boot environment
+   variables, so all these data from FDT can be overwritten
+   through the U-boot environment variable during run time.
+   For examples:
+   "storage_interface" - Storage interface, it can be "mmc", "usb", "sata"
+ or "ubi".
+   "fw_dev_part" - Block device number and its partition, it can be "0:1".
+   "fw_ubi_mtdpart" - UBI device mtd partition, it can be "UBI".
+   "fw_ubi_volume" - UBI volume, it can be "ubi0".
+
+   When above environment variables are set, environment values would be
+   used instead of data from FDT.
+   The benefit of this design allows user to change storage attribute data
+   at run time through U-boot console and saving the setting as default
+   environment values in the storage for the next power cycle, so no
+   compilation is required for both driver and FDT.
+
+File system firmware Loader API
+---
+
+int request_firmware_into_buf(struct device_platdata *plat,
+const char *name,
+void *buf, size_t size, u32 offset,
+struct firmware **firmwarep)
+
+Load firmware into a previously allocated buffer
+
+Parameters:
+
+1. struct device_platdata *plat
+   Platform data such as storage and partition firmware loading from
+
+2. const char *name
+   name of firmware file
+
+3. void *buf
+   address of buffer to load firmware into
+
+4. size_t size
+   size of buffer
+
+5. u32 offset
+   offset of a file for start reading into buffer
+
+6. struct firmware **firmwarep
+   pointer to firmware image
+
+return:
+   size of total read
+   -ve when error
+
+Description:
+   The firmware is loaded directly into the buffer pointed to by buf and
+   the @firmwarep data member is pointed at buf
+
+Note: Memory would be allocated for firmware image, hence user should
+ free() *firmwarep and *firmwarep->priv structs after usage of
+ request_firmware_into_buf(), otherwise it will always leak memory
+ while subsequent calls of request_firmware_into_buf() with the same

[U-Boot] [PATCH v4 2/6] cmd: ubifs: Factor out some checking codes into cmd_ubifs_mount()

2018-07-06 Thread tien . fong . chee
From: Tien Fong Chee 

cmd_ubifs_mount() function would be called directly instead of
involving whole command machinery for mounting ubifs in
generic firmware loader, so some checking codes need to be factored out
into cmd_ubifs_mount() without breaking original functionality design.

Signed-off-by: Tien Fong Chee 
Reviewed-by: Marek Vasut 
---
 cmd/ubifs.c | 22 ++
 include/ubi_uboot.h |  1 +
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/cmd/ubifs.c b/cmd/ubifs.c
index 1710348..e4000b7 100644
--- a/cmd/ubifs.c
+++ b/cmd/ubifs.c
@@ -19,16 +19,10 @@
 static int ubifs_initialized;
 static int ubifs_mounted;
 
-static int do_ubifs_mount(cmd_tbl_t *cmdtp, int flag, int argc,
-   char * const argv[])
+int cmd_ubifs_mount(char *vol_name)
 {
-   char *vol_name;
int ret;
 
-   if (argc != 2)
-   return CMD_RET_USAGE;
-
-   vol_name = argv[1];
debug("Using volume %s\n", vol_name);
 
if (ubifs_initialized == 0) {
@@ -42,7 +36,19 @@ static int do_ubifs_mount(cmd_tbl_t *cmdtp, int flag, int 
argc,
 
ubifs_mounted = 1;
 
-   return 0;
+   return ret;
+}
+static int do_ubifs_mount(cmd_tbl_t *cmdtp, int flag, int argc,
+   char * const argv[])
+{
+   char *vol_name;
+
+   if (argc != 2)
+   return CMD_RET_USAGE;
+
+   vol_name = argv[1];
+
+   return cmd_ubifs_mount(vol_name);
 }
 
 int ubifs_is_mounted(void)
diff --git a/include/ubi_uboot.h b/include/ubi_uboot.h
index 827dbfc..0770228 100644
--- a/include/ubi_uboot.h
+++ b/include/ubi_uboot.h
@@ -75,6 +75,7 @@ extern int ubi_volume_write(char *volume, void *buf, size_t 
size);
 extern int ubi_volume_read(char *volume, char *buf, size_t size);
 
 extern struct ubi_device *ubi_devices[];
+int cmd_ubifs_mount(char *vol_name);
 int cmd_ubifs_umount(void);
 
 #endif
-- 
2.2.0

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


[U-Boot] [PATCH v4 1/6] cmd: ubifs: Move ubifs_initialized checking into cmd_ubifs_umount()

2018-07-06 Thread tien . fong . chee
From: Tien Fong Chee 

cmd_ubifs_umount() function would be called directly instead of involving
whole command machinery in generic firmware loader, so checking on
ubifs_initialized status need to be done in cmd_ubifs_umount() without
breaking original functionality design.

Signed-off-by: Tien Fong Chee 
Reviewed-by: Marek Vasut 
---
 cmd/ubifs.c | 18 +-
 include/ubi_uboot.h |  1 +
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/cmd/ubifs.c b/cmd/ubifs.c
index 11bab7a..1710348 100644
--- a/cmd/ubifs.c
+++ b/cmd/ubifs.c
@@ -50,11 +50,18 @@ int ubifs_is_mounted(void)
return ubifs_mounted;
 }
 
-void cmd_ubifs_umount(void)
+int cmd_ubifs_umount(void)
 {
+   if (ubifs_initialized == 0) {
+   printf("No UBIFS volume mounted!\n");
+   return -1;
+   }
+
uboot_ubifs_umount();
ubifs_mounted = 0;
ubifs_initialized = 0;
+
+   return 0;
 }
 
 static int do_ubifs_umount(cmd_tbl_t *cmdtp, int flag, int argc,
@@ -63,14 +70,7 @@ static int do_ubifs_umount(cmd_tbl_t *cmdtp, int flag, int 
argc,
if (argc != 1)
return CMD_RET_USAGE;
 
-   if (ubifs_initialized == 0) {
-   printf("No UBIFS volume mounted!\n");
-   return -1;
-   }
-
-   cmd_ubifs_umount();
-
-   return 0;
+   return cmd_ubifs_umount();
 }
 
 static int do_ubifs_ls(cmd_tbl_t *cmdtp, int flag, int argc,
diff --git a/include/ubi_uboot.h b/include/ubi_uboot.h
index 80acbcb..827dbfc 100644
--- a/include/ubi_uboot.h
+++ b/include/ubi_uboot.h
@@ -75,5 +75,6 @@ extern int ubi_volume_write(char *volume, void *buf, size_t 
size);
 extern int ubi_volume_read(char *volume, char *buf, size_t size);
 
 extern struct ubi_device *ubi_devices[];
+int cmd_ubifs_umount(void);
 
 #endif
-- 
2.2.0

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


[U-Boot] [PATCH v4 0/6] Generic file system firmware loader DM

2018-07-06 Thread tien . fong . chee
From: Tien Fong Chee 

This patchset contains generic file system loader DM which is very close to
Linux firmware loader but for U-Boot framework. Generic file system firmware
loader can be used load whatever into target location, and then consumer driver
would use it to program whatever, ie. the FPGA. This version mainly resolved
comments from Simon and Anatolij in [v3].
Patch set for sandbox will be sent out separately.

This series is working on top of u-boot-socfpga.git -
 http://git.denx.de/u-boot.git .

[v3]: https://www.mail-archive.com/u-boot@lists.denx.de/msg290433.html
[v2]: https://www.mail-archive.com/u-boot@lists.denx.de/msg286979.html
[v1]: https://www.mail-archive.com/u-boot@lists.denx.de/msg286294.html

v3 -> v4 changes

- Adding mounting and unmounting for UBI.
- Adding some new enviroment variables.
- Removed storage_device from FDT.
- devpart from fdt changed to phandlepart for supporting block device node
  pointer and partition.
- Adding new function for getting block device description based on device.
- Adding new function for freeing firmware buffer.
- Update firmware doc and device tree binding doc.

Tien Fong Chee (6):
  cmd: ubifs: Move ubifs_initialized checking into cmd_ubifs_umount()
  cmd: ubifs: Factor out some checking codes into cmd_ubifs_mount()
  block: Add a function to find block device descriptor
  doc: Add new doc for file system firmware loader driver model
  doc: dtbinding: Add file system firmware loader binding document
  common: Generic loader for file system

 cmd/ubifs.c |  40 ++--
 doc/device-tree-bindings/chosen.txt |  21 ++
 doc/device-tree-bindings/misc/fs_loader.txt |  48 +
 doc/driver-model/fs_firmware_loader.txt | 133 +
 drivers/block/blk-uclass.c  |  23 +++
 drivers/misc/Kconfig|  10 +
 drivers/misc/Makefile   |   1 +
 drivers/misc/fs_loader.c| 295 
 include/blk.h   |   9 +
 include/dm/uclass-id.h  |   1 +
 include/fs_loader.h |  79 
 include/ubi_uboot.h |   2 +
 12 files changed, 645 insertions(+), 17 deletions(-)
 create mode 100644 doc/device-tree-bindings/misc/fs_loader.txt
 create mode 100644 doc/driver-model/fs_firmware_loader.txt
 create mode 100644 drivers/misc/fs_loader.c
 create mode 100644 include/fs_loader.h

-- 
2.2.0

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


Re: [U-Boot] [PATCH v3] spi: cadence_qspi: Fix compilation warning

2018-07-06 Thread Marek Vasut
On 07/06/2018 04:39 AM, Ley Foon Tan wrote:
> Use "%zu" for size_t data type.
> 
> Compilation warning as below:
> 
> In file included from include/linux/bug.h:7:0,
>  from include/common.h:26,
>  from drivers/spi/cadence_qspi.c:8:
> drivers/spi/cadence_qspi.c: In function ‘cadence_spi_xfer’:
> drivers/spi/cadence_qspi.c:211:8: warning: format ‘%d’ expects argument of 
> type ‘int’, but argument 3 has type ‘size_t {aka long unsigned int}’ 
> [-Wformat=]
>   debug("%s: len=%d [bytes]\n", __func__, data_bytes);
> ^
> include/linux/printk.h:37:21: note: in definition of macro ‘pr_fmt’
>  #define pr_fmt(fmt) fmt
>  ^~~
> include/log.h:142:2: note: in expansion of macro ‘debug_cond’
>   debug_cond(_DEBUG, fmt, ##args)
>   ^~
> drivers/spi/cadence_qspi.c:211:2: note: in expansion of macro ‘debug’
>   debug("%s: len=%d [bytes]\n", __func__, data_bytes);
> 
> Signed-off-by: Ley Foon Tan 
> Acked-by: Marek Vasut 

I replaced the V2 with this in u-boot-socfpga/master, so let's see.

> ---
> 
> v1: Cast data_byte to integet
> v2: Use "%lu"
> v3: Still have compilation warning with "%lu" in Cyclone V build.
> So, change to use "%zu" for size_t type.
> ---
>  drivers/spi/cadence_qspi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/cadence_qspi.c b/drivers/spi/cadence_qspi.c
> index 91742ba..29db6fa 100644
> --- a/drivers/spi/cadence_qspi.c
> +++ b/drivers/spi/cadence_qspi.c
> @@ -207,7 +207,7 @@ static int cadence_spi_xfer(struct udevice *dev, unsigned 
> int bitlen,
>   } else {
>   data_bytes = bitlen / 8;
>   }
> - debug("%s: len=%d [bytes]\n", __func__, data_bytes);
> + debug("%s: len=%zu [bytes]\n", __func__, data_bytes);
>  
>   /* Set Chip select */
>   cadence_qspi_apb_chipselect(base, spi_chip_select(dev),
> 


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


Re: [U-Boot] [PATCH v2 3/3] efi_selftest: unit test for CalculateCrc32()

2018-07-06 Thread Heinrich Schuchardt
On 07/06/2018 07:24 AM, Alexander Graf wrote:
> 
> 
> On 06.07.18 07:09, Heinrich Schuchardt wrote:
>> This unit test checks the CalculateCrc32 bootservice and checks the
>> headers of the system table, the boot services tablle, and the runtime
>> services table before and after ExitBootServices().
>>
>> Signed-off-by: Heinrich Schuchardt 
> 
> This is a good step forward, thanks!
> 
> I still don't see any code that adapts the systab crc in
> efi_install_configuration_table(), so we're clearly missing a test case
> for this.

You are right. We are changing the field NumberOfTableEntries which is
part of the crc32. The field ConfigurationTable is currently not changed.

Best regards

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


Re: [U-Boot] [PATCH v3] tegra: nyan-big: Update CONFIG_SYS_TEXT to the default in README.chromium

2018-07-06 Thread Peter Robinson
Tom,

Ping, could we get this applied please?

Peter

On Sun, Jun 10, 2018 at 6:17 AM, Peter Robinson  wrote:
> To build U-Boot on a Nyan Big Chromebook the docs outline adjusting the 
> Tegra124
> defined CONFIG_SYS_TEXT_BASE but this has since been moved to individual 
> config
> files. We should have the default required for U-Boot chain loading on the
> chromebook as the default CONFIG_SYS_TEXT_BASE and update the docs to remove
> this now non required step.
>
> Signed-off-by: Peter Robinson 
> ---
>
> v3: Update commit message
> v2: Update to 2018.07 RC1
>
>  configs/nyan-big_defconfig |  2 +-
>  doc/README.chromium| 27 +++
>  2 files changed, 8 insertions(+), 21 deletions(-)
>
> diff --git a/configs/nyan-big_defconfig b/configs/nyan-big_defconfig
> index 8868d1f9e10..3b64c643716 100644
> --- a/configs/nyan-big_defconfig
> +++ b/configs/nyan-big_defconfig
> @@ -1,6 +1,6 @@
>  CONFIG_ARM=y
>  CONFIG_TEGRA=y
> -CONFIG_SYS_TEXT_BASE=0x8011
> +CONFIG_SYS_TEXT_BASE=0x81000100
>  CONFIG_DEBUG_UART_BASE=0x70006000
>  CONFIG_DEBUG_UART_CLOCK=40800
>  CONFIG_TEGRA124=y
> diff --git a/doc/README.chromium b/doc/README.chromium
> index 7bf4d874474..45eaeced2da 100644
> --- a/doc/README.chromium
> +++ b/doc/README.chromium
> @@ -43,26 +43,13 @@ 
> https://git.collabora.com/cgit/user/tomeu/u-boot.git/commit/?h=nyan-big
>  https://lists.denx.de/pipermail/u-boot/2017-May/289491.html
>  
> https://github.com/chromeos-nvidia-androidtv/gnu-linux-on-acer-chromebook-13#copy-data-to-the-sd-card
>
> -1. Patch U-Boot
> -
> -Open include/configs/tegra124-common.h
> -
> -Change:
> -
> -#define CONFIG_SYS_TEXT_BASE   0x8011
> -
> -to:
> -
> -#define CONFIG_SYS_TEXT_BASE   0x81000100
> -
> -
> -2. Build U-Boot
> +1. Build U-Boot
>
> mkdir b
> make -j8 O=b/nyan-big CROSS_COMPILE=arm-linux-gnueabi- nyan-big_defconfig 
> all
>
>
> -3. Select a .its file
> +2. Select a .its file
>
>  Select something from doc/chromium which matches your board, or create your
>  own.
> @@ -72,7 +59,7 @@ used by U-Boot. This is because the Chromebook expects to 
> pass it to the
>  kernel, and crashes if it is not present.
>
>
> -4. Build and sign an image
> +3. Build and sign an image
>
> ./b/nyan-big/tools/mkimage -f doc/chromium/nyan-big.its 
> u-boot-chromium.fit
> echo test >dummy.txt
> @@ -82,7 +69,7 @@ kernel, and crashes if it is not present.
> --bootloader dummy.txt --pack u-boot.kpart
>
>
> -5. Prepare an SD card
> +4. Prepare an SD card
>
> DISK=/dev/sdc   # Replace with your actual SD card device
> sudo cgpt create $DISK
> @@ -91,12 +78,12 @@ kernel, and crashes if it is not present.
> sudo gdisk $DISK   # Enter command 'w' to write a protective MBR to the 
> disk
>
>
> -6. Write U-Boot to the SD card
> +5. Write U-Boot to the SD card
>
> sudo dd if=u-boot.kpart of=/dev/sdc1; sync
>
>
> -7. Start it up
> +6. Start it up
>
>  Reboot the device in dev mode. Make sure that you have USB booting enabled. 
> To
>  do this, login as root (via Ctrl-Alt-forward_arrow) and type
> @@ -115,7 +102,7 @@ mode screen. It should show something like the following 
> on the display:
> Tegra124 (Nyan-big) #
>
>
> -8. Known problems
> +7. Known problems
>
>  On the serial console the word MMC is chopped at the start of the line:
>
> --
> 2.17.1
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 1/2] spl: Fix redundant image of uboot

2018-07-06 Thread Michael Trimarchi
We need to address the redundat image case and undestand if the
image is corrupted or not. In error case we need to try the fallback copy.
The function used before was always return 0 without any evaluation of the
error. We try to make it work properly

Signed-off-by: Michael Trimarchi 
---
Changes V1->V2:
Address the comments on using the err variable
---
 common/spl/spl_nand.c | 34 +-
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
index 9a52500..109dd6e 100644
--- a/common/spl/spl_nand.c
+++ b/common/spl/spl_nand.c
@@ -44,9 +44,7 @@ static int spl_nand_load_element(struct spl_image_info 
*spl_image,
 {
int err;
 
-   err = nand_spl_load_image(offset, sizeof(*header), (void *)header);
-   if (err)
-   return err;
+   nand_spl_load_image(offset, sizeof(*header), (void *)header);
 
if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
image_get_magic(header) == FDT_MAGIC) {
@@ -59,13 +57,31 @@ static int spl_nand_load_element(struct spl_image_info 
*spl_image,
load.bl_len = 1;
load.read = spl_nand_fit_read;
return spl_load_simple_fit(spl_image, , offset, header);
-   } else {
-   err = spl_parse_image_header(spl_image, header);
-   if (err)
-   return err;
-   return nand_spl_load_image(offset, spl_image->size,
-  (void *)(ulong)spl_image->load_addr);
}
+   err = spl_parse_image_header(spl_image, header);
+   if (err)
+   return err;
+
+   nand_spl_load_image(offset, spl_image->size,
+  (void *)(ulong)spl_image->load_addr);
+
+   /*
+* Verify the crc of the header
+*/
+   if (!((const image_header_t *)spl_image->load_addr)) {
+   debug("Header checksum failed\n");
+   return -EINVAL;
+   }
+
+   /*
+* Verify the crc of the data
+*/
+   if (!image_check_dcrc((const image_header_t *)spl_image->load_addr)) {
+   debug("Image checksum failed\n");
+   return -EINVAL;
+   }
+
+   return 0;
 }
 
 static int spl_nand_load_image(struct spl_image_info *spl_image,
-- 
2.7.4

-- 
| Michael Nazzareno Trimarchi Amarula Solutions BV |
| COO  -  Founder  Cruquiuskade 47 |
| +31(0)851119172 Amsterdam 1018 AM NL |
|  [`as] http://www.amarulasolutions.com   |
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot