LowPowerLab Forum

Software support => Wireless Programming (aka OTA) => Topic started by: roman_s on May 02, 2017, 09:58:02 PM

Title: OTA Programming from RPi & SPI
Post by: roman_s on May 02, 2017, 09:58:02 PM
I got bitten by the Moteino bug and am starting to scale up my sensor network around the house. That will become easier to manage with OTA programming, so I am looking into my options. From my limited insight so far it seems like Felix' approach is based on a Moteino Gateway that a PC talks to through the serial port. However, my current gateway that listens sensor readings is a bare RFM69 connected to a Raspberry Pi Zero via SPI (using https://github.com/etrombly/RFM69 and hence a simple Python-based daemon).

I wonder if it's worth the effort to try to port the OTA library & client to something that runs on the Rpi and talks to the radio through SPI, as opposed to a sketch and a Windows GUI. I'd prefer a scriptable, programmatic approach, but it seems to be a non-trivial amount of work.

Any opinions?

Thanks,
Roman
Title: Re: OTA Programming from RPi & SPI
Post by: Felix on May 03, 2017, 07:37:37 AM
IMHO its not worth it. But I am biased because I believe in a middle man (moteino or avr/atmega) between the computer and the radio. I like to have the two talk serial rather than go to SPI, reason being that if Pi stops being made tomorrow, I can take serial to the next Pi or PC or whatever, but with the SPI i have to reimplement everything.
Title: Re: OTA Programming from RPi & SPI
Post by: roman_s on May 03, 2017, 03:52:31 PM
Makes sense, thanks for the feedback, Felix. Even though the challenge is tempting, I'll just use one of my Moteinos as a OTA programming gateway and keep the rest of my setup. I assume I can simply connect its serial pins with the Pi Zero?

On that note: I still want to follow the programmatic approach, using a script instead of a GUI. Does https://github.com/LowPowerLab/WirelessProgramming/blob/master/WirelessProgramming.py still work? It is part of the old repo that is now marked as obsolete (I guess it is entirely subsumed by https://github.com/LowPowerLab/RFM69).

I do have one more question regarding your reply though: Isn't SPI a common standard just like serial, and just as "future-proof"? Or did you mean that you prefer the generality of a PC as a programming client, rather than a microcontroller?

Roman
Title: Re: OTA Programming from RPi & SPI
Post by: Felix on May 03, 2017, 04:04:43 PM
Yes connect to GPIO serial.

The py script is old and wont work. I may combine a windows GUI to invoke an updated py script but I need to find the time to make that change, not top priority right now.

SPI is more low level, you dont find a "SPI" port on the laptops at best buy, serial is universal and on every PC, either in USB or RS232 form, on the Pi its also available on the GPIO directly.
Title: Re: OTA Programming from RPi & SPI
Post by: brolly759 on May 11, 2017, 12:33:24 AM
Why wont the Py script work anymore?
Title: Re: OTA Programming from RPi & SPI
Post by: Felix on May 11, 2017, 09:11:35 AM
Because it's deprecated by changes to the OTA algorithm.
Title: Re: OTA Programming from RPi & SPI
Post by: brolly759 on May 11, 2017, 10:42:04 AM
Ugh, thats not good, I was building something with a Pi that uses 2 modules, 1 for OTA and 1 for the network hub... Is there anyway to wireless OTA a Mote using a Pi at the moment? If not, what is the ETA on the Py script to be updated?
Title: Re: OTA Programming from RPi & SPI
Post by: Felix on May 11, 2017, 01:39:53 PM

I don't have an ETA but I plan to explore a way to invoke that from the .net program and then it could also be directly invoked on linux.
If you are not afraid of some coding you could take the existing py script to make changes to it yourself based on what the moteino OTA programmer expects. There are a few handshakes and the rest is the transmission packet by packet.
Title: Re: OTA Programming from RPi & SPI
Post by: brolly759 on May 11, 2017, 04:07:53 PM
Is there a version of software that works with the py script so I can do a compare on the differences?
Title: Re: OTA Programming from RPi & SPI
Post by: Felix on May 11, 2017, 04:36:14 PM
Currently the RFM69_OTA.h is the header for the new OTA library.
Before it used to be called WirelessHEX69, located here for reference (https://github.com/LowPowerLab/WirelessProgramming/tree/master/WirelessHEX69).
The current .net GUI worked with that WirelessHEX until I merged that into the RFM69 library as RFM69_OTA.h.
So if you go back in history on the WirelessHEX69, perhaps this revision (https://github.com/LowPowerLab/WirelessProgramming/tree/24fbed52d382886f4fa9a48811c0a9d30e630dd1), you might be able to run it. Also the OTA examples would need to include WirelessHEX69.h instead of the latest RFM69_OTA.h. Good luck :)
Title: Re: OTA Programming from RPi & SPI
Post by: brolly759 on May 11, 2017, 05:49:18 PM
I dont need SPI communication, is their a USB/UART python OTA already written and currently working? Hell I can use any programming language as long as it works on linux lol
Title: Re: OTA Programming from RPi & SPI
Post by: brolly759 on May 11, 2017, 07:55:45 PM
I guess my question is, does this py file still work?
https://github.com/LowPowerLab/WirelessProgramming/blob/master/WirelessProgramming.py

Title: Re: OTA Programming from RPi & SPI
Post by: Felix on May 11, 2017, 11:24:41 PM
I answered that here (https://lowpowerlab.com/forum/wireless-programming-(aka-ota)/ota-programming-from-rpi-spi/msg19654/#msg19654).
Looks like I might be able to use IronPython to include a small py runtime in a .net executable and then just pass parameters to a py script. If that works, then I will bring the py script up to date and keep the OTA logic there rather than in c#.
Title: Re: OTA Programming from RPi & SPI
Post by: brolly759 on June 30, 2017, 06:02:22 PM
So, any updated Python code yet? :)

I can settle with an ESP8266/32 OTA for Motes :)
Title: Re: OTA Programming from RPi & SPI
Post by: Felix on June 30, 2017, 06:50:54 PM
Yup, I blogged about it here (https://lowpowerlab.com/2017/05/26/wireless-programming-updates/).
More very cool stuff is coming to OTA ;)
Title: Re: OTA Programming from RPi & SPI
Post by: brolly759 on June 30, 2017, 06:59:32 PM
more cool stuff? Tell me tell me tell me!! :)
Title: Re: OTA Programming from RPi & SPI
Post by: Felix on July 01, 2017, 08:49:58 AM
Youll have to wait and see  ;)
Title: Re: OTA Programming from RPi & SPI
Post by: WhiteHare on July 01, 2017, 01:16:44 PM
I hope whatever you come up with will work on a Raspberry Pi 3!   ;)
Title: Re: OTA Programming from RPi & SPI
Post by: Felix on July 01, 2017, 04:17:45 PM
Does it not work on a Pi3 now with the latest python script?
Title: Re: OTA Programming from RPi & SPI
Post by: brolly759 on July 07, 2017, 12:17:59 AM
Felix, I am about to work on OTA soon, the flash chip I got was the wrong version, go figure. I had a quick question. The Arduino + RFM69 that sits on the Pi / PC.... That doesnt need to be reprogrammed everytime I want to do an OTA? In other words, can I have the OTA functionality and the Gateway functionality on the same run code?

Thanks
Title: Re: OTA Programming from RPi & SPI
Post by: Felix on July 07, 2017, 10:37:29 AM
Quote from: brolly759 on July 07, 2017, 12:17:59 AM
I had a quick question. The Arduino + RFM69 that sits on the Pi / PC.... That doesnt need to be reprogrammed everytime I want to do an OTA? In other words, can I have the OTA functionality and the Gateway functionality on the same run code?

You could yes, the OTA protocol (current and future) changes the frequency (this is enabled by default in the RFM69_OTA lib) so it stays clear of the "main" transmit channel. So the OTA happens in some 1mhz or so frequency below/above the main channel. You can keep your functionality combined with OTA gateway on your gateway arduino, although I would recommend using another board for OTA purposes (so the gateway would not stay "busy" while OTA in progress...).
Title: Re: OTA Programming from RPi & SPI
Post by: brolly759 on July 07, 2017, 01:26:35 PM
How long is the OTA process per node?
Title: Re: OTA Programming from RPi & SPI
Post by: Felix on July 07, 2017, 02:32:18 PM
See my blog on the Wireless Programming subject for more details, but about 14seconds for a 15K sketch.
That's subject to change.
Title: Re: OTA Programming from RPi & SPI
Post by: brolly759 on July 07, 2017, 10:37:16 PM
Are there other MCU's that are supported for OTA like ARM or comparative?
Title: Re: OTA Programming from RPi & SPI
Post by: Felix on July 10, 2017, 10:52:52 AM
The OTA protocol is platform agnostic, it doesn't care how you get that image over to the target.
I believe the RFM69 lib supports certain ARM chips as well.
Title: Re: OTA Programming from RPi & SPI
Post by: brolly759 on July 10, 2017, 09:54:30 PM
I meant if the end node was an ARM processor.... not a 328p
Title: Re: OTA Programming from RPi & SPI
Post by: Felix on July 11, 2017, 09:20:17 AM
I am AVR :) so no clue which ARMs it works on, there are thousands of variants. But I believe it does on the samd21.