Closes https://github.com/espressif/esp-idf/issues/2965 (cherry picked from commit 66e38e9bac)
66e38e9bac
Closes https://github.com/espressif/esp-idf/issues/3011 (cherry picked from commit ce4944edf01b2a4c997eafe36b66d71f98f2fe29) (cherry picked from commit 76e4ea7f68)
76e4ea7f68