Skip to content

Commit

Permalink
Merge branch 'bugfix/efuse_summary_v5.1' into 'release/v5.1'
Browse files Browse the repository at this point in the history
system-hardware/efuse: fixed efuse summary description containing ; breaking efuse-summary (v5.1)

See merge request espressif/esp-idf!23979
  • Loading branch information
AdityaHPatwardhan committed May 31, 2023
2 parents 30f8f83 + bb42182 commit 7b09d12
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions components/esptool_py/espefuse.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,36 @@ function(espefuse_cmd cmd output_log)
set(log ${SERIAL_TOOL_OUTPUT_LOG})

set(prefix_str " command ===")
string(FIND ${log} ${prefix_str} pos)
string(FIND "${log}" ${prefix_str} pos)
if(${pos} GREATER -1)
string(LENGTH ${prefix_str} len_of_prefix_str)
math(EXPR pos "${pos} + ${len_of_prefix_str}")
string(SUBSTRING ${log} ${pos} -1 final_log)
string(SUBSTRING "${log}" ${pos} -1 final_log)
else()
set(final_log ${log})
set(final_log "${log}")
endif()

set(${output_log} ${final_log} PARENT_SCOPE)
set(${output_log} "${final_log}" PARENT_SCOPE)
endfunction()

# Reads efuses "espefuse.py summary" and returns JSON string
function(espefuse_get_json_summary json_str)
espefuse_cmd("summary;--format;json" output_log)
set(${json_str} ${output_log} PARENT_SCOPE)
set(${json_str} "${output_log}" PARENT_SCOPE)
endfunction()

# See the esp-idf/docs/en/api-reference/system/efuse.rst "Get eFuses During Build".
#
# It takes the efuse json string and returns a value of property for a given efuse name
function(espefuse_get_efuse result efuse_json efuse_name efuse_property)
if(${CMAKE_VERSION} VERSION_LESS "3.19.0")
string(REGEX MATCH "\"${efuse_name}\":[ \t\n\r]*\{[^\}]*\}" cur_efuse ${efuse_json})
string(REGEX MATCH "\"${efuse_property}\":[ \t\n\r]*\"?([^,\"]*)\"?," ret_value ${cur_efuse})
string(REGEX MATCH "\"${efuse_name}\":[ \t\n\r]*\{[^\}]*\}" cur_efuse "${efuse_json}")
string(REGEX MATCH "\"${efuse_property}\":[ \t\n\r]*\"?([^,\"]*)\"?," ret_value "${cur_efuse}")
set(${result} ${CMAKE_MATCH_1} PARENT_SCOPE)
else()
# The JSON feature has been supported by Cmake since 3.19.0
string(JSON cur_efuse GET ${efuse_json} ${efuse_name})
string(JSON ret_value GET ${cur_efuse} ${efuse_property})
string(JSON cur_efuse GET "${efuse_json}" ${efuse_name})
string(JSON ret_value GET "${cur_efuse}" ${efuse_property})
set(${result} ${ret_value} PARENT_SCOPE)
endif()
endfunction()
2 changes: 1 addition & 1 deletion examples/system/efuse/get_efuse_summary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ cmake_minimum_required(VERSION 3.16)
include(${esptool_py_dir}/espefuse.cmake)
espefuse_get_json_summary(efuse_json)
foreach(name ${efuse_names})
espefuse_get_efuse(ret_data ${efuse_json} ${name} "value")
espefuse_get_efuse(ret_data "${efuse_json}" ${name} "value")
message(STATUS "FROM_CMAKE: ${name}: ${ret_data}")
endforeach()

0 comments on commit 7b09d12

Please sign in to comment.