Open simogaspa84 opened 2 years ago
No, the Ethernet library it uses is for Wiznet W5100 (compatible with also W5500). But I think you can replace the ethernet library to an API-compatible one for the ENC28J60.
Ok,..the point is Can i update the fw from command line of my pc when it works ? It is not clear where you insert the ip address of the esp32
Can i update directly a .bin file ? ok so from the web browser i type
http://arduino:password@192.168.1.237:65280/firmware.bin
If i don't know before the ipaddress of the device how can I do it?
I meam i deply the board but i now later the ip address of the device how can I set a generic ipaddress here
Can i update directly a .bin file ?
As
says, the upload works by HTTP POST'ing the firmware.bin file to the given URL.
ok so from the web browser i type http://arduino:password@192.168.1.237:65280/firmware.bin
No, if you access that URL from the web browser it will just send a HTTP GET request there, there is no intermediate website that lets you drag-and-drop the file onto it. You have to use a HTTP client that can do a post request with a binary file -- like curl
.
If i don't know before the ipaddress of the device how can I do it?
Use a dynamic DNS vendor or have the device connect to a static server to which it can post its IP or device name. Of course for this method to work, the device musn't be behind a firewall or a router, the 65280 port must be directly accessible from the computer which you want to upload the firmware. If that is not the case, you must have the device connect to a known static server from which it will check the firmware and download the new firmware file as needed. While possible, this is not what this repository showcases.
@maxgerhardt Use a dynamic DNS vendor or have the device connect to a static server to which it can post its IP or device name. Of course for this method to work, the device musn't be behind a firewall or a router, the 65280 port must be directly accessible from the computer which you want to upload the firmware.
Yes i will now the future ip address once the device is deployed.. but it is not clear where i have to insert this information..
if i need it here it is over because i don't know in advance the local ip address.. I am posting it on a web app so i can retrieve it
How can i set correctly here if i don't know in advance the ip address
upload_flags = http://arduino:password@192.168.1.237:65280/sketch
Can you explain the whole process ?
Thanks a lot
if i need it here it is over because i don't know in advance the local ip address..
The device does not need to know its IP in advance. You just flash it with the firmware regularly over USB using the env:esp32dev
environment. When you know the IP of the deployed device and it is directly reachable on port 65280 (default), you can update the target IP in the upload_flags
of the env:esp32dev_ota
environment and press upload.
Again, if you are not on the same network as the deployed device or there's a router in between that doesn't have port-forwarding set-up for this specific port, this method won't work. You'd have to reverse the connection flow as I've indicated above.
@maxgerhardt my idea is to update the fw of an esp32 device which is sending data to a cloud service via mqtt. For sure we have already tested with wifi and also with ethernet shield at physical layer. We are posting the local ip address of the device in the cloud so now we now the local ip, We want to create a procedure to update the fw of the esp32 without using platformio installed (so no update taste is possible) I was thinking there was a way to start webserver localluy and then knowing the ip address of the esp32 sending the update (instead of wifi as in the elegantota ) .. Is it more clear now ? Thanks however for your patience
The ESP32 hosts the "Web Server", which only supports this one URL for uploading the data via a direct HTTP Post request (no Web UI).
You can push an update to an ESP32 device with the exact same command PlatformIO is instructed to use -- just curl
the new firmware binary to the device. This does not require PlatformIO.
@maxgerhardt I start to undertstand now maybe. First i deplyìoy the fw with this file
`[platformio] default_envs = esp32dev
[env:esp32dev] platform = espressif32 board = esp32dev framework = arduino lib_deps = ArduinoOTA=https://github.com/jandrassy/ArduinoOTA.git Ethernet=https://github.com/maxgerhardt/Ethernet.git
[env:esp32dev_ota] platform = espressif32 board = esp32dev framework = arduino lib_deps = ArduinoOTA=https://github.com/jandrassy/ArduinoOTA.git Ethernet=https://github.com/maxgerhardt/Ethernet.git
extra_scripts = post:extra_scripts.py upload_protocol = custom upload_flags = http://arduino:password@192.168.1.237:65280/sketch`
then when i want to update the fw i change the code for sure but moreover i change the .ini in this way
[``` platformio] default_envs = esp32dev
[env:esp32dev] platform = espressif32 board = esp32dev framework = arduino lib_deps = ArduinoOTA=https://github.com/jandrassy/ArduinoOTA.git Ethernet=https://github.com/maxgerhardt/Ethernet.git
[env:esp32dev_ota] platform = espressif32 board = esp32dev framework = arduino lib_deps = ArduinoOTA=https://github.com/jandrassy/ArduinoOTA.git Ethernet=https://github.com/maxgerhardt/Ethernet.git
extra_scripts = post:extra_scripts.py upload_protocol = custom upload_flags = http://arduino:passwordnew@ipaddressdiscovered:65280/firmware.bin
then i connect my laptop to the same network of the esp32 and from the command line i type
(only requisite is that curl is installed)
`curl --request POST --data-binary @"C:\Users\Maxi\Desktop\esp32_eth_ota\.pio\build\esp32dev_ota\firmware.bin" http://arduino:passwordnew@ipaddressdiscovered:65280/firmware.bin`
Is it correct this procedure ?
Thanks a lot @maxgerhardt
Yes, that's correct.
You are my hero you know that @maxgerhardt
@maxgerhardt maybe I am doing some mistakes I am getting not found
C:\Users\simone.gasparella>curl --request POST --data-binary @"C:\Users\simone.gasparella\Documents\firmware.bin" http://systel:lab2022@192.168.0.46:65280/firmware.bin Not Found
Here there is the code main.cpp
#include <Arduino.h>
#include <SPI.h>
#include <Ethernet.h>
#include "Ethernet_pinout_setting.h"
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <ArduinoOTA.h>
SPIClass ethernetSPI(ETH_SPI_BUS);
EthernetServer server(80);
/**
* @brief Function to execute the setup generated by the arduino framework
* @param None
* @retval None
*/
void setup()
{
Ethernet.init(ETH_CS, ðernetSPI, ETH_SCLK, ETH_MISO, ETH_MOSI);
Serial.begin(115200);
while (!Serial)
{
; // wait for serial port to connect. Needed for native USB port only
}
Ethernet.begin(mac);
// Check for Ethernet hardware present
if (Ethernet.hardwareStatus() == EthernetNoHardware)
{
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
while (true)
{
delay(1); // do nothing, no point running without Ethernet hardware
}
}
if (Ethernet.linkStatus() == LinkOFF)
{
Serial.println("Ethernet cable is not connected.");
}
Serial.print("Joined LAN with IP ");
Serial.println(Ethernet.localIP());
Serial.flush();
delay(200);
Serial.println("HTTP server started");
ArduinoOTA.begin(Ethernet.localIP(), "systel", "lab2022", InternalStorage);
}
/**
* @brief Function to execute the loop of the mqtt connection
* @param None
* @retval None
*/
void loop()
{
ArduinoOTA.poll();
// constantly maintain DHCP ip in the long run
Ethernet.maintain();
}
and here the platformio.ini file ..
[env:esp32dev]
platform = espressif32@3.5.0
board = esp32dev
framework = arduino
monitor_speed = 115200
monitor_filters = esp32_exception_decoder
lib_deps =
https://github.com/maxgerhardt/EthernetENC.git
me-no-dev/AsyncTCP@^1.1.1
me-no-dev/ESP Async WebServer@^1.2.3
jandrassy/ArduinoOTA@^1.0.9
build_flags =
-DCORE_DEBUG_LEVEL=5
-Iinclude
[env:esp32dev_ota]
platform = espressif32@3.5.0
board = esp32dev
framework = arduino
lib_deps =
https://github.com/maxgerhardt/EthernetENC.git
me-no-dev/AsyncTCP@^1.1.1
me-no-dev/ESP Async WebServer@^1.2.3
jandrassy/ArduinoOTA@^1.0.9
extra_scripts = post:extra_scripts.py
upload_protocol = custom
upload_flags =
http://systel:lab2022@192.168.0.46:65280/firmware.bin
build_flags =
-DCORE_DEBUG_LEVEL=5
-Iinclude
and this is the output of the terminal window in monitor debug
Joined LAN with IP 192.168.0.46
HTTP server started
@maxgerhardt If i try to use from platformio
pio run -e esp32dev_ota -t upload -v
i got this
upload_flags =
http://systel:lab2022@192.168.0.46:65280/firmware.bin
Is wrongly indented, you are setting it to an empty value that way. You have to either put at least two spaces in front of the value or put it on the same line.
upload_flags = http://systel:lab2022@192.168.0.46:65280/firmware.bin
@maxgerhardt sometimes it is trivial than was expected
@maxgerhardt from platformio ok it is working but from cmd still I have this
That's weird. curl --version
outputs what? dir C:\Users\simone.gasparella\Projects\ethernet_update_fw_esp32\.pio\build\esp32dev_ota\firmware.bin
outputs what?
If i type
C:\Users\simone.gasparella\Projects\ethernet_update_fw_esp32.pio\build\esp32dev_ota\firmware.bin
I open the binary file
Maybe it needs to write a temp file and C:\Windows\System32\
is not the best place to do that. And actually, I don't see why that cmd.exe would need to be started with admnistrator rights. Can you open the shell normally? (Windows+R -> cmd.exe)
Then try the command
curl --request POST --data-binary "@C:\Users\simone.gasparella\Projects\ethernet_update_fw_esp32\.pio\build\esp32dev_ota\firmware.bin" "http://systel:lab2022@192.168.0.46:65280/sketch"
I also just noticed you use the target URL /firmware.bin
, which is weird. The original code uses /sketch
as the target URL.
And it hthe old firmware.bin target URL?
curl --request POST --data-binary "@C:\Users\simone.gasparella\Projects\ethernet_update_fw_esp32\.pio\build\esp32dev_ota\firmware.bin" "http://systel:lab2022@192.168.0.46:65280/firmware.bin"
Also double check that username + password are correct.
username and password are always the same as you saw in the code
really don't understand
Can you flash the original firmware again via USB and then try the curl
command on the console? Maybe the OTA update didn't work properly.
Also, please try
curl --request POST --data-binary @C:\Users\simone.gasparella\Projects\ethernet_update_fw_esp32\.pio\build\esp32dev_ota\firmware.bin "http://systel:lab2022@192.168.0.46:65280/firmware.bin"
ok i flash the esp32_dev with usb e try again on cmd.exe
But uploading with PlatformIO still works?
I tried again with platformio and I got this
Also you're still using an administrator cmd.exe, try starting it without admin rights.
without admin rights
from cli platformio
Can you open a Powershell and try the previous commands you used in the cmd
? Maybe it behaves differently.
Ah, powershell has its own implementation of curl
that doesn't actually go to the curl
you installed.
so what could I do ?
Instead of curl
write the full path to curl
as obtained by the where curl
command.
so How the command change
Aha, why are 2 curls installed?
Well you can try
& 'C:\Program Files\cURL\bin\curl.exe' --request POST --data-binary @C:\Users\simone.gasparella\Projects\ethernet_update_fw_esp32\.pio\build\esp32dev_ota\firmware.bin "http://systel:lab2022@192.168.0.46:65280/firmware.bin"
/sketch
as URL?Not sure what's going on there -- if the command works in PIO it should work in the shell if the same shell + program + arguments are used.
Maybe I'll have time this weekend to look at things.
Meanwhile try sending the POST request using anotherprogram, like "Postman" (https://stackoverflow.com/a/50531746/5296568).
@maxgerhardt Thanks a lot .. I really appreciate if you have time to check this weekend.. Thanks a gain
@maxgerhardt even thought i see this
I have tried to turn on a led in the update fw... Nothing to do,.. it is not updating the fw
Will it fail in PIO if you use the /sketch
URL?
where I have to change with the /sketch
?
success but not update i changed just here upload_flags = http://systel:lab2022@192.168.0.46:65280/sketch
Hi @maxgerhardt Does this example work also in case of ethernet shield enc28j60 ?
Thnaks a lot