mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-22 08:22:04 +03:00
Sketch emulation on host (#5342)
* WIP compile examples on host with 'make examples' * WIP bufferize tcp input * WIP Makefile * WIP network to rework, tcp/udp to factorize, udp addresses broken * minor changes to the core * WIP basic udp working * WIP mdns * WIP mcast receiving, not sending * WIP mdns OK * beta version * SSL + doc * update travis host test command * licenses * typo * doc: arduino builder is not around: declare functions before calling them * fix with latest SSL PR, compile in 32 bits mode * fix make clean * make -m32 optional * 32bits compiler ability tester * WIP * WIP (fix 1 vtable error, still another one to hunt with using spiffs) * example astyle * fix os_printf_plus * load / save mock spiffs * fix style * fix using spiffs/mock * don't mess ram * update doc * remove leftover * optimization -Os except for CI, rename ARCH32 to FORCE32 * revert useless cast (not even compiled) * remove unused function * use proper type for pointer arithmetics * makefile: sketch object and cpp file moved to bin/ directories easier to clean, and IDE don't like them * changes for review * make use of %zd * less verbose makefile by default (option) * update readme
This commit is contained in:
@ -22,7 +22,7 @@
|
||||
#include "flash_utils.h"
|
||||
#include "eboot_command.h"
|
||||
#include <memory>
|
||||
#include "interrupts.h"
|
||||
#include <interrupts.h>
|
||||
#include "MD5Builder.h"
|
||||
#include "umm_malloc/umm_malloc.h"
|
||||
#include "cont.h"
|
||||
@ -165,6 +165,7 @@ void EspClass::restart(void)
|
||||
uint16_t EspClass::getVcc(void)
|
||||
{
|
||||
InterruptLock lock;
|
||||
(void)lock;
|
||||
return system_get_vdd33();
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,7 @@ public:
|
||||
|
||||
class FSImpl {
|
||||
public:
|
||||
virtual ~FSImpl () { }
|
||||
virtual bool begin() = 0;
|
||||
virtual void end() = 0;
|
||||
virtual bool format() = 0;
|
||||
|
@ -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,21 +84,21 @@ 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));
|
||||
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
|
||||
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));
|
||||
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", updateEndAddress, 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)
|
||||
@ -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%08zX (%zd)\n", _size, _size);
|
||||
#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:%zu/%zu\n", getError(), progress(), _size);
|
||||
#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%08zX\n", _startAddress, _size);
|
||||
}
|
||||
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%08zX\n", _startAddress, _size);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -109,6 +109,7 @@ bool isSpiffsFilenameValid(const char* name)
|
||||
}
|
||||
|
||||
// these symbols should be defined in the linker script for each flash layout
|
||||
#ifndef CORE_MOCK
|
||||
#ifdef ARDUINO
|
||||
extern "C" uint32_t _SPIFFS_start;
|
||||
extern "C" uint32_t _SPIFFS_end;
|
||||
@ -131,6 +132,7 @@ FS SPIFFS = FS(FSImplPtr(new SPIFFSImpl(
|
||||
SPIFFS_PHYS_PAGE,
|
||||
SPIFFS_PHYS_BLOCK,
|
||||
SPIFFS_MAX_OPEN_FILES)));
|
||||
#endif
|
||||
#endif // ARDUINO
|
||||
#endif // !CORE_MOCK
|
||||
|
||||
#endif
|
||||
|
@ -220,7 +220,7 @@ protected:
|
||||
size_t cacheBufSize = SPIFFS_buffer_bytes_for_cache(&_fs, _maxOpenFds);
|
||||
|
||||
if (!_workBuf) {
|
||||
DEBUGV("SPIFFSImpl: allocating %d+%d+%d=%d bytes\r\n",
|
||||
DEBUGV("SPIFFSImpl: allocating %zd+%zd+%zd=%zd bytes\r\n",
|
||||
workBufSize, fdsBufSize, cacheBufSize,
|
||||
workBufSize + fdsBufSize + cacheBufSize);
|
||||
_workBuf.reset(new uint8_t[workBufSize]);
|
||||
|
Reference in New Issue
Block a user