diff --git a/.gitignore b/.gitignore index 88b3c6b5c..ec5122ae8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ rancilio-pid/userConfig.h-mb rancilio-pid/.vscode/arduino.json rancilio-pid/.vscode/c_cpp_properties.json rancilio-pid/.vscode/settings.json +.pio/* diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 000000000..16d823015 --- /dev/null +++ b/platformio.ini @@ -0,0 +1,8 @@ +[platformio] +lib_dir = rancilio-pid/libraries/ +src_dir = rancilio-pid/src/ + +[env:nodemcuv2] +platform = espressif8266 +board = nodemcuv2 +framework = arduino diff --git a/rancilio-pid/libraries/ArduinoOTA/ArduinoOTA.png b/rancilio-pid/libraries/ArduinoOTA/ArduinoOTA.png deleted file mode 100644 index 1aa86b1ba..000000000 Binary files a/rancilio-pid/libraries/ArduinoOTA/ArduinoOTA.png and /dev/null differ diff --git a/rancilio-pid/libraries/ArduinoOTA/LICENSE b/rancilio-pid/libraries/ArduinoOTA/LICENSE deleted file mode 100644 index 8000a6faa..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/LICENSE +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 - USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random - Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! diff --git a/rancilio-pid/libraries/ArduinoOTA/README.md b/rancilio-pid/libraries/ArduinoOTA/README.md deleted file mode 100644 index cb3ad68fc..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/README.md +++ /dev/null @@ -1,108 +0,0 @@ - -# Arduino library to upload sketch over network to supported Arduino board - -This library allows you to update sketches on your board over WiFi or Ethernet. - -The library is a modification of the Arduino WiFi101OTA library. - -![network port in IDE](ArduinoOTA.png) - -## Supported micro-controllers - -* ATmega AVR with at least 64 kB of flash (Arduino Mega, [MegaCore](https://github.com/MCUdude/MegaCore) MCUs, MightyCore 1284p and 644) -* Arduino SAMD boards like Zero, M0 or MKR -* nRF5 board supported by [nRF5 core](https://github.com/sandeepmistry/arduino-nRF5). -* boards supported by ESP8266 and ESP32 Arduino boards package - -## Supported networking libraries - -* Ethernet library - shields and modules with Wiznet 5100, 5200 and 5500 chips -* WiFi101 - WiFi101 shield and MKR 1000 -* WiFiNINA - MKR 1010, MKR 4000, ESP32 as SPI network adapter with WiFiNINA firmware -* WiFiLink - esp8266 as network adapter with WiFiLink firmware (SPI or Serial) -* UIPEthernet - shields and modules with ENC28j60 chip -* WiFiSpi - esp8266 as SPI network adapter with WiFiSpi library updated with [this PR](https://github.com/JiriBilek/WiFiSpi/pull/12) -* WiFi - Arduino WiFi Shield (not tested) -* WiFi library of ESP8266 and ESP32 Arduino boards package - -UIPEthernet, WiFiSpi and WiFi library don't support UDP multicast for MDNS, so Arduino IDE will not show the network upload port. WiFiLink doesn't support UDP multicast, but the firmware propagates the MDNS record. - -WiFiEsp library for esp8266 with AT firmware failed tests and there is no easy fix. - -## Installation - -The library is in Library Manager of the Arduino IDE. - -Arduino SAMD boards (Zero, M0, MKR) are supported 'out of the box'. - -For nRF5 boards two lines need to be added to platform.txt file of the nRF5 Arduino package (until the PR that adds them is accepted and included in a release). Only nRF51 was tested until now. For details scroll down. - -For ESP8266 and ESP32 boards, platform.local.txt from extras folder need to be copied into boards package installation folder and the bundled ArduinoOTA library must be deleted. For details scroll down. - -ATmega boards require to flash a modified Optiboot bootloader for flash write operations. Details are below. - -## ATmega support - -The size of networking library and SD library limit the use of ArduinoOTA library to ATmega MCUs with at least 64 kB flash memory. - -*There are other network upload options for here excluded ATmega328p: ([Ariadne bootloader](https://github.com/loathingKernel/ariadne-bootloader) for Wiznet chips, [WiFiLink firmware](https://github.com/jandrassy/arduino-firmware-wifilink) for the esp8266).* - -For upload over InternalStorage, Optiboot bootloader with [`copy_flash_pages` function](https://github.com/Optiboot/optiboot/pull/269) is required. Arduino AVR package doesn't use Optiboot for Arduino Mega. For Arduino Mega you can download [my boards definitions](https://github.com/jandrassy/my_boards) and use it [to burn](https://arduino.stackexchange.com/questions/473/how-do-i-burn-the-bootloader) the modified Optiboot and to upload sketches to your Mega over USB and over network. - -For SDStorage a 'SD bootloader' is required to load the uploaded file from the SD card. There is no good SD bootloader. 2boots works only with not available old types of SD cards and zevero/avr_boot doesn't yet support USB upload of sketch. The SDStorage was tested with zevero/avr_boot. The ATmega_SD example shows how to use this ArduinoOTA library with SD bootloader. - -To use remote upload from IDE with SDStorage or InternalStorage, copy platform.local.txt from extras/avr folder, next to platform.txt in the boards package used (Arduino-avr or MCUdude packages). Packages are located in ~/.arduino15/packages/ on Linux and %userprofile%\AppData\Local\Arduino15\packages\ on Windows (AppData is a hidden folder). The platform.local.txt contains a line to create a .bin file and a line to override tools.avrdude.upload.network_pattern, because in platform.txt it is defined for Yun. - -The IDE upload tool is installed with Arduino AVR core package. At least version 1.2 of the arduinoOTA tool is required. For upload from command line without IDE see the command template in extras/avr/platform.local.txt. - -## ESP8266 and ESP32 support - -The ArduinoOTA library bundled with ESP8266 and ESP32 Arduino packages works only with native WiFi libraries. This library allows to upload a sketch to esp8266 or esp32 over Ethernet with Ethernet or UIPEthernet library. Upload over the native WiFi library works too. - -To use this library instead of the bundled library, the bundled library must be removed from the boards package library folder. To override the configuration of OTA upload in platform.txt, copy the platform.local.txt file from extras folder of this library next to platform.txt file in boards package installation folder. Packages are located in ~/.arduino15/packages/ on Linux and %userprofile%\AppData\Local\Arduino15\packages\ on Windows (AppData is a hidden folder). - -The esp8266 boards package has bundled Ethernet library. It is an old version of the Arduino Ethernet library which works only with W5100 chips. It is better to remove it from boards package and install the Ethernet library from Library Manager in IDE. - -This library supports SPIFFS upload to esp8266 and esp32, but the IDE plugins have the network upload tool hardcoded to espota. It can't be changed in configuration. To upload SPIFFS, call the plugin in Tools menu and after it fails to upload over network, go to location of the created bin file and upload the file with arduinoOTA tool from command line. The location of the file is printed in the IDE console window. Upload command example (linux): -``` -~/arduino-1.8.8/hardware/tools/avr/bin/arduinoOTA -address 192.168.1.107 -port 65280 -username arduino -password password -sketch OTEthernet.spiffs.bin -upload /data -b -``` -(the same command can be used to upload the sketch binary, only use `-upload /sketch`) - -## nRF5 support - -Note: Only nRF51 was tested for now - -If SoftDevice is not used, the sketch is written from address 0. For write to address 0 the sketch must be compiled with -fno-delete-null-pointer-checks. - -For SD card update use [SDUnRF5 library](https://github.com/jandrassy/SDUnRF5). - -To use remote upload from IDE, add lines from [this PR](https://github.com/sandeepmistry/arduino-nRF5/pull/327/commits/4b70ae7207124bd92afa14e562e4f0c4d931220d) to sandeepmistry/hardware/nRF5/0.6.0/platform.txt at the end of section "OpenOCD sketch upload": - -If you use SoftDevice, stop BLE before applying update. Use `ArduinoOTA.beforeApply` to register a callback function. For example in setup `ArduinoOTA.beforeApply(shutdown);` and add the function to to sketch: - -``` -void shutdown() { - blePeripheral.end(); -} -``` -## Boards tested - -* SAMD - - Arduino MKR Zero - - Crowduino M0 SD -* nRF5 - - Seeed Arch Link -* ATmega - - Arduino Mega - - Badio 1284p -* esp8266 - - Wemos D1 mini -* esp32 - - ESP32 Dev Module - -## Contribution - -Please report tested boards. - -Other ARM based MCUs could be added with code similar to SAMD and nRF5. diff --git a/rancilio-pid/libraries/ArduinoOTA/examples/ATmega_SD/ATmega_SD.ino b/rancilio-pid/libraries/ArduinoOTA/examples/ATmega_SD/ATmega_SD.ino deleted file mode 100644 index 4d0acda8f..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/examples/ATmega_SD/ATmega_SD.ino +++ /dev/null @@ -1,64 +0,0 @@ -/* - - This example polls for sketch updates over Ethernet, sketches - can be updated by selecting a network port from within - the Arduino IDE: Tools -> Port -> Network Ports ... - - Circuit: - * W5100, W5200 or W5500 Ethernet shield with SD card attached - - created 13 July 2010 - by dlf (Metodo2 srl) - modified 31 May 2012 - by Tom Igoe - modified 16 January 2017 - by Sandeep Mistry - ArduinoOTA version Dec 2018 - by Juraj Andrassy - */ - -#include -#include -#include -#include - -// Enter a MAC address for your controller below. -// Newer Ethernet shields have a MAC address printed on a sticker on the shield -byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; - -void setup() { - //Initialize serial: - Serial.begin(9600); - while (!Serial); - - // setup SD card - Serial.print("Initializing SD card..."); - if (!SD.begin(SDCARD_SS_PIN)) { - Serial.println("initialization failed!"); - // don't continue: - while (true); - } - Serial.println("initialization done."); - - // start the Ethernet connection: - Serial.println("Initialize Ethernet with DHCP:"); - if (Ethernet.begin(mac) == 0) { - Serial.println("Failed to configure Ethernet using DHCP"); - } else { - Serial.print(" DHCP assigned IP "); - Serial.println(Ethernet.localIP()); - } - - // start the OTEthernet library with SD based storage - SDStorage.setUpdateFileName("FIRMWARE.BIN"); // for https://github.com/zevero/avr_boot/ - SDStorage.clear(); // AVR SD bootloaders don't delete the update file - ArduinoOTA.begin(Ethernet.localIP(), "Arduino", "password", SDStorage); - -} - -void loop() { - // check for updates - ArduinoOTA.poll(); - - // add your normal loop code below ... -} diff --git a/rancilio-pid/libraries/ArduinoOTA/examples/OTEthernet/OTEthernet.ino b/rancilio-pid/libraries/ArduinoOTA/examples/OTEthernet/OTEthernet.ino deleted file mode 100644 index 88c083d3f..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/examples/OTEthernet/OTEthernet.ino +++ /dev/null @@ -1,53 +0,0 @@ -/* - - This example polls for sketch updates over Ethernet, sketches - can be updated by selecting a network port from within - the Arduino IDE: Tools -> Port -> Network Ports ... - - Circuit: - * W5100, W5200 or W5500 Ethernet shield attached - - created 13 July 2010 - by dlf (Metodo2 srl) - modified 31 May 2012 - by Tom Igoe - modified 16 January 2017 - by Sandeep Mistry - Ethernet version August 2018 - by Juraj Andrassy - */ - -#include -#include -#include - -//#define Serial SerialUSB - -// Enter a MAC address for your controller below. -// Newer Ethernet shields have a MAC address printed on a sticker on the shield -byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; - -void setup() { - //Initialize serial: - Serial.begin(9600); - while (!Serial); - - // start the Ethernet connection: - Serial.println("Initialize Ethernet with DHCP:"); - if (Ethernet.begin(mac) == 0) { - Serial.println("Failed to configure Ethernet using DHCP"); - } else { - Serial.print(" DHCP assigned IP "); - Serial.println(Ethernet.localIP()); - } - - // start the OTEthernet library with internal (flash) based storage - ArduinoOTA.begin(Ethernet.localIP(), "Arduino", "password", InternalStorage); -} - -void loop() { - // check for updates - ArduinoOTA.poll(); - - // add your normal loop code below ... -} diff --git a/rancilio-pid/libraries/ArduinoOTA/examples/OTEthernet_SD/OTEthernet_SD.ino b/rancilio-pid/libraries/ArduinoOTA/examples/OTEthernet_SD/OTEthernet_SD.ino deleted file mode 100644 index 64bc3eacd..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/examples/OTEthernet_SD/OTEthernet_SD.ino +++ /dev/null @@ -1,65 +0,0 @@ -/* - - This example polls for sketch updates over Ethernet, sketches - can be updated by selecting a network port from within - the Arduino IDE: Tools -> Port -> Network Ports ... - - Circuit: - * W5100, W5200 or W5500 Ethernet shield with SD card attached - - created 13 July 2010 - by dlf (Metodo2 srl) - modified 31 May 2012 - by Tom Igoe - modified 16 January 2017 - by Sandeep Mistry - Ethernet version August 2018 - by Juraj Andrassy - */ - -#include -#include -#include -#include -#include - -//#define Serial SerialUSB - -// Enter a MAC address for your controller below. -// Newer Ethernet shields have a MAC address printed on a sticker on the shield -byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; - -void setup() { - //Initialize serial: - Serial.begin(9600); - while (!Serial); - - // setup SD card - Serial.print("Initializing SD card..."); - if (!SD.begin(SDCARD_SS_PIN)) { - Serial.println("initialization failed!"); - // don't continue: - while (true); - } - Serial.println("initialization done."); - - // start the Ethernet connection: - Serial.println("Initialize Ethernet with DHCP:"); - if (Ethernet.begin(mac) == 0) { - Serial.println("Failed to configure Ethernet using DHCP"); - } else { - Serial.print(" DHCP assigned IP "); - Serial.println(Ethernet.localIP()); - } - - // start the OTEthernet library with SD based storage - ArduinoOTA.begin(Ethernet.localIP(), "Arduino", "password", SDStorage); - -} - -void loop() { - // check for updates - ArduinoOTA.poll(); - - // add your normal loop code below ... -} diff --git a/rancilio-pid/libraries/ArduinoOTA/examples/WiFi101_OTA/WiFi101_OTA.ino b/rancilio-pid/libraries/ArduinoOTA/examples/WiFi101_OTA/WiFi101_OTA.ino deleted file mode 100644 index 0a18fa97f..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/examples/WiFi101_OTA/WiFi101_OTA.ino +++ /dev/null @@ -1,81 +0,0 @@ -/* - - This example connects to an WPA encrypted WiFi network. - Then it prints the MAC address of the Wifi shield, - the IP address obtained, and other network details. - It then polls for sketch updates over WiFi, sketches - can be updated by selecting a network port from within - the Arduino IDE: Tools -> Port -> Network Ports ... - - Circuit: - * WiFi shield attached - - created 13 July 2010 - by dlf (Metodo2 srl) - modified 31 May 2012 - by Tom Igoe - modified 16 January 2017 - by Sandeep Mistry - */ - -#include -#include -#include - -#include "arduino_secrets.h" -///////please enter your sensitive data in the Secret tab/arduino_secrets.h -/////// Wifi Settings /////// -char ssid[] = SECRET_SSID; // your network SSID (name) -char pass[] = SECRET_PASS; // your network password - -int status = WL_IDLE_STATUS; - -void setup() { - //Initialize serial: - Serial.begin(9600); - - // check for the presence of the shield: - if (WiFi.status() == WL_NO_SHIELD) { - Serial.println("WiFi shield not present"); - // don't continue: - while (true); - } - - // attempt to connect to Wifi network: - while ( status != WL_CONNECTED) { - Serial.print("Attempting to connect to SSID: "); - Serial.println(ssid); - // Connect to WPA/WPA2 network. Change this line if using open or WEP network: - status = WiFi.begin(ssid, pass); - } - - // start the WiFi OTA library with internal (flash) based storage - ArduinoOTA.begin(WiFi.localIP(), "Arduino", "password", InternalStorage); - - // you're connected now, so print out the status: - printWifiStatus(); -} - -void loop() { - // check for WiFi OTA updates - ArduinoOTA.poll(); - - // add your normal loop code below ... -} - -void printWifiStatus() { - // print the SSID of the network you're attached to: - Serial.print("SSID: "); - Serial.println(WiFi.SSID()); - - // print your WiFi shield's IP address: - IPAddress ip = WiFi.localIP(); - Serial.print("IP Address: "); - Serial.println(ip); - - // print the received signal strength: - long rssi = WiFi.RSSI(); - Serial.print("signal strength (RSSI):"); - Serial.print(rssi); - Serial.println(" dBm"); -} diff --git a/rancilio-pid/libraries/ArduinoOTA/examples/WiFi101_OTA/arduino_secrets.h b/rancilio-pid/libraries/ArduinoOTA/examples/WiFi101_OTA/arduino_secrets.h deleted file mode 100644 index a8ff904d6..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/examples/WiFi101_OTA/arduino_secrets.h +++ /dev/null @@ -1,3 +0,0 @@ -#define SECRET_SSID "" -#define SECRET_PASS "" - diff --git a/rancilio-pid/libraries/ArduinoOTA/examples/WiFi101_SD_OTA/WiFi101_SD_OTA.ino b/rancilio-pid/libraries/ArduinoOTA/examples/WiFi101_SD_OTA/WiFi101_SD_OTA.ino deleted file mode 100644 index a7a3e331a..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/examples/WiFi101_SD_OTA/WiFi101_SD_OTA.ino +++ /dev/null @@ -1,93 +0,0 @@ -/* - - This example connects to an WPA encrypted WiFi network. - Then it prints the MAC address of the Wifi shield, - the IP address obtained, and other network details. - It then polls for sketch updates over WiFi, sketches - can be updated by selecting a network port from within - the Arduino IDE: Tools -> Port -> Network Ports ... - - Circuit: - * WiFi shield attached - * SD shield attached - - created 13 July 2010 - by dlf (Metodo2 srl) - modified 31 May 2012 - by Tom Igoe - modified 16 January 2017 - by Sandeep Mistry - */ - -#include -#include -#include -#include -#include - -#include "arduino_secrets.h" -///////please enter your sensitive data in the Secret tab/arduino_secrets.h -/////// Wifi Settings /////// -char ssid[] = SECRET_SSID; // your network SSID (name) -char pass[] = SECRET_PASS; // your network password - -int status = WL_IDLE_STATUS; - -void setup() { - //Initialize serial: - Serial.begin(9600); - - // setup SD card - Serial.print("Initializing SD card..."); - if (!SD.begin(SDCARD_SS_PIN)) { - Serial.println("initialization failed!"); - // don't continue: - while (true); - } - Serial.println("initialization done."); - - // check for the presence of the shield: - if (WiFi.status() == WL_NO_SHIELD) { - Serial.println("WiFi shield not present"); - // don't continue: - while (true); - } - - // attempt to connect to Wifi network: - while ( status != WL_CONNECTED) { - Serial.print("Attempting to connect to SSID: "); - Serial.println(ssid); - // Connect to WPA/WPA2 network. Change this line if using open or WEP network: - status = WiFi.begin(ssid, pass); - } - - // start the WiFi OTA library with SD based storage - ArduinoOTA.begin(WiFi.localIP(), "Arduino", "password", SDStorage); - - // you're connected now, so print out the status: - printWifiStatus(); -} - -void loop() { - // check for WiFi OTA updates - ArduinoOTA.poll(); - - // add your normal loop code below ... -} - -void printWifiStatus() { - // print the SSID of the network you're attached to: - Serial.print("SSID: "); - Serial.println(WiFi.SSID()); - - // print your WiFi shield's IP address: - IPAddress ip = WiFi.localIP(); - Serial.print("IP Address: "); - Serial.println(ip); - - // print the received signal strength: - long rssi = WiFi.RSSI(); - Serial.print("signal strength (RSSI):"); - Serial.print(rssi); - Serial.println(" dBm"); -} diff --git a/rancilio-pid/libraries/ArduinoOTA/examples/WiFi101_SD_OTA/arduino_secrets.h b/rancilio-pid/libraries/ArduinoOTA/examples/WiFi101_SD_OTA/arduino_secrets.h deleted file mode 100644 index a8ff904d6..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/examples/WiFi101_SD_OTA/arduino_secrets.h +++ /dev/null @@ -1,3 +0,0 @@ -#define SECRET_SSID "" -#define SECRET_PASS "" - diff --git a/rancilio-pid/libraries/ArduinoOTA/extras/avr/platform.local.txt b/rancilio-pid/libraries/ArduinoOTA/extras/avr/platform.local.txt deleted file mode 100644 index 1794fefda..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/extras/avr/platform.local.txt +++ /dev/null @@ -1,9 +0,0 @@ - -# This configuration file supports the general ArduinoOTA library https://github.com/jandrassy/ArduinoOTA - -## Create output (bin file) -recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" -O binary {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" - -tools.avrdude.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b - - diff --git a/rancilio-pid/libraries/ArduinoOTA/extras/esp32/platform.local.txt b/rancilio-pid/libraries/ArduinoOTA/extras/esp32/platform.local.txt deleted file mode 100644 index 5e0c7234d..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/extras/esp32/platform.local.txt +++ /dev/null @@ -1,6 +0,0 @@ - -# This configuration file supports the general ArduinoOTA library https://github.com/jandrassy/ArduinoOTA - -tools.esptool_py.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA -tools.esptool_py.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b - diff --git a/rancilio-pid/libraries/ArduinoOTA/extras/esp8266/platform.local.txt b/rancilio-pid/libraries/ArduinoOTA/extras/esp8266/platform.local.txt deleted file mode 100644 index a39c67e04..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/extras/esp8266/platform.local.txt +++ /dev/null @@ -1,6 +0,0 @@ - -# This configuration file supports the general ArduinoOTA library https://github.com/jandrassy/ArduinoOTA - -tools.esptool.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA -tools.esptool.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b - diff --git a/rancilio-pid/libraries/ArduinoOTA/keywords.txt b/rancilio-pid/libraries/ArduinoOTA/keywords.txt deleted file mode 100644 index bc838be15..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/keywords.txt +++ /dev/null @@ -1,24 +0,0 @@ -####################################### -# Syntax Coloring Map For WiFi101OTA -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -ArduinoOTA KEYWORD1 - -InternalStorage KEYWORD1 -SDStorage KEYWORD1 -SerialFlashStorage KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### - -begin KEYWORD2 -poll KEYWORD2 - -####################################### -# Constants (LITERAL1) -####################################### diff --git a/rancilio-pid/libraries/ArduinoOTA/library.properties b/rancilio-pid/libraries/ArduinoOTA/library.properties deleted file mode 100644 index 3ffe2187a..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/library.properties +++ /dev/null @@ -1,10 +0,0 @@ -name=ArduinoOTA -version=1.0.1 -author=Arduino,Juraj Andrassy -maintainer=Juraj Andrassy -sentence=Upload sketch over network to Arduino board with WiFi or Ethernet libraries -paragraph=Based on WiFi101OTA library. Uploads over Ethernet, UIPEthernet, WiFi101, WiFiNina, WiFiLink, WiFi to SAMD, nRF5, esp8266, esp32 and to ATmega with more then 64 kB flash memory. -category=Other -url=https://github.com/jandrassy/ArduinoOTA -architectures=* -includes=ArduinoOTA.h diff --git a/rancilio-pid/libraries/ArduinoOTA/src/ArduinoOTA.h b/rancilio-pid/libraries/ArduinoOTA/src/ArduinoOTA.h deleted file mode 100644 index dbb4f41ba..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/src/ArduinoOTA.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - Copyright (c) 2018 Juraj Andrassy - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef _ARDUINOOTA_H_ -#define _ARDUINOOTA_H_ - -#include "WiFiOTA.h" -#ifdef __AVR__ -#if FLASHEND >= 0xFFFF -#include "InternalStorageAVR.h" -#endif -#elif defined(ESP8266) || defined(ESP32) -#include "InternalStorageESP.h" -#else -#include "InternalStorage.h" -#endif -#ifdef __SD_H__ -#include "SDStorage.h" -SDStorageClass SDStorage; -#endif -#ifdef SerialFlash_h_ -#include "SerialFlashStorage.h" -SerialFlashStorageClass SerialFlashStorage; -#endif - - -template -class ArduinoOTAClass : public WiFiOTAClass { - -private: - NetServer server; - -public: - ArduinoOTAClass() : server(65280) {}; - - void begin(IPAddress localIP, const char* name, const char* password, OTAStorage& storage) { - WiFiOTAClass::begin(localIP, name, password, storage); - server.begin(); - } - - void poll() { - NetClient client = server.available(); - pollServer(client); - } - - void handle() { // alias - poll(); - } - -}; - -template -class ArduinoOTAMdnsClass : public ArduinoOTAClass { - -private: - NetUDP mdnsSocket; - -public: - ArduinoOTAMdnsClass() {}; - - void begin(IPAddress localIP, const char* name, const char* password, OTAStorage& storage) { - ArduinoOTAClass::begin(localIP, name, password, storage); -#if defined(ESP8266) && !(defined(ethernet_h_) || defined(ethernet_h) || defined(UIPETHERNET_H)) - mdnsSocket.beginMulticast(localIP, IPAddress(224, 0, 0, 251), 5353); -#else - mdnsSocket.beginMulticast(IPAddress(224, 0, 0, 251), 5353); -#endif - } - - void poll() { - ArduinoOTAClass::poll(); - WiFiOTAClass::pollMdns(mdnsSocket); - } - -}; - -#if defined(ethernet_h_) || defined(ethernet_h) // Ethernet library -ArduinoOTAMdnsClass ArduinoOTA; - -#elif defined(UIPETHERNET_H) // no UDP multicast implementation yet -ArduinoOTAClass ArduinoOTA; - -#elif defined(WiFiNINA_h) || defined(WIFI_H) || defined(ESP8266) || defined(ESP32) // NINA, WiFi101 and Espressif WiFi -#include -ArduinoOTAMdnsClass ArduinoOTA; - -#elif defined(WiFi_h) // WiFi and WiFiLink lib (no UDP multicast), for WiFiLink firmware handles mdns -ArduinoOTAClass ArduinoOTA; - -#elif defined(_WIFISPI_H_INCLUDED) // no UDP multicast implementation -ArduinoOTAClass ArduinoOTA; - -#else -#error "Network library not included or not supported" -#endif - -#endif diff --git a/rancilio-pid/libraries/ArduinoOTA/src/InternalStorage.cpp b/rancilio-pid/libraries/ArduinoOTA/src/InternalStorage.cpp deleted file mode 100644 index e71a09ab5..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/src/InternalStorage.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - Copyright (c) 2017 Arduino LLC. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - WiFi101OTA version Feb 2017 - by Sandeep Mistry (Arduino) - modified for ArduinoOTA Dec 2018 - by Juraj Andrassy -*/ - -#if !defined(__AVR__) && !defined(ESP8266) && !defined(ESP32) - -#include - -#include "InternalStorage.h" - -InternalStorageClass::InternalStorageClass() : - MAX_PARTIONED_SKETCH_SIZE((MAX_FLASH - SKETCH_START_ADDRESS) / 2), - STORAGE_START_ADDRESS(SKETCH_START_ADDRESS + MAX_PARTIONED_SKETCH_SIZE) -{ - _writeIndex = 0; - _writeAddress = nullptr; -} - -extern "C" { - // these functions must be in RAM (.data) and NOT inlined - // as they erase and copy the sketch data in flash - - __attribute__ ((long_call, noinline, section (".data#"))) // - void waitForReady() { -#if defined(ARDUINO_ARCH_SAMD) - while (!NVMCTRL->INTFLAG.bit.READY); -#elif defined(ARDUINO_ARCH_NRF5) - while (NRF_NVMC->READY == NVMC_READY_READY_Busy); -#endif - } - - __attribute__ ((long_call, noinline, section (".data#"))) - static void eraseFlash(int address, int length, int pageSize) - { -#if defined(ARDUINO_ARCH_SAMD) - int rowSize = pageSize * 4; - 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) - // Enable erasing flash - NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Een << NVMC_CONFIG_WEN_Pos; - - // Erase page(s) - int end_address = address + length; - while (address < end_address) { - waitForReady(); - // Erase one 1k/4k page - NRF_NVMC->ERASEPAGE = address; - address = address + pageSize; - } - // Disable erasing, enable write - waitForReady(); - NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos; - waitForReady(); -#endif - } - - __attribute__ ((long_call, noinline, section (".data#"))) - static void copyFlashAndReset(int dest, int src, int length, int pageSize) - { - uint32_t* d = (uint32_t*)dest; - uint32_t* s = (uint32_t*)src; - - eraseFlash(dest, length, pageSize); - - for (int i = 0; i < length; i += 4) { - *d++ = *s++; - - waitForReady(); - } - - NVIC_SystemReset(); - } -} - -int InternalStorageClass::open(int length) -{ - (void)length; - _writeIndex = 0; - _writeAddress = (uint32_t*)STORAGE_START_ADDRESS; - -#ifdef ARDUINO_ARCH_SAMD - // enable auto page writes - NVMCTRL->CTRLB.bit.MANW = 0; -#endif - - eraseFlash(STORAGE_START_ADDRESS, MAX_PARTIONED_SKETCH_SIZE, PAGE_SIZE); - - return 1; -} - -size_t InternalStorageClass::write(uint8_t b) -{ - _addressData.u8[_writeIndex] = b; - _writeIndex++; - - if (_writeIndex == 4) { - _writeIndex = 0; - - *_writeAddress = _addressData.u32; - - _writeAddress++; - - waitForReady(); - } - - return 1; -} - -void InternalStorageClass::close() -{ - while ((int)_writeAddress % PAGE_SIZE) { - write(0xff); - } -} - -void InternalStorageClass::clear() -{ -} - -void InternalStorageClass::apply() -{ - // disable interrupts, as vector table will be erase during flash sequence - noInterrupts(); - - copyFlashAndReset(SKETCH_START_ADDRESS, STORAGE_START_ADDRESS, MAX_PARTIONED_SKETCH_SIZE, PAGE_SIZE); -} - -long InternalStorageClass::maxSize() -{ - return MAX_PARTIONED_SKETCH_SIZE; -} - -InternalStorageClass InternalStorage; - -#endif diff --git a/rancilio-pid/libraries/ArduinoOTA/src/InternalStorage.h b/rancilio-pid/libraries/ArduinoOTA/src/InternalStorage.h deleted file mode 100644 index 1e055de62..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/src/InternalStorage.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright (c) 2017 Arduino LLC. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - WiFi101OTA version Feb 2017 - by Sandeep Mistry (Arduino) - modified for ArduinoOTA Dec 2018 - by Juraj Andrassy -*/ - -#ifndef _INTERNAL_STORAGE_H_INCLUDED -#define _INTERNAL_STORAGE_H_INCLUDED - -#include "OTAStorage.h" - -class InternalStorageClass : public OTAStorage { -public: - - InternalStorageClass(); - - virtual int open(int length); - virtual size_t write(uint8_t); - virtual void close(); - virtual void clear(); - virtual void apply(); - virtual long maxSize(); - -private: - const uint32_t MAX_PARTIONED_SKETCH_SIZE, STORAGE_START_ADDRESS; - - union { - uint32_t u32; - uint8_t u8[4]; - } _addressData; - - int _writeIndex; - uint32_t* _writeAddress; -}; - -extern InternalStorageClass InternalStorage; - -#endif diff --git a/rancilio-pid/libraries/ArduinoOTA/src/InternalStorageAVR.cpp b/rancilio-pid/libraries/ArduinoOTA/src/InternalStorageAVR.cpp deleted file mode 100644 index 628c0eab4..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/src/InternalStorageAVR.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright (c) 2018 Juraj Andrassy - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -#if defined(__AVR__) && FLASHEND >= 0xFFFF - -#include "InternalStorageAVR.h" -#include "utility/optiboot.h" - -InternalStorageAVRClass::InternalStorageAVRClass() { - maxSketchSize = (MAX_FLASH - bootloaderSize) / 2; - maxSketchSize = (maxSketchSize / SPM_PAGESIZE) * SPM_PAGESIZE; // align to page - pageAddress = maxSketchSize; - pageIndex = 0; -} - -int InternalStorageAVRClass::open(int length) { - (void)length; - pageAddress = maxSketchSize; - pageIndex = 0; - return 1; -} - -size_t InternalStorageAVRClass::write(uint8_t b) { - if (pageIndex == 0) { - optiboot_page_erase(pageAddress); - } - dataWord.u8[pageIndex % 2] = b; - if (pageIndex % 2) { - optiboot_page_fill(pageAddress + pageIndex, dataWord.u16); - } - pageIndex++; - if (pageIndex == SPM_PAGESIZE) { - optiboot_page_write(pageAddress); - pageIndex = 0; - pageAddress += SPM_PAGESIZE; - } - return 1; -} - -void InternalStorageAVRClass::close() { - if (pageIndex) { - optiboot_page_write(pageAddress); - } - pageIndex = 0; -} - -void InternalStorageAVRClass::clear() { -} - -void InternalStorageAVRClass::apply() { - copy_flash_pages_cli(SKETCH_START_ADDRESS, maxSketchSize, (pageAddress - maxSketchSize) / SPM_PAGESIZE + 1, true); -} - -long InternalStorageAVRClass::maxSize() { - return maxSketchSize; -} - -InternalStorageAVRClass InternalStorage; - -#endif diff --git a/rancilio-pid/libraries/ArduinoOTA/src/InternalStorageAVR.h b/rancilio-pid/libraries/ArduinoOTA/src/InternalStorageAVR.h deleted file mode 100644 index 6cea26a36..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/src/InternalStorageAVR.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright (c) 2018 Juraj Andrassy - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - */ - -#ifndef _INTERNAL_STORAGE_AVR_H_INCLUDED -#define _INTERNAL_STORAGE_AVR_H_INCLUDED - -#include "OTAStorage.h" - -class InternalStorageAVRClass : public OTAStorage { -public: - - InternalStorageAVRClass(); - - virtual int open(int length); - virtual size_t write(uint8_t); - virtual void close(); - virtual void clear(); - virtual void apply(); - virtual long maxSize(); - -private: - uint32_t maxSketchSize; - uint32_t pageAddress; - uint16_t pageIndex; - - union { - uint16_t u16; - uint8_t u8[2]; - } dataWord; -}; - -extern InternalStorageAVRClass InternalStorage; - -#endif diff --git a/rancilio-pid/libraries/ArduinoOTA/src/InternalStorageESP.cpp b/rancilio-pid/libraries/ArduinoOTA/src/InternalStorageESP.cpp deleted file mode 100644 index bdb4d047a..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/src/InternalStorageESP.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - Copyright (c) 2019 Juraj Andrassy. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#if defined(ESP8266) || defined(ESP32) - -#include - -#ifdef ESP32 -#include -#endif - -#include "InternalStorageESP.h" - -InternalStorageESPClass::InternalStorageESPClass() -{ -} - -int InternalStorageESPClass::open(int length, uint8_t command) -{ - return Update.begin(length, command == 0 ? U_FLASH : U_SPIFFS); -} - -size_t InternalStorageESPClass::write(uint8_t b) -{ - return Update.write(&b, 1); -} - -void InternalStorageESPClass::close() -{ - Update.end(false); -} - -void InternalStorageESPClass::clear() -{ -} - -void InternalStorageESPClass::apply() -{ - ESP.restart(); -} - -long InternalStorageESPClass::maxSize() -{ - return ESP.getFlashChipSize() / 2; // Update.begin() in open() does the exact check -} - -InternalStorageESPClass InternalStorage; - -#endif diff --git a/rancilio-pid/libraries/ArduinoOTA/src/InternalStorageESP.h b/rancilio-pid/libraries/ArduinoOTA/src/InternalStorageESP.h deleted file mode 100644 index 2c63cc0a0..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/src/InternalStorageESP.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - Copyright (c) 2019 Juraj Andrassy. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef _INTERNAL_STORAGE_ESP_H_INCLUDED -#define _INTERNAL_STORAGE_ESP_H_INCLUDED - -#include "OTAStorage.h" - -class InternalStorageESPClass : public OTAStorage { -public: - - InternalStorageESPClass(); - - virtual int open(int length) { - return open(length, 0); - } - virtual int open(int length, uint8_t command); - virtual size_t write(uint8_t); - virtual void close(); - virtual void clear(); - virtual void apply(); - virtual long maxSize(); - -private: -}; - -extern InternalStorageESPClass InternalStorage; - -#endif diff --git a/rancilio-pid/libraries/ArduinoOTA/src/OTAStorage.cpp b/rancilio-pid/libraries/ArduinoOTA/src/OTAStorage.cpp deleted file mode 100644 index e685c68b1..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/src/OTAStorage.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "OTAStorage.h" - -#if defined(ARDUINO_ARCH_SAMD) -static const uint32_t pageSizes[] = { 8, 16, 32, 64, 128, 256, 512, 1024 }; -extern "C" { -char * __text_start__(); // 0x2000, 0x0 without bootloader and 0x4000 for M0 original bootloader -} -#elif defined(ARDUINO_ARCH_NRF5) -extern "C" { -char * __isr_vector(); -} -#elif defined(__AVR__) -#include -#include -#define MIN_BOOTSZ (4 * SPM_PAGESIZE) -#endif - -OTAStorage::OTAStorage() : -#if defined(ARDUINO_ARCH_SAMD) - SKETCH_START_ADDRESS((uint32_t) __text_start__), - PAGE_SIZE(pageSizes[NVMCTRL->PARAM.bit.PSZ]), - MAX_FLASH(PAGE_SIZE * NVMCTRL->PARAM.bit.NVMP) -#elif defined(ARDUINO_ARCH_NRF5) - SKETCH_START_ADDRESS((uint32_t) __isr_vector), - PAGE_SIZE((size_t) NRF_FICR->CODEPAGESIZE), - MAX_FLASH(PAGE_SIZE * (uint32_t) NRF_FICR->CODESIZE) -#elif defined(__AVR__) - SKETCH_START_ADDRESS(0), - PAGE_SIZE(SPM_PAGESIZE), - MAX_FLASH((uint32_t) FLASHEND + 1) -#elif defined(ESP8266) || defined(ESP32) - SKETCH_START_ADDRESS(0), // not used - PAGE_SIZE(0), // not used - MAX_FLASH(0) // not used -#endif -{ - bootloaderSize = 0; -#ifdef __AVR__ - cli(); - uint8_t highBits = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS); - sei(); - if (!(highBits & bit(FUSE_BOOTRST))) { - byte v = (highBits & ((~FUSE_BOOTSZ1 ) + (~FUSE_BOOTSZ0 ))); - bootloaderSize = MIN_BOOTSZ << ((v >> 1) ^ 3); - } -#endif -} - -void ExternalOTAStorage::apply() { -#ifdef __AVR__ - wdt_enable(WDTO_15MS); - while (true); -#elif defined(ESP8266) || defined(ESP32) - ESP.restart(); -#else - NVIC_SystemReset(); -#endif -} diff --git a/rancilio-pid/libraries/ArduinoOTA/src/OTAStorage.h b/rancilio-pid/libraries/ArduinoOTA/src/OTAStorage.h deleted file mode 100644 index ca65394a9..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/src/OTAStorage.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - Copyright (c) 2017 Arduino LLC. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - WiFi101OTA version Feb 2017 - by Sandeep Mistry (Arduino) - modified for ArduinoOTA Dec 2018, Apr 2019 - by Juraj Andrassy -*/ - -#ifndef _OTA_STORAGE_H_INCLUDED -#define _OTA_STORAGE_H_INCLUDED - -#include - -class OTAStorage { -public: - - OTAStorage(); - - virtual int open(int length) = 0; - virtual int open(int length, uint8_t command) { - (void) command; - return open(length); - } - virtual size_t write(uint8_t) = 0; - virtual void close() = 0; - virtual void clear() = 0; - virtual void apply() = 0; - - virtual long maxSize() { - return (MAX_FLASH - SKETCH_START_ADDRESS - bootloaderSize); - } - -protected: - const uint32_t SKETCH_START_ADDRESS; - const uint32_t PAGE_SIZE; - const uint32_t MAX_FLASH; - uint32_t bootloaderSize; - -}; - -class ExternalOTAStorage : public OTAStorage { - -protected: - const char* updateFileName = "UPDATE.BIN"; - -public: - void setUpdateFileName(const char* _updateFileName) { - updateFileName = _updateFileName; - } - - virtual void apply(); -}; - -#endif diff --git a/rancilio-pid/libraries/ArduinoOTA/src/SDStorage.h b/rancilio-pid/libraries/ArduinoOTA/src/SDStorage.h deleted file mode 100644 index 5b51b45fb..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/src/SDStorage.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright (c) 2017 Arduino LLC. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef _SD_STORAGE_H_INCLUDED -#define _SD_STORAGE_H_INCLUDED - -#include - -#include "OTAStorage.h" - -#ifndef SDCARD_SS_PIN -#define SDCARD_SS_PIN 4 -#endif - -class SDStorageClass : public ExternalOTAStorage { -public: - - virtual int open(int length) { - _file = SD.open(updateFileName, O_CREAT | O_WRITE); - if (!_file) - return 0; - return 1; - } - - virtual size_t write(uint8_t b) { - return _file.write(b); - } - virtual void close() { - _file.close(); - } - - virtual void clear() { - SD.remove(updateFileName); - } - -private: - File _file; -}; - -#endif diff --git a/rancilio-pid/libraries/ArduinoOTA/src/SerialFlashStorage.h b/rancilio-pid/libraries/ArduinoOTA/src/SerialFlashStorage.h deleted file mode 100644 index 10eec5f84..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/src/SerialFlashStorage.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - Copyright (c) 2017 Arduino LLC. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef _SERIALFLASH_STORAGE_H_INCLUDED -#define _SERIALFLASH_STORAGE_H_INCLUDED - -#include - -#include "OTAStorage.h" - -#define SERIAL_FLASH_BUFFER_SIZE 64 -#define SERIAL_FLASH_CS 5 - -class SerialFlashStorageClass : public ExternalOTAStorage { -public: - - virtual int open(int length) { - if (!SerialFlash.begin(SERIAL_FLASH_CS)) { - return 0; - } - - while (!SerialFlash.ready()) {} - - if (SerialFlash.exists(updateFileName)) { - SerialFlash.remove(updateFileName); - } - - if (SerialFlash.create(updateFileName, length)) { - _file = SerialFlash.open(updateFileName); - } - - if (!_file) { - return 0; - } - - return 1; - } - - virtual size_t write(uint8_t b) { - while (!SerialFlash.ready()) {} - int ret = _file.write(&b, 1); - return ret; - } - - virtual void close() { - _file.close(); - } - - virtual void clear() { - SerialFlash.remove(updateFileName); - } - -private: - SerialFlashFile _file; -}; - -#endif diff --git a/rancilio-pid/libraries/ArduinoOTA/src/WiFiOTA.cpp b/rancilio-pid/libraries/ArduinoOTA/src/WiFiOTA.cpp deleted file mode 100644 index bf102f069..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/src/WiFiOTA.cpp +++ /dev/null @@ -1,358 +0,0 @@ -/* - Copyright (c) 2017 Arduino LLC. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - WiFi101OTA version Feb 2017 - by Sandeep Mistry (Arduino) - modified for ArduinoOTA Dec 2018, Apr 2019 - by Juraj Andrassy -*/ - -#include - -#include "WiFiOTA.h" - -#define BOARD "arduino" -#define BOARD_LENGTH (sizeof(BOARD) - 1) - -static String base64Encode(const String& in) -{ - static const char* CODES = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - - int b; - String out; - out.reserve((in.length()) * 4 / 3); - - for (unsigned int i = 0; i < in.length(); i += 3) { - b = (in.charAt(i) & 0xFC) >> 2; - out += CODES[b]; - - b = (in.charAt(i) & 0x03) << 4; - if (i + 1 < in.length()) { - b |= (in.charAt(i + 1) & 0xF0) >> 4; - out += CODES[b]; - b = (in.charAt(i + 1) & 0x0F) << 2; - if (i + 2 < in.length()) { - b |= (in.charAt(i + 2) & 0xC0) >> 6; - out += CODES[b]; - b = in.charAt(i + 2) & 0x3F; - out += CODES[b]; - } else { - out += CODES[b]; - out += '='; - } - } else { - out += CODES[b]; - out += "=="; - } - } - - return out; -} - -WiFiOTAClass::WiFiOTAClass() : - _storage(NULL), - localIp(0), - _lastMdnsResponseTime(0), - beforeApplyCallback(nullptr) -{ -} - -void WiFiOTAClass::begin(IPAddress& localIP, const char* name, const char* password, OTAStorage& storage) -{ - localIp = localIP; - _name = name; - _expectedAuthorization = "Basic " + base64Encode("arduino:" + String(password)); - _storage = &storage; -} - -void WiFiOTAClass::pollMdns(UDP &_mdnsSocket) -{ - int packetLength = _mdnsSocket.parsePacket(); - - if (packetLength <= 0) { - return; - } - - const byte ARDUINO_SERVICE_REQUEST[37] = { - 0x00, 0x00, // transaction id - 0x00, 0x00, // flags - 0x00, 0x01, // questions - 0x00, 0x00, // answer RRs - 0x00, 0x00, // authority RRs - 0x00, 0x00, // additional RRs - 0x08, - 0x5f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, // _arduino - 0x04, - 0x5f, 0x74, 0x63, 0x70, // _tcp - 0x05, - 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x00, // local - 0x00, 0x0c, // PTR - 0x00, 0x01 // Class IN - }; - - if (packetLength != sizeof(ARDUINO_SERVICE_REQUEST)) { - while (packetLength) { - if (_mdnsSocket.available()) { - packetLength--; - _mdnsSocket.read(); - } - } - return; - } - - byte request[packetLength]; - - _mdnsSocket.read(request, sizeof(request)); - - if (memcmp(&request[2], &ARDUINO_SERVICE_REQUEST[2], packetLength - 2) != 0) { - return; - } - - if ((millis() - _lastMdnsResponseTime) < 1000) { - // ignore request - return; - } - _lastMdnsResponseTime = millis(); - - _mdnsSocket.beginPacket(IPAddress(224, 0, 0, 251), 5353); - - const byte responseHeader[] = { - 0x00, 0x00, // transaction id - 0x84, 0x00, // flags - 0x00, 0x00, // questions - 0x00, 0x04, // answers RRs - 0x00, 0x00, // authority RRs - 0x00, 0x00 // additional RRS - }; - _mdnsSocket.write(responseHeader, sizeof(responseHeader)); - - const byte ptrRecordStart[] = { - 0x08, - '_', 'a', 'r', 'd', 'u', 'i', 'n', 'o', - - 0x04, - '_', 't', 'c', 'p', - - 0x05, - 'l', 'o', 'c', 'a', 'l', - 0x00, - - 0x00, 0x0c, // PTR - 0x00, 0x01, // class IN - 0x00, 0x00, 0x11, 0x94, // TTL - - 0x00, (byte)(_name.length() + 3), // length - (byte)_name.length() - }; - - const byte ptrRecordEnd[] = { - 0xc0, 0x0c - }; - - _mdnsSocket.write(ptrRecordStart, sizeof(ptrRecordStart)); - _mdnsSocket.write((const byte*) _name.c_str(), _name.length()); - _mdnsSocket.write(ptrRecordEnd, sizeof(ptrRecordEnd)); - - const byte txtRecord[] = { - 0xc0, 0x2b, - 0x00, 0x10, // TXT strings - 0x80, 0x01, // class - 0x00, 0x00, 0x11, 0x94, // TTL - 0x00, (50 + BOARD_LENGTH), - 13, - 's', 's', 'h', '_', 'u', 'p', 'l', 'o', 'a', 'd', '=', 'n', 'o', - 12, - 't', 'c', 'p', '_', 'c', 'h', 'e', 'c', 'k', '=', 'n', 'o', - 15, - 'a', 'u', 't', 'h', '_', 'u', 'p', 'l', 'o', 'a', 'd', '=', 'y', 'e', 's', - (6 + BOARD_LENGTH), - 'b', 'o', 'a', 'r', 'd', '=', - }; - _mdnsSocket.write(txtRecord, sizeof(txtRecord)); - _mdnsSocket.write((byte*)BOARD, BOARD_LENGTH); - - const byte srvRecordStart[] = { - 0xc0, 0x2b, - 0x00, 0x21, // SRV - 0x80, 0x01, // class - 0x00, 0x00, 0x00, 0x78, // TTL - 0x00, (byte)(_name.length() + 9), // length - 0x00, 0x00, - 0x00, 0x00, - 0xff, 0x00, // port - (byte)_name.length() - }; - - const byte srvRecordEnd[] = { - 0xc0, 0x1a - }; - - _mdnsSocket.write(srvRecordStart, sizeof(srvRecordStart)); - _mdnsSocket.write((const byte*) _name.c_str(), _name.length()); - _mdnsSocket.write(srvRecordEnd, sizeof(srvRecordEnd)); - - byte aRecordNameOffset = sizeof(responseHeader) + - sizeof(ptrRecordStart) + _name.length() + sizeof(ptrRecordEnd) + - sizeof(txtRecord) + BOARD_LENGTH + - sizeof(srvRecordStart) - 1; - - byte aRecord[] = { - 0xc0, aRecordNameOffset, - - 0x00, 0x01, // A record - 0x80, 0x01, // class - 0x00, 0x00, 0x00, 0x78, // TTL - 0x00, 0x04, - 0xff, 0xff, 0xff, 0xff // IP - }; - memcpy(&aRecord[sizeof(aRecord) - 4], &localIp, sizeof(localIp)); - _mdnsSocket.write(aRecord, sizeof(aRecord)); - - _mdnsSocket.endPacket(); -} - -void WiFiOTAClass::pollServer(Client& client) -{ - - if (client) { - String request = client.readStringUntil('\n'); - request.trim(); - - String header; - long contentLength = -1; - String authorization; - - do { - header = client.readStringUntil('\n'); - header.trim(); - - if (header.startsWith("Content-Length: ")) { - header.remove(0, 16); - - contentLength = header.toInt(); - } else if (header.startsWith("Authorization: ")) { - header.remove(0, 15); - - authorization = header; - } - } while (header != ""); - - bool dataUpload = false; -#if defined(ESP8266) || defined(ESP32) - if (request == "POST /data HTTP/1.1") { - dataUpload = true; - } else -#endif - if (request != "POST /sketch HTTP/1.1") { - flushRequestBody(client, contentLength); - sendHttpResponse(client, 404, "Not Found"); - return; - } - - if (_expectedAuthorization != authorization) { - flushRequestBody(client, contentLength); - sendHttpResponse(client, 401, "Unauthorized"); - return; - } - - if (contentLength <= 0) { - sendHttpResponse(client, 400, "Bad Request"); - return; - } - - if (_storage == NULL || !_storage->open(contentLength, dataUpload)) { - flushRequestBody(client, contentLength); - sendHttpResponse(client, 500, "Internal Server Error"); - return; - } - - if (contentLength > _storage->maxSize()) { - _storage->close(); - flushRequestBody(client, contentLength); - sendHttpResponse(client, 413, "Payload Too Large"); - return; - } - - long read = 0; - byte buff[64]; - - while (client.connected() && read < contentLength) { - while (client.available()) { - int l = client.read(buff, sizeof(buff)); - for (int i = 0; i < l; i++) { - _storage->write(buff[i]); - } - read += l; - } - } - - _storage->close(); - - if (read == contentLength) { - sendHttpResponse(client, 200, "OK"); - - delay(500); - - if (beforeApplyCallback) { - beforeApplyCallback(); - } - - // apply the update - _storage->apply(); - - while (true); - } else { - - sendHttpResponse(client, 414, "Payload size wrong"); - _storage->clear(); - - delay(500); - - client.stop(); - } - } -} - -void WiFiOTAClass::sendHttpResponse(Client& client, int code, const char* status) -{ - while (client.available()) { - client.read(); - } - - client.print("HTTP/1.1 "); - client.print(code); - client.print(" "); - client.println(status); - client.println("Connection: close"); - client.println(); - delay(500); - client.stop(); -} - -void WiFiOTAClass::flushRequestBody(Client& client, long contentLength) -{ - long read = 0; - - while (client.connected() && read < contentLength) { - if (client.available()) { - read++; - - client.read(); - } - } -} - diff --git a/rancilio-pid/libraries/ArduinoOTA/src/WiFiOTA.h b/rancilio-pid/libraries/ArduinoOTA/src/WiFiOTA.h deleted file mode 100644 index d9878168e..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/src/WiFiOTA.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - Copyright (c) 2017 Arduino LLC. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - WiFi101OTA version Feb 2017 - by Sandeep Mistry (Arduino) - modified for ArduinoOTA Dec 2018 - by Juraj Andrassy -*/ - -#ifndef _WIFI_OTA_H_INCLUDED -#define _WIFI_OTA_H_INCLUDED - -#include -#include -#include -#include -#include - -#include "OTAStorage.h" - -class WiFiOTAClass { -protected: - WiFiOTAClass(); - - void begin(IPAddress& localIP, const char* name, const char* password, OTAStorage& storage); - - void pollMdns(UDP &mdnsSocket); - void pollServer(Client& client); - -public: - void beforeApply(void (*fn)(void)) { - beforeApplyCallback = fn; - } - -private: - void sendHttpResponse(Client& client, int code, const char* status); - void flushRequestBody(Client& client, long contentLength); - -private: - String _name; - String _expectedAuthorization; - OTAStorage* _storage; - - uint32_t localIp; - uint32_t _lastMdnsResponseTime; - - void (*beforeApplyCallback)(void); -}; - -#endif diff --git a/rancilio-pid/libraries/ArduinoOTA/src/utility/optiboot.h b/rancilio-pid/libraries/ArduinoOTA/src/utility/optiboot.h deleted file mode 100644 index 9783b67cf..000000000 --- a/rancilio-pid/libraries/ArduinoOTA/src/utility/optiboot.h +++ /dev/null @@ -1,200 +0,0 @@ -/*------------------------ Optiboot header file ----------------------------| - | | - | June 2015 by Marek Wodzinski, https://github.com/majekw | - | Modified June 2016 by MCUdude, https://github.com/MCUdude | - | Modified Dec 2018 by Juraj Andrassy, https://github.com/jandrassy | - | Released to public domain | - | | - | This header file gives possibility to use SPM instruction | - | from Optiboot bootloader memory. | - | | - | There are 5 convenient functions available here: | - | * optiboot_page_erase - to erase a FLASH page | - | * optiboot_page_fill - to put words into temporary buffer | - | * optiboot_page_write - to write contents of temporary buffer into FLASH | | - | * optiboot_readPage - higher level function to read a flash page and | - | store it in an array | - | * optiboot_writePage - higher level function to write content to | - | a flash page | - | | - | For some hardcore users, you could use 'do_spm' as raw entry to | - | bootloader spm function. | - |-------------------------------------------------------------------------*/ - -#ifndef _OPTIBOOT_H_ -#define _OPTIBOOT_H_ 1 - -#include -#include "Arduino.h" - - -/* - * Main 'magic' function - enter to bootloader do_spm function - * - * address - address to write (in bytes) but must be even number - * command - one of __BOOT_PAGE_WRITE, __BOOT_PAGE_ERASE or __BOOT_PAGE_FILL - * data - data to write in __BOOT_PAGE_FILL. In __BOOT_PAGE_ERASE or - * __BOOT_PAGE_WRITE it control if boot_rww_enable is run - * (0 = run, !0 = skip running boot_rww_enable) - * - */ - - // 'typedef' (in following line) and 'const' (few lines below) are a way to define external function at some arbitrary address - typedef void (*do_spm_t)(uint16_t address, uint8_t command, uint16_t data); - typedef void (*copy_flash_pages_t)(uint32_t dest, uint32_t src, uint16_t page_count, uint8_t reset); - - -/* - * Devices with more than 64KB of flash: - * - have larger bootloader area (1KB) (they are BIGBOOT targets) - * - have RAMPZ register :-) - * - need larger variable to hold address (pgmspace.h uses uint32_t) - */ -#ifdef RAMPZ - typedef uint32_t optiboot_addr_t; -#else - typedef uint16_t optiboot_addr_t; -#endif - - #if FLASHEND > 65534 - const do_spm_t do_spm = (do_spm_t)((FLASHEND-1023+2)>>1); - const copy_flash_pages_t copy_flash_pages = (copy_flash_pages_t)((FLASHEND-1023+4)>>1); - #else - const do_spm_t do_spm = (do_spm_t)((FLASHEND-511+2)>>1); - #endif - - -/* - * The same as do_spm but with disable/restore interrupts state - * required to succesfull SPM execution - * - * On devices with more than 64kB flash, 16 bit address is not enough, - * so there is also RAMPZ used in that case. - * - * On devices with more than 128kB flash, 16 bit word address is not enough - * for a function call above 0x20000, so there is also EIND used in that case. - */ -void do_spm_cli(optiboot_addr_t address, uint8_t command, uint16_t data) { - uint8_t sreg_save; - - sreg_save = SREG; // save old SREG value - asm volatile("cli"); // disable interrupts -#ifdef RAMPZ - RAMPZ = (address >> 16) & 0xff; // address bits 23-16 goes to RAMPZ -#ifdef EIND - uint8_t eind = EIND; - EIND = FLASHEND / 0x20000; -#endif - do_spm((address & 0xffff), command, data); // do_spm accepts only lower 16 bits of address -#ifdef EIND - EIND = eind; -#endif -#else - do_spm(address, command, data); // 16 bit address - no problems to pass directly -#endif - SREG = sreg_save; // restore last interrupts state -} - -/* - * Copy contents of the flash pages. Addresses must be aligned to page boundary. - * - * On devices with more than 128kB flash, 16 bit word address is not enough - * for a function call above 0x20000, so there is also EIND used in that case. - * - * If reset_mcu is true, watchdog is used to reset the MCU after pages are copied. - * That enables to copy a new version of application from upper half of the flash. - */ -#if FLASHEND > 65534 -void copy_flash_pages_cli(uint32_t dest, uint32_t src, uint16_t page_count, uint8_t reset_mcu) { - uint8_t sreg_save = SREG; // save old SREG value - asm volatile("cli"); // disable interrupts -#ifdef EIND - uint8_t eind = EIND; - EIND = FLASHEND / 0x20000; -#endif - copy_flash_pages(dest, src, page_count, reset_mcu); -#ifdef EIND - EIND = eind; -#endif - SREG = sreg_save; // restore last interrupts state -} -#endif - -// Erase page in FLASH -void optiboot_page_erase(optiboot_addr_t address) { - do_spm_cli(address, __BOOT_PAGE_ERASE, 0); -} - - -// Write word into temporary buffer -void optiboot_page_fill(optiboot_addr_t address, uint16_t data) { - do_spm_cli(address, __BOOT_PAGE_FILL, data); -} - - -//Write temporary buffer into FLASH -void optiboot_page_write(optiboot_addr_t address) { - do_spm_cli(address, __BOOT_PAGE_WRITE, 0); -} - - - -/* - * Higher level functions for reading and writing from flash - * See the examples for more info on how to use these functions - */ - -// Function to read a flash page and store it in an array (storage_array[]) -void optiboot_readPage(const uint8_t allocated_flash_space[], uint8_t storage_array[], uint16_t page, char blank_character) -{ - uint8_t read_character; - for(uint16_t j = 0; j < SPM_PAGESIZE; j++) - { - read_character = pgm_read_byte(&allocated_flash_space[j + SPM_PAGESIZE*(page-1)]); - if(read_character != 0 && read_character != 255) - storage_array[j] = read_character; - else - storage_array[j] = blank_character; - } -} - - -// Function to read a flash page and store it in an array (storage_array[]), but without blank_character -void optiboot_readPage(const uint8_t allocated_flash_space[], uint8_t storage_array[], uint16_t page) -{ - uint8_t read_character; - for(uint16_t j = 0; j < SPM_PAGESIZE; j++) - { - read_character = pgm_read_byte(&allocated_flash_space[j + SPM_PAGESIZE*(page-1)]); - if(read_character != 0 && read_character != 255) - storage_array[j] = read_character; - } -} - - -// Function to write data to a flash page -void optiboot_writePage(const uint8_t allocated_flash_space[], uint8_t data_to_store[], uint16_t page) -{ - uint16_t word_buffer = 0; - - // Erase the flash page - optiboot_page_erase((optiboot_addr_t)(void*) &allocated_flash_space[SPM_PAGESIZE*(page-1)]); - - // Copy ram buffer to temporary flash buffer - for(uint16_t i = 0; i < SPM_PAGESIZE; i++) - { - if(i % 2 == 0) // We must write words - word_buffer = data_to_store[i]; - else - { - word_buffer += (data_to_store[i] << 8); - optiboot_page_fill((optiboot_addr_t)(void*) &allocated_flash_space[i + SPM_PAGESIZE*(page-1)], word_buffer); - } - } - - // Writing temporary buffer to flash - optiboot_page_write((optiboot_addr_t)(void*) &allocated_flash_space[SPM_PAGESIZE*(page-1)]); -} - - -#endif /* _OPTIBOOT_H_ */ diff --git a/rancilio-pid/icon.h b/rancilio-pid/src/icon.h similarity index 100% rename from rancilio-pid/icon.h rename to rancilio-pid/src/icon.h diff --git a/rancilio-pid/rancilio-pid.ino b/rancilio-pid/src/rancilio-pid.ino similarity index 100% rename from rancilio-pid/rancilio-pid.ino rename to rancilio-pid/src/rancilio-pid.ino diff --git a/rancilio-pid/userConfig.h b/rancilio-pid/src/userConfig.h similarity index 100% rename from rancilio-pid/userConfig.h rename to rancilio-pid/src/userConfig.h