aws / amazon-freertos

DEPRECATED - See README.md
https://aws.amazon.com/freertos/
MIT License
2.54k stars 1.1k forks source link

[BUG] idf.py monitor will error occur #3508

Closed misupopo closed 2 years ago

misupopo commented 2 years ago

I followed the steps of the AWS docs to build. However, when I run "idf.py monitor", I get the following error.

Is this a bug? I proceeded as per the documentation.

■idf.py monitor error

CMake Error at freertos/vendors/espressif/esp-idf/components/esp32/project_include.cmake:21 (message):
  Internal error, toolchain has not been set correctly by project (or an
  invalid CMakeCache.txt file has been generated somehow)
Call Stack (most recent call first):
  freertos/vendors/espressif/esp-idf/tools/cmake/build.cmake:312 (include)
  freertos/vendors/espressif/esp-idf/tools/cmake/build.cmake:457 (__build_process_project_includes)
  freertos/vendors/espressif/boards/esp32/CMakeLists.txt:591 (idf_build_process)
  freertos/CMakeLists.txt:78 (include)

The actual procedure I executed is as follows.

■src/main.c

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"

//extern void esp_vApplicationTickHook();
void IRAM_ATTR vApplicationTickHook()
{
//    esp_vApplicationTickHook();
}

//extern void esp_vApplicationIdleHook();
void vApplicationIdleHook()
{
//    esp_vApplicationIdleHook();
}

void vApplicationDaemonTaskStartupHook( void )
{
}

void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
                                    StackType_t ** ppxIdleTaskStackBuffer,
                                    uint32_t * pulIdleTaskStackSize )
{
    /* If the buffers to be provided to the Idle task are declared inside this
     * function then they must be declared static - otherwise they will be allocated on
     * the stack and so not exists after this function exits. */
    static StaticTask_t xIdleTaskTCB;
    static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];

    /* Pass out a pointer to the StaticTask_t structure in which the Idle
     * task's state will be stored. */
    *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;

    /* Pass out the array that will be used as the Idle task's stack. */
    *ppxIdleTaskStackBuffer = uxIdleTaskStack;

    /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
     * Note that, as the array is necessarily of type StackType_t,
     * configMINIMAL_STACK_SIZE is specified in words, not bytes. */
    *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
}

void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
                                     StackType_t ** ppxTimerTaskStackBuffer,
                                     uint32_t * pulTimerTaskStackSize )
{
    /* If the buffers to be provided to the Timer task are declared inside this
     * function then they must be declared static - otherwise they will be allocated on
     * the stack and so not exists after this function exits. */
    static StaticTask_t xTimerTaskTCB;
    static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];

    /* Pass out a pointer to the StaticTask_t structure in which the Idle
     * task's state will be stored. */
    *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;

    /* Pass out the array that will be used as the Timer task's stack. */
    *ppxTimerTaskStackBuffer = uxTimerTaskStack;

    /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
     * Note that, as the array is necessarily of type StackType_t,
     * configMINIMAL_STACK_SIZE is specified in words, not bytes. */
    *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
}

void app_main()
{
    printf("Hello world!\n");

    for (int i = 10; i >= 0; i--) {
        printf("Restarting in %d seconds...\n", i);
        vTaskDelay(1000 / portTICK_PERIOD_MS);
    }
    printf("Restarting now.\n");
    fflush(stdout);
    esp_restart();
}

■project structure

ls -la
drwxr-xr-x  13 user  staff   416  7  5 15:01 .git
-rw-r--r--   1 user  staff   108  7  5 11:19 .gitmodules
drwxr-xr-x   8 user  staff   256  7  5 17:17 .idea
-rw-r--r--   1 user  staff   547  7  5 15:41 CMakeLists.txt
drwxr-xr-x   7 user  staff   224  7  5 17:18 build
drwxr-xr-x  33 user  staff  1056  7  5 17:17 build-directory
drwxr-xr-x   7 user  staff   224  7  5 15:27 cmake-build-debug
drwxr-xr-x  29 user  staff   928  7  5 15:29 freertos
drwxr-xr-x   3 user  staff    96  7  5 17:17 src

■CMakeLists.txt

cmake_minimum_required(VERSION 3.13)

project(freertos_examples)

# Tell IDF build to link against this target.
set(IDF_EXECUTABLE_SRCS "/Users/user/Documents/test/aws/freeRTOS/original/src/main.c")
set(IDF_PROJECT_EXECUTABLE my_app)

# Add FreeRTOS as a subdirectory. AFR_BOARD tells which board to target.
set(AFR_BOARD espressif.esp32_devkitc CACHE INTERNAL "")
add_subdirectory(freertos)

# Link against the mqtt library so that we can use it. Dependencies are transitively
# linked.
target_link_libraries(my_app PRIVATE AFR::core_mqtt)

■Referenced pages https://docs.aws.amazon.com/ja_jp/freertos/latest/userguide/getting_started_espressif.html#download-and-configure-espressif-idf42

Hardware board: [ ESP32-DevKitC ] Operating System: [ macOS Monterey ver12.3.1 ]

■error log

-- Project sdkconfig file /Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig
Loading defaults file /Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults...
/Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults:21 CONFIG_NIMBLE_ENABLED was replaced with CONFIG_BT_NIMBLE_ENABLED
/Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults:22 CONFIG_NIMBLE_MAX_CONNECTIONS was replaced with CONFIG_BT_NIMBLE_MAX_CONNECTIONS
/Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults:23 CONFIG_NIMBLE_MAX_BONDS was replaced with CONFIG_BT_NIMBLE_MAX_BONDS
/Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults:24 CONFIG_NIMBLE_MAX_CCCDS was replaced with CONFIG_BT_NIMBLE_MAX_CCCDS
/Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults:25 CONFIG_NIMBLE_L2CAP_COC_MAX_NUM was replaced with CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM
/Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults:26 CONFIG_NIMBLE_PINNED_TO_CORE was replaced with CONFIG_BT_NIMBLE_PINNED_TO_CORE
/Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults:27 CONFIG_NIMBLE_ROLE_CENTRAL was replaced with CONFIG_BT_NIMBLE_ROLE_CENTRAL
/Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults:28 CONFIG_NIMBLE_ROLE_PERIPHERAL was replaced with CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
/Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults:29 CONFIG_NIMBLE_ROLE_BROADCASTER was replaced with CONFIG_BT_NIMBLE_ROLE_BROADCASTER
/Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults:30 CONFIG_NIMBLE_ROLE_OBSERVER was replaced with CONFIG_BT_NIMBLE_ROLE_OBSERVER
/Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults:31 CONFIG_NIMBLE_NVS_PERSIST was replaced with CONFIG_BT_NIMBLE_NVS_PERSIST
/Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults:32 CONFIG_NIMBLE_SM_LEGACY was replaced with CONFIG_BT_NIMBLE_SM_LEGACY
/Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults:33 CONFIG_NIMBLE_SM_SC was replaced with CONFIG_BT_NIMBLE_SM_SC
/Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults:34 CONFIG_NIMBLE_DEBUG was replaced with CONFIG_BT_NIMBLE_DEBUG
/Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults:35 CONFIG_NIMBLE_SVC_GAP_DEVICE_NAME was replaced with CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME
/Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults:36 CONFIG_NIMBLE_GAP_DEVICE_NAME_MAX_LEN was replaced with CONFIG_BT_NIMBLE_GAP_DEVICE_NAME_MAX_LEN
/Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults:37 CONFIG_NIMBLE_ATT_PREFERRED_MTU was replaced with CONFIG_BT_NIMBLE_ATT_PREFERRED_MTU
/Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults:38 CONFIG_NIMBLE_SVC_GAP_APPEARANCE was replaced with CONFIG_BT_NIMBLE_SVC_GAP_APPEARANCE
/Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults:39 CONFIG_NIMBLE_ACL_BUF_COUNT was replaced with CONFIG_BT_NIMBLE_ACL_BUF_COUNT
/Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults:40 CONFIG_NIMBLE_ACL_BUF_SIZE was replaced with CONFIG_BT_NIMBLE_ACL_BUF_SIZE
/Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults:41 CONFIG_NIMBLE_HCI_EVT_BUF_SIZE was replaced with CONFIG_BT_NIMBLE_HCI_EVT_BUF_SIZE
/Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults:42 CONFIG_NIMBLE_HCI_EVT_HI_BUF_COUNT was replaced with CONFIG_BT_NIMBLE_HCI_EVT_HI_BUF_COUNT
/Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults:43 CONFIG_NIMBLE_HCI_EVT_LO_BUF_COUNT was replaced with CONFIG_BT_NIMBLE_HCI_EVT_LO_BUF_COUNT
/Users/user/Documents/test/aws/freeRTOS/original/build/sdkconfig.defaults:44 CONFIG_NIMBLE_MESH was replaced with CONFIG_BT_NIMBLE_MESH
/var/folders/lw/ktjk26fn7gv2p8w0jlbw49w00000gn/T/confgen_tmp_tzu3qg0:20 line was updated to CONFIG_BT_BLUEDROID_ENABLED=n
/var/folders/lw/ktjk26fn7gv2p8w0jlbw49w00000gn/T/confgen_tmp_tzu3qg0:34 line was updated to CONFIG_BT_NIMBLE_DEBUG=n
/var/folders/lw/ktjk26fn7gv2p8w0jlbw49w00000gn/T/confgen_tmp_tzu3qg0:44 line was updated to CONFIG_BT_NIMBLE_MESH=n
CMake Error at freertos/vendors/espressif/esp-idf/components/esp32/project_include.cmake:21 (message):
  Internal error, toolchain has not been set correctly by project (or an
  invalid CMakeCache.txt file has been generated somehow)
Call Stack (most recent call first):
  freertos/vendors/espressif/esp-idf/tools/cmake/build.cmake:312 (include)
  freertos/vendors/espressif/esp-idf/tools/cmake/build.cmake:457 (__build_process_project_includes)
  freertos/vendors/espressif/boards/esp32/CMakeLists.txt:591 (idf_build_process)
  freertos/CMakeLists.txt:78 (include)

-- Configuring incomplete, errors occurred!
See also "/Users/user/Documents/test/aws/freeRTOS/original/build/CMakeFiles/CMakeOutput.log".
See also "/Users/user/Documents/test/aws/freeRTOS/original/build/CMakeFiles/CMakeError.log".
cmake failed with exit code 1
misupopo commented 2 years ago

Suddenly this error started happening. What should I do?

cmake -S . -B build-directory -DCMAKE_TOOLCHAIN_FILE=freertos/tools/cmake/toolchains/xtensa-esp32.cmake -GNinja
-- Submodule update
Skipping submodule '../../../libraries/abstractions/backoff_algorithm/'
Skipping submodule '../../../../libraries/abstractions/pkcs11/corePKCS11/'
Skipping submodule '../../../libraries/abstractions/pkcs11/corePKCS11/'
Skipping submodule '../../../libraries/abstractions/pkcs11/corePKCS11/'
Skipping submodule '../../../libraries/abstractions/pkcs11/corePKCS11/'
Skipping submodule '../../../libraries/coreHTTP/'
Skipping submodule '../../../libraries/coreHTTP/'
Skipping submodule '../../../libraries/coreHTTP/'
Skipping submodule '../../../libraries/coreJSON/'
Skipping submodule '../../../libraries/coreJSON/'
Skipping submodule '../../../libraries/coreJSON/'
Skipping submodule '../../../libraries/coreMQTT/'
Skipping submodule '../../../libraries/coreMQTT/'
Skipping submodule '../../../libraries/coreMQTT/'
Skipping submodule '../../../libraries/coreMQTT-Agent/source/dependency/coreMQTT/'
Skipping submodule '../../../libraries/coreMQTT-Agent/source/dependency/coreMQTT/'
Skipping submodule '../../../libraries/coreMQTT-Agent/source/dependency/coreMQTT/'
Skipping submodule '../../../libraries/device_defender_for_aws/'
Skipping submodule '../../../libraries/device_defender_for_aws/'
Skipping submodule '../../../libraries/device_defender_for_aws/'
Skipping submodule '../../../libraries/device_shadow_for_aws/'
Skipping submodule '../../../libraries/device_shadow_for_aws/'
Skipping submodule '../../../libraries/device_shadow_for_aws/'
Skipping submodule '../../libraries/freertos_plus/standard/freertos_plus_tcp/'
Skipping submodule '../../libraries/freertos_plus/standard/freertos_plus_tcp/'
Skipping submodule '../../libraries/freertos_plus/standard/freertos_plus_tcp/'
Skipping submodule '../../../libraries/jobs_for_aws/'
Skipping submodule '../../../libraries/jobs_for_aws/'
Skipping submodule '../../../libraries/jobs_for_aws/'
Skipping submodule '../../../../libraries/ota_for_aws/'
Skipping submodule '../../../libraries/ota_for_aws/'
Skipping submodule '../../../libraries/ota_for_aws/'
Skipping submodule '../../../libraries/ota_for_aws/'
Skipping submodule '../../../libraries/ota_for_aws/'
Skipping submodule '../../../libraries/ota_for_aws/'
WARNING: IDF_PATH environment variable is not cleared.
    If CMake is generating an error, consider clearing the IDF_PATH environment
    variable, and generating a clean build. This message can be ignored if
    CMake was successful.
-- Component directory /Users/user/Documents/test/aws/freeRTOS/originalTest3/freertos/vendors/espressif/esp-idf/components/mbedtls does not contain a CMakeLists.txt file. No component will be added
-- Component directory /Users/user/Documents/test/aws/freeRTOS/originalTest3/freertos/vendors/espressif/esp-idf/components/unity does not contain a CMakeLists.txt file. No component will be added
CMake Error at freertos/vendors/espressif/boards/esp32/CMakeLists.txt:434 (add_executable):
  add_executable cannot create target "my_app" because another target with
  the same name already exists.  The existing target is an executable created
  in source directory
  "/Users/user/Documents/test/aws/freeRTOS/originalTest3".  See
  documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  freertos/CMakeLists.txt:78 (include)
shubhamkulkarni97 commented 2 years ago

Hi @misupopo,

For using AFR in custom CMake project, please check this repository: https://github.com/shubhamkulkarni97/amazon-freertos-examples

misupopo commented 2 years ago

Hi @misupopo,

For using AFR in custom CMake project, please check this repository: https://github.com/shubhamkulkarni97/amazon-freertos-examples

Thank you very much for your help. It looks like it will be very helpful.

I flushed to ESP32. it was success.