[U-Boot] [PATCH] include: compiler: fix tools-only compiles on Cygwin and with the Android NDK on Linux

2019-04-12 Thread Chris Renshaw
Hi again, I am submitting this patch with some easy fixes for the ongoing 
broken compiling U-Boot tools-only on Cygwin and cross-compiling with the 
Android NDK on Linux. The added __kernel_* definitions in posix_types.h come 
from mainline so should be safe for inclusion: 
https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/posix_types.h

I also feel it worth mentioning that my previous bug report for dumpimage 
failing on untrimmed dumps has not received any response yet, so I'll link it 
again for your attention as the issue remains in 2019.04: 
https://lists.denx.de/pipermail/u-boot/2019-January/355670.html

Errors on Cygwin resolved by this patch:

  HOSTCC  tools/aisimage.o
In file included from tools/aisimage.c:9:0:
include/image.h:321:2: error: unknown type name ‘__be32’
  __be32  ih_magic; /* Image Header Magic Number */
  ^~
(and 6 similar __be32 errors)
make[1]: *** [scripts/Makefile.host:114: tools/aisimage.o] Error 1
make: *** [Makefile:1722: tools-only] Error 2

  HOSTCC  tools/imx8image.o
In file included from include/linux/kernel.h:5:0,
 from include/imx8image.h:14,
 from tools/imx8image.c:8:
include/linux/types.h:155:2: error: unknown type name ‘__kernel_daddr_t’
  __kernel_daddr_t f_tfree;
  ^~~~
include/linux/types.h:156:2: error: unknown type name ‘__kernel_ino_t’
  __kernel_ino_t  f_tinode;
  ^~
make[1]: *** [scripts/Makefile.host:114: tools/imx8image.o] Error 1
make: *** [Makefile:1722: tools-only] Error 2

  HOSTCC  tools/mtk_image.o
In file included from tools/mtk_image.c:12:0:
tools/mtk_image.h:18:3: error: unknown type name ‘__le32’
   __le32 version;
   ^~
(and 30 similar __le32 errors)
tools/mtk_image.h:35:3: error: unknown type name ‘__le16’
   __le16 ioif;
   ^~
(and 10 similar __le16 errors)
make[1]: *** [scripts/Makefile.host:114: tools/mtk_image.o] Error 1
make: *** [Makefile:1722: tools-only] Error 2

  HOSTCC  tools/zynqmpbif.o
tools/zynqmpbif.c: In function ‘bif_add_bit’:
tools/zynqmpbif.c:520:15: warning: implicit declaration of function ‘__swab32’; 
did you mean ‘__bswap32’? [-Wimplicit-function-declaration]
   *bitbin32 = __swab32(*bitbin32);
   ^~~~
   __bswap32
tools/zynqmpbif.o:zynqmpbif.c:(.text+0xdb7): undefined reference to `__swab32'
collect2: error: ld returned 1 exit status
make[1]: *** [scripts/Makefile.host:106: tools/dumpimage] Error 1
make: *** [Makefile:1722: tools-only] Error 2


Errors with the Android NDK on Linux resolved by this patch:

  HOSTCC  tools/aisimage.o
In file included from tools/aisimage.c:7:0:
tools/imagetool.h:215:2: error: unknown type name 'ulong'
  ulong file_data,
  ^
In file included from tools/aisimage.c:9:0:
include/image.h:335:2: error: unknown type name 'ulong'
  ulong  start, end;  /* start/end of blob */
  ^
(and 42 similar ulong errors)
make[1]: *** [tools/aisimage.o] Error 1
make: *** [tools-only] Error 2

  HOSTCC  tools/zynqmpbif.o
tools/zynqmpbif.c: In function 'bif_add_bit':
tools/zynqmpbif.c:520:3: warning: implicit declaration of function '__fswab32' 
[-Wimplicit-function-declaration]
   *bitbin32 = __swab32(*bitbin32);
   ^
tools/zynqmpbif.o:zynqmpbif.c:function bif_add_bit: error: undefined reference 
to '__fswab32'
collect2: error: ld returned 1 exit status
make[1]: *** [tools/mkimage] Error 1
make: *** [tools-only] Error 2

Thanks for your time and consideration!
Chris

0001-include-compiler-fix-tools-only-compiles-on-Cygwin-a.patch
Description: 0001-include-compiler-fix-tools-only-compiles-on-Cygwin-a.patch
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] ARM tools-only CROSS_COMPILE issues within Cygwin

2019-04-12 Thread Chris Renshaw
Just posting an update on the current Cygwin issues with U-Boot and the Android 
NDK.

I do have NDK cross-compiles of tools-only working well from a Linux 
environment now but on Cygwin there continues to be some major compatibility 
issue with U-Boot's KBuild system and the Android NDK.

Using the same command-line as my Linux NDK cross-compile on Cygwin results in 
the following odd build error:

  HOSTCC  scripts/basic/fixdep
  CHK     include/config/uboot.release
  CHK     include/generated/version_autogenerated.h
  CHK     include/generated/timestamp_autogenerated.h
  UPD     include/generated/timestamp_autogenerated.h
  HOSTCC  tools/gen_eth_addr
: No such file or directoryg file:
make[1]: *** [scripts/Makefile.host:97: tools/gen_eth_addr] Error 2
make[1]: *** Deleting file 'tools/gen_eth_addr'
make: *** [Makefile:1722: tools-only] Error 2

Then seeing if adding --sysroot helps gives the following also-bizarre error:

  HOSTCC  scripts/basic/fixdep
  CHK     include/config/uboot.release
  CHK     include/generated/version_autogenerated.h
  CHK     include/generated/timestamp_autogenerated.h
  UPD     include/generated/timestamp_autogenerated.h
  HOSTCC  tools/gen_eth_addr
In file included from ././include/compiler.h:19:0,
                 from :0:
g:\cygwin\home\chris\x-tools\arm-linux-androideabi-r15c-api21-unified\lib\gcc\arm-linux-androideabi\4.9.x\include\stdint.h:9:26:
 fatal error: stdint.h: No such file or directory
 # include_next 
                          ^
compilation terminated.
make[1]: *** [scripts/Makefile.host:97: tools/gen_eth_addr] Error 1
make: *** [Makefile:1722: tools-only] Error 2

I'll be uploading a patch to fix issues with tools-only native Cygwin compiles 
and Android NDK cross-compiles on Linux shortly, but Android NDK cross-compiles 
on Cygwin could definitely still use some attention beyond my ability.

Thanks for you for your time!
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] dumpimage: failure on null-padded image dumps

2019-01-21 Thread Chris Renshaw
Hi, I maintain the Android Image Kitchen project, which has U-Boot uImage 
support for the handfull of Android devices that use uImage for their 
boot.img/recovery.img format. This support is achieved using cross-compiles of 
U-Boot's dumpimage and mkimage tools, to all the Android NDK architectures, as 
well as macOS, Linux and Cygwin.

My users have pointed out what appears to be a major flaw in dumpimage. 
Generally - on an Android device at least - a dump of a partition will be made 
with `dd if=/dev/block/*/*/by-name/boot of=boot.img` so this boot.img is the 
size of the entire partition, but dumpimage won't read/extract these, where 
freshly built images work fine.

The reason for this appears to be that dumpimage can only handle images that 
are exactly the size they're supposed to be, and not a single byte more of even 
\x00 padding on the end; anything more and it seems to misinterpret the file as 
a GP image.

Here's me demoing that:

10,485,760 uimage-untrimmed-gb-boot.img (dump from device boot partition)
 5,110,936 uimage-trimmed-gb-boot.img   (correct size)
 5,110,937 uimage-extrabyte-gb-boot.img (single extra \x00 byte added to end)

: dumpimage -l uimage-untrimmed-gb-boot.img
GP Header: Size 27051956 LoadAddr 6116d3f2

: dumpimage -l uimage-trimmed-gb-boot.img
Image Name:   Linux-2.6.35
Created:  Thu Apr 19 13:05:52 2012
Image Type:   ARM Linux Multi-File Image (uncompressed)
Data Size:5110872 Bytes = 4991.09 KiB = 4.87 MiB
Load Address: 80008000
Entry Point:  80008000
Contents:
   Image 0: 3367356 Bytes = 3288.43 KiB = 3.21 MiB
   Image 1: 1743504 Bytes = 1702.64 KiB = 1.66 MiB

: dumpimage -l uimage-extrabyte-gb-boot.img
GP Header: Size 27051956 LoadAddr 6116d3f2


I took a look at the dumpimage source and couldn't find where/why this could be 
happening so I'm hoping someone more familiar here could take a look and 
perhaps help with a fix.

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


Re: [U-Boot] ARM tools-only CROSS_COMPILE issues within Cygwin

2017-05-21 Thread Chris Renshaw
From: U-Boot <u-boot-boun...@lists.denx.de> on behalf of Chris Renshaw 
<osm0...@outlook.com>
Sent: May 20, 2017 12:53 AM
To: u-boot@lists.denx.de
Subject: [U-Boot] ARM tools-only CROSS_COMPILE issues within Cygwin
    
Hi!

I've managed to get U-Boot sandbox_defconfig tools-only compiling nicely in 
Cygwin with a few minor modifications to the source tree I hope you'll consider 
for proper inclusion:

    # Even with case insensitivity disabled, Cygwin does not handle 
execution of the file scripts/Kconfig and the directory scripts/kconfig 
correctly
    mv scripts/Kconfig scripts/Kconfig-scripts;
    sed -i 's;source "scripts/Kconfig";source "scripts/Kconfig-scripts";' 
Kconfig;
    
    # We can still be conservative with our standard without breaking the 
Cygwin compile completely (inline function issues)
    sed -i "s/HOSTCFLAGS\t+= -ansi/HOSTCFLAGS\t+= -std=gnu90/" Makefile;
    
    # Cygwin's compiler will create a .dll, not a .so
    sed -i 's/mv _libfdt.so/mv _libfdt.*/' tools/Makefile;

My problems arise when I then attempt to do the same for any Android NDK 
stand-alone cross-compiler through Cygwin. I've managed to get most other 
things to compile with this setup as the stand-alone is the preferred/only 
method to ensure a proper sysroot etc.  when using Makefiles. The issues and 
some workarounds for getting any further with U-Boot sandbox_defconfig 
tools-only I've come up with so far are as follows:

1) Despite exporting the usual PATH and CROSS_COMPILE environment tools-only 
insists on using HOSTCC and creates Cygwin builds, so:

    export CROSS_BUILD_TOOLS=y CC="${CROSS_COMPILE}gcc";

2) The exports in #1 appear to have the desired effect and forces the 
CROSS_COMPILE toolchain to be used for the tool builds themselves, but produces 
further frustrations:

  HOSTCC  tools/gen_eth_addr
g:/cygwin/home/chris/x-tools/arm-linux-androideabi-4.9/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld.exe:
 error: 
g:/cygwin/home/chris/x-tools/arm-linux-androideabi-4.9/bin/../sysroot/usr/lib/libc.a(atexit.o):
 multiple definition  of 'atexit'
g:/cygwin/home/chris/x-tools/arm-linux-androideabi-4.9/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld.exe:
 
g:/cygwin/home/chris/x-tools/arm-linux-androideabi-4.9/bin/../lib/gcc/arm-linux-androideabi/4.9/crtbegin_dynamic.o:
  previous definition here
g:/cygwin/home/chris/x-tools/arm-linux-androideabi-4.9/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld.exe:
 error: cannot find -ldl
/s/ndk-toolchain/src/build/../gcc/gcc-4.9/libgcc/config/arm/lib1funcs.S:1337: 
error: undefined reference to 'raise'
collect2.exe: error: ld returned 1 exit status
make[1]: *** [scripts/Makefile.host:99: tools/gen_eth_addr] Error 1
make: *** [Makefile:1413: tools-only] Error 2

3) Attempting to resolve #2 by specifying --sysroot= with *any* value (ie. what 
should be working paths like 
"/home/Chris/x-tools/arm-linux-androideabi-4.9/sysroot", 
"G:/cygwin/home/Chris/x-tools/arm-linux-androideabi-4.9/sysroot" or just a 
single nonsense  word like "fubar") breaks the compiler even further:

  HOSTCC  tools/gen_eth_addr
In file included from ././include/compiler.h:19:0,
                 from ././include/libfdt_env.h:12,
                 from :0:
g:\cygwin\home\chris\x-tools\arm-linux-androideabi-4.9\lib\gcc\arm-linux-androideabi\4.9\include\stdint.h:9:26:
 fatal error: stdint.h: No such file or directory
 # include_next 
                          ^
compilation terminated.
make[1]: *** [scripts/Makefile.host:99: tools/gen_eth_addr] Error 1
make: *** [Makefile:1413: tools-only] Error 2

I've attempted to throw -L and -I with various paths at it by adding them to 
the exported CC= override, both with -Wl, and without to no avail. Considering 
under Cygwin itself the tools build and the NDK stand-alone toolchains work 
perfectly for other things  I feel like I'm close, so I'm wondering if there is 
anything I am missing or any fixes (e.g. to make CROSS_COMPILE work normally on 
Cygwin with tools-only, or, getting --sysroot to cooperate like it should) you 
could think of that might improve the situation.

Thank you for any insight or guidance you can provide!

Chris Renshaw
---

Hello,

I haven't yet received a response, but I've looked into this abit more, and it 
appears it has nothing to do with Cygwin, as I'm trying it on my Ubuntu VM and 
it still won't compile with the exact same -ldl error.

Has anyone had any success cross-compiling U-Boot tools with the Android NDK on 
any platform? Is there something I'm missing? Please help.

I'm starting to think that there is some incompatibility between U-Boot's build 
system and the Android NDK itself; could a U-Boot developer please look into 
this?

Thank you for your time,
Chris Renshaw

[U-Boot] ARM tools-only CROSS_COMPILE issues within Cygwin

2017-05-20 Thread Chris Renshaw
Hi!

I've managed to get U-Boot sandbox_defconfig tools-only compiling nicely in 
Cygwin with a few minor modifications to the source tree I hope you'll consider 
for proper inclusion:

# Even with case insensitivity disabled, Cygwin does not handle 
execution of the file scripts/Kconfig and the directory scripts/kconfig 
correctly
mv scripts/Kconfig scripts/Kconfig-scripts;
sed -i 's;source "scripts/Kconfig";source "scripts/Kconfig-scripts";' 
Kconfig;

# We can still be conservative with our standard without breaking the 
Cygwin compile completely (inline function issues)
sed -i "s/HOSTCFLAGS\t+= -ansi/HOSTCFLAGS\t+= -std=gnu90/" Makefile;

# Cygwin's compiler will create a .dll, not a .so
sed -i 's/mv _libfdt.so/mv _libfdt.*/' tools/Makefile;

My problems arise when I then attempt to do the same for any Android NDK 
stand-alone cross-compiler through Cygwin. I've managed to get most other 
things to compile with this setup as the stand-alone is the preferred/only 
method to ensure a proper sysroot etc. when using Makefiles. The issues and 
some workarounds for getting any further with U-Boot sandbox_defconfig 
tools-only I've come up with so far are as follows:

1) Despite exporting the usual PATH and CROSS_COMPILE environment tools-only 
insists on using HOSTCC and creates Cygwin builds, so:

export CROSS_BUILD_TOOLS=y CC="${CROSS_COMPILE}gcc";

2) The exports in #1 appear to have the desired effect and forces the 
CROSS_COMPILE toolchain to be used for the tool builds themselves, but produces 
further frustrations:

  HOSTCC  tools/gen_eth_addr
g:/cygwin/home/chris/x-tools/arm-linux-androideabi-4.9/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld.exe:
 error: 
g:/cygwin/home/chris/x-tools/arm-linux-androideabi-4.9/bin/../sysroot/usr/lib/libc.a(atexit.o):
 multiple definition of 'atexit'
g:/cygwin/home/chris/x-tools/arm-linux-androideabi-4.9/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld.exe:
 
g:/cygwin/home/chris/x-tools/arm-linux-androideabi-4.9/bin/../lib/gcc/arm-linux-androideabi/4.9/crtbegin_dynamic.o:
 previous definition here
g:/cygwin/home/chris/x-tools/arm-linux-androideabi-4.9/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld.exe:
 error: cannot find -ldl
/s/ndk-toolchain/src/build/../gcc/gcc-4.9/libgcc/config/arm/lib1funcs.S:1337: 
error: undefined reference to 'raise'
collect2.exe: error: ld returned 1 exit status
make[1]: *** [scripts/Makefile.host:99: tools/gen_eth_addr] Error 1
make: *** [Makefile:1413: tools-only] Error 2

3) Attempting to resolve #2 by specifying --sysroot= with *any* value (ie. what 
should be working paths like 
"/home/Chris/x-tools/arm-linux-androideabi-4.9/sysroot", 
"G:/cygwin/home/Chris/x-tools/arm-linux-androideabi-4.9/sysroot" or just a 
single nonsense word like "fubar") breaks the compiler even further:

  HOSTCC  tools/gen_eth_addr
In file included from ././include/compiler.h:19:0,
                 from ././include/libfdt_env.h:12,
                 from :0:
g:\cygwin\home\chris\x-tools\arm-linux-androideabi-4.9\lib\gcc\arm-linux-androideabi\4.9\include\stdint.h:9:26:
 fatal error: stdint.h: No such file or directory
 # include_next 
                          ^
compilation terminated.
make[1]: *** [scripts/Makefile.host:99: tools/gen_eth_addr] Error 1
make: *** [Makefile:1413: tools-only] Error 2

I've attempted to throw -L and -I with various paths at it by adding them to 
the exported CC= override, both with -Wl, and without to no avail. Considering 
under Cygwin itself the tools build and the NDK stand-alone toolchains work 
perfectly for other things I feel like I'm close, so I'm wondering if there is 
anything I am missing or any fixes (e.g. to make CROSS_COMPILE work normally on 
Cygwin with tools-only, or, getting --sysroot to cooperate like it should) you 
could think of that might improve the situation.

Thank you for any insight or guidance you can provide!

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