I'm using an M5Stack Core2 and have been writing programs on Arduino for it and hadn't had a problem until now. Out of the blue I have this error, I'm not sure how to solve it. I've already tried pip install esptool but didn't work. The only thing that changed between this and the last time that compiled successfully is that I upgraded pip and increased my PC memory (I can't see how this could possibly cause this error, but I'm still mentioning it because you never know).
The board manager from M5Stack appears to have been updated just 24 hours ago, and the new version (2.0.6) requires esptool_py 4.2.1, whereas the previous version (2.0.5-1.0) requires 3.3.0. Is there any chance that you updated the board manager accidentally? If it was the case, reverting the board manager back to an older version might workaround the issue.
I personally did not have this issue and am not really sure if it helps. But, at least, I noticed package_m5stack_index.json was updated almost at the same time as you started to experience the issue (the response header said Last-Modified: Thu, 11 May 2023 16:12:09 GMT), and it seemed logical to me to hypothesize the latest version might have caused some issue to you.
Thank you for the response, I'll revert to an older version of the board manager and see if that can fix the issue. Would another solution be updating esptool_py to 4.2.1 (although I think I already installed it in my computer, after the issue appeared which would download the latest version I believe, unless I have to install it somewhere else? I'm not sure)?
I myself have been using https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json, not the one released by M5Stack, which is the reason why I am not affected by this issue. I do not know the pros and cons of both options, but it is just the way I am happy with for a long time. You may follow the same path if it makes sense to you.
Just now, I tried to update the board manager from EXPRESSIF to 2.0.9 and the one from M5Stack to 2.0.6. Both worked successfully, and the necessary toolset was installed automatically in the location below. Compliation worked as well. You may want to clean up the environment and reinstall it, hoping the issue you experienced was temporary and might have been fixed by now.
This issue is most likely caused by the M5Stack board manager.
If the official response to the problem is addressed, the post#5 response may be unnecessary or may cause a new problem.