As a start, you can install esp-idf following these
instructions. For now select esp-idf version 4.3.3, this is virtually the same as v 4.3.2 tested with fpcupdeluxe. The newer release 4.4 should also work, but was not tested as much.
Then build the blink example in the esp-idf/examples/get-started/blink for esp32, starting with one of the preconfigured
ESP-IDF 4.3 CMD or
ESP-IDF 4.3 PowerShell shortcuts to configure the environment. Use the build command
idf.py build.
Copy all the libraries in the examples\get-started\blink\build\esp-idf folder into a separate
blink\build\libs folder (an easy way is to open the blink\build\esp-idf folder in file explorer, search for *.a, copy the search results into a folder named
blink\build\libs).
Also copy the following files (used later to flash the bootloader and flash partition scheme) into libs:
blink\build\bootloader\bootloader.bin
blink\build\partition_table\partition-table.bin
And these files to
libs:
blink\build\esp-idf\esp32\esp32_out.ld
blink\build\esp-idf\esp32\ld\esp32.project.ld
blink\build\config\sdkconfig.h
Copy other libraries from the esp-idf\components folder (for my install settings : C:\Espressif\frameworks\esp-idf-v4.3.3\components) to
libs:
components\esp_wifi\lib\esp32\*.a
components\xtensa\esp32\libxt_hal.a
Now modify the
CPULX6 section in fpc.cfg to point to this new libs folder. Also change some other settings to point to the Espressif installed bin tools and point the compiler to the esp-idf folder:
#IFDEF CPULX6
-Cfhard
-FDC:\Espressif\tools\xtensa-esp32-elf\esp-2021r2-patch3-8.4.0\xtensa-esp32-elf\bin
-XPxtensa-esp32-elf-
-Wpesp32
-FlC:\fpcupdeluxe\cross\lib\xtensa-freertos\lx6\
-WP4.3.3
# Library paths to GCC supplied libraries
-FlC:\Espressif\tools\xtensa-esp32-elf\esp-2021r2-patch3-8.4.0\xtensa-esp32-elf\lib\gcc\xtensa-esp32-elf\8.4.0\no-rtti
-FlC:\Espressif\tools\xtensa-esp32-elf\esp-2021r2-patch3-8.4.0\xtensa-esp32-elf\xtensa-esp32-elf\lib\no-rtti
# Custom folder with esp-idf libs
-FlC:\Espressif\frameworks\esp-idf-v4.3.3\examples\get-started\blink\build\libs
# Set path to esp-idf root
-FfC:\Espressif\frameworks\esp-idf-v4.3.3
#ENDIF CPULX6
Note that these folders are specific to my esp-idf installation, adjust as necessary for your installation.
This is obviously a lot of work and easy to miss a file required for successful compilation and linking in FPC. I am busy writing a batch script to automate this process and build a release that can be installed by fpcupdeluxe, but it will be a couple of days to get all of this sorted out.