Giter VIP home page Giter VIP logo

sonota's Introduction

SonOTA

Flashing Itead Sonoff devices via original OTA mechanism

This program is based on research documented here:

The script is fairly well documented (I think) - apart from that above stated links should provide some context of what's been done how and why. Feel free to open issue tickets or contact me directly: [email protected]

DNS redirect

The program only works if you made sure the hostname 'eu-disp.coolkit.cc' is being resolved to an IP address assigned to the machine this script is running on.

On a WiFi router running OpenWrt this can be easily done by adding the following line to /etc/hosts and restarting dnsmasq:

10.23.42.5 eu-disp.coolkit.cc

Adjust IP address and make sure variable serving_host in sonota.py is set to the same.

No DNS redirect is needed anymore with version 2 as the script can now also provision the Sonoff device and hence specify the serving_host.

Creation of SSL certificates

openssl req -x509 -nodes -newkey rsa:2048 -keyout ${SONOTA}/ssl/server.key -out ${SONOTA}/ssl/server.crt -days 42235

Building an user2 image with Arduino

--- a/~/.arduino15/packages/esp8266/hardware/esp8266/2.3.0/tools/sdk/ld/eagle.flash.1m64.ld
+++ b/~/.arduino15/packages/esp8266/hardware/esp8266/2.3.0/tools/sdk/ld/eagle.flash.1m64.ld
@@ -7,7 +7,7 @@ MEMORY
   dport0_0_seg :                        org = 0x3FF00000, len = 0x10
   dram0_0_seg :                         org = 0x3FFE8000, len = 0x14000
   iram1_0_seg :                         org = 0x40100000, len = 0x8000
-  irom0_0_seg :                         org = 0x40201010, len = 0xf9ff0
+  irom0_0_seg :                         org = 0x40281010, len = 0xf9ff0
 }
 
 PROVIDE ( _SPIFFS_start = 0x402FB000 );

Converting Arduino images to v2 images

esptool.py elf2image --version 2 image_user1.ino.elf esptool.py elf2image --version 2 image_user2.ino.elf

mv image_user1-0x01000.bin image_user2-0x81000.bin ${SONOTA}/static/

Run

The script needs to be run as root, as it binds to port 443 to which the Sonoff device initially sets up a HTTPS POST request.

The script can now be run as a regular user; as we are doing the provisioning now, we can also set the port to anything other than 443.

python3 sonota.py --wifi-ssid foobar --wifi-password ew4Ookie 10.23.42.5

Issues

As we don't override the bootloader which still expects v2 images and our custom firmware might end up in the user2 partition, vanilla Arduino OTA functionality - if provided by your custom image - will not work.

sonota's People

Contributors

jalmeroth avatar mirko avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.