[PATCH 1/2] ARM: VFxxx: zii-vf610-dev: Add newline before error banner

2018-08-09 Thread Andrey Smirnov
Add a cosmetic newline to the beginning of the error banner printed
when we encounter unidentified board type. This way we'd avoid
artifacts like:

barebox@ZII RDU1 Board:/ >*
* Unknown system type: 0004

Signed-off-by: Andrey Smirnov 
---
 arch/arm/boards/zii-vf610-dev/lowlevel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boards/zii-vf610-dev/lowlevel.c 
b/arch/arm/boards/zii-vf610-dev/lowlevel.c
index f3d67501a..d2f30d7ab 100644
--- a/arch/arm/boards/zii-vf610-dev/lowlevel.c
+++ b/arch/arm/boards/zii-vf610-dev/lowlevel.c
@@ -111,7 +111,7 @@ ENTRY_FUNCTION(start_zii_vf610_dev, r0, r1, r2)
if (IS_ENABLED(CONFIG_DEBUG_LL)) {
relocate_to_current_adr();
setup_c();
-   puts_ll("*\n");
+   puts_ll("\n*\n");
puts_ll("* Unknown system type: ");
puthex_ll(system_type);
puts_ll("\n* Assuming devboard revision B\n");
-- 
2.17.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/2] ARM: VFxxx: zii-vf610-dev: Make get_sytem_type() static

2018-08-09 Thread Andrey Smirnov
There's no reason for that function to be non-static, so convert it.

Signed-off-by: Andrey Smirnov 
---
 arch/arm/boards/zii-vf610-dev/lowlevel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boards/zii-vf610-dev/lowlevel.c 
b/arch/arm/boards/zii-vf610-dev/lowlevel.c
index d2f30d7ab..c771d81cc 100644
--- a/arch/arm/boards/zii-vf610-dev/lowlevel.c
+++ b/arch/arm/boards/zii-vf610-dev/lowlevel.c
@@ -43,7 +43,7 @@ enum zii_platform_vf610_type {
ZII_PLATFORM_VF610_DEV_REV_C= 0x05,
 };
 
-unsigned int get_system_type(void)
+static unsigned int get_system_type(void)
 {
 #define GPIO_PDIR 0x10
 
-- 
2.17.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [RFC] Revert "i.MX: Add provisions to boot from IRAM"

2018-08-09 Thread Andrey Smirnov
On Thu, Jun 14, 2018 at 9:09 PM Andrey Smirnov  wrote:
>
> After being introduced 3 years ago this feature ended up being
> "obsoleted by events" and project it was supposed to be a part of
> winded down.
>
> Revert this feature due to:
>
>   a) Lack of users
>
>   b) Existence of better way to make barebox load via SRAM as
>   intermediary step that does not require two separate images to be
>   built (.imx-sram-img)
>
> This reverts commit 903c9477a08c5655161779ef4144886928ecc7d1.
> ---
>
> I am assuming that this feature was never used by anyone but me (hence
> a) above), so it should be safe to drop it. However if this feature is
> useful to anyone, I am more than happy to keep it.
>
> Thanks,
> Andrey Smirnov
>

Sascha, any comment on this?

>  Documentation/boards/imx.rst  | 27 -
>  .../arm/boards/freescale-mx51-babbage/board.c | 60 ---
>  .../flash-header-common.imxcfg| 58 --
>  .../flash-header-imx51-babbage-xload.imxcfg   |  3 -
>  .../flash-header-imx51-babbage.imxcfg | 60 ++-
>  .../boards/freescale-mx51-babbage/lowlevel.c  | 25 
>  arch/arm/configs/imx_v7-xload_defconfig   | 31 --
>  arch/arm/mach-imx/Kconfig | 15 -
>  arch/arm/mach-imx/Makefile|  1 -
>  arch/arm/mach-imx/xload.c | 52 
>  images/Makefile.imx   | 19 +-
>  11 files changed, 59 insertions(+), 292 deletions(-)
>  delete mode 100644 
> arch/arm/boards/freescale-mx51-babbage/flash-header-common.imxcfg
>  delete mode 100644 
> arch/arm/boards/freescale-mx51-babbage/flash-header-imx51-babbage-xload.imxcfg
>  delete mode 100644 arch/arm/configs/imx_v7-xload_defconfig
>  delete mode 100644 arch/arm/mach-imx/xload.c
>
> diff --git a/Documentation/boards/imx.rst b/Documentation/boards/imx.rst
> index b3002badf..73b0993ce 100644
> --- a/Documentation/boards/imx.rst
> +++ b/Documentation/boards/imx.rst
> @@ -105,33 +105,6 @@ Some notes about the mentioned *conditions*.
>   - ``until_any_bit_clear`` waits until ``(*addr & mask) != mask`` is true
>   - ``until_any_bit_set`` waits until ``(*addr & mask) != 0`` is true.
>
> -Internal Boot Mode Through Internal RAM(IRAM)
> --
> -
> -The Internal Boot Mode Through Internal RAM is supported on:
> -
> -* i.MX51
> -
> -As can be easily deduced from its name, the Internal Boot Mode Through
> -Internal RAM is just a variant of Internal Boot Mode so all of the
> -stated above still applies in this case. What it differs in is the following:
> -
> -* Boot process is done in two stages(First stage binary can be
> -  produced with ``imx_v7-xload_defconfig``)
> -* DCD of the first stage image is set such that the image is fetched
> -  into an unoccupied area or IRAM
> -* First stage image once uncompressed and set up will look for a
> -  second stage bootloader on the same media it booted from and start
> -  it(see mach-imx/xload.c for more details)
> -* Second stage images are just regular i.MX boot images
> -
> -Since on a typical i.MX SoC unused IRAM area is not enough to run
> -anything but a PBL this mode, due to its very limited usability,
> -serves only one purpose -- allow for a portion of a bootloader to be
> -executed without depending on DRAM to be functional. This peculiarity
> -of the mode can be used to implement various memory testing
> -scenarious.
> -
>  USB Boot
>  
>
> diff --git a/arch/arm/boards/freescale-mx51-babbage/board.c 
> b/arch/arm/boards/freescale-mx51-babbage/board.c
> index 915748528..e90f38e80 100644
> --- a/arch/arm/boards/freescale-mx51-babbage/board.c
> +++ b/arch/arm/boards/freescale-mx51-babbage/board.c
> @@ -167,63 +167,3 @@ static int imx51_babbage_init(void)
> return 0;
>  }
>  coredevice_initcall(imx51_babbage_init);
> -
> -#ifdef CONFIG_ARCH_IMX_XLOAD
> -
> -static int imx51_babbage_xload_init_pinmux(void)
> -{
> -   static const iomux_v3_cfg_t pinmux[] = {
> -   /* (e)CSPI */
> -   MX51_PAD_CSPI1_MOSI__ECSPI1_MOSI,
> -   MX51_PAD_CSPI1_MISO__ECSPI1_MISO,
> -   MX51_PAD_CSPI1_SCLK__ECSPI1_SCLK,
> -
> -   /* (e)CSPI chip select lines */
> -   MX51_PAD_CSPI1_SS1__GPIO4_25,
> -
> -
> -   /* eSDHC 1 */
> -   MX51_PAD_SD1_CMD__SD1_CMD,
> -   MX51_PAD_SD1_CLK__SD1_CLK,
> -   MX51_PAD_SD1_DATA0__SD1_DATA0,
> -   MX51_PAD_SD1_DATA1__SD1_DATA1,
> -   MX51_PAD_SD1_DATA2__SD1_DATA2,
> -   MX51_PAD_SD1_DATA3__SD1_DATA3,
> -   };
> -
> -   mxc_iomux_v3_setup_multiple_pads(ARRAY_AND_SIZE(pinmux));
> -
> -   return 0;
> -}
> -coredevice_initcall(imx51_babbage_xload_init_pinmux);
> -
> -static int imx51_babbage_xload_init_devices(void)
> -{
> -   static int spi0_chipselects[] = {
> -   IMX_GPIO_NR(4, 25),
> -   };

[PATCH v2 2/2] Documentation: fix code block and literal block highlighting

2018-08-09 Thread Roland Hieber
Use shell script highlighting where it is resonable, use console
highlighting for transcripts, and fix some of the few cases where the
syntax was broken, resulting in text not being rendered at all.

Signed-off-by: Roland Hieber 
---
v1 -> v2:
 - patch should now apply to next
 - drop first patch, which was already applied

---
 Documentation/boards/imx.rst  |  8 +--
 Documentation/boards/imx/amazon-kindle-3.rst  |  6 +++--
 .../boards/imx/garz-fricke-vincell.rst|  4 +++-
 .../boards/imx/phytec-phycore-i.mx31.rst  |  8 +--
 Documentation/boards/mips/dlink-dir-320.rst   |  4 +++-
 Documentation/boards/mips/qemu-malta.rst  | 16 +
 Documentation/boards/mvebu.rst|  4 +++-
 .../boards/mxs/Chumby-Falconwing.rst  |  8 +--
 .../boards/mxs/Freescale-i.MX23-evk.rst   |  8 +--
 Documentation/boards/mxs/KaRo-TX28.rst|  8 +--
 Documentation/boards/mxs/Olimex-olinuxino.rst |  8 +--
 Documentation/boards/omap.rst |  4 +++-
 Documentation/boards/openrisc.rst |  8 +--
 Documentation/boards/s3c/Digi-a9m2440.rst |  8 +--
 Documentation/boards/sandbox.rst  |  6 -
 Documentation/boards/socfpga.rst  | 24 ++-
 Documentation/boards/x86.rst  |  3 ++-
 Documentation/filesystems/fat.rst |  4 +++-
 Documentation/filesystems/nfs.rst |  8 +--
 Documentation/filesystems/pstore.rst  |  2 +-
 Documentation/filesystems/ramfs.rst   |  4 +++-
 Documentation/filesystems/smhfs.rst   |  4 +++-
 Documentation/filesystems/squashfs.rst|  4 +++-
 Documentation/filesystems/tftp.rst|  4 +++-
 Documentation/user/automount.rst  | 12 +++---
 Documentation/user/barebox.rst|  4 +---
 Documentation/user/defaultenv-2.rst   |  4 +++-
 Documentation/user/driver-model.rst   | 20 
 Documentation/user/hush.rst   | 24 ++-
 Documentation/user/memory-areas.rst   |  8 +--
 Documentation/user/system-setup.rst   | 12 +++---
 Documentation/user/updating.rst   |  8 +--
 Documentation/user/variables.rst  | 14 +++
 33 files changed, 200 insertions(+), 71 deletions(-)

diff --git a/Documentation/boards/imx.rst b/Documentation/boards/imx.rst
index db889ee702..56fd3ab41c 100644
--- a/Documentation/boards/imx.rst
+++ b/Documentation/boards/imx.rst
@@ -32,7 +32,9 @@ Normally it's not necessary to call this tool manually, it is 
executed
 automatically at the end of the build process.
 
 The images generated by the build process can be directly written to an
-SD card::
+SD card:
+
+.. code-block:: sh
 
   # with Multi Image support:
   cat images/barebox-freescale-imx51-babbage.img > /dev/sdd
@@ -152,7 +154,9 @@ contains a USB upload tool. As it depends on the libusb 
development headers,
 it is not built by default. Enable it explicitly in ``make menuconfig``
 and install the libusb development package. On Debian, this can be done
 with ``apt-get install libusb-dev``. After compilation, the tool can be used
-with only the image name as argument::
+with only the image name as argument:
+
+.. code-block:: sh
 
   scripts/imx/imx-usb-loader images/barebox-freescale-imx51-babbage.img
 
diff --git a/Documentation/boards/imx/amazon-kindle-3.rst 
b/Documentation/boards/imx/amazon-kindle-3.rst
index dffb7efb2d..6b5d9fe535 100644
--- a/Documentation/boards/imx/amazon-kindle-3.rst
+++ b/Documentation/boards/imx/amazon-kindle-3.rst
@@ -15,7 +15,7 @@ To upload and run a new bootloader the device can be put into 
USB-downloader
 mode by the SOC microcode when Vol+ is pressed during startup. A new USB
 device "SE Blank RINGO" should appear, barebox may be uploaded using
 
-::
+.. code-block:: console
 
 $ scripts/imx/imx-usb-loader barebox.imximg
 
@@ -26,7 +26,9 @@ imx-usb-loader)
 Barebox may be used as drop-in replacement for the shipped bootloader.
 When installing the barebox imximg on the eMMC take care not to overwrite
 the partition table and vendor supplied serial numbers stored on the eMMC.
-e.g. just write the imx-header and the application section::
+e.g. just write the imx-header and the application section:
+
+.. code-block:: sh
 
 memcpy -b -s barebox.imximg -d /dev/disk0.imx_header 1024 0 1024
 memcpy -b -s barebox.imximg -d /dev/disk0.self 4096 0 195584
diff --git a/Documentation/boards/imx/garz-fricke-vincell.rst 
b/Documentation/boards/imx/garz-fricke-vincell.rst
index 09d87d67c3..4127c8bc8c 100644
--- a/Documentation/boards/imx/garz-fricke-vincell.rst
+++ b/Documentation/boards/imx/garz-fricke-vincell.rst
@@ -38,6 +38,8 @@ If the network setup is working properly, barebox can be 
loaded into memory::
   load -v -r -b 0x8010 barebox-guf-vincell-lt.img
   exec
 
-Once in barebox, the bootloader can now be persisted to 

[PATCH v2] FIT: be more verbose when RSA signature check fails

2018-08-09 Thread Roland Hieber
Tell the user what device tree node we're looking for.

Signed-off-by: Roland Hieber 
---
v1 -> v2: prevent use-after-free of key_path

---
 common/image-fit.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index 6cbf23250d..dfd1fa02c9 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -289,11 +289,12 @@ static int fit_check_rsa_signature(struct device_node 
*sig_node,
}
key_path = xasprintf("/signature/key-%s", key_name);
key_node = of_find_node_by_path(key_path);
-   free(key_path);
if (!key_node) {
-   pr_info("failed to find key node\n");
+   pr_info("failed to find key node %s\n", key_path);
+   free(key_path);
return -ENOENT;
}
+   free(key_path);
 
ret = rsa_of_read_key(key_node, );
if (ret) {
-- 
2.18.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 4/4] linux/types.h: fix missing include for BITS_TO_LONGS()

2018-08-09 Thread Roland Hieber
On Thu, Aug 09, 2018 at 09:38:39PM +0200, Sascha Hauer wrote:
> On Mon, Jul 30, 2018 at 01:14:37PM +0200, Roland Hieber wrote:
> > Signed-off-by: Roland Hieber 
> > ---
> >  include/linux/types.h | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/include/linux/types.h b/include/linux/types.h
> > index f64ec4a814..44d8238d53 100644
> > --- a/include/linux/types.h
> > +++ b/include/linux/types.h
> > @@ -2,6 +2,7 @@
> >  #define _LINUX_TYPES_H
> >  
> >  #include 
> > +#include 
> >  #include 
> 
> This breaks compilation on ppc. Here linux/bitops.h includes files which
> use types (__be32 and friends) which are declared later in
> include/linux/types.h.
> 
> Why specifically is this patch needed?

I was isolating the architecture-specific parts of a shared customer
code base into single files (in order to port it to another arch), and
in that process I ended up with a .c file that included 
for some macro which I don't remember, but it did not compile because
 declares macros that use BITS_TO_LONGS(), which is
declared in , which was not included before.
I guess the original code already included  via some
other path before including , so the error did not happen
there. So I reasoned that if  uses BITS_TO_LONGS(), it
should include the respective header where this macro is defined.

And now that you say it, I see that I should have written that in my
commit message.

 - Roland

-- 
Roland Hieber | r.hie...@pengutronix.de |
Pengutronix e.K.  | https://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim | Phone: +49-5121-206917-5086 |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 4/4] linux/types.h: fix missing include for BITS_TO_LONGS()

2018-08-09 Thread Sascha Hauer
On Mon, Jul 30, 2018 at 01:14:37PM +0200, Roland Hieber wrote:
> Signed-off-by: Roland Hieber 
> ---
>  include/linux/types.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/linux/types.h b/include/linux/types.h
> index f64ec4a814..44d8238d53 100644
> --- a/include/linux/types.h
> +++ b/include/linux/types.h
> @@ -2,6 +2,7 @@
>  #define _LINUX_TYPES_H
>  
>  #include 
> +#include 
>  #include 

This breaks compilation on ppc. Here linux/bitops.h includes files which
use types (__be32 and friends) which are declared later in
include/linux/types.h.

Why specifically is this patch needed?

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: Help requested with Barebox on Globalscale Mirabox

2018-08-09 Thread Leigh Brown

Hi Uwe,

On 2018-08-06 19:36, Uwe Kleine-König wrote:

Hello Leigh,

On Tue, Jul 31, 2018 at 02:21:04PM +0100, Leigh Brown wrote:

Have I missed any steps?  Any help would be greatly appreciated.


Looks good.

Which revision are you on (i.e. git rev-parse @ in your barebox copy)?
What is currently running on the device?


I was running against the same revision as you tried (445a7f).  I'm now
running against the latest revision (3307e8) with the same issue.


Do you get an U when applying this patch?:

[snip patch]

I did.  Thanks very much for that hint, it helped me debug the issue. I 
am

booting from the UART as follows:

scripts/kwboot -t -b images/barebox-globalscale-mirabox.img -B 115200 
/dev/ttyUSB0


I believe the issue is that in arch/arm/mach-mvebu/common.c the function
armada_370_xp_barebox_entry() calls mvebu_remap_registers() before the 
stack is

set up (it looks like the SP points somewhere in the SRAM range).  As
mvebu_remap_registers() as compiled by my version of gcc uses the stack, 
it fails

to return.

Making mvebu_remap_registers() inline fixes the issue, as per the 
following

patch:

diff --git a/arch/arm/mach-mvebu/common.c b/arch/arm/mach-mvebu/common.c
index 83aeb41ae..588cef515 100644
--- a/arch/arm/mach-mvebu/common.c
+++ b/arch/arm/mach-mvebu/common.c
@@ -183,11 +183,15 @@ mem_initcall(mvebu_meminit);
  * There no way to determine internal registers base address
  * safely later on, as the remap register itself is within the
  * internal registers.
+ *
+ * As this function may be called before we have a working stack,
+ * make it inline to avoid the possibility of using the stack.
+ *
  */
 #define MVEBU_BRIDGE_REG_BASE  0x2
 #define DEVICE_INTERNAL_BASE_ADDR  (MVEBU_BRIDGE_REG_BASE + 0x80)

-static void mvebu_remap_registers(void)
+static inline void mvebu_remap_registers(void)
 {
void __iomem *base = mvebu_get_initial_int_reg_base();


I just tried 7ba0f2d29959256025ece9ae961a6c3421445a7f on my ReadyNAS 
104

which has an armada370, too.

I hangs when using second-stage booting from the Vendor U-Boot after:

	barebox 2018.07.0-00139-g7ba0f2d29959-dirty #50 Mon Aug 6 20:27:11 
CEST 2018



Board: Marvell Armada 370/XP
SoC: Marvell 6710 rev 1
mdio_bus: miibus0: probed
eth1: got preset MAC address: 28:c6:8e:36:df:57

When enabling DEBUG_INITCALLS I got a prompt, hmm. Didn't debug that
further.

Best regards
Uwe


Once I got past that issue I also had an issue in 
barebox_multi_pbl_start.  I
think the following patch is the right solution, but I'm not 100% sure.  
It

certainly makes it work for me.

diff --git a/arch/arm/cpu/uncompress.c b/arch/arm/cpu/uncompress.c
index b07087e4c..5ee80da9d 100644
--- a/arch/arm/cpu/uncompress.c
+++ b/arch/arm/cpu/uncompress.c
@@ -50,7 +66,7 @@ void __noreturn barebox_multi_pbl_start(unsigned long 
membase,

void *pg_start;
unsigned long pc = get_pc();

-   image_end = (void *)_end_marker + global_variable_offset();
+   image_end = (void *)_end_marker;

if (IS_ENABLED(CONFIG_PBL_RELOCATABLE)) {
/*
@@ -63,6 +79,8 @@ void __noreturn barebox_multi_pbl_start(unsigned long 
membase,

else
relocate_to_adr(membase);
}
+   else
+   image_end += global_variable_offset();

/*
 	 * image_end is the image_end_marker defined above. It is the last 
location


Anyway, with the following two fixes I now have it booting on my 
Mirabox:


barebox 2018.07.0-00143-gf9fc8254b-dirty #53 Thu Aug 9 16:11:01 BST 2018


Board: Marvell Armada 370/XP
SoC: Marvell 6710 rev 1
mdio_bus: miibus0: probed
pci: pci_scan_bus for bus 0
pci:  last_io = 0xffe0, last_mem = 0xe000, last_mem_pref = 
0x

pci: pci_scan_bus returning with max=01
pci: pci_scan_bus for bus 1
pci:  last_io = 0xffe1, last_mem = 0xe200, last_mem_pref = 
0x

pci: pci_scan_bus returning with max=02
malloc space: 0x0fefe600 -> 0x1fdfcbff (size 255 MiB)
environment load /dev/env0: No such file or directory
Maybe you have to create the partition.
running /env/bin/init...
/env/bin/init not found
barebox:/

Thanks again for your help.  I'll now figure out how to get NAND support 
working.


Regards,

Leigh.

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] FIT: be more verbose when RSA signature check fails

2018-08-09 Thread Roland Hieber
Tell the user what device tree node we're looking for.

Signed-off-by: Roland Hieber 
---
 common/image-fit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index 6cbf23250d..72b5bbf179 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -291,7 +291,7 @@ static int fit_check_rsa_signature(struct device_node 
*sig_node,
key_node = of_find_node_by_path(key_path);
free(key_path);
if (!key_node) {
-   pr_info("failed to find key node\n");
+   pr_info("failed to find key node %s\n", key_path);
return -ENOENT;
}
 
-- 
2.18.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: NFS boot - could not open /.tftp_tmp_path

2018-08-09 Thread Ulrich Ölmann
Sam Ravnborg  writes:
> Hi Ulrich
>> > Then when I try to boot from nfs I get the following output:
>> >
>> > barebox: boot nfs://192.168.86.201/nfsboot/arm9/
>> 
>> you already have the slash separating the host part of the URL and the
>> path part, but you missed the slash that is needed at the beginning of
>> the absolute path:
>> 
>>   boot nfs://192.168.86.201//nfsboot/arm9/
>> 
>> (with a two slashes) should hopefully do the trick.
>
> Hmm, no luck:
> barebox:/ boot nfs://192.168.86.201//nfsboot/arm9/
> eth0: DHCP client bound to address 192.168.86.20
> T T T T T T T T T T T T T T could not open 
> /.tftp_tmp_path/zImage-at91sam9263ekt
>
> barebox:/ boot nfs://192.168.86.201//nfsboot/arm9
> eth0: DHCP client bound to address 192.168.86.20
> T T T T T T T T T T T T T T could not open 
> /.tftp_tmp_path/zImage-at91sam9263ekt
>
> I will try to add some debugging and see whats going on.

Do you see anything of interest in the server's log?
-- 
Pengutronix e.K.   | Ulrich Ölmann   |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 2/2] Documentation: fix code block and literal block highlighting

2018-08-09 Thread Roland Hieber
On Wed, Aug 08, 2018 at 09:00:18AM +0200, Sascha Hauer wrote:
> On Wed, Jul 25, 2018 at 04:18:11PM +0200, Roland Hieber wrote:
> > Use shell script highlighting where it is resonable, use console
> > highlighting for transcripts, and fix some of the few cases where the
> > syntax was broken, resulting in text not being rendered at all.
> > 
> > Signed-off-by: Roland Hieber 
> > ---
> >  Documentation/boards/imx.rst  | 16 +
> >  .../boards/imx/Garz-Fricke-Vincell.rst|  4 +++-
> >  .../boards/imx/Phytec-phyCORE-i.MX31.rst  |  8 +--
> >  Documentation/boards/imx/Wandboard.rst|  5 +++-
> 
> This patch does not apply. In my tree the filenames are all different,
> for example this one is Documentation/boards/imx/wandboard.rst (with a
> lowercase 'w') in my tree.

You're right, I didn't build on top of my own patches from my previous
doc series… Will send v2 shortly.

 - Roland

-- 
Roland Hieber | r.hie...@pengutronix.de |
Pengutronix e.K.  | https://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim | Phone: +49-5121-206917-5086 |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: NFS boot - could not open /.tftp_tmp_path

2018-08-09 Thread Sam Ravnborg
Hi Ulrich
> > Then when I try to boot from nfs I get the following output:
> >
> > barebox: boot nfs://192.168.86.201/nfsboot/arm9/
> 
> you already have the slash separating the host part of the URL and the
> path part, but you missed the slash that is needed at the beginning of
> the absolute path:
> 
>   boot nfs://192.168.86.201//nfsboot/arm9/
> 
> (with a two slashes) should hopefully do the trick.

Hmm, no luck:
barebox:/ boot nfs://192.168.86.201//nfsboot/arm9/
eth0: DHCP client bound to address 192.168.86.20
T T T T T T T T T T T T T T could not open /.tftp_tmp_path/zImage-at91sam9263ekt

barebox:/ boot nfs://192.168.86.201//nfsboot/arm9
eth0: DHCP client bound to address 192.168.86.20
T T T T T T T T T T T T T T could not open /.tftp_tmp_path/zImage-at91sam9263ekt

I will try to add some debugging and see whats going on.

Sam

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: NFS boot - could not open /.tftp_tmp_path

2018-08-09 Thread Ulrich Ölmann
Hi Sam,

Sam Ravnborg  writes:
> I try to boot my target using NFS - but something does not work.
> I have a server (192.168.86.201) where I have exported
> an nfs mount like this:
> $ sudo exportfs
> /nfsboot/arm9   
> $ cat /etc/exports.d/nfsboot.exports
> /nfsboot/arm9*(insecure,no_subtree_check,no_root_squash,rw,nohide)
>
> On my barebox target I can then mount the nfs like this:
> barebox: mkdir /mnt
> barebox: /mnt/nfs
> barebox: mount -t nfs 192.168.86.201:/nfsboot/arm9
>
> barebox: mount
> none on / type ramfs
> none on /dev type devfs
> 192.168.86.201:/nfsboot/arm9 on /mnt/nfs type nfs
>
> barebox: ls /mnt/nfs <= shows the file I have on the server
>
> Then when I try to boot from nfs I get the following output:
>
> barebox: boot nfs://192.168.86.201/nfsboot/arm9/

you already have the slash separating the host part of the URL and the
path part, but you missed the slash that is needed at the beginning of
the absolute path:

  boot nfs://192.168.86.201//nfsboot/arm9/

(with a two slashes) should hopefully do the trick.

Best regards
Ulrich


> eth0: DHCP client bound to address 192.168.86.20
> T T T T T T T T T T T T T T could not open 
> /.tftp_tmp_path/zImage-at91sam9263ek
>
> When I grep the barebox source I can only find 'tftp_tmp_path' in some
> tftp code.
>
> It looks like it somehow revert back to tftp despite I have specified nfs.
> I hope there is something trivial I do wrong.
>
> Any hints?
>
>   Sam
>
> ___
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox


--
Pengutronix e.K.   | Ulrich Ölmann   |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


NFS boot - could not open /.tftp_tmp_path

2018-08-09 Thread Sam Ravnborg
Hi all.

I try to boot my target using NFS - but something does not work.
I have a server (192.168.86.201) where I have exported
an nfs mount like this:
$ sudo exportfs
/nfsboot/arm9   
$ cat /etc/exports.d/nfsboot.exports
/nfsboot/arm9*(insecure,no_subtree_check,no_root_squash,rw,nohide)

On my barebox target I can then mount the nfs like this:
barebox: mkdir /mnt
barebox: /mnt/nfs
barebox: mount -t nfs 192.168.86.201:/nfsboot/arm9

barebox: mount
none on / type ramfs
none on /dev type devfs
192.168.86.201:/nfsboot/arm9 on /mnt/nfs type nfs

barebox: ls /mnt/nfs <= shows the file I have on the server

Then when I try to boot from nfs I get the following output:

barebox: boot nfs://192.168.86.201/nfsboot/arm9/
eth0: DHCP client bound to address 192.168.86.20
T T T T T T T T T T T T T T could not open /.tftp_tmp_path/zImage-at91sam9263ek

When I grep the barebox source I can only find 'tftp_tmp_path' in some
tftp code.

It looks like it somehow revert back to tftp despite I have specified nfs.
I hope there is something trivial I do wrong.

Any hints?

Sam

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/3] libfile: open_and_lseek: enlarge small files enough to make lseek possible

2018-08-09 Thread Uwe Kleine-König
This makes the following do the expected thing:

barebox@barebox sandbox:/ ls -l lala
-rwxrwxrwx  4 lala
barebox@barebox sandbox:/ mw -d lala 72 0

Without this patch mw dies with

lseek: Invalid argument

memset, memcpy and probably others benefit in the same way.

Signed-off-by: Uwe Kleine-König 
---
 lib/libfile.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/lib/libfile.c b/lib/libfile.c
index 83c6399a5b39..01c59cdb80fe 100644
--- a/lib/libfile.c
+++ b/lib/libfile.c
@@ -510,6 +510,24 @@ int open_and_lseek(const char *filename, int mode, loff_t 
pos)
if (!pos)
return fd;
 
+   if (mode & (O_WRONLY | O_RDWR)) {
+   struct stat s;
+
+   ret = fstat(fd, );
+   if (ret) {
+   perror("ftruncate");
+   return ret;
+   }
+
+   if (s.st_size < pos) {
+   ret = ftruncate(fd, pos);
+   if (ret) {
+   perror("ftruncate");
+   return ret;
+   }
+   }
+   }
+
ret = lseek(fd, pos, SEEK_SET);
if (ret == -1) {
perror("lseek");
-- 
2.18.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/3] libfile: open_and_lseek: don't imply O_RDONLY

2018-08-09 Thread Uwe Kleine-König
There are several users that pass O_RDWR or O_WRONLY in mode to
open_and_lseek() and use the resulting file descriptor for writing. This
is no real issue becauce O_RDONLY is 0 and so can be dropped without
any side effects.

Signed-off-by: Uwe Kleine-König 
---
 lib/libfile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/libfile.c b/lib/libfile.c
index d22519b8f4bb..83c6399a5b39 100644
--- a/lib/libfile.c
+++ b/lib/libfile.c
@@ -501,7 +501,7 @@ int open_and_lseek(const char *filename, int mode, loff_t 
pos)
 {
int fd, ret;
 
-   fd = open(filename, mode | O_RDONLY);
+   fd = open(filename, mode);
if (fd < 0) {
perror("open");
return fd;
-- 
2.18.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 3/3] commands: teach commands that write to files to also create them

2018-08-09 Thread Uwe Kleine-König
This allows to use the adapted commands on non-existing files which
failed before with

open: No such file or directory

Signed-off-by: Uwe Kleine-König 
---
 commands/memset.c | 2 +-
 commands/mm.c | 2 +-
 commands/mw.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/commands/memset.c b/commands/memset.c
index f871e07c9523..f99bf86c0415 100644
--- a/commands/memset.c
+++ b/commands/memset.c
@@ -56,7 +56,7 @@ static int do_memset(int argc, char *argv[])
c = strtoull_suffix(argv[optind + 1], NULL, 0);
n = strtoull_suffix(argv[optind + 2], NULL, 0);
 
-   fd = open_and_lseek(file, mode | O_WRONLY, s);
+   fd = open_and_lseek(file, mode | O_WRONLY | O_CREAT, s);
if (fd < 0)
return 1;
 
diff --git a/commands/mm.c b/commands/mm.c
index 6d2a88789299..c7f62fca54bb 100644
--- a/commands/mm.c
+++ b/commands/mm.c
@@ -53,7 +53,7 @@ static int do_mem_mm(int argc, char *argv[])
value = simple_strtoull(argv[optind++], NULL, 0);
mask = simple_strtoull(argv[optind++], NULL, 0);
 
-   fd = open_and_lseek(filename, mode | O_RDWR, adr);
+   fd = open_and_lseek(filename, mode | O_RDWR | O_CREAT, adr);
if (fd < 0)
return 1;
 
diff --git a/commands/mw.c b/commands/mw.c
index 7ff589abb1d4..2912997a31df 100644
--- a/commands/mw.c
+++ b/commands/mw.c
@@ -52,7 +52,7 @@ static int do_mem_mw(int argc, char *argv[])
 
adr = strtoull_suffix(argv[optind++], NULL, 0);
 
-   fd = open_and_lseek(filename, mode | O_WRONLY, adr);
+   fd = open_and_lseek(filename, mode | O_WRONLY | O_CREAT, adr);
if (fd < 0)
return 1;
 
-- 
2.18.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] scripts/dtc: Reenable fdtget

2018-08-09 Thread Sascha Hauer
On Thu, Aug 09, 2018 at 10:03:06AM +0200, Juergen Borleis wrote:
> On Thursday 09 August 2018 09:20:24 Sascha Hauer wrote:
> > [...]
> > >
> > > You should add "fdtget" to the "clean-files" variable as well.
> >
> > Nope, it's not necessary to add that explicitly.
> 
> Hmm, then somewhere else?
> 
> $ make
> [...]
> $ git status
> scripts/dtc/fdtget
> $ make clean

Host tools are cleaned with 'make distclean'

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] scripts/dtc: Reenable fdtget

2018-08-09 Thread Juergen Borleis
On Thursday 09 August 2018 09:20:24 Sascha Hauer wrote:
> [...]
> >
> > You should add "fdtget" to the "clean-files" variable as well.
>
> Nope, it's not necessary to add that explicitly.

Hmm, then somewhere else?

$ make
[...]
$ git status
scripts/dtc/fdtget
$ make clean
[...]
$ git status
scripts/dtc/fdtget

I think that's why this issue wasn't noticed when the update to 1.4.6 was 
made.

jb

-- 
Pengutronix e.K.                             | Juergen Borleis             |
Industrial Linux Solutions                   | http://www.pengutronix.de/  |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: root= kernel cmdline parameter

2018-08-09 Thread Giorgio Dal Molin
Hi,

> On August 8, 2018 at 9:52 AM Sascha Hauer  wrote:
> 
> 
> On Tue, Jul 31, 2018 at 01:20:12PM +0200, Giorgio Dal Molin wrote:
> > Hi all,
> > 
> > I'm trying to find out the best method to define the root=
> > parameter when booting the linux kernel from barebox.
> > 
> > My system boots from an sd card partitioned with a GPT.
> > The sd card has two independent set of partitions with
> > the following labels:
> > 
> > 1)   boot_1 + rootfs_1
> > 2)   boot_2 + rootfs_2
> > 
> > for redondance in case one set gets damaged while updating.
> > 
> > 'boot_1' is formatted with ext4 and contains the kernel + dtb images
> > for the userland in 'rootfs_1'; and the same for 'boot_2' and 'rootfs_2'.
> > 
> > Currently I hardcode the 'root' parameter to '/dev/mmcblk0p3' or
> > '/dev/mmcblk0p4' corresponding to the kernel in 'boot_1' or
> > 'boot_2' and it actually works but is there a better way to do
> > this ?
> 
> You could use bootloader spec. That would at least allow you to store a
> suitable root= parameter in the config files in the boot_1 and boot_2
> partitions.
> 
> Not sure if that's what you are looking for though.
> 
> Sascha
> 

as I already wrote to Uwe Kleine-Koenig I wanted to keep the kernel
image and the dtb in a separate partition because these are the files
the bootloader *must* be able to read to boot the system. Having the
userland in a separate partition lets me choose an image format for it
independently from what barebox supports; as an example I could pack
my userland in a btrfs image. Moreover I can be more selective when
updating the firmware: I can update only the kernel+dtb or only the
userland image.

What I would like to have is an automatic way to set the root= kernel
command line parameter similar to what barebox does with the 'bootm.appendroot'
but a bit more flexible.
Looking at the kernel function name_to_dev_t() in the source init/do_mounts.c,
it accepts also the format 'PARTUUID=00112233-4455-6677-8899-AABBCCDDEEFF':
my idea was to somehow tell barebox 'use the partition with label "rootfs_1"
for the "root" parameter' and barebox should be able to match my label with
the partition UUID and automatically generate the root= value.

giorgio

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] scripts/dtc: Reenable fdtget

2018-08-09 Thread Sascha Hauer
On Thu, Aug 09, 2018 at 09:14:47AM +0200, Juergen Borleis wrote:
> On Thursday 09 August 2018 08:54:20 Sascha Hauer wrote:
> > [...]
> > diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile
> > index 06aaa8c550..cc4ebefcb6 100644
> > --- a/scripts/dtc/Makefile
> > +++ b/scripts/dtc/Makefile
> > @@ -1,6 +1,6 @@
> >  # scripts/dtc makefile
> >
> > -hostprogs-y:= dtc
> > +hostprogs-y:= dtc fdtget
> >  always := $(hostprogs-y)
> >
> >  dtc-objs   := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \
> > @@ -10,6 +10,8 @@ dtc-objs  += dtc-lexer.lex.o dtc-parser.tab.o
> >  libfdt-objs= fdt.o fdt_ro.o fdt_strerror.o fdt_wip.o fdt_overlay.o
> >  libfdt-objs+= fdt_empty_tree.o fdt_rw.o fdt_sw.o
> >
> > +fdtget-objs+= fdtget.o $(libfdt-objs) util.o
> > +
> >  # Source files need to get at the userspace version of libfdt_env.h to 
> > compile
> >
> >  HOSTCFLAGS_DTC := -I$(src)
> > @@ -23,6 +25,7 @@ HOSTCFLAGS_livetree.o := $(HOSTCFLAGS_DTC)
> >  HOSTCFLAGS_srcpos.o := $(HOSTCFLAGS_DTC)
> >  HOSTCFLAGS_treesource.o := $(HOSTCFLAGS_DTC)
> >  HOSTCFLAGS_util.o := $(HOSTCFLAGS_DTC)
> > +HOSTCFLAGS_fdtget.o := $(HOSTCFLAGS_DTC)
> >
> >  HOSTCFLAGS_fdt.o := $(HOSTCFLAGS_DTC)
> >  HOSTCFLAGS_fdt_ro.o := $(HOSTCFLAGS_DTC)
> 
> You should add "fdtget" to the "clean-files" variable as well.

Nope, it's not necessary to add that explicitly.

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] scripts/dtc: Reenable fdtget

2018-08-09 Thread Juergen Borleis
On Thursday 09 August 2018 08:54:20 Sascha Hauer wrote:
> [...]
> diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile
> index 06aaa8c550..cc4ebefcb6 100644
> --- a/scripts/dtc/Makefile
> +++ b/scripts/dtc/Makefile
> @@ -1,6 +1,6 @@
>  # scripts/dtc makefile
>
> -hostprogs-y  := dtc
> +hostprogs-y  := dtc fdtget
>  always   := $(hostprogs-y)
>
>  dtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \
> @@ -10,6 +10,8 @@ dtc-objs+= dtc-lexer.lex.o dtc-parser.tab.o
>  libfdt-objs  = fdt.o fdt_ro.o fdt_strerror.o fdt_wip.o fdt_overlay.o
>  libfdt-objs  += fdt_empty_tree.o fdt_rw.o fdt_sw.o
>
> +fdtget-objs+= fdtget.o $(libfdt-objs) util.o
> +
>  # Source files need to get at the userspace version of libfdt_env.h to 
> compile
>
>  HOSTCFLAGS_DTC := -I$(src)
> @@ -23,6 +25,7 @@ HOSTCFLAGS_livetree.o := $(HOSTCFLAGS_DTC)
>  HOSTCFLAGS_srcpos.o := $(HOSTCFLAGS_DTC)
>  HOSTCFLAGS_treesource.o := $(HOSTCFLAGS_DTC)
>  HOSTCFLAGS_util.o := $(HOSTCFLAGS_DTC)
> +HOSTCFLAGS_fdtget.o := $(HOSTCFLAGS_DTC)
>
>  HOSTCFLAGS_fdt.o := $(HOSTCFLAGS_DTC)
>  HOSTCFLAGS_fdt_ro.o := $(HOSTCFLAGS_DTC)

You should add "fdtget" to the "clean-files" variable as well.

jb

-- 
Pengutronix e.K.                             | Juergen Borleis             |
Industrial Linux Solutions                   | http://www.pengutronix.de/  |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: scripts/dtc/fdtget: No such file or directory

2018-08-09 Thread Sascha Hauer
Hi Peter,

On Wed, Aug 08, 2018 at 07:22:51PM +0300, Peter Mamonov wrote:
> Hi, 
> 
> After "8a8982541 scripts/dtc: Update to upstream version 1.4.6" 
> scripts/dtc/Makefile lacks rule for scripts/dtc/fdtget, which causes 
> scripts/gen-dtb-s to complain:
> 
>   $ make
>   ...
>   scripts/gen-dtb-s: line 24: scripts/dtc/fdtget: No such file or 
> directory
>   scripts/gen-dtb-s: line 27: scripts/dtc/fdtget: No such file or 
> directory
>   scripts/gen-dtb-s: line 34: scripts/dtc/fdtget: No such file or 
> directory
>   scripts/gen-dtb-s: line 37: scripts/dtc/fdtget: No such file or 
> directory
>   scripts/gen-dtb-s: line 24: scripts/dtc/fdtget: No such file or 
> directory
>   scripts/gen-dtb-s: line 27: scripts/dtc/fdtget: No such file or 
> directory
>   scripts/gen-dtb-s: line 34: scripts/dtc/fdtget: No such file or 
> directory
>   scripts/gen-dtb-s: line 37: scripts/dtc/fdtget: No such file or 
> directory
> 
> Yet a build finishes ok.

In 8a8982541 building of fdget is dropped. I didn't notice because I
have fdtget still in my build dir from previous builds. I just sent a
patch for this, you're on Cc:.

The build was still successful because only the output of fdtget was
used in a pipe. Apparently the error handling leaves room for
improvements.

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] scripts/dtc: Reenable fdtget

2018-08-09 Thread Sascha Hauer
compilation of fdtget was lost during the update to version 1.4.6.
We need this tool internally for the build process when imd support
is enabled.

Apparently our dtc code comes from the Kernel which doesn't have the
upstream version of fdtget.c and it doesn't compile. This patch
changes fdtget.c to the upstream version as of 1.4.6. This isn't
noticed in the Kernel because fdtget isn't compiled there.

Fixes: 8a8982541 scripts/dtc: Update to upstream version 1.4.6

Signed-off-by: Sascha Hauer 
---
 scripts/dtc/Makefile |   5 +-
 scripts/dtc/fdtget.c | 119 +--
 2 files changed, 73 insertions(+), 51 deletions(-)

diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile
index 06aaa8c550..cc4ebefcb6 100644
--- a/scripts/dtc/Makefile
+++ b/scripts/dtc/Makefile
@@ -1,6 +1,6 @@
 # scripts/dtc makefile
 
-hostprogs-y:= dtc
+hostprogs-y:= dtc fdtget
 always := $(hostprogs-y)
 
 dtc-objs   := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \
@@ -10,6 +10,8 @@ dtc-objs  += dtc-lexer.lex.o dtc-parser.tab.o
 libfdt-objs= fdt.o fdt_ro.o fdt_strerror.o fdt_wip.o fdt_overlay.o
 libfdt-objs+= fdt_empty_tree.o fdt_rw.o fdt_sw.o
 
+fdtget-objs+= fdtget.o $(libfdt-objs) util.o
+
 # Source files need to get at the userspace version of libfdt_env.h to compile
 
 HOSTCFLAGS_DTC := -I$(src)
@@ -23,6 +25,7 @@ HOSTCFLAGS_livetree.o := $(HOSTCFLAGS_DTC)
 HOSTCFLAGS_srcpos.o := $(HOSTCFLAGS_DTC)
 HOSTCFLAGS_treesource.o := $(HOSTCFLAGS_DTC)
 HOSTCFLAGS_util.o := $(HOSTCFLAGS_DTC)
+HOSTCFLAGS_fdtget.o := $(HOSTCFLAGS_DTC)
 
 HOSTCFLAGS_fdt.o := $(HOSTCFLAGS_DTC)
 HOSTCFLAGS_fdt_ro.o := $(HOSTCFLAGS_DTC)
diff --git a/scripts/dtc/fdtget.c b/scripts/dtc/fdtget.c
index c2fbab2a54..6cc5242f10 100644
--- a/scripts/dtc/fdtget.c
+++ b/scripts/dtc/fdtget.c
@@ -53,6 +53,37 @@ static void report_error(const char *where, int err)
fprintf(stderr, "Error at '%s': %s\n", where, fdt_strerror(err));
 }
 
+/**
+ * Shows a list of cells in the requested format
+ *
+ * @param disp Display information / options
+ * @param data Data to display
+ * @param len  Maximum length of buffer
+ * @param size Data size to use for display (e.g. 4 for 32-bit)
+ * @return 0 if ok, -1 on error
+ */
+static int show_cell_list(struct display_info *disp, const char *data, int len,
+ int size)
+{
+   const uint8_t *p = (const uint8_t *)data;
+   char fmt[3];
+   int value;
+   int i;
+
+   fmt[0] = '%';
+   fmt[1] = disp->type ? disp->type : 'd';
+   fmt[2] = '\0';
+   for (i = 0; i < len; i += size, p += size) {
+   if (i)
+   printf(" ");
+   value = size == 4 ? fdt32_to_cpu(*(const fdt32_t *)p) :
+   size == 2 ? (*p << 8) | p[1] : *p;
+   printf(fmt, value);
+   }
+
+   return 0;
+}
+
 /**
  * Displays data of a given length according to selected options
  *
@@ -66,12 +97,9 @@ static void report_error(const char *where, int err)
  */
 static int show_data(struct display_info *disp, const char *data, int len)
 {
-   int i, size;
-   const uint8_t *p = (const uint8_t *)data;
+   int size;
const char *s;
-   int value;
int is_string;
-   char fmt[3];
 
/* no data, don't print */
if (len == 0)
@@ -99,17 +127,8 @@ static int show_data(struct display_info *disp, const char 
*data, int len)
"selected data size\n");
return -1;
}
-   fmt[0] = '%';
-   fmt[1] = disp->type ? disp->type : 'd';
-   fmt[2] = '\0';
-   for (i = 0; i < len; i += size, p += size) {
-   if (i)
-   printf(" ");
-   value = size == 4 ? fdt32_to_cpu(*(const uint32_t *)p) :
-   size == 2 ? (*p << 8) | p[1] : *p;
-   printf(fmt, value);
-   }
-   return 0;
+
+   return show_cell_list(disp, data, len, size);
 }
 
 /**
@@ -245,7 +264,7 @@ static int show_data_for_item(const void *blob, struct 
display_info *disp,
  * @param filename Filename of blob file
  * @param arg  List of arguments to process
  * @param arg_countNumber of arguments
- * @param return 0 if ok, -ve on error
+ * @return 0 if ok, -ve on error
  */
 static int do_fdtget(struct display_info *disp, const char *filename,
 char **arg, int arg_count, int args_per_step)
@@ -266,44 +285,50 @@ static int do_fdtget(struct display_info *disp, const 
char *filename,
continue;
} else {
report_error(arg[i], node);
+   free(blob);
return -1;
}
}
prop = args_per_step == 1 ? NULL : arg[i + 1];
 
-   if (show_data_for_item(blob, disp, node,