diff --git a/tools/cmake/afr.cmake b/tools/cmake/afr.cmake index 61796e4d05d..bcb8a19c39a 100644 --- a/tools/cmake/afr.cmake +++ b/tools/cmake/afr.cmake @@ -62,9 +62,18 @@ if(NOT DEFINED CACHE{AFR_TOOLCHAIN}) set(AFR_TOOLCHAIN ${__toolchain} CACHE INTERNAL "Toolchain to build Amazon FreeRTOS.") endif() +# Provide an option to enable demos. If we're not at top level, turn off demos build by default. +if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") + option(AFR_ENABLE_DEMOS "Build demos for Amazon FreeRTOS." ON) +else() + option(AFR_ENABLE_DEMOS "Build demos for Amazon FreeRTOS." OFF) +endif() + # Provide an option to enable tests. Also set an helper variable to use in generator expression. option(AFR_ENABLE_TESTS "Build tests for Amazon FreeRTOS. Requires recompiling whole library." OFF) if(AFR_ENABLE_TESTS) + # Turning off demo when tests are enabled. + set(AFR_ENABLE_DEMOS 0 CACHE BOOL "Build demos for Amazon FreeRTOS." FORCE) add_compile_definitions(AMAZON_FREERTOS_ENABLE_UNIT_TESTS) add_compile_definitions(IOT_BUILD_TESTS=1) set(AFR_IS_TESTING 1 CACHE INTERNAL "") diff --git a/tools/cmake/afr_module.cmake b/tools/cmake/afr_module.cmake index 744598cc33a..bdb1df1a7ac 100644 --- a/tools/cmake/afr_module.cmake +++ b/tools/cmake/afr_module.cmake @@ -332,7 +332,10 @@ function(afr_resolve_dependencies) set(exe_target aws_demos) set(exe_base demo_base) endif() - __search_afr_dependencies(${exe_target} dependencies) + # If neither demos nor tests are enabled, then don't search the aws_demos/aws_tests targets. + if(AFR_ENABLE_DEMOS OR AFR_ENABLE_TESTS) + __search_afr_dependencies(${exe_target} dependencies) + endif() afr_module_dependencies(${exe_base} INTERFACE ${dependencies}) # Make sure kernel can be enabled first. diff --git a/vendors/espressif/boards/esp32/CMakeLists.txt b/vendors/espressif/boards/esp32/CMakeLists.txt index 69245ad753a..44c3bfa2aa5 100644 --- a/vendors/espressif/boards/esp32/CMakeLists.txt +++ b/vendors/espressif/boards/esp32/CMakeLists.txt @@ -192,33 +192,31 @@ afr_glob_src(config_files DIRECTORY "${board_dir}/config_files") if(AFR_IS_TESTING) set(exe_target aws_tests) - set(extra_exe_sources "${AFR_TESTS_DIR}/common/iot_tests_network.c") else() set(exe_target aws_demos) - set( - extra_exe_sources - "${AFR_DEMOS_DIR}/wifi_provisioning/aws_wifi_connect_task.c" - ) endif() -add_executable( - ${exe_target} - "${board_dir}/application_code/main.c" - ${extra_exe_sources} -) -target_include_directories( - ${exe_target} - PUBLIC - $ - $ -) -target_link_libraries( - ${exe_target} - PRIVATE - AFR::wifi - AFR::utils - AFR::ble -) +# Do not add demos or tests if they're turned off. +if(AFR_ENABLE_DEMOS OR AFR_ENABLE_TESTS) + add_executable( + ${exe_target} + "${board_dir}/application_code/main.c" + ${extra_exe_sources} + ) + target_include_directories( + ${exe_target} + PUBLIC + $ + $ + ) + target_link_libraries( + ${exe_target} + PRIVATE + AFR::wifi + AFR::utils + AFR::ble + ) +endif() if(AFR_METADATA_MODE) return() diff --git a/vendors/infineon/boards/xmc4800_iotkit/CMakeLists.txt b/vendors/infineon/boards/xmc4800_iotkit/CMakeLists.txt index 4fd5745cbaa..f28edda83a9 100644 --- a/vendors/infineon/boards/xmc4800_iotkit/CMakeLists.txt +++ b/vendors/infineon/boards/xmc4800_iotkit/CMakeLists.txt @@ -254,43 +254,46 @@ afr_glob_src(board_src DIRECTORY "${xmc4800_aws_dir}/application_code/infineon_c afr_glob_src(newlib DIRECTORY "${xmclib_dir}/Newlib") afr_glob_src(config_src DIRECTORY "${xmc4800_aws_dir}/config_files") -add_executable( - ${exe_target} - ${board_src} - ${config_src} - ${newlib} - ${esp_at_lib} - ${linker_script} - "${xmc4800_aws_dir}/application_code/main.c" -) - -target_link_libraries( - ${exe_target} - PRIVATE - AFR::wifi - AFR::utils -) - -if(AFR_METADATA_MODE) - return() -endif() - -find_program(gcc_objectcopy arm-none-eabi-objcopy) -find_program(gcc_size arm-none-eabi-size) - -if(NOT gcc_objectcopy ) - message(FATAL_ERROR "Cannot find arm-none-eabi-objcopy.") +# Do not add demos or tests if they're turned off. +if(AFR_ENABLE_DEMOS OR AFR_ENABLE_TESTS) + add_executable( + ${exe_target} + ${board_src} + ${config_src} + ${newlib} + ${esp_at_lib} + ${linker_script} + "${xmc4800_aws_dir}/application_code/main.c" + ) + + target_link_libraries( + ${exe_target} + PRIVATE + AFR::wifi + AFR::utils + ) + + if(AFR_METADATA_MODE) + return() + endif() + + find_program(gcc_objectcopy arm-none-eabi-objcopy) + find_program(gcc_size arm-none-eabi-size) + + if(NOT gcc_objectcopy ) + message(FATAL_ERROR "Cannot find arm-none-eabi-objcopy.") + endif() + + set(output_file "$/${exe_target}.hex") + + add_custom_command( + TARGET ${exe_target} POST_BUILD + COMMAND "${gcc_objectcopy}" -O ihex "$" "${output_file}" + COMMAND "${gcc_size}" "$" + ) + + add_custom_command( + TARGET ${exe_target} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy "${output_file}" "${CMAKE_BINARY_DIR}" + ) endif() - -set(output_file "$/${exe_target}.hex") - -add_custom_command( - TARGET ${exe_target} POST_BUILD - COMMAND "${gcc_objectcopy}" -O ihex "$" "${output_file}" - COMMAND "${gcc_size}" "$" -) - -add_custom_command( - TARGET ${exe_target} POST_BUILD - COMMAND "${CMAKE_COMMAND}" -E copy "${output_file}" "${CMAKE_BINARY_DIR}" -) diff --git a/vendors/marvell/boards/mw300_rd/CMakeLists.txt b/vendors/marvell/boards/mw300_rd/CMakeLists.txt index 920a9d87fdf..c2fc1f0ccbe 100644 --- a/vendors/marvell/boards/mw300_rd/CMakeLists.txt +++ b/vendors/marvell/boards/mw300_rd/CMakeLists.txt @@ -257,45 +257,48 @@ set(default_modules AFR::wifi AFR::utils) afr_glob_src(board_code_src RECURSE DIRECTORY "${board_dir}/application_code/marvell_code") afr_glob_src(config_files DIRECTORY "${board_dir}/config_files") -add_executable( - ${exe_target} - ${board_code_src} - ${config_files} - "${board_dir}/application_code/main.c" -) - -target_include_directories( - ${exe_target} - PUBLIC - "${AFR_MODULES_ABSTRACTIONS_DIR}/pkcs11/include" - "${AFR_3RDPARTY_DIR}/pkcs11" - "${AFR_MODULES_FREERTOS_PLUS_DIR}/standard/crypto/include" -) - -target_link_libraries( - ${exe_target} - PRIVATE - AFR::utils - ${default_modules} - -T${global-linkerscript-y} -) - -if(AFR_METADATA_MODE) - return() -endif() - -# Convert afx file to bin file -if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux") - set(axf2fw "${mw320_dir}/sdk/tools/bin/Linux/axf2firmware") - execute_process(COMMAND chmod +x "${axf2fw}") # TODO, workaround for Amazon FreeRTOS console permission issue. -else() - message(FATAL_ERROR "Only Linux host is supported for marvell.") +# Do not add demos or tests if they're turned off. +if(AFR_ENABLE_DEMOS OR AFR_ENABLE_TESTS) + add_executable( + ${exe_target} + ${board_code_src} + ${config_files} + "${board_dir}/application_code/main.c" + ) + + target_include_directories( + ${exe_target} + PUBLIC + "${AFR_MODULES_ABSTRACTIONS_DIR}/pkcs11/include" + "${AFR_3RDPARTY_DIR}/pkcs11" + "${AFR_MODULES_FREERTOS_PLUS_DIR}/standard/crypto/include" + ) + + target_link_libraries( + ${exe_target} + PRIVATE + AFR::utils + ${default_modules} + -T${global-linkerscript-y} + ) + + if(AFR_METADATA_MODE) + return() + endif() + + # Convert afx file to bin file + if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux") + set(axf2fw "${mw320_dir}/sdk/tools/bin/Linux/axf2firmware") + execute_process(COMMAND chmod +x "${axf2fw}") # TODO, workaround for Amazon FreeRTOS console permission issue. + else() + message(FATAL_ERROR "Only Linux host is supported for marvell.") + endif() + + add_custom_command( + TARGET ${exe_target} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E remove "${exe_target}.bin" + COMMAND "${axf2fw}" "${exe_target}.axf" "${exe_target}.bin" + ) + + set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${exe_target}.bin" "${exe_target}.map") endif() - -add_custom_command( - TARGET ${exe_target} POST_BUILD - COMMAND "${CMAKE_COMMAND}" -E remove "${exe_target}.bin" - COMMAND "${axf2fw}" "${exe_target}.axf" "${exe_target}.bin" -) - -set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${exe_target}.bin" "${exe_target}.map") diff --git a/vendors/mediatek/boards/mt7697hx-dev-kit/CMakeLists.txt b/vendors/mediatek/boards/mt7697hx-dev-kit/CMakeLists.txt index 0fb0c8137bc..0b50e0501d1 100644 --- a/vendors/mediatek/boards/mt7697hx-dev-kit/CMakeLists.txt +++ b/vendors/mediatek/boards/mt7697hx-dev-kit/CMakeLists.txt @@ -320,51 +320,51 @@ target_link_libraries( # ------------------------------------------------------------------------------------------------- set(CMAKE_EXECUTABLE_SUFFIX ".axf") -# TODO, remove network manager src. -afr_glob_src(network_manager_src DIRECTORY "${AFR_DEMOS_DIR}/network_manager") afr_glob_src(board_code_src DIRECTORY "${board_dir}/application_code/mediatek_code") afr_glob_src(config_files DIRECTORY "${board_dir}/config_files") -add_executable( - ${exe_target} - ${board_code_src} - ${config_files} - $ - "${board_dir}/startup_mt7687.s" - "${board_dir}/application_code/main.c" - "${board_dir}/application_code/mediatek_code/source/sys_init.c" - "${board_dir}/application_code/mediatek_code/source/system_mt7687.c" - "${board_dir}/application_code/mediatek_code/source/ept_gpio_var.c" - "${board_dir}/application_code/mediatek_code/source/ept_eint_var.c" - - "${AFR_VENDORS_DIR}/mediatek/sdk/kernel/service/src/exception_handler.c" - "${AFR_VENDORS_DIR}/mediatek/sdk/kernel/service/src/toi.c" - "${AFR_VENDORS_DIR}/mediatek/sdk/kernel/service/src/os_trace_callback.c" - "${AFR_VENDORS_DIR}/mediatek/sdk/kernel/service/src/os_port_callback.c" - "${AFR_VENDORS_DIR}/mediatek/sdk/kernel/service/src/memory_regions.c" -) - -target_link_libraries( - ${exe_target} - PRIVATE - AFR::utils - "${AFR_VENDORS_DIR}/mediatek/sdk/prebuilt/keil/libwifi_CM4_Keil.lib" - "${AFR_VENDORS_DIR}/mediatek/sdk/prebuilt/keil/libhal_core_CM4_Keil.lib" - "${AFR_VENDORS_DIR}/mediatek/sdk/prebuilt/keil/libhal_protected_CM4_Keil.lib" - "${AFR_VENDORS_DIR}/mediatek/sdk/prebuilt/keil/libkservice_CM4_MT7687_Keil.lib" - "${AFR_VENDORS_DIR}/mediatek/sdk/prebuilt/keil/libminicli_CM4_Keil.lib" - "${AFR_VENDORS_DIR}/mediatek/sdk/prebuilt/keil/libminisupp_CM4_Keil.lib" - ${link_extra_flags} - AFR::wifi -) - -find_program(fromelf fromelf.exe PATHS "${AFR_COMPILER_DIR}") -set(output_bin_file "$/${exe_target}.bin") -set(output_axf_file "$/${exe_target}.axf") - -add_custom_command( - TARGET ${exe_target} POST_BUILD - COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_BINARY_DIR}" - COMMAND "echo" "Creating .bin file" - COMMAND "${fromelf}" --bin -o ${output_bin_file} ${output_axf_file} -) +# Do not add demos or tests if they're turned off. +if(AFR_ENABLE_DEMOS OR AFR_ENABLE_TESTS) + add_executable( + ${exe_target} + ${board_code_src} + ${config_files} + "${board_dir}/startup_mt7687.s" + "${board_dir}/application_code/main.c" + "${board_dir}/application_code/mediatek_code/source/sys_init.c" + "${board_dir}/application_code/mediatek_code/source/system_mt7687.c" + "${board_dir}/application_code/mediatek_code/source/ept_gpio_var.c" + "${board_dir}/application_code/mediatek_code/source/ept_eint_var.c" + + "${AFR_VENDORS_DIR}/mediatek/sdk/kernel/service/src/exception_handler.c" + "${AFR_VENDORS_DIR}/mediatek/sdk/kernel/service/src/toi.c" + "${AFR_VENDORS_DIR}/mediatek/sdk/kernel/service/src/os_trace_callback.c" + "${AFR_VENDORS_DIR}/mediatek/sdk/kernel/service/src/os_port_callback.c" + "${AFR_VENDORS_DIR}/mediatek/sdk/kernel/service/src/memory_regions.c" + ) + + target_link_libraries( + ${exe_target} + PRIVATE + AFR::utils + "${AFR_VENDORS_DIR}/mediatek/sdk/prebuilt/keil/libwifi_CM4_Keil.lib" + "${AFR_VENDORS_DIR}/mediatek/sdk/prebuilt/keil/libhal_core_CM4_Keil.lib" + "${AFR_VENDORS_DIR}/mediatek/sdk/prebuilt/keil/libhal_protected_CM4_Keil.lib" + "${AFR_VENDORS_DIR}/mediatek/sdk/prebuilt/keil/libkservice_CM4_MT7687_Keil.lib" + "${AFR_VENDORS_DIR}/mediatek/sdk/prebuilt/keil/libminicli_CM4_Keil.lib" + "${AFR_VENDORS_DIR}/mediatek/sdk/prebuilt/keil/libminisupp_CM4_Keil.lib" + ${link_extra_flags} + AFR::wifi + ) + + find_program(fromelf fromelf.exe PATHS "${AFR_COMPILER_DIR}") + set(output_bin_file "$/${exe_target}.bin") + set(output_axf_file "$/${exe_target}.axf") + + add_custom_command( + TARGET ${exe_target} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_BINARY_DIR}" + COMMAND "echo" "Creating .bin file" + COMMAND "${fromelf}" --bin -o ${output_bin_file} ${output_axf_file} + ) +endif() diff --git a/vendors/microchip/boards/curiosity_pic32mzef/CMakeLists.txt b/vendors/microchip/boards/curiosity_pic32mzef/CMakeLists.txt index 64644529d9b..60294c922c0 100644 --- a/vendors/microchip/boards/curiosity_pic32mzef/CMakeLists.txt +++ b/vendors/microchip/boards/curiosity_pic32mzef/CMakeLists.txt @@ -254,58 +254,9 @@ target_link_libraries( INTERFACE AFR::pkcs11 ) -# ------------------------------------------------------------------------------------------------- -# Amazon FreeRTOS demos and tests -# ------------------------------------------------------------------------------------------------- - -if(AFR_IS_TESTING) - set(exe_target aws_tests) - set(extra_exe_sources "${AFR_TESTS_DIR}/common/iot_tests_network.c") -else() - set(exe_target aws_demos) - set( - extra_exe_sources - ${NETWORK_MANAGER_SOURCES} - ) -endif() - -afr_glob_src(microchip_code RECURSE DIRECTORY "${board_dir}/application_code/microchip_code") -afr_glob_src(config_files DIRECTORY "${board_dir}/config_files") -add_executable( - ${exe_target} - ${config_files} - "${board_dir}/application_code/main.c" - ${microchip_code} - ${extra_exe_sources} - "${board_dir}/application_code/microchip_code/app_mz.ld" -) - -target_link_libraries( - ${exe_target} - PRIVATE - AFR::wifi - AFR::utils - "${harmony_dir}/bin/framework/peripheral/PIC32MZ2048EFM100_peripherals.a" -) - -target_include_directories( - ${exe_target} - PUBLIC - "${harmony_dir}/framework/system/common" -) - - -if(AFR_METADATA_MODE) - return() -endif() - - # ------------------------------------------------------------------------------------------------- # Additional build configurations # ------------------------------------------------------------------------------------------------- -set(CMAKE_EXECUTABLE_SUFFIX ".elf") - - set_source_files_properties(${AFR_MODULES_C_SDK_DIR}/aws/greengrass/aws_greengrass_discovery.c ${AFR_DEMOS_DIR}/tcp/aws_tcp_echo_client_single_task.c ${AFR_DEMOS_DIR}/secure_sockets/iot_test_tcp.c @@ -336,39 +287,83 @@ set_source_files_properties(${AFR_DEMOS_DIR}/posix/iot_test_posix_pthread.c set(CMAKE_STATIC_LIBRARY_PREFIX "lib") +# ------------------------------------------------------------------------------------------------- +# Amazon FreeRTOS demos and tests +# ------------------------------------------------------------------------------------------------- +set(CMAKE_EXECUTABLE_SUFFIX ".elf") -find_program(xc32_bin2hex xc32-bin2hex PATHS "${AFR_COMPILER_DIR}") -find_program(xc32_objcopy xc32-objcopy PATHS "${AFR_COMPILER_DIR}") +afr_glob_src(microchip_code RECURSE DIRECTORY "${board_dir}/application_code/microchip_code") +afr_glob_src(config_files DIRECTORY "${board_dir}/config_files") -# Locate microchip hexmate. -set(MCHP_HEXMATE_PATH "" CACHE STRING "Path to microchip hexmate, usually this should be mplab's path") -find_program(hexmate_path hexmate PATHS "${MCHP_HEXMATE_PATH}" PATH_SUFFIXES bin) -if (NOT AFR_METADATA_MODE) - if(NOT hexmate_path) - message(FATAL_ERROR "Cannot find Microchip's hexmate tool. Set MCHP_HEXMATE_PATH to the hexmate tool that comes with MPLAB. Try MPLABX\{VERSION}\mplab_platform\bin or /Applications/microchip/mplabx/{VERSION}/mplab_ide.app/Contents/Resources/mplab_ide/bin.") - endif() +if(AFR_IS_TESTING) + set(exe_target aws_tests) + set(extra_exe_sources "${AFR_TESTS_DIR}/common/iot_tests_network.c") +else() + set(exe_target aws_demos) endif() -# These locations have to be generalized through the toolchain -# We may have to re-build the bootloader hex file? -set(bl_hex_file ${CMAKE_CURRENT_LIST_DIR}/bootloader/aws_bootloader.X.production.hex) - -set(output_hex_file "$/${exe_target}.hex") -set(output_bin_file "$/${exe_target}.production.bin") -add_custom_command( - TARGET ${exe_target} POST_BUILD - COMMAND "echo" "Running Post-build step" - COMMAND "${xc32_bin2hex}" "$" - COMMAND "echo" "Running Hexmate to combine bootloader with image" - COMMAND "${hexmate_path}" ${output_hex_file} ${bl_hex_file} -O${exe_target}.production.unified.hex -) -if(NOT AFR_IS_TESTING) - set(ota_image_generator "${CMAKE_CURRENT_LIST_DIR}/bootloader/bootloader/utility/ota_image_generator.py") +# Do not add demos or tests if they're turned off. +if(AFR_ENABLE_DEMOS OR AFR_ENABLE_TESTS) + add_executable( + ${exe_target} + ${config_files} + "${board_dir}/application_code/main.c" + ${microchip_code} + ${extra_exe_sources} + "${board_dir}/application_code/microchip_code/app_mz.ld" + ) + + target_link_libraries( + ${exe_target} + PRIVATE + AFR::wifi + AFR::utils + "${harmony_dir}/bin/framework/peripheral/PIC32MZ2048EFM100_peripherals.a" + ) + + target_include_directories( + ${exe_target} + PUBLIC + "${harmony_dir}/framework/system/common" + ) + + if(AFR_METADATA_MODE) + return() + endif() + + find_program(xc32_bin2hex xc32-bin2hex PATHS "${AFR_COMPILER_DIR}") + find_program(xc32_objcopy xc32-objcopy PATHS "${AFR_COMPILER_DIR}") + + # Locate microchip hexmate. + set(MCHP_HEXMATE_PATH "" CACHE STRING "Path to microchip hexmate, usually this should be mplab's path") + find_program(hexmate_path hexmate PATHS "${MCHP_HEXMATE_PATH}" PATH_SUFFIXES bin) + if (NOT AFR_METADATA_MODE) + if(NOT hexmate_path) + message(FATAL_ERROR "Cannot find Microchip's hexmate tool. Set MCHP_HEXMATE_PATH to the hexmate tool that comes with MPLAB. Try MPLABX\{VERSION}\mplab_platform\bin or /Applications/microchip/mplabx/{VERSION}/mplab_ide.app/Contents/Resources/mplab_ide/bin.") + endif() + endif() + + # These locations have to be generalized through the toolchain + # We may have to re-build the bootloader hex file? + set(bl_hex_file ${CMAKE_CURRENT_LIST_DIR}/bootloader/aws_bootloader.X.production.hex) + + set(output_hex_file "$/${exe_target}.hex") + set(output_bin_file "$/${exe_target}.production.bin") add_custom_command( TARGET ${exe_target} POST_BUILD - COMMAND "echo" "Running xc32-objcopy" - COMMAND "${xc32_objcopy}" -I ihex ${output_hex_file} -O binary "${output_bin_file}" - COMMAND "echo" "Creating binary image" - COMMAND "python" "${ota_image_generator}" -b "${output_bin_file}" -p MCHP-Curiosity-PIC32MZEF + COMMAND "echo" "Running Post-build step" + COMMAND "${xc32_bin2hex}" "$" + COMMAND "echo" "Running Hexmate to combine bootloader with image" + COMMAND "${hexmate_path}" ${output_hex_file} ${bl_hex_file} -O${exe_target}.production.unified.hex ) + if(NOT AFR_IS_TESTING) + set(ota_image_generator "${CMAKE_CURRENT_LIST_DIR}/bootloader/bootloader/utility/ota_image_generator.py") + add_custom_command( + TARGET ${exe_target} POST_BUILD + COMMAND "echo" "Running xc32-objcopy" + COMMAND "${xc32_objcopy}" -I ihex ${output_hex_file} -O binary "${output_bin_file}" + COMMAND "echo" "Creating binary image" + COMMAND "python" "${ota_image_generator}" -b "${output_bin_file}" -p MCHP-Curiosity-PIC32MZEF + ) + endif() endif() diff --git a/vendors/nordic/boards/nrf52840-dk/CMakeLists.txt b/vendors/nordic/boards/nrf52840-dk/CMakeLists.txt index e3e4112989e..e8eb9db89e2 100644 --- a/vendors/nordic/boards/nrf52840-dk/CMakeLists.txt +++ b/vendors/nordic/boards/nrf52840-dk/CMakeLists.txt @@ -468,8 +468,6 @@ else() set(exe_target aws_demos) endif() -include("${CMAKE_CURRENT_LIST_DIR}/bootloader.cmake") - # Do not add demos or tests if they're turned off. if(AFR_ENABLE_DEMOS OR AFR_ENABLE_TESTS) @@ -522,7 +520,7 @@ if(AFR_ENABLE_DEMOS OR AFR_ENABLE_TESTS) find_program(gcc_size arm-none-eabi-size) if(NOT gcc_objectcopy ) - message(FATAL_ERROR "Cannot find arm-none-eabi-objcopy.") + message(FATAL_ERROR "Cannot find objcopy.") endif() set(output_file "$/${build_target}.hex") @@ -540,6 +538,12 @@ if(AFR_ENABLE_DEMOS OR AFR_ENABLE_TESTS) endfunction() + if (AFR_METADATA_MODE) + return() + endif() + + include("${CMAKE_CURRENT_LIST_DIR}/bootloader.cmake") + nrf52840_build( bootloader bootloader_mkld_flags diff --git a/vendors/nuvoton/boards/numaker_iot_m487_wifi/CMakeLists.txt b/vendors/nuvoton/boards/numaker_iot_m487_wifi/CMakeLists.txt index 35d9298b78c..e21be27fa0d 100644 --- a/vendors/nuvoton/boards/numaker_iot_m487_wifi/CMakeLists.txt +++ b/vendors/nuvoton/boards/numaker_iot_m487_wifi/CMakeLists.txt @@ -42,18 +42,18 @@ target_compile_definitions( AFR::compiler::mcu_port INTERFACE $<$:${compiler_defined_symbols}> -D__MICROLIB - -D_REENT_SMALL - -DPRODUCT_VERSION=m487 - -DCONFIG_REPEATER - -DSUPPORT_MBEDTLS - -DHAL_DFS_MODULE_ENABLED - -DLWIP_NO_STDINT_H=1 + -D_REENT_SMALL + -DPRODUCT_VERSION=m487 + -DCONFIG_REPEATER + -DSUPPORT_MBEDTLS + -DHAL_DFS_MODULE_ENABLED + -DLWIP_NO_STDINT_H=1 -DLWIP_TIMEVAL_PRIVATE=1 -D__little_endian__=1 -DNDEBUG - -DUNITY_INCLUDE_CONFIG_H - -DRVDS_ARMCM4_NUC4xx - -D__LITTLE_ENDIAN__ + -DUNITY_INCLUDE_CONFIG_H + -DRVDS_ARMCM4_NUC4xx + -D__LITTLE_ENDIAN__ -DM487 ) target_compile_definitions( @@ -99,7 +99,7 @@ afr_mcu_port(kernel) target_sources( AFR::kernel::mcu_port INTERFACE - # Nuvoton SDK sources (driver) + # Nuvoton SDK sources (driver) "${AFR_VENDORS_DIR}/nuvoton/sdk/StdDriver/src/clk.c" "${AFR_VENDORS_DIR}/nuvoton/sdk/StdDriver/src/crypto.c" "${AFR_VENDORS_DIR}/nuvoton/sdk/StdDriver/src/fmc.c" @@ -130,7 +130,7 @@ target_include_directories( afr_mcu_port(wifi) target_sources( AFR::wifi::mcu_port - INTERFACE + INTERFACE "${afr_ports_dir}/wifi/iot_wifi.c" "${AFR_VENDORS_DIR}/nuvoton/sdk/middleware/wifi_esp8266/esp8266_wifi.c" ) @@ -138,7 +138,7 @@ target_sources( target_include_directories( AFR::wifi::mcu_port INTERFACE - "${AFR_VENDORS_DIR}/nuvoton/sdk/middleware/wifi_esp8266" + "${AFR_VENDORS_DIR}/nuvoton/sdk/middleware/wifi_esp8266" ) # PKCS11 @@ -154,7 +154,7 @@ afr_mcu_port(secure_sockets) target_sources( AFR::secure_sockets::mcu_port - INTERFACE + INTERFACE "${afr_ports_dir}/secure_sockets/iot_secure_sockets.c" ) @@ -171,37 +171,34 @@ target_link_libraries( # ------------------------------------------------------------------------------------------------- set(CMAKE_EXECUTABLE_SUFFIX ".axf") -# TODO, remove network manager src. -afr_glob_src(network_manager_src DIRECTORY "${AFR_DEMOS_DIR}/network_manager") afr_glob_src(config_files DIRECTORY "${board_dir}/config_files") -add_executable( - ${exe_target} - ${board_code_src} - ${config_files} - "${board_dir}/application_code/main.c" - "${AFR_VENDORS_DIR}/nuvoton/sdk/Device/Nuvoton/numaker_iot_m487_wifi/Source/ARM/startup_M480.s" - "${AFR_VENDORS_DIR}/nuvoton/sdk/Device/Nuvoton/numaker_iot_m487_wifi/Source/system_M480.c" - $ - -) - -target_link_libraries( - ${exe_target} - PRIVATE - AFR::wifi - AFR::utils -) - -if(NOT AFR_METADATA_MODE) - # Convert afx file to bin file - afr_find_compiler(ARM_KEIL_FROMELF fromelf.exe) +# Do not add demos or tests if they're turned off. +if(AFR_ENABLE_DEMOS OR AFR_ENABLE_TESTS) + add_executable( + ${exe_target} + ${board_code_src} + ${config_files} + "${board_dir}/application_code/main.c" + "${AFR_VENDORS_DIR}/nuvoton/sdk/Device/Nuvoton/numaker_iot_m487_wifi/Source/ARM/startup_M480.s" + "${AFR_VENDORS_DIR}/nuvoton/sdk/Device/Nuvoton/numaker_iot_m487_wifi/Source/system_M480.c" + ) + target_link_libraries( + ${exe_target} + PRIVATE + AFR::wifi + AFR::utils + ) + + if(NOT AFR_METADATA_MODE) + # Convert afx file to bin file + find_program(ARM_KEIL_FROMELF fromelf.exe PATHS "${AFR_COMPILER_DIR}") + endif() + + add_custom_command( + TARGET ${exe_target} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_BINARY_DIR}" + COMMAND "${ARM_KEIL_FROMELF}" --bin "${exe_target}.axf" --output "${exe_target}.bin" + COMMAND "${ARM_KEIL_FROMELF}" --text -c "${exe_target}.axf" --output "${exe_target}.txt" + ) endif() - -add_custom_command( - TARGET ${exe_target} POST_BUILD - COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_BINARY_DIR}" - COMMAND "${ARM_KEIL_FROMELF}" --bin "${exe_target}.axf" --output "${exe_target}.bin" - COMMAND "${ARM_KEIL_FROMELF}" --text -c "${exe_target}.axf" --output "${exe_target}.txt" -) - diff --git a/vendors/nxp/boards/lpc54018iotmodule/CMakeLists.txt b/vendors/nxp/boards/lpc54018iotmodule/CMakeLists.txt index ecd6e487f7c..b0925cc144e 100644 --- a/vendors/nxp/boards/lpc54018iotmodule/CMakeLists.txt +++ b/vendors/nxp/boards/lpc54018iotmodule/CMakeLists.txt @@ -281,24 +281,22 @@ endif() afr_glob_src(board_code_src DIRECTORY "${lpc54018_aws_dir}/application_code/nxp_code") afr_glob_src(config_files_src DIRECTORY "${lpc54018_aws_dir}/config_files") -# TODO, remove network manager src. -afr_glob_src(network_manager_src DIRECTORY "${AFR_DEMOS_DIR}/network_manager") - -add_executable(${exe_target} - ${board_code_src} - ${config_files_src} - "${lpc54018_aws_dir}/application_code/main.c" - # TODO, It is unknown why hw_poll.c has to be included here - "${lpc54018_ports_dir}/pkcs11/hw_poll.c" - $<$:${network_manager_src}> -) - -target_link_libraries( - ${exe_target} - PRIVATE - AFR::wifi - AFR::utils -) +# Do not add demos or tests if they're turned off. +if(AFR_ENABLE_DEMOS OR AFR_ENABLE_TESTS) + add_executable(${exe_target} + ${board_code_src} + ${config_files_src} + "${lpc54018_aws_dir}/application_code/main.c" + # TODO, It is unknown why hw_poll.c has to be included here + "${lpc54018_ports_dir}/pkcs11/hw_poll.c" + ) + target_link_libraries( + ${exe_target} + PRIVATE + AFR::wifi + AFR::utils + ) +endif() if(NOT AFR_METADATA_MODE) message(FATAL_ERROR "CMake support for nxp is not complete yet.") diff --git a/vendors/pc/boards/windows/CMakeLists.txt b/vendors/pc/boards/windows/CMakeLists.txt index bbebcc50999..32483e67e17 100644 --- a/vendors/pc/boards/windows/CMakeLists.txt +++ b/vendors/pc/boards/windows/CMakeLists.txt @@ -134,8 +134,6 @@ target_link_libraries( # ------------------------------------------------------------------------------------------------- # Amazon FreeRTOS demos and tests # ------------------------------------------------------------------------------------------------- -# TODO, remove network manager src. -afr_glob_src(network_manager_src DIRECTORY "${AFR_DEMOS_DIR}/network_manager") afr_glob_src(config_files DIRECTORY "${board_dir}/config_files") # Build an OTA test that only builds on Windows. @@ -149,27 +147,28 @@ if(AFR_IS_TESTING) set(exe_target aws_tests) else() set(exe_target aws_demos) - set(extra_src ${network_manager_src}) endif() -add_executable( - ${exe_target} - "${board_dir}/application_code/main.c" - "${board_demos_dir}/application_code/aws_demo_logging.c" - "${board_demos_dir}/application_code/aws_demo_logging.h" - "${board_demos_dir}/application_code/aws_entropy_hardware_poll.c" - "${board_demos_dir}/application_code/aws_run-time-stats-utils.c" - ${extra_src} -) -target_include_directories( - ${exe_target} - PRIVATE - "${board_demos_dir}/application_code" -) -target_link_libraries( - ${exe_target} - PRIVATE - AFR::freertos_plus_tcp - AFR::utils - AFR::dev_mode_key_provisioning -) +# Do not add demos or tests if they're turned off. +if(AFR_ENABLE_DEMOS OR AFR_ENABLE_TESTS) + add_executable( + ${exe_target} + "${board_dir}/application_code/main.c" + "${board_demos_dir}/application_code/aws_demo_logging.c" + "${board_demos_dir}/application_code/aws_demo_logging.h" + "${board_demos_dir}/application_code/aws_entropy_hardware_poll.c" + "${board_demos_dir}/application_code/aws_run-time-stats-utils.c" + ) + target_include_directories( + ${exe_target} + PRIVATE + "${board_demos_dir}/application_code" + ) + target_link_libraries( + ${exe_target} + PRIVATE + AFR::freertos_plus_tcp + AFR::utils + AFR::dev_mode_key_provisioning + ) +endif() diff --git a/vendors/renesas/boards/rx65n-rsk/CMakeLists.txt b/vendors/renesas/boards/rx65n-rsk/CMakeLists.txt index 68562372806..2a16bcc0ba0 100644 --- a/vendors/renesas/boards/rx65n-rsk/CMakeLists.txt +++ b/vendors/renesas/boards/rx65n-rsk/CMakeLists.txt @@ -247,22 +247,20 @@ set(CMAKE_EXECUTABLE_SUFFIX "abs") afr_glob_src(board_code_src DIRECTORY "${rx65nrsk_aws_dir}/application_code/renesas_code") afr_glob_src(config_files_src DIRECTORY "${rx65nrsk_aws_dir}/config_files") -# TODO, remove network manager src. -afr_glob_src(network_manager_src DIRECTORY "${AFR_DEMOS_DIR}/network_manager") - -add_executable(${exe_target} - ${board_code_src} - ${config_files_src} - "${rx65nrsk_aws_dir}/application_code/main.c" - $<$:${network_manager_src}> -) - -target_link_libraries( - ${exe_target} - PRIVATE - AFR::freertos_plus_tcp - AFR::utils -) +# Do not add demos or tests if they're turned off. +if(AFR_ENABLE_DEMOS OR AFR_ENABLE_TESTS) + add_executable(${exe_target} + ${board_code_src} + ${config_files_src} + "${rx65nrsk_aws_dir}/application_code/main.c" + ) + target_link_libraries( + ${exe_target} + PRIVATE + AFR::freertos_plus_tcp + AFR::utils + ) +endif() if(NOT AFR_METADATA_MODE) message(FATAL_ERROR "CMake support for nxp is not complete yet.") diff --git a/vendors/st/boards/stm32l475_discovery/CMakeLists.txt b/vendors/st/boards/stm32l475_discovery/CMakeLists.txt index ed8b200a4f2..4d8a55ee03e 100644 --- a/vendors/st/boards/stm32l475_discovery/CMakeLists.txt +++ b/vendors/st/boards/stm32l475_discovery/CMakeLists.txt @@ -154,57 +154,43 @@ else() set(exe_target aws_demos) endif() -# TODO, remove network manager src. -afr_glob_src(network_manager_src DIRECTORY "${AFR_DEMOS_DIR}/network_manager") afr_glob_src(board_code_src DIRECTORY "${board_dir}/application_code/st_code") afr_glob_src(config_files DIRECTORY "${board_dir}/config_files") -if(AFR_IS_TESTING) -add_executable( - ${exe_target} - ${board_code_src} - ${config_files} - "${board_dir}/application_code/main.c" -) -else() -add_executable( - ${exe_target} - ${board_code_src} - ${config_files} - ${network_manager_src} - "${board_dir}/application_code/main.c" -) -endif() - -target_link_libraries( - ${exe_target} - PRIVATE - AFR::wifi - AFR::utils - -T"${board_dir}/STM32L475VGTx_FLASH.ld" -) - -if(AFR_METADATA_MODE) - return() +# Do not add demos or tests if they're turned off. +if(AFR_ENABLE_DEMOS OR AFR_ENABLE_TESTS) + add_executable( + ${exe_target} + ${board_code_src} + ${config_files} + "${board_dir}/application_code/main.c" + ) + target_link_libraries( + ${exe_target} + PRIVATE + AFR::wifi + AFR::utils + -T"${board_dir}/STM32L475VGTx_FLASH.ld" + ) + + if(AFR_METADATA_MODE) + return() + endif() + + find_program(gcc_objcopy arm-none-eabi-objcopy) + find_program(gcc_size arm-none-eabi-size) + if(NOT gcc_objcopy) + message(FATAL_ERROR "Cannot find arm-none-eabi-objcopy.") + endif() + + set(output_file "$/${exe_target}.hex") + add_custom_command( + TARGET ${exe_target} POST_BUILD + COMMAND "${gcc_objcopy}" -O ihex "$" "${output_file}" + COMMAND "${gcc_size}" "$" + ) + add_custom_command( + TARGET ${exe_target} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy "${output_file}" "${CMAKE_BINARY_DIR}" + ) endif() - -# ------------------------------------------------------------------------------------------------- -# Additional build configurations -# ------------------------------------------------------------------------------------------------- - -find_program(gcc_objcopy arm-none-eabi-objcopy) -find_program(gcc_size arm-none-eabi-size) -if(NOT gcc_objcopy) - message(FATAL_ERROR "Cannot find arm-none-eabi-objcopy.") -endif() - -set(output_file "$/${exe_target}.hex") -add_custom_command( - TARGET ${exe_target} POST_BUILD - COMMAND "${gcc_objcopy}" -O ihex "$" "${output_file}" - COMMAND "${gcc_size}" "$" -) -add_custom_command( - TARGET ${exe_target} POST_BUILD - COMMAND "${CMAKE_COMMAND}" -E copy "${output_file}" "${CMAKE_BINARY_DIR}" -) diff --git a/vendors/ti/boards/cc3220_launchpad/CMakeLists.txt b/vendors/ti/boards/cc3220_launchpad/CMakeLists.txt index 4fa51301dd1..1ef1c0d1d85 100644 --- a/vendors/ti/boards/cc3220_launchpad/CMakeLists.txt +++ b/vendors/ti/boards/cc3220_launchpad/CMakeLists.txt @@ -174,41 +174,41 @@ target_sources( # ------------------------------------------------------------------------------------------------- set(CMAKE_EXECUTABLE_SUFFIX ".out") -# TODO, remove network manager src. -afr_glob_src(network_manager_src DIRECTORY "${AFR_DEMOS_DIR}/network_manager") afr_glob_src(board_code_src DIRECTORY "${board_dir}/application_code/ti_code") afr_glob_src(config_files DIRECTORY "${board_dir}/config_files") -add_executable( - ${exe_target} - ${board_code_src} - ${config_files} - "${board_dir}/application_code/main.c" - $<$:${network_manager_src}> - "${board_dir}/application_code/ti_code/CC3220SF_LAUNCHXL_FREERTOS.cmd" -) -target_link_libraries( - ${exe_target} - PRIVATE - AFR::wifi - AFR::utils - AFR::posix::mcu_port - ${link_extra_flags} -) -add_custom_command( - TARGET ${exe_target} POST_BUILD - COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_BINARY_DIR}" -) - -find_program(tiobj2bin tiobj2bin PATHS "${TI_CCS_PATH}/utils/tiobj2bin") -find_program(mkhex4bin mkhex4bin PATHS "${TI_CCS_PATH}/utils/tiobj2bin") -find_program(armofd armofd PATHS "${AFR_COMPILER_DIR}") -find_program(armhex armhex PATHS "${AFR_COMPILER_DIR}") -if(tiobj2bin) - set(output_file "$/${exe_target}.hex") +# Do not add demos or tests if they're turned off. +if(AFR_ENABLE_DEMOS OR AFR_ENABLE_TESTS) + add_executable( + ${exe_target} + ${board_code_src} + ${config_files} + "${board_dir}/application_code/main.c" + "${board_dir}/application_code/ti_code/CC3220SF_LAUNCHXL_FREERTOS.cmd" + ) + target_link_libraries( + ${exe_target} + PRIVATE + AFR::wifi + AFR::utils + AFR::posix::mcu_port + ${link_extra_flags} + ) add_custom_command( TARGET ${exe_target} POST_BUILD - COMMAND "${tiobj2bin}" "${CMAKE_BINARY_DIR}/${exe_target}.out" "${CMAKE_BINARY_DIR}/${exe_target}.bin" - "${armofd}" "${armhex}" "${mkhex4bin}" + COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_BINARY_DIR}" ) + + find_program(tiobj2bin tiobj2bin PATHS "${TI_CCS_PATH}/utils/tiobj2bin") + find_program(mkhex4bin mkhex4bin PATHS "${TI_CCS_PATH}/utils/tiobj2bin") + find_program(armofd armofd PATHS "${AFR_COMPILER_DIR}") + find_program(armhex armhex PATHS "${AFR_COMPILER_DIR}") + if(tiobj2bin) + set(output_file "$/${exe_target}.hex") + add_custom_command( + TARGET ${exe_target} POST_BUILD + COMMAND "${tiobj2bin}" "${CMAKE_BINARY_DIR}/${exe_target}.out" "${CMAKE_BINARY_DIR}/${exe_target}.bin" + "${armofd}" "${armhex}" "${mkhex4bin}" + ) + endif() endif() diff --git a/vendors/vendor/boards/board/CMakeLists.txt b/vendors/vendor/boards/board/CMakeLists.txt index 37c3db378fc..04a3bda8e87 100644 --- a/vendors/vendor/boards/board/CMakeLists.txt +++ b/vendors/vendor/boards/board/CMakeLists.txt @@ -215,24 +215,27 @@ afr_set_board_metadata(KEY_IMPORT_PROVISIONING "TRUE") # scripts and post build commands. # ==================== Example ==================== -# set(CMAKE_EXECUTABLE_SUFFIX ".out") - -# set(default_modules AFR::wifi AFR::utils) - -# if(AFR_IS_TESTING) -# set(exe_target aws_tests) -# else() -# set(exe_target aws_demos) +# Do not add demos or tests if they're turned off. +# if(AFR_ENABLE_DEMOS OR AFR_ENABLE_TESTS) +# set(CMAKE_EXECUTABLE_SUFFIX ".out") + +# set(default_modules AFR::wifi AFR::utils) + +# if(AFR_IS_TESTING) +# set(exe_target aws_tests) +# else() +# set(exe_target aws_demos) +# endif() + +# add_executable(${exe_target} "${board_dir}/application_code/main.c") +# target_link_libraries( +# ${exe_target} +# PRIVATE +# ${default_modules} +# ${additional_linker_file_and_flags} +# ) +# add_custom_command( +# TARGET ${exe_target} POST_BUILD +# COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_BINARY_DIR}" +# ) # endif() - -# add_executable(${exe_target} "${board_dir}/application_code/main.c") -# target_link_libraries( -# ${exe_target} -# PRIVATE -# ${default_modules} -# ${additional_linker_file_and_flags} -# ) -# add_custom_command( -# TARGET ${exe_target} POST_BUILD -# COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_BINARY_DIR}" -# ) diff --git a/vendors/xilinx/boards/microzed/CMakeLists.txt b/vendors/xilinx/boards/microzed/CMakeLists.txt index 4b83bdfc00f..79b966931ba 100644 --- a/vendors/xilinx/boards/microzed/CMakeLists.txt +++ b/vendors/xilinx/boards/microzed/CMakeLists.txt @@ -167,25 +167,9 @@ target_link_libraries( # ------------------------------------------------------------------------------------------------- set(CMAKE_EXECUTABLE_SUFFIX ".elf") -afr_glob_src(network_manager_src DIRECTORY "${AFR_DEMOS_DIR}/network_manager") afr_glob_src(board_code_src DIRECTORY "${board_dir}/application_code/xilinx_code") afr_glob_src(config_files DIRECTORY "${board_dir}/config_files") -add_executable( - ${exe_target} - ${board_code_src} - "${board_dir}/application_code/xilinx_code/FreeRTOS_tick_config.c" - ${config_files} - "${board_dir}/application_code/main.c" - $<$:${network_manager_src}> -) - -target_link_libraries( - ${exe_target} - PRIVATE - AFR::utils -) - # The kernel is the root dependency, linking the library flags like this ensures it adds the flags last in the command line set(link_extra_flags -Wl,--start-group,-lxilffs,-lxil,-lgcc,-lc,-lrsa,--end-group) @@ -195,21 +179,36 @@ target_link_libraries( ${link_extra_flags} ) - -set(bootgen "${AFR_COMPILER_DIR}/../../../../../bin/bootgen.bat") - -if(AFR_IS_TESTING) -add_custom_command( - TARGET ${exe_target} POST_BUILD - COMMAND "echo" "Running Post-build step" - COMMAND "${bootgen}" -w -image "${board_dir}/aws_tests.bif" -arch zynq -o BOOT.bin -) -else() -add_custom_command( - TARGET ${exe_target} POST_BUILD - COMMAND "echo" "Running Post-build step" - COMMAND "${bootgen}" -w -image "${board_dir}/aws_demos.bif" -arch zynq -o BOOT.bin -) +# Do not add demos or tests if they're turned off. +if(AFR_ENABLE_DEMOS OR AFR_ENABLE_TESTS) + add_executable( + ${exe_target} + ${board_code_src} + ${config_files} + "${board_dir}/application_code/xilinx_code/FreeRTOS_tick_config.c" + "${board_dir}/application_code/main.c" + ) + target_link_libraries( + ${exe_target} + PRIVATE + AFR::utils + ) + + set(bootgen "${AFR_COMPILER_DIR}/../../../../../bin/bootgen.bat") + + if(AFR_IS_TESTING) + add_custom_command( + TARGET ${exe_target} POST_BUILD + COMMAND "echo" "Running Post-build step" + COMMAND "${bootgen}" -w -image "${board_dir}/aws_tests.bif" -arch zynq -o BOOT.bin + ) + else() + add_custom_command( + TARGET ${exe_target} POST_BUILD + COMMAND "echo" "Running Post-build step" + COMMAND "${bootgen}" -w -image "${board_dir}/aws_demos.bif" -arch zynq -o BOOT.bin + ) + endif() endif() if(NOT AFR_METADATA_MODE)