Skip to content

Commit a9fbe27

Browse files
committed
Merge pull request esp8266#729 from Links2004/esp8266
fix mac 599 for ESP8266HTTPUpdate
2 parents 33de15e + f96ea40 commit a9fbe27

File tree

10 files changed

+44
-4
lines changed

10 files changed

+44
-4
lines changed

cores/esp8266/Updater.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "Updater.h"
22
#include "Arduino.h"
33
#include "eboot_command.h"
4+
#include "interrupts.h"
5+
46
//#define DEBUG_UPDATER Serial
57

68
extern "C" {

cores/esp8266/Updater.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#define UPDATE_ERROR_SIZE 4
1212
#define UPDATE_ERROR_STREAM 5
1313

14+
//#define DEBUG_UPDATER Serial1
15+
1416
class UpdaterClass {
1517
public:
1618
UpdaterClass();

cores/esp8266/debug.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
#define ARD_DEBUG_H
33

44
#include <stddef.h>
5-
// #define DEBUGV(...) ets_printf(__VA_ARGS__)
5+
//#define DEBUGV(...) ets_printf(__VA_ARGS__)
6+
7+
#ifndef DEBUGV
68
#define DEBUGV(...)
9+
#endif
710

811
#ifdef __cplusplus
912
void hexdump(uint8_t *mem, uint32_t len, uint8_t cols = 16);

libraries/ESP8266WiFi/src/WiFiClient.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,3 +332,16 @@ void WiFiClient::stopAll()
332332
}
333333
}
334334
}
335+
336+
337+
void WiFiClient::stopAllExcept(WiFiClient * exC) {
338+
for (WiFiClient* it = _s_first; it; it = it->_next) {
339+
ClientContext* c = it->_client;
340+
341+
if (c && c != exC->_client) {
342+
c->abort();
343+
c->unref();
344+
it->_client = 0;
345+
}
346+
}
347+
}

libraries/ESP8266WiFi/src/WiFiClient.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class WiFiClient : public Client, public SList<WiFiClient> {
9696
using Print::write;
9797

9898
static void stopAll();
99+
static void stopAllExcept(WiFiClient * c);
99100

100101
private:
101102

libraries/ESP8266WiFi/src/WiFiUdp.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,3 +290,12 @@ void WiFiUDP::stopAll()
290290
it->stop();
291291
}
292292
}
293+
294+
void WiFiUDP::stopAllExcept(WiFiUDP * exC) {
295+
for (WiFiUDP* it = _s_first; it; it = it->_next) {
296+
if (it->_ctx != exC->_ctx) {
297+
DEBUGV("%s %08x %08x\n", __func__, (uint32_t) it, (uint32_t) _s_first);
298+
it->stop();
299+
}
300+
}
301+
}

libraries/ESP8266WiFi/src/WiFiUdp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class WiFiUDP : public UDP, public SList<WiFiUDP> {
105105
uint16_t localPort();
106106

107107
static void stopAll();
108+
static void stopAllExcept(WiFiUDP * exC);
108109

109110
};
110111

libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,17 @@ t_httpUpdate_return ESP8266HTTPUpdate::update(const char * host, uint16_t port,
128128
ret = HTTP_UPDATE_FAILD;
129129
DEBUG_HTTP_UPDATE("[httpUpdate] FreeSketchSpace to low (%d) needed: %d\n", ESP.getFreeSketchSpace(), len);
130130
} else {
131-
if(ESP.updateSketch(tcp, len)) {
132-
// may never reached!
131+
132+
WiFiUDP::stopAll();
133+
WiFiClient::stopAllExcept(&tcp);
134+
135+
delay(100);
136+
137+
if(ESP.updateSketch(tcp, len, false, false)) {
133138
ret = HTTP_UPDATE_OK;
134139
DEBUG_HTTP_UPDATE("[httpUpdate] Update ok\n");
140+
tcp.stop();
141+
ESP.restart();
135142
} else {
136143
ret = HTTP_UPDATE_FAILD;
137144
DEBUG_HTTP_UPDATE("[httpUpdate] Update failed\n");

libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
#include <Arduino.h>
3030
#include <ESP8266WiFi.h>
31+
#include <WiFiUdp.h>
32+
#include <WiFiClient.h>
3133

3234
//#define DEBUG_HTTP_UPDATE(...) Serial1.printf( __VA_ARGS__ )
3335

tools/sdk/include/osapi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
#ifdef USE_OPTIMIZE_PRINTF
4848
#define os_printf(fmt, ...) do { \
49-
static const char flash_str[] ICACHE_RODATA_ATTR = fmt; \
49+
static const char flash_str[] ICACHE_RODATA_ATTR __attribute__((aligned(4))) = fmt; \
5050
os_printf_plus(flash_str, ##__VA_ARGS__); \
5151
} while(0)
5252
#else

0 commit comments

Comments
 (0)