forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3c5d19
commit 896cf6c
Showing
3 changed files
with
91 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
function(factory_partition_create_image partition1 partition2 esp_matter_dir) | ||
set(options FLASH_IN_PROJECT) | ||
set(multi DEPENDS) | ||
cmake_parse_arguments(arg "${options}" "" "${multi}" "${ARGN}") | ||
get_filename_component(esp_matter_dir_full_path ${esp_matter_dir} ABSOLUTE) | ||
|
||
set(mfg_tool_py ${PYTHON} ${esp_matter_dir}/scripts/tools/generate_esp32_chip_factory_bin.py) | ||
|
||
partition_table_get_partition_info(size1 "--partition-name ${partition1}" "size") | ||
partition_table_get_partition_info(offset1 "--partition-name ${partition1}" "offset") | ||
|
||
partition_table_get_partition_info(size2 "--partition-name ${partition2}" "size") | ||
partition_table_get_partition_info(offset2 "--partition-name ${partition2}" "offset") | ||
|
||
|
||
message(STATUS "Size1 : ${size1}") | ||
message(STATUS "offset1 : ${offset1}") | ||
message(STATUS "Size2 : ${size2}") | ||
message(STATUS "offset2 : ${offset2}") | ||
if("${size1}" AND "${offset1}") | ||
set(MY_BULB_NAME "My bulb") | ||
set(VENDOR_NAME "Test-vendor") | ||
set(HARDWARE_VERSION 1) | ||
set(HARDWARE_VERSION_STR "Devkit") | ||
set(VENDOR_ID 0xFFF2) | ||
set(PRODUCT_ID 0x8001) | ||
set(DAC_CERT "${esp_matter_dir_full_path}/credentials/test/attestation/Chip-Test-DAC-FFF2-8001-0008-Cert.der") | ||
set(DAC_KEY "${esp_matter_dir_full_path}/credentials/test/attestation/Chip-Test-DAC-FFF2-8001-0008-Key.der") | ||
set(PAI_CERT "${esp_matter_dir_full_path}/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-Cert.der") | ||
set(CERT_DCLRN "${esp_matter_dir_full_path}/credentials/test/certification-declaration/Chip-Test-CD-FFF2-8001.der") | ||
set(PASSCODE 20202020) | ||
set(DISCRIMINATOR 3841) | ||
|
||
# Execute Factory partition image generation; this always executes as there is no way to specify for CMake to watch for | ||
# contents of the base dir changing. | ||
add_custom_target(factory ALL | ||
COMMAND ${mfg_tool_py} -d ${DISCRIMINATOR} | ||
-p ${PASSCODE} | ||
--product-name "${MY_BULB_NAME}" | ||
--vendor-name "${VENDOR_NAME}" | ||
--vendor-id ${VENDOR_ID} | ||
--product-id ${PRODUCT_ID} | ||
--hw-ver ${HARDWARE_VERSION} | ||
--hw-ver-str "${HARDWARE_VERSION_STR}" | ||
--dac-cert ${DAC_CERT} | ||
--dac-key ${DAC_KEY} | ||
--pai-cert ${PAI_CERT} | ||
--cd ${CERT_DCLRN} | ||
--dac-in-secure-cert | ||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | ||
) | ||
|
||
set(image_file1 ${CMAKE_BINARY_DIR}/bin/factory_partition.bin) | ||
set(image_file2 ${CMAKE_BINARY_DIR}/bin/esp_secure_cert_partititon.bin) | ||
idf_component_get_property(main_args esptool_py FLASH_ARGS) | ||
idf_component_get_property(sub_args esptool_py FLASH_SUB_ARGS) | ||
|
||
esptool_py_flash_target(${partition1}-flash "${main_args}" "${sub_args}" ALWAYS_PLAINTEXT) | ||
esptool_py_flash_to_partition(${partition1}-flash "${partition1}" "${image_file1}") | ||
|
||
esptool_py_flash_target(${partition2}-flash "${main_args}" "${sub_args}" ALWAYS_PLAINTEXT) | ||
esptool_py_flash_to_partition(${partition2}-flash "${partition2}" "${image_file2}") | ||
|
||
add_dependencies(${partition1}-flash factory) | ||
add_dependencies(${partition2}-flash factory) | ||
|
||
if(arg_FLASH_IN_PROJECT) | ||
esptool_py_flash_to_partition(flash "${partition1}" "${image_file1}") | ||
esptool_py_flash_to_partition(flash "${partition2}" "${image_file2}") | ||
add_dependencies(flash factory) | ||
endif() | ||
else() | ||
set(message "Failed to create Factory partition image for partition '${partition}'. " | ||
"Check project configuration if using the correct partition table file.") | ||
fail_at_build_time(factory_${partition}_bin "${message}") | ||
|
||
endif() | ||
endfunction() |