This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#define _ARDUINOOTA_H_
|
||||
|
||||
#include "WiFiOTA.h"
|
||||
|
||||
#ifdef __AVR__
|
||||
#if FLASHEND >= 0xFFFF
|
||||
#include "InternalStorageAVR.h"
|
||||
@@ -28,6 +29,8 @@
|
||||
#include <InternalStorageSTM32.h>
|
||||
#elif defined(ARDUINO_ARCH_RP2040)
|
||||
#include <InternalStorageRP2.h>
|
||||
#elif defined(ARDUINO_ARCH_RENESAS_UNO)
|
||||
#include <InternalStorageRenesas.h>
|
||||
#elif defined(ESP8266) || defined(ESP32)
|
||||
#include "InternalStorageESP.h"
|
||||
#else
|
||||
@@ -59,10 +62,10 @@ public:
|
||||
}
|
||||
|
||||
void end() {
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
server.stop();
|
||||
#elif defined(_WIFI_ESP_AT_H_)
|
||||
#if defined(_WIFI_ESP_AT_H_)|| defined(WiFiS3_h) || defined(ESP32) || defined(UIPETHERNET_H)
|
||||
server.end();
|
||||
#elif defined(ESP8266) || (defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_ARCH_MBED))
|
||||
server.stop();
|
||||
#else
|
||||
//#warning "The networking library doesn't have a function to stop the server"
|
||||
#endif
|
||||
@@ -107,37 +110,38 @@ public:
|
||||
WiFiOTAClass::pollMdns(mdnsSocket);
|
||||
}
|
||||
|
||||
void handle() { // alias
|
||||
poll();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#if defined(ethernet_h_) || defined(ethernet_h) // Ethernet library
|
||||
#ifndef NO_OTA_NETWORK
|
||||
|
||||
#if defined(ethernet_h_) || defined(ethernet_h) || defined(UIPETHERNET_H)
|
||||
#define OTETHERNET
|
||||
#endif
|
||||
#if defined(UIPETHERNET_H) || defined(WIFIESPAT1) // no UDP multicast implementation
|
||||
#define NO_OTA_PORT
|
||||
#endif
|
||||
|
||||
#ifdef OTETHERNET
|
||||
#ifdef NO_OTA_PORT
|
||||
ArduinoOTAClass <EthernetServer, EthernetClient> ArduinoOTA;
|
||||
#else
|
||||
ArduinoOTAMdnsClass <EthernetServer, EthernetClient, EthernetUDP> ArduinoOTA;
|
||||
#endif
|
||||
|
||||
#elif defined(UIPETHERNET_H) // no UDP multicast implementation yet
|
||||
ArduinoOTAClass <EthernetServer, EthernetClient> ArduinoOTA;
|
||||
#else
|
||||
|
||||
#elif defined(WiFiNINA_h) || defined(WIFI_H) || defined(ESP8266) || defined(ESP32) || defined(ARDUINO_RASPBERRY_PI_PICO_W) // NINA, WiFi101 and Espressif WiFi
|
||||
#ifdef NO_OTA_PORT
|
||||
ArduinoOTAClass <WiFiServer, WiFiClient> ArduinoOTA;
|
||||
#else
|
||||
#include <WiFiUdp.h>
|
||||
ArduinoOTAMdnsClass <WiFiServer, WiFiClient, WiFiUDP> ArduinoOTA;
|
||||
#endif
|
||||
|
||||
#elif defined(_WIFI_ESP_AT_H_) && !defined(WIFIESPAT1) && !defined(NO_OTA_PORT) // WiFiEspAT with AT2 has UDP multicast
|
||||
ArduinoOTAMdnsClass <WiFiServer, WiFiClient, WiFiUDP> ArduinoOTA;
|
||||
|
||||
#elif defined(WiFi_h) || defined(_WIFI_ESP_AT_H_) // WiFi, WiFiLink and WiFiEspAT lib (no UDP multicast) for WiFiLink the firmware handles mdns
|
||||
ArduinoOTAClass <WiFiServer, WiFiClient> ArduinoOTA;
|
||||
|
||||
#elif defined(_WIFISPI_H_INCLUDED) // no UDP multicast implementation
|
||||
ArduinoOTAClass <WiFiSpiServer, WiFiSpiClient> ArduinoOTA;
|
||||
|
||||
#else
|
||||
#warning "Network library not included or not supported"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -63,7 +63,7 @@ extern "C" {
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if defined(__SAMD51__)
|
||||
// Invalidate all CMCC cache entries if CMCC cache is enabled.
|
||||
__attribute__ ((long_call, noinline, section (".data#")))
|
||||
@@ -94,7 +94,7 @@ extern "C" {
|
||||
for (int i = 0; i < length; i += rowSize) {
|
||||
NVMCTRL->ADDR.reg = ((uint32_t)(address + i)) / 2;
|
||||
NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_ER;
|
||||
|
||||
|
||||
waitForReady();
|
||||
}
|
||||
#elif defined(ARDUINO_ARCH_NRF5)
|
||||
@@ -113,7 +113,7 @@ extern "C" {
|
||||
waitForReady();
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
|
||||
waitForReady();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
__attribute__ ((long_call, noinline, section (".data#")))
|
||||
@@ -156,7 +156,10 @@ int InternalStorageClass::open(int length)
|
||||
NVMCTRL->CTRLB.bit.MANW = 0;
|
||||
#endif
|
||||
|
||||
#if !defined(ARDUINO_ARCH_NRF5)
|
||||
// Erase all pages
|
||||
eraseFlash(STORAGE_START_ADDRESS, pageAlignedLength, PAGE_SIZE);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -169,6 +172,13 @@ size_t InternalStorageClass::write(uint8_t b)
|
||||
if (_writeIndex == 4) {
|
||||
_writeIndex = 0;
|
||||
|
||||
#if defined(ARDUINO_ARCH_NRF5)
|
||||
// Erase a single page if needed
|
||||
if ((int)(_writeAddress) % PAGE_SIZE == 0) {
|
||||
eraseFlash((int)_writeAddress, PAGE_SIZE, PAGE_SIZE);
|
||||
}
|
||||
#endif
|
||||
|
||||
*_writeAddress = _addressData.u32;
|
||||
|
||||
_writeAddress++;
|
||||
@@ -184,6 +194,10 @@ void InternalStorageClass::close()
|
||||
while ((int)_writeAddress % PAGE_SIZE) {
|
||||
write(0xff);
|
||||
}
|
||||
|
||||
// Re-calculate pageAlignedLength in case the actually written binary
|
||||
// is smaller then the size provided in open()
|
||||
pageAlignedLength = (_writeAddress - (uint32_t*)STORAGE_START_ADDRESS) * sizeof(uint32_t);
|
||||
}
|
||||
|
||||
void InternalStorageClass::clear()
|
||||
|
||||
@@ -22,6 +22,9 @@ extern "C" char * g_pfnVectors; // at first address of the binary. 0x0000 withou
|
||||
#include <hardware/flash.h>
|
||||
extern "C" uint8_t _FS_start;
|
||||
extern "C" uint8_t _EEPROM_start;
|
||||
#elif defined(ARDUINO_ARCH_RENESAS_UNO)
|
||||
#include <r_flash_lp.h>
|
||||
extern "C" uint8_t __ROM_Start;
|
||||
#elif defined(ARDUINO_ARCH_MEGAAVR)
|
||||
#include <avr/wdt.h>
|
||||
#elif defined(__AVR__)
|
||||
@@ -47,10 +50,14 @@ OTAStorage::OTAStorage() :
|
||||
PAGE_SIZE(4), //for FLASH_TYPEPROGRAM_WORD
|
||||
#endif
|
||||
MAX_FLASH((min(LL_GetFlashSize(), 512ul) * 1024)) // LL_GetFlashSize returns size in kB. 512 is max for a bank
|
||||
#elif defined(ARDUINO_ARCH_RP2040)
|
||||
#elif defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_ARCH_MBED)
|
||||
SKETCH_START_ADDRESS(0),
|
||||
PAGE_SIZE(FLASH_PAGE_SIZE),
|
||||
MAX_FLASH((uint32_t) min(&_FS_start, &_EEPROM_start) - XIP_BASE)
|
||||
#elif defined(ARDUINO_ARCH_RENESAS_UNO)
|
||||
SKETCH_START_ADDRESS((uint32_t)(&__ROM_Start)),
|
||||
PAGE_SIZE(BSP_FEATURE_FLASH_LP_CF_BLOCK_SIZE),
|
||||
MAX_FLASH(BSP_ROM_SIZE_BYTES)
|
||||
#elif defined(__AVR__) && !defined(ARDUINO_ARCH_MEGAAVR)
|
||||
SKETCH_START_ADDRESS(0),
|
||||
PAGE_SIZE(SPM_PAGESIZE),
|
||||
|
||||
Reference in New Issue
Block a user