diff --git a/tools/test_apps/.build-test-rules.yml b/tools/test_apps/.build-test-rules.yml index c57cb458fa..8bc316fe55 100644 --- a/tools/test_apps/.build-test-rules.yml +++ b/tools/test_apps/.build-test-rules.yml @@ -1,5 +1,10 @@ # Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps +tools/test_apps/build_system/custom_partition_subtypes: + enable: + - if: IDF_TARGET in ["esp32", "linux"] + reason: the test should be run on ESP32 and linux + tools/test_apps/build_system/ldgen_test: disable: - if: IDF_TARGET == "esp32c2" diff --git a/tools/test_apps/build_system/custom_partition_subtypes/CMakeLists.txt b/tools/test_apps/build_system/custom_partition_subtypes/CMakeLists.txt new file mode 100644 index 0000000000..5735e62225 --- /dev/null +++ b/tools/test_apps/build_system/custom_partition_subtypes/CMakeLists.txt @@ -0,0 +1,25 @@ +# The following lines of boilerplate have to be in your project's +# CMakeLists in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.16) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) + +project(custom_partition_subtypes) + +idf_build_get_property(build_dir BUILD_DIR) +idf_build_get_property(idf_path IDF_PATH) +idf_build_get_property(python PYTHON) +set(blank_file ${build_dir}/blank_file.bin) +idf_component_get_property(partition_table_dir partition_table COMPONENT_DIR) + +partition_table_get_partition_info(partition "--partition-type app --partition-subtype my_app1" "name") +partition_table_get_partition_info(partition_size "--partition-type app --partition-subtype my_app1" "size") + +add_custom_command(OUTPUT ${blank_file} + COMMAND ${python} ${partition_table_dir}/gen_empty_partition.py + ${partition_size} ${blank_file}) + +add_custom_target(blank_bin ALL DEPENDS ${blank_file}) +add_dependencies(flash blank_bin) + +esptool_py_flash_to_partition(flash "${partition}" "${blank_file}") diff --git a/tools/test_apps/build_system/custom_partition_subtypes/README.md b/tools/test_apps/build_system/custom_partition_subtypes/README.md new file mode 100644 index 0000000000..6c60a6a14d --- /dev/null +++ b/tools/test_apps/build_system/custom_partition_subtypes/README.md @@ -0,0 +1,3 @@ +| Supported Targets | ESP32 | Linux | +| ----------------- | ----- | ----- | + diff --git a/tools/test_apps/build_system/custom_partition_subtypes/components/custom/CMakeLists.txt b/tools/test_apps/build_system/custom_partition_subtypes/components/custom/CMakeLists.txt new file mode 100644 index 0000000000..a96dced59e --- /dev/null +++ b/tools/test_apps/build_system/custom_partition_subtypes/components/custom/CMakeLists.txt @@ -0,0 +1 @@ +idf_component_register() diff --git a/tools/test_apps/build_system/custom_partition_subtypes/components/custom/project_include.cmake b/tools/test_apps/build_system/custom_partition_subtypes/components/custom/project_include.cmake new file mode 100644 index 0000000000..bd09b18ed8 --- /dev/null +++ b/tools/test_apps/build_system/custom_partition_subtypes/components/custom/project_include.cmake @@ -0,0 +1,2 @@ +idf_build_set_property(EXTRA_PARTITION_SUBTYPES "app, my_app1, 0x40" APPEND) +idf_build_set_property(EXTRA_PARTITION_SUBTYPES "app, my_app2, 0x41" APPEND) diff --git a/tools/test_apps/build_system/custom_partition_subtypes/main/CMakeLists.txt b/tools/test_apps/build_system/custom_partition_subtypes/main/CMakeLists.txt new file mode 100644 index 0000000000..8e923c48a3 --- /dev/null +++ b/tools/test_apps/build_system/custom_partition_subtypes/main/CMakeLists.txt @@ -0,0 +1 @@ +idf_component_register(SRCS test_main.c) diff --git a/tools/test_apps/build_system/custom_partition_subtypes/main/test_main.c b/tools/test_apps/build_system/custom_partition_subtypes/main/test_main.c new file mode 100644 index 0000000000..1f3f7d2a88 --- /dev/null +++ b/tools/test_apps/build_system/custom_partition_subtypes/main/test_main.c @@ -0,0 +1,27 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 + */ +#include +#include +#include + +static const char *TAG = "test_main"; + +void app_main(void) +{ + const esp_partition_t *my_app1 = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_MY_APP1, NULL); + if (my_app1 == NULL) { + ESP_LOGE(TAG, "Failed to find custom my_app1"); + } else { + ESP_LOGI(TAG, "Found custom partition @ 0x%x (0x%x)", my_app1->address, my_app1->size); + } + + const esp_partition_t *my_app2 = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_MY_APP2, NULL); + if (my_app2 == NULL) { + ESP_LOGE(TAG, "Failed to find custom my_app1"); + } else { + ESP_LOGI(TAG, "Found custom partition @ 0x%x (0x%x)", my_app2->address, my_app2->size); + } +} diff --git a/tools/test_apps/build_system/custom_partition_subtypes/partitions.csv b/tools/test_apps/build_system/custom_partition_subtypes/partitions.csv new file mode 100644 index 0000000000..eaf74ee709 --- /dev/null +++ b/tools/test_apps/build_system/custom_partition_subtypes/partitions.csv @@ -0,0 +1,7 @@ +# Name, Type, SubType, Offset, Size, Flags +# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap +nvs, data, nvs, , 0x6000, +phy_init, data, phy, , 0x1000, +fctry, app, factory, , 1M, +my_app1, app, my_app1, , 256K, +my_app2, app, my_app2, , 256K, diff --git a/tools/test_apps/build_system/custom_partition_subtypes/sdkconfig.defaults b/tools/test_apps/build_system/custom_partition_subtypes/sdkconfig.defaults new file mode 100644 index 0000000000..91d7574d37 --- /dev/null +++ b/tools/test_apps/build_system/custom_partition_subtypes/sdkconfig.defaults @@ -0,0 +1,2 @@ +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"