For M5Camera, please change pins definition in /src/internal/pins.hpp by
This library wraps esp32-camera library in object oriented API. It has been tested with M5Camera ESP32-CAM board and OV2640 camera.
In ESP32 Arduino, the board type should be set to "ESP32 WROVER" to enable 4MB external PSRAM. Otherwise, internal RAM is insufficient to support high resolution.