mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
Initial Upload From IDE
For Test ONLY
This commit is contained in:
parent
a82796f83f
commit
dc9072b94b
22
boards.txt
22
boards.txt
@ -1,7 +1,9 @@
|
|||||||
menu.UploadSpeed=Upload Speed
|
menu.UploadSpeed=Upload Speed
|
||||||
menu.CpuFrequency=CPU Frequency
|
menu.CpuFrequency=CPU Frequency
|
||||||
menu.FlashSize=Flash Size
|
menu.FlashSize=Flash Size
|
||||||
|
menu.FlashMode=Flash Mode
|
||||||
menu.FlashFreq=Flash Frequency
|
menu.FlashFreq=Flash Frequency
|
||||||
|
menu.UploadTool=Upload Using
|
||||||
|
|
||||||
##############################################################
|
##############################################################
|
||||||
generic.name=Generic ESP8266 Module
|
generic.name=Generic ESP8266 Module
|
||||||
@ -23,11 +25,26 @@ generic.build.variant=generic
|
|||||||
generic.build.flash_mode=qio
|
generic.build.flash_mode=qio
|
||||||
generic.build.spiffs_pagesize=256
|
generic.build.spiffs_pagesize=256
|
||||||
|
|
||||||
|
generic.menu.UploadTool.esptool=Serial
|
||||||
|
generic.menu.UploadTool.esptool.upload.tool=esptool
|
||||||
|
generic.menu.UploadTool.espota=OTA
|
||||||
|
generic.menu.UploadTool.espota.upload.tool=espota
|
||||||
|
|
||||||
generic.menu.CpuFrequency.80=80 MHz
|
generic.menu.CpuFrequency.80=80 MHz
|
||||||
generic.menu.CpuFrequency.80.build.f_cpu=80000000L
|
generic.menu.CpuFrequency.80.build.f_cpu=80000000L
|
||||||
generic.menu.CpuFrequency.160=160 MHz
|
generic.menu.CpuFrequency.160=160 MHz
|
||||||
generic.menu.CpuFrequency.160.build.f_cpu=160000000L
|
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=115200
|
||||||
generic.menu.UploadSpeed.115200.upload.speed=115200
|
generic.menu.UploadSpeed.115200.upload.speed=115200
|
||||||
generic.menu.UploadSpeed.9600=9600
|
generic.menu.UploadSpeed.9600=9600
|
||||||
@ -117,11 +134,6 @@ generic.menu.FlashSize.4M.upload.maximum_size=1044464
|
|||||||
# generic.menu.FlashSize.16M.build.spiffs_end=0x1000000
|
# generic.menu.FlashSize.16M.build.spiffs_end=0x1000000
|
||||||
# generic.menu.FlashSize.16M.build.spiffs_blocksize=8192
|
# generic.menu.FlashSize.16M.build.spiffs_blocksize=8192
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
##############################################################
|
##############################################################
|
||||||
modwifi.name=Olimex MOD-WIFI-ESP8266(-DEV)
|
modwifi.name=Olimex MOD-WIFI-ESP8266(-DEV)
|
||||||
|
|
||||||
|
@ -66,11 +66,16 @@ extern "C" {
|
|||||||
#define MDNS_TYPE_PTR 0x000C
|
#define MDNS_TYPE_PTR 0x000C
|
||||||
#define MDNS_TYPE_SRV 0x0021
|
#define MDNS_TYPE_SRV 0x0021
|
||||||
#define MDNS_TYPE_TXT 0x0010
|
#define MDNS_TYPE_TXT 0x0010
|
||||||
#define MDNS_TYPE_NSEC 0x002F
|
|
||||||
|
|
||||||
#define MDNS_CLASS_IN 0x0001
|
#define MDNS_CLASS_IN 0x0001
|
||||||
#define MDNS_CLASS_IN_FLUSH_CACHE 0x8001
|
#define MDNS_CLASS_IN_FLUSH_CACHE 0x8001
|
||||||
|
|
||||||
|
#define MDNS_ANSWERS_ALL 0x0F
|
||||||
|
#define MDNS_ANSWER_PTR 0x08
|
||||||
|
#define MDNS_ANSWER_TXT 0x04
|
||||||
|
#define MDNS_ANSWER_SRV 0x02
|
||||||
|
#define MDNS_ANSWER_A 0x01
|
||||||
|
|
||||||
#define _conn_read32() (((uint32_t)_conn->read() << 24) | ((uint32_t)_conn->read() << 16) | ((uint32_t)_conn->read() << 8) | _conn->read())
|
#define _conn_read32() (((uint32_t)_conn->read() << 24) | ((uint32_t)_conn->read() << 16) | ((uint32_t)_conn->read() << 8) | _conn->read())
|
||||||
#define _conn_read16() (((uint16_t)_conn->read() << 8) | _conn->read())
|
#define _conn_read16() (((uint16_t)_conn->read() << 8) | _conn->read())
|
||||||
#define _conn_read8() _conn->read()
|
#define _conn_read8() _conn->read()
|
||||||
@ -341,7 +346,6 @@ void MDNSResponder::_parsePacket(){
|
|||||||
else if(currentType == MDNS_TYPE_PTR) os_printf(" PTR ");
|
else if(currentType == MDNS_TYPE_PTR) os_printf(" PTR ");
|
||||||
else if(currentType == MDNS_TYPE_SRV) os_printf(" SRV ");
|
else if(currentType == MDNS_TYPE_SRV) os_printf(" SRV ");
|
||||||
else if(currentType == MDNS_TYPE_TXT) os_printf(" TXT ");
|
else if(currentType == MDNS_TYPE_TXT) os_printf(" TXT ");
|
||||||
else if(currentType == MDNS_TYPE_NSEC) os_printf(" NSEC ");
|
|
||||||
else os_printf(" 0x%04X ", currentType);
|
else os_printf(" 0x%04X ", currentType);
|
||||||
|
|
||||||
if(currentClass == MDNS_CLASS_IN) os_printf(" IN ");
|
if(currentClass == MDNS_CLASS_IN) os_printf(" IN ");
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
#include <ESP8266WiFi.h>
|
||||||
|
#include <ESP8266mDNS.h>
|
||||||
|
#include <WiFiUDP.h>
|
||||||
|
|
||||||
|
const char* host = "esp8266-ota";
|
||||||
|
const char* ssid = "**********";
|
||||||
|
const char* pass = "**********";
|
||||||
|
const uint16_t aport = 8266;
|
||||||
|
|
||||||
|
WiFiUDP listener;
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
Serial.setDebugOutput(true);
|
||||||
|
Serial.println("");
|
||||||
|
Serial.println("Arduino OTA Test");
|
||||||
|
|
||||||
|
Serial.printf("Sketch size: %u\n", ESP.getSketchSize());
|
||||||
|
Serial.printf("Free size: %u\n", ESP.getFreeSketchSpace());
|
||||||
|
|
||||||
|
WiFi.begin(ssid, pass);
|
||||||
|
if(WiFi.waitForConnectResult() == WL_CONNECTED){
|
||||||
|
MDNS.begin(host);
|
||||||
|
MDNS.addService("arduino", "tcp", aport);
|
||||||
|
listener.begin(aport);
|
||||||
|
Serial.print("IP address: ");
|
||||||
|
Serial.println(WiFi.localIP());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
if (ota_cmd_listener.parsePacket()) {
|
||||||
|
IPAddress remote = listener.remoteIP();
|
||||||
|
int cmd = listener.parseInt();
|
||||||
|
int port = listener.parseInt();
|
||||||
|
int sz = listener.parseInt();
|
||||||
|
Serial.printf("Starting Update: cmd:%d, port:%d, size:%d\r\n", cmd, port, sz);
|
||||||
|
WiFiClient cl;
|
||||||
|
if (!cl.connect(remote, port)) {
|
||||||
|
Serial.println("Failed to connect");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
listener.stop();
|
||||||
|
if (!ESP.updateSketch(cl, sz)) {
|
||||||
|
Serial.println("Update failed");
|
||||||
|
listener.begin(aport);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delay(100);
|
||||||
|
}
|
@ -93,3 +93,12 @@ tools.esptool.upload.protocol=esp
|
|||||||
tools.esptool.upload.params.verbose=-vv
|
tools.esptool.upload.params.verbose=-vv
|
||||||
tools.esptool.upload.params.quiet=
|
tools.esptool.upload.params.quiet=
|
||||||
tools.esptool.upload.pattern="{path}/{cmd}" {upload.verbose} -cd {upload.resetmethod} -cb {upload.speed} -cp "{serial.port}" -ca 0x00000 -cf "{build.path}/{build.project_name}.bin"
|
tools.esptool.upload.pattern="{path}/{cmd}" {upload.verbose} -cd {upload.resetmethod} -cb {upload.speed} -cp "{serial.port}" -ca 0x00000 -cf "{build.path}/{build.project_name}.bin"
|
||||||
|
|
||||||
|
tools.espota.cmd=python
|
||||||
|
tools.espota.cmd.windows=python.exe
|
||||||
|
tools.espota.path={runtime.platform.path}/tools
|
||||||
|
|
||||||
|
tools.espota.upload.protocol=espota
|
||||||
|
tools.espota.upload.params.verbose=
|
||||||
|
tools.espota.upload.params.quiet=
|
||||||
|
tools.espota.upload.pattern="{cmd}" "{path}/espota.py" "{serial.port}" "{build.path}/{build.project_name}.bin"
|
||||||
|
67
tools/espota.py
Executable file
67
tools/espota.py
Executable file
@ -0,0 +1,67 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
#
|
||||||
|
# this script will push an OTA update to the ESP
|
||||||
|
#
|
||||||
|
# use it like: python ota_server.py <ESP_IP_address> <sketch.bin>
|
||||||
|
#
|
||||||
|
# on the ESP side you need code like this: https://gist.github.com/igrr/43d5c52328e955bb6b09 to handle the update
|
||||||
|
#
|
||||||
|
|
||||||
|
import socket
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
def serve(remoteAddr, filename):
|
||||||
|
# Create a TCP/IP socket
|
||||||
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
serverPort = 48266
|
||||||
|
server_address = ('0.0.0.0', serverPort)
|
||||||
|
print >>sys.stderr, 'starting up on %s port %s' % server_address
|
||||||
|
sock.bind(server_address)
|
||||||
|
sock.listen(1)
|
||||||
|
|
||||||
|
sock2 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
|
remote_address = (remoteAddr, 8266)
|
||||||
|
content_size = os.path.getsize(filename)
|
||||||
|
print >>sys.stderr, 'upload size: %d' % content_size
|
||||||
|
message = '%d %d %d\n' % (0, serverPort, content_size)
|
||||||
|
print >>sys.stderr, 'sending invitation %s' % message
|
||||||
|
sent = sock2.sendto(message, remote_address)
|
||||||
|
sent = sock2.sendto(message, remote_address)
|
||||||
|
sent = sock2.sendto(message, remote_address)
|
||||||
|
|
||||||
|
|
||||||
|
while True:
|
||||||
|
# Wait for a connection
|
||||||
|
print >>sys.stderr, 'waiting for connection'
|
||||||
|
connection, client_address = sock.accept()
|
||||||
|
try:
|
||||||
|
print >>sys.stderr, 'connection from', client_address
|
||||||
|
|
||||||
|
print >>sys.stderr, 'opening file %s' % filename
|
||||||
|
f = open(filename, "rb")
|
||||||
|
|
||||||
|
while True:
|
||||||
|
chunk = f.read(4096)
|
||||||
|
if not chunk:
|
||||||
|
break
|
||||||
|
|
||||||
|
print >>sys.stderr, 'sending %d' % len(chunk)
|
||||||
|
connection.sendall(chunk)
|
||||||
|
|
||||||
|
print >>sys.stderr, 'done!'
|
||||||
|
return 0
|
||||||
|
|
||||||
|
finally:
|
||||||
|
connection.close()
|
||||||
|
f.close()
|
||||||
|
return 1
|
||||||
|
|
||||||
|
def main(args):
|
||||||
|
return serve(args[1], args[2])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.exit(main(sys.argv))
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user