From a9224266f33d879debf207f3de0f81c2fee35cde Mon Sep 17 00:00:00 2001 From: Sergio Tomasello Date: Tue, 11 Apr 2017 17:19:30 +0200 Subject: [PATCH] Arduino boards with ESP8266 (#3121) default crystal freq 26M for all boards, 40M for arduino --- boards.txt | 70 ++++++++++++++++++++++++++++ cores/esp8266/core_esp8266_phy.c | 7 ++- platform.txt | 4 +- variants/arduino_spi/pins_arduino.h | 39 ++++++++++++++++ variants/arduino_uart/pins_arduino.h | 39 ++++++++++++++++ 5 files changed, 155 insertions(+), 4 deletions(-) create mode 100644 variants/arduino_spi/pins_arduino.h create mode 100644 variants/arduino_uart/pins_arduino.h diff --git a/boards.txt b/boards.txt index 818b26ce2..720ec3a6f 100644 --- a/boards.txt +++ b/boards.txt @@ -1,5 +1,7 @@ +menu.BoardModel=Model menu.UploadSpeed=Upload Speed menu.CpuFrequency=CPU Frequency +menu.CrystalFreq=Crystal Frequency menu.FlashSize=Flash Size menu.FlashMode=Flash Mode menu.FlashFreq=Flash Frequency @@ -1892,3 +1894,71 @@ coredev.menu.DebugLevel.OTA2____=OTA + Updater coredev.menu.DebugLevel.OTA2____.build.debug_level=-DDEBUG_ESP_OTA -DDEBUG_ESP_UPDATER coredev.menu.DebugLevel.all_____=All coredev.menu.DebugLevel.all_____.build.debug_level=-DDEBUG_ESP_CORE -DDEBUG_ESP_SSL -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_HTTP_SERVER -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_TLS_MEM + +############ Arduino boards with Esp8266 ############ + +arduino-esp8266.name=Arduino + +arduino-esp8266.upload.tool=esptool +arduino-esp8266.upload.speed=9600 +arduino-esp8266.upload.resetmethod=ck +arduino-esp8266.upload.maximum_size=1044464 +arduino-esp8266.upload.maximum_data_size=81920 +arduino-esp8266.upload.wait_for_upload_port=true +arduino-esp8266.serial.disableDTR=true +arduino-esp8266.serial.disableRTS=true + +arduino-esp8266.build.mcu=esp8266 +arduino-esp8266.build.f_cpu=80000000L +#arduino-esp8266.build.f_crystal=40000000 +arduino-esp8266.build.core=esp8266 +arduino-esp8266.build.flash_mode=qio +arduino-esp8266.build.flash_size=4M +arduino-esp8266.build.flash_freq=40 +arduino-esp8266.build.debug_port= +arduino-esp8266.build.debug_level= +arduino-esp8266.build.board=ESP8266_ARDUINO + +arduino-esp8266.menu.BoardModel.starottodeved=Star OTTO +arduino-esp8266.menu.BoardModel.starottodeved.build.board=ESP8266_ARDUINO_STAR_OTTO +arduino-esp8266.menu.BoardModel.starottodeved.build.variant=arduino_uart +arduino-esp8266.menu.BoardModel.starottodeved.build.extra_flags=-DF_CRYSTAL=40000000 + +arduino-esp8266.menu.BoardModel.primo=Primo +arduino-esp8266.menu.BoardModel.primo.build.board=ESP8266_ARDUINO_PRIMO +arduino-esp8266.menu.BoardModel.primo.build.variant=arduino_spi +arduino-esp8266.menu.BoardModel.primo.build.extra_flags=-DF_CRYSTAL=40000000 + +arduino-esp8266.menu.BoardModel.unowifideved=Uno WiFi +arduino-esp8266.menu.BoardModel.unowifideved.build.board=ESP8266_ARDUINO_UNOWIFI +arduino-esp8266.menu.BoardModel.unowifideved.build.variant=arduino_uart +arduino-esp8266.menu.BoardModel.unowifideved.build.extra_flags=-DF_CRYSTAL=40000000 + +arduino-esp8266.menu.UploadSpeed.9600=9600 +arduino-esp8266.menu.UploadSpeed.9600.upload.speed=9600 +arduino-esp8266.menu.UploadSpeed.19200=19200 +arduino-esp8266.menu.UploadSpeed.19200.upload.speed=19200 +arduino-esp8266.menu.UploadSpeed.57600=57600 +arduino-esp8266.menu.UploadSpeed.57600.upload.speed=57600 +arduino-esp8266.menu.UploadSpeed.115200=115200 +arduino-esp8266.menu.UploadSpeed.115200.upload.speed=115200 +arduino-esp8266.menu.UploadSpeed.230400=230400 +arduino-esp8266.menu.UploadSpeed.230400.upload.speed=230400 +arduino-esp8266.menu.UploadSpeed.460800=460800 +arduino-esp8266.menu.UploadSpeed.460800.upload.speed=460800 + +arduino-esp8266.menu.FlashSize.4M1M=4M (1M SPIFFS) +arduino-esp8266.menu.FlashSize.4M1M.build.flash_size=4M +arduino-esp8266.menu.FlashSize.4M1M.build.flash_ld=eagle.flash.4m1m.ld +arduino-esp8266.menu.FlashSize.4M1M.build.spiffs_start=0x300000 +arduino-esp8266.menu.FlashSize.4M1M.build.spiffs_end=0x3FB000 +arduino-esp8266.menu.FlashSize.4M1M.build.spiffs_blocksize=8192 +arduino-esp8266.menu.FlashSize.4M1M.build.spiffs_pagesize=256 + +arduino-esp8266.menu.FlashSize.4M3M=4M (3M SPIFFS) +arduino-esp8266.menu.FlashSize.4M3M.build.flash_size=4M +arduino-esp8266.menu.FlashSize.4M3M.build.flash_ld=eagle.flash.4m.ld +arduino-esp8266.menu.FlashSize.4M3M.build.spiffs_start=0x100000 +arduino-esp8266.menu.FlashSize.4M3M.build.spiffs_end=0x3FB000 +arduino-esp8266.menu.FlashSize.4M3M.build.spiffs_blocksize=8192 +arduino-esp8266.menu.FlashSize.4M3M.build.spiffs_pagesize=256 diff --git a/cores/esp8266/core_esp8266_phy.c b/cores/esp8266/core_esp8266_phy.c index 67604174e..1b45642f8 100644 --- a/cores/esp8266/core_esp8266_phy.c +++ b/cores/esp8266/core_esp8266_phy.c @@ -88,7 +88,11 @@ static const uint8_t ICACHE_FLASH_ATTR phy_init_data[128] = // 0: 40MHz // 1: 26MHz // 2: 24MHz - [48] = 1, + #if F_CRYSTAL == 40000000 + [48] = 0, + #else + [48] = 1, + #endif @@ -312,4 +316,3 @@ void user_rf_pre_init() void ICACHE_RAM_ATTR user_spi_flash_dio_to_qio_pre_init() {} - diff --git a/platform.txt b/platform.txt index f8f79de6c..e300effc9 100644 --- a/platform.txt +++ b/platform.txt @@ -31,10 +31,10 @@ compiler.c.flags=-c {compiler.warning_flags} -Os -g -Wpointer-arith -Wno-implici compiler.S.cmd=xtensa-lx106-elf-gcc compiler.S.flags=-c -g -x assembler-with-cpp -MMD -mlongcalls -compiler.c.elf.flags=-g {compiler.warning_flags} -Os -nostdlib -Wl,--no-check-sections -u call_user_start -u _printf_float -u _scanf_float -Wl,-static "-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/ld" "-L{compiler.libc.path}/lib" "-T{build.flash_ld}" -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,spi_flash_read +compiler.c.elf.flags=-g {compiler.warning_flags} -Os -nostdlib -Wl,--no-check-sections -u call_user_start -u _printf_float -u _scanf_float -Wl,-static "-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/ld" "-L{compiler.libc.path}/lib" "-T{build.flash_ld}" -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,spi_flash_read compiler.c.elf.cmd=xtensa-lx106-elf-gcc -compiler.c.elf.libs=-lhal -lphy -lpp -lnet80211 {build.lwip_lib} -lwpa -lcrypto -lmain -lwps -laxtls -lespnow -lsmartconfig -lmesh -lwpa2 -lstdc++ -lm -lc -lgcc +compiler.c.elf.libs=-lhal -lphy -lpp -lnet80211 {build.lwip_lib} -lwpa -lcrypto -lmain -lwps -laxtls -lespnow -lsmartconfig -lmesh -lwpa2 -lstdc++ -lm -lc -lgcc compiler.cpp.cmd=xtensa-lx106-elf-g++ compiler.cpp.flags=-c {compiler.warning_flags} -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections diff --git a/variants/arduino_spi/pins_arduino.h b/variants/arduino_spi/pins_arduino.h new file mode 100644 index 000000000..69513edbb --- /dev/null +++ b/variants/arduino_spi/pins_arduino.h @@ -0,0 +1,39 @@ +/* + pins_arduino.h - Pin definition functions for Arduino + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2007 David A. Mellis + Modified for ESP8266 platform by Ivan Grokhotkov, 2014-2015. + + 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., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $ +*/ + +/* + Modified 23 March 2017 + by Sergio Tomasello and Andrea CannistrĂ¡ +*/ + +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include "../generic/common.h" + +static const uint8_t LED_BUILTIN = 2; +static const uint8_t BUILTIN_LED = 2; + +#endif /* Pins_Arduino_h */ diff --git a/variants/arduino_uart/pins_arduino.h b/variants/arduino_uart/pins_arduino.h new file mode 100644 index 000000000..b64249bd3 --- /dev/null +++ b/variants/arduino_uart/pins_arduino.h @@ -0,0 +1,39 @@ +/* + pins_arduino.h - Pin definition functions for Arduino + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2007 David A. Mellis + Modified for ESP8266 platform by Ivan Grokhotkov, 2014-2015. + + 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., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $ +*/ + +/* + Modified 23 March 2017 + by Sergio Tomasello and Andrea CannistrĂ¡ +*/ + +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include "../generic/common.h" + +static const uint8_t LED_BUILTIN = 14; +static const uint8_t BUILTIN_LED = 14; + +#endif /* Pins_Arduino_h */