Make ArduinoOTA MKR1400/1500 compatible - Feature request #196
Replies: 15 comments
-
I don't understand. my example uses the Arduino API of the Stream class which should work the same way for all implementations of Stream |
Beta Was this translation helpful? Give feedback.
-
Me neither. The MKRGSM lib does read the tcp connection with looping the AT command At the end of the file, when there is not a full portion of 512 bytes avaiable, the modem struggles and answer with the very detailed report of "ERROR".. So the file is not completely downloaded (between 1 and 512 bytes are missed) and your lib handles the error and stop the process. The referenced Arduino example lib handles this task in the way as described and then it works. |
Beta Was this translation helpful? Give feedback.
-
Here are two example of the log. Always at the end the modem closes the socket and some bytes were missing: 8:35:01.054 -> +UUSORD: 1,722 08:35:01.054 -> +USORD: 1,512,"00000000A0420000A0420000A0420000A042000048C2000048C2000048C2000048C20000C84210270000F04902000024744800002042439C03004B9C0300559C03005D9C0300689C0300729C03005000000039990300FFFFFFFF38A2030027A203000CA203003C000000002000420024004200280042002C0042003000420034004240420F000A0000000A00000008000000FFFFFFFFFFFFFFFF00366E01FFFFFFFF00C2010000000800FFFFFFFF010000008401002000000000C8C20300E8C20300A8C2030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004300000000000000000000000000000000000000000000000000000000000000430000000000000000000000000000000000000000000000000000000000000043000000000000000000000000000000000000000000000000000000000000004300000000000000000000000000000000000000000000000000000000000000430000000000000000000000000000000000000000000000000000000000000043000000000000000000000000000000000000000000000000000000000000004300000000000000000000000000000000000000000000000000000000000000B99E0200D98302000000" 08:35:01.125 -> +USORD: 1,210,"000098C10300DABD02007EC002007EC002007EC002007EC002007EC002007EC002007EC002007EC002007EC00200FFFFFFFFFFFFFFFFFFFFFFFFFFFF00000100415343494900000000000000000000000000000000000000000000000000000041534349490000000000000000000000000000000000000000000000000000000000DD600000BD9300008D3D0100FD3F010091480100514C010049520100E952010089800100B18201007D890100ADFD01003D0002005D17020071250200452C0200B5600000000000000000000000000000" 08:35:01.409 -> ERROR 08:35:01.444 -> ERROR 08:35:02.902 -> +USORD: 0,0,"" Example 2: 8:38:13.075 -> +USORD: 1,512,"00000000A0420000A0420000A0420000A042000048C2000048C2000048C2000048C20000C84210270000F04902000024744800002042439C03004B9C0300559C03005D9C0300689C0300729C03005000000039990300FFFFFFFF38A2030027A203000CA203003C000000002000420024004200280042002C0042003000420034004240420F000A0000000A00000008000000FFFFFFFFFFFFFFFF00366E01FFFFFFFF00C2010000000800FFFFFFFF010000008401002000000000C8C20300E8C20300A8C2030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004300000000000000000000000000000000000000000000000000000000000000430000000000000000000000000000000000000000000000000000000000000043000000000000000000000000000000000000000000000000000000000000004300000000000000000000000000000000000000000000000000000000000000430000000000000000000000000000000000000000000000000000000000000043000000000000000000000000000000000000000000000000000000000000004300000000000000000000000000000000000000000000000000000000000000B99E0200D98302000000" 08:38:13.147 -> +USORD: 1,210,"000098C10300DABD02007EC002007EC002007EC002007EC002007EC002007EC002007EC002007EC002007EC00200FFFFFFFFFFFFFFFFFFFFFFFFFFFF00000100415343494900000000000000000000000000000000000000000000000000000041534349490000000000000000000000000000000000000000000000000000000000DD600000BD9300008D3D0100FD3F010091480100514C010049520100E952010089800100B18201007D890100ADFD01003D0002005D17020071250200452C0200B5600000000000000000000000000000" 08:38:13.443 -> ERROR 08:38:13.443 -> ERROR 08:38:14.923 -> +USORD: 0,0,"" |
Beta Was this translation helpful? Give feedback.
-
I digged deeper and i found the root cause: The modem is simply not delivering the right data. I made a hexdump diff of the file on the server and with the file downloaded and the missed bytes were all over the file, not just at the end.
|
Beta Was this translation helpful? Give feedback.
-
this is usually caused by buffer overflows of the Serial buffer. see how it is done in WiFiOTA.cpp Line 296 in 28a22f0 |
Beta Was this translation helpful? Give feedback.
-
I tried yesterday a solution (but with 512 byte pakets to write in one rush to the SD, i assumed the bottleneck was the SD card) with no success, i will try again following your provided example. Thanks a bunch |
Beta Was this translation helpful? Give feedback.
-
I implemented with no success. I also tried to reduce the #define GSM_SOCKET_BUFFER_SIZE 512 down to 16 (recommended by the modem manufacturer if the FIFO rx buffer from the serial connected device is small. |
Beta Was this translation helpful? Give feedback.
-
I invested another day on investigation. Conclusion remains the same - the only way to get a bin complete to a MKR1400 is into the internal memory and then from there to the SD card, for large sketches i still see only my way: |
Beta Was this translation helpful? Give feedback.
-
why to SD card? |
Beta Was this translation helpful? Give feedback.
-
Because the UPDATE.bin is around 230kB. I see no other way then update over SDU.h ?!? |
Beta Was this translation helpful? Give feedback.
-
so now I wonder why you have so large binary? maybe move some large data from the binary into a file on the SD card |
Beta Was this translation helpful? Give feedback.
-
My whole sketch is that large. The OTA is for a complete firmware update. Your sketch works like a charm on MKR1100 over Wifi within seconds thats why i tried to have the same code on MKR1400 - without success. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I found out that MKR 1400 ArduinoHttpClient and direct write to the SD card is not working, probably, as @JAndrassy mentioned, because of buffer time lag, whatever, it's working not properly but flaky. This has nothing to do with the ArduinoOTA lib, so just for documentation if someone with the same problem finds this thread, a version that works with direct client.read and .print from MKRGSM. The HTTP Head removal is a hack, this one is for a Apache Header on a Ubuntu, maybe needs changes :
|
Beta Was this translation helpful? Give feedback.
-
Final conclusion: |
Beta Was this translation helpful? Give feedback.
-
At the moment, the lib is not compatible because MKRGSM reads out the connection in 512 bytes portions, so at the end when there is just a rest of bytes, it misses the last portion.
The core is:
The Arduino download example under
https://github.com/arduino-libraries/MKRGSM/blob/master/examples/Tools/FileUtilsHttpDownload/FileUtilsHttpDownload.ino
to store the file in the memory of the modem calculates this way:
fileSize is the size of the file to be downloaded
The core is:
I tried but failed on merge this concepts (but i'm surely not skilled as JAndrassy or many others) but maybe someone can contribute a ArduinoOTA SD version to this lib?
@JAndrassy what do you think?
Beta Was this translation helpful? Give feedback.
All reactions