diff --git a/boards.txt b/boards.txt deleted file mode 100644 index e1ec03dbf..000000000 --- a/boards.txt +++ /dev/null @@ -1,818 +0,0 @@ -menu.UploadSpeed=Upload Speed -menu.CpuFrequency=CPU Frequency -menu.FlashSize=Flash Size -menu.FlashMode=Flash Mode -menu.FlashFreq=Flash Frequency -menu.UploadTool=Upload Using -menu.ResetMethod=Reset Method -menu.ESPModule=Module - -############################################################## -generic.name=Generic ESP8266 Module - -generic.upload.tool=esptool -generic.upload.speed=115200 -generic.upload.resetmethod=ck -generic.upload.maximum_size=434160 -generic.upload.maximum_data_size=81920 -generic.upload.wait_for_upload_port=true -generic.serial.disableDTR=true -generic.serial.disableRTS=true - -generic.build.mcu=esp8266 -generic.build.f_cpu=80000000L -generic.build.board=ESP8266_ESP01 -generic.build.core=esp8266 -generic.build.variant=generic -generic.build.flash_mode=qio -generic.build.spiffs_pagesize=256 - -generic.menu.UploadTool.esptool=Serial -generic.menu.UploadTool.esptool.upload.tool=esptool -generic.menu.UploadTool.esptool.upload.verbose=-vv -generic.menu.UploadTool.espota=OTA -generic.menu.UploadTool.espota.upload.tool=espota - -generic.menu.CpuFrequency.80=80 MHz -generic.menu.CpuFrequency.80.build.f_cpu=80000000L -generic.menu.CpuFrequency.160=160 MHz -generic.menu.CpuFrequency.160.build.f_cpu=160000000L - -generic.menu.FlashFreq.40=40MHz -generic.menu.FlashFreq.40.build.flash_freq=40 -generic.menu.FlashFreq.80=80MHz -generic.menu.FlashFreq.80.build.flash_freq=80 - -generic.menu.FlashMode.dio=DIO -generic.menu.FlashMode.dio.build.flash_mode=dio -generic.menu.FlashMode.qio=QIO -generic.menu.FlashMode.qio.build.flash_mode=qio - -generic.menu.UploadSpeed.115200=115200 -generic.menu.UploadSpeed.115200.upload.speed=115200 -generic.menu.UploadSpeed.9600=9600 -generic.menu.UploadSpeed.9600.upload.speed=9600 -generic.menu.UploadSpeed.57600=57600 -generic.menu.UploadSpeed.57600.upload.speed=57600 -generic.menu.UploadSpeed.256000.windows=256000 -generic.menu.UploadSpeed.256000.upload.speed=256000 -generic.menu.UploadSpeed.230400.linux=230400 -generic.menu.UploadSpeed.230400.macosx=230400 -generic.menu.UploadSpeed.230400.upload.speed=230400 -generic.menu.UploadSpeed.460800.linux=460800 -generic.menu.UploadSpeed.460800.macosx=460800 -generic.menu.UploadSpeed.460800.upload.speed=460800 -generic.menu.UploadSpeed.512000.windows=512000 -generic.menu.UploadSpeed.512000.upload.speed=512000 -generic.menu.UploadSpeed.921600=921600 -generic.menu.UploadSpeed.921600.upload.speed=921600 - -generic.menu.FlashSize.512K64=512K (64K SPIFFS) -generic.menu.FlashSize.512K64.build.flash_size=512K -generic.menu.FlashSize.512K64.build.flash_ld=eagle.flash.512k64.ld -generic.menu.FlashSize.512K64.build.spiffs_start=0x6B000 -generic.menu.FlashSize.512K64.build.spiffs_end=0x7B000 -generic.menu.FlashSize.512K64.build.spiffs_blocksize=4096 -generic.menu.FlashSize.512K64.upload.maximum_size=434160 - -generic.menu.FlashSize.512K0=512K (no SPIFFS) -generic.menu.FlashSize.512K0.build.flash_size=512K -generic.menu.FlashSize.512K0.build.flash_ld=eagle.flash.512k0.ld -generic.menu.FlashSize.512K0.upload.maximum_size=499696 - -generic.menu.FlashSize.1M512=1M (512K SPIFFS) -generic.menu.FlashSize.1M512.build.flash_size=1M -generic.menu.FlashSize.1M512.build.flash_ld=eagle.flash.1m512.ld -generic.menu.FlashSize.1M512.build.spiffs_start=0x7B000 -generic.menu.FlashSize.1M512.build.spiffs_end=0xFB000 -generic.menu.FlashSize.1M512.build.spiffs_blocksize=8192 -generic.menu.FlashSize.1M512.upload.maximum_size=499696 - -generic.menu.FlashSize.1M256=1M (256K SPIFFS) -generic.menu.FlashSize.1M256.build.flash_size=1M -generic.menu.FlashSize.1M256.build.flash_ld=eagle.flash.1m256.ld -generic.menu.FlashSize.1M256.build.spiffs_start=0xBB000 -generic.menu.FlashSize.1M256.build.spiffs_end=0xFB000 -generic.menu.FlashSize.1M256.build.spiffs_blocksize=4096 -generic.menu.FlashSize.1M256.upload.maximum_size=761840 - -generic.menu.FlashSize.1M128=1M (128K SPIFFS) -generic.menu.FlashSize.1M128.build.flash_size=1M -generic.menu.FlashSize.1M128.build.flash_ld=eagle.flash.1m128.ld -generic.menu.FlashSize.1M128.build.spiffs_start=0xDB000 -generic.menu.FlashSize.1M128.build.spiffs_end=0xFB000 -generic.menu.FlashSize.1M128.build.spiffs_blocksize=4096 -generic.menu.FlashSize.1M128.upload.maximum_size=892912 - -generic.menu.FlashSize.1M64=1M (64K SPIFFS) -generic.menu.FlashSize.1M64.build.flash_size=1M -generic.menu.FlashSize.1M64.build.flash_ld=eagle.flash.1m64.ld -generic.menu.FlashSize.1M64.build.spiffs_start=0xEB000 -generic.menu.FlashSize.1M64.build.spiffs_end=0xFB000 -generic.menu.FlashSize.1M64.build.spiffs_blocksize=4096 -generic.menu.FlashSize.1M64.upload.maximum_size=958448 - -generic.menu.FlashSize.2M=2M (1M SPIFFS) -generic.menu.FlashSize.2M.build.flash_size=2M -generic.menu.FlashSize.2M.build.flash_ld=eagle.flash.2m.ld -generic.menu.FlashSize.2M.build.spiffs_start=0x100000 -generic.menu.FlashSize.2M.build.spiffs_end=0x1FB000 -generic.menu.FlashSize.2M.build.spiffs_blocksize=8192 -generic.menu.FlashSize.2M.upload.maximum_size=1044464 - -generic.menu.FlashSize.4M1M=4M (1M SPIFFS) -generic.menu.FlashSize.4M1M.build.flash_size=4M -generic.menu.FlashSize.4M1M.build.flash_ld=eagle.flash.4m1m.ld -generic.menu.FlashSize.4M1M.build.spiffs_start=0x300000 -generic.menu.FlashSize.4M1M.build.spiffs_end=0x3FB000 -generic.menu.FlashSize.4M1M.build.spiffs_blocksize=8192 -generic.menu.FlashSize.4M1M.build.spiffs_pagesize=256 -generic.menu.FlashSize.4M1M.upload.maximum_size=1044464 - -generic.menu.FlashSize.4M3M=4M (3M SPIFFS) -generic.menu.FlashSize.4M3M.build.flash_size=4M -generic.menu.FlashSize.4M3M.build.flash_ld=eagle.flash.4m.ld -generic.menu.FlashSize.4M3M.build.spiffs_start=0x100000 -generic.menu.FlashSize.4M3M.build.spiffs_end=0x3FB000 -generic.menu.FlashSize.4M3M.build.spiffs_blocksize=8192 -generic.menu.FlashSize.4M3M.upload.maximum_size=1044464 - -generic.menu.ResetMethod.ck=ck -generic.menu.ResetMethod.ck.upload.resetmethod=ck -generic.menu.ResetMethod.nodemcu=nodemcu -generic.menu.ResetMethod.nodemcu.upload.resetmethod=nodemcu - -# disabled because espressif's bootloader refuses to write above 4M -# generic.menu.FlashSize.8M=8M (7M SPIFFS) -# generic.menu.FlashSize.8M.build.flash_size=1M -# generic.menu.FlashSize.8M.build.flash_ld=eagle.flash.8m.ld -# generic.menu.FlashSize.8M.build.spiffs_start=0x100000 -# generic.menu.FlashSize.8M.build.spiffs_end=0x800000 -# generic.menu.FlashSize.8M.build.spiffs_blocksize=8192 -# generic.menu.FlashSize.16M=16M (15M SPIFFS) -# generic.menu.FlashSize.16M.build.flash_size=1M -# generic.menu.FlashSize.16M.build.flash_ld=eagle.flash.16m.ld -# generic.menu.FlashSize.16M.build.spiffs_start=0x100000 -# generic.menu.FlashSize.16M.build.spiffs_end=0x1000000 -# generic.menu.FlashSize.16M.build.spiffs_blocksize=8192 - -############################################################## -huzzah.name=Adafruit HUZZAH ESP8266 - -huzzah.upload.tool=esptool -huzzah.upload.speed=115200 -huzzah.upload.resetmethod=ck -huzzah.upload.maximum_size=1044464 -huzzah.upload.maximum_data_size=81920 -huzzah.upload.wait_for_upload_port=true -huzzah.serial.disableDTR=true -huzzah.serial.disableRTS=true - -huzzah.build.mcu=esp8266 -huzzah.build.f_cpu=80000000L -huzzah.build.board=ESP8266_ESP12 -huzzah.build.core=esp8266 -huzzah.build.variant=adafruit -huzzah.build.flash_mode=qio -huzzah.build.flash_size=4M -huzzah.build.flash_freq=40 - -huzzah.menu.CpuFrequency.80=80 MHz -huzzah.menu.CpuFrequency.80.build.f_cpu=80000000L -huzzah.menu.CpuFrequency.160=160 MHz -huzzah.menu.CpuFrequency.160.build.f_cpu=160000000L - -huzzah.menu.UploadTool.esptool=Serial -huzzah.menu.UploadTool.esptool.upload.tool=esptool -huzzah.menu.UploadTool.esptool.upload.verbose=-vv - -huzzah.menu.UploadSpeed.115200=115200 -huzzah.menu.UploadSpeed.115200.upload.speed=115200 -huzzah.menu.UploadSpeed.9600=9600 -huzzah.menu.UploadSpeed.9600.upload.speed=9600 -huzzah.menu.UploadSpeed.57600=57600 -huzzah.menu.UploadSpeed.57600.upload.speed=57600 -huzzah.menu.UploadSpeed.256000=256000 -huzzah.menu.UploadSpeed.256000.upload.speed=256000 -huzzah.menu.UploadSpeed.921600=921600 -huzzah.menu.UploadSpeed.921600.upload.speed=921600 - -huzzah.menu.FlashSize.4M3M=4M (3M SPIFFS) -huzzah.menu.FlashSize.4M3M.build.flash_size=4M -huzzah.menu.FlashSize.4M3M.build.flash_ld=eagle.flash.4m.ld -huzzah.menu.FlashSize.4M3M.build.spiffs_start=0x100000 -huzzah.menu.FlashSize.4M3M.build.spiffs_end=0x3FB000 -huzzah.menu.FlashSize.4M3M.build.spiffs_blocksize=8192 -huzzah.menu.FlashSize.4M3M.build.spiffs_pagesize=256 - -huzzah.menu.FlashSize.4M1M=4M (1M SPIFFS) -huzzah.menu.FlashSize.4M1M.build.flash_size=4M -huzzah.menu.FlashSize.4M1M.build.flash_ld=eagle.flash.4m1m.ld -huzzah.menu.FlashSize.4M1M.build.spiffs_start=0x300000 -huzzah.menu.FlashSize.4M1M.build.spiffs_end=0x3FB000 -huzzah.menu.FlashSize.4M1M.build.spiffs_blocksize=8192 -huzzah.menu.FlashSize.4M1M.build.spiffs_pagesize=256 - -############################################################## -nodemcu.name=NodeMCU 0.9 (ESP-12 Module) - -nodemcu.upload.tool=esptool -nodemcu.upload.speed=115200 -nodemcu.upload.resetmethod=nodemcu -nodemcu.upload.maximum_size=1044464 -nodemcu.upload.maximum_data_size=81920 -nodemcu.upload.wait_for_upload_port=true -nodemcu.serial.disableDTR=true -nodemcu.serial.disableRTS=true - -nodemcu.build.mcu=esp8266 -nodemcu.build.f_cpu=80000000L -nodemcu.build.board=ESP8266_ESP12 -nodemcu.build.core=esp8266 -nodemcu.build.variant=nodemcu -nodemcu.build.flash_mode=qio -nodemcu.build.flash_size=4M -nodemcu.build.flash_freq=40 - -nodemcu.menu.CpuFrequency.80=80 MHz -nodemcu.menu.CpuFrequency.80.build.f_cpu=80000000L -nodemcu.menu.CpuFrequency.160=160 MHz -nodemcu.menu.CpuFrequency.160.build.f_cpu=160000000L - -nodemcu.menu.UploadTool.esptool=Serial -nodemcu.menu.UploadTool.esptool.upload.tool=esptool -nodemcu.menu.UploadTool.esptool.upload.verbose=-vv - -nodemcu.menu.UploadSpeed.115200=115200 -nodemcu.menu.UploadSpeed.115200.upload.speed=115200 -nodemcu.menu.UploadSpeed.9600=9600 -nodemcu.menu.UploadSpeed.9600.upload.speed=9600 -nodemcu.menu.UploadSpeed.57600=57600 -nodemcu.menu.UploadSpeed.57600.upload.speed=57600 -nodemcu.menu.UploadSpeed.256000.windows=256000 -nodemcu.menu.UploadSpeed.256000.upload.speed=256000 -nodemcu.menu.UploadSpeed.230400.linux=230400 -nodemcu.menu.UploadSpeed.230400.macosx=230400 -nodemcu.menu.UploadSpeed.230400.macosx=230400 -nodemcu.menu.UploadSpeed.230400.upload.speed=230400 -nodemcu.menu.UploadSpeed.460800.linux=460800 -nodemcu.menu.UploadSpeed.460800.macosx=460800 -nodemcu.menu.UploadSpeed.460800.upload.speed=460800 -nodemcu.menu.UploadSpeed.512000.windows=512000 -nodemcu.menu.UploadSpeed.512000.upload.speed=512000 -nodemcu.menu.UploadSpeed.921600=921600 -nodemcu.menu.UploadSpeed.921600.upload.speed=921600 - -nodemcu.menu.FlashSize.4M3M=4M (3M SPIFFS) -nodemcu.menu.FlashSize.4M3M.build.flash_size=4M -nodemcu.menu.FlashSize.4M3M.build.flash_ld=eagle.flash.4m.ld -nodemcu.menu.FlashSize.4M3M.build.spiffs_start=0x100000 -nodemcu.menu.FlashSize.4M3M.build.spiffs_end=0x3FB000 -nodemcu.menu.FlashSize.4M3M.build.spiffs_blocksize=8192 -nodemcu.menu.FlashSize.4M3M.build.spiffs_pagesize=256 - -nodemcu.menu.FlashSize.4M1M=4M (1M SPIFFS) -nodemcu.menu.FlashSize.4M1M.build.flash_size=4M -nodemcu.menu.FlashSize.4M1M.build.flash_ld=eagle.flash.4m1m.ld -nodemcu.menu.FlashSize.4M1M.build.spiffs_start=0x300000 -nodemcu.menu.FlashSize.4M1M.build.spiffs_end=0x3FB000 -nodemcu.menu.FlashSize.4M1M.build.spiffs_blocksize=8192 -nodemcu.menu.FlashSize.4M1M.build.spiffs_pagesize=256 - -############################################################## -nodemcuv2.name=NodeMCU 1.0 (ESP-12E Module) - -nodemcuv2.upload.tool=esptool -nodemcuv2.upload.speed=115200 -nodemcuv2.upload.resetmethod=nodemcu -nodemcuv2.upload.maximum_size=1044464 -nodemcuv2.upload.maximum_data_size=81920 -nodemcuv2.upload.wait_for_upload_port=true -nodemcuv2.serial.disableDTR=true -nodemcuv2.serial.disableRTS=true - -nodemcuv2.build.mcu=esp8266 -nodemcuv2.build.f_cpu=80000000L -nodemcuv2.build.board=ESP8266_ESP12 -nodemcuv2.build.core=esp8266 -nodemcuv2.build.variant=nodemcu -nodemcuv2.build.flash_mode=dio -nodemcuv2.build.flash_size=4M -nodemcuv2.build.flash_freq=40 - -nodemcuv2.menu.CpuFrequency.80=80 MHz -nodemcuv2.menu.CpuFrequency.80.build.f_cpu=80000000L -nodemcuv2.menu.CpuFrequency.160=160 MHz -nodemcuv2.menu.CpuFrequency.160.build.f_cpu=160000000L - -nodemcuv2.menu.UploadTool.esptool=Serial -nodemcuv2.menu.UploadTool.esptool.upload.tool=esptool -nodemcuv2.menu.UploadTool.esptool.upload.verbose=-vv -nodemcuv2.menu.UploadTool.espota=OTA -nodemcuv2.menu.UploadTool.espota.upload.tool=espota - -nodemcuv2.menu.UploadSpeed.115200=115200 -nodemcuv2.menu.UploadSpeed.115200.upload.speed=115200 -nodemcuv2.menu.UploadSpeed.9600=9600 -nodemcuv2.menu.UploadSpeed.9600.upload.speed=9600 -nodemcuv2.menu.UploadSpeed.57600=57600 -nodemcuv2.menu.UploadSpeed.57600.upload.speed=57600 -nodemcuv2.menu.UploadSpeed.256000.windows=256000 -nodemcuv2.menu.UploadSpeed.256000.upload.speed=256000 -nodemcuv2.menu.UploadSpeed.230400.linux=230400 -nodemcuv2.menu.UploadSpeed.230400.macosx=230400 -nodemcuv2.menu.UploadSpeed.230400.macosx=230400 -nodemcuv2.menu.UploadSpeed.230400.upload.speed=230400 -nodemcuv2.menu.UploadSpeed.460800.linux=460800 -nodemcuv2.menu.UploadSpeed.460800.macosx=460800 -nodemcuv2.menu.UploadSpeed.460800.upload.speed=460800 -nodemcuv2.menu.UploadSpeed.512000.windows=512000 -nodemcuv2.menu.UploadSpeed.512000.upload.speed=512000 -nodemcuv2.menu.UploadSpeed.921600=921600 -nodemcuv2.menu.UploadSpeed.921600.upload.speed=921600 - -nodemcuv2.menu.FlashSize.4M3M=4M (3M SPIFFS) -nodemcuv2.menu.FlashSize.4M3M.build.flash_size=4M -nodemcuv2.menu.FlashSize.4M3M.build.flash_ld=eagle.flash.4m.ld -nodemcuv2.menu.FlashSize.4M3M.build.spiffs_start=0x100000 -nodemcuv2.menu.FlashSize.4M3M.build.spiffs_end=0x3FB000 -nodemcuv2.menu.FlashSize.4M3M.build.spiffs_blocksize=8192 -nodemcuv2.menu.FlashSize.4M3M.build.spiffs_pagesize=256 - -nodemcuv2.menu.FlashSize.4M1M=4M (1M SPIFFS) -nodemcuv2.menu.FlashSize.4M1M.build.flash_size=4M -nodemcuv2.menu.FlashSize.4M1M.build.flash_ld=eagle.flash.4m1m.ld -nodemcuv2.menu.FlashSize.4M1M.build.spiffs_start=0x300000 -nodemcuv2.menu.FlashSize.4M1M.build.spiffs_end=0x3FB000 -nodemcuv2.menu.FlashSize.4M1M.build.spiffs_blocksize=8192 -nodemcuv2.menu.FlashSize.4M1M.build.spiffs_pagesize=256 - - -############################################################## -modwifi.name=Olimex MOD-WIFI-ESP8266(-DEV) - -modwifi.upload.tool=esptool -modwifi.upload.speed=115200 -modwifi.upload.resetmethod=ck -modwifi.upload.maximum_size=1044464 -modwifi.upload.maximum_data_size=81920 -modwifi.upload.wait_for_upload_port=true -modwifi.serial.disableDTR=true -modwifi.serial.disableRTS=true - -modwifi.build.mcu=esp8266 -modwifi.build.f_cpu=80000000L -modwifi.build.board=MOD_WIFI_ESP8266 -modwifi.build.core=esp8266 -modwifi.build.variant=generic -# Winbond W25Q16 flash -modwifi.build.flash_mode=qio -modwifi.build.flash_size=2M -modwifi.build.flash_freq=40 -modwifi.build.flash_ld=eagle.flash.2m.ld -modwifi.build.spiffs_start=0x100000 -modwifi.build.spiffs_end=0x1FB000 -modwifi.build.spiffs_pagesize=256 -modwifi.build.spiffs_blocksize=8192 - -modwifi.menu.CpuFrequency.80=80 MHz -modwifi.menu.CpuFrequency.80.build.f_cpu=80000000L -modwifi.menu.CpuFrequency.160=160 MHz -modwifi.menu.CpuFrequency.160.build.f_cpu=160000000L - -modwifi.menu.UploadTool.esptool=Serial -modwifi.menu.UploadTool.esptool.upload.tool=esptool -modwifi.menu.UploadTool.esptool.upload.verbose=-vv - -modwifi.menu.UploadSpeed.115200=115200 -modwifi.menu.UploadSpeed.115200.upload.speed=115200 -modwifi.menu.UploadSpeed.9600=9600 -modwifi.menu.UploadSpeed.9600.upload.speed=9600 -modwifi.menu.UploadSpeed.57600=57600 -modwifi.menu.UploadSpeed.57600.upload.speed=57600 -modwifi.menu.UploadSpeed.256000.windows=256000 -modwifi.menu.UploadSpeed.256000.upload.speed=256000 -modwifi.menu.UploadSpeed.230400.linux=230400 -modwifi.menu.UploadSpeed.230400.macosx=230400 -modwifi.menu.UploadSpeed.230400.macosx=230400 -modwifi.menu.UploadSpeed.230400.upload.speed=230400 -modwifi.menu.UploadSpeed.460800.linux=460800 -modwifi.menu.UploadSpeed.460800.macosx=460800 -modwifi.menu.UploadSpeed.460800.upload.speed=460800 -modwifi.menu.UploadSpeed.512000.windows=512000 -modwifi.menu.UploadSpeed.512000.upload.speed=512000 -modwifi.menu.UploadSpeed.921600=921600 -modwifi.menu.UploadSpeed.921600.upload.speed=921600 - -############################################################## -thing.name=SparkFun ESP8266 Thing - -thing.upload.tool=esptool -thing.upload.speed=921600 -thing.upload.resetmethod=ck -thing.upload.maximum_size=434160 -thing.upload.maximum_data_size=81920 -thing.upload.wait_for_upload_port=true -thing.serial.disableDTR=true -thing.serial.disableRTS=true - -thing.build.mcu=esp8266 -thing.build.f_cpu=80000000L -thing.build.board=ESP8266_THING -thing.build.core=esp8266 -thing.build.variant=thing -thing.build.flash_mode=qio -# flash chip: AT25SF041 (512 kbyte, 4Mbit) -thing.build.flash_size=512K -thing.build.flash_ld=eagle.flash.512k64.ld -thing.build.flash_freq=40 -thing.build.spiffs_start=0x6B000 -thing.build.spiffs_end=0x7B000 -thing.build.spiffs_blocksize=4096 -thing.build.spiffs_pagesize=256 - -thing.menu.CpuFrequency.80=80 MHz -thing.menu.CpuFrequency.80.build.f_cpu=80000000L -thing.menu.CpuFrequency.160=160 MHz -thing.menu.CpuFrequency.160.build.f_cpu=160000000L - -thing.menu.UploadTool.esptool=Serial -thing.menu.UploadTool.esptool.upload.tool=esptool -thing.menu.UploadTool.esptool.upload.verbose=-vv - -thing.menu.UploadSpeed.115200=115200 -thing.menu.UploadSpeed.115200.upload.speed=115200 -thing.menu.UploadSpeed.9600=9600 -thing.menu.UploadSpeed.9600.upload.speed=9600 -thing.menu.UploadSpeed.57600=57600 -thing.menu.UploadSpeed.57600.upload.speed=57600 -thing.menu.UploadSpeed.256000.windows=256000 -thing.menu.UploadSpeed.256000.upload.speed=256000 -thing.menu.UploadSpeed.230400.linux=230400 -thing.menu.UploadSpeed.230400.macosx=230400 -thing.menu.UploadSpeed.230400.upload.speed=230400 -thing.menu.UploadSpeed.460800.linux=460800 -thing.menu.UploadSpeed.460800.macosx=460800 -thing.menu.UploadSpeed.460800.upload.speed=460800 -thing.menu.UploadSpeed.512000.windows=512000 -thing.menu.UploadSpeed.512000.upload.speed=512000 -thing.menu.UploadSpeed.921600=921600 -thing.menu.UploadSpeed.921600.upload.speed=921600 - -############################################################## -esp210.name=SweetPea ESP-210 - -esp210.upload.tool=esptool -esp210.upload.speed=115200 -esp210.upload.resetmethod=ck -esp210.upload.maximum_size=1044464 -esp210.upload.maximum_data_size=81920 -esp210.upload.wait_for_upload_port=true -esp210.serial.disableDTR=true -esp210.serial.disableRTS=true - -esp210.build.mcu=esp8266 -esp210.build.f_cpu=80000000L -esp210.build.board=ESP8266_ESP210 -esp210.build.core=esp8266 -esp210.build.variant=generic -esp210.build.flash_mode=qio -esp210.build.flash_size=4M -esp210.build.flash_freq=40 - -esp210.menu.CpuFrequency.80=80 MHz -esp210.menu.CpuFrequency.80.build.f_cpu=80000000L -esp210.menu.CpuFrequency.160=160 MHz -esp210.menu.CpuFrequency.160.build.f_cpu=160000000L - -esp210.menu.UploadTool.esptool=Serial -esp210.menu.UploadTool.esptool.upload.tool=esptool -esp210.menu.UploadTool.esptool.upload.verbose=-vv - -esp210.menu.UploadSpeed.57600=57600 -esp210.menu.UploadSpeed.57600.upload.speed=57600 -esp210.menu.UploadSpeed.115200=115200 -esp210.menu.UploadSpeed.115200.upload.speed=115200 -esp210.menu.UploadSpeed.256000.windows=256000 -esp210.menu.UploadSpeed.256000.upload.speed=256000 -esp210.menu.UploadSpeed.230400.linux=230400 -esp210.menu.UploadSpeed.230400.macosx=230400 -esp210.menu.UploadSpeed.230400.macosx=230400 -esp210.menu.UploadSpeed.230400.upload.speed=230400 -esp210.menu.UploadSpeed.460800.linux=460800 -esp210.menu.UploadSpeed.460800.macosx=460800 -esp210.menu.UploadSpeed.460800.upload.speed=460800 -esp210.menu.UploadSpeed.512000.windows=512000 -esp210.menu.UploadSpeed.512000.upload.speed=512000 -esp210.menu.UploadSpeed.921600=921600 -esp210.menu.UploadSpeed.921600.upload.speed=921600 - -esp210.menu.FlashSize.4M3M=4M (3M SPIFFS) -esp210.menu.FlashSize.4M3M.build.flash_size=4M -esp210.menu.FlashSize.4M3M.build.flash_ld=eagle.flash.4m.ld -esp210.menu.FlashSize.4M3M.build.spiffs_start=0x100000 -esp210.menu.FlashSize.4M3M.build.spiffs_end=0x3FB000 -esp210.menu.FlashSize.4M3M.build.spiffs_blocksize=8192 -esp210.menu.FlashSize.4M3M.build.spiffs_pagesize=256 - -esp210.menu.FlashSize.4M1M=4M (1M SPIFFS) -esp210.menu.FlashSize.4M1M.build.flash_size=4M -esp210.menu.FlashSize.4M1M.build.flash_ld=eagle.flash.4m1m.ld -esp210.menu.FlashSize.4M1M.build.spiffs_start=0x300000 -esp210.menu.FlashSize.4M1M.build.spiffs_end=0x3FB000 -esp210.menu.FlashSize.4M1M.build.spiffs_blocksize=8192 -esp210.menu.FlashSize.4M1M.build.spiffs_pagesize=256 - -############################################################## -# wifio.name=Wifio -# -# wifio.upload.tool=esptool -# wifio.upload.speed=115200 -# wifio.upload.resetmethod=wifio -# wifio.upload.maximum_size=524288 -# wifio.upload.wait_for_upload_port=true -# -# wifio.build.mcu=esp8266 -# wifio.build.f_cpu=80000000L -# wifio.build.board=ESP8266_WIFIO -# wifio.build.core=esp8266 -# wifio.build.variant=wifio -# wifio.build.flash_mode=qio -# wifio.build.flash_size=512K -# wifio.build.flash_freq=40 -# wifio.build.flash_ld=eagle.flash.512k64.ld -# wifio.build.spiffs_start=0x6B000 -# wifio.build.spiffs_end=0x7B000 -# -# wifio.menu.CpuFrequency.80=80MHz -# wifio.menu.CpuFrequency.80.build.f_cpu=80000000L -# wifio.menu.CpuFrequency.160=160MHz -# wifio.menu.CpuFrequency.160.build.f_cpu=160000000L -# -# wifio.upload.tool=esptool -# - -############################################################## -d1.name=WeMos D1 - -d1.upload.tool=esptool -d1.upload.speed=460800 -d1.upload.resetmethod=nodemcu -d1.upload.maximum_size=1044464 -d1.upload.maximum_data_size=81920 -d1.upload.wait_for_upload_port=true -d1.serial.disableDTR=true -d1.serial.disableRTS=true - -d1.build.mcu=esp8266 -d1.build.f_cpu=80000000L -d1.build.board=ESP8266_ESP12 -d1.build.core=esp8266 -d1.build.variant=d1 -d1.build.flash_mode=dio -d1.build.flash_size=4M -d1.build.flash_freq=40 - -d1.menu.CpuFrequency.80=80 MHz -d1.menu.CpuFrequency.80.build.f_cpu=80000000L -d1.menu.CpuFrequency.160=160 MHz -d1.menu.CpuFrequency.160.build.f_cpu=160000000L - -d1.menu.UploadTool.esptool=Serial -d1.menu.UploadTool.esptool.upload.tool=esptool -d1.menu.UploadTool.esptool.upload.verbose=-vv - -d1.menu.UploadTool.espota=OTA -d1.menu.UploadTool.espota.upload.tool=espota - -d1.menu.UploadSpeed.921600=921600 -d1.menu.UploadSpeed.921600.upload.speed=921600 -d1.menu.UploadSpeed.115200=115200 -d1.menu.UploadSpeed.115200.upload.speed=115200 -d1.menu.UploadSpeed.9600=9600 -d1.menu.UploadSpeed.9600.upload.speed=9600 -d1.menu.UploadSpeed.57600=57600 -d1.menu.UploadSpeed.57600.upload.speed=57600 -d1.menu.UploadSpeed.256000.windows=256000 -d1.menu.UploadSpeed.256000.upload.speed=256000 -d1.menu.UploadSpeed.230400.linux=230400 -d1.menu.UploadSpeed.230400.macosx=230400 -d1.menu.UploadSpeed.230400.macosx=230400 -d1.menu.UploadSpeed.230400.upload.speed=230400 -d1.menu.UploadSpeed.460800.linux=460800 -d1.menu.UploadSpeed.460800.macosx=460800 -d1.menu.UploadSpeed.460800.upload.speed=460800 -d1.menu.UploadSpeed.512000.windows=512000 -d1.menu.UploadSpeed.512000.upload.speed=512000 - - -d1.menu.FlashSize.4M3M=4M (3M SPIFFS) -d1.menu.FlashSize.4M3M.build.flash_size=4M -d1.menu.FlashSize.4M3M.build.flash_ld=eagle.flash.4m.ld -d1.menu.FlashSize.4M3M.build.spiffs_start=0x100000 -d1.menu.FlashSize.4M3M.build.spiffs_end=0x3FB000 -d1.menu.FlashSize.4M3M.build.spiffs_blocksize=8192 -d1.menu.FlashSize.4M3M.build.spiffs_pagesize=256 - -d1.menu.FlashSize.4M1M=4M (1M SPIFFS) -d1.menu.FlashSize.4M1M.build.flash_size=4M -d1.menu.FlashSize.4M1M.build.flash_ld=eagle.flash.4m1m.ld -d1.menu.FlashSize.4M1M.build.spiffs_start=0x300000 -d1.menu.FlashSize.4M1M.build.spiffs_end=0x3FB000 -d1.menu.FlashSize.4M1M.build.spiffs_blocksize=8192 -d1.menu.FlashSize.4M1M.build.spiffs_pagesize=256 - - -############################################################## -d1_mini.name=WeMos D1 mini - -d1_mini.upload.tool=esptool -d1_mini.upload.speed=460800 -d1_mini.upload.resetmethod=nodemcu -d1_mini.upload.maximum_size=1044464 -d1_mini.upload.maximum_data_size=81920 -d1_mini.upload.wait_for_upload_port=true -d1_mini.serial.disableDTR=true -d1_mini.serial.disableRTS=true - -d1_mini.build.mcu=esp8266 -d1_mini.build.f_cpu=80000000L -d1_mini.build.board=ESP8266_ESP12 -d1_mini.build.core=esp8266 -d1_mini.build.variant=d1_mini -d1_mini.build.flash_mode=dio -d1_mini.build.flash_size=4M -d1_mini.build.flash_freq=40 - -d1_mini.menu.CpuFrequency.80=80 MHz -d1_mini.menu.CpuFrequency.80.build.f_cpu=80000000L -d1_mini.menu.CpuFrequency.160=160 MHz -d1_mini.menu.CpuFrequency.160.build.f_cpu=160000000L - -d1_mini.menu.UploadTool.esptool=Serial -d1_mini.menu.UploadTool.esptool.upload.tool=esptool -d1_mini.menu.UploadTool.esptool.upload.verbose=-vv - -d1_mini.menu.UploadTool.espota=OTA -d1_mini.menu.UploadTool.espota.upload.tool=espota - -d1_mini.menu.UploadSpeed.921600=921600 -d1_mini.menu.UploadSpeed.921600.upload.speed=921600 -d1_mini.menu.UploadSpeed.115200=115200 -d1_mini.menu.UploadSpeed.115200.upload.speed=115200 -d1_mini.menu.UploadSpeed.9600=9600 -d1_mini.menu.UploadSpeed.9600.upload.speed=9600 -d1_mini.menu.UploadSpeed.57600=57600 -d1_mini.menu.UploadSpeed.57600.upload.speed=57600 -d1_mini.menu.UploadSpeed.256000.windows=256000 -d1_mini.menu.UploadSpeed.256000.upload.speed=256000 -d1_mini.menu.UploadSpeed.230400.linux=230400 -d1_mini.menu.UploadSpeed.230400.macosx=230400 -d1_mini.menu.UploadSpeed.230400.macosx=230400 -d1_mini.menu.UploadSpeed.230400.upload.speed=230400 -d1_mini.menu.UploadSpeed.460800.linux=460800 -d1_mini.menu.UploadSpeed.460800.macosx=460800 -d1_mini.menu.UploadSpeed.460800.upload.speed=460800 -d1_mini.menu.UploadSpeed.512000.windows=512000 -d1_mini.menu.UploadSpeed.512000.upload.speed=512000 - - -d1_mini.menu.FlashSize.4M3M=4M (3M SPIFFS) -d1_mini.menu.FlashSize.4M3M.build.flash_size=4M -d1_mini.menu.FlashSize.4M3M.build.flash_ld=eagle.flash.4m.ld -d1_mini.menu.FlashSize.4M3M.build.spiffs_start=0x100000 -d1_mini.menu.FlashSize.4M3M.build.spiffs_end=0x3FB000 -d1_mini.menu.FlashSize.4M3M.build.spiffs_blocksize=8192 -d1_mini.menu.FlashSize.4M3M.build.spiffs_pagesize=256 - -d1_mini.menu.FlashSize.4M1M=4M (1M SPIFFS) -d1_mini.menu.FlashSize.4M1M.build.flash_size=4M -d1_mini.menu.FlashSize.4M1M.build.flash_ld=eagle.flash.4m1m.ld -d1_mini.menu.FlashSize.4M1M.build.spiffs_start=0x300000 -d1_mini.menu.FlashSize.4M1M.build.spiffs_end=0x3FB000 -d1_mini.menu.FlashSize.4M1M.build.spiffs_blocksize=8192 -d1_mini.menu.FlashSize.4M1M.build.spiffs_pagesize=256 - -############################################################## -wifinfo.name=WifInfo - -wifinfo.upload.tool=esptool -wifinfo.upload.speed=115200 -wifinfo.upload.resetmethod=nodemcu -wifinfo.upload.maximum_size=434160 -wifinfo.upload.maximum_data_size=81920 -wifinfo.upload.wait_for_upload_port=true -wifinfo.serial.disableDTR=true -wifinfo.serial.disableRTS=true - -wifinfo.build.mcu=esp8266 -wifinfo.build.f_cpu=80000000L -wifinfo.build.core=esp8266 -wifinfo.build.variant=wifinfo -wifinfo.build.flash_mode=qio -wifinfo.build.spiffs_pagesize=256 - -#wifinfo.menu.ESPModule.ESP07512=ESP07 (1M/512K SPIFFS) -#wifinfo.menu.ESPModule.ESP07512.build.board=ESP8266_ESP07 -#wifinfo.menu.ESPModule.ESP07512.build.flash_size=1M -#wifinfo.menu.ESPModule.ESP07512.build.flash_ld=eagle.flash.1m512.ld -#wifinfo.menu.ESPModule.ESP07512.build.spiffs_start=0x7B000 -#wifinfo.menu.ESPModule.ESP07512.build.spiffs_end=0xFB000 -#wifinfo.menu.ESPModule.ESP07512.build.spiffs_blocksize=8192 -#wifinfo.menu.ESPModule.ESP07512.upload.maximum_size=499696 - -#wifinfo.menu.ESPModule.ESP07256=ESP07 (1M/256K SPIFFS) -#wifinfo.menu.ESPModule.ESP07256.build.board=ESP8266_ESP07 -#wifinfo.menu.ESPModule.ESP07256.build.flash_size=1M -#wifinfo.menu.ESPModule.ESP07256.build.flash_ld=eagle.flash.1m256.ld -#wifinfo.menu.ESPModule.ESP07256.build.spiffs_start=0xBB000 -#wifinfo.menu.ESPModule.ESP07256.build.spiffs_end=0xFB000 -##wifinfo.menu.ESPModule.ESP07256.build.spiffs_blocksize=4096 -#wifinfo.menu.ESPModule.ESP07256.upload.maximum_size=761840 - -wifinfo.menu.ESPModule.ESP07192=ESP07 (1M/192K SPIFFS) -wifinfo.menu.ESPModule.ESP07192.build.board=ESP8266_ESP07 -wifinfo.menu.ESPModule.ESP07192.build.flash_size=1M -wifinfo.menu.ESPModule.ESP07192.build.flash_ld=eagle.flash.1m192.ld -wifinfo.menu.ESPModule.ESP07192.build.spiffs_start=0xCB000 -wifinfo.menu.ESPModule.ESP07192.build.spiffs_end=0xFB000 -wifinfo.menu.ESPModule.ESP07192.build.spiffs_blocksize=4096 -wifinfo.menu.ESPModule.ESP07192.upload.maximum_size=827376 - -#wifinfo.menu.ESPModule.ESP07160=ESP07 (1M/160K SPIFFS) -#wifinfo.menu.ESPModule.ESP07160.build.board=ESP8266_ESP07 -#wifinfo.menu.ESPModule.ESP07160.build.flash_size=1M -#wifinfo.menu.ESPModule.ESP07160.build.flash_ld=eagle.flash.1m160.ld -#wifinfo.menu.ESPModule.ESP07160.build.spiffs_start=0xD3000 -#wifinfo.menu.ESPModule.ESP07160.build.spiffs_end=0xFB000 -#wifinfo.menu.ESPModule.ESP07160.build.spiffs_blocksize=4096 -#wifinfo.menu.ESPModule.ESP07160.upload.maximum_size=860144 -# -#wifinfo.menu.ESPModule.ESP07144=ESP07 (1M/144K SPIFFS) -#wifinfo.menu.ESPModule.ESP07144.build.board=ESP8266_ESP07 -#wifinfo.menu.ESPModule.ESP07144.build.flash_size=1M -#wifinfo.menu.ESPModule.ESP07144.build.flash_ld=eagle.flash.1m144.ld -#wifinfo.menu.ESPModule.ESP07144.build.spiffs_start=0xD7000 -#wifinfo.menu.ESPModule.ESP07144.build.spiffs_end=0xFB000 -#wifinfo.menu.ESPModule.ESP07144.build.spiffs_blocksize=4096 -#wifinfo.menu.ESPModule.ESP07144.upload.maximum_size=876528 -# -#wifinfo.menu.ESPModule.ESP07=ESP07 (1M/64K SPIFFS) -#wifinfo.menu.ESPModule.ESP07.build.board=ESP8266_ESP07 -#wifinfo.menu.ESPModule.ESP07.build.flash_size=1M -#wifinfo.menu.ESPModule.ESP07.build.flash_ld=eagle.flash.1m64.ld -#wifinfo.menu.ESPModule.ESP07.build.spiffs_start=0xEB000 -#wifinfo.menu.ESPModule.ESP07.build.spiffs_end=0xFB000 -#wifinfo.menu.ESPModule.ESP07.build.spiffs_blocksize=4096 -#wifinfo.menu.ESPModule.ESP07.upload.maximum_size=958448 - -wifinfo.menu.ESPModule.ESP12=ESP12 (4M/1M SPIFFS) -wifinfo.menu.ESPModule.ESP12.build.board=ESP8266_ESP12 -wifinfo.menu.ESPModule.ESP12.build.flash_size=4M -wifinfo.menu.ESPModule.ESP12.build.flash_ld=eagle.flash.4m1m.ld -wifinfo.menu.ESPModule.ESP12.build.spiffs_start=0x300000 -wifinfo.menu.ESPModule.ESP12.build.spiffs_end=0x3FB000 -wifinfo.menu.ESPModule.ESP12.build.spiffs_blocksize=8192 -wifinfo.menu.ESPModule.ESP12.build.spiffs_pagesize=256 -wifinfo.menu.ESPModule.ESP12.upload.maximum_size=1044464 - -wifinfo.menu.UploadTool.esptool=Serial -wifinfo.menu.UploadTool.esptool.upload.tool=esptool -wifinfo.menu.UploadTool.esptool.upload.verbose=-vv -wifinfo.menu.UploadTool.espota=OTA -wifinfo.menu.UploadTool.espota.upload.tool=espota - -wifinfo.menu.CpuFrequency.80=80 MHz -wifinfo.menu.CpuFrequency.80.build.f_cpu=80000000L -wifinfo.menu.CpuFrequency.160=160 MHz -wifinfo.menu.CpuFrequency.160.build.f_cpu=160000000L - -wifinfo.menu.FlashFreq.40=40MHz -wifinfo.menu.FlashFreq.40.build.flash_freq=40 -wifinfo.menu.FlashFreq.80=80MHz -wifinfo.menu.FlashFreq.80.build.flash_freq=80 - -wifinfo.menu.FlashMode.dio=DIO -wifinfo.menu.FlashMode.dio.build.flash_mode=dio -wifinfo.menu.FlashMode.qio=QIO -wifinfo.menu.FlashMode.qio.build.flash_mode=qio - -wifinfo.menu.UploadSpeed.115200=115200 -wifinfo.menu.UploadSpeed.115200.upload.speed=115200 -wifinfo.menu.UploadSpeed.9600=9600 -wifinfo.menu.UploadSpeed.9600.upload.speed=9600 -wifinfo.menu.UploadSpeed.57600=57600 -wifinfo.menu.UploadSpeed.57600.upload.speed=57600 -wifinfo.menu.UploadSpeed.256000.windows=256000 -wifinfo.menu.UploadSpeed.256000.upload.speed=256000 -wifinfo.menu.UploadSpeed.230400.linux=230400 -wifinfo.menu.UploadSpeed.230400.macosx=230400 -wifinfo.menu.UploadSpeed.230400.upload.speed=230400 -wifinfo.menu.UploadSpeed.460800.linux=460800 -wifinfo.menu.UploadSpeed.460800.macosx=460800 -wifinfo.menu.UploadSpeed.460800.upload.speed=460800 -wifinfo.menu.UploadSpeed.512000.windows=512000 -wifinfo.menu.UploadSpeed.512000.upload.speed=512000 -wifinfo.menu.UploadSpeed.921600=921600 -wifinfo.menu.UploadSpeed.921600.upload.speed=921600 - diff --git a/cores/esp8266/Arduino.h b/cores/esp8266/Arduino.h index 7e06e0058..10c6ebd44 100644 --- a/cores/esp8266/Arduino.h +++ b/cores/esp8266/Arduino.h @@ -219,14 +219,12 @@ void loop(void); void yield(void); void optimistic_yield(uint32_t interval_us); -// Get the bit location within the hardware port of the given virtual pin. -// This comes from the pins_*.c file for the active board configuration. #define digitalPinToPort(pin) (0) #define digitalPinToBitMask(pin) (1UL << (pin)) #define digitalPinToTimer(pin) (0) -#define portOutputRegister(port) ((volatile uint32_t*) GPO) -#define portInputRegister(port) ((volatile uint32_t*) GPI) -#define portModeRegister(port) ((volatile uint32_t*) GPE) +#define portOutputRegister(port) ((volatile uint32_t*) &GPO) +#define portInputRegister(port) ((volatile uint32_t*) &GPI) +#define portModeRegister(port) ((volatile uint32_t*) &GPE) #define NOT_A_PIN -1 #define NOT_A_PORT -1 diff --git a/cores/esp8266/HardwareSerial.cpp b/cores/esp8266/HardwareSerial.cpp index 2e93f8aee..78108bee7 100644 --- a/cores/esp8266/HardwareSerial.cpp +++ b/cores/esp8266/HardwareSerial.cpp @@ -617,18 +617,15 @@ size_t HardwareSerial::write(uint8_t c) { size_t room = uart_get_tx_fifo_room(_uart); if(room > 0 && _tx_buffer->empty()) { uart_transmit_char(_uart, c); - if(room < 10) { - uart_arm_tx_interrupt(_uart); - } return 1; } while(_tx_buffer->room() == 0) { yield(); - uart_arm_tx_interrupt(_uart); } _tx_buffer->write(c); + uart_arm_tx_interrupt(_uart); return 1; } diff --git a/cores/esp8266/Updater.cpp b/cores/esp8266/Updater.cpp index 28830fba5..7ad21300a 100644 --- a/cores/esp8266/Updater.cpp +++ b/cores/esp8266/Updater.cpp @@ -38,14 +38,14 @@ void UpdaterClass::_reset() { bool UpdaterClass::begin(size_t size, int command) { if(_size > 0){ #ifdef DEBUG_UPDATER - DEBUG_UPDATER.println("already running"); + DEBUG_UPDATER.println("[begin] already running"); #endif return false; } #ifdef DEBUG_UPDATER if (command == U_SPIFFS) { - DEBUG_UPDATER.println("Update SPIFFS."); + DEBUG_UPDATER.println("[begin] Update SPIFFS."); } #endif @@ -73,6 +73,12 @@ bool UpdaterClass::begin(size_t size, int command) { //address where we will start writing the update updateStartAddress = updateEndAddress - roundedSize; +#ifdef DEBUG_UPDATER + DEBUG_UPDATER.printf("[begin] roundedSize: 0x%08X (%d)\n", roundedSize, roundedSize); + DEBUG_UPDATER.printf("[begin] updateEndAddress: 0x%08X (%d)\n", updateEndAddress, updateEndAddress); + DEBUG_UPDATER.printf("[begin] currentSketchSize: 0x%08X (%d)\n", currentSketchSize, currentSketchSize); +#endif + //make sure that the size of both sketches is less than the total space (updateEndAddress) if(updateStartAddress < currentSketchSize) { _error = UPDATE_ERROR_SPACE; @@ -88,7 +94,7 @@ bool UpdaterClass::begin(size_t size, int command) { else { // unknown command #ifdef DEBUG_UPDATER - DEBUG_UPDATER.println("Unknown update command."); + DEBUG_UPDATER.println("[begin] Unknown update command."); #endif return false; } @@ -100,6 +106,12 @@ bool UpdaterClass::begin(size_t size, int command) { _buffer = new uint8_t[FLASH_SECTOR_SIZE]; _command = command; +#ifdef DEBUG_UPDATER + DEBUG_UPDATER.printf("[begin] _startAddress: 0x%08X (%d)\n", _startAddress, _startAddress); + DEBUG_UPDATER.printf("[begin] _currentAddress: 0x%08X (%d)\n", _currentAddress, _currentAddress); + DEBUG_UPDATER.printf("[begin] _size: 0x%08X (%d)\n", _size, _size); +#endif + _md5.begin(); return true; } @@ -168,9 +180,14 @@ bool UpdaterClass::end(bool evenIfRemaining){ } bool UpdaterClass::_writeBuffer(){ + + yield(); + bool result = ESP.flashEraseSector(_currentAddress/FLASH_SECTOR_SIZE); + yield(); + if (result) { + result = ESP.flashWrite(_currentAddress, (uint32_t*) _buffer, _bufferLen); + } yield(); - bool result = ESP.flashEraseSector(_currentAddress/FLASH_SECTOR_SIZE) && - ESP.flashWrite(_currentAddress, (uint32_t*) _buffer, _bufferLen); if (!result) { _error = UPDATE_ERROR_WRITE; @@ -217,29 +234,32 @@ size_t UpdaterClass::write(uint8_t *data, size_t len) { } size_t UpdaterClass::writeStream(Stream &data) { - size_t written = 0; - size_t toRead = 0; - if(hasError() || !isRunning()) - return 0; + size_t written = 0; + size_t toRead = 0; + if(hasError() || !isRunning()) + return 0; - while(remaining()) { - toRead = FLASH_SECTOR_SIZE - _bufferLen; - toRead = data.readBytes(_buffer + _bufferLen, toRead); - if(toRead == 0){ //Timeout - _error = UPDATE_ERROR_STREAM; - _currentAddress = (_startAddress + _size); + while(remaining()) { + toRead = data.readBytes(_buffer + _bufferLen, (FLASH_SECTOR_SIZE - _bufferLen)); + if(toRead == 0) { //Timeout + delay(100); + toRead = data.readBytes(_buffer + _bufferLen, (FLASH_SECTOR_SIZE - _bufferLen)); + if(toRead == 0) { //Timeout + _error = UPDATE_ERROR_STREAM; + _currentAddress = (_startAddress + _size); #ifdef DEBUG_UPDATER - printError(DEBUG_UPDATER); + printError(DEBUG_UPDATER); #endif - return written; + } + return written; + } + _bufferLen += toRead; + if((_bufferLen == remaining() || _bufferLen == FLASH_SECTOR_SIZE) && !_writeBuffer()) + return written; + written += toRead; + yield(); } - _bufferLen += toRead; - if((_bufferLen == remaining() || _bufferLen == FLASH_SECTOR_SIZE) && !_writeBuffer()) - return written; - written += toRead; - yield(); - } - return written; + return written; } void UpdaterClass::printError(Stream &out){ diff --git a/cores/esp8266/Updater.h b/cores/esp8266/Updater.h index b9f1b3d06..a25cb081b 100644 --- a/cores/esp8266/Updater.h +++ b/cores/esp8266/Updater.h @@ -26,7 +26,7 @@ class UpdaterClass { Call this to check the space needed for the update Will return false if there is not enough space */ - bool begin(size_t size, int = U_FLASH); + bool begin(size_t size, int command = U_FLASH); /* Writes a buffer to the flash and increments the address diff --git a/cores/esp8266/WString.cpp b/cores/esp8266/WString.cpp index f92344b84..4ba4b1f9f 100644 --- a/cores/esp8266/WString.cpp +++ b/cores/esp8266/WString.cpp @@ -121,6 +121,7 @@ ICACHE_FLASH_ATTR String::~String() { if(buffer) { free(buffer); } + init(); } // /*********************************************/ @@ -136,8 +137,7 @@ inline void String::init(void) { void ICACHE_FLASH_ATTR String::invalidate(void) { if(buffer) free(buffer); - buffer = NULL; - capacity = len = 0; + init(); } unsigned char ICACHE_FLASH_ATTR String::reserve(unsigned int size) { diff --git a/cores/esp8266/WString.h b/cores/esp8266/WString.h index 4c502bfe5..3f216cee4 100644 --- a/cores/esp8266/WString.h +++ b/cores/esp8266/WString.h @@ -76,7 +76,11 @@ class String { // invalid string (i.e., "if (s)" will be true afterwards) unsigned char reserve(unsigned int size); inline unsigned int length(void) const { - return len; + if(buffer) { + return len; + } else { + return 0; + } } // creates a copy of the assigned value. if the value is null or diff --git a/cores/esp8266/abi.cpp b/cores/esp8266/abi.cpp index b38f16453..ff865d9ca 100644 --- a/cores/esp8266/abi.cpp +++ b/cores/esp8266/abi.cpp @@ -68,6 +68,10 @@ void __throw_length_error(char const*) { void __throw_bad_alloc() { panic(); } + +void __throw_logic_error(const char* str) { + panic(); +} } // TODO: rebuild windows toolchain to make this unnecessary: diff --git a/cores/esp8266/base64.cpp b/cores/esp8266/base64.cpp new file mode 100644 index 000000000..11deb0af0 --- /dev/null +++ b/cores/esp8266/base64.cpp @@ -0,0 +1,63 @@ +/** + * base64.cpp + * + * Created on: 09.12.2015 + * + * Copyright (c) 2015 Markus Sattler. All rights reserved. + * This file is part of the ESP8266 core for Arduino. + * + * 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 "Arduino.h" +extern "C" { +#include "libb64/cdecode.h" +#include "libb64/cencode.h" +} +#include "base64.h" + +/** + * convert input data to base64 + * @param data uint8_t * + * @param length size_t + * @return String + */ +String base64::encode(uint8_t * data, size_t length) { + // base64 needs more size then the source data + size_t size = ((length * 1.6f) + 1); + char * buffer = (char *) malloc(size); + if(buffer) { + base64_encodestate _state; + base64_init_encodestate(&_state); + int len = base64_encode_block((const char *) &data[0], length, &buffer[0], &_state); + len = base64_encode_blockend((buffer + len), &_state); + + String base64 = String(buffer); + free(buffer); + return base64; + } + return String("-FAIL-"); +} + +/** + * convert input data to base64 + * @param text String + * @return String + */ +String base64::encode(String text) { + return base64::encode((uint8_t *) text.c_str(), text.length()); +} + diff --git a/cores/esp8266/base64.h b/cores/esp8266/base64.h new file mode 100644 index 000000000..39be2d397 --- /dev/null +++ b/cores/esp8266/base64.h @@ -0,0 +1,36 @@ +/** + * base64.h + * + * Created on: 09.12.2015 + * + * Copyright (c) 2015 Markus Sattler. All rights reserved. + * This file is part of the ESP8266 core for Arduino. + * + * 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 CORE_BASE64_H_ +#define CORE_BASE64_H_ + +class base64 { + public: + static String encode(uint8_t * data, size_t length); + static String encode(String text); + private: +}; + + +#endif /* CORE_BASE64_H_ */ diff --git a/cores/esp8266/cbuf.h b/cores/esp8266/cbuf.h index fee98a94b..087e7200b 100644 --- a/cores/esp8266/cbuf.h +++ b/cores/esp8266/cbuf.h @@ -42,9 +42,6 @@ class cbuf { if(_end >= _begin) { return _size - (_end - _begin) - 1; } - if(_begin == _end) { - return _size; - } return _begin - _end - 1; } @@ -62,7 +59,7 @@ class cbuf { if(getSize() == 0) return -1; char result = *_begin; - if(++_begin == _bufend) _begin = _buf; + _begin = wrap_if_bufend(_begin + 1); return static_cast(result); } @@ -78,8 +75,7 @@ class cbuf { dst += top_size; } memcpy(dst, _begin, size_to_read); - _begin += size_to_read; - if(_begin == _bufend) _begin = _buf; + _begin = wrap_if_bufend(_begin + size_to_read); return size_read; } @@ -87,7 +83,7 @@ class cbuf { if(room() == 0) return 0; *_end = c; - if(++_end == _bufend) _end = _buf; + _end = wrap_if_bufend(_end + 1); return 1; } @@ -103,8 +99,7 @@ class cbuf { src += top_size; } memcpy(_end, src, size_to_write); - _end += size_to_write; - if(_end == _bufend) _end = _buf; + _end = wrap_if_bufend(_end + size_to_write); return size_written; } @@ -114,6 +109,10 @@ class cbuf { } private: + inline char* wrap_if_bufend(char* ptr) { + return (ptr == _bufend) ? _buf : ptr; + } + size_t _size; char* _buf; char* _bufend; diff --git a/cores/esp8266/core_esp8266_features.h b/cores/esp8266/core_esp8266_features.h new file mode 100644 index 000000000..ae5d58539 --- /dev/null +++ b/cores/esp8266/core_esp8266_features.h @@ -0,0 +1,33 @@ +/* + core_esp8266_features.h - list of features integrated in to ESP8266 core + + Copyright (c) 2014 Ivan Grokhotkov. All rights reserved. + This file is part of the esp8266 core for Arduino environment. + + 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 CORE_ESP8266_FEATURES_H +#define CORE_ESP8266_FEATURES_H + + +#define CORE_HAS_LIBB64 +#define CORE_HAS_BASE64_CLASS + + +#endif + diff --git a/cores/esp8266/core_esp8266_main.cpp b/cores/esp8266/core_esp8266_main.cpp index 92c48312d..5913fa5c2 100644 --- a/cores/esp8266/core_esp8266_main.cpp +++ b/cores/esp8266/core_esp8266_main.cpp @@ -98,11 +98,11 @@ extern "C" void optimistic_yield(uint32_t interval_us) { static void loop_wrapper() { static bool setup_done = false; + preloop_update_frequency(); if(!setup_done) { setup(); setup_done = true; } - preloop_update_frequency(); loop(); esp_schedule(); } diff --git a/cores/esp8266/esp8266_peri.h b/cores/esp8266/esp8266_peri.h index 64c1f30b5..e7aab1f03 100644 --- a/cores/esp8266/esp8266_peri.h +++ b/cores/esp8266/esp8266_peri.h @@ -494,7 +494,7 @@ extern uint8_t esp8266_gpioToFn[16]; //SPI Phase Length Locations #define SPILCOMMAND 28 //4 bit in SPIxU2 default 7 (8bit) -#define SPILADDR 16 //6 bit in SPIxU1 default:23 (24bit) +#define SPILADDR 26 //6 bit in SPIxU1 default:23 (24bit) #define SPILDUMMY 0 //8 bit in SPIxU1 default:0 (0 cycles) #define SPILMISO 8 //9 bit in SPIxU1 default:0 (1bit) #define SPILMOSI 17 //9 bit in SPIxU1 default:0 (1bit) @@ -834,4 +834,10 @@ extern uint8_t esp8266_gpioToFn[16]; #define I2STXCMM (0x7) //I2S_TX_CHAN_MOD #define I2STXCM (0) //I2S_TX_CHAN_MOD_S +/** + Random Number Generator 32bit + http://esp8266-re.foogod.com/wiki/Random_Number_Generator +**/ +#define RANDOM_REG32 ESP8266_DREG(0x20E44) + #endif diff --git a/cores/esp8266/pgmspace.h b/cores/esp8266/pgmspace.h index 4ee599557..c9e83fa05 100644 --- a/cores/esp8266/pgmspace.h +++ b/cores/esp8266/pgmspace.h @@ -78,7 +78,7 @@ int vsnprintf_P(char *str, size_t strSize, PGM_P formatP, va_list ap) __attribut (__extension__({ \ PGM_P __local = (PGM_P)(addr); /* isolate varible for macro expansion */ \ ptrdiff_t __offset = ((uint32_t)__local & 0x00000003); /* byte aligned mask */ \ - const uint32_t* __addr32 = reinterpret_cast(reinterpret_cast(__local)-__offset); \ + const uint32_t* __addr32 = (const uint32_t*)((const uint8_t*)(__local)-__offset); \ uint8_t __result = ((*__addr32) >> (__offset * 8)); \ __result; \ })) @@ -87,7 +87,7 @@ int vsnprintf_P(char *str, size_t strSize, PGM_P formatP, va_list ap) __attribut (__extension__({ \ PGM_P __local = (PGM_P)(addr); /* isolate varible for macro expansion */ \ ptrdiff_t __offset = ((uint32_t)__local & 0x00000002); /* word aligned mask */ \ - const uint32_t* __addr32 = reinterpret_cast(reinterpret_cast(__local) - __offset); \ + const uint32_t* __addr32 = (const uint32_t*)((const uint8_t*)(__local) - __offset); \ uint16_t __result = ((*__addr32) >> (__offset * 8)); \ __result; \ })) diff --git a/cores/esp8266/spiffs_api.cpp b/cores/esp8266/spiffs_api.cpp index 978e2ea0d..f189b4d4e 100644 --- a/cores/esp8266/spiffs_api.cpp +++ b/cores/esp8266/spiffs_api.cpp @@ -41,11 +41,13 @@ extern int32_t spiffs_hal_write(uint32_t addr, uint32_t size, uint8_t *src); extern int32_t spiffs_hal_erase(uint32_t addr, uint32_t size); extern int32_t spiffs_hal_read(uint32_t addr, uint32_t size, uint8_t *dst); -int getSpiffsMode(OpenMode openMode, AccessMode accessMode); +static int getSpiffsMode(OpenMode openMode, AccessMode accessMode); +static bool isSpiffsFilenameValid(const char* name); class SPIFFSFileImpl; class SPIFFSDirImpl; + class SPIFFSImpl : public FSImpl { public: SPIFFSImpl(uint32_t start, uint32_t size, uint32_t pageSize, uint32_t blockSize, uint32_t maxOpenFds) @@ -63,6 +65,14 @@ public: DirImplPtr openDir(const char* path) override; bool rename(const char* pathFrom, const char* pathTo) override { + if (!isSpiffsFilenameValid(pathFrom)) { + DEBUGV("SPIFFSImpl::rename: invalid pathFrom=`%s`\r\n", path); + return false; + } + if (!isSpiffsFilenameValid(pathTo)) { + DEBUGV("SPIFFSImpl::rename: invalid pathTo=`%s` \r\n", path); + return false; + } auto rc = SPIFFS_rename(&_fs, pathFrom, pathTo); if (rc != SPIFFS_OK) { DEBUGV("SPIFFS_rename: rc=%d, from=`%s`, to=`%s`\r\n", rc, @@ -86,6 +96,10 @@ public: } bool remove(const char* path) override { + if (!isSpiffsFilenameValid(path)) { + DEBUGV("SPIFFSImpl::remove: invalid path=`%s`\r\n", path); + return false; + } auto rc = SPIFFS_remove(&_fs, path); if (rc != SPIFFS_OK) { DEBUGV("SPIFFS_remove: rc=%d path=`%s`\r\n", rc, path); @@ -229,7 +243,7 @@ protected: std::unique_ptr _cacheBuf; }; -#define CHECKFD() while (_fd == 0) { DEBUGV("SPIFFSFileImpl(%d) _fd == 0\r\n", __LINE__); abort(); } +#define CHECKFD() while (_fd == 0) { panic(); } class SPIFFSFileImpl : public FileImpl { public: @@ -408,8 +422,23 @@ protected: FileImplPtr SPIFFSImpl::open(const char* path, OpenMode openMode, AccessMode accessMode) { + if (!isSpiffsFilenameValid(path)) { + DEBUGV("SPIFFSImpl::open: invalid path=`%s` \r\n", path); + return FileImplPtr(); + } int mode = getSpiffsMode(openMode, accessMode); int fd = SPIFFS_open(&_fs, path, mode, 0); + if (fd < 0 && _fs.err_code == SPIFFS_ERR_DELETED && (openMode & OM_CREATE)) { + DEBUGV("SPIFFSImpl::open: fd=%d path=`%s` openMode=%d accessMode=%d err=%d, trying to remove\r\n", + fd, path, openMode, accessMode, _fs.err_code); + auto rc = SPIFFS_remove(&_fs, path); + if (rc != SPIFFS_OK) { + DEBUGV("SPIFFSImpl::open: SPIFFS_ERR_DELETED, but failed to remove path=`%s` openMode=%d accessMode=%d err=%d\r\n", + path, openMode, accessMode, _fs.err_code); + return FileImplPtr(); + } + fd = SPIFFS_open(&_fs, path, mode, 0); + } if (fd < 0) { DEBUGV("SPIFFSImpl::open: fd=%d path=`%s` openMode=%d accessMode=%d err=%d\r\n", fd, path, openMode, accessMode, _fs.err_code); @@ -419,12 +448,20 @@ FileImplPtr SPIFFSImpl::open(const char* path, OpenMode openMode, AccessMode acc } bool SPIFFSImpl::exists(const char* path) { + if (!isSpiffsFilenameValid(path)) { + DEBUGV("SPIFFSImpl::exists: invalid path=`%s` \r\n", path); + return false; + } spiffs_stat stat; int rc = SPIFFS_stat(&_fs, path, &stat); return rc == SPIFFS_OK; } DirImplPtr SPIFFSImpl::openDir(const char* path) { + if (!isSpiffsFilenameValid(path)) { + DEBUGV("SPIFFSImpl::openDir: invalid path=`%s` \r\n", path); + return DirImplPtr(); + } spiffs_DIR dir; spiffs_DIR* result = SPIFFS_opendir(&_fs, path, &dir); if (!result) { @@ -434,7 +471,7 @@ DirImplPtr SPIFFSImpl::openDir(const char* path) { return std::make_shared(path, this, dir); } -int getSpiffsMode(OpenMode openMode, AccessMode accessMode) { +static int getSpiffsMode(OpenMode openMode, AccessMode accessMode) { int mode = 0; if (openMode & OM_CREATE) { mode |= SPIFFS_CREAT; @@ -454,6 +491,13 @@ int getSpiffsMode(OpenMode openMode, AccessMode accessMode) { return mode; } +static bool isSpiffsFilenameValid(const char* name) { + if (name == nullptr) + return false; + auto len = strlen(name); + return len > 0 && len <= SPIFFS_OBJ_NAME_LEN; +} + // these symbols should be defined in the linker script for each flash layout extern "C" uint32_t _SPIFFS_start; extern "C" uint32_t _SPIFFS_end; diff --git a/doc/boards.md b/doc/boards.md index e92c4c591..578ea319d 100644 --- a/doc/boards.md +++ b/doc/boards.md @@ -11,6 +11,7 @@ title: Supported Hardware * [Olimex MOD\-WIFI\-ESP8266](#olimex-mod-wifi-esp8266) * [SparkFun ESP8266 Thing](#sparkfun-esp8266-thing) * [SweetPea ESP\-210](#sweetpea-esp-210) + * [ESPino](#espino) * [Generic ESP8266 modules](#generic-esp8266-modules) * [Serial Adapter](#serial-adapter) * [Minimal Hardware Setup for Bootloading and Usage](#minimal-hardware-setup-for-bootloading-and-usage) @@ -91,6 +92,14 @@ Product page: https://www.sparkfun.com/products/13231 *TODO: add notes* +## ESPino + +ESPino integrates the ESP-12 module with a 3.3v regulator, CP2104 USB-Serial bridge and a micro USB connector for easy programming. It is designed for fitting in a breadboard and has an RGB Led and two buttons for easy prototyping. + +For more information about the hardware, pinout diagram and programming procedures, please see the [datasheet](https://github.com/makerlabmx/ESPino-tools/raw/master/Docs/ESPino-Datasheet-EN.pdf). + +Product page: http://www.espino.io/en + ## Generic ESP8266 modules These modules come in different form factors and pinouts. See the page at ESP8266 community wiki for more info: diff --git a/doc/eclipse/makefile.init b/doc/eclipse/makefile.init new file mode 100644 index 000000000..76438d62c --- /dev/null +++ b/doc/eclipse/makefile.init @@ -0,0 +1,39 @@ +vecho := @echo +Q := @ + +PROJECT_NAME=project_name + +OTA_IP=192.168.254.100 +OTA_PORT=8266 + +SERIAL_PORT=COM3 +SERIAL_BAUD=230400 + +ARDUINO_BASE = D:/Coding/avr/Programme/arduino-nightly +ESP8266_BASE = $(ARDUINO_BASE)/hardware/esp8266com/esp8266 +ESP8266_TOOLS = $(ESP8266_BASE)/tools +XTENSA_TOOLS_ROOT = $(ESP8266_TOOLS)/xtensa-lx106-elf/bin + +PYTHON_BIN = python +ESPTOOL_PY_BIN = $(ESP8266_TOOLS)/esptool.py +ESPOTA_PY_BIN = $(ESP8266_TOOLS)/espota.py +ESPTOOL_BIN = $(ESP8266_TOOLS)/esptool/esptool.exe + +ota: + $(vecho) ota... + $(PYTHON_BIN) $(ESPOTA_PY_BIN) -i $(OTA_IP) -p $(OTA_PORT) --auth= -f ./$(PROJECT_NAME).bin + +ota_spiffs: + $(vecho) ota spiffs... + $(PYTHON_BIN) $(ESPOTA_PY_BIN) -i $(OTA_IP) -p $(OTA_PORT) --auth= -s -f ./$(PROJECT_NAME)_spiffs.bin + +erase_flash: + $(vecho) "Erase Flash" + $(PYTHON_BIN) $(ESPTOOL_PY_BIN) -p $(SERIAL_PORT) -b $(SERIAL_BAUD) erase_flash + +dumpmem: + $(vecho) "Read Flash need some time..." + $(PYTHON_BIN) $(ESPTOOL_PY_BIN) -p $(SERIAL_PORT) -b $(SERIAL_BAUD) read_flash 0 4194304 dump.bin + +objdump: + "$(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objdump" -S $(PROJECT_NAME).elf > $(PROJECT_NAME).dobj diff --git a/doc/libraries.md b/doc/libraries.md index cb6ad3272..c9c714e2f 100644 --- a/doc/libraries.md +++ b/doc/libraries.md @@ -140,14 +140,17 @@ While many RC servo motors will accept the 3.3V IO data pin from a ESP8266, most Libraries that don't rely on low-level access to AVR registers should work well. Here are a few libraries that were verified to work: +- [Adafruit_ILI9341](https://github.com/Links2004/Adafruit_ILI9341) - Port of the Adafruit ILI9341 for the ESP8266 - [arduinoWebSockets](https://github.com/Links2004/arduinoWebSockets) - WebSocket Server and Client compatible with ESP8266 (RFC6455) -- [aREST](https://github.com/marcoschwartz/aREST) REST API handler library. +- [aREST](https://github.com/marcoschwartz/aREST) - REST API handler library. - [Blynk](https://github.com/blynkkk/blynk-library) - easy IoT framework for Makers (check out the [Kickstarter page](http://tiny.cc/blynk-kick)). - [DallasTemperature](https://github.com/milesburton/Arduino-Temperature-Control-Library.git) - [DHT-sensor-library](https://github.com/adafruit/DHT-sensor-library) - Arduino library for the DHT11/DHT22 temperature and humidity sensors. Download latest v1.1.1 library and no changes are necessary. Older versions should initialize DHT as follows: `DHT dht(DHTPIN, DHTTYPE, 15)` - [NeoPixel](https://github.com/adafruit/Adafruit_NeoPixel) - Adafruit's NeoPixel library, now with support for the ESP8266 (use version 1.0.2 or higher from Arduino's library manager). - [NeoPixelBus](https://github.com/Makuna/NeoPixelBus) - Arduino NeoPixel library compatible with ESP8266. Use the "NeoPixelAnimator" branch for ESP8266 to get HSL color support and more. -- [PubSubClient](https://github.com/Imroy/pubsubclient) MQTT library by @Imroy. +- [PubSubClient](https://github.com/Imroy/pubsubclient) - MQTT library by @Imroy. - [RTC](https://github.com/Makuna/Rtc) - Arduino Library for Ds1307 & Ds3231 compatible with ESP8266. - [Souliss, Smart Home](https://github.com/souliss/souliss) - Framework for Smart Home based on Arduino, Android and openHAB. - [ST7735](https://github.com/nzmichaelh/Adafruit-ST7735-Library) - Adafruit's ST7735 library modified to be compatible with ESP8266. Just make sure to modify the pins in the examples as they are still AVR specific. +- [UTFT-ESP8266](https://github.com/gnulabis/UTFT-ESP8266) - UTFT display library with support for ESP8266. Only serial interface (SPI) displays are supported for now (no 8-bit parallel mode, etc). Also includes support for the hardware SPI controller of the ESP8266. +- [WiFiManager](https://github.com/tzapu/WiFiManager) - WiFi Connection manager with web captive portal. If it can't connect, it starts AP mode and a configuration portal so you can choose and enter WiFi credentials. diff --git a/doc/ota_updates/ota_updates.md b/doc/ota_updates/ota_updates.md index 8071a2303..28aed2c9f 100644 --- a/doc/ota_updates/ota_updates.md +++ b/doc/ota_updates/ota_updates.md @@ -79,7 +79,13 @@ void onError(OTA_CALLBACK_ERROR (fn)); ### Basic Requirements -- Flash chip size is 2x the size of the sketch. +Flash chip size needs a size thats is able to hold the old sketch (currently running) and the new sketch (OTA) at the same time. +keep in mind that the File system and EEPROM for example needs space too (one time) see [flash layout](../filesystem.md#flash-layout). +```cpp +ESP.getFreeSketchSpace(); +``` +can be used for checking the free space for the new sketch. + The following chapters provide more details and specific methods of doing OTA. @@ -318,7 +324,7 @@ Example header data: [HTTP_X_ESP8266_AP_MAC] => 1A:FE:AA:AA:AA:AA [HTTP_X_ESP8266_FREE_SPACE] => 671744 [HTTP_X_ESP8266_SKETCH_SIZE] => 373940 - [HTTP_X_ESP8266_CHIP_SIZE] => 524288 + [HTTP_X_ESP8266_CHIP_SIZE] => 4194304 [HTTP_X_ESP8266_SDK_VERSION] => 1.3.0 [HTTP_X_ESP8266_VERSION] => DOOR-7-g14f53a19 ``` @@ -399,6 +405,15 @@ The Stream Interface is the base for all other update modes like OTA, http Serve ## Updater class -TODO describe Updater class +Updater is in the Core and deals with writing the firmware to the flash, +checking its integrity and telling the bootloader to load the new firmware on the next boot. + +### Update process - memory view + + - The new sketch will be stored in the space between the old sketch and the spiff. + - on the next reboot the "eboot" bootloader check for commands. + - the new sketch is now copied "over" the old one. + - the new sketch is started. + +![Memory Copy](update_memory_copy.png) -Updater is in the Core and deals with writing the firmware to the flash, checking its integrity and telling the bootloader to load the new firmware on the next boot. diff --git a/doc/ota_updates/update_memory_copy.png b/doc/ota_updates/update_memory_copy.png new file mode 100644 index 000000000..c708f5f4c Binary files /dev/null and b/doc/ota_updates/update_memory_copy.png differ diff --git a/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino b/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino index ec621bb79..50e926efe 100644 --- a/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino +++ b/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino @@ -30,10 +30,10 @@ void setup() { Serial.println("Start"); }); ArduinoOTA.onEnd([]() { - Serial.println("End"); + Serial.println("\nEnd"); }); ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { - Serial.printf("Progress: %u%%\n", (progress / (total / 100))); + Serial.printf("Progress: %u%%\r", (progress / (total / 100))); }); ArduinoOTA.onError([](ota_error_t error) { Serial.printf("Error[%u]: ", error); diff --git a/libraries/ESP8266HTTPClient/examples/Authorization/Authorization.ino b/libraries/ESP8266HTTPClient/examples/Authorization/Authorization.ino new file mode 100644 index 000000000..79a4c3fdf --- /dev/null +++ b/libraries/ESP8266HTTPClient/examples/Authorization/Authorization.ino @@ -0,0 +1,84 @@ +/** + * Authorization.ino + * + * Created on: 09.12.2015 + * + */ + +#include + +#include +#include + +#include + +#define USE_SERIAL Serial + +ESP8266WiFiMulti WiFiMulti; + +void setup() { + + USE_SERIAL.begin(115200); + // USE_SERIAL.setDebugOutput(true); + + USE_SERIAL.println(); + USE_SERIAL.println(); + USE_SERIAL.println(); + + for(uint8_t t = 4; t > 0; t--) { + USE_SERIAL.printf("[SETUP] WAIT %d...\n", t); + USE_SERIAL.flush(); + delay(1000); + } + + WiFiMulti.addAP("SSID", "PASSWORD"); + +} + +void loop() { + // wait for WiFi connection + if((WiFiMulti.run() == WL_CONNECTED)) { + + HTTPClient http; + + USE_SERIAL.print("[HTTP] begin...\n"); + // configure traged server and url + + + http.begin("http://user:password@192.168.1.12/test.html"); + + /* + // or + http.begin("http://192.168.1.12/test.html"); + http.setAuthorization("user", "password"); + + // or + http.begin("http://192.168.1.12/test.html"); + http.setAuthorization("dXNlcjpwYXN3b3Jk"); + */ + + + USE_SERIAL.print("[HTTP] GET...\n"); + // start connection and send HTTP header + int httpCode = http.GET(); + + // httpCode will be negative on error + if(httpCode) { + // HTTP header has been send and Server response header has been handled + USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode); + + // file found at server + if(httpCode == HTTP_CODE_OK) { + String payload = http.getString(); + USE_SERIAL.println(payload); + } + } else { + USE_SERIAL.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str()); + } + + http.end(); + } + + delay(10000); +} + diff --git a/libraries/ESP8266HTTPClient/examples/BasicHttpClient/BasicHttpClient.ino b/libraries/ESP8266HTTPClient/examples/BasicHttpClient/BasicHttpClient.ino index 3c722556b..d3a5fbc7d 100644 --- a/libraries/ESP8266HTTPClient/examples/BasicHttpClient/BasicHttpClient.ino +++ b/libraries/ESP8266HTTPClient/examples/BasicHttpClient/BasicHttpClient.ino @@ -43,24 +43,28 @@ void loop() { USE_SERIAL.print("[HTTP] begin...\n"); // configure traged server and url - //http.begin("192.168.1.12", 443, "/test.html", true, "7a 9c f4 db 40 d3 62 5a 6e 21 bc 5c cc 66 c8 3e a1 45 59 38"); //HTTPS - http.begin("192.168.1.12", 80, "/test.html"); //HTTP + //http.begin("https://192.168.1.12/test.html", "7a 9c f4 db 40 d3 62 5a 6e 21 bc 5c cc 66 c8 3e a1 45 59 38"); //HTTPS + http.begin("http://192.168.1.12/test.html"); //HTTP USE_SERIAL.print("[HTTP] GET...\n"); // start connection and send HTTP header int httpCode = http.GET(); + + // httpCode will be negative on error if(httpCode) { // HTTP header has been send and Server response header has been handled USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode); // file found at server - if(httpCode == 200) { + if(httpCode == HTTP_CODE_OK) { String payload = http.getString(); USE_SERIAL.println(payload); } } else { - USE_SERIAL.print("[HTTP] GET... failed, no connection or no HTTP server\n"); + USE_SERIAL.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str()); } + + http.end(); } delay(10000); diff --git a/libraries/ESP8266HTTPClient/examples/ReuseConnection/ReuseConnection.ino b/libraries/ESP8266HTTPClient/examples/ReuseConnection/ReuseConnection.ino index e725a1f76..35babdc33 100644 --- a/libraries/ESP8266HTTPClient/examples/ReuseConnection/ReuseConnection.ino +++ b/libraries/ESP8266HTTPClient/examples/ReuseConnection/ReuseConnection.ino @@ -36,26 +36,31 @@ void setup() { WiFiMulti.addAP("SSID", "PASSWORD"); - + // allow reuse (if server supports it) + http.setReuse(true); } void loop() { // wait for WiFi connection if((WiFiMulti.run() == WL_CONNECTED)) { - http.begin("192.168.1.12", 80, "/test.html"); + http.begin("http://192.168.1.12/test.html"); + //http.begin("192.168.1.12", 80, "/test.html"); int httpCode = http.GET(); if(httpCode) { USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode); // file found at server - if(httpCode == 200) { + if(httpCode == HTTP_CODE_OK) { http.writeToStream(&USE_SERIAL); } } else { - USE_SERIAL.print("[HTTP] GET... failed, no connection or no HTTP server\n"); + USE_SERIAL.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str()); } + + http.end(); + } delay(1000); diff --git a/libraries/ESP8266HTTPClient/examples/StreamHttpClient/StreamHttpClient.ino b/libraries/ESP8266HTTPClient/examples/StreamHttpClient/StreamHttpClient.ino index 442fa6547..2e7f4487d 100644 --- a/libraries/ESP8266HTTPClient/examples/StreamHttpClient/StreamHttpClient.ino +++ b/libraries/ESP8266HTTPClient/examples/StreamHttpClient/StreamHttpClient.ino @@ -42,19 +42,20 @@ void loop() { HTTPClient http; USE_SERIAL.print("[HTTP] begin...\n"); - // configure traged server and url - http.begin("192.168.1.12", 80, "/test.html"); + + // configure server and url + http.begin("http://192.168.1.12/test.html"); + //http.begin("192.168.1.12", 80, "/test.html"); USE_SERIAL.print("[HTTP] GET...\n"); // start connection and send HTTP header int httpCode = http.GET(); if(httpCode) { // HTTP header has been send and Server response header has been handled - USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode); // file found at server - if(httpCode == 200) { + if(httpCode == HTTP_CODE_OK) { // get lenght of document (is -1 when Server sends no Content-Length header) int len = http.getSize(); @@ -89,8 +90,10 @@ void loop() { } } else { - USE_SERIAL.print("[HTTP] GET... failed, no connection or no HTTP server\n"); + USE_SERIAL.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str()); } + + http.end(); } delay(10000); diff --git a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp index 37b71dbc1..6a8d010e1 100644 --- a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp +++ b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp @@ -26,9 +26,11 @@ #include #include #include +#include #include "ESP8266HTTPClient.h" + /** * constractor */ @@ -100,27 +102,34 @@ void HTTPClient::begin(String url, String httpsFingerprint) { String protocol; // check for : (http: or https: int index = url.indexOf(':'); - int index2; + //int index2; bool hasPort = false; if(index) { protocol = url.substring(0, index); url.remove(0, (index + 3)); // remove http:// or https:// - index = url.indexOf(':'); - index2 = url.indexOf('/'); + index = url.indexOf('/'); + String host = url.substring(0, index); + url.remove(0, index); // remove host part - if(index >= 0 && ((index2 >= 0 && index < index2) || index2 == 0)) { // do we have a port? - _host = url.substring(0, index); // hostname - url.remove(0, (index + 1)); // remove hostname + : + // get Authorization + index = host.indexOf('@'); + if(index >= 0) { + // auth info + String auth = host.substring(0, index); + host.remove(0, index +1); // remove auth part including @ + _base64Authorization = base64::encode(auth); + } - index = url.indexOf('/'); - _port = url.substring(0, index).toInt(); // get port - url.remove(0, index); // remove port + // get port + index = host.indexOf(':'); + if(index >= 0) { + _host = host.substring(0, index); // hostname + host.remove(0, (index + 1)); // remove hostname + : + _port = host.toInt(); // get port hasPort = true; } else { - index = index2; - _host = url.substring(0, index); - url.remove(0, index); // remove hostname + _host = host; } _url = url; @@ -139,6 +148,7 @@ void HTTPClient::begin(String url, String httpsFingerprint) { DEBUG_HTTPCLIENT("[HTTP-Client][begin] protocol: %s unknown?!\n", protocol.c_str()); return; } + } DEBUG_HTTPCLIENT("[HTTP-Client][begin] host: %s port: %d url: %s https: %d httpsFingerprint: %s\n", _host.c_str(), _port, _url.c_str(), _https, _httpsFingerprint.c_str()); @@ -219,6 +229,30 @@ void HTTPClient::setUserAgent(const char * userAgent) { _userAgent = userAgent; } +/** + * set the Authorizatio for the http request + * @param user const char * + * @param password const char * + */ +void HTTPClient::setAuthorization(const char * user, const char * password) { + if(user && password) { + String auth = user; + auth += ":"; + auth += password; + _base64Authorization = base64::encode(auth); + } +} + +/** + * set the Authorizatio for the http request + * @param auth const char * base64 + */ +void HTTPClient::setAuthorization(const char * auth) { + if(auth) { + _base64Authorization = auth; + } +} + /** * send a GET request * @return http code @@ -454,6 +488,33 @@ String HTTPClient::getString(void) { return sstring; } +/** + * converts error code to String + * @param error int + * @return String + */ +String HTTPClient::errorToString(int error) { + switch(error) { + case HTTPC_ERROR_CONNECTION_REFUSED: + return String("connection refused"); + case HTTPC_ERROR_SEND_HEADER_FAILED: + return String("send header failed"); + case HTTPC_ERROR_SEND_PAYLOAD_FAILED: + return String("send payload failed"); + case HTTPC_ERROR_NOT_CONNECTED: + return String("not connected"); + case HTTPC_ERROR_CONNECTION_LOST: + return String("connection lost"); + case HTTPC_ERROR_NO_STREAM: + return String("no stream"); + case HTTPC_ERROR_NO_HTTP_SERVER: + return String("no HTTP server"); + default: + return String(); + } +} + + /** * adds Header to the request * @param name @@ -463,7 +524,7 @@ String HTTPClient::getString(void) { void HTTPClient::addHeader(const String& name, const String& value, bool first) { // not allow set of Header handled by code - if(!name.equalsIgnoreCase("Connection") && !name.equalsIgnoreCase("User-Agent") && !name.equalsIgnoreCase("Host")) { + if(!name.equalsIgnoreCase("Connection") && !name.equalsIgnoreCase("User-Agent") && !name.equalsIgnoreCase("Host") && !(_base64Authorization.length() && name.equalsIgnoreCase("Authorization"))) { String headerLine = name; headerLine += ": "; headerLine += value; @@ -595,7 +656,13 @@ bool HTTPClient::sendHeader(const char * type) { } else { header += "close"; } - header += "\r\n" + _Headers + "\r\n"; + header += "\r\n"; + + if(_base64Authorization.length()) { + header += "Authorization: Basic " + _base64Authorization + "\r\n"; + } + + header += _Headers + "\r\n"; return (_tcp->write(header.c_str(), header.length()) == header.length()); } diff --git a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h index 2d1312a29..2bf6d0565 100644 --- a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h +++ b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h @@ -42,6 +42,67 @@ #define HTTPC_ERROR_NO_STREAM (-6) #define HTTPC_ERROR_NO_HTTP_SERVER (-7) +/// HTTP codes see RFC7231 +typedef enum { + HTTP_CODE_CONTINUE = 100, + HTTP_CODE_SWITCHING_PROTOCOLS = 101, + HTTP_CODE_PROCESSING = 102, + HTTP_CODE_OK = 200, + HTTP_CODE_CREATED = 201, + HTTP_CODE_ACCEPTED = 202, + HTTP_CODE_NON_AUTHORITATIVE_INFORMATION = 203, + HTTP_CODE_NO_CONTENT = 204, + HTTP_CODE_RESET_CONTENT = 205, + HTTP_CODE_PARTIAL_CONTENT = 206, + HTTP_CODE_MULTI_STATUS = 207, + HTTP_CODE_ALREADY_REPORTED = 208, + HTTP_CODE_IM_USED = 226, + HTTP_CODE_MULTIPLE_CHOICES = 300, + HTTP_CODE_MOVED_PERMANENTLY = 301, + HTTP_CODE_FOUND = 302, + HTTP_CODE_SEE_OTHER = 303, + HTTP_CODE_NOT_MODIFIED = 304, + HTTP_CODE_USE_PROXY = 305, + HTTP_CODE_TEMPORARY_REDIRECT = 307, + HTTP_CODE_PERMANENT_REDIRECT = 308, + HTTP_CODE_BAD_REQUEST = 400, + HTTP_CODE_UNAUTHORIZED = 401, + HTTP_CODE_PAYMENT_REQUIRED = 402, + HTTP_CODE_FORBIDDEN = 403, + HTTP_CODE_NOT_FOUND = 404, + HTTP_CODE_METHOD_NOT_ALLOWED = 405, + HTTP_CODE_NOT_ACCEPTABLE = 406, + HTTP_CODE_PROXY_AUTHENTICATION_REQUIRED = 407, + HTTP_CODE_REQUEST_TIMEOUT = 408, + HTTP_CODE_CONFLICT = 409, + HTTP_CODE_GONE = 410, + HTTP_CODE_LENGTH_REQUIRED = 411, + HTTP_CODE_PRECONDITION_FAILED = 412, + HTTP_CODE_PAYLOAD_TOO_LARGE = 413, + HTTP_CODE_URI_TOO_LONG = 414, + HTTP_CODE_UNSUPPORTED_MEDIA_TYPE = 415, + HTTP_CODE_RANGE_NOT_SATISFIABLE = 416, + HTTP_CODE_EXPECTATION_FAILED = 417, + HTTP_CODE_MISDIRECTED_REQUEST = 421, + HTTP_CODE_UNPROCESSABLE_ENTITY = 422, + HTTP_CODE_LOCKED = 423, + HTTP_CODE_FAILED_DEPENDENCY = 424, + HTTP_CODE_UPGRADE_REQUIRED = 426, + HTTP_CODE_PRECONDITION_REQUIRED = 428, + HTTP_CODE_TOO_MANY_REQUESTS = 429, + HTTP_CODE_REQUEST_HEADER_FIELDS_TOO_LARGE = 431, + HTTP_CODE_INTERNAL_SERVER_ERROR = 500, + HTTP_CODE_NOT_IMPLEMENTED = 501, + HTTP_CODE_BAD_GATEWAY = 502, + HTTP_CODE_SERVICE_UNAVAILABLE = 503, + HTTP_CODE_GATEWAY_TIMEOUT = 504, + HTTP_CODE_HTTP_VERSION_NOT_SUPPORTED = 505, + HTTP_CODE_VARIANT_ALSO_NEGOTIATES = 506, + HTTP_CODE_INSUFFICIENT_STORAGE = 507, + HTTP_CODE_LOOP_DETECTED = 508, + HTTP_CODE_NOT_EXTENDED = 510, + HTTP_CODE_NETWORK_AUTHENTICATION_REQUIRED = 511 +} t_http_codes; class HTTPClient { public: @@ -60,6 +121,8 @@ class HTTPClient { void setReuse(bool reuse); /// keep-alive void setUserAgent(const char * userAgent); + void setAuthorization(const char * user, const char * password); + void setAuthorization(const char * auth); /// request handling int GET(); @@ -86,6 +149,8 @@ class HTTPClient { int writeToStream(Stream * stream); String getString(void); + String errorToString(int error); + protected: struct RequestArgument { @@ -109,6 +174,7 @@ class HTTPClient { String _Headers; String _userAgent; + String _base64Authorization; /// Response handling RequestArgument* _currentHeaders; diff --git a/libraries/ESP8266WebServer/src/ESP8266WebServer.cpp b/libraries/ESP8266WebServer/src/ESP8266WebServer.cpp index 67e42c090..a2c8a9866 100644 --- a/libraries/ESP8266WebServer/src/ESP8266WebServer.cpp +++ b/libraries/ESP8266WebServer/src/ESP8266WebServer.cpp @@ -71,6 +71,7 @@ ESP8266WebServer::~ESP8266WebServer() { delete handler; handler = next; } + close(); } void ESP8266WebServer::begin() { @@ -87,17 +88,25 @@ bool ESP8266WebServer::authenticate(const char * username, const char * password authReq.trim(); char toencodeLen = strlen(username)+strlen(password)+1; char *toencode = new char[toencodeLen]; - if(toencode == NULL) + if(toencode == NULL){ + authReq = String(); return false; + } char *encoded = new char[base64_encode_expected_len(toencodeLen)+1]; - if(encoded == NULL) + if(encoded == NULL){ + authReq = String(); + delete[] toencode; return false; - + } sprintf(toencode, "%s:%s", username, password); if(base64_encode_chars(toencode, toencodeLen, encoded) > 0 && authReq.equals(encoded)){ authReq = String(); + delete[] toencode; + delete[] encoded; return true; } + delete[] toencode; + delete[] encoded; } authReq = String(); } @@ -165,6 +174,14 @@ void ESP8266WebServer::handleClient() { _handleRequest(); } +void ESP8266WebServer::close() { + _server.close(); +} + +void ESP8266WebServer::stop() { + close(); +} + void ESP8266WebServer::sendHeader(const String& name, const String& value, bool first) { String headerLine = name; headerLine += ": "; diff --git a/libraries/ESP8266WebServer/src/ESP8266WebServer.h b/libraries/ESP8266WebServer/src/ESP8266WebServer.h index 40172e92a..e9ea8f1a1 100644 --- a/libraries/ESP8266WebServer/src/ESP8266WebServer.h +++ b/libraries/ESP8266WebServer/src/ESP8266WebServer.h @@ -66,6 +66,9 @@ public: void begin(); void handleClient(); + void close(); + void stop(); + bool authenticate(const char * username, const char * password); void requestAuthentication(); diff --git a/libraries/ESP8266WiFi/examples/HTTPSRequest/HTTPSRequest.ino b/libraries/ESP8266WiFi/examples/HTTPSRequest/HTTPSRequest.ino index 975fe13ef..6d10d5115 100644 --- a/libraries/ESP8266WiFi/examples/HTTPSRequest/HTTPSRequest.ino +++ b/libraries/ESP8266WiFi/examples/HTTPSRequest/HTTPSRequest.ino @@ -4,7 +4,7 @@ * This example demonstrates how to use * WiFiClientSecure class to access HTTPS API. * We fetch and display the status of - * esp8266/Arduino project continous integration + * esp8266/Arduino project continuous integration * build. * * Created by Ivan Grokhotkov, 2015. @@ -54,7 +54,7 @@ void setup() { Serial.println("certificate doesn't match"); } - String url = "/repos/esp8266/Arduino/commits/esp8266/status"; + String url = "/repos/esp8266/Arduino/commits/master/status"; Serial.print("requesting URL: "); Serial.println(url); diff --git a/libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino b/libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino index 7ffc78acd..eb7c02eff 100644 --- a/libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino +++ b/libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino @@ -71,7 +71,14 @@ void loop() { client.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n"); - delay(10); + int timeout = millis() + 5000; + while (client.available() == 0) { + if (timeout - millis() < 0) { + Serial.println(">>> Client Timeout !"); + client.stop(); + return; + } + } // Read all the lines of the reply from server and print them to Serial while(client.available()){ diff --git a/libraries/ESP8266WiFi/examples/WiFiClientBasic/WiFiClientBasic.ino b/libraries/ESP8266WiFi/examples/WiFiClientBasic/WiFiClientBasic.ino new file mode 100644 index 000000000..accb37bf8 --- /dev/null +++ b/libraries/ESP8266WiFi/examples/WiFiClientBasic/WiFiClientBasic.ino @@ -0,0 +1,68 @@ +/* + * This sketch sends a message to a TCP server + * + */ + +#include +#include + +ESP8266WiFiMulti WiFiMulti; + +void setup() { + Serial.begin(115200); + delay(10); + + // We start by connecting to a WiFi network + WiFiMulti.addAP("SSID", "passpasspass"); + + Serial.println(); + Serial.println(); + Serial.print("Wait for WiFi... "); + + while(WiFiMulti.run() != WL_CONNECTED) { + Serial.print("."); + delay(500); + } + + Serial.println(""); + Serial.println("WiFi connected"); + Serial.println("IP address: "); + Serial.println(WiFi.localIP()); + + delay(500); +} + + +void loop() { + const uint16_t port = 80; + const char * host = "192.168.1.1"; // ip or dns + + + + Serial.print("connecting to "); + Serial.println(host); + + // Use WiFiClient class to create TCP connections + WiFiClient client; + + if (!client.connect(host, port)) { + Serial.println("connection failed"); + Serial.println("wait 5 sec..."); + delay(5000); + return; + } + + // This will send the request to the server + client.print("Send this data to server"); + + //read back one line from server + String line = client.readStringUntil('\r'); + client.println(line); + + Serial.println("closing connection"); + client.stop(); + + Serial.println("wait 5 sec..."); + delay(5000); +} + diff --git a/libraries/ESP8266WiFi/src/WiFiClientSecure.cpp b/libraries/ESP8266WiFi/src/WiFiClientSecure.cpp index 6d4365221..f141a0909 100644 --- a/libraries/ESP8266WiFi/src/WiFiClientSecure.cpp +++ b/libraries/ESP8266WiFi/src/WiFiClientSecure.cpp @@ -29,7 +29,6 @@ extern "C" } #include #include "debug.h" -#include "cbuf.h" #include "ESP8266WiFi.h" #include "WiFiClientSecure.h" #include "WiFiClient.h" @@ -50,6 +49,17 @@ extern "C" #define SSL_DEBUG_OPTS 0 #endif +uint8_t* default_private_key = 0; +uint32_t default_private_key_len = 0; +static bool default_private_key_dynamic = false; +static int s_pk_refcnt = 0; +uint8_t* default_certificate = 0; +uint32_t default_certificate_len = 0; +static bool default_certificate_dynamic = false; + +static void clear_private_key(); +static void clear_certificate(); + class SSLContext { public: @@ -172,12 +182,17 @@ int SSLContext::_ssl_ctx_refcnt = 0; WiFiClientSecure::WiFiClientSecure() { + ++s_pk_refcnt; } WiFiClientSecure::~WiFiClientSecure() { if (_ssl) { _ssl->unref(); } + if (--s_pk_refcnt == 0) { + clear_private_key(); + clear_certificate(); + } } WiFiClientSecure::WiFiClientSecure(const WiFiClientSecure& other) @@ -337,6 +352,66 @@ bool WiFiClientSecure::verify(const char* fp, const char* url) { return true; } +void WiFiClientSecure::setCertificate(const uint8_t* cert_data, size_t size) { + clear_certificate(); + default_certificate = (uint8_t*) cert_data; + default_certificate_len = size; +} + +void WiFiClientSecure::setPrivateKey(const uint8_t* pk, size_t size) { + clear_private_key(); + default_private_key = (uint8_t*) pk; + default_private_key_len = size; +} + +bool WiFiClientSecure::loadCertificate(Stream& stream, size_t size) { + clear_certificate(); + default_certificate = new uint8_t[size]; + if (!default_certificate) { + return false; + } + if (stream.readBytes(default_certificate, size) != size) { + delete[] default_certificate; + return false; + } + default_certificate_dynamic = true; + default_certificate_len = size; + return true; +} + +bool WiFiClientSecure::loadPrivateKey(Stream& stream, size_t size) { + clear_private_key(); + default_private_key = new uint8_t[size]; + if (!default_private_key) { + return false; + } + if (stream.readBytes(default_private_key, size) != size) { + delete[] default_private_key; + return false; + } + default_private_key_dynamic = true; + default_private_key_len = size; + return true; +} + +static void clear_private_key() { + if (default_private_key && default_private_key_dynamic) { + delete[] default_private_key; + default_private_key_dynamic = false; + } + default_private_key = 0; + default_private_key_len = 0; +} + +static void clear_certificate() { + if (default_certificate && default_certificate_dynamic) { + delete[] default_certificate; + default_certificate_dynamic = false; + } + default_certificate = 0; + default_certificate_len = 0; +} + extern "C" int ax_port_read(int fd, uint8_t* buffer, size_t count) { ClientContext* _client = reinterpret_cast(fd); if (_client->state() != ESTABLISHED && !_client->getSize()) { diff --git a/libraries/ESP8266WiFi/src/WiFiClientSecure.h b/libraries/ESP8266WiFi/src/WiFiClientSecure.h index 8ce11f939..07b111e1a 100644 --- a/libraries/ESP8266WiFi/src/WiFiClientSecure.h +++ b/libraries/ESP8266WiFi/src/WiFiClientSecure.h @@ -48,6 +48,22 @@ public: int peek() override; void stop() override; + void setCertificate(const uint8_t* cert_data, size_t size); + void setPrivateKey(const uint8_t* pk, size_t size); + + bool loadCertificate(Stream& stream, size_t size); + bool loadPrivateKey(Stream& stream, size_t size); + + template + bool loadCertificate(TFile& file) { + return loadCertificate(file, file.size()); + } + + template + bool loadPrivateKey(TFile& file) { + return loadPrivateKey(file, file.size()); + } + protected: int _connectSSL(); diff --git a/libraries/ESP8266WiFi/src/WiFiServer.cpp b/libraries/ESP8266WiFi/src/WiFiServer.cpp index 5de2d4ac7..462e7d7de 100644 --- a/libraries/ESP8266WiFi/src/WiFiServer.cpp +++ b/libraries/ESP8266WiFi/src/WiFiServer.cpp @@ -121,6 +121,16 @@ uint8_t WiFiServer::status() { return _pcb->state; } +void WiFiServer::close() { + if (!_pcb) { + return; + } + tcp_close(_pcb); +} + +void WiFiServer::stop() { + close(); +} size_t WiFiServer::write(uint8_t b) { return write(&b, 1); diff --git a/libraries/ESP8266WiFi/src/WiFiServer.h b/libraries/ESP8266WiFi/src/WiFiServer.h index 263bcbcdf..424a2331d 100644 --- a/libraries/ESP8266WiFi/src/WiFiServer.h +++ b/libraries/ESP8266WiFi/src/WiFiServer.h @@ -54,6 +54,8 @@ public: virtual size_t write(uint8_t); virtual size_t write(const uint8_t *buf, size_t size); uint8_t status(); + void close(); + void stop(); using Print::write; diff --git a/libraries/ESP8266WiFi/src/include/UdpContext.h b/libraries/ESP8266WiFi/src/include/UdpContext.h index d9347fd34..708007036 100644 --- a/libraries/ESP8266WiFi/src/include/UdpContext.h +++ b/libraries/ESP8266WiFi/src/include/UdpContext.h @@ -1,9 +1,9 @@ -/* +/* UdpContext.h - UDP connection handling on top of lwIP Copyright (c) 2014 Ivan Grokhotkov. All rights reserved. This file is part of the esp8266 core for Arduino environment. - + 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 @@ -206,10 +206,10 @@ public: size_t max_size = _rx_buf->len - _rx_buf_offset; size = (size < max_size) ? size : max_size; DEBUGV(":urd %d, %d, %d\r\n", size, _rx_buf->len, _rx_buf_offset); - - os_memcpy(dst, reinterpret_cast(_rx_buf->payload) + _rx_buf_offset, size); + + memcpy(dst, reinterpret_cast(_rx_buf->payload) + _rx_buf_offset, size); _consume(size); - + return size; } @@ -236,7 +236,7 @@ public: { _reserve(_tx_buf_offset + size); } - + size_t left_to_copy = size; while(left_to_copy) { @@ -249,7 +249,7 @@ public: continue; } size_t will_copy = (left_to_copy < free_cur) ? left_to_copy : free_cur; - os_memcpy(reinterpret_cast(_tx_buf_cur->payload) + used_cur, data, will_copy); + memcpy(reinterpret_cast(_tx_buf_cur->payload) + used_cur, data, will_copy); _tx_buf_offset += will_copy; left_to_copy -= will_copy; data += will_copy; @@ -259,18 +259,20 @@ public: void send(ip_addr_t* addr = 0, uint16_t port = 0) { - size_t orig_size = _tx_buf_head->tot_len; - size_t data_size = _tx_buf_offset; - size_t size_adjustment = orig_size - data_size; - for (pbuf* p = _tx_buf_head; p; p = p->next) - { - p->tot_len -= size_adjustment; - if (!p->next) - { - p->len = p->tot_len; - } + pbuf* tx_copy = pbuf_alloc(PBUF_TRANSPORT, data_size, PBUF_RAM); + uint8_t* dst = reinterpret_cast(tx_copy->payload); + for (pbuf* p = _tx_buf_head; p; p = p->next) { + size_t will_copy = (data_size < p->len) ? data_size : p->len; + memcpy(dst, p->payload, will_copy); + dst += will_copy; + data_size -= will_copy; } + pbuf_free(_tx_buf_head); + _tx_buf_head = 0; + _tx_buf_cur = 0; + _tx_buf_offset = 0; + if (!addr) { addr = &_dest_addr; @@ -282,30 +284,16 @@ public: _pcb->ttl = _multicast_ttl; } - udp_sendto(_pcb, _tx_buf_head, addr, port); - + udp_sendto(_pcb, tx_copy, addr, port); _pcb->ttl = old_ttl; - - for (pbuf* p = _tx_buf_head; p; p = p->next) - { - p->tot_len += size_adjustment; - if (!p->next) - { - p->len = p->tot_len; - } - } - - pbuf_free(_tx_buf_head); - _tx_buf_head = 0; - _tx_buf_cur = 0; - _tx_buf_offset = 0; + pbuf_free(tx_copy); } private: void _reserve(size_t size) { - const size_t pbuf_unit_size = 512; + const size_t pbuf_unit_size = 128; if (!_tx_buf_head) { _tx_buf_head = pbuf_alloc(PBUF_TRANSPORT, pbuf_unit_size, PBUF_RAM); @@ -357,7 +345,7 @@ private: } - static void _s_recv(void *arg, + static void _s_recv(void *arg, udp_pcb *upcb, pbuf *p, ip_addr_t *addr, u16_t port) { diff --git a/libraries/ESP8266httpUpdate/examples/httpUpdateSPIFFS/httpUpdateSPIFFS.ino b/libraries/ESP8266httpUpdate/examples/httpUpdateSPIFFS/httpUpdateSPIFFS.ino new file mode 100644 index 000000000..3d746af6c --- /dev/null +++ b/libraries/ESP8266httpUpdate/examples/httpUpdateSPIFFS/httpUpdateSPIFFS.ino @@ -0,0 +1,65 @@ +/** + * httpUpdateSPIFFS.ino + * + * Created on: 05.12.2015 + * + */ + +#include + +#include +#include + +#include +#include + +#define USE_SERIAL Serial + +ESP8266WiFiMulti WiFiMulti; + +void setup() { + + USE_SERIAL.begin(115200); + // USE_SERIAL.setDebugOutput(true); + + USE_SERIAL.println(); + USE_SERIAL.println(); + USE_SERIAL.println(); + + for(uint8_t t = 4; t > 0; t--) { + USE_SERIAL.printf("[SETUP] WAIT %d...\n", t); + USE_SERIAL.flush(); + delay(1000); + } + + WiFiMulti.addAP("SSID", "PASSWORD"); + +} + +void loop() { + // wait for WiFi connection + if((WiFiMulti.run() == WL_CONNECTED)) { + + USE_SERIAL.println("Update SPIFFS..."); + t_httpUpdate_return ret = ESPhttpUpdate.updateSpiffs("https://server/spiffs.bin"); + if(ret == HTTP_UPDATE_OK) { + USE_SERIAL.println("Update sketch..."); + ret = ESPhttpUpdate.update("https://server/file.bin"); + + switch(ret) { + case HTTP_UPDATE_FAILED: + USE_SERIAL.println("HTTP_UPDATE_FAILD"); + break; + + case HTTP_UPDATE_NO_UPDATES: + USE_SERIAL.println("HTTP_UPDATE_NO_UPDATES"); + break; + + case HTTP_UPDATE_OK: + USE_SERIAL.println("HTTP_UPDATE_OK"); + break; + } + } + } +} + diff --git a/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp b/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp index 39ba0555c..785258de9 100644 --- a/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp +++ b/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp @@ -23,9 +23,11 @@ * */ - #include "ESP8266httpUpdate.h" +#include +extern "C" uint32_t _SPIFFS_start; +extern "C" uint32_t _SPIFFS_end; ESP8266HTTPUpdate::ESP8266HTTPUpdate(void) { } @@ -46,6 +48,19 @@ t_httpUpdate_return ESP8266HTTPUpdate::update(const char * url, const char * cur return handleUpdate(&http, current_version); } +/** + * + * @param url const char * + * @param current_version const char * + * @param httpsFingerprint const char * + * @return t_httpUpdate_return + */ +t_httpUpdate_return ESP8266HTTPUpdate::updateSpiffs(const char * url, const char * current_version, const char * httpsFingerprint) { + HTTPClient http; + http.begin(url, httpsFingerprint); + return handleUpdate(&http, current_version, false, true); +} + /** * * @param host const char * @@ -73,7 +88,7 @@ t_httpUpdate_return ESP8266HTTPUpdate::update(String host, uint16_t port, String * @param current_version const char * * @return t_httpUpdate_return */ -t_httpUpdate_return ESP8266HTTPUpdate::handleUpdate(HTTPClient * http, const char * current_version) { +t_httpUpdate_return ESP8266HTTPUpdate::handleUpdate(HTTPClient * http, const char * current_version, bool reboot, bool spiffs) { t_httpUpdate_return ret = HTTP_UPDATE_FAILED; @@ -85,6 +100,12 @@ t_httpUpdate_return ESP8266HTTPUpdate::handleUpdate(HTTPClient * http, const cha http->addHeader("x-ESP8266-chip-size", String(ESP.getFlashChipRealSize())); http->addHeader("x-ESP8266-sdk-version", ESP.getSdkVersion()); + if(spiffs) { + http->addHeader("x-ESP8266-mode", "spiffs"); + } else { + http->addHeader("x-ESP8266-mode", "sketch"); + } + if(current_version && current_version[0] != 0x00) { http->addHeader("x-ESP8266-version", current_version); } @@ -99,6 +120,12 @@ t_httpUpdate_return ESP8266HTTPUpdate::handleUpdate(HTTPClient * http, const cha int code = http->GET(); int len = http->getSize(); + if(code <= 0) { + DEBUG_HTTP_UPDATE("[httpUpdate] HTTP error: %s\n", http->errorToString(code).c_str()); + http->end(); + return HTTP_UPDATE_FAILED; + } + DEBUG_HTTP_UPDATE("[httpUpdate] Header read fin.\n"); DEBUG_HTTP_UPDATE("[httpUpdate] Server header:\n"); DEBUG_HTTP_UPDATE("[httpUpdate] - code: %d\n", code); @@ -117,11 +144,24 @@ t_httpUpdate_return ESP8266HTTPUpdate::handleUpdate(HTTPClient * http, const cha } switch(code) { - case 200: ///< OK (Start Update) + case HTTP_CODE_OK: ///< OK (Start Update) if(len > 0) { - if(len > ESP.getFreeSketchSpace()) { + bool startUpdate = true; + if(spiffs) { + size_t spiffsSize = ((size_t) &_SPIFFS_end - (size_t) &_SPIFFS_start); + if(len > (int) spiffsSize) { + DEBUG_HTTP_UPDATE("[httpUpdate] spiffsSize to low (%d) needed: %d\n", spiffsSize, len); + startUpdate = false; + } + } else { + if(len > (int) ESP.getFreeSketchSpace()) { + DEBUG_HTTP_UPDATE("[httpUpdate] FreeSketchSpace to low (%d) needed: %d\n", ESP.getFreeSketchSpace(), len); + startUpdate = false; + } + } + + if(!startUpdate) { ret = HTTP_UPDATE_FAILED; - DEBUG_HTTP_UPDATE("[httpUpdate] FreeSketchSpace to low (%d) needed: %d\n", ESP.getFreeSketchSpace(), len); } else { WiFiClient * tcp = http->getStreamPtr(); @@ -131,11 +171,25 @@ t_httpUpdate_return ESP8266HTTPUpdate::handleUpdate(HTTPClient * http, const cha delay(100); - if(runUpdate(*tcp, len, http->header("x-MD5"))) { + int command; + + if(spiffs) { + command = U_SPIFFS; + DEBUG_HTTP_UPDATE("[httpUpdate] runUpdate spiffs...\n"); + } else { + command = U_FLASH; + DEBUG_HTTP_UPDATE("[httpUpdate] runUpdate flash...\n"); + } + + if(runUpdate(*tcp, len, http->header("x-MD5"), command)) { ret = HTTP_UPDATE_OK; DEBUG_HTTP_UPDATE("[httpUpdate] Update ok\n"); http->end(); - ESP.restart(); + + if(reboot) { + ESP.restart(); + } + } else { ret = HTTP_UPDATE_FAILED; DEBUG_HTTP_UPDATE("[httpUpdate] Update failed\n"); @@ -146,19 +200,18 @@ t_httpUpdate_return ESP8266HTTPUpdate::handleUpdate(HTTPClient * http, const cha DEBUG_HTTP_UPDATE("[httpUpdate] Content-Length is 0 or not set by Server?!\n"); } break; - case 304: + case HTTP_CODE_NOT_MODIFIED: ///< Not Modified (No updates) ret = HTTP_UPDATE_NO_UPDATES; break; - case 403: - ///< Forbidden - // todo handle login default: ret = HTTP_UPDATE_FAILED; - DEBUG_HTTP_UPDATE("[httpUpdate] Code is (%d)\n", code); + DEBUG_HTTP_UPDATE("[httpUpdate] HTTP Code is (%d)\n", code); + //http->writeToStream(&Serial1); break; } + http->end(); return ret; @@ -171,10 +224,14 @@ t_httpUpdate_return ESP8266HTTPUpdate::handleUpdate(HTTPClient * http, const cha * @param md5 String * @return true if Update ok */ -bool ESP8266HTTPUpdate::runUpdate(Stream& in, uint32_t size, String md5) { +bool ESP8266HTTPUpdate::runUpdate(Stream& in, uint32_t size, String md5, int command) { - if(!Update.begin(size)) { - DEBUG_HTTP_UPDATE("[httpUpdate] Update.begin failed!\n"); + StreamString error; + + if(!Update.begin(size, command)) { + Update.printError(error); + error.trim(); // remove line ending + DEBUG_HTTP_UPDATE("[httpUpdate] Update.begin failed! (%s)\n", error.c_str()); return false; } @@ -183,12 +240,16 @@ bool ESP8266HTTPUpdate::runUpdate(Stream& in, uint32_t size, String md5) { } if(Update.writeStream(in) != size) { - DEBUG_HTTP_UPDATE("[httpUpdate] Update.writeStream failed!\n"); + Update.printError(error); + error.trim(); // remove line ending + DEBUG_HTTP_UPDATE("[httpUpdate] Update.writeStream failed! (%s)\n", error.c_str()); return false; } if(!Update.end()) { - DEBUG_HTTP_UPDATE("[httpUpdate] Update.end failed!\n"); + Update.printError(error); + error.trim(); // remove line ending + DEBUG_HTTP_UPDATE("[httpUpdate] Update.end failed! (%s)\n", error.c_str()); return false; } diff --git a/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h b/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h index a494695ff..d3fe4ca19 100644 --- a/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h +++ b/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h @@ -53,9 +53,11 @@ class ESP8266HTTPUpdate { t_httpUpdate_return update(const char * host, uint16_t port, const char * url = "/", const char * current_version = "", bool https = false, const char * httpsFingerprint = ""); t_httpUpdate_return update(String host, uint16_t port, String url = "/", String current_version = "", bool https = false, String httpsFingerprint = ""); + t_httpUpdate_return updateSpiffs(const char * url, const char * current_version = "", const char * httpsFingerprint = ""); + protected: - t_httpUpdate_return handleUpdate(HTTPClient * http, const char * current_version); - bool runUpdate(Stream& in, uint32_t size, String md5); + t_httpUpdate_return handleUpdate(HTTPClient * http, const char * current_version, bool reboot = true, bool spiffs = false); + bool runUpdate(Stream& in, uint32_t size, String md5, int command = U_FLASH); }; extern ESP8266HTTPUpdate ESPhttpUpdate; diff --git a/package/package_esp8266com_index.template.json b/package/package_esp8266com_index.template.json index ee1042450..d070d4809 100644 --- a/package/package_esp8266com_index.template.json +++ b/package/package_esp8266com_index.template.json @@ -43,11 +43,14 @@ { "name": "SweetPea ESP-210" }, - { + { "name": "WeMos D1" }, - { + { "name": "WeMos D1 mini" + }, + { + "name": "ESPino" } ], "toolsDependencies": [ diff --git a/tests/FSWrapper/FSWrapper.ino b/tests/FSWrapper/FSWrapper.ino index b152093d5..099065f4f 100644 --- a/tests/FSWrapper/FSWrapper.ino +++ b/tests/FSWrapper/FSWrapper.ino @@ -139,7 +139,15 @@ void setup() { fail("some files left after format"); } } - + { + File tmp = SPIFFS.open("/tmp.txt", "w"); + } + { + File tmp = SPIFFS.open("/tmp.txt", "w"); + if (!tmp) { + fail("failed to re-open empty file"); + } + } Serial.println("success"); } diff --git a/tools/sdk/lib/libaxtls.a b/tools/sdk/lib/libaxtls.a index e8c08dc1e..9e29c802b 100644 Binary files a/tools/sdk/lib/libaxtls.a and b/tools/sdk/lib/libaxtls.a differ diff --git a/variants/espino/pins_arduino.h b/variants/espino/pins_arduino.h new file mode 100644 index 000000000..2efad2db3 --- /dev/null +++ b/variants/espino/pins_arduino.h @@ -0,0 +1,73 @@ +/* + 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 $ +*/ + +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#define EXTERNAL_NUM_INTERRUPTS 16 +#define NUM_DIGITAL_PINS 17 +#define NUM_ANALOG_INPUTS 1 + +#define analogInputToDigitalPin(p) ((p > 0)?NOT_A_PIN:0) +#define digitalPinToInterrupt(p) (((p) < EXTERNAL_NUM_INTERRUPTS)?p:NOT_A_PIN) +#define digitalPinHasPWM(p) (((p) < NUM_DIGITAL_PINS)?p:NOT_A_PIN) + +static const uint8_t SDA = 4; +static const uint8_t SCL = 5; + +static const uint8_t SS = 15; +static const uint8_t MOSI = 13; +static const uint8_t MISO = 12; +static const uint8_t SCK = 14; + +static const uint8_t BUILTIN_LED = 2; +static const uint8_t BUILTIN_LEDR = 2; +static const uint8_t BUILTIN_LEDG = 4; +static const uint8_t BUILTIN_LEDB = 5; +static const uint8_t BUILTIN_BUTTON = 0; + +static const uint8_t A0 = 17; + +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_USBVIRTUAL Serial +#define SERIAL_PORT_HARDWARE Serial +#define SERIAL_PORT_HARDWARE_OPEN Serial + +#endif /* Pins_Arduino_h */