#!/bin/bash # Fix esp_psram compatibility for ESP-IDF v4.4 GNUBOY_DIR=~/Arduino/gameboy/gnuboy echo "Fixing esp_psram compatibility issues..." # 1. Fix components/gnuboy/CMakeLists.txt echo "Patching components/gnuboy/CMakeLists.txt..." sed -i 's/esp_psram/esp_hw_support/g' "$GNUBOY_DIR/components/gnuboy/CMakeLists.txt" # 2. Fix main/CMakeLists.txt echo "Patching main/CMakeLists.txt..." sed -i 's/esp_psram/esp_hw_support/g' "$GNUBOY_DIR/main/CMakeLists.txt" # 3. Fix main/main.c echo "Patching main/main.c..." sed -i 's/#include "esp_psram.h"/#include "esp_heap_caps.h"\n#include "esp32s3\/spiram.h"/g' "$GNUBOY_DIR/main/main.c" sed -i 's/esp_psram_is_initialized()/esp_spiram_is_initialized()/g' "$GNUBOY_DIR/main/main.c" sed -i 's/esp_psram_get_size()/esp_spiram_get_size()/g' "$GNUBOY_DIR/main/main.c" #4 Fix sdkconfig cat >> sdkconfig << 'EOF' CONFIG_ESP32S3_SPIRAM_SUPPORT=y CONFIG_SPIRAM=y CONFIG_SPIRAM_MODE_OCT=y CONFIG_SPIRAM_TYPE_AUTO=y EOF echo "Done! Now run:" echo " cd $GNUBOY_DIR" echo " rm -rf build sdkconfig" echo " source ~/esp-idf/export.sh" echo " idf.py set-target esp32s3" echo " idf.py build"