Wireless OTA via the serial port

Started by miketuk, December 18, 2018, 04:21:42 PM

miketuk

Eventually I would like to do this over the GSM modem, but for now I thought it prudent to start with flashing a new sketch via serial.

So, I have taken the example sketches and kinda merged them into one, so the windows app talks to one sketch, that writes the data straight to the flash memory. I thought I would try with a simple OTA sketch which is essentially the blink app. However, I am a bit stuck.

The Moteino OTA programmer reports success and the first packet sent is as follows: "TX > FLX:0:300000000C9461000C9489000C9489000C9489000C9489000C9489000C9489000C9489000C9489000C9489000C9489000C9489000C RX > FLX:0:OK". However, when I read back the flash, I see the following :

46.4C.58.49.4D.47.3A.FF.FF.3A.31.30.30.30.30.30.30.30.30.43.31.30.30.30.31.30.30.30.30.43.31.30.30.30.32.30.30.30.30.43.31.30.30.30.33.30.30.30.30.43.31.30.30.30.34.30.30.30.30.43.31.30.30.30.35.30.30.30.30.43.31.30.30.30.36.30.30.30.30.43.31.30.30.30.37.30.30.30.30.30.31.30.30.30.38.30.30.30.30.30.31.30.30.30.39.30.30.30.32.30.31.30.30.30.41.30.30.30.30.31.30.30.30.42.30.30.30.30.31.30.30.30.43.30.30.30.43.31.30.30.30.44.30.30.30.41.31.30.30.30.45.30.30.30.42.31.30.30.30.46.30.30.30.42.31.30.30.31.30.30.30.30.30.31.30.30.31.31.30.30.30.41.31.30.30.31.32.30.30.30.38.31.30.30.31.33.30.30.30.30.31.30.30.31.34.30.30.30.38.31.30.30.31.35.30.30.30.36.31.30.30.31.36.30.30.30.30.31.30.30.31.37.30.30.30.31.31.30.30.31.38.30.30.30.39.31.30.30.31.39.30.30.30.32.31.30.30.

Ignoring for the moment the length of the sketch in bytes 7&8, it appears different and fails to boot the new code. I calculated the total bytes (minus the header) as 2087, but the optiboot doesn't seem to like an odd number of bytes. I have tried forcing it to be 2088, but still no joy.

Clearly I am missing something obvious, any clues?

TomWS

Without digging into the details, it appears to me than you haven't converted the hex value to binary.  The flash appears to have ASCII hexdecimal values stored in it.  And, no, you should not have an odd number of bytes.

miketuk

Thank you for the reply Tom, I have now converted the hex bytes back to binary before writing. Should of read the code a bit closer!

All is now well and I can do FOTA (over serial at least) and I understand the protocol a little better now.

Many thanks for your assistance.