From 921a8c9201e8f19c62221749ed851a2bc176be58 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 21 May 2015 10:04:05 +0300 Subject: [PATCH 1/3] Add changelog for the esp8266 core --- hardware/esp8266com/esp8266/changes.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 hardware/esp8266com/esp8266/changes.md diff --git a/hardware/esp8266com/esp8266/changes.md b/hardware/esp8266com/esp8266/changes.md new file mode 100644 index 000000000..25c27a12f --- /dev/null +++ b/hardware/esp8266com/esp8266/changes.md @@ -0,0 +1,21 @@ + + +# Current version + +- Add 32-bit Linux toolchain +- Better connection handling in ESP8266WebServer. + The server now sends Content-Length and Connection: close headers, + then waits for the client to disconnect. By not closing the connection + actively, server avoids TIME_WAIT TCP state, and the TCP stack is able to + release the memory immediately, without waiting for 2xMSL period. + If the client doesn't disconnect in 2000ms, the server closes the connection + actively. +- Add Hash library, which has a function to calculate SHA1 hash. + +--- + +# 1.6.4-g545ffde +19 May, 2015 + +- Initial release of board manager package + From dd58d72687cf35e019319c9c0cd198514b5f978d Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 21 May 2015 10:22:45 +0300 Subject: [PATCH 2/3] EEPROM: fix incorrect start address, support multiple instances related to #279, #240 --- .../esp8266/libraries/EEPROM/EEPROM.cpp | 150 +++++++++--------- .../esp8266/libraries/EEPROM/EEPROM.h | 61 ++++--- .../examples/eeprom_write/eeprom_write.ino | 2 +- 3 files changed, 104 insertions(+), 109 deletions(-) diff --git a/hardware/esp8266com/esp8266/libraries/EEPROM/EEPROM.cpp b/hardware/esp8266com/esp8266/libraries/EEPROM/EEPROM.cpp index 2d8b23db9..dfd968a4a 100644 --- a/hardware/esp8266com/esp8266/libraries/EEPROM/EEPROM.cpp +++ b/hardware/esp8266com/esp8266/libraries/EEPROM/EEPROM.cpp @@ -28,95 +28,91 @@ #include "os_type.h" #include "osapi.h" #include "spi_flash.h" -extern uint32_t _SPIFFS_end; } -#define CONFIG_START_SECTOR (((uint32_t)_SPIFFS_end - 0x40200000) / 4096) -#define CONFIG_SECTOR (CONFIG_START_SECTOR + 0) -#define CONFIG_ADDR (SPI_FLASH_SEC_SIZE * CONFIG_SECTOR) - -EEPROMClass::EEPROMClass() -: _data(0), _size(0), _dirty(false) +EEPROMClass::EEPROMClass(uint32_t sector) +: _sector(sector) +, _data(0) +, _size(0) +, _dirty(false) { } -void EEPROMClass::begin(size_t size) -{ - if (size <= 0) - return; - if (size > SPI_FLASH_SEC_SIZE) - size = SPI_FLASH_SEC_SIZE; +void EEPROMClass::begin(size_t size) { + if (size <= 0) + return; + if (size > SPI_FLASH_SEC_SIZE) + size = SPI_FLASH_SEC_SIZE; - _data = new uint8_t[size]; - _size = size; + if (_data) { + delete[] _data; + } - noInterrupts(); - spi_flash_read(CONFIG_ADDR, reinterpret_cast(_data), _size); - interrupts(); + _data = new uint8_t[size]; + _size = size; + + noInterrupts(); + spi_flash_read(_sector * SPI_FLASH_SEC_SIZE, reinterpret_cast(_data), _size); + interrupts(); } -void EEPROMClass::end() -{ - if (!_size) - return; +void EEPROMClass::end() { + if (!_size) + return; - commit(); - if(_data) { - delete[] _data; + commit(); + if(_data) { + delete[] _data; + } + _data = 0; + _size = 0; +} + + +uint8_t EEPROMClass::read(int address) { + if (address < 0 || (size_t)address >= _size) + return 0; + if(!_data) + return 0; + + return _data[address]; +} + +void EEPROMClass::write(int address, uint8_t value) { + if (address < 0 || (size_t)address >= _size) + return; + if(!_data) + return; + + _data[address] = value; + _dirty = true; +} + +bool EEPROMClass::commit() { + bool ret = false; + if (!_size) + return false; + if(!_dirty) + return true; + if(!_data) + return false; + + noInterrupts(); + if(spi_flash_erase_sector(_sector) == SPI_FLASH_RESULT_OK) { + if(spi_flash_write(_sector * SPI_FLASH_SEC_SIZE, reinterpret_cast(_data), _size) == SPI_FLASH_RESULT_OK) { + _dirty = false; + ret = true; } - _data = 0; - _size = 0; + } + interrupts(); + + return ret; } - -uint8_t EEPROMClass::read(int address) -{ - if (address < 0 || (size_t)address >= _size) - return 0; - if(!_data) - return 0; - - return _data[address]; +uint8_t * EEPROMClass::getDataPtr() { + _dirty = true; + return &_data[0]; } -void EEPROMClass::write(int address, uint8_t value) -{ - if (address < 0 || (size_t)address >= _size) - return; - if(!_data) - return; - - _data[address] = value; - _dirty = true; -} - -bool EEPROMClass::commit() -{ - bool ret = false; - if (!_size) - return false; - if(!_dirty) - return true; - if(!_data) - return false; - - noInterrupts(); - if(spi_flash_erase_sector(CONFIG_SECTOR) == SPI_FLASH_RESULT_OK) { - if(spi_flash_write(CONFIG_ADDR, reinterpret_cast(_data), _size) == SPI_FLASH_RESULT_OK) { - _dirty = false; - ret = true; - } - } - interrupts(); - - return ret; -} - -uint8_t * EEPROMClass::getDataPtr() -{ - _dirty = true; - return &_data[0]; -} - - -EEPROMClass EEPROM; +extern "C" uint32_t _SPIFFS_end; +EEPROMClass EEPROM((((uint32_t)&_SPIFFS_end - 0x40200000) / SPI_FLASH_SEC_SIZE)); diff --git a/hardware/esp8266com/esp8266/libraries/EEPROM/EEPROM.h b/hardware/esp8266com/esp8266/libraries/EEPROM/EEPROM.h index 97dd4c26a..ef7ac454d 100644 --- a/hardware/esp8266com/esp8266/libraries/EEPROM/EEPROM.h +++ b/hardware/esp8266com/esp8266/libraries/EEPROM/EEPROM.h @@ -26,43 +26,42 @@ #include #include -class EEPROMClass -{ - public: - EEPROMClass(); - void begin(size_t size); - uint8_t read(int address); - void write(int address, uint8_t val); - bool commit(); - void end(); +class EEPROMClass { +public: + EEPROMClass(uint32_t sector); - uint8_t * getDataPtr(); + void begin(size_t size); + uint8_t read(int address); + void write(int address, uint8_t val); + bool commit(); + void end(); - template T &get(int address, T &t) - { - if (address < 0 || address + sizeof(T) > _size) - return t; + uint8_t * getDataPtr(); - uint8_t *ptr = (uint8_t*) &t; - memcpy(ptr, _data + address, sizeof(T)); - return t; - } + template + T &get(int address, T &t) { + if (address < 0 || address + sizeof(T) > _size) + return t; - template const T &put(int address, const T &t) - { - if (address < 0 || address + sizeof(T) > _size) - return t; + memcpy((uint8_t*) &t, _data + address, sizeof(T)); + return t; + } - const uint8_t *ptr = (const uint8_t*) &t; - memcpy(_data + address, ptr, sizeof(T)); - _dirty = true; - return t; - } + template + const T &put(int address, const T &t) { + if (address < 0 || address + sizeof(T) > _size) + return t; - protected: - uint8_t* _data; - size_t _size; - bool _dirty; + memcpy(_data + address, (const uint8_t*) &t, sizeof(T)); + _dirty = true; + return t; + } + +protected: + uint32_t _sector; + uint8_t* _data; + size_t _size; + bool _dirty; }; extern EEPROMClass EEPROM; diff --git a/hardware/esp8266com/esp8266/libraries/EEPROM/examples/eeprom_write/eeprom_write.ino b/hardware/esp8266com/esp8266/libraries/EEPROM/examples/eeprom_write/eeprom_write.ino index 3f1af8e41..b41a5ca32 100644 --- a/hardware/esp8266com/esp8266/libraries/EEPROM/examples/eeprom_write/eeprom_write.ino +++ b/hardware/esp8266com/esp8266/libraries/EEPROM/examples/eeprom_write/eeprom_write.ino @@ -22,7 +22,7 @@ void loop() // need to divide by 4 because analog inputs range from // 0 to 1023 and each byte of the EEPROM can only hold a // value from 0 to 255. - int val = analogRead(0) / 4; + int val = analogRead(A0) / 4; // write the value to the appropriate byte of the EEPROM. // these values will remain there when the board is From 877f8ffbd63d6c6576ad78dafff2c3f54b1d68b8 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 21 May 2015 10:42:19 +0300 Subject: [PATCH 3/3] Bundle some libraries with the board manager package #282 SD #283 Adafruit_ILI9341 #290 OneWire --- build/.gitignore | 7 +++++++ build/build_board_manager_package.sh | 30 +++++++++++++++++++++------- 2 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 build/.gitignore diff --git a/build/.gitignore b/build/.gitignore new file mode 100644 index 000000000..0e4a6549a --- /dev/null +++ b/build/.gitignore @@ -0,0 +1,7 @@ +*.zip +linux/*tar.gz +linux/dist/*tgz +macosx/*tar.gz +macosx/dist/*tgz +windows/*zip +windows/dist/*tgz diff --git a/build/build_board_manager_package.sh b/build/build_board_manager_package.sh index 3d6ba517f..9a1582f6e 100755 --- a/build/build_board_manager_package.sh +++ b/build/build_board_manager_package.sh @@ -5,6 +5,11 @@ outdir=esp8266-$ver srcdir=../hardware/esp8266com/esp8266/ mkdir -p $outdir cp -R $srcdir/* $outdir/ + +cp -R ../libraries/SD $outdir/libraries/ +cp -R ../libraries/Adafruit_ILI9341 $outdir/libraries/ +cp -R ../libraries/OneWire $outdir/libraries/ + cat $srcdir/platform.txt | \ gsed 's/runtime.tools.xtensa-lx106-elf-gcc.path={runtime.platform.path}\/tools\/xtensa-lx106-elf//g' | \ gsed 's/runtime.tools.esptool.path={runtime.platform.path}\/tools//g' | \ @@ -12,13 +17,17 @@ gsed 's/tools.esptool.path={runtime.platform.path}\/tools/tools.esptool.path=\{r > $outdir/platform.txt zip -r $outdir.zip $outdir +rm -rf $outdir sha=`shasum -a 256 $outdir.zip | cut -f 1 -d ' '` size=`/bin/ls -l $outdir.zip | awk '{print $5}'` echo Size: $size echo SHA-256: $sha -scp $outdir.zip dl:apps/download_files/download/ - +if [ ! -z "$do_upload" ]; then + remote="http://arduino.esp8266.com" +else + remote="http://localhost:8000" +fi cat << EOF > package_esp8266com_index.json { @@ -36,7 +45,7 @@ cat << EOF > package_esp8266com_index.json "architecture":"esp8266", "version":"$ver", "category":"ESP8266", - "url":"http://arduino.esp8266.com/$outdir.zip", + "url":"$remote/$outdir.zip", "archiveFileName":"$outdir.zip", "checksum":"SHA-256:$sha", "size":"$size", @@ -85,11 +94,11 @@ cat << EOF > package_esp8266com_index.json "size":"12513" }, { - "host":"i686-pc-linux-gnu", - "url":"https://github.com/igrr/esptool-ck/releases/download/0.4.4/esptool-0.4.4-linux32.tar.gz", + "host":"i686-pc-linux-gnu", + "url":"https://github.com/igrr/esptool-ck/releases/download/0.4.4/esptool-0.4.4-linux32.tar.gz", "archiveFileName":"esptool-0.4.4-linux32.tar.gz", "checksum":"SHA-256:4aa81b97a470641771cf371e5d470ac92d3b177adbe8263c4aae66e607b67755", - "size":"12044" + "size":"12044" } ] }, @@ -131,5 +140,12 @@ cat << EOF > package_esp8266com_index.json } EOF -scp package_esp8266com_index.json dl:apps/download_files/download +if [ ! -z "$do_upload" ]; then + scp $outdir.zip dl:apps/download_files/download/ + scp package_esp8266com_index.json dl:apps/download_files/download +else + python -m SimpleHTTPServer +fi + +