@@ -458,4 +458,160 @@ function(cy_add_link_libraries)
458
458
# message("cy_kit_utils.cmake: disable module ${module}")
459
459
afr_module_dependencies (${module} INTERFACE 3rdparty::does_not_exist )
460
460
endforeach ()
461
+
462
+ #----------------------------------------------------------------
463
+ # OTA SUPPORT
464
+ #----------------------------------------------------------------
465
+ if (OTA_SUPPORT )
466
+ #----------------------------------------------------------------
467
+ # Add AWS OTA Library
468
+ afr_mcu_port (ota )
469
+
470
+ # Define these environment variables to override default settings
471
+ # "export CY_TEST_APP_VERSION_IN_TAR=1"
472
+ # "export APP_VERSION_MAJOR=x"
473
+ # "export APP_VERSION_MINOR=y"
474
+ # "export APP_VERSION_BUILD=z"
475
+
476
+ if (NOT "${CY_TEST_APP_VERSION_IN_TAR} " STREQUAL "" )
477
+ if ( ("$ENV{APP_VERSION_MAJOR} " STREQUAL "" ) OR
478
+ ("$ENV{APP_VERSION_MINOR} " STREQUAL "" ) OR
479
+ ("$ENV{APP_VERSION_BUILD} " STREQUAL "" ) )
480
+ message (FATAL "Define APP_VERSION_MAJOR, APP_VERSION_MINOR, and APP_VERSION_BUILD when using CY_TEST_APP_VERSION_IN_TAR." )
481
+ endif ()
482
+ target_compile_definitions (AFR::ota::mcu_port INTERFACE
483
+ "-DAPP_VERSION_MAJOR=$ENV{APP_VERSION_MAJOR} "
484
+ "-DAPP_VERSION_MINOR=$ENV{APP_VERSION_MINOR} "
485
+ "-DAPP_VERSION_BUILD=$ENV{APP_VERSION_BUILD} "
486
+ )
487
+ endif ()
488
+
489
+ if ("$ENV{MCUBOOT_IMAGE_NUMBER} " STREQUAL "" )
490
+ set (ENV{MCUBOOT_IMAGE_NUMBER} "1" )
491
+ endif ()
492
+
493
+ # need these here for the mcu_port
494
+ target_compile_definitions (AFR::ota::mcu_port INTERFACE
495
+ "-DOTA_SUPPORT=1"
496
+ "-DMCUBOOT_KEY_FILE=${MCUBOOT_KEY_FILE} "
497
+ "-DCY_FLASH_ERASE_VALUE=$ENV{CY_FLASH_ERASE_VALUE} "
498
+ "-DMCUBOOT_HEADER_SIZE=$ENV{MCUBOOT_HEADER_SIZE} "
499
+ "-DMCUBOOT_IMAGE_NUMBER=$ENV{MCUBOOT_IMAGE_NUMBER} "
500
+ "-DCY_BOOT_SCRATCH_SIZE=$ENV{CY_BOOT_SCRATCH_SIZE} "
501
+ "-DCY_BOOT_BOOTLOADER_SIZE=$ENV{MCUBOOT_BOOTLOADER_SIZE} "
502
+ "-DMCUBOOT_BOOTLOADER_SIZE=$ENV{MCUBOOT_BOOTLOADER_SIZE} "
503
+ "-DCY_BOOT_PRIMARY_1_START=$ENV{CY_BOOT_PRIMARY_1_START} "
504
+ "-DCY_BOOT_PRIMARY_1_SIZE=$ENV{CY_BOOT_PRIMARY_1_SIZE} "
505
+ "-DCY_BOOT_SECONDARY_1_SIZE=$ENV{CY_BOOT_PRIMARY_1_SIZE} "
506
+ "-DCY_BOOT_SECONDARY_2_START=$ENV{CY_BOOT_SECONDARY_2_START} "
507
+ "-DCY_BOOT_SECONDARY_2_SIZE=$ENV{CY_BOOT_PRIMARY_2_SIZE} "
508
+ "-DMCUBOOT_MAX_IMG_SECTORS=$ENV{MCUBOOT_MAX_IMG_SECTORS} "
509
+ "-DCY_RETARGET_IO_CONVERT_LF_TO_CRLF=1"
510
+ )
511
+
512
+ # is CY_BOOT_USE_EXTERNAL_FLASH supported?
513
+ if ("$ENV{CY_BOOT_USE_EXTERNAL_FLASH} " STREQUAL "1" )
514
+ target_compile_definitions (AFR::ota::mcu_port INTERFACE "-DCY_BOOT_USE_EXTERNAL_FLASH=$ENV{CY_BOOT_USE_EXTERNAL_FLASH} " )
515
+ endif ()
516
+
517
+ if ("$ENV{MCUBOOT_IMAGE_NUMBER} " STREQUAL "2" )
518
+ target_compile_definitions (AFR::ota::mcu_port INTERFACE
519
+ "-DCY_BOOT_PRIMARY_2_START=$ENV{CY_BOOT_PRIMARY_2_START} "
520
+ "-DCY_BOOT_PRIMARY_2_SIZE=$ENV{CY_BOOT_PRIMARY_2_SIZE} "
521
+ "-DCY_BOOT_SECONDARY_2_SIZE=$ENV{CY_BOOT_PRIMARY_2_SIZE} "
522
+ "-DCY_BOOT_SECONDARY_2_START=$ENV{CY_BOOT_SECONDARY_2_START} "
523
+ )
524
+ endif ()
525
+
526
+ # common ota sources
527
+ target_sources (AFR::ota::mcu_port INTERFACE
528
+ "${AFR_DEMOS_DIR} /ota/aws_iot_ota_update_demo.c"
529
+ "${MCUBOOT_CYFLASH_PAL_DIR} /cy_flash_map.c"
530
+ "${MCUBOOT_CYFLASH_PAL_DIR} /cy_flash_psoc6.c"
531
+ "${MCUBOOT_CYFLASH_PAL_DIR} /flash_qspi/flash_qspi.c"
532
+ "${MCUBOOT_CYFLASH_PAL_DIR} /cy_smif_psoc6.c"
533
+ "${MCUBOOT_DIR} /bootutil/src/bootutil_misc.c"
534
+ "${cy_libraries_dir} /connectivity-utilities/JSON_parser/cy_json_parser.c"
535
+ "${cy_port_support_dir} /untar/untar.c"
536
+ )
537
+
538
+ # The ports for the secure board lives in the OTA directory since this is the only board accepted in the upstream amazon-freertos repo
539
+ #( not the cypress port) and since that board is not OTA qualified amazon did not allow putting the ota port in the ports folder with
540
+ # the board. This should be removed when the board gets qualified and at OTA port is moved with the other ports.
541
+ if (CY_TFM_PSA_SUPPORTED )
542
+ target_sources (AFR::ota::mcu_port INTERFACE "${cy_port_support_dir} /ota/ports/${AFR_BOARD_NAME} /aws_ota_pal.c" )
543
+ else ()
544
+ target_sources (AFR::ota::mcu_port INTERFACE "${afr_ports_dir} /ota/aws_ota_pal.c" )
545
+ endif ()
546
+
547
+ target_include_directories (AFR::ota::mcu_port INTERFACE
548
+ "${AFR_DEMOS_DIR} /network_manager"
549
+ "${MCUBOOT_DIR} "
550
+ "${MCUBOOT_DIR} /bootutil/include"
551
+ "${MCUBOOT_DIR} /mcuboot_header"
552
+ "${MCUBOOT_DIR} /sysflash"
553
+ "${MCUBOOT_CYFLASH_PAL_DIR} "
554
+ "${MCUBOOT_CYFLASH_PAL_DIR} /include"
555
+ "${MCUBOOT_CYFLASH_PAL_DIR} /flash_qspi"
556
+ "${cy_libraries_dir} /connectivity-utilities"
557
+ "${cy_libraries_dir} /connectivity-utilities/JSON_parser"
558
+ "${cy_port_support_dir} /untar"
559
+ "${cy_libraries_dir} /abstraction-rtos/include"
560
+ "${cy_psoc6_dir} /psoc6pdl/cmsis/include"
561
+ "${cy_psoc6_dir} /psoc6pdl/devices/include"
562
+ "${cy_psoc6_dir} /psoc6pdl/drivers/include"
563
+ "${iot_common_include} "
564
+ "${ARG_BSP_DIR} "
565
+ "${ARG_BSP_DIR} /GeneratedSource"
566
+ )
567
+
568
+ if (AFR_IS_TESTING )
569
+ # For aws_tests build for OTA and OTA PAL
570
+ # add files to build for testing
571
+ target_include_directories (AFR::ota::mcu_port INTERFACE
572
+ "${AFR_ROOT_DIR} /tests/include"
573
+ "${cy_board_dir} /aws_tests/config_files"
574
+ "${AFR_MODULES_C_SDK_DIR} /standard/https/include"
575
+ "${AFR_3RDPARTY_DIR} /unity/extras/fixture/src"
576
+ "${AFR_ROOT_DIR} /demos/include"
577
+ "${AFR_ROOT_DIR} /demos/dev_mode_key_provisioning/include"
578
+ "${AFR_MODULES_FREERTOS_PLUS_DIR} /standard/pkcs11/include"
579
+ "${AFR_MODULES_FREERTOS_PLUS_DIR} /aws/ota/src/mqtt"
580
+ "${AFR_3RDPARTY_DIR} /pkcs11"
581
+ )
582
+ else ()
583
+ # For aws_demos builds for OTA demos
584
+ # add extra includes
585
+ target_include_directories (AFR::ota::mcu_port INTERFACE
586
+ "${AFR_MODULES_FREERTOS_PLUS_DIR} /aws/ota/test"
587
+ "${cy_board_dir} /aws_demos/config_files"
588
+ )
589
+ endif ()
590
+
591
+ target_link_libraries (AFR::ota::mcu_port INTERFACE
592
+ AFR::ota_mqtt
593
+ AFR::ota_http
594
+ AFR::crypto
595
+ AFR::wifi
596
+ )
597
+
598
+ target_include_directories (psoc6_core INTERFACE
599
+ "${MCUBOOT_CYFLASH_PAL_DIR} /include"
600
+ "${MCUBOOT_CYFLASH_PAL_DIR} /flash_qspi"
601
+ "${MCUBOOT_DIR} /sysflash"
602
+ )
603
+ target_link_libraries (psoc6_core INTERFACE
604
+ AFR::ota
605
+ afr_dev_mode_key_provisioning
606
+ AFR::https
607
+ )
608
+
609
+ target_include_directories (AFR::pkcs11_implementation::mcu_port INTERFACE
610
+ "${MCUBOOT_DIR} /mcuboot_header"
611
+ )
612
+ target_include_directories (AFR::kernel::mcu_port INTERFACE
613
+ "${MCUBOOT_DIR} /mcuboot_header"
614
+ )
615
+
616
+ endif (OTA_SUPPORT )
461
617
endfunction (cy_add_link_libraries )
0 commit comments