menu "Espressif ELF Loader Configuration"
    visible if (IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32C6 || IDF_TARGET_ESP32P4 || IDF_TARGET_ESP32C61)

    config ELF_LOADER_BUS_ADDRESS_MIRROR
        bool
        default y if (IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3)
        default n if (IDF_TARGET_ESP32C6 || IDF_TARGET_ESP32P4 || IDF_TARGET_ESP32C61)

    config ELF_LOADER
        bool "Enable Espressif ELF Loader"
        default y
        depends on (IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32C6 || IDF_TARGET_ESP32P4 || IDF_TARGET_ESP32C61)
        help
            Select this option to enable ELF Loader and show the submenu with ELF Loader configuration choices.

    if ELF_LOADER
        config ELF_DYNAMIC_LOAD_SHARED_OBJECT
            bool "Enable dynamic load shared object"
            default n
            help
                Select this option to enable dynamic loading of shared objects (.so files) at runtime.

        config ELF_FILE_SYSTEM_BASE_PATH
            string "File-system base path"
            depends on ELF_DYNAMIC_LOAD_SHARED_OBJECT
            default "/storage"
            help
                Specify the base path for the file system where ELF files and shared objects are stored.
                This path will be used as the root directory for loading ELF binaries.
                Default is "/storage".

        config ELF_LOADER_CACHE_OFFSET
            bool
            default n
            help
                Select this option if D-cache and I-cache has different offset to access the same physical address.

        config ELF_LOADER_SET_MMU
            bool
            default n
            help
                Select this option if D-cache and I-cache are not symmetric.

        config ELF_LOADER_LOAD_PSRAM
            bool "Load ELF to PSRAM"
            default y
            depends on (IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32P4 || IDF_TARGET_ESP32C61) && SPIRAM
            select ELF_LOADER_CACHE_OFFSET if (IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3)
            select ELF_LOADER_SET_MMU if IDF_TARGET_ESP32S2
            help
                Load ELF file into PSRAM instead of internal SRAM.

        menu "ELF Symbols Table"

            config ELF_LOADER_LIBC_SYMBOLS
                bool "Libc Symbols Table"
                default y

            config ELF_LOADER_ESPIDF_SYMBOLS
                bool "ESP-IDF Symbols Table"
                default y

            config ELF_LOADER_CUSTOMER_SYMBOLS
                bool "Customer Symbols Table"
                default n

            config ELF_LOADER_NUMBER_SYMBOLS
                int "Maximum Number of registered symbol tables"
                range 1 4096
                default 32
                help
                    This configuration is the maximum number of registered symbol tables,
                    which can be configured according to the number of embedded ELF applications
        endmenu
    endif
endmenu
