Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 Nov 8, 2018
d7bd8db
WIP
d-a-v Nov 9, 2018
6b5c634
WIP
d-a-v Nov 9, 2018
786aa81
WIP
d-a-v Nov 9, 2018
909bbea
Merge branch 'host' of github.com:d-a-v/Arduino into host
d-a-v Nov 9, 2018
780e9d9
WIP
d-a-v Nov 10, 2018
b4e9cfb
WIP
d-a-v Nov 10, 2018
b087d70
WIP
d-a-v Nov 10, 2018
3ac0bf1
WIP
d-a-v Nov 10, 2018
1d795e5
WIP bufferize tcp input
d-a-v Nov 10, 2018
c9d302a
WIP Makefile
d-a-v Nov 11, 2018
b1e5769
WIP
d-a-v Nov 12, 2018
83e4a43
WIP network to rework, tcp/udp to factorize, udp addresses broken
d-a-v Nov 12, 2018
0520303
minor changes to the core
d-a-v Nov 12, 2018
3897ebe
WIP basic udp working
d-a-v Nov 13, 2018
c29a35d
WIP mdns
d-a-v Nov 14, 2018
c2f8b45
WIP
d-a-v Nov 14, 2018
005cd42
WIP
d-a-v Nov 14, 2018
964711e
WIP
d-a-v Nov 14, 2018
4b21486
WIP
d-a-v Nov 14, 2018
8921987
WIP mcast receiving, not sending
d-a-v Nov 14, 2018
f99e272
WIP mdns OK
d-a-v Nov 14, 2018
669397e
beta version
d-a-v Nov 14, 2018
c287b51
Merge branch 'master' into host
d-a-v Nov 14, 2018
2ec3403
SSL + doc
d-a-v Nov 15, 2018
e4a6c37
update travis host test command
d-a-v Nov 15, 2018
37aaa36
licenses
d-a-v Nov 15, 2018
57d2ee5
Merge branch 'host' of github.com:d-a-v/Arduino into host
d-a-v Nov 15, 2018
98f4cca
typo
d-a-v Nov 15, 2018
51ba240
Merge branch 'master' into host
d-a-v Nov 15, 2018
81c4f9b
doc: arduino builder is not around: declare functions before calling …
d-a-v Nov 15, 2018
76c7c4b
fix with latest SSL PR, compile in 32 bits mode
d-a-v Nov 15, 2018
e597a25
fix make clean
d-a-v Nov 16, 2018
bf42c2d
make -m32 optional
d-a-v Nov 16, 2018
1cc8f41
32bits compiler ability tester
d-a-v Nov 16, 2018
f9cd3c4
WIP
d-a-v Nov 16, 2018
4c4288b
WIP (fix 1 vtable error, still another one to hunt with using spiffs)
d-a-v Nov 16, 2018
77b61d1
example astyle
d-a-v Nov 16, 2018
6565a99
fix os_printf_plus
d-a-v Nov 16, 2018
706b313
load / save mock spiffs
d-a-v Nov 16, 2018
747f3b3
fix style
d-a-v Nov 16, 2018
940c0f1
fix using spiffs/mock
d-a-v Nov 16, 2018
3510f93
don't mess ram
d-a-v Nov 16, 2018
81d471f
update doc
d-a-v Nov 16, 2018
7bf8ab2
remove leftover
d-a-v Nov 16, 2018
a04996c
optimization -Os except for CI, rename ARCH32 to FORCE32
d-a-v Nov 16, 2018
ffe9811
revert useless cast (not even compiled)
d-a-v Nov 18, 2018
148bb78
remove unused function
d-a-v Nov 18, 2018
8bf7b01
use proper type for pointer arithmetics
d-a-v Nov 18, 2018
c7bc146
makefile: sketch object and cpp file moved to bin/ directories
d-a-v Nov 19, 2018
2f109c4
changes for review
d-a-v Nov 20, 2018
2d4c89b
make use of %zd
d-a-v Nov 20, 2018
aff3336
less verbose makefile by default (option)
d-a-v Nov 20, 2018
49b3e9c
update readme
d-a-v Nov 20, 2018
ab1e846
Merge branch 'master' into host
devyte Nov 20, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
make use of %zd
  • Loading branch information
d-a-v committed Nov 20, 2018
commit 2d4c89b4de6bcf685d60c06fa68ea5415f743110
18 changes: 9 additions & 9 deletions cores/esp8266/Updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,18 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) {
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));
size_t currentSketchSize = (ESP.getSketchSize() + FLASH_SECTOR_SIZE - 1) & (~(FLASH_SECTOR_SIZE - 1));
//address of the end of the space available for sketch and update
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));
size_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", (int)updateEndAddress, (int)updateEndAddress);
DEBUG_UPDATER.printf("[begin] currentSketchSize: 0x%08X (%d)\n", currentSketchSize, currentSketchSize);
DEBUG_UPDATER.printf("[begin] roundedSize: 0x%08zX (%zd)\n", roundedSize, roundedSize);
DEBUG_UPDATER.printf("[begin] updateEndAddress: 0x%08zX (%zd)\n", updateEndAddress, updateEndAddress);
DEBUG_UPDATER.printf("[begin] currentSketchSize: 0x%08zX (%zd)\n", currentSketchSize, currentSketchSize);
#endif

//make sure that the size of both sketches is less than the total space (updateEndAddress)
Expand Down Expand Up @@ -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", (int)_size, (int)_size);
DEBUG_UPDATER.printf("[begin] _size: 0x%08zX (%zd)\n", _size, _size);
#endif

_md5.begin();
Expand All @@ -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(), (unsigned)progress(), (unsigned)_size);
DEBUG_UPDATER.printf("premature end: res:%u, pos:%zu/%zu\n", getError(), progress(), _size);
#endif

_reset();
Expand Down Expand Up @@ -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, (unsigned)_size);
DEBUG_UPDATER.printf("Staged: address:0x%08X, size:0x%08zX\n", _startAddress, _size);
}
else if (_command == U_SPIFFS) {
DEBUG_UPDATER.printf("SPIFFS: address:0x%08X, size:0x%08X\n", _startAddress, (unsigned)_size);
DEBUG_UPDATER.printf("SPIFFS: address:0x%08X, size:0x%08zX\n", _startAddress, _size);
#endif
}

Expand Down
6 changes: 3 additions & 3 deletions cores/esp8266/spiffs_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ class SPIFFSImpl : public FSImpl
size_t cacheBufSize = SPIFFS_buffer_bytes_for_cache(&_fs, _maxOpenFds);

if (!_workBuf) {
DEBUGV("SPIFFSImpl: allocating %d+%d+%d=%d bytes\r\n",
(int)workBufSize, (int)fdsBufSize, (int)cacheBufSize,
(int)(workBufSize + fdsBufSize + cacheBufSize));
DEBUGV("SPIFFSImpl: allocating %zd+%zd+%zd=%zd bytes\r\n",
workBufSize, fdsBufSize, cacheBufSize,
workBufSize + fdsBufSize + cacheBufSize);
_workBuf.reset(new uint8_t[workBufSize]);
_fdsBuf.reset(new uint8_t[fdsBufSize]);
_cacheBuf.reset(new uint8_t[cacheBufSize]);
Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ int HTTPClient::sendRequest(const char * type, Stream * stream, size_t size)
free(buff);

if(size && (int) size != bytesWritten) {
DEBUG_HTTPCLIENT("[HTTP-Client][sendRequest] Stream payload bytesWritten %d and size %d mismatch!.\n", bytesWritten, (int)size);
DEBUG_HTTPCLIENT("[HTTP-Client][sendRequest] Stream payload bytesWritten %d and size %zd mismatch!.\n", bytesWritten, size);
DEBUG_HTTPCLIENT("[HTTP-Client][sendRequest] ERROR SEND PAYLOAD FAILED!");
return returnError(HTTPC_ERROR_SEND_PAYLOAD_FAILED);
} else {
Expand Down
4 changes: 2 additions & 2 deletions libraries/ESP8266WebServer/src/ESP8266WebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ void ESP8266WebServer::sendContent(const String& content) {
size_t len = content.length();
if(_chunked) {
char chunkSize[11];
sprintf(chunkSize, "%x\r\n", (unsigned)len);
sprintf(chunkSize, "%zx\r\n", len);
_currentClientWrite(chunkSize, strlen(chunkSize));
}
_currentClientWrite(content.c_str(), len);
Expand All @@ -459,7 +459,7 @@ void ESP8266WebServer::sendContent_P(PGM_P content, size_t size) {
const char * footer = "\r\n";
if(_chunked) {
char chunkSize[11];
sprintf(chunkSize, "%x\r\n", (unsigned)size);
sprintf(chunkSize, "%zx\r\n", size);
_currentClientWrite(chunkSize, strlen(chunkSize));
}
_currentClientWrite_P(content, size);
Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@ extern "C" {
int freeheap = ESP.getFreeHeap();
static int laststack, lastheap, laststack2;
if ((laststack != freestack) || (lastheap != freeheap) || (laststack2 != (int)br_esp8266_stack_proxy_usage())) {
Serial.printf("%s:%s(%d): FREESTACK=%d, STACK2USAGE=%d, FREEHEAP=%d\n", file, fcn, line, freestack, (int)br_esp8266_stack_proxy_usage(), freeheap);
Serial.printf("%s:%s(%d): FREESTACK=%d, STACK2USAGE=%zd, FREEHEAP=%d\n", file, fcn, line, freestack, br_esp8266_stack_proxy_usage(), freeheap);
if (freestack < 256) {
Serial.printf("!!! Out of main stack space\n");
}
Expand Down
4 changes: 2 additions & 2 deletions tests/host/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ MOCK_CPP_FILES_COMMON := $(addprefix common/,\
Arduino.cpp \
spiffs_mock.cpp \
WMath.cpp \
HardwareSerial.cpp \
MockSerial.cpp \
MockTools.cpp \
)

Expand Down Expand Up @@ -222,7 +222,7 @@ MOCK_ARDUINO_LIBS := \
common/MockWiFiServerSocket.cpp \
common/MockWiFiServer.cpp \
common/UdpContextSocket.cpp \
common/MockWire.cpp \
common/HostWiring.cpp \
common/MockEsp.cpp \
common/MockEEPROM.cpp \
common/MockSPI.cpp \
Expand Down
9 changes: 4 additions & 5 deletions tests/host/common/ArduinoMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ int main (int argc, char* const argv [])
exit(EXIT_FAILURE);
}
}

// setup global global_ipv4_netfmt
wifi_get_ip_info(0, nullptr);

Expand All @@ -122,9 +122,9 @@ int main (int argc, char* const argv [])
{
if (!fast)
usleep(10000); // not 100% cpu

loop();

// check incoming udp
for (auto& udp: udps)
{
Expand All @@ -133,11 +133,10 @@ int main (int argc, char* const argv [])
p.events = POLLIN;
if (poll(&p, 1, 0) && p.revents == POLLIN)
{
fprintf(stderr, MOCK "UDP poll(%d) -> cb\r", (int)p.fd);
fprintf(stderr, MOCK "UDP poll(%d) -> cb\r", p.fd);
udp.second->mock_cb();
}
}

}
return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/host/common/ClientContextSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ size_t mockFillInBuf (int sock, char* ccinbuf, size_t& ccinbufsize)
if (ret == -1)
{
if (errno != EAGAIN)
fprintf(stderr, MOCK "ClientContext::(read/peek): filling buffer for %d bytes: %s\n", (int)maxread, strerror(errno));
fprintf(stderr, MOCK "ClientContext::(read/peek): filling buffer for %zd bytes: %s\n", maxread, strerror(errno));
ret = 0;
}
return ccinbufsize += ret;
Expand All @@ -82,7 +82,7 @@ size_t mockFillInBuf (int sock, char* ccinbuf, size_t& ccinbufsize)
size_t mockPeekBytes (int sock, char* dst, size_t usersize, int timeout_ms, char* ccinbuf, size_t& ccinbufsize)
{
if (usersize > CCBUFSIZE)
fprintf(stderr, MOCK "CCBUFSIZE(%d) should be increased by %d bytes (-> %d)\n", CCBUFSIZE, (int)usersize - CCBUFSIZE, (int)usersize);
fprintf(stderr, MOCK "CCBUFSIZE(%d) should be increased by %zd bytes (-> %zd)\n", CCBUFSIZE, usersize - CCBUFSIZE, usersize);

struct pollfd p;
size_t retsize = 0;
Expand Down Expand Up @@ -143,7 +143,7 @@ size_t mockWrite (int sock, const uint8_t* data, size_t size, int timeout_ms)
}
if (ret != (int)size)
{
fprintf(stderr, MOCK "ClientContext::write: short write (%d < %d) (TODO)\n", (int)ret, (int)size);
fprintf(stderr, MOCK "ClientContext::write: short write (%d < %zd) (TODO)\n", ret, size);
exit(EXIT_FAILURE);
}
}
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/host/common/MockTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ extern "C" void configTime(long timezone, int daylightOffset_sec,
(void)server1;
(void)server2;
(void)server3;
fprintf(stderr, MOCK "configTime: TODO (tz=%dH offset=%dS) (time will be host's)\n", (int)timezone, daylightOffset_sec);

fprintf(stderr, MOCK "configTime: TODO (tz=%ldH offset=%dS) (time will be host's)\n", timezone, daylightOffset_sec);
}

void stack_thunk_add_ref() { }
Expand Down
8 changes: 4 additions & 4 deletions tests/host/common/MockWiFiServerSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void WiFiServer::begin ()
{
int sock;
struct sockaddr_in server;

if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1)
{
perror(MOCK "socket()");
Expand All @@ -79,7 +79,7 @@ void WiFiServer::begin ()
perror(MOCK "reuseport");
exit(EXIT_FAILURE);
}

server.sin_family = AF_INET;
server.sin_port = htons(_port);
server.sin_addr.s_addr = htonl(INADDR_ANY);
Expand All @@ -88,7 +88,7 @@ void WiFiServer::begin ()
perror(MOCK "bind()");
exit(EXIT_FAILURE);
}

if (listen(sock, 1) == -1)
{
perror(MOCK "listen()");
Expand All @@ -115,7 +115,7 @@ size_t WiFiServer::write (uint8_t c)

size_t WiFiServer::write (const uint8_t *buf, size_t size)
{
fprintf(stderr, MOCK "todo: WiFiServer::write(%p, %d)\n", buf, (int)size);
fprintf(stderr, MOCK "todo: WiFiServer::write(%p, %zd)\n", buf, size);
return 0;
}

Expand Down
30 changes: 15 additions & 15 deletions tests/host/common/UdpContextSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,28 @@ bool mockUDPListen (int sock, uint32_t dstaddr, uint16_t port, uint32_t mcast)
fprintf(stderr, MOCK "SO_REUSEADDR failed\n");

struct sockaddr_in servaddr;
memset(&servaddr, 0, sizeof(servaddr));
// Filling server information
memset(&servaddr, 0, sizeof(servaddr));

// Filling server information
servaddr.sin_family = AF_INET;
//servaddr.sin_addr.s_addr = global_ipv4_netfmt?: dstaddr;
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
servaddr.sin_port = htons(port);
// Bind the socket with the server address

// Bind the socket with the server address
if (bind(sock, (const struct sockaddr *)&servaddr, sizeof(servaddr)) < 0)
{
fprintf(stderr, MOCK "UDP bind on port %d failed: %s\n", port, strerror(errno));
fprintf(stderr, MOCK "UDP bind on port %d failed: %s\n", port, strerror(errno));
return false;
}
else
fprintf(stderr, MOCK "UDP server on port %d (sock=%d)\n", (int)port, (int)sock);
fprintf(stderr, MOCK "UDP server on port %d (sock=%d)\n", (int)port, sock);

if (mcast)
{
// https://web.cs.wpi.edu/~claypool/courses/4514-B99/samples/multicast.c
// https://stackoverflow.com/questions/12681097/c-choose-interface-for-udp-multicast-socket

struct ip_mreq mreq;
mreq.imr_multiaddr.s_addr = mcast;
//mreq.imr_interface.s_addr = global_ipv4_netfmt?: htonl(INADDR_ANY);
Expand All @@ -99,7 +99,7 @@ bool mockUDPListen (int sock, uint32_t dstaddr, uint16_t port, uint32_t mcast)
return false;
}
}

return true;
}

Expand All @@ -114,10 +114,10 @@ size_t mockUDPFillInBuf (int sock, char* ccinbuf, size_t& ccinbufsize, uint8_t&
if (ret == -1)
{
if (errno != EAGAIN)
fprintf(stderr, MOCK "UDPContext::(read/peek): filling buffer for %d bytes: %s\n", (int)maxread, strerror(errno));
fprintf(stderr, MOCK "UDPContext::(read/peek): filling buffer for %zd bytes: %s\n", maxread, strerror(errno));
ret = 0;
}

if (ret > 0)
{
port = ntohs(((sockaddr_in*)&addrbuf)->sin_port);
Expand All @@ -136,7 +136,7 @@ size_t mockUDPFillInBuf (int sock, char* ccinbuf, size_t& ccinbufsize, uint8_t&
size_t mockUDPPeekBytes (int sock, char* dst, size_t usersize, int timeout_ms, char* ccinbuf, size_t& ccinbufsize)
{
if (usersize > CCBUFSIZE)
fprintf(stderr, MOCK "CCBUFSIZE(%d) should be increased by %d bytes (-> %d)\n", CCBUFSIZE, (int)usersize - CCBUFSIZE, (int)usersize);
fprintf(stderr, MOCK "CCBUFSIZE(%d) should be increased by %zd bytes (-> %zd)\n", CCBUFSIZE, usersize - CCBUFSIZE, usersize);

size_t retsize = 0;
if (ccinbufsize)
Expand All @@ -161,7 +161,7 @@ size_t mockUDPRead (int sock, char* dst, size_t size, int timeout_ms, char* ccin

size_t mockUDPWrite (int sock, const uint8_t* data, size_t size, int timeout_ms, uint32_t ipv4, uint16_t port)
{
// Filling server information
// Filling server information
struct sockaddr_in peer;
peer.sin_family = AF_INET;
peer.sin_addr.s_addr = ipv4; //XXFIXME should use lwip_htonl?
Expand All @@ -174,7 +174,7 @@ size_t mockUDPWrite (int sock, const uint8_t* data, size_t size, int timeout_ms,
}
if (ret != (int)size)
{
fprintf(stderr, MOCK "UDPContext::write: short write (%d < %d) (TODO)\n", (int)ret, (int)size);
fprintf(stderr, MOCK "UDPContext::write: short write (%d < %zd) (TODO)\n", ret, size);
exit(EXIT_FAILURE);
}

Expand Down
10 changes: 5 additions & 5 deletions tests/host/common/include/UdpContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class UdpContext
fprintf(stderr, MOCK "TODO: implement UDP offset\n");
if (!isValidOffset(pos))
{
fprintf(stderr, MOCK "UDPContext::seek too far (%d >= %d)\n", (int)pos, (int)_inbufsize);
fprintf(stderr, MOCK "UDPContext::seek too far (%zd >= %zd)\n", pos, _inbufsize);
exit(EXIT_FAILURE);
}
}
Expand Down Expand Up @@ -183,7 +183,7 @@ class UdpContext
{
if (size + _outbufsize > sizeof _outbuf)
{
fprintf(stderr, MOCK "UdpContext::append: increase CCBUFSIZE (%d -> %d)\n", CCBUFSIZE, (int)(size + _outbufsize));
fprintf(stderr, MOCK "UdpContext::append: increase CCBUFSIZE (%d -> %zd)\n", CCBUFSIZE, (size + _outbufsize));
exit(EXIT_FAILURE);
}

Expand All @@ -200,7 +200,7 @@ class UdpContext
_outbufsize = 0;
return ret > 0;
}

void mock_cb (void)
{
if (_on_rx) _on_rx();
Expand Down Expand Up @@ -232,14 +232,14 @@ class UdpContext

ip_addr_t _dst;
uint16_t _dstport;

char _inbuf [CCBUFSIZE];
size_t _inbufsize = 0;
char _outbuf [CCBUFSIZE];
size_t _outbufsize = 0;

int _timeout_ms = 0;

uint8_t addrsize;
uint8_t addr[16];
};
Expand Down
Loading