-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read EFuse from CMake (IDFGH-8890) #10311
Comments
Hi @tsctrl! The efuse json representation looks like this: {
"FLASH_CRYPT_CNT": {
"bit_len": 7,
"block": 0,
"category": "security",
"description": "Flash encryption mode counter",
"efuse_type": "uint:7",
"name": "FLASH_CRYPT_CNT",
"pos": 20,
"readable": true,
"value": 0,
"word": 0,
"writeable": true
},
//....
} espefuse_get_json_summary(efuse_json) # connects to chip once and read out all efuses to a string var
espefuse_get_efuse(efuse_value ${efuse_json} "FLASH_CRYPT_CNT" "value") # extract required efuses and properties one by one
message("FLASH_CRYPT_CNT:" ${efuse_value})
espefuse_get_efuse(efuse_value ${efuse_json} "ABS_DONE_1" "value")
message("ABS_DONE_1:" ${efuse_value})
espefuse_get_efuse(efuse_value ${efuse_json} "MAC" "value")
message("MAC:" ${efuse_value}) It returns the same format of values as shown in
You will be able to use these APIs in the esp-idf/examples/get-started/hello_world/CMakeLists.txt file. If it is urgent, you can use this patch. Create the esp-idf/components/efuse/project_include.cmake file and put it there. # reads efuses from chip using "espefuse.py summary" and returns a cleaned json string
function(espefuse_get_json_summary result)
execute_process(COMMAND ${ESPEFUSEPY} summary
--format json
OUTPUT_VARIABLE info
RESULT_VARIABLE exit_code
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT ${exit_code} EQUAL 0 AND NOT ${exit_code} EQUAL 1)
message(WARNING "espefuse.py execution failed (${result}), problem with ... (see above)")
endif()
string(FIND ${info} "=== Run \"summary\" command ===" output_variable)
MATH(EXPR output_variable "${output_variable} + 29")
string(SUBSTRING ${info} ${output_variable} -1 output)
set(${result} ${output} PARENT_SCOPE)
endfunction()
# 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)
string(JSON cur_efuse GET ${efuse_json} ${efuse_name})
string(JSON ret_value GET ${cur_efuse} ${efuse_property})
set(${result} ${ret_value} PARENT_SCOPE)
endfunction() |
Is your feature request related to a problem?
i am frustrated when i am accidentally flasing my encrypted and brick my device, adding capability in build cmake system could help us to read efuses value to stop the build and avoid from reflashing the encrypted device.
Describe the solution you'd like.
adding capability in build cmake system could help us to read efuses value to stop the build and avoid from reflashing the encrypted device
Describe alternatives you've considered.
please let me know other approach thats interact to cmake, i dont want to modify espressif idf.py script to have this capability and reading the files in bash is not reliable and impacted by sdk version update.
Additional context.
The text was updated successfully, but these errors were encountered: