platformio / platform-espressif32

Espressif 32: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/espressif32
Apache License 2.0
890 stars 600 forks source link

CMake was unable to find a build program corresponding to "Ninja" #511

Closed Kampi closed 3 years ago

Kampi commented 3 years ago

I try to add a ULP code to my existing PlattformIO project. I do the following steps:

ulp.S (no function yet)

#include "soc/rtc_cntl_reg.h"
#include "soc/soc_ulp.h"

CMakeLists.txt (root directory)

cmake_minimum_required(VERSION 3.5)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(PlattformIO)

CMakeLists.txt (src directory)

idf_component_register( INCLUDE_DIRS
                        SRCS
                        "main.cpp" 
                        "application/application.cpp" 
                        )

# The ULP app name must be unique (if multiple components use ULP).
set(ulp_app_name ulp_main)

# Specify all assembly source files.
# Files should be placed into a separate directory (in this case, ulp/), which should not be added to COMPONENT_SRCS.
set(ulp_s_sources "../ulp/ulp.S")

# List all the component source files which include automatically generated ULP export file, ${ulp_app_name}.h:
set(ulp_exp_dep_srcs "main.cpp")

# Call function to build ULP binary and embed in project using the argument values above.
ulp_embed_binary(${ulp_app_name} ${ulp_s_sources} ${ulp_exp_dep_srcs})

main.cpp

#include <Arduino.h>
#include <esp32/ulp.h>
#include <soc/timer_group_struct.h>
#include <soc/timer_group_reg.h>

#ifndef CONFIG_ARDUINO_LOOP_STACK_SIZE
    #define CONFIG_ARDUINO_LOOP_STACK_SIZE          8192
#endif

extern const uint8_t ulp_main_bin_start[]           asm("_binary_ulp_main_bin_start");
extern const uint8_t ulp_main_bin_end[]             asm("_binary_ulp_main_bin_end");

extern "C" void app_main()
{
    DEBUG_INFO("Load ULP program...\n");
    ESP_ERROR_CHECK(ulp_load_binary(0, ulp_main_bin_start, (ulp_main_bin_end - ulp_main_bin_start) / sizeof(uint32_t)));

    ulp_set_wakeup_period(0, 20000);

    DEBUG_INFO("Enter deep sleep...\n");
    ESP_ERROR_CHECK( esp_sleep_enable_ulp_wakeup() );
    esp_deep_sleep_start();
}

plattformio.ini

[platformio]
src_dir = src

[env]
board = esp32dev
board_build.partitions = other/partitions.csv

platform = espressif32
framework = arduino, espidf

upload_speed = 921600
upload_port = COM9

monitor_speed = 115200
monitor_port = COM9

platform_packages =
    framework-arduinoespressif32@https://github.com/espressif/arduino-esp32.git#idf-release/v4.0 

[common]
build_flags =
    -D APP_VERSION=1.0.0
    -D CONFIG_ARDUHAL_ESP_LOG

lib_deps_builtin =

lib_deps_external =
    mcci-catena/MCCI LoRaWAN LMIC library@^3.3.0

[env:debug]
build_type = debug

build_flags =
    ${common.build_flags}
    -D DEBUG
    -D ENABLE_DEBUG_PRINT

lib_deps =
    ${common.lib_deps_builtin}
    ${common.lib_deps_external}

I got the following message during compilation:

Processing debug (board: esp32dev; platform: espressif32; framework: arduino, espidf)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (3.1.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 0.0.0+sha.d011dd7
 - framework-espidf 3.40001.200521 (4.0.1)
 - tool-cmake 3.16.4
 - tool-esptoolpy 1.30000.201119 (3.0.0)
 - tool-idf 1.0.1
 - tool-mconf 1.4060000.20190628 (406.0.0)
 - tool-ninja 1.9.0
 - toolchain-esp32ulp 1.22851.191205 (2.28.51)
 - toolchain-xtensa32 2.80400.210211 (8.4.0)
Reading CMake configuration...
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 1 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <MCCI LoRaWAN LMIC library> 3.3.0
Building in debug mode
Generating ULP configuration
CMake Error at C:/.../.platformio/packages/tool-cmake/share/cmake-3.16/Modules/CMakeDetermineSystem.cmake:99 (message):
  Could not find toolchain file:
  C:\...\.platformio\packages\framework-espidf\components\ulp\cmake\toolchain-esp32-ulp.cmake
Call Stack (most recent call first):
  CMakeLists.txt:4 (project)

CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMAKE_ASM_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
Compiling .pio\build\debug\app_trace\host_file_io.o
Compiling .pio\build\debug\app_trace\gcov\gcov_rtio.o
Compiling .pio\build\debug\app_update\esp_ota_ops.o
Compiling .pio\build\debug\app_update\esp_app_desc.o
Compiling .pio\build\debug\asio\asio\asio\src\asio.o
Compiling .pio\build\debug\bootloader_support\src\bootloader_clock.o
Compiling .pio\build\debug\bootloader_support\src\bootloader_common.o
*** [.pio\build\debug\esp-idf\src\ulp_main\build.ninja] Error 1

Edit

It is working with espressif32@1.12.4. The difference between both releases is that 1.12.4 is using tool-esptoolpy 1.20600.0 (2.6.0) and toolchain-xtensa32 2.80200.200827 (8.2.0). So the issue comes from one of these tools.

What´s wrong here?

valeros commented 3 years ago

Hi @Kampi ! Does this C:\...\.platformio\packages\framework-espidf\components\ulp\cmake\toolchain-esp32-ulp.cmake file exist?