From 2d9c5d8297e9065dc982b9f75cf55e84b4afcb15 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 2 Dec 2014 00:46:57 +0300 Subject: [PATCH] Modify the linker script to move some code into flash, enable -mtext-section-literals --- cores/esp8266/abi.cpp | 28 ++++++++++-- .../{main.cpp => core_esp8266_main.cpp} | 0 ...{stdlib_noniso.c => core_esp8266_noniso.c} | 0 .../{wiring.c => core_esp8266_wiring.c} | 0 ..._analog.c => core_esp8266_wiring_analog.c} | 0 ...igital.c => core_esp8266_wiring_digital.c} | 7 +++ ...pts.c => core_esp8266_wiring_interrupts.c} | 0 ...ng_pulse.c => core_esp8266_wiring_pulse.c} | 0 ...ng_shift.c => core_esp8266_wiring_shift.c} | 0 cores/esp8266/new.cpp | 43 ------------------- cores/esp8266/new.h | 30 ------------- platform.txt | 4 +- 12 files changed, 33 insertions(+), 79 deletions(-) rename cores/esp8266/{main.cpp => core_esp8266_main.cpp} (100%) rename cores/esp8266/{stdlib_noniso.c => core_esp8266_noniso.c} (100%) rename cores/esp8266/{wiring.c => core_esp8266_wiring.c} (100%) rename cores/esp8266/{wiring_analog.c => core_esp8266_wiring_analog.c} (100%) rename cores/esp8266/{wiring_digital.c => core_esp8266_wiring_digital.c} (96%) rename cores/esp8266/{WInterrupts.c => core_esp8266_wiring_interrupts.c} (100%) rename cores/esp8266/{wiring_pulse.c => core_esp8266_wiring_pulse.c} (100%) rename cores/esp8266/{wiring_shift.c => core_esp8266_wiring_shift.c} (100%) delete mode 100644 cores/esp8266/new.cpp delete mode 100644 cores/esp8266/new.h diff --git a/cores/esp8266/abi.cpp b/cores/esp8266/abi.cpp index 8d719b8e6..72e0cc76a 100644 --- a/cores/esp8266/abi.cpp +++ b/cores/esp8266/abi.cpp @@ -17,19 +17,39 @@ */ #include +extern "C" { +#include "ets_sys.h" +#include "os_type.h" +#include "osapi.h" +#include "mem.h" +#include "user_interface.h" +} + +void *operator new(size_t size) { + return os_malloc(size); +} + +void *operator new[](size_t size) { + return os_malloc(size); +} + +void operator delete(void * ptr) { + os_free(ptr); +} + +void operator delete[](void * ptr) { + os_free(ptr); +} extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__)); extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__)); void __cxa_pure_virtual(void) { - // We might want to write some diagnostics to uart in this case - //std::terminate(); abort(); } void __cxa_deleted_virtual(void) { - // We might want to write some diagnostics to uart in this case - //std::terminate(); abort(); } + diff --git a/cores/esp8266/main.cpp b/cores/esp8266/core_esp8266_main.cpp similarity index 100% rename from cores/esp8266/main.cpp rename to cores/esp8266/core_esp8266_main.cpp diff --git a/cores/esp8266/stdlib_noniso.c b/cores/esp8266/core_esp8266_noniso.c similarity index 100% rename from cores/esp8266/stdlib_noniso.c rename to cores/esp8266/core_esp8266_noniso.c diff --git a/cores/esp8266/wiring.c b/cores/esp8266/core_esp8266_wiring.c similarity index 100% rename from cores/esp8266/wiring.c rename to cores/esp8266/core_esp8266_wiring.c diff --git a/cores/esp8266/wiring_analog.c b/cores/esp8266/core_esp8266_wiring_analog.c similarity index 100% rename from cores/esp8266/wiring_analog.c rename to cores/esp8266/core_esp8266_wiring_analog.c diff --git a/cores/esp8266/wiring_digital.c b/cores/esp8266/core_esp8266_wiring_digital.c similarity index 96% rename from cores/esp8266/wiring_digital.c rename to cores/esp8266/core_esp8266_wiring_digital.c index 91a84a41f..0e075e56c 100644 --- a/cores/esp8266/wiring_digital.c +++ b/cores/esp8266/core_esp8266_wiring_digital.c @@ -27,6 +27,7 @@ #define ARDUINO_MAIN #include "wiring_private.h" #include "pins_arduino.h" +#include "c_types.h" #include "eagle_soc.h" #include "gpio.h" @@ -68,6 +69,12 @@ static const uint32_t g_pin_funcs[PINCOUNT] = { }; +enum PinFunction { GPIO, PWM }; +static uint32_t g_gpio_function[PINCOUNT] = { + GPIO +}; + + void pinMode(uint8_t pin, uint8_t mode) { uint32_t mux = g_pin_muxes[pin]; diff --git a/cores/esp8266/WInterrupts.c b/cores/esp8266/core_esp8266_wiring_interrupts.c similarity index 100% rename from cores/esp8266/WInterrupts.c rename to cores/esp8266/core_esp8266_wiring_interrupts.c diff --git a/cores/esp8266/wiring_pulse.c b/cores/esp8266/core_esp8266_wiring_pulse.c similarity index 100% rename from cores/esp8266/wiring_pulse.c rename to cores/esp8266/core_esp8266_wiring_pulse.c diff --git a/cores/esp8266/wiring_shift.c b/cores/esp8266/core_esp8266_wiring_shift.c similarity index 100% rename from cores/esp8266/wiring_shift.c rename to cores/esp8266/core_esp8266_wiring_shift.c diff --git a/cores/esp8266/new.cpp b/cores/esp8266/new.cpp deleted file mode 100644 index b7d8f4d84..000000000 --- a/cores/esp8266/new.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright (c) 2014 Arduino. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include -extern "C" { -#include "ets_sys.h" -#include "os_type.h" -#include "osapi.h" -#include "mem.h" -#include "user_interface.h" -} - -void *operator new(size_t size) { - return os_malloc(size); -} - -void *operator new[](size_t size) { - return os_malloc(size); -} - -void operator delete(void * ptr) { - os_free(ptr); -} - -void operator delete[](void * ptr) { - os_free(ptr); -} - diff --git a/cores/esp8266/new.h b/cores/esp8266/new.h deleted file mode 100644 index 6e1b68f0d..000000000 --- a/cores/esp8266/new.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - Copyright (c) 2014 Arduino. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef NEW_H -#define NEW_H - -#include - -void * operator new(size_t size); -void * operator new[](size_t size); -void operator delete(void * ptr); -void operator delete[](void * ptr); - -#endif - diff --git a/platform.txt b/platform.txt index 0349451df..171b2d30c 100644 --- a/platform.txt +++ b/platform.txt @@ -15,7 +15,7 @@ compiler.sdk.path={compiler.tools.path}/sdk/ compiler.cpreprocessor.flags=-D__ets__ -DICACHE_FLASH -I{compiler.sdk.path}/include compiler.c.cmd=xtensa-lx106-elf-gcc -compiler.c.flags=-c -Os -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -MMD -std=c99 +compiler.c.flags=-c -Os -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -MMD -std=c99 compiler.c.elf.ldscript=eagle.app.v6.ld compiler.c.elf.flags=-nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static -L{compiler.sdk.path}/lib -L{compiler.sdk.path}/ld -T{compiler.c.elf.ldscript} @@ -23,7 +23,7 @@ compiler.c.elf.cmd=xtensa-lx106-elf-gcc compiler.c.elf.libs=-lc -lgcc -lhal -lphy -lnet80211 -llwip -lwpa -lmain compiler.cpp.cmd=xtensa-lx106-elf-g++ -compiler.cpp.flags=-c -Os -mlongcalls -fno-exceptions -fno-rtti -std=c++11 -MMD +compiler.cpp.flags=-c -Os -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -std=c++11 -MMD compiler.as.cmd=xtensa-lx106-elf-as