mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
* Upgrade to GCC 9.1 toolchain * Rebuilt using pure GNU binutils and GCC Remove dependencies on earlier forked GNU utilities (gcc-xtensa, binutils-gdb-xtensa) and just use GCC sources, unmodified (except for patches in the esp-quick-toolchain directories). * Rebuild bearssl using new toolchain * Fix GDBstub linkage options GDB works with pure GNU GCC and pure GNU binutils now. Still warnings galore, but tested with the example sketch in the docs. * Fix digitalRead alias warning * Remove gdb stub warnings w/a pragma * Fix deprecated implicit copy ctors in IP code Fix some warnings present in GCC8/9 in the IPAddress code In AddressListIterator there was a copy constructor which simply copied the structure bit-for-bit. That's the default operation, so remove it to avoid the warning there. IPAddress, add a default copy constructor since the other copy constructors are simply parsing from one format into a native ip_addr_t. @d-a-v, can you give these a look over and see if they're good (since IP stuff is really your domain). * Fix AxTLS alias function defs to match real code * Fix WiFiClientSecure implicit default copy ctor These both use shared-ptrs to handle refcnts to allocated data, so using the default copy constructor is fine (and has been in use for a long time). * Dummy size for heap to avoid GCC 8/9 warnings Make GCC think _heap_start is large enough to avoid the basic (and incorrect) bounds-checking warnings it produces. The size chosen is arbitrary and does not affect the actual size of the heap in any way. * Make heap an undefined extend array Instead of a bogus size, use an indefinite size for the heap to avoid GCC warnings * Trivial tab to space fix * Update SDFat to remove FatFile warnings * Fix ticker function cast warnings in GCC 9 The callback function is defined to take a (void*) as parameter, but our templates let users use anything that fits inside sizeof(void*) to be passed in. Add pragmas to stop GCC warnings about this, since we already check the size of the type will fit in the allocated space. * Remove GCC support fcn that's in ROM Manually delete the divdi3.so from the libgcc.a library by running the updated EQT's 9.1-post script. * Make exceptions work again, get std::regex up Exceptions are broken on all builds (GCC4.8-9.1) due to the removal of the PROGMEM non-32b read exception handler (added in the unstable pre3.0.0). Build the exception code with -mforce-l32 and patch accordingly to avoid LoadStore errors. Apply patches to select portions of the regex lib which use _stype_ (which is now in flash). * Rebuild Bearssl using latest GCC push * Automate building of BearSSL and LWIP w/new toolchain * Workaround g++ template section problem for exception strings G++ seems to throw out the section attributes for templates. This means that the __EXCSTR(a synonym for "PSTR()") is ignored and exception.what strings are stored in RODATA, eating up RAM. Workaround by using the linker to place the strings keying off their name ("*__exception_what__*"). * Rebuild moving exception.what to unique names Exception.whats are now all in __exception_what__ and can be moved by the linker to flash. Works aroung G++ issue with segments being lost in templates. * Rebuild with new LWIP locking * Update to latest libs, save iram Move two GCC FP support routines out of iram since they are in ROM already, saving some add'l IRAM. Same list as gcc 4.8. * Update BearSSL to latest release * Fix umm_perf reference to ROM function * Fix "reinterpret_case is not a constexpr" error In GCC 9 (and 8 from what I read on SO), a cast of a const int to a function pointer (via explicit or implicit reinterpret_cast) is not a constexpr. ```` /home/earle/Arduino/hardware/esp8266com/esp8266/cores/esp8266/umm_malloc/umm_performance.cpp:45:36: error: a reinterpret_cast is not a constant expression 45 | int constexpr (*_rom_putc1)(int) = (int (*)(int))(void*)0x40001dcc; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ```` Remove the constexpr, potentially increasing heap usage by 4 bytes in debug mode. * Update libc.a to latest rev * Full rebuild of toolchain and libs * Upgrade to GCC 9.2, released in August 2019 Add builds for all 5 cross-compiles to pass CI * Move to --std=gnu++14 (C++14 + GNU extensions) * Fix Ticker merge conflict * Fix json merge conflict * One more merge diff fix * Reapply Ticker.h casting warning fixes for gcc9 * Update with fixes from Sming repo for PSTR and ASM * Upgrade to -gnu4 toolchain * Move to gnu5 build with add'l softFP from ROM * Move add'l softFP from IRAM to flash Per @mikee47, we miss sone add'l soft-FP routined in the linker which makes them end up in IRAM. Move them explicitly into flash, like a couple others we have already done this for. * Move to std=c++17/c17 in platform, remove abs/round Move to C++17 and C17 standards on the compiler options. Remove "register" from core since it is deprecated. Remove the #define abs() and #define round() which a) overwrote the C stdlib definitions, poorly, and b) broke the GCC core code which used "abs" as an internal function name. Now abs() returns an integer, and not whatever was being absoluted. fabs() etc. can be used if users need fload/double suport. round() returns a double now, which is basically what it was returning in the original case since adding/subtracting by a FP. * Use std::abs/round to replace the macro definitions Per discussion w/@devyte, preserve the abs() and round() functionality via the using statement. * Remove using std::abs which conflicted with C lib headers * Add 2nd arg (exception handler) to ets_isr_t Disassembly of the ROM shows there are 2 params to the ets_isr_t callback. The first is the arg passed in, the second is a pointer to an exception frame where you can get info about when the IRQ happened. * Move the gdbstub example to a subdir The Arduino IDE and the build CI don't build it without a subdir, so make one for gdbstub's example so it's visible and tested. * Fix ets_irq_arratch redefinition and core IRQ handlers Remove a duplicated, different declaration for ets_irq_attach from ets_sys.h. It never really even matched the other declaration in the same header. Update the core to IRQ handlers to fix the prototype and include the 2nd, unused frame parameter. * Actually rebuild the libc.a using GCC 9.2 * Fix SPISlave interrupt attach's 2nd parameter * Rebuild eboot.elf with GCC 9 * Update to latest SoftwareSerial for Delegate fix * Upgrade to GCC 9.3 * Rebuild all arch toolchains * Move to GCC 10.1 * Merge master and fix eboot build GCC10 now uses `-fno-common` so the eboot global variables were being placed in IRAM. Adjust the makefile and rebuild to fix. * Built complete toolchain for all archs * Pull in latest PSTR changes and fix GCC10.1 build Somehow the prior GCC build's -mforce32 patch wasn't applying correctly, but I was still able to get a binary. Fixed. Also pulled in latest PSTR changes in progmem.h * Update platform.io to platform C/C++ standards * Use PR's toolchain in platformio build * Fix several asm warnings in PIO build * Optional stack smash protection -fstack-protector Add a menu to enable GCC's built-in stack smash protection. When a subroutine goes past its end of stack, generate a crashdump on function exit like: ```` GCC detected stack overrun Stack corrupted, stack smash detected. >>>stack>>> ctx: cont sp: 3fffff20 end: 3fffffc0 offset: 0000 3fffff20: 40202955 00000001 0000001c 4020287e 3fffff30: feefeffe 000000fd 00000000 00000000 ... <<<stack<<< ```` Disabled by default because there is a small per-function code overhead (and CPU time if the function is called very frequently and is very small). BearSSL and LWIP are not built using stack smash detection, yet. * Fix duplicated stc=gnu99/c17 in build * Dump faulting function PC in stack overflow Report a fake exception to have the exception decoder print the actual faulting function. This won't tell you where in the function the issue happened, but it will tell you the function name first and foremost. * Rebuild with Platform.io JSON tag in release tgzs
266 lines
8.8 KiB
C
266 lines
8.8 KiB
C
/*
|
|
* ESPRESSIF MIT License
|
|
*
|
|
* Copyright (c) 2016 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
|
|
*
|
|
* Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case,
|
|
* it is free of charge, to any person obtaining a copy of this software and associated
|
|
* documentation files (the "Software"), to deal in the Software without restriction, including
|
|
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
|
|
* to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all copies or
|
|
* substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*
|
|
*/
|
|
|
|
#ifndef _ETS_SYS_H
|
|
#define _ETS_SYS_H
|
|
|
|
#include "c_types.h"
|
|
#include "eagle_soc.h"
|
|
#include <stddef.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*
|
|
* This "print character function" prototype is modeled after the argument for
|
|
* ets_install_putc1() found in "ESP8266_NONOS_SDK/include/osapi.h". This
|
|
* deviates away from the familiar C library definition of putchar; however, it
|
|
* agrees with the code we are working with. Note, in the ROM some "printf
|
|
* character functions" always return 0 (uart_tx_one_char and ets_putc), some
|
|
* return last character printed (buildin _putc1), and some return nothing
|
|
* (ets_write_char). Using a void return type safely represents them all.
|
|
*/
|
|
typedef void (*fp_putc_t)(char);
|
|
|
|
typedef uint32_t ETSSignal;
|
|
typedef uint32_t ETSParam;
|
|
|
|
typedef struct ETSEventTag ETSEvent;
|
|
|
|
struct ETSEventTag {
|
|
ETSSignal sig;
|
|
ETSParam par;
|
|
};
|
|
|
|
typedef void (*ETSTask)(ETSEvent *e);
|
|
|
|
/* timer related */
|
|
typedef uint32_t ETSHandle;
|
|
typedef void ETSTimerFunc(void *timer_arg);
|
|
|
|
typedef struct _ETSTIMER_ {
|
|
struct _ETSTIMER_ *timer_next;
|
|
uint32_t timer_expire;
|
|
uint32_t timer_period;
|
|
ETSTimerFunc *timer_func;
|
|
void *timer_arg;
|
|
} ETSTimer;
|
|
|
|
/* interrupt related */
|
|
|
|
// The xtos_1int handler calls with param1 as the arg, param2 as a pointer
|
|
// to an exception frame in memory.
|
|
typedef void (*int_handler_t)(void*, void*);
|
|
|
|
#define ETS_SLC_INUM 1
|
|
#define ETS_SDIO_INUM 1
|
|
#define ETS_SPI_INUM 2
|
|
#define ETS_GPIO_INUM 4
|
|
#define ETS_UART_INUM 5
|
|
#define ETS_UART1_INUM 5
|
|
#define ETS_CCOMPARE0_INUM 6
|
|
#define ETS_SOFT_INUM 7
|
|
#define ETS_WDT_INUM 8
|
|
#define ETS_FRC_TIMER1_INUM 9 /* use edge*/
|
|
|
|
// The xtos_1int handler calls with param1 as the arg, param2 as a pointer
|
|
// to an exception frame in memory.
|
|
|
|
void ets_intr_lock(void);
|
|
void ets_intr_unlock(void);
|
|
|
|
void NmiTimSetFunc(void (*func)(void));
|
|
|
|
#define ETS_INTR_LOCK() \
|
|
ets_intr_lock()
|
|
|
|
#define ETS_INTR_UNLOCK() \
|
|
ets_intr_unlock()
|
|
|
|
#define ETS_INTR_ENABLE(inum) \
|
|
ets_isr_unmask((1<<inum))
|
|
|
|
#define ETS_INTR_DISABLE(inum) \
|
|
ets_isr_mask((1<<inum))
|
|
|
|
inline bool ETS_INTR_WITHINISR()
|
|
{
|
|
uint32_t ps;
|
|
__asm__ __volatile__("rsr %0,ps":"=a" (ps));
|
|
// PS.INTLEVEL check
|
|
return ((ps & 0x0f) != 0);
|
|
}
|
|
|
|
inline uint32_t ETS_INTR_ENABLED(void)
|
|
{
|
|
uint32_t enabled;
|
|
__asm__ __volatile__("esync; rsr %0,intenable":"=a" (enabled));
|
|
return enabled;
|
|
}
|
|
|
|
inline uint32_t ETS_INTR_PENDING(void)
|
|
{
|
|
uint32_t pending;
|
|
__asm__ __volatile__("esync; rsr %0,interrupt":"=a" (pending));
|
|
return pending;
|
|
}
|
|
|
|
#define ETS_CCOMPARE0_INTR_ATTACH(func, arg) \
|
|
ets_isr_attach(ETS_CCOMPARE0_INUM, (int_handler_t)(func), (void *)(arg))
|
|
|
|
#define ETS_CCOMPARE0_ENABLE() \
|
|
ETS_INTR_ENABLE(ETS_CCOMPARE0_INUM)
|
|
|
|
#define ETS_CCOMPARE0_DISABLE() \
|
|
ETS_INTR_DISABLE(ETS_CCOMPARE0_INUM)
|
|
|
|
|
|
#define ETS_FRC_TIMER1_INTR_ATTACH(func, arg) \
|
|
ets_isr_attach(ETS_FRC_TIMER1_INUM, (int_handler_t)(func), (void *)(arg))
|
|
|
|
#define ETS_FRC_TIMER1_NMI_INTR_ATTACH(func) \
|
|
NmiTimSetFunc(func)
|
|
|
|
#define ETS_GPIO_INTR_ATTACH(func, arg) \
|
|
ets_isr_attach(ETS_GPIO_INUM, (int_handler_t)(func), (void *)(arg))
|
|
|
|
#define ETS_GPIO_INTR_ENABLE() \
|
|
ETS_INTR_ENABLE(ETS_GPIO_INUM)
|
|
|
|
#define ETS_GPIO_INTR_DISABLE() \
|
|
ETS_INTR_DISABLE(ETS_GPIO_INUM)
|
|
|
|
|
|
#define ETS_UART_INTR_ATTACH(func, arg) \
|
|
ets_isr_attach(ETS_UART_INUM, (int_handler_t)(func), (void *)(arg))
|
|
|
|
#define ETS_UART_INTR_ENABLE() \
|
|
ETS_INTR_ENABLE(ETS_UART_INUM)
|
|
|
|
#define ETS_UART_INTR_DISABLE() \
|
|
ETS_INTR_DISABLE(ETS_UART_INUM)
|
|
|
|
#define ETS_FRC1_INTR_ENABLE() \
|
|
ETS_INTR_ENABLE(ETS_FRC_TIMER1_INUM)
|
|
|
|
#define ETS_FRC1_INTR_DISABLE() \
|
|
ETS_INTR_DISABLE(ETS_FRC_TIMER1_INUM)
|
|
|
|
|
|
#define ETS_SPI_INTR_ATTACH(func, arg) \
|
|
ets_isr_attach(ETS_SPI_INUM, (int_handler_t)(func), (void *)(arg))
|
|
|
|
#define ETS_SPI_INTR_ENABLE() \
|
|
ETS_INTR_ENABLE(ETS_SPI_INUM)
|
|
|
|
#define ETS_SPI_INTR_DISABLE() \
|
|
ETS_INTR_DISABLE(ETS_SPI_INUM)
|
|
|
|
|
|
#define ETS_SLC_INTR_ATTACH(func, arg) \
|
|
ets_isr_attach(ETS_SLC_INUM, (int_handler_t)(func), (void *)(arg))
|
|
|
|
#define ETS_SLC_INTR_ENABLE() \
|
|
ETS_INTR_ENABLE(ETS_SLC_INUM)
|
|
|
|
#define ETS_SLC_INTR_DISABLE() \
|
|
ETS_INTR_DISABLE(ETS_SLC_INUM)
|
|
|
|
|
|
#define ETS_SDIO_INTR_ATTACH(func, arg) \
|
|
ets_isr_attach(ETS_SDIO_INUM, (int_handler_t)(func), (void *)(arg))
|
|
|
|
#define ETS_SDIO_INTR_ENABLE() \
|
|
ETS_INTR_ENABLE(ETS_SDIO_INUM)
|
|
|
|
#define ETS_SDIO_INTR_DISABLE() \
|
|
ETS_INTR_DISABLE(ETS_SDIO_INUM)
|
|
|
|
|
|
void *pvPortMalloc(size_t xWantedSize, const char* file, int line) __attribute__((malloc, alloc_size(1)));
|
|
void *pvPortRealloc(void* ptr, size_t xWantedSize, const char* file, int line) __attribute__((alloc_size(2)));
|
|
void vPortFree(void *ptr, const char* file, int line);
|
|
void *ets_memcpy(void *dest, const void *src, size_t n);
|
|
void *ets_memmove(void *dest, const void *src, size_t n);
|
|
void *ets_memset(void *s, int c, size_t n);
|
|
void ets_timer_arm_new(ETSTimer *a, int b, int c, int isMstimer);
|
|
void ets_timer_setfn(ETSTimer *t, ETSTimerFunc *fn, void *parg);
|
|
void ets_timer_disarm(ETSTimer *a);
|
|
int atoi(const char *nptr);
|
|
int ets_strncmp(const char *s1, const char *s2, int len);
|
|
int ets_strcmp(const char *s1, const char *s2);
|
|
int ets_strlen(const char *s);
|
|
char *ets_strcpy(char *dest, const char *src);
|
|
char *ets_strncpy(char *dest, const char *src, size_t n);
|
|
char *ets_strstr(const char *haystack, const char *needle);
|
|
int ets_sprintf(char *str, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
|
|
int os_snprintf(char *str, size_t size, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
|
|
int ets_printf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
|
|
void ets_install_putc1(fp_putc_t routine);
|
|
void ets_isr_mask(int intr);
|
|
void ets_isr_unmask(int intr);
|
|
void ets_isr_attach(int intr, int_handler_t handler, void *arg);
|
|
void ets_intr_lock();
|
|
void ets_intr_unlock();
|
|
int ets_vsnprintf(char * s, size_t n, const char * format, va_list arg) __attribute__ ((format (printf, 3, 0)));
|
|
int ets_vprintf(fp_putc_t print_function, const char * format, va_list arg) __attribute__ ((format (printf, 2, 0)));
|
|
|
|
/*
|
|
* ets_putc(), a "print character function" in ROM, prints a character to a
|
|
* UART. It always returns 0; however, the prototype here is defined with void
|
|
* return to make compatible with other usages of fp_putc_t. ets_putc() provides
|
|
* a "raw", print as is, interface. '\r' and '\n' are each printed exactly as is
|
|
* w/o addition. For a "cooked" interface use ets_uart_putc1().
|
|
* The use of this function requires a prior setup call to uart_buff_switch() to
|
|
* select the UART.
|
|
*/
|
|
void ets_putc(char);
|
|
|
|
/*
|
|
* ets_uart_putc1(), a "print character function" in ROM, prints a character to
|
|
* a UART. It returns the character printed; however, the prototype here is
|
|
* defined with void return to make compatible with other usages of fp_putc_t.
|
|
* This function provides additional processing to characters '\r' and '\n'. It
|
|
* filters out '\r'. When called with '\n', it prints characters '\r' and '\n'.
|
|
* This is sometimes refered to as a "cooked" interface. For a "raw", print as
|
|
* is, interface use ets_putc(). The use of this function requires a prior setup
|
|
* call to uart_buff_switch() to select the UART.
|
|
* ets_uart_putc1() is used internally by ets_uart_printf. It is also the
|
|
* function that gets installed by ets_uart_install_printf through a call to
|
|
* ets_install_putc1.
|
|
*/
|
|
void ets_uart_putc1(char);
|
|
|
|
bool ets_task(ETSTask task, uint8 prio, ETSEvent *queue, uint8 qlen);
|
|
bool ets_post(uint8 prio, ETSSignal sig, ETSParam par);
|
|
void ets_update_cpu_frequency(uint32_t ticks_per_us);
|
|
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* _ETS_SYS_H */
|