Ok, it seems that the problem was due to my version of ESP32 tools. I updated my ESP32 framework and now the code is working fine. Also, I used PlatformIO in VSCode which make things simpler since it enables the M5STACK_FIRE flag during compilation.