[U-Boot] SUCCESS: Building U-Boot for MIPS64 on Windows7

I was able to successfully Build U-Boot v2018.07 under Windows 7 SP1 (64bit) - under MinGW64_NT-6.1 ( a.k.a. MSYS2 or MSYS64 ) - using the native host toolchain (with GCC v7.3.0 for x86_64 code generation on x86_64 CPU) - using the target toolchain (with GCC v5.3.0 for MIPS code generation on x86_64 CPU (Sourcery CodeBench Lite 2016.05-8) )
by modifying the function parse_dep_file() defnied in u-boot-master/scripts/basic/fixdep.c, as illustrated below:
The change was necessary because the command "gcc cc -Wp,-MD, dependencyfile.o.d..." generates a dependency file containg Windows style paths like: C:\src\bin ...instead of the Linux like path, like: /c/src/bin
static void parse_dep_file(void *map, size_t len) { char *m = map; char *end = m + len; char *p; char s[PATH_MAX]; int is_target; int saw_any_target = 0; int is_first_dep = 0;
while (m < end) { /* Skip any "white space" */ while (m < end && (*m == ' ' || *m == '\t' || *m == '\' || *m == '\r' || *m == '\n')) m++; /* Skip any "non-white space" */ p = m; while (p < end && *p != ' ' && *p != '\t' && *p != '\' && *p != '\r' && *p != '\n') p++;
/* Convert any Windows paths into Cygwin paths, just like "cygpath -u <windowspath>" would do. */ if( ( (p-m) >=2) && (*(m+1) == ':') && ((*(m+2) == '/') || (*(m+2) == '\')) && (((*m>='A') && (*m<='Z')) || ((*m>='a') && (*m<='z'))) ) { *(m+1)= (*m) | 0x20; //Convert the drive letter to lowercase and move it where the colon was *m = '/'; //Prepend a forward slash //*(m+2) = '/'; //Make sure a forward slash follows the drive letter
// Substitute remaining backslashes in the Windows path, with forward slashes while (p < end && *p != ' ' && *p != '\t' && *p != '\r' && *p != '\n') { if(*p == '\') *p = '/'; p++; } #ifdef FIXDEP_DBG fprintf(stderr,"FIXDEP: Windows path at %ld= %s\n", m-(char*)map, m); #endif }
/* Is the token we found a target name? */ is_target = (*(p-1) == ':'); /* Don't write any target names into the dependency file */ if (is_target) { /* The /next/ file is the first dependency */ is_first_dep = 1; } else if( (p-m) > 0 ) { /* Save this token/filename */ memcpy(s, m, p-m); s[p - m] = 0;
/* Ignore certain dependencies */ if (strrcmp(s, "include/generated/autoconf.h") && strrcmp(s, "arch/um/include/uml-config.h") && strrcmp(s, "include/linux/kconfig.h") && strrcmp(s, ".ver")) { /* * Do not list the source file as dependency, * so that kbuild is not confused if a .c file * is rewritten into .S or vice versa. Storing * it in source_* is needed for modpost to * compute srcversions. */ if (is_first_dep) { /* * If processing the concatenation of * multiple dependency files, only * process the first target name, which * will be the original source name, * and ignore any other target names, * which will be intermediate temporary * files. */ if (!saw_any_target) { saw_any_target = 1; printf("source_%s := %s\n\n", target, s); printf("deps_%s := \\n", target); } is_first_dep = 0; } else printf(" %s \\n", s); do_config_file(s); } } /* * Start searching for next token immediately after the first * "whitespace" character that follows this token. */ m = p + 1; }
if (!saw_any_target) { fprintf(stderr, "fixdep: parse error; no targets found\n"); exit(1); }
printf("\n%s: $(deps_%s)\n\n", target, target); printf("$(deps_%s):\n", target); }
Also the command "gcc -print-file-name=include" generates such Windows style paths. They can be adjusted by patching the NOSTDINC_FLAGS assignment in the main Makefile as such:
PossiblyWinPath = $(shell $(CC) -print-file-name=include) NOSTDINC_FLAGS += -nostdinc -isystem $(shell cygpath -u $(subst \,/,$(PossiblyWinPath))) CHECKFLAGS += $(NOSTDINC_FLAGS)
Besides the above, in order to get it to compile I had to define the following data types because they were Linux-specific and were not defined in the sys/types.h belonging to MinGW64.
#ifdef __CHECKER__ #define __bitwise__ __attribute__((bitwise)) #else #define __bitwise__ #endif #ifdef __CHECK_ENDIAN__ #define __bitwise __bitwise__ #else #define __bitwise #endif
typedef unsigned short __u16; typedef unsigned int __u32; typedef unsigned long long int __u64;
typedef __u16 __bitwise __le16; typedef __u16 __bitwise __be16; typedef __u32 __bitwise __le32; typedef __u32 __bitwise __be32; #if defined(__GNUC__) typedef __u64 __bitwise __le64; typedef __u64 __bitwise __be64; #endif typedef __u16 __bitwise __sum16; typedef __u32 __bitwise __wsum;
Also, I had to add: #include <linux/byteorder/swab.h>
...to the file tools/zynqmpbif.c, because__swab32 was not defined anywhere in the default headers.
Is, this of any interest to anyone ?

Hi,
On Thu, Aug 2, 2018 at 6:48 AM, George Robinson george.robinson@prototech.us wrote:
I was able to successfully Build U-Boot v2018.07 under Windows 7 SP1 (64bit)
- under MinGW64_NT-6.1 ( a.k.a. MSYS2 or MSYS64 )
- using the native host toolchain (with GCC v7.3.0 for x86_64 code
generation on x86_64 CPU)
- using the target toolchain (with GCC v5.3.0 for MIPS code generation on
x86_64 CPU (Sourcery CodeBench Lite 2016.05-8) )
by modifying the function parse_dep_file() defnied in u-boot-master/scripts/basic/fixdep.c, as illustrated below:
The change was necessary because the command "gcc cc -Wp,-MD, dependencyfile.o.d..." generates a dependency file containg Windows style paths like: C:\src\bin ...instead of the Linux like path, like: /c/src/bin
static void parse_dep_file(void *map, size_t len) { char *m = map; char *end = m + len; char *p; char s[PATH_MAX]; int is_target; int saw_any_target = 0; int is_first_dep = 0;
while (m < end) { /* Skip any "white space" */ while (m < end && (*m == ' ' || *m == '\t' || *m == '\\' ||
*m == '\r' || *m == '\n')) m++; /* Skip any "non-white space" */ p = m; while (p < end && *p != ' ' && *p != '\t' && *p != '\' && *p != '\r' && *p != '\n') p++;
/* Convert any Windows paths into Cygwin paths, just like
"cygpath -u <windowspath>" would do. */ if( ( (p-m) >=2) && (*(m+1) == ':') && ((*(m+2) == '/') || (*(m+2) == '\')) && (((*m>='A') && (*m<='Z')) || ((*m>='a') && (*m<='z'))) ) { *(m+1)= (*m) | 0x20; //Convert the drive letter to lowercase and move it where the colon was *m = '/'; //Prepend a forward slash //*(m+2) = '/'; //Make sure a forward slash follows the drive letter
// Substitute remaining backslashes in the Windows
path, with forward slashes while (p < end && *p != ' ' && *p != '\t' && *p != '\r' && *p != '\n') { if(*p == '\') *p = '/'; p++; } #ifdef FIXDEP_DBG fprintf(stderr,"FIXDEP: Windows path at %ld= %s\n", m-(char*)map, m); #endif }
/* Is the token we found a target name? */ is_target = (*(p-1) == ':'); /* Don't write any target names into the dependency file */ if (is_target) { /* The /next/ file is the first dependency */ is_first_dep = 1; } else if( (p-m) > 0 ) { /* Save this token/filename */ memcpy(s, m, p-m); s[p - m] = 0; /* Ignore certain dependencies */ if (strrcmp(s, "include/generated/autoconf.h") && strrcmp(s, "arch/um/include/uml-config.h") && strrcmp(s, "include/linux/kconfig.h") && strrcmp(s, ".ver")) { /* * Do not list the source file as
dependency, * so that kbuild is not confused if a .c file * is rewritten into .S or vice versa. Storing * it in source_* is needed for modpost to * compute srcversions. */ if (is_first_dep) { /* * If processing the concatenation of * multiple dependency files, only * process the first target name, which * will be the original source name, * and ignore any other target names, * which will be intermediate temporary * files. */ if (!saw_any_target) { saw_any_target = 1; printf("source_%s := %s\n\n", target, s); printf("deps_%s := \\n", target); } is_first_dep = 0; } else printf(" %s \\n", s); do_config_file(s); } } /* * Start searching for next token immediately after the first * "whitespace" character that follows this token. */ m = p + 1; }
if (!saw_any_target) { fprintf(stderr, "fixdep: parse error; no targets found\n"); exit(1); } printf("\n%s: $(deps_%s)\n\n", target, target); printf("$(deps_%s):\n", target);
}
Also the command "gcc -print-file-name=include" generates such Windows style paths. They can be adjusted by patching the NOSTDINC_FLAGS assignment in the main Makefile as such:
PossiblyWinPath = $(shell $(CC) -print-file-name=include) NOSTDINC_FLAGS += -nostdinc -isystem $(shell cygpath -u $(subst \,/,$(PossiblyWinPath))) CHECKFLAGS += $(NOSTDINC_FLAGS)
Besides the above, in order to get it to compile I had to define the following data types because they were Linux-specific and were not defined in the sys/types.h belonging to MinGW64.
#ifdef __CHECKER__ #define __bitwise__ __attribute__((bitwise)) #else #define __bitwise__ #endif #ifdef __CHECK_ENDIAN__ #define __bitwise __bitwise__ #else #define __bitwise #endif
typedef unsigned short __u16; typedef unsigned int __u32; typedef unsigned long long int __u64;
typedef __u16 __bitwise __le16; typedef __u16 __bitwise __be16; typedef __u32 __bitwise __le32; typedef __u32 __bitwise __be32; #if defined(__GNUC__) typedef __u64 __bitwise __le64; typedef __u64 __bitwise __be64; #endif typedef __u16 __bitwise __sum16; typedef __u32 __bitwise __wsum;
Also, I had to add: #include <linux/byteorder/swab.h>
...to the file tools/zynqmpbif.c, because__swab32 was not defined anywhere in the default headers.
Is, this of any interest to anyone ?
Yes, please get the patch properly formatted and submit to the ML for review and testing. Thanks!
Regards, Bin
participants (2)
-
Bin Meng
-
George Robinson