This commit is contained in:
Mysteo91
2023-07-20 13:55:29 +03:00
parent 96e193a7f2
commit 8c73cea539
331 changed files with 120 additions and 455964 deletions

View File

@@ -31,4 +31,70 @@ function(FUNC_CREATE_MEMORY_MAP filename flash_size boot_size eeprom_size)
message(${CRC32_USER_AREA_ADDRESS})
add_compile_definitions("EEPROM_START_ADDRESS=${FLASH_EEPROM_EMU_START_ADDRESS}" "FLASH_USER_PROG_ADDRESS=${FLASH_MAIN_PROG_START_ADDRESS}")
set(FLASH_MAIN_ADDRESS ${FLASH_MAIN_PROG_START_ADDRESS} PARENT_SCOPE)
endfunction()
endfunction()
function (FUNC_GENERATE_KEYS path_to_user_key_file path_to_user_cert_file path_to_ca_file path_for_header login_file )
if(EXISTS "${path_to_user_key_file}" )
file(SIZE ${path_to_user_key_file} SIZE_FILE)
if (SIZE_FILE EQUAL 0)
message(FATAL_ERROR "${path_to_user_key_file} file is empty")
return()
endif()
file(STRINGS "${path_to_user_key_file}" USER_KEY)
file(WRITE "${path_for_header}" "char const user_key[] = ")
foreach(X IN LISTS USER_KEY)
file (APPEND "${path_for_header}" "\"${X}\\n\"\n")
message("\"${X}\"\n")
endforeach()
file(APPEND "${path_for_header}" ";\n")
else()
message(FATAL_ERROR "Please create user_key.cer in /keys directory" )
return()
endif()
if(EXISTS "${path_to_user_cert_file}" )
file(SIZE ${path_to_user_cert_file} SIZE_FILE)
if (SIZE_FILE EQUAL 0)
message(FATAL_ERROR "${path_to_user_cert_file} file is empty")
return()
endif()
file(STRINGS "${path_to_user_cert_file}" USER_CERT )
file(APPEND "${path_for_header}" "char const user_cert[] = ")
foreach(X IN LISTS USER_CERT)
file (APPEND keys/keys.h "\"${X}\\n\"\n")
endforeach()
file(APPEND "${path_for_header}" ";\n")
else()
message(FATAL_ERROR "Please create user_cert.cer in /keys directory" )
return()
endif()
if(EXISTS "${path_to_ca_file}" )
file(SIZE ${path_to_ca_file} SIZE_FILE)
if (SIZE_FILE EQUAL 0)
message(FATAL_ERROR "${path_to_ca_file} file is empty")
return()
endif()
file(STRINGS "${path_to_ca_file}" CA_CERT )
file(APPEND "${path_for_header}" "char const ca[] = ")
foreach(X IN LISTS CA_CERT)
file (APPEND "${path_for_header}" "\"${X}\\n\"\n" )
endforeach()
file(APPEND "${path_for_header}" ";\n")
else()
message(FATAL_ERROR "Please create ca.cer in /keys directory" )
return()
endif()
if (EXISTS "${login_file}")
file(STRINGS ${login_file} BANKSPACE)
list(GET BANKSPACE 4 STR1)
message("${STR1}")
file(APPEND "${path_for_header}" "const char* hostname = \"${STR1}\";\n")
list(GET BANKSPACE 5 STR1)
file(APPEND "${path_for_header}" "uint16_t port = ${STR1};\n")
endif()
endfunction()