diff --git a/.gitmodules b/.gitmodules index 154c825bb..764ec1cad 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,10 +1,10 @@ [submodule "crosstool-NG"] path = crosstool-NG url = https://github.com/jcmvbkbc/crosstool-NG - branch = lx106-g++ + branch = xtensa-1.22.x [submodule "lx106-hal"] path = lx106-hal url = https://github.com/tommie/lx106-hal [submodule "esptool"] path = esptool - url = https://github.com/pfalcon/esptool + url = https://github.com/themadinventor/esptool diff --git a/1000-mforce-l32.patch b/1000-mforce-l32.patch new file mode 100644 index 000000000..a8859d81c --- /dev/null +++ b/1000-mforce-l32.patch @@ -0,0 +1,253 @@ +https://github.com/jcmvbkbc/gcc-xtensa/commit/6b0c9f92fb8e11c6be098febb4f502f6af37cd35.patch + +From 6b0c9f92fb8e11c6be098febb4f502f6af37cd35 Mon Sep 17 00:00:00 2001 +From: Max Filippov +Date: Thu, 11 Jun 2015 17:56:57 +0300 +Subject: [PATCH] WIP: xtensa: add -mforce-l32 + +Signed-off-by: Max Filippov +--- + gcc/config/xtensa/constraints.md | 15 ++++++++++++ + gcc/config/xtensa/xtensa.c | 53 +++++++++++++++++++++++++++++++++++++++- + gcc/config/xtensa/xtensa.md | 49 ++++++++++++++++++++----------------- + gcc/config/xtensa/xtensa.opt | 4 +++ + 4 files changed, 98 insertions(+), 23 deletions(-) + +diff --git a/gcc/config/xtensa/constraints.md b/gcc/config/xtensa/constraints.md +index 30f4c1f..5fd9337 100644 +--- a/gcc/config/xtensa/constraints.md ++++ b/gcc/config/xtensa/constraints.md +@@ -137,3 +137,18 @@ + (and (match_code "reg") + (match_test "reload_in_progress + && REGNO (op) >= FIRST_PSEUDO_REGISTER")))) ++ ++(define_constraint "Y" ++ "Memory that is not in a literal pool." ++ (ior (and (and (match_code "mem") ++ (match_test "! constantpool_mem_p (op)")) ++ (match_test "!TARGET_FORCE_L32")) ++ (and (match_code "reg") ++ (match_test "reload_in_progress ++ && REGNO (op) >= FIRST_PSEUDO_REGISTER")))) ++ ++(define_constraint "Z" ++ "Memory that is not in a literal pool." ++ (and (and (match_code "mem") ++ (match_test "! constantpool_mem_p (op)")) ++ (match_test "TARGET_FORCE_L32"))) +diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c +index d8c5b41..559b181 100644 +--- a/gcc/config/xtensa/xtensa.c ++++ b/gcc/config/xtensa/xtensa.c +@@ -1824,7 +1824,8 @@ xtensa_legitimate_address_p (machine_mode mode, rtx addr, bool strict) + return true; + + /* Check for "register + offset" addressing. */ +- if (GET_CODE (addr) == PLUS) ++ if (GET_CODE (addr) == PLUS && ++ (!TARGET_FORCE_L32 || (mode != HImode && mode != QImode))) + { + rtx xplus0 = XEXP (addr, 0); + rtx xplus1 = XEXP (addr, 1); +@@ -2308,6 +2309,8 @@ printx (FILE *file, signed int val) + fprintf (file, "0x%x", val); + } + ++static void ++output_address_base (FILE *file, rtx addr); + + void + print_operand (FILE *file, rtx x, int letter) +@@ -2317,6 +2320,13 @@ print_operand (FILE *file, rtx x, int letter) + + switch (letter) + { ++ case 'B': ++ if (GET_CODE (x) == MEM) ++ output_address_base (file, XEXP (x, 0)); ++ else ++ output_operand_lossage ("invalid %%B value"); ++ break; ++ + case 'D': + if (GET_CODE (x) == REG || GET_CODE (x) == SUBREG) + fprintf (file, "%s", reg_names[xt_true_regnum (x) + 1]); +@@ -2450,6 +2460,47 @@ print_operand (FILE *file, rtx x, int letter) + } + } + ++static void ++output_address_base (FILE *file, rtx addr) ++{ ++ switch (GET_CODE (addr)) ++ { ++ default: ++ fatal_insn ("invalid address", addr); ++ break; ++ ++ case REG: ++ fprintf (file, "%s", reg_names [REGNO (addr)]); ++ break; ++ ++ case PLUS: ++ { ++ rtx reg = (rtx)0; ++ rtx offset = (rtx)0; ++ rtx arg0 = XEXP (addr, 0); ++ rtx arg1 = XEXP (addr, 1); ++ ++ if (GET_CODE (arg0) == REG) ++ { ++ reg = arg0; ++ offset = arg1; ++ } ++ else if (GET_CODE (arg1) == REG) ++ { ++ reg = arg1; ++ offset = arg0; ++ } ++ else ++ fatal_insn ("no register in address", addr); ++ ++ if (CONSTANT_P (offset)) ++ fprintf (file, "%s", reg_names [REGNO (reg)]); ++ else ++ fatal_insn ("address offset not a constant", addr); ++ } ++ break; ++ } ++} + + /* A C compound statement to output to stdio stream STREAM the + assembler syntax for an instruction operand that is a memory +diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md +index a577aa3..f56c45e 100644 +--- a/gcc/config/xtensa/xtensa.md ++++ b/gcc/config/xtensa/xtensa.md +@@ -532,26 +532,28 @@ + ;; Zero-extend instructions. + + (define_insn "zero_extendhisi2" +- [(set (match_operand:SI 0 "register_operand" "=a,a") +- (zero_extend:SI (match_operand:HI 1 "nonimmed_operand" "r,U")))] ++ [(set (match_operand:SI 0 "register_operand" "=a,a,a") ++ (zero_extend:SI (match_operand:HI 1 "nonimmed_operand" "r,Y,Z")))] + "" + "@ + extui\t%0, %1, 0, 16 +- l16ui\t%0, %1" +- [(set_attr "type" "arith,load") ++ l16ui\t%0, %1 ++ ssa8l\t%B1 ; srli\t%0, %B1, 2 ; slli\t%0, %0, 2 ; l32i\t%0, %0, 0 ; srl\t%0, %0 ; extui\t%0, %0, 0, 16" ++ [(set_attr "type" "arith,load,load") + (set_attr "mode" "SI") +- (set_attr "length" "3,3")]) ++ (set_attr "length" "3,3,18")]) + + (define_insn "zero_extendqisi2" +- [(set (match_operand:SI 0 "register_operand" "=a,a") +- (zero_extend:SI (match_operand:QI 1 "nonimmed_operand" "r,U")))] ++ [(set (match_operand:SI 0 "register_operand" "=a,a,a") ++ (zero_extend:SI (match_operand:QI 1 "nonimmed_operand" "r,Y,Z")))] + "" + "@ + extui\t%0, %1, 0, 8 +- l8ui\t%0, %1" +- [(set_attr "type" "arith,load") ++ l8ui\t%0, %1 ++ ssa8l\t%B1 ; srli\t%0, %B1, 2 ; slli\t%0, %0, 2 ; l32i\t%0, %0, 0 ; srl\t%0, %0 ; extui\t%0, %0, 0, 8" ++ [(set_attr "type" "arith,load,load") + (set_attr "mode" "SI") +- (set_attr "length" "3,3")]) ++ (set_attr "length" "3,3,18")]) + + + ;; Sign-extend instructions. +@@ -569,15 +571,16 @@ + }) + + (define_insn "extendhisi2_internal" +- [(set (match_operand:SI 0 "register_operand" "=B,a") +- (sign_extend:SI (match_operand:HI 1 "sext_operand" "r,U")))] ++ [(set (match_operand:SI 0 "register_operand" "=B,a,a") ++ (sign_extend:SI (match_operand:HI 1 "sext_operand" "r,r,Y")))] + "" + "@ + sext\t%0, %1, 15 ++ slli\t%0, %1, 16 ; srai\t%0, %0, 16 + l16si\t%0, %1" +- [(set_attr "type" "arith,load") ++ [(set_attr "type" "arith,arith,load") + (set_attr "mode" "SI") +- (set_attr "length" "3,3")]) ++ (set_attr "length" "3,6,3")]) + + (define_expand "extendqisi2" + [(set (match_operand:SI 0 "register_operand" "") +@@ -796,8 +799,8 @@ + }) + + (define_insn "movhi_internal" +- [(set (match_operand:HI 0 "nonimmed_operand" "=D,D,a,a,a,U,*a,*A") +- (match_operand:HI 1 "move_operand" "M,d,r,I,U,r,*A,*r"))] ++ [(set (match_operand:HI 0 "nonimmed_operand" "=D,D,a,a,a,a,U,*a,*A") ++ (match_operand:HI 1 "move_operand" "M,d,r,I,Y,Z,r,*A,*r"))] + "xtensa_valid_move (HImode, operands)" + "@ + movi.n\t%0, %x1 +@@ -805,12 +808,13 @@ + mov\t%0, %1 + movi\t%0, %x1 + %v1l16ui\t%0, %1 ++ ssa8l\t%B1 ; srli\t%0, %B1, 2 ; slli\t%0, %0, 2 ; %v1l32i\t%0, %0, 0 ; srl\t%0, %0 ; extui\t%0, %0, 0, 16 + %v0s16i\t%1, %0 + rsr\t%0, ACCLO + wsr\t%1, ACCLO" +- [(set_attr "type" "move,move,move,move,load,store,rsr,wsr") ++ [(set_attr "type" "move,move,move,move,load,load,store,rsr,wsr") + (set_attr "mode" "HI") +- (set_attr "length" "2,2,3,3,3,3,3,3")]) ++ (set_attr "length" "2,2,3,3,3,18,3,3,3")]) + + ;; 8-bit Integer moves + +@@ -824,8 +828,8 @@ + }) + + (define_insn "movqi_internal" +- [(set (match_operand:QI 0 "nonimmed_operand" "=D,D,a,a,a,U,*a,*A") +- (match_operand:QI 1 "move_operand" "M,d,r,I,U,r,*A,*r"))] ++ [(set (match_operand:QI 0 "nonimmed_operand" "=D,D,a,a,a,a,U,*a,*A") ++ (match_operand:QI 1 "move_operand" "M,d,r,I,Y,Z,r,*A,*r"))] + "xtensa_valid_move (QImode, operands)" + "@ + movi.n\t%0, %x1 +@@ -833,12 +837,13 @@ + mov\t%0, %1 + movi\t%0, %x1 + %v1l8ui\t%0, %1 ++ ssa8l\t%B1 ; srli\t%0, %B1, 2 ; slli\t%0, %0, 2 ; %v1l32i\t%0, %0, 0 ; srl\t%0, %0 ; extui\t%0, %0, 0, 8 + %v0s8i\t%1, %0 + rsr\t%0, ACCLO + wsr\t%1, ACCLO" +- [(set_attr "type" "move,move,move,move,load,store,rsr,wsr") ++ [(set_attr "type" "move,move,move,move,load,load,store,rsr,wsr") + (set_attr "mode" "QI") +- (set_attr "length" "2,2,3,3,3,3,3,3")]) ++ (set_attr "length" "2,2,3,3,3,18,3,3,3")]) + + ;; Sub-word reloads from the constant pool. + +diff --git a/gcc/config/xtensa/xtensa.opt b/gcc/config/xtensa/xtensa.opt +index 2fd6cee..02020d2 100644 +--- a/gcc/config/xtensa/xtensa.opt ++++ b/gcc/config/xtensa/xtensa.opt +@@ -41,3 +41,7 @@ Intersperse literal pools with code in the text section + mserialize-volatile + Target Report Mask(SERIALIZE_VOLATILE) + -mno-serialize-volatile Do not serialize volatile memory references with MEMW instructions ++ ++mforce-l32 ++Target Report Mask(FORCE_L32) ++Use l32i to access 1- and 2-byte quantities in memory instead of l8ui/l16ui diff --git a/9000-newlib-flags.patch b/9000-newlib-flags.patch new file mode 100644 index 000000000..4120423d9 --- /dev/null +++ b/9000-newlib-flags.patch @@ -0,0 +1,12 @@ +--- a/newlib/configure.host 2015-11-12 14:04:48.064467034 +0000 ++++ b/newlib/configure.host 2015-11-12 14:07:45.645532708 +0000 +@@ -285,7 +285,8 @@ + xtensa) + libm_machine_dir=xtensa + machine_dir=xtensa +- newlib_cflags="${newlib_cflags} -mlongcalls" ++ newlib_cflags="${newlib_cflags} -mlongcalls -ffunction-sections -mtext-section-literals -Os" ++ newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED" + newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED" + ;; + z8k) diff --git a/9001-newlib-disable-rom-funcs.patch b/9001-newlib-disable-rom-funcs.patch new file mode 100644 index 000000000..b63d68ad8 --- /dev/null +++ b/9001-newlib-disable-rom-funcs.patch @@ -0,0 +1,170 @@ +diff -ru a/newlib/libc/machine/xtensa/memcpy.S b/newlib/libc/machine/xtensa/memcpy.S +--- a/newlib/libc/machine/xtensa/memcpy.S 2015-08-25 09:37:13.871717025 +0800 ++++ b/newlib/libc/machine/xtensa/memcpy.S 2015-08-25 10:00:03.000000000 +0800 +@@ -1,3 +1,5 @@ ++/* esp8266 has this function in rom */ ++#if 1 + /* ANSI C standard library function memcpy. + + Copyright (c) 2002-2008 Tensilica Inc. +@@ -287,3 +289,4 @@ + .end schedule + + .size memcpy, . - memcpy ++#endif +diff -ru a/newlib/libc/machine/xtensa/memset.S b/newlib/libc/machine/xtensa/memset.S +--- a/newlib/libc/machine/xtensa/memset.S 2015-08-25 09:37:13.855716648 +0800 ++++ b/newlib/libc/machine/xtensa/memset.S 2015-08-25 09:59:51.000000000 +0800 +@@ -1,3 +1,5 @@ ++/* esp8266 has this function in rom */ ++#if 0 + /* ANSI C standard library function memset. + + Copyright (c) 2001-2008 Tensilica Inc. +@@ -168,3 +170,4 @@ + .end schedule + + .size memset, . - memset ++#endif +diff -ru a/newlib/libc/machine/xtensa/strcmp.S b/newlib/libc/machine/xtensa/strcmp.S +--- a/newlib/libc/machine/xtensa/strcmp.S 2015-08-25 09:37:13.871717025 +0800 ++++ b/newlib/libc/machine/xtensa/strcmp.S 2015-08-25 09:58:38.000000000 +0800 +@@ -1,3 +1,5 @@ ++/* esp8266 has this function in rom */ ++#if 0 + /* ANSI C standard library function strcmp. + + Copyright (c) 2001-20012 Tensilica Inc. +@@ -776,3 +778,4 @@ + #endif /* FLIX3*/ + + .size strcmp, . - strcmp ++#endif +diff -ru a/newlib/libc/machine/xtensa/strcpy.S b/newlib/libc/machine/xtensa/strcpy.S +--- a/newlib/libc/machine/xtensa/strcpy.S 2015-08-25 09:37:13.855716648 +0800 ++++ b/newlib/libc/machine/xtensa/strcpy.S 2015-08-25 09:59:08.000000000 +0800 +@@ -1,3 +1,5 @@ ++/* esp8266 has this function in rom */ ++#if 0 + /* ANSI C standard library function strcpy. + + Copyright (c) 2001-2008 Tensilica Inc. +@@ -233,3 +235,4 @@ + .end schedule + + .size strcpy, . - strcpy ++#endif +diff -ru a/newlib/libc/machine/xtensa/strlen.S b/newlib/libc/machine/xtensa/strlen.S +--- a/newlib/libc/machine/xtensa/strlen.S 2015-08-25 09:37:13.871717025 +0800 ++++ b/newlib/libc/machine/xtensa/strlen.S 2015-08-25 09:59:22.000000000 +0800 +@@ -1,3 +1,5 @@ ++/* esp8266 has this function in rom */ ++#if 0 + /* ANSI C standard library function strlen. + + Copyright (c) 2001-2008 Tensilica Inc. +@@ -113,3 +115,4 @@ + .end schedule + + .size strlen, . - strlen ++#endif +diff -ru a/newlib/libc/machine/xtensa/strncpy.S b/newlib/libc/machine/xtensa/strncpy.S +--- a/newlib/libc/machine/xtensa/strncpy.S 2015-08-25 09:37:13.859716742 +0800 ++++ b/newlib/libc/machine/xtensa/strncpy.S 2015-08-25 09:59:37.000000000 +0800 +@@ -1,3 +1,5 @@ ++/* esp8266 has this function in rom */ ++#if 0 + /* ANSI C standard library function strncpy. + + Copyright (c) 2001-2008 Tensilica Inc. +@@ -256,3 +258,4 @@ + .end schedule + + .size strncpy, . - strncpy ++#endif +diff -ru a/newlib/libc/string/bzero.c b/newlib/libc/string/bzero.c +--- a/newlib/libc/string/bzero.c 2015-08-25 09:37:10.851645991 +0800 ++++ b/newlib/libc/string/bzero.c 2015-08-25 09:56:18.000000000 +0800 +@@ -32,6 +32,8 @@ + + #include + ++/* esp8266 has this function in rom */ ++#if 0 + _VOID + _DEFUN (bzero, (b, length), + void *b _AND +@@ -41,3 +43,4 @@ + while (length--) + *ptr++ = 0; + } ++#endif +diff -ru a/newlib/libc/string/memcmp.c b/newlib/libc/string/memcmp.c +--- a/newlib/libc/string/memcmp.c 2015-08-25 09:37:10.859646179 +0800 ++++ b/newlib/libc/string/memcmp.c 2015-08-25 09:57:13.000000000 +0800 +@@ -49,6 +49,8 @@ + /* Threshhold for punting to the byte copier. */ + #define TOO_SMALL(LEN) ((LEN) < LBLOCKSIZE) + ++/* esp8266 has this function in rom */ ++#if 0 + int + _DEFUN (memcmp, (m1, m2, n), + _CONST _PTR m1 _AND +@@ -110,4 +112,5 @@ + return 0; + #endif /* not PREFER_SIZE_OVER_SPEED */ + } ++#endif + +diff -ru a/newlib/libc/string/memmove.c b/newlib/libc/string/memmove.c +--- a/newlib/libc/string/memmove.c 2015-08-25 09:37:10.855646086 +0800 ++++ b/newlib/libc/string/memmove.c 2015-08-25 09:56:46.000000000 +0800 +@@ -53,6 +53,8 @@ + /* Threshhold for punting to the byte copier. */ + #define TOO_SMALL(LEN) ((LEN) < BIGBLOCKSIZE) + ++/* esp8266 has this function in rom */ ++#if 0 + /*SUPPRESS 20*/ + _PTR + _DEFUN (memmove, (dst_void, src_void, length), +@@ -140,3 +142,4 @@ + return dst_void; + #endif /* not PREFER_SIZE_OVER_SPEED */ + } ++#endif +diff -ru a/newlib/libc/string/strncmp.c b/newlib/libc/string/strncmp.c +--- a/newlib/libc/string/strncmp.c 2015-08-25 09:37:10.851645991 +0800 ++++ b/newlib/libc/string/strncmp.c 2015-08-25 09:55:31.000000000 +0800 +@@ -58,6 +58,8 @@ + #error long int is not a 32bit or 64bit byte + #endif + ++/* esp8266 has this function in rom */ ++#if 0 + int + _DEFUN (strncmp, (s1, s2, n), + _CONST char *s1 _AND +@@ -120,3 +122,4 @@ + return (*(unsigned char *) s1) - (*(unsigned char *) s2); + #endif /* not PREFER_SIZE_OVER_SPEED */ + } ++#endif +diff -ru a/newlib/libc/string/strstr.c b/newlib/libc/string/strstr.c +--- a/newlib/libc/string/strstr.c 2015-08-25 09:37:10.859646179 +0800 ++++ b/newlib/libc/string/strstr.c 2015-08-25 09:55:56.000000000 +0800 +@@ -44,6 +44,8 @@ + # include "str-two-way.h" + #endif + ++/* esp8266 has this function in rom */ ++#if 0 + char * + _DEFUN (strstr, (searchee, lookfor), + _CONST char *searchee _AND +@@ -119,3 +121,4 @@ + (const unsigned char *) lookfor, needle_len); + #endif /* compilation for speed */ + } ++#endif diff --git a/9002-libgcc-disable-rom-funcs.patch b/9002-libgcc-disable-rom-funcs.patch new file mode 100644 index 000000000..0bf9aff73 --- /dev/null +++ b/9002-libgcc-disable-rom-funcs.patch @@ -0,0 +1,63 @@ +diff -ru a/libgcc/config/xtensa/t-xtensa b/libgcc/config/xtensa/t-xtensa +--- a/libgcc/config/xtensa/t-xtensa 2015-08-25 10:24:19.439057512 +0800 ++++ b/libgcc/config/xtensa/t-xtensa 2015-08-25 10:26:34.462308416 +0800 +@@ -1,13 +1,12 @@ + LIB1ASMSRC = xtensa/lib1funcs.S +-LIB1ASMFUNCS = _mulsi3 _divsi3 _modsi3 _udivsi3 _umodsi3 \ +- _umulsidi3 _clz _clzsi2 _ctzsi2 _ffssi2 \ ++LIB1ASMFUNCS = _mulsi3 _modsi3 \ ++ _clz _clzsi2 _ctzsi2 _ffssi2 \ + _ashldi3 _ashrdi3 _lshrdi3 \ +- _negsf2 _addsubsf3 _mulsf3 _divsf3 _cmpsf2 _fixsfsi _fixsfdi \ +- _fixunssfsi _fixunssfdi _floatsisf _floatunsisf \ ++ _negsf2 _mulsf3 _divsf3 _cmpsf2 _fixsfsi _fixsfdi \ ++ _fixunssfdi \ + _floatdisf _floatundisf \ +- _negdf2 _addsubdf3 _muldf3 _divdf3 _cmpdf2 _fixdfsi _fixdfdi \ +- _fixunsdfsi _fixunsdfdi _floatsidf _floatunsidf \ +- _floatdidf _floatundidf \ +- _truncdfsf2 _extendsfdf2 ++ _negdf2 _cmpdf2 _fixdfdi \ ++ _fixunsdfdi \ ++ _floatdidf _floatundidf + + LIB2ADD = $(srcdir)/config/xtensa/lib2funcs.S +diff -ru a/libgcc/Makefile.in b/libgcc/Makefile.in +--- a/libgcc/Makefile.in 2015-08-25 10:24:19.427057223 +0800 ++++ b/libgcc/Makefile.in 2015-08-25 10:27:39.511874029 +0800 +@@ -245,7 +245,7 @@ + + # These might cause a divide overflow trap and so are compiled with + # unwinder info. +-LIB2_DIVMOD_FUNCS = _divdi3 _moddi3 _udivdi3 _umoddi3 _udiv_w_sdiv _udivmoddi4 ++LIB2_DIVMOD_FUNCS = _moddi3 _udiv_w_sdiv _udivmoddi4 + + # List of extra C and assembler files to add to static and shared libgcc2. + # Assembler files should have names ending in `.S'. +@@ -401,7 +401,7 @@ + LIB2ADDEHSHARED += $(srcdir)/emutls.c + + # Library members defined in libgcc2.c. +-lib2funcs = _muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3 _cmpdi2 _ucmpdi2 \ ++lib2funcs = _negdi2 _lshrdi3 _ashldi3 _ashrdi3 _cmpdi2 _ucmpdi2 \ + _clear_cache _trampoline __main _absvsi2 \ + _absvdi2 _addvsi3 _addvdi3 _subvsi3 _subvdi3 _mulvsi3 _mulvdi3 \ + _negvsi2 _negvdi2 _ctors _ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 \ +@@ -412,7 +412,7 @@ + + # The floating-point conversion routines that involve a single-word integer. + # XX stands for the integer mode. +-swfloatfuncs = $(patsubst %,_fixuns%XX,sf df xf) ++swfloatfuncs = $(patsubst %,_fixuns%XX,xf) + + # Likewise double-word routines. + dwfloatfuncs = $(patsubst %,_fix%XX,sf df xf tf) \ +@@ -427,7 +427,7 @@ + + # These might cause a divide overflow trap and so are compiled with + # unwinder info. +-LIB2_DIVMOD_FUNCS = _divdi3 _moddi3 _udivdi3 _umoddi3 _udiv_w_sdiv _udivmoddi4 ++LIB2_DIVMOD_FUNCS = _moddi3 _udiv_w_sdiv _udivmoddi4 + + # Remove any objects from lib2funcs and LIB2_DIVMOD_FUNCS that are + # defined as optimized assembly code in LIB1ASMFUNCS or as C code diff --git a/Makefile b/Makefile index 5ea49015b..b4f9e842b 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,21 @@ TOP = $(PWD) TOOLCHAIN = $(TOP)/xtensa-lx106-elf -VENDOR_SDK = 1.4.0 +VENDOR_SDK = 2.0.0 UNZIP = unzip -q -o VENDOR_SDK_ZIP = $(VENDOR_SDK_ZIP_$(VENDOR_SDK)) VENDOR_SDK_DIR = $(VENDOR_SDK_DIR_$(VENDOR_SDK)) +VENDOR_SDK_ZIP_2.0.0 = ESP8266_NONOS_SDK_V2.0.0_16_08_10.zip +VENDOR_SDK_ZIP_2.0.0dead1 = ESP8266_NONOS_SDK_V2.0.0_16_07_19.zip +VENDOR_SDK_DIR_2.0.0 = ESP8266_NONOS_SDK +VENDOR_SDK_ZIP_1.5.2 = ESP8266_NONOS_SDK_V1.5.2_16_01_29.zip +VENDOR_SDK_DIR_1.5.2 = esp_iot_sdk_v1.5.2 +VENDOR_SDK_ZIP_1.5.0 = esp_iot_sdk_v1.5.0_15_11_27.zip +VENDOR_SDK_DIR_1.5.0 = esp_iot_sdk_v1.5.0 +VENDOR_SDK_ZIP_1.4.1 = esp_iot_sdk_v1.4.1_pre5_15_10_27.zip +VENDOR_SDK_DIR_1.4.1 = esp_iot_sdk_v1.4.1_pre5 VENDOR_SDK_ZIP_1.4.0 = esp_iot_sdk_v1.4.0_15_09_18.zip VENDOR_SDK_DIR_1.4.0 = esp_iot_sdk_v1.4.0 VENDOR_SDK_ZIP_1.3.0 = esp_iot_sdk_v1.3.0_15_08_08.zip @@ -42,9 +51,12 @@ VENDOR_SDK_ZIP_0.9.2 = esp_iot_sdk_v0.9.2_14_10_24.zip VENDOR_SDK_DIR_0.9.2 = esp_iot_sdk_v0.9.2 STANDALONE = y -.PHONY: crosstool-NG toolchain libhal libcirom sdk +.PHONY: crosstool-NG toolchain libhal sdk -all: esptool libcirom standalone sdk sdk_patch $(TOOLCHAIN)/xtensa-lx106-elf/sysroot/usr/lib/libhal.a $(TOOLCHAIN)/bin/xtensa-lx106-elf-gcc +LIBHAL := $(TOOLCHAIN)/xtensa-lx106-elf/sysroot/usr/lib/libhal.a +LIBGCC := $(TOOLCHAIN)/lib/gcc/xtensa-lx106-elf/4.8.5/libgcc.a + +all: esptool standalone sdk .sdk_patch $(LIBHAL) $(TOOLCHAIN)/bin/xtensa-lx106-elf-gcc @echo @echo "Xtensa toolchain is built, to use it:" @echo @@ -64,14 +76,32 @@ endif esptool: toolchain cp esptool/esptool.py $(TOOLCHAIN)/bin/ -$(TOOLCHAIN)/xtensa-lx106-elf/sysroot/lib/libcirom.a: $(TOOLCHAIN)/xtensa-lx106-elf/sysroot/lib/libc.a $(TOOLCHAIN)/bin/xtensa-lx106-elf-gcc - @echo "Creating irom version of libc..." - $(TOOLCHAIN)/bin/xtensa-lx106-elf-objcopy --rename-section .text=.irom0.text \ - --rename-section .literal=.irom0.literal $(<) $(@); +.sdk_patch: .sdk_patch_$(VENDOR_SDK) $(TOOLCHAIN)/bin/xtensa-lx106-elf-gcc + for l in sdk/lib/lib*.a; do \ + $(TOOLCHAIN)/bin/xtensa-lx106-elf-objcopy \ + --rename-section .text=.fast.text \ + --rename-section .irom0.text=.text \ + $$l; \ + done + @touch $@ -libcirom: $(TOOLCHAIN)/xtensa-lx106-elf/sysroot/lib/libcirom.a +.sdk_patch_2.0.0: + echo -e "#undef ESP_SDK_VERSION\n#define ESP_SDK_VERSION 010502" >>$(VENDOR_SDK_DIR)/include/esp_sdk_ver.h + patch -N -d $(VENDOR_SDK_DIR_2.0.0) -p1 < c_types-c99_sdk_2.patch + @touch $@ -sdk_patch: .sdk_patch_$(VENDOR_SDK) +.sdk_patch_1.5.2: + echo -e "#undef ESP_SDK_VERSION\n#define ESP_SDK_VERSION 010502" >>$(VENDOR_SDK_DIR)/include/esp_sdk_ver.h + patch -N -d $(VENDOR_SDK_DIR_1.5.2) -p1 < c_types-c99.patch + @touch $@ + +.sdk_patch_1.5.0: + patch -N -d $(VENDOR_SDK_DIR_1.5.0) -p1 < c_types-c99.patch + @touch $@ + +.sdk_patch_1.4.1: + patch -N -d $(VENDOR_SDK_DIR_1.4.1) -p1 < c_types-c99.patch + @touch $@ .sdk_patch_1.4.0: patch -N -d $(VENDOR_SDK_DIR_1.4.0) -p1 < c_types-c99.patch @@ -160,7 +190,7 @@ empty_user_rf_pre_init.o: empty_user_rf_pre_init.c $(TOOLCHAIN)/bin/xtensa-lx106 cp FRM_ERR_PATCH/*.a $(VENDOR_SDK_DIR)/lib/ @touch $@ -standalone: sdk sdk_patch toolchain +standalone: sdk .sdk_patch toolchain ifeq ($(STANDALONE),y) @echo "Installing vendor SDK headers into toolchain sysroot" @cp -Rf sdk/include/* $(TOOLCHAIN)/xtensa-lx106-elf/sysroot/usr/include/ @@ -204,6 +234,21 @@ $(VENDOR_SDK_DIR)/.dir: $(VENDOR_SDK_ZIP) -mv License $(VENDOR_SDK_DIR) touch $@ +ESP8266_NONOS_SDK_V2.0.0_16_08_10.zip: + wget --content-disposition "http://bbs.espressif.com/download/file.php?id=1690" + +ESP8266_NONOS_SDK_V2.0.0_16_07_19.zip: + wget --content-disposition "http://bbs.espressif.com/download/file.php?id=1613" + +ESP8266_NONOS_SDK_V1.5.2_16_01_29.zip: + wget --content-disposition "http://bbs.espressif.com/download/file.php?id=1079" + +esp_iot_sdk_v1.5.0_15_11_27.zip: + wget --content-disposition "http://bbs.espressif.com/download/file.php?id=989" + +esp_iot_sdk_v1.4.1_pre5_15_10_27.zip: + wget --content-disposition "http://bbs.espressif.com/download/file.php?id=917" + esp_iot_sdk_v1.4.0_15_09_18.zip: wget --content-disposition "http://bbs.espressif.com/download/file.php?id=838" @@ -252,11 +297,17 @@ esp_iot_sdk_v0.9.3_14_11_21.zip: esp_iot_sdk_v0.9.2_14_10_24.zip: wget --content-disposition "http://bbs.espressif.com/download/file.php?id=9" -libhal: $(TOOLCHAIN)/xtensa-lx106-elf/sysroot/usr/lib/libhal.a +libhal: $(LIBHAL) .patch_libhal -$(TOOLCHAIN)/xtensa-lx106-elf/sysroot/usr/lib/libhal.a: $(TOOLCHAIN)/bin/xtensa-lx106-elf-gcc +$(LIBHAL): $(TOOLCHAIN)/bin/xtensa-lx106-elf-gcc make -C lx106-hal -f ../Makefile _libhal +.patch_libhal: $(LIBHAL) + $(TOOLCHAIN)/bin/xtensa-lx106-elf-objcopy \ + --rename-section .text=.fast.text \ + $(LIBHAL) + @touch $@ + _libhal: autoreconf -i PATH=$(TOOLCHAIN)/bin:$(PATH) ./configure --host=xtensa-lx106-elf --prefix=$(TOOLCHAIN)/xtensa-lx106-elf/sysroot/usr @@ -264,22 +315,32 @@ _libhal: PATH=$(TOOLCHAIN)/bin:$(PATH) make install -toolchain: $(TOOLCHAIN)/bin/xtensa-lx106-elf-gcc +toolchain: $(TOOLCHAIN)/bin/xtensa-lx106-elf-gcc .patch_libgcc $(TOOLCHAIN)/bin/xtensa-lx106-elf-gcc: crosstool-NG/ct-ng + cp -f 1000-mforce-l32.patch crosstool-NG/local-patches/gcc/4.8.5/ make -C crosstool-NG -f ../Makefile _toolchain +.patch_libgcc: $(TOOLCHAIN)/bin/xtensa-lx106-elf-gcc + $(TOOLCHAIN)/bin/xtensa-lx106-elf-objcopy \ + --rename-section .text=.fast.text \ + $(LIBGCC) + @touch $@ + _toolchain: ./ct-ng xtensa-lx106-elf sed -r -i.org s%CT_PREFIX_DIR=.*%CT_PREFIX_DIR="$(TOOLCHAIN)"% .config sed -r -i s%CT_INSTALL_DIR_RO=y%"#"CT_INSTALL_DIR_RO=y% .config cat ../crosstool-config-overrides >> .config + rm -f local-patches/gdb/7.5.1/* ./ct-ng build crosstool-NG: crosstool-NG/ct-ng crosstool-NG/ct-ng: crosstool-NG/bootstrap + cp *-newlib-*.patch crosstool-NG/local-patches/newlib/2.0.0 + cp *-libgcc-*.patch crosstool-NG/local-patches/gcc/4.8.5 make -C crosstool-NG -f ../Makefile _ct-ng _ct-ng: diff --git a/c_types-c99_sdk_2.patch b/c_types-c99_sdk_2.patch new file mode 100644 index 000000000..6691130a3 --- /dev/null +++ b/c_types-c99_sdk_2.patch @@ -0,0 +1,34 @@ +--- ESP8266_NONOS_SDK/include/c_types.h.orig 2016-07-18 15:16:07.000000000 +0100 ++++ ESP8266_NONOS_SDK/include/c_types.h 2016-08-10 00:36:51.216294997 +0100 +@@ -6,17 +6,13 @@ + #ifndef _C_TYPES_H_ + #define _C_TYPES_H_ + +-typedef unsigned char uint8_t; ++#include ++#include ++ + typedef signed char sint8_t; +-typedef signed char int8_t; +-typedef unsigned short uint16_t; + typedef signed short sint16_t; +-typedef signed short int16_t; +-typedef unsigned int uint32_t; + typedef signed long sint32_t; +-typedef signed int int32_t; + typedef signed long long sint64_t; +-typedef unsigned long long uint64_t; + typedef unsigned long long u_int64_t; + typedef float real32_t; + typedef double real64_t; +@@ -82,10 +78,7 @@ + #define STORE_ATTR __attribute__((aligned(4))) + + #ifndef __cplusplus +-typedef unsigned char bool; + #define BOOL bool +-#define true (1) +-#define false (0) + #define TRUE true + #define FALSE false + diff --git a/crosstool-NG b/crosstool-NG index feb1fb829..ecfc19a59 160000 --- a/crosstool-NG +++ b/crosstool-NG @@ -1 +1 @@ -Subproject commit feb1fb829d5cb4f8739e488cbd2f0b72304705bb +Subproject commit ecfc19a597d76c0eea65148b08d7ccb505cdcac6 diff --git a/crosstool-config-overrides b/crosstool-config-overrides index a021795d3..f65cdce83 100644 --- a/crosstool-config-overrides +++ b/crosstool-config-overrides @@ -2,4 +2,6 @@ # by default don't install static libs for all required dependencies #CT_STATIC_TOOLCHAIN=y CT_LIBC_NEWLIB_ENABLE_TARGET_OPTSPACE=y - +CT_LIBC_NEWLIB_IO_LL=y +CT_LIBC_NEWLIB_IO_FLOAT=y +CT_LIBC_NEWLIB_IO_C99FMT=y diff --git a/esptool b/esptool index 765cf23f8..4deca7033 160000 --- a/esptool +++ b/esptool @@ -1 +1 @@ -Subproject commit 765cf23f878a522db6bc34854d4a14bbae470ff6 +Subproject commit 4deca7033e17d9b8d3b947a2d8f7ec3700d7d276 diff --git a/lx106-hal b/lx106-hal index ecdc98953..e4bcc63c9 160000 --- a/lx106-hal +++ b/lx106-hal @@ -1 +1 @@ -Subproject commit ecdc98953f2fc5058a79168528387cd14b287636 +Subproject commit e4bcc63c9c016e4f8848e7e8f512438ca857531d