Forum Replies Created
-
AuthorPosts
-
I think this can be useful.
I tested It with some microcontrollers.Bye Renzo
Attachments:
You must be logged in to view attached files.9 February 2022 at 15:38 in reply to: Flash bin file from SPIFFS of ESP8266 via serial to Arduino UNO #18526Hi Martin,
from a Medium article I extract this, and I think It’s what you need.How does firmware update work on Arduino Uno?
The Arduino Uno comes with a bootloader (known as Optiboot) which implements the STK500 protocol for receiving the compiled program binaries through the UART.
Explanation on Optiboot in Updating Arduino Firmware
- On reset:
Arduino reboot from bootloader and check for the cause of the reset. If it was an internal reset (eg. reset by watchdog timer), then it directly jumps to the main application program. However, if it was an external reset, it will set up a watchdog timer which will timeout in 1 second. - Listen to UART port:
If it was an external reset, the bootloader will start an infinite loop to listen to the UART port after the watchdog timer setup. If there is no valid command dedicated to the STK500 protocol received in 1 second, the watchdog timer will timeout and cause an internal reset. However, on receiving any valid command code, the watchdog timer counter will be reset to avoid unnecessary system reset from occurring. According to the application note of STK500 Communication Protocol, the format of the command is: <Command_Code> <Data (if any)> <CRC_EOP>
List of valid and useful command codes for Optiboot: 1. STK_GET_SYNC : — 0x30 2. STK_ENTER_PROGMODE : — 0x50 3. STK_LEAVE_PROGMODE : — 0x51 4. STK_LOAD_ADDRESS : — 0x55 5. STK_PROG_PAGE : — 0x64 6. CRC_EOP : — 0x20List of useful reply codes from Optiboot: 1. STK_INSYNC : — 0x14 2. STK_OK : — 0x10
Algorithm of Optiboot in receiving compiled binaries:
- Programmer send <STK_ENTER_PROGMODE> <CRC_EOP> to Arduino to command for starting of programming mode. The bootloader will reply <STK_INSYNC> <STK_OK> if it is in sync with the programmer.
*Note: After reading through the source code of Optiboot, I found that this step is not necessary as there is no specific condition checking for this command. However, it could be used for checking whether the Arduino is in sync with the programmer or not. Alternatively, by sending <STK_GET_SYNC> <CRC_EOP> could also check whether it is in sync or not. - If the Arduino is in sync with the programmer, the programmer can then send <STK_LOAD_ADDRESS> <Low byte of address> <High byte of address> <CRC_EOP>. This command is for loading the starting address of flash memory which will be filled with the bytes of program binary codes that will be sent later.
* low byte of address = address & 0xFF
* high byte of address = address >> 8
** address starts from 0 - If <STK_INSYNC> <STK_OK> is received, the programmer can then send <STK_PROG_PAGE> <Low byte of length> <High byte of length> <Dest type> <bytes of program of the specified length> <CRC_EOP>.
* The length specified the number of bytes of program binaries to be written in the flash memory.
low byte of length = length & 0xFF
high byte of length = length >> 8
* The <Dest type> specified the location (eeprom [‘E’] or flash [default]) at which the program codes to be written. - Check for reply. If <STK_INSYNC> <STK_OK> is received, update the as address := address + (length / 2), then continue the loop from step 2 until all the program binaries are sent and written into the flash memory.
* Since the address is a word pointer, so it is updated by half of the length (byte). - After sending all program binaries, the programmer then send <STK_LEAVE_PROGMODE> <CRC_EOP> for leaving programming mode.
OTA Firmware Update on Arduino Uno through ESP8266
The Arduino Uno is connected with a WiFi module to enable OTA firmware update. In this project, ESP8266 WiFi module is used. A simple ESP8266 library is developed to remotely interface with the connected Arduino Uno. This library enables the OTA firmware update functionality for the Arduino by implementing STK500 protocol (as explained above) for writing the compiled binaries to the Arduino. Besides, remote debug message logging is also enabled in this library.
On the host machine, a graphical user interface (GUI) is also developed to aid the process of remotely interfacing with the connected Arduino.
The remote interfacing process is done through MQTT protocol. So, the WiFi module and the host machine must connect to a MQTT broker for communication. The library used for establishing MQTT connection on the WiFi module here is the PubSubClient by knolleary.
GitHub Link of the complete project: https://github.com/JayLooi/RemoteArduino
Demo Video
References
- https://www.wired.com/2012/08/nasa-patch/
- “AVR061: STK500 Communication Protocol” retrieved from http://ww1.microchip.com/downloads/en/AppNotes/doc2525.pdf
- https://github.com/arduino/ArduinoCore-avr/tree/master/bootloaders/optiboot
- https://github.com/knolleary/pubsubclient
Bye Renzo
Hi George,
you must consider the time to read from serial, after read, the reader data are removed from the buffer.
I think it’s very difficult that you lost data.
But depending on the type of application.
Bye RenzoAlways UART version.
I want to create other libraries to use with Android and Python or java. But I need more time.
Bye RenzoI think It’s not possible, but the price of LoRa E220 it’s the same as RFM95W so you can use only that.
I don’t know if E32 SPI can communicate with RFM95W.
Bye RenzoIf I remember exists an e32 SPI version, but if you want something with good performance and less price you must get Ebyte E220.
It has a configurable encrypting key, WOR, RSSI etc. etc. module format and SMD.
I’ll release the definitive version of the library soon, here a preview
Ebyte E220 (LLCC68) compatibilityBye Renzo
Hi Javi,
It seems all ok.
But change the size of int value to 2 byte.
And type to 1 charstruct Message { char type = '1'; byte amp1[2]; byte volt1[2]; } message;
And reduce the packet size to 64bytes so It’s more responsive
configuration.OPTION.subPacketSetting = SPS_064_10;
and enable the LBT to prevent network problem
configuration.TRANSMISSION_MODE.enableLBT = LBT_ENABLED;
Bye Renzo
Hi Javi,
You can use the specified method, check the article of e32 module as reference
Ebyte LoRa E32 device for Arduino, esp32 or esp8266: power saving and sending structured data – Part 5receiveMessageUntil is only for string.
But attach your code, we try to check better.
Bye Renzo
Hi ezcGman,
I think the two modules can’t be compatible.
RFM95W is a basic lora module, e32 is more complex, have a specified protocol with data criptyng, WOR, addressing and other features.
Bye RenzoHi Silvio,
It seems that you configure transparent transmission but you try to send a fixed transmission.
Check this article, it’s e32 but the concept is the same.
Ebyte LoRa E32 device for Arduino, esp32 or esp8266: fixed transmission – 4Bye Renzo
Thanks a lot, koobs,
Can you explain better (with a simple schema) the connection? I’ll try to put in this topic, and I will try to integrate it with other info.
Bye RenzoHi Ari,
no, your device is the SPI version not UART version, so isn’t compatible with my library.
Bye RenzoHi Ari,
you can follow this pinout schemaNo. Name 1 GND 2 GND 3 GND 4 GND 5 Input M0 (weak pull-up) 6 Input M1 (weak pull-up) 7 Input RXD 8 Output TXD 9 AUX 10 VCC 11 GND 12 NRST 13 GND 14 NC 15 NC 16 NC 17 NC 18 NC 19 GND 20 GND 21 ANT 22 GND
And you can change the pin as you want, you must only pay attention to the microcontroller internal pull-up, but you can simply do a test to check if It’s work.
Bye Renzo
Hi Enzaii,
There is a limitation on file length (I had seen that on MKS WiFi Plugin for Cura). I’m going to add a file length limitation on the web interface.
Thanks, RenzoHi Silvio,
you can find It in the upper post.
If you have trouble writing on the forum.
Bye Renzo - On reset:
-
AuthorPosts