-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/custom_partition_subtypes' into 'master'
gen_esp32part.py: Support custom partition types See merge request espressif/esp-idf!18656
- Loading branch information
Showing
19 changed files
with
187 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env python | ||
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import argparse | ||
|
||
|
||
def gen_header_file(path: str, subtypes: str) -> None: | ||
HDR_MESSAGE = '/* Automatically generated file. DO NOT EDIT. */\n\n' | ||
PARTTOOL_USAGE = 'If you want to use parttool.py manually, please use the following as an extra argument:' | ||
with open(path, 'w') as f: | ||
f.write(HDR_MESSAGE) | ||
if subtypes: | ||
f.write('/*\n\t' + PARTTOOL_USAGE + '\n\t') | ||
f.write('--extra-partition-subtypes ') | ||
for line_no in subtypes: | ||
f.write(line_no + ' ') | ||
f.write('\n*/\n\n') | ||
f.write('#pragma once\n\n') | ||
for line_no in subtypes: | ||
try: | ||
fields = [line.strip() for line in line_no.split(',')] | ||
fields[0] = fields[0].strip() | ||
fields[1] = fields[1].strip() | ||
fields[2] = fields[2].strip() | ||
f.write('ESP_PARTITION_SUBTYPE_%s_%s = %s,\n' % (fields[0].upper(), fields[1].upper(), fields[2])) | ||
except ValueError as err: | ||
raise ValueError('Error parsing custom subtypes: %s' % err) | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser(description='ESP32 extra partitions utility') | ||
parser.add_argument('config_dir', help='Path to config directory') | ||
parser.add_argument('extra_partition_subtypes', help='Extra partition subtype entries', nargs='*') | ||
args = parser.parse_args() | ||
|
||
gen_header_file(args.config_dir, args.extra_partition_subtypes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
tools/test_apps/build_system/custom_partition_subtypes/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}") |
3 changes: 3 additions & 0 deletions
3
tools/test_apps/build_system/custom_partition_subtypes/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
| Supported Targets | ESP32 | Linux | | ||
| ----------------- | ----- | ----- | | ||
|
1 change: 1 addition & 0 deletions
1
tools/test_apps/build_system/custom_partition_subtypes/components/custom/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
idf_component_register() |
2 changes: 2 additions & 0 deletions
2
.../test_apps/build_system/custom_partition_subtypes/components/custom/project_include.cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
1 change: 1 addition & 0 deletions
1
tools/test_apps/build_system/custom_partition_subtypes/main/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
idf_component_register(SRCS test_main.c) |
27 changes: 27 additions & 0 deletions
27
tools/test_apps/build_system/custom_partition_subtypes/main/test_main.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Unlicense OR CC0-1.0 | ||
*/ | ||
#include <stdio.h> | ||
#include <esp_partition.h> | ||
#include <esp_log.h> | ||
|
||
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); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
tools/test_apps/build_system/custom_partition_subtypes/partitions.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, |
2 changes: 2 additions & 0 deletions
2
tools/test_apps/build_system/custom_partition_subtypes/sdkconfig.defaults
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CONFIG_PARTITION_TABLE_CUSTOM=y | ||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" |