mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-27 18:02:17 +03:00
Merge remote-tracking branch 'upstream/esp8266' into esp8266
This commit is contained in:
@ -291,7 +291,7 @@ uint32_t EspClass::getFlashChipSizeByChipId(void) {
|
||||
String EspClass::getResetInfo(void) {
|
||||
if(resetInfo.reason != 0) {
|
||||
char buff[200];
|
||||
sprintf(&buff[0], "Fatal exception:%d flag:%d (%s) epc1:0x%08x epc2:0x%08x epc3:0x%08x excvaddr:0x%08x depc:0x%08x", resetInfo.exccause, resetInfo.reason, (resetInfo.reason == 0 ? "DEFAULT" : resetInfo.reason == 1 ? "WDT" : resetInfo.reason == 2 ? "EXCEPTION" : resetInfo.reason == 3 ? "SOFT_WDT" : resetInfo.reason == 4 ? "SOFT_RESTART" : resetInfo.reason == 5 ? "DEEP_SLEEP_AWAKE" : "???"), resetInfo.epc1, resetInfo.epc2, resetInfo.epc3, resetInfo.excvaddr, resetInfo.depc);
|
||||
sprintf(&buff[0], "Fatal exception:%d flag:%d (%s) epc1:0x%08x epc2:0x%08x epc3:0x%08x excvaddr:0x%08x depc:0x%08x", resetInfo.exccause, resetInfo.reason, (resetInfo.reason == 0 ? "DEFAULT" : resetInfo.reason == 1 ? "WDT" : resetInfo.reason == 2 ? "EXCEPTION" : resetInfo.reason == 3 ? "SOFT_WDT" : resetInfo.reason == 4 ? "SOFT_RESTART" : resetInfo.reason == 5 ? "DEEP_SLEEP_AWAKE" : resetInfo.reason == 6 ? "EXT_SYS_RST" : "???"), resetInfo.epc1, resetInfo.epc2, resetInfo.epc3, resetInfo.excvaddr, resetInfo.depc);
|
||||
return String(buff);
|
||||
}
|
||||
return String("flag: 0");
|
||||
|
@ -290,6 +290,7 @@ uart_t* uart_init(int uart_nr, int baudrate, byte config, byte mode) {
|
||||
uart->txPin = (uart->txEnabled)?1:255;
|
||||
if(uart->rxEnabled) pinMode(uart->rxPin, SPECIAL);
|
||||
if(uart->txEnabled) pinMode(uart->txPin, SPECIAL);
|
||||
IOSWAP &= ~(1 << IOSWAPU0);
|
||||
break;
|
||||
case UART1:
|
||||
uart->rxEnabled = false;
|
||||
|
@ -221,13 +221,9 @@ public:
|
||||
: _fs(fs)
|
||||
, _fd(fd)
|
||||
, _stat({0})
|
||||
, _written(false)
|
||||
{
|
||||
CHECKFD();
|
||||
auto rc = SPIFFS_fstat(_fs->getFs(), _fd, &_stat);
|
||||
if (rc != SPIFFS_OK) {
|
||||
DEBUGV("SPIFFS_fstat rc=%d\r\n", rc);
|
||||
_stat = {0};
|
||||
}
|
||||
_getStat();
|
||||
}
|
||||
|
||||
~SPIFFSFileImpl() override {
|
||||
@ -242,7 +238,7 @@ public:
|
||||
DEBUGV("SPIFFS_write rc=%d\r\n", result);
|
||||
return 0;
|
||||
}
|
||||
|
||||
_written = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -265,11 +261,16 @@ public:
|
||||
if (rc < 0) {
|
||||
DEBUGV("SPIFFS_fflush rc=%d\r\n", rc);
|
||||
}
|
||||
_written = true;
|
||||
}
|
||||
|
||||
bool seek(uint32_t pos, SeekMode mode) override {
|
||||
CHECKFD();
|
||||
|
||||
int32_t offset = static_cast<int32_t>(pos);
|
||||
if (mode == SeekEnd) {
|
||||
offset = -offset;
|
||||
}
|
||||
auto rc = SPIFFS_lseek(_fs->getFs(), _fd, pos, (int) mode);
|
||||
if (rc < 0) {
|
||||
DEBUGV("SPIFFS_lseek rc=%d\r\n", rc);
|
||||
@ -293,7 +294,9 @@ public:
|
||||
|
||||
size_t size() const override {
|
||||
CHECKFD();
|
||||
|
||||
if (_written) {
|
||||
_getStat();
|
||||
}
|
||||
return _stat.size;
|
||||
}
|
||||
|
||||
@ -311,15 +314,27 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
void _getStat() const{
|
||||
CHECKFD();
|
||||
auto rc = SPIFFS_fstat(_fs->getFs(), _fd, &_stat);
|
||||
if (rc != SPIFFS_OK) {
|
||||
DEBUGV("SPIFFS_fstat rc=%d\r\n", rc);
|
||||
_stat = {0};
|
||||
}
|
||||
_written = false;
|
||||
}
|
||||
|
||||
SPIFFSImpl* _fs;
|
||||
spiffs_file _fd;
|
||||
spiffs_stat _stat;
|
||||
mutable spiffs_stat _stat;
|
||||
mutable bool _written;
|
||||
};
|
||||
|
||||
class SPIFFSDirImpl : public DirImpl {
|
||||
public:
|
||||
SPIFFSDirImpl(SPIFFSImpl* fs, spiffs_DIR& dir)
|
||||
: _fs(fs)
|
||||
SPIFFSDirImpl(const String& pattern, SPIFFSImpl* fs, spiffs_DIR& dir)
|
||||
: _pattern(pattern)
|
||||
, _fs(fs)
|
||||
, _dir(dir)
|
||||
, _valid(false)
|
||||
{
|
||||
@ -359,12 +374,16 @@ public:
|
||||
}
|
||||
|
||||
bool next() override {
|
||||
spiffs_dirent* result = SPIFFS_readdir(&_dir, &_dirent);
|
||||
_valid = (result != nullptr);
|
||||
const int n = _pattern.length();
|
||||
do {
|
||||
spiffs_dirent* result = SPIFFS_readdir(&_dir, &_dirent);
|
||||
_valid = (result != nullptr);
|
||||
} while(_valid && strncmp((const char*) _dirent.name, _pattern.c_str(), n) != 0);
|
||||
return _valid;
|
||||
}
|
||||
|
||||
protected:
|
||||
String _pattern;
|
||||
SPIFFSImpl* _fs;
|
||||
spiffs_DIR _dir;
|
||||
spiffs_dirent _dirent;
|
||||
@ -394,7 +413,7 @@ DirImplPtr SPIFFSImpl::openDir(const char* path) {
|
||||
DEBUGV("SPIFFSImpl::openDir: path=`%s` err=%d\r\n", path, _fs.err_code);
|
||||
return DirImplPtr();
|
||||
}
|
||||
return std::make_shared<SPIFFSDirImpl>(this, dir);
|
||||
return std::make_shared<SPIFFSDirImpl>(path, this, dir);
|
||||
}
|
||||
|
||||
int getSpiffsMode(OpenMode openMode, AccessMode accessMode) {
|
||||
|
@ -48,6 +48,9 @@ int32_t spiffs_hal_read(uint32_t addr, uint32_t size, uint8_t *dst) {
|
||||
uint32_t result = SPIFFS_OK;
|
||||
uint32_t alignedBegin = (addr + 3) & (~3);
|
||||
uint32_t alignedEnd = (addr + size) & (~3);
|
||||
if (alignedEnd < alignedBegin) {
|
||||
alignedEnd = alignedBegin;
|
||||
}
|
||||
|
||||
if (addr < alignedBegin) {
|
||||
uint32_t nb = alignedBegin - addr;
|
||||
@ -101,6 +104,9 @@ int32_t spiffs_hal_write(uint32_t addr, uint32_t size, uint8_t *src) {
|
||||
|
||||
uint32_t alignedBegin = (addr + 3) & (~3);
|
||||
uint32_t alignedEnd = (addr + size) & (~3);
|
||||
if (alignedEnd < alignedBegin) {
|
||||
alignedEnd = alignedBegin;
|
||||
}
|
||||
|
||||
if (addr < alignedBegin) {
|
||||
uint32_t nb = alignedBegin - addr;
|
||||
|
Reference in New Issue
Block a user