-
Notifications
You must be signed in to change notification settings - Fork 16
LoLin NodeMCU V3 ESP8266 requires header patching #103
Comments
This is how ESPTool is currently detecting the crystal frequency (https://github.com/espressif/esptool/blob/ded13e025628d4c5ca350378b391e9b0d38bcb57/esptool.py#L1223),
|
I don't have enough knowledge to understand how crystal speed comes into play with flashing. |
Okay I will try to study that and clarify what's really happening with the crystal frequency and the flashing modes. But regardless of the deeper relationship, isn't getting the flashing mode as a parameter from esp-web-tools and then passing to the function which were existing earlier a straightforward fix? |
We don't want to ask the user about the crystal speed of their device, it should be automatically detected. ESP Web Tools and ESP Web Flasher shouldn't do any header patching anymore. The developer putting up the website with ESP Web Tools should create the correct firmware versions. ESP Web Tools does the selecting based on data provided by ESP Web Flasher. It could probably become a new property for the builds specified in |
I respectfully disagree, I think the 'Flashing mode' should be handled by the 'flashing tool' and not the 'firmware compilation' tool and hence both ESPTool & Adafruit's ESP tool does the patching.
I don't think that's even possible, If so esp-sdks which compiles the firmware would have done that and wouldn't be handled during flashing like I mentioned above. I think this was not brought before in earlier discussions on this subject(#83, esphome/esp-web-tools#151) because the users were using ESP32 and the current default flashing mode works for them i.e. No one is supplying different firmware versions based on the crystal now. |
Maybe I misunderstand, but this is not about 'flashing mode' but about flashing the correct bootloader? ESP Web Flasher has no knowledge if something is a bootloader. It just flashes what it is told to flash. It's up to the tool using ESP Web Flasher to provide the right files (in your case ESP Web Tools). Now ESP Web Tools doesn't generate/patch any files either but instead relies on the manifest file to point at the right data for each ESP variation. |
The misunderstanding is because unlike ESP32, the bootloader is not flashed separately(it's not a multi-stage) for ESP8266(It's a single firmware.bin as in the manifest for ESP Web Tools) and header patching 4th byte to 0x20 was done to set the 'Flashing Mode' to DIO and 'Flashing Speed' to 40 Mhz(40m). More information about the flashing modes can be found here and here. During the earlier discussion(#83) @TD-er raised concern that removing header patching could affect ESP82666 boards but wrongly concluded that all ESP boards after 2017 doesn't use this flashing mode as they don't contain 26 MHz crystal; That might be the case with ESP32 but not with ESP8266. My board uses the latest revision of ESP8266 i.e. ESP8266EX so it's likely that removal of header patching prevents all recent ESP8266 boards from being flashed by esp-web-flasher. |
I have not seen ESP8266 boards using a crystal other than 26 MHz (as far as I can remember), so building for 26 MHz crystal should work on (almost?) all boards out there. I am not entirely sure whether the web flasher should patch it, but on the other hand esptool.py and the Espressif download tool patch it. (Espressif download tool has a flag to no change the bin to disable this) |
Is this true for ESP8266 as well? I'm using micropython and only ESP32 seems to accept XTAL as a config option (micropython/micropython@f431795),
My reasoning is that a developer doesn't have access to all available boards for a particular microcontroller and so the flashing tool takes care of the messy bits. Espressif knows if there's a new board with X frequency and so they just update their tool. Now esp-web-flasher being a flashing tool as well, In theory one might expect it behave similar to Espressif's tools.
No my boards are 26MHz and hence I ran into the reset loop as there's no header patching in latest version and had to use v4.0.0. |
Sure, but my point is that if there is only 1 crystal frequency for all ESP8266 boards, then the bin files should be made for 26 MHz and thus no patching is needed. If there are multiple crystal frequencies, then the flash tool should at least be able to detect the frequency and either pick the right one, or patch it, or fail to flash with a proper error message. |
That's a reasonable assessment from your position.
But are we 100% certain that this is the case? Besides projects like micropython depend upon the flashing tool for patching and doesn't expect the average developer to build the firmware(let alone setting the correct crystal frequency, which I haven't found yet). So web flashing using esp-web-flasher is out of the scope for such developers and projects now. I have found at least one project using esp-web-tools(6.1.1) in the wild to flash official micropython build to ESP8266, Now they have to resort to building custom micropython firmware with hard coded crystal frequency if that's possible. Removing header patching has made the barrier for entry much higher for using esp-web-tools. |
Your conclusion is incorrect. Header patching was removed because it was breaking installs and causing a high barrier. Instead of developers relying on magic in ESP Web Flasher, we prefer developers create the right images and we can help with the selection process. |
I didn't mean the issue which caused ESP32 devices from being flashed correctly shouldn't be fixed, I meant the solution for fixing it has increased barrier for entry i.e. developers should know how to build custom firmware to use esp-web-tools. |
ESP Web Tools is meant for firmware creators to help users install and update devices. Creating custom builds is what firmware creators do? I guess MicroPython is the only exception here as it's a generic platform. |
Disclaimer: I myself use esp-web-tools to flash my custom micropython firmware to my customers device. That said, I see scenarios where people would like to flash a generic firmware to their customer devices to offer other services like education(IDE), configuration(IoT) etc.
There are at least about dozen such generic firmwares.
No contention there, It's your choice as a project maintainer. |
I do not understand what the problem is. Since the header patching was removed we had not a single user of Tasmota complaining that the flashed firmware is NOT working. |
@Jason2866 Can you check the crystal frequency of the "esp8266 Tasmota variant" you are using with the latest version of this tool? |
Which tool? |
Sorry, I'll rephrase; What's the crystal frequency of the esp8266 board you're able to flash successfully after the header patching was removed in esp-web-flasher. |
26MHz Just flash Tasmota and it will work https://arendst.github.io/Tasmota-firmware/ |
If it does not work for you have either a very! rare board with 40Mhz and builded the firmware without setting the crystal speed to 40Mhz. It is no problem to flash this firmware with webflasher too. Just do a extra manifest and provide the according firmware. |
Flashing Tasmota firmware through that website on the board in question(LoLin NodeMCU Lua V3) works fine, The flashing mode (DIO) seems to have been set in the firmware itself during compilation(likely via PlatformIO) as @TD-er mentioned earlier. Unfortunately PlatformIO doesn't support Micropython(I'm using esp-open-sdk to build mine) and I haven't figured out a way for setting the flashing mode during firmware compilation if that's possible. So for those in my position, Using esp-web-flasher v4.0.0 is the temporary solution. |
Thats the point. Your platform generating the firmware has to generate a valid firmware for flashing. Do not expect other tools fixes issues caused by a tool generating a faulty firmware. |
That's harsh and inaccurate.
|
At least your title of this opened issue is not correct. Patching is NOT required. |
Going to close this as it's not a ESP Web Flasher issue and should be fixed when firmware created. |
Greetings developers & contributors.
Header patching was removed(598c556) as it was perceived to be useless for ESP32 boards but ESP8266 boards like LoLin NodeMCU V3 uses 26MHz crystal(Including latest ones) and so without header patching the flashing results in reset loop when using esp-web-tools.
Allowing user to set the right flashing mode is perhaps the correct way to go regarding this, But for that to happen esp-web-flasher needs to accept the parameters and execute the patching as it was in version 4.0.0 and prior. Then esp-web-tools could possibly call esp-web-flasher with the correct flashing mode(esphome/esp-web-tools#186) from user input.
Considering ESP8266 continues to be most accessible and affordable development board and its likely to remain that way for next few years due to semiconductor shortage & shipping issues; I think accepting flashing mode from user would be a valuable addition.
The text was updated successfully, but these errors were encountered: