Updated Compiling the Firmware (markdown)

rstrouse 2023-02-27 11:40:31 -08:00
parent dd9f600e4f
commit 6d8e77c2d4
2 changed files with 68 additions and 36 deletions

@ -1,36 +0,0 @@
I developed this using the painfully awful Arduino IDE v1.8. I originally installed v2.0 then found out you cannot upload the file data to it. Download v1.8 (legacy) and save yourself several hours of searching through forums for functions that are not supported on 2.0 even several years after its release. If you are using VS Code then you are on your own since I don't have any experience with it. The good news is that you only need this during the initial install and all follow on work for the module is user friendly.
Did I mention that you shouldn't waste your time on Arduino IDE v2.0. As of January 2023, it is incomplete, and it exists only for tortured souls in search of a never realized promise. Don't do it you will be disappointed. If this situation improves I will be back to update my recommendations.
First compile and upload the firmware to the ESP32. Then upload the data using the Sketch Data upload tool. You will be happy to know that once the initial install is done you don't have to go through all these hoops to update the firmware or the LittleFS file system if you are using an ESP32S-WROOM-32 module. I created a utility that is part of the software to do this task but it is a chicken/egg thing where you need the hen on the ESP32 to hatch the egg. You can install the future firmware and the applicaton files remotely. So you can put the ESPSomfy RTS module into a remote location.
# Prerequisites
You must first install the Arduino IDE v1.8 which you will find on the [Arduino Software Site](https://www.arduino.cc/en/software). Install what they call the `Legacy IDE` for the platform you are developing on. Then follow the instructions to configure it for your ESP32 board. Make sure you use a ***USB data cable*** not one of the ones that is only for charging. If you cannot connect to your ESP32 then this is likely the problem.
To compile the firmware you will need to include four libraries. To install them, navigate to `Sketch` -> `Install Library`. Some of these libraries may be installed by default when you installed the Arduino IDE. They are listed below in the least likelihood of being installed already.
The libraries include:
* SmartRC-CC1101-Driver-Lib - Used to configure the transceiver.
* PubSubClient - Used to provide the MQTT interface for integration.
* WebSockets - Used to communicate the state of the shades over a websocket connection.
* ArduinoJson - JSON serializer and deserializer.
# LittleFS
This project uses the file system on the ESP32. Follow the instructions found here to set up your Arduino IDE so it can upload the files to your board. Why this isn't just part of the Arduino development suite is a mystery but I guess that is why it is called hacking.
[LittleFS Plugin](https://github.com/lorol/arduino-esp32littlefs-plugin)
# Compile and Upload
Once you have set up the environment press the arrow button at the top left of the Arduino IDE and it will begin compiling the software then upload when it is done. Bear in mind that this takes a bit of time to compile. If it is successful it will show in the console area at the bottom of the IDE.
# Upload the File System
All of the files required to build the file system are included in the `/data/` directory of the repository. When you click on the menu `Tool` -> `ESP32 Sketch Data Upload` it will compress these files into the file system layout and upload it to the ESP32. If you have the Serial Monitor open, close it before you perform this operation as it will fail if it is open.
The good news is that it will give you some innocuous message about how the port is busy. So you don't do something silly like shut everything down, open the serial monitor and try it repeatedly.
Once you have completed compiling and uploading the sketch you are done with the arduous part. Hopefully you have not spent all your F-Bombs on this process and have some left for bombing other targets. I am seeking easier ways so if you have a suggestion feel free to open an issue describing it.

@ -0,0 +1,68 @@
There are two (actually 3 but the third method uses the command line) methods you can use to upload the initial firmware to your device. Both of them are a bit technical but not insurmountable. If you develop software on ESP devices then you probably already have the Arduino IDE v1.8 software installed on your computer. If you do not then choose the ESP32 flash download tool method as it is fairly straight forward. I didn't ask him to try, but think that even the hairy dude from the Geico commercials can get this done.
# Using ESP32 Flash Download tool
The flash download tool is probably the most straight forward way to onboard your new ESPSomfy RTS device. Depending on the device you have chosen, you may need to set the device into download mode. For instance, the WT32-ETH01 requires a jumper between the IO0 and ground before uploading any firmware to it. So check your documentation and set the board appropriately.
For those of you using a regular ESP32S device then you do not need to set any jumpers. The chip select will be controlled by the software.
There are two files attached to every release in this repository. These are `SomfyController.ino.esp32.bin` and `SomfyController.littlefs.bin`. Download both of these files to your computer somewhere. These files are located on this repository under releases on the right side of the main page.
![image](https://user-images.githubusercontent.com/47839015/221660466-ab827cf1-4bfe-4e4d-8b5a-5b1245544a53.png)
Download the ESP32 Flash Download tool from the Espressif website. https://www.espressif.com/en/support/download/other-tools
This tool only works in Windows but I suspect that if you are on a Linux environment you will be using the other method anyway. For you Mac users, I just dunno... yet. If you have some variant on how to get this done when a user has five thumbs on each hand let me know.
Once you download the zip file extract it to a directory. In this newly extracted directory you will find an executable file named for the version you downloaded. I downloaded version 3.9.4 so run the `flash_download_tool_3.9.4.exe` file.
A window will appear asking for a ChipType. Choose ESP32-D2WD and leave the rest of the settings alone. Then press OK. At the top of the next screen check the top two file checkboxes. Then click the `...` next to the top one and select the file `SomfyController.ino.esp32.bin` file from the location where you downloaded it to. In the `@` box next to it enter `0x1000`. In the second line choose the `SomfyController.littlefs.bin` file from its location and enter `0x290000` in the `@` box. The download tool will have two entries in this like below.
![image](https://user-images.githubusercontent.com/47839015/221662265-3dfcdfeb-1482-4b2a-b876-8ca864330252.png)
Next choose the COM port from the dropdown. If you do not know which COM port the device is on, unplug the USB port and see which one goes away from the dropdown. Then plug it back in and use that one. You do not need to change any of the other values. Once you have selected the COM Port press the start button and the firmware will start flashing to your device.
![image](https://user-images.githubusercontent.com/47839015/221664147-39ef28da-e6c4-43a9-af7e-fb168fd06471.png)
If you receive an error then double check to ensure you have set the board to download mode using whatever jumper or voodoo chant required to get the board to accept firmware. If you are sure you have done this correctly, then the next most likely issue is the cable you are using. There are a ton of cables out there that are charge only. This means they are not capable of sending or receiving data. On the surface you will not be able to tell which is which but I suspect it is cheaper to not include two wires inside the cable.
Once the flash process is complete disconnect any jumpers you have installed to get the device to accept firmware and reboot the device. Then follow the instructions to connect the device to your network in the [Configuring the Software](https://github.com/rstrouse/ESPSomfy-RTS/wiki/Configuring-the-Software) wiki.
You are now free to upload firmware using the included web interface.
# Using Arduiono IDE v1.8
I developed this using the painfully awful Arduino IDE v1.8. I originally installed v2.0 then found out you cannot upload the file data to it. Download v1.8 (legacy) and save yourself several hours of searching through forums for functions that are not supported on 2.0 even several years after its release. If you are using VS Code then you are on your own since I don't have any experience with it. The good news is that you only need this during the initial install and all follow on work for the module is user friendly.
Did I mention that you shouldn't waste your time on Arduino IDE v2.0. As of January 2023, it is incomplete, and it exists only for tortured souls in search of a never realized promise. Don't do it you will be disappointed. If this situation improves I will be back to update my recommendations.
First compile and upload the firmware to the ESP32. Then upload the data using the Sketch Data upload tool. You will be happy to know that once the initial install is done you don't have to go through all these hoops to update the firmware or the LittleFS file system if you are using an ESP32S-WROOM-32 module. I created a utility that is part of the software to do this task but it is a chicken/egg thing where you need the hen on the ESP32 to hatch the egg. You can install the future firmware and the applicaton files remotely. So you can put the ESPSomfy RTS module into a remote location.
# Prerequisites
You must first install the Arduino IDE v1.8 which you will find on the [Arduino Software Site](https://www.arduino.cc/en/software). Install what they call the `Legacy IDE` for the platform you are developing on. Then follow the instructions to configure it for your ESP32 board. Make sure you use a ***USB data cable*** not one of the ones that is only for charging. If you cannot connect to your ESP32 then this is likely the problem.
To compile the firmware you will need to include four libraries. To install them, navigate to `Sketch` -> `Install Library`. Some of these libraries may be installed by default when you installed the Arduino IDE. They are listed below in the least likelihood of being installed already.
The libraries include:
* SmartRC-CC1101-Driver-Lib - Used to configure the transceiver.
* PubSubClient - Used to provide the MQTT interface for integration.
* WebSockets - Used to communicate the state of the shades over a websocket connection.
* ArduinoJson - JSON serializer and deserializer.
# LittleFS
This project uses the file system on the ESP32. Follow the instructions found here to set up your Arduino IDE so it can upload the files to your board. Why this isn't just part of the Arduino development suite is a mystery but I guess that is why it is called hacking.
[LittleFS Plugin](https://github.com/lorol/arduino-esp32littlefs-plugin)
# Compile and Upload
Once you have set up the environment press the arrow button at the top left of the Arduino IDE and it will begin compiling the software then upload when it is done. Bear in mind that this takes a bit of time to compile. If it is successful it will show in the console area at the bottom of the IDE.
# Upload the File System
All of the files required to build the file system are included in the `/data/` directory of the repository. When you click on the menu `Tool` -> `ESP32 Sketch Data Upload` it will compress these files into the file system layout and upload it to the ESP32. If you have the Serial Monitor open, close it before you perform this operation as it will fail if it is open.
The good news is that it will give you some innocuous message about how the port is busy. So you don't do something silly like shut everything down, open the serial monitor and try it repeatedly.
Once you have completed compiling and uploading the sketch you are done with the arduous part. Hopefully you have not spent all your F-Bombs on this process and have some left for bombing other targets. I am seeking easier ways so if you have a suggestion feel free to open an issue describing it.