-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Sketch emulation on host #5342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Sketch emulation on host #5342
Changes from 49 commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
022e66c
WIP compile examples on host with 'make examples'
d-a-v d7bd8db
WIP
d-a-v 6b5c634
WIP
d-a-v 786aa81
WIP
d-a-v 909bbea
Merge branch 'host' of github.com:d-a-v/Arduino into host
d-a-v 780e9d9
WIP
d-a-v b4e9cfb
WIP
d-a-v b087d70
WIP
d-a-v 3ac0bf1
WIP
d-a-v 1d795e5
WIP bufferize tcp input
d-a-v c9d302a
WIP Makefile
d-a-v b1e5769
WIP
d-a-v 83e4a43
WIP network to rework, tcp/udp to factorize, udp addresses broken
d-a-v 0520303
minor changes to the core
d-a-v 3897ebe
WIP basic udp working
d-a-v c29a35d
WIP mdns
d-a-v c2f8b45
WIP
d-a-v 005cd42
WIP
d-a-v 964711e
WIP
d-a-v 4b21486
WIP
d-a-v 8921987
WIP mcast receiving, not sending
d-a-v f99e272
WIP mdns OK
d-a-v 669397e
beta version
d-a-v c287b51
Merge branch 'master' into host
d-a-v 2ec3403
SSL + doc
d-a-v e4a6c37
update travis host test command
d-a-v 37aaa36
licenses
d-a-v 57d2ee5
Merge branch 'host' of github.com:d-a-v/Arduino into host
d-a-v 98f4cca
typo
d-a-v 51ba240
Merge branch 'master' into host
d-a-v 81c4f9b
doc: arduino builder is not around: declare functions before calling …
d-a-v 76c7c4b
fix with latest SSL PR, compile in 32 bits mode
d-a-v e597a25
fix make clean
d-a-v bf42c2d
make -m32 optional
d-a-v 1cc8f41
32bits compiler ability tester
d-a-v f9cd3c4
WIP
d-a-v 4c4288b
WIP (fix 1 vtable error, still another one to hunt with using spiffs)
d-a-v 77b61d1
example astyle
d-a-v 6565a99
fix os_printf_plus
d-a-v 706b313
load / save mock spiffs
d-a-v 747f3b3
fix style
d-a-v 940c0f1
fix using spiffs/mock
d-a-v 3510f93
don't mess ram
d-a-v 81d471f
update doc
d-a-v 7bf8ab2
remove leftover
d-a-v a04996c
optimization -Os except for CI, rename ARCH32 to FORCE32
d-a-v ffe9811
revert useless cast (not even compiled)
d-a-v 148bb78
remove unused function
d-a-v 8bf7b01
use proper type for pointer arithmetics
d-a-v c7bc146
makefile: sketch object and cpp file moved to bin/ directories
d-a-v 2f109c4
changes for review
d-a-v 2d4c89b
make use of %zd
d-a-v aff3336
less verbose makefile by default (option)
d-a-v 49b3e9c
update readme
d-a-v ab1e846
Merge branch 'master' into host
devyte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
#include "Updater.h" | ||
#include "Arduino.h" | ||
#include "eboot_command.h" | ||
#include "interrupts.h" | ||
#include "esp8266_peri.h" | ||
#include <interrupts.h> | ||
#include <esp8266_peri.h> | ||
|
||
//#define DEBUG_UPDATER Serial | ||
|
||
|
@@ -84,20 +84,20 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) { | |
|
||
wifi_set_sleep_type(NONE_SLEEP_T); | ||
|
||
uint32_t updateStartAddress = 0; | ||
uintptr_t updateStartAddress = 0; | ||
if (command == U_FLASH) { | ||
//size of current sketch rounded to a sector | ||
uint32_t currentSketchSize = (ESP.getSketchSize() + FLASH_SECTOR_SIZE - 1) & (~(FLASH_SECTOR_SIZE - 1)); | ||
//address of the end of the space available for sketch and update | ||
uint32_t updateEndAddress = (uint32_t)&_SPIFFS_start - 0x40200000; | ||
uintptr_t updateEndAddress = (uintptr_t)&_SPIFFS_start - 0x40200000; | ||
//size of the update rounded to a sector | ||
uint32_t roundedSize = (size + FLASH_SECTOR_SIZE - 1) & (~(FLASH_SECTOR_SIZE - 1)); | ||
//address where we will start writing the update | ||
updateStartAddress = (updateEndAddress > roundedSize)? (updateEndAddress - roundedSize) : 0; | ||
|
||
#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] updateEndAddress: 0x%08X (%d)\n", (int)updateEndAddress, (int)updateEndAddress); | ||
DEBUG_UPDATER.printf("[begin] currentSketchSize: 0x%08X (%d)\n", currentSketchSize, currentSketchSize); | ||
#endif | ||
|
||
|
@@ -108,7 +108,7 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) { | |
} | ||
} | ||
else if (command == U_SPIFFS) { | ||
updateStartAddress = (uint32_t)&_SPIFFS_start - 0x40200000; | ||
updateStartAddress = (uintptr_t)&_SPIFFS_start - 0x40200000; | ||
} | ||
else { | ||
// unknown command | ||
|
@@ -133,7 +133,7 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) { | |
#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); | ||
DEBUG_UPDATER.printf("[begin] _size: 0x%08X (%d)\n", (int)_size, (int)_size); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. %d=>%u? |
||
#endif | ||
|
||
_md5.begin(); | ||
|
@@ -159,7 +159,7 @@ bool UpdaterClass::end(bool evenIfRemaining){ | |
|
||
if(hasError() || (!isFinished() && !evenIfRemaining)){ | ||
#ifdef DEBUG_UPDATER | ||
DEBUG_UPDATER.printf("premature end: res:%u, pos:%u/%u\n", getError(), progress(), _size); | ||
DEBUG_UPDATER.printf("premature end: res:%u, pos:%u/%u\n", getError(), (unsigned)progress(), (unsigned)_size); | ||
devyte marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#endif | ||
|
||
_reset(); | ||
|
@@ -199,10 +199,10 @@ bool UpdaterClass::end(bool evenIfRemaining){ | |
eboot_command_write(&ebcmd); | ||
|
||
#ifdef DEBUG_UPDATER | ||
DEBUG_UPDATER.printf("Staged: address:0x%08X, size:0x%08X\n", _startAddress, _size); | ||
DEBUG_UPDATER.printf("Staged: address:0x%08X, size:0x%08X\n", _startAddress, (unsigned)_size); | ||
devyte marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
else if (_command == U_SPIFFS) { | ||
DEBUG_UPDATER.printf("SPIFFS: address:0x%08X, size:0x%08X\n", _startAddress, _size); | ||
DEBUG_UPDATER.printf("SPIFFS: address:0x%08X, size:0x%08X\n", _startAddress, (unsigned)_size); | ||
devyte marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#endif | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
UDPSendReceive.pde: | ||
This sketch receives UDP message strings, prints them to the serial port | ||
and sends an "acknowledge" string back to the sender | ||
|
||
A Processing sketch is included at the end of file that can be used to send | ||
and received messages for testing with a computer. | ||
|
||
created 21 Aug 2010 | ||
by Michael Margolis | ||
|
||
This code is in the public domain. | ||
|
||
adapted from Ethernet library examples | ||
*/ | ||
|
||
|
||
#include <ESP8266WiFi.h> | ||
#include <WiFiUdp.h> | ||
|
||
#define SSID "ssid" | ||
#define PSK "psk" | ||
|
||
unsigned int localPort = 8888; // local port to listen on | ||
|
||
// buffers for receiving and sending data | ||
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet, | ||
char ReplyBuffer[] = "acknowledged\r\n"; // a string to send back | ||
|
||
WiFiUDP Udp; | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
WiFi.mode(WIFI_STA); | ||
WiFi.begin(SSID, PSK); | ||
while (WiFi.status() != WL_CONNECTED) { | ||
Serial.print('.'); | ||
delay(500); | ||
} | ||
Serial.print("Connected! IP address: "); | ||
Serial.println(WiFi.localIP()); | ||
Serial.printf("UDP server on port %d\n", localPort); | ||
Udp.begin(localPort); | ||
} | ||
|
||
void loop() { | ||
// if there's data available, read a packet | ||
int packetSize = Udp.parsePacket(); | ||
if (packetSize) { | ||
Serial.print("Received packet of size "); | ||
Serial.println(packetSize); | ||
Serial.print("From "); | ||
IPAddress remote = Udp.remoteIP(); | ||
for (int i = 0; i < 4; i++) { | ||
Serial.print(remote[i], DEC); | ||
if (i < 3) { | ||
Serial.print("."); | ||
} | ||
} | ||
Serial.print(", port "); | ||
Serial.println(Udp.remotePort()); | ||
|
||
// read the packet into packetBufffer | ||
Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE); | ||
Serial.println("Contents:"); | ||
Serial.println(packetBuffer); | ||
|
||
// send a reply, to the IP address and port that sent us the packet we received | ||
Udp.beginPacket(Udp.remoteIP(), Udp.remotePort()); | ||
Udp.write(ReplyBuffer); | ||
Udp.endPacket(); | ||
} | ||
delay(10); | ||
} | ||
|
||
/* | ||
test (shell/netcat): | ||
--------------- | ||
nc -u 192.168.esp.address 8888 | ||
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0x%08X => %p?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%d => %u or %ul?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Output is aligned on purpose, only the second is a pointer, using %p would required alignment testing.
uint32_t
may be anint
,size_t
too, or along
.printf()
and types different fromint
/long
, we never know for sure which one they are. I only casted what was necessary to warninglessly compile on 64 bits host. I believe those printf cast are harmless on esp8266/32bits.