From 9991862a108c905c52ac7aa00caa27634a81c2b5 Mon Sep 17 00:00:00 2001 From: Jakob Hasse Date: Tue, 17 Jan 2023 11:44:14 +0800 Subject: [PATCH] fix(linux): fix build errors and warnings, remove ignore file --- .gitlab/ci/host-test.yml | 6 +-- components/esp_event/CMakeLists.txt | 2 - .../esp_hw_support/port/linux/esp_random.c | 4 +- .../include/esp_private/partition_linux.h | 14 ++--- components/esp_partition/partition_linux.c | 16 +++--- .../linux/include/freertos/portmacro_idf.h | 9 +--- .../portable/linux/utils/wait_for_event.c | 2 +- .../portable/linux/utils/wait_for_event.h | 2 +- .../host_test/nvs_host_test/main/test_nvs.cpp | 10 ++-- .../spiffs/host_test/main/host_test_spiffs.c | 4 +- .../host_test/gpio/main/gpio_cxx_test.cpp | 20 +++++--- .../host_test/i2c/main/i2c_cxx_test.cpp | 1 + .../host_test/spi/main/spi_cxx_test.cpp | 5 +- tools/ci/check_copyright_ignore.txt | 1 - tools/ci/ignore_build_warnings_linux.txt | 6 --- tools/mocks/esp_system/include/esp_task.h | 51 ------------------- tools/mocks/freertos/Kconfig | 8 +++ 17 files changed, 54 insertions(+), 107 deletions(-) delete mode 100644 tools/ci/ignore_build_warnings_linux.txt delete mode 100644 tools/mocks/esp_system/include/esp_task.h diff --git a/.gitlab/ci/host-test.yml b/.gitlab/ci/host-test.yml index ad2e95eb68..c84f7fd653 100644 --- a/.gitlab/ci/host-test.yml +++ b/.gitlab/ci/host-test.yml @@ -382,6 +382,7 @@ test_pytest_qemu: test_pytest_linux: extends: - .host_test_template + - .before_script_build_jobs artifacts: when: always paths: @@ -391,13 +392,8 @@ test_pytest_linux: junit: XUNIT_RESULT.xml expire_in: 1 week script: - # TODO: fix the warnings in build flags and ignore-warning-str: IDF-6637 - # Record the warnings regexes in file tools/ci/ignore_build_warnings_linux.txt to avoid using parentheses and - # doublequotes with bash. - # Please remove that file while fixing all the warnings. - run_cmd python tools/ci/ci_build_apps.py components examples tools/test_apps -vv --target linux --pytest-apps -m host_test - --ignore-warning-file tools/ci/ignore_build_warnings_linux.txt - run_cmd pytest --target linux -m host_test --junitxml=XUNIT_RESULT.xml diff --git a/components/esp_event/CMakeLists.txt b/components/esp_event/CMakeLists.txt index 33b4850ad2..7438748b5e 100644 --- a/components/esp_event/CMakeLists.txt +++ b/components/esp_event/CMakeLists.txt @@ -8,8 +8,6 @@ set(srcs "default_event_loop.c" if(${target} STREQUAL "linux") list(APPEND requires "linux") - # Temporary fix until esp_system is available for linux, too - list(APPEND priv_include_dirs "$ENV{IDF_PATH}/tools/mocks/esp_system/include") else() list(APPEND priv_requires esp_timer) endif() diff --git a/components/esp_hw_support/port/linux/esp_random.c b/components/esp_hw_support/port/linux/esp_random.c index 3811826905..71f2013f82 100644 --- a/components/esp_hw_support/port/linux/esp_random.c +++ b/components/esp_hw_support/port/linux/esp_random.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -14,7 +14,7 @@ static const char* TAG = "esp-random"; -static void __attribute__((constructor)) esp_random_init() +static void __attribute__((constructor)) esp_random_init(void) { srand(time(NULL)); ESP_LOGW(TAG, "esp_random do not provide a cryptographically secure numbers on Linux, and should never be used for anything security related"); diff --git a/components/esp_partition/include/esp_private/partition_linux.h b/components/esp_partition/include/esp_private/partition_linux.h index ef7174a596..f2a007a7ce 100644 --- a/components/esp_partition/include/esp_private/partition_linux.h +++ b/components/esp_partition/include/esp_private/partition_linux.h @@ -102,7 +102,7 @@ esp_err_t esp_partition_file_munmap(void); * @brief Clears statistics gathered by emulated partition read/write/erase operations * */ -void esp_partition_clear_stats(); +void esp_partition_clear_stats(void); /** * @brief Returns number of read operations called @@ -112,7 +112,7 @@ void esp_partition_clear_stats(); * @return * - number of calls to esp_partition_read since recent esp_partition_clear_stats */ -size_t esp_partition_get_read_ops(); +size_t esp_partition_get_read_ops(void); /** * @brief Returns number of write operations called @@ -122,7 +122,7 @@ size_t esp_partition_get_read_ops(); * @return * - number of calls to esp_partition_write since recent esp_partition_clear_stats */ -size_t esp_partition_get_write_ops(); +size_t esp_partition_get_write_ops(void); /** * @brief Returns number of erase operations performed on behalf of calls to esp_partition_erase_range @@ -132,7 +132,7 @@ size_t esp_partition_get_write_ops(); * @return * - total number of emulated sector erase operations on behalf of esp_partition_erase_range since recent esp_partition_clear_stats */ -size_t esp_partition_get_erase_ops(); +size_t esp_partition_get_erase_ops(void); /** * @brief Returns total number of bytes read on behalf of esp_partition_read @@ -142,7 +142,7 @@ size_t esp_partition_get_erase_ops(); * @return * - total number of bytes read on behalf of esp_partition_read since recent esp_partition_clear_stats */ -size_t esp_partition_get_read_bytes(); +size_t esp_partition_get_read_bytes(void); /** * @brief Returns total number of bytes written on behalf of esp_partition_write @@ -152,7 +152,7 @@ size_t esp_partition_get_read_bytes(); * @return * - total number of bytes written on behalf of esp_partition_write since recent esp_partition_clear_stats */ -size_t esp_partition_get_write_bytes(); +size_t esp_partition_get_write_bytes(void); /** * @brief Returns estimated total time spent on partition operations. @@ -163,7 +163,7 @@ size_t esp_partition_get_write_bytes(); * @return * - estimated total time spent in read/write/erase operations in miliseconds */ -size_t esp_partition_get_total_time(); +size_t esp_partition_get_total_time(void); /** * @brief Initializes emulation of failure caused by wear on behalf of write/erase operations diff --git a/components/esp_partition/partition_linux.c b/components/esp_partition/partition_linux.c index c351333ca2..810e3f19e0 100644 --- a/components/esp_partition/partition_linux.c +++ b/components/esp_partition/partition_linux.c @@ -176,7 +176,7 @@ esp_err_t esp_partition_file_mmap(const uint8_t **part_desc_addr_start) return ESP_OK; } -esp_err_t esp_partition_file_munmap() +esp_err_t esp_partition_file_munmap(void) { if (s_spiflash_mem_file_buf == NULL) { return ESP_ERR_NO_MEM; @@ -445,7 +445,7 @@ static bool esp_partition_hook_erase(const void *dstAddr, const size_t size) return true; } -void esp_partition_clear_stats() +void esp_partition_clear_stats(void) { s_esp_partition_stat_read_bytes = 0; s_esp_partition_stat_write_bytes = 0; @@ -457,32 +457,32 @@ void esp_partition_clear_stats() memset(s_esp_partition_stat_sector_erase_count, 0, sizeof(s_esp_partition_stat_sector_erase_count)); } -size_t esp_partition_get_read_ops() +size_t esp_partition_get_read_ops(void) { return s_esp_partition_stat_read_ops; } -size_t esp_partition_get_write_ops() +size_t esp_partition_get_write_ops(void) { return s_esp_partition_stat_write_ops; } -size_t esp_partition_get_erase_ops() +size_t esp_partition_get_erase_ops(void) { return s_esp_partition_stat_erase_ops; } -size_t esp_partition_get_read_bytes() +size_t esp_partition_get_read_bytes(void) { return s_esp_partition_stat_read_bytes; } -size_t esp_partition_get_write_bytes() +size_t esp_partition_get_write_bytes(void) { return s_esp_partition_stat_write_bytes; } -size_t esp_partition_get_total_time() +size_t esp_partition_get_total_time(void) { return s_esp_partition_stat_total_time; } diff --git a/components/freertos/FreeRTOS-Kernel/portable/linux/include/freertos/portmacro_idf.h b/components/freertos/FreeRTOS-Kernel/portable/linux/include/freertos/portmacro_idf.h index ac86614f07..bc573f3957 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/linux/include/freertos/portmacro_idf.h +++ b/components/freertos/FreeRTOS-Kernel/portable/linux/include/freertos/portmacro_idf.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -16,18 +16,13 @@ #include // This is for malloc(), used by portmacro.h #include "sdkconfig.h" #include "esp_attr.h" +#include "esp_task.h" #include "spinlock.h" #ifdef __cplusplus extern "C" { #endif -#define ESP_TASK_PRIO_MAX (configMAX_PRIORITIES) -#define ESP_TASK_PRIO_MIN (0) -#define ESP_TASK_MAIN_PRIO (ESP_TASK_PRIO_MIN + 1) -#define ESP_TASK_MAIN_STACK (CONFIG_ESP_MAIN_TASK_STACK_SIZE) -#define ESP_TASK_MAIN_CORE CONFIG_ESP_MAIN_TASK_AFFINITY - // interrupt module will mask interrupt with priority less than threshold #define RVHAL_EXCM_LEVEL 4 diff --git a/components/freertos/FreeRTOS-Kernel/portable/linux/utils/wait_for_event.c b/components/freertos/FreeRTOS-Kernel/portable/linux/utils/wait_for_event.c index d3e5f03226..ae20cf667e 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/linux/utils/wait_for_event.c +++ b/components/freertos/FreeRTOS-Kernel/portable/linux/utils/wait_for_event.c @@ -44,7 +44,7 @@ struct event bool event_triggered; }; -struct event * event_create() +struct event * event_create(void) { struct event * ev = malloc( sizeof( struct event ) ); diff --git a/components/freertos/FreeRTOS-Kernel/portable/linux/utils/wait_for_event.h b/components/freertos/FreeRTOS-Kernel/portable/linux/utils/wait_for_event.h index 45336238c5..11ef9929de 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/linux/utils/wait_for_event.h +++ b/components/freertos/FreeRTOS-Kernel/portable/linux/utils/wait_for_event.h @@ -39,7 +39,7 @@ struct event; -struct event * event_create(); +struct event * event_create(void); void event_delete( struct event * ); bool event_wait( struct event * ev ); bool event_wait_timed( struct event * ev, diff --git a/components/nvs_flash/host_test/nvs_host_test/main/test_nvs.cpp b/components/nvs_flash/host_test/nvs_host_test/main/test_nvs.cpp index 48f07285bc..74628f8e65 100644 --- a/components/nvs_flash/host_test/nvs_host_test/main/test_nvs.cpp +++ b/components/nvs_flash/host_test/nvs_host_test/main/test_nvs.cpp @@ -720,8 +720,8 @@ TEST_CASE("nvs iterators tests", "[nvs]") nvs_iterator_t it; nvs_entry_info_t info; - nvs_handle handle_1; - nvs_handle handle_2; + nvs_handle_t handle_1; + nvs_handle_t handle_2; const uint32_t blob = 0x11223344; const char *name_1 = "namespace1"; const char *name_2 = "namespace2"; @@ -860,7 +860,7 @@ TEST_CASE("nvs iterators tests", "[nvs]") SECTION("Iterating over multiple pages works correctly") { - nvs_handle handle_3; + nvs_handle_t handle_3; const char *name_3 = "namespace3"; const int entries_created = 250; @@ -885,7 +885,7 @@ TEST_CASE("nvs iterators tests", "[nvs]") } SECTION("Iterating over multi-page blob works correctly") { - nvs_handle handle_3; + nvs_handle_t handle_3; const char *name_3 = "namespace3"; const uint8_t multipage_blob[4096 * 2] = { 0 }; const int NUMBER_OF_ENTRIES_PER_PAGE = 125; @@ -1740,7 +1740,7 @@ TEST_CASE("Multi-page blob erased using nvs_erase_key should not be found when p size_t read_size = blob_size; PartitionEmulationFixture f(0, 5); TEST_ESP_OK(nvs::NVSPartitionManager::get_instance()->init_custom(f.part(), 0, 5)); - nvs_handle handle; + nvs_handle_t handle; TEST_ESP_OK(nvs_open("Test", NVS_READWRITE, &handle)); TEST_ESP_OK(nvs_set_blob(handle, "abc", blob, blob_size)); TEST_ESP_OK(nvs_erase_key(handle, "abc")); diff --git a/components/spiffs/host_test/main/host_test_spiffs.c b/components/spiffs/host_test/main/host_test_spiffs.c index 33845f9fe2..24a3352c1b 100644 --- a/components/spiffs/host_test/main/host_test_spiffs.c +++ b/components/spiffs/host_test/main/host_test_spiffs.c @@ -149,7 +149,7 @@ static void check_spiffs_files(spiffs *fs, const char *base_path, char *cur_path fseek(f, 0, SEEK_SET); char *f_contents = (char *) malloc(sz); - fread(f_contents, 1, sz, f); + TEST_ASSERT(fread(f_contents, 1, sz, f) == sz); fclose(f); s32_t spiffs_res; @@ -247,7 +247,7 @@ TEST(spiffs, can_read_spiffs_image) fseek(img_file, 0, SEEK_SET); char *img = (char *) malloc(img_size); - fread(img, 1, img_size, img_file); + TEST_ASSERT(fread(img, 1, img_size, img_file) == img_size); fclose(img_file); TEST_ASSERT_TRUE(partition->size == img_size); diff --git a/examples/cxx/experimental/experimental_cpp_component/host_test/gpio/main/gpio_cxx_test.cpp b/examples/cxx/experimental/experimental_cpp_component/host_test/gpio/main/gpio_cxx_test.cpp index 1078a3e9cd..a6aa647085 100644 --- a/examples/cxx/experimental/experimental_cpp_component/host_test/gpio/main/gpio_cxx_test.cpp +++ b/examples/cxx/experimental/experimental_cpp_component/host_test/gpio/main/gpio_cxx_test.cpp @@ -1,16 +1,22 @@ -/* GPIO C++ unit tests - - This example code is in the Public Domain (or CC0 licensed, at your option.) - - Unless required by applicable law or agreed to in writing, this - software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - CONDITIONS OF ANY KIND, either express or implied. +/* + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: CC0-1.0 + * + * GPIO C++ unit tests + * + * This example code is in the Public Domain (or CC0 licensed, at your option.) + * + * Unless required by applicable law or agreed to in writing, this + * software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. */ #define CATCH_CONFIG_MAIN #include #include "esp_err.h" #include "unity.h" +#include "freertos/FreeRTOS.h" #include "freertos/portmacro.h" #include "gpio_cxx.hpp" #include "test_fixtures.hpp" diff --git a/examples/cxx/experimental/experimental_cpp_component/host_test/i2c/main/i2c_cxx_test.cpp b/examples/cxx/experimental/experimental_cpp_component/host_test/i2c/main/i2c_cxx_test.cpp index 60e274087b..be28b99e0e 100644 --- a/examples/cxx/experimental/experimental_cpp_component/host_test/i2c/main/i2c_cxx_test.cpp +++ b/examples/cxx/experimental/experimental_cpp_component/host_test/i2c/main/i2c_cxx_test.cpp @@ -14,6 +14,7 @@ #define CATCH_CONFIG_MAIN #include #include "unity.h" +#include "freertos/FreeRTOS.h" #include "freertos/portmacro.h" #include "driver/i2c.h" #include "i2c_cxx.hpp" diff --git a/examples/cxx/experimental/experimental_cpp_component/host_test/spi/main/spi_cxx_test.cpp b/examples/cxx/experimental/experimental_cpp_component/host_test/spi/main/spi_cxx_test.cpp index a6e11b563a..472c66fbfc 100644 --- a/examples/cxx/experimental/experimental_cpp_component/host_test/spi/main/spi_cxx_test.cpp +++ b/examples/cxx/experimental/experimental_cpp_component/host_test/spi/main/spi_cxx_test.cpp @@ -1,7 +1,7 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD * - * SPDX-License-Identifier: CC0 + * SPDX-License-Identifier: CC0-1.0 * * This test code is in the Public Domain (or CC0 licensed, at your option.) * @@ -13,6 +13,7 @@ #define CATCH_CONFIG_MAIN #include #include "unity.h" +#include "freertos/FreeRTOS.h" #include "freertos/portmacro.h" #include "spi_host_cxx.hpp" #include "spi_host_private_cxx.hpp" diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index 2994d44592..337f03d4b8 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -1444,7 +1444,6 @@ examples/cxx/experimental/experimental_cpp_component/esp_event_cxx.cpp examples/cxx/experimental/experimental_cpp_component/esp_exception.cpp examples/cxx/experimental/experimental_cpp_component/esp_timer_cxx.cpp examples/cxx/experimental/experimental_cpp_component/host_test/esp_timer/main/esp_timer_test.cpp -examples/cxx/experimental/experimental_cpp_component/host_test/gpio/main/gpio_cxx_test.cpp examples/cxx/experimental/experimental_cpp_component/include/esp_event_api.hpp examples/cxx/experimental/experimental_cpp_component/include/esp_timer_cxx.hpp examples/cxx/experimental/experimental_cpp_component/test/test_cxx_exceptions.cpp diff --git a/tools/ci/ignore_build_warnings_linux.txt b/tools/ci/ignore_build_warnings_linux.txt deleted file mode 100644 index 76241a5c9d..0000000000 --- a/tools/ci/ignore_build_warnings_linux.txt +++ /dev/null @@ -1,6 +0,0 @@ -the hex symbol ESP_MAIN_TASK_AFFINITY \(defined at .+\) has a non-hex default FREERTOS_NO_AFFINITY \(undefined\) -"CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE" redefined -No function prototypes found! --Wdeprecated-declarations --Wno-enum-conversion --Wunused-result diff --git a/tools/mocks/esp_system/include/esp_task.h b/tools/mocks/esp_system/include/esp_task.h deleted file mode 100644 index 6df80ceb21..0000000000 --- a/tools/mocks/esp_system/include/esp_task.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/* Notes: - * 1. Put all task priority and stack size definition in this file - * 2. If the task priority is less than 10, use ESP_TASK_PRIO_MIN + X style, - * otherwise use ESP_TASK_PRIO_MAX - X style - * 3. If this is a daemon task, the macro prefix is ESP_TASKD_, otherwise - * it's ESP_TASK_ - * 4. If the configMAX_PRIORITIES is modified, please make all priority are - * greater than 0 - * 5. Make sure esp_task.h is consistent between wifi lib and idf - * 6. If changing system task priorities, please check the values documented in /api-guides/performance/speed.rst - * are up to date - */ - -#ifndef _ESP_TASK_H_ -#define _ESP_TASK_H_ - -#include "sdkconfig.h" - -#define ESP_TASK_PRIO_MAX (configMAX_PRIORITIES) -#define ESP_TASK_PRIO_MIN (0) - -/* Temporary define until system is properly buildable on Linux */ -#define CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE 10 - -/* Bt contoller Task */ -/* controller */ -#define ESP_TASK_BT_CONTROLLER_PRIO (ESP_TASK_PRIO_MAX - 2) -#ifdef CONFIG_NEWLIB_NANO_FORMAT -#define TASK_EXTRA_STACK_SIZE (0) -#else -#define TASK_EXTRA_STACK_SIZE (512) -#endif - -#define BT_TASK_EXTRA_STACK_SIZE TASK_EXTRA_STACK_SIZE -#define ESP_TASK_BT_CONTROLLER_STACK (3584 + TASK_EXTRA_STACK_SIZE) - -/* Ping Task */ -#define ESP_TASK_PING_STACK (2048 + TASK_EXTRA_STACK_SIZE) - - -/* idf task */ -#define ESP_TASKD_EVENT_PRIO (ESP_TASK_PRIO_MAX - 5) -#define ESP_TASKD_EVENT_STACK (2048) - -#endif diff --git a/tools/mocks/freertos/Kconfig b/tools/mocks/freertos/Kconfig index 0863a1be23..d65bf47cc9 100644 --- a/tools/mocks/freertos/Kconfig +++ b/tools/mocks/freertos/Kconfig @@ -29,4 +29,12 @@ menu "FreeRTOS" However, task notifications in general are more light weight compared to alternatives such as semaphores. endmenu + + config FREERTOS_NO_AFFINITY + # This invisible config value sets the value of tskNO_AFFINITY in task.h. + # Intended to be used as a constant from other Kconfig files. + # Value is (32-bit) INT_MAX. + hex + default 0x7FFFFFFF if !FREERTOS_SMP + default 0xFFFFFFFF if FREERTOS_SMP endmenu