mirror of
https://github.com/espressif/esp-idf
synced 2025-03-08 15:49:08 -05:00
Merge branch 'contrib/github_pr_15401' into 'master'
Fix idf_as_lib example (GitHub PR) Closes IDFGH-14655 See merge request espressif/esp-idf!37127
This commit is contained in:
commit
4f968c3fc5
@ -1,17 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
PARAM=""
|
|
||||||
|
|
||||||
# Retrive the target from the current filename, if no target specified,
|
|
||||||
# the variable will be empty
|
|
||||||
TARGET=$(echo $0 | cut -s -f2 -d- | cut -s -f1 -d.)
|
|
||||||
if [[ -n $TARGET ]]
|
|
||||||
then
|
|
||||||
# Target is not null, specify the build parameters
|
|
||||||
PARAM="-DCMAKE_TOOLCHAIN_FILE=$IDF_PATH/tools/cmake/toolchain-${TARGET}.cmake -DTARGET=${TARGET} -GNinja"
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm -rf build && mkdir build && cd build
|
|
||||||
cmake .. $PARAM
|
|
||||||
cmake --build .
|
|
1
examples/build_system/cmake/idf_as_lib/build-esp32p4.sh
Symbolic link
1
examples/build_system/cmake/idf_as_lib/build-esp32p4.sh
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
build.sh
|
@ -1,4 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
cd build
|
|
||||||
python $IDF_PATH/components/esptool_py/esptool/esptool.py -p $1 write_flash @flash_project_args
|
|
||||||
python -m esp_idf_monitor -p $1 idf_as_lib.elf
|
|
1
examples/build_system/cmake/idf_as_lib/run-esp32p4.sh
Symbolic link
1
examples/build_system/cmake/idf_as_lib/run-esp32p4.sh
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
run-esp32.sh
|
@ -1,5 +1,3 @@
|
|||||||
add_library(stub_esp32 STATIC system_api.c flash_ops.c cpu_start.c)
|
add_library(stub_esp32 STATIC system_api.c cpu_start.c)
|
||||||
target_include_directories(stub_esp32 PUBLIC .)
|
target_include_directories(stub_esp32 PUBLIC .)
|
||||||
add_library(stub::esp32 ALIAS stub_esp32)
|
add_library(stub::esp32 ALIAS stub_esp32)
|
||||||
|
|
||||||
target_link_libraries(stub_esp32 stub::spi_flash)
|
|
||||||
|
@ -9,6 +9,10 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define ESP_OK 0 /*!< esp_err_t value indicating success (no error) */
|
||||||
|
|
||||||
|
typedef int esp_err_t;
|
||||||
|
|
||||||
void esp_restart(void);
|
void esp_restart(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
int spi_flash_get_chip_size(void)
|
|
||||||
{
|
|
||||||
return (1024 * 1024 * 1024);
|
|
||||||
}
|
|
@ -1,3 +1,4 @@
|
|||||||
add_library(stub_spi_flash INTERFACE)
|
add_library(stub_spi_flash STATIC flash_ops.c)
|
||||||
target_include_directories(stub_spi_flash INTERFACE .)
|
target_include_directories(stub_spi_flash PUBLIC .)
|
||||||
add_library(stub::spi_flash ALIAS stub_spi_flash)
|
add_library(stub::spi_flash ALIAS stub_spi_flash)
|
||||||
|
target_link_libraries(stub_spi_flash PUBLIC stub_esp32)
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "esp_system.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef void * esp_flash_t;
|
||||||
|
|
||||||
|
esp_err_t esp_flash_get_size(esp_flash_t *chip, uint32_t *out_size);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int spi_flash_get_chip_size(void);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "esp_flash.h"
|
||||||
|
|
||||||
|
esp_err_t esp_flash_get_size(esp_flash_t *chip, uint32_t *out_size)
|
||||||
|
{
|
||||||
|
*out_size = 1024 * 1024 * 1024;
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
# SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
# SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
@ -16,14 +16,17 @@ from test_build_system_helpers import run_cmake_and_build
|
|||||||
|
|
||||||
def test_build_custom_cmake_project(test_app_copy: Path) -> None:
|
def test_build_custom_cmake_project(test_app_copy: Path) -> None:
|
||||||
# Test is compatible with any target. Random targets in the list are selected for performance reasons
|
# Test is compatible with any target. Random targets in the list are selected for performance reasons
|
||||||
for target in ['esp32', 'esp32s3', 'esp32c6', 'esp32h2']:
|
idf_path = Path(os.environ['IDF_PATH'])
|
||||||
|
for target in ['esp32','esp32c2','esp32c3','esp32c6','esp32h2','esp32p4','esp32s2','esp32s3']:
|
||||||
logging.info(f'Test build ESP-IDF as a library to a custom CMake projects for {target}')
|
logging.info(f'Test build ESP-IDF as a library to a custom CMake projects for {target}')
|
||||||
idf_path = Path(os.environ['IDF_PATH'])
|
|
||||||
run_cmake_and_build(str(idf_path / 'examples' / 'build_system' / 'cmake' / 'idf_as_lib'), '-G', 'Ninja',
|
run_cmake_and_build(str(idf_path / 'examples' / 'build_system' / 'cmake' / 'idf_as_lib'), '-G', 'Ninja',
|
||||||
'-DCMAKE_TOOLCHAIN_FILE={}'.format(idf_path / 'tools' / 'cmake' / f'toolchain-{target}.cmake'), f'-DTARGET={target}')
|
'-DCMAKE_TOOLCHAIN_FILE={}'.format(idf_path / 'tools' / 'cmake' / f'toolchain-{target}.cmake'), f'-DTARGET={target}')
|
||||||
assert file_contains((test_app_copy / 'build' / 'compile_commands.json'), '"command"')
|
assert file_contains((test_app_copy / 'build' / 'compile_commands.json'), '"command"')
|
||||||
shutil.rmtree(test_app_copy / 'build')
|
shutil.rmtree(test_app_copy / 'build')
|
||||||
|
|
||||||
|
logging.info(f'Test build ESP-IDF as a library to a custom CMake projects for host')
|
||||||
|
run_cmake_and_build(str(idf_path / 'examples' / 'build_system' / 'cmake' / 'idf_as_lib'), '-G', 'Ninja')
|
||||||
|
|
||||||
|
|
||||||
def test_build_cmake_library_psram_workaround(test_app_copy: Path) -> None:
|
def test_build_cmake_library_psram_workaround(test_app_copy: Path) -> None:
|
||||||
logging.info('Building a project with CMake library imported and PSRAM workaround, all files compile with workaround')
|
logging.info('Building a project with CMake library imported and PSRAM workaround, all files compile with workaround')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user