

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 設定 LTS 資格先決條件
<a name="lts-idt-dev-tester-prereqs"></a>

本節說明使用 測試微控制器的先決條件 AWS IoT Device Tester。

## 準備 FreeRTOS 資格
<a name="idt-preparing-qualification"></a>

**注意**  
AWS IoT Device Tester for FreeRTOS 強烈建議使用最新的 FreeRTOS-LTS 版本修補程式版本。

IDT for FRQ 2.0 是 FreeRTOS 的資格。在執行 IDT FRQ 2.0 以獲得資格之前，您必須完成 FreeRTOS 資格指南中的[電路板](https://docs.aws.amazon.com/freertos/latest/qualificationguide/freertos-qualification.html)資格。 *FreeRTOS * 若要移植程式庫、測試和設定 `manifest.yml`，請參閱 [ FreeRTOS 移植指南中的移植 FreeRTOS 程式庫](https://docs.aws.amazon.com/freertos/latest/portingguide/afr-porting.html)。 *FreeRTOS * FRQ 2.0 包含不同的資格程序。如需詳細資訊，請參閱 *FreeRTOS * [資格指南中資格的最新變更](https://docs.aws.amazon.com/freertos/latest/qualificationguide/latest-changes.html)。

[FreeRTOS-Libraries-Integration-Tests](https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests) 儲存庫必須存在，IDT 才能執行。請參閱 https：//[README.md](https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests/blob/main/README.md)。FreeRTOS-Libraries-Integration-Tests 必須包含`manifest.yml`位於專案根目錄的 ，IDT 才能執行。

**注意**  
IDT 取決於測試儲存庫對 的實作`UNITY_OUTPUT_CHAR`。測試輸出日誌和裝置日誌不得互相交錯。如需更多詳細資訊，請參閱 *FreeRTOS 移植指南*中的[實作程式庫日誌巨集](https://docs.aws.amazon.com/freertos/latest/portingguide/afr-library-logging-macros.html)一節。

## 下載 IDT for FreeRTOS
<a name="idt-download-dev-tester-afr"></a>

每個 FreeRTOS 版本都有對應的 IDT for FreeRTOS 版本，以執行資格測試。從 FreeRTOS [支援的 版本下載適當的 IDT for FreeRTOS AWS IoT Device Tester 版本](https://docs.aws.amazon.com/freertos/latest/userguide/dev-test-versions-afr.html)。

將 IDT for FreeRTOS 解壓縮到檔案系統上具有讀取和寫入許可的位置。由於 Microsoft Windows 具有路徑長度的字元限制，請將 IDT for FreeRTOS 擷取到根目錄，例如 `C:\`或 `D:\`。

**注意**  
多個使用者不得從共用位置執行 IDT，例如 NFS 目錄或 Windows 網路共用資料夾。這會導致當機或資料損毀。建議您將 IDT 套件解壓縮至本機磁碟機。

## 下載 Git
<a name="idt-download-git"></a>

IDT 必須安裝 Git 作為先決條件，以確保原始碼完整性。

遵循 [GitHub](https://github.com/git-guides/install-git) 指南中的指示來安裝 Git。若要驗證目前安裝的 Git 版本，請在終端機輸入 `git --version` 命令。

**警告**  
IDT 使用 Git 來對齊目錄的乾淨或骯髒狀態。如果未安裝 Git，`FreeRTOSIntegrity`測試群組將會失敗，或無法如預期執行。如果 IDT 傳回錯誤，例如 `git executable not found`或 `git command not found`，請安裝或重新安裝 Git，然後再試一次。

**Topics**
+ [準備 FreeRTOS 資格](#idt-preparing-qualification)
+ [下載 IDT for FreeRTOS](#idt-download-dev-tester-afr)
+ [下載 Git](#idt-download-git)
+ [建立 AWS 帳戶](#lts-config-aws-account)
+ [AWS IoT Device Tester 受管政策](#managed-policy)
+ [（選用） 安裝 AWS Command Line Interface](#install-cli)

## 建立 AWS 帳戶
<a name="lts-config-aws-account"></a>

**注意**  
僅在下列 中支援完整的 IDT 資格套件 AWS 區域   
美國東部 (維吉尼亞北部)
 美國西部 (奧勒岡) 
亞太地區 (東京) 
歐洲 (愛爾蘭) 

為了測試您的裝置，IDT for FreeRTOS 會建立 AWS IoT 物件、FreeRTOS 群組和 Lambda 函數等資源。若要建立這些資源，IDT for FreeRTOS 會要求您建立和設定 AWS 帳戶，以及授予 IDT for FreeRTOS 在執行測試時代表您存取資源的 IAM 政策。

下列步驟是建立和設定 AWS 您的帳戶。

1. 如果您已有 AWS 帳戶，請跳到下一個步驟。否則，請建立 [AWS 帳戶](https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/)。

1. 請遵循[建立 IAM 角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-user.html)中的步驟。此時請勿新增許可或政策。

1. 若要執行 OTA 資格測試，請前往步驟 4。否則請前往步驟 5。

1.  將 OTA IAM 許可內嵌政策連接至您的 IAM 角色。

   1. 
**重要**  
 下列政策範本會授予 IDT 許可，允許使用者建立角色、建立政策，以及將政策附加至角色。IDT for FreeRTOS 會將這些許可用於建立角色的測試。雖然政策範本不會為使用者提供管理員權限，但許可可用來取得 AWS 您帳戶的管理員存取權。

   1.  請依照下列步驟，將必要的許可連接至您的 IAM 角色：

      1. 在**許可**頁面上，選擇**新增許可**。

      1. 選擇**建立內嵌政策**。

      1. 選擇 **JSON** 索引標籤，並將以下權限複製到 **JSON** 文字方塊中。如果您不在中國區域，請使用**大多數**區域下的範本。如果您位於中國區域，請使用**北京和寧夏區域的** 範本。

------
#### [ Most Regions ]

------
#### [ JSON ]

****  

         ```
         {
             "Version":"2012-10-17",		 	 	 
             "Statement": [
                 {
                     "Effect": "Allow",
                     "Action": "iotdeviceadvisor:*",
                     "Resource": [
                         "arn:aws:iotdeviceadvisor:*:*:suiterun/*/*",
                         "arn:aws:iotdeviceadvisor:*:*:suitedefinition/*"
                     ]
                 },
                 {
                     "Effect": "Allow",
                     "Action": "iam:PassRole",
                     "Resource": "arn:aws:iam::*:role/idt*",
                     "Condition": {
                         "StringEquals": {
                             "iam:PassedToService": "iotdeviceadvisor.amazonaws.com"
                         }
                     }
                 },
                 {
                     "Effect": "Allow",
                     "Action": [
                         "execute-api:Invoke*",
                         "iam:ListRoles",
                         "iot:Connect",  
                         "iot:CreateJob",
                         "iot:DeleteJob",
                         "iot:DescribeCertificate", 
                         "iot:DescribeEndpoint",
                         "iot:DescribeJobExecution",
                         "iot:DescribeJob",                                 
                         "iot:DescribeThing",
                         "iot:GetPolicy",
                         "iot:ListAttachedPolicies",
                         "iot:ListCertificates",
                         "iot:ListPrincipalPolicies",
                         "iot:ListThingPrincipals",
                         "iot:ListThings",
                         "iot:Publish",    
                         "iot:UpdateThingShadow",                
                         "logs:CreateLogGroup",
                         "logs:CreateLogStream",
                         "logs:DescribeLogGroups",
                         "logs:DescribeLogStreams",
                         "logs:PutLogEvents",
                         "logs:PutRetentionPolicy"
                     ],
                     "Resource": "*"
                 },
                 {
                     "Effect": "Allow",
                     "Action": "iotdeviceadvisor:*",
                     "Resource": "*"
                 },
                 {
                     "Effect": "Allow",
                     "Action": "logs:DeleteLogGroup",
                     "Resource": "arn:aws:logs:*:*:log-group:/aws/iot/deviceadvisor/*"
                 },
                 {
                     "Effect": "Allow",
                     "Action": "logs:GetLogEvents",
                     "Resource": "arn:aws:logs:*:*:log-group:/aws/iot/deviceadvisor/*:log-stream:*"
                 },
                 {
                     "Effect": "Allow",
                     "Action": [
                         "iam:CreatePolicy",
                         "iam:DetachRolePolicy",
                         "iam:DeleteRolePolicy",
                         "iam:DeletePolicy",
                         "iam:CreateRole",
                         "iam:DeleteRole",
                         "iam:AttachRolePolicy"
                     ],
                     "Resource": [
                         "arn:aws:iam::*:policy/idt*",
                         "arn:aws:iam::*:role/idt*"
                     ]
                 },
                 {
                     "Effect": "Allow",
                     "Action": [
                         "ssm:GetParameters"
                     ],
                     "Resource": [
                         "arn:aws:ssm:*::parameter/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2"
                     ]
                 },
                 {
                     "Effect": "Allow",
                     "Action": [
                         "ec2:DescribeInstances",
                         "ec2:RunInstances",
                         "ec2:CreateSecurityGroup",
                         "ec2:CreateTags",
                         "ec2:DeleteTags"
                     ],
                     "Resource": [
                         "*"
                     ]
                 },
                 {
                     "Effect": "Allow",
                     "Action": [
                         "ec2:CreateKeyPair",
                         "ec2:DeleteKeyPair"
                     ],
                     "Resource": [
                         "arn:aws:ec2:*:*:key-pair/idt-ec2-ssh-key-*"
                     ]
                 },
                 {
                     "Effect": "Allow",
                     "Condition": {
                         "StringEqualsIgnoreCase": {
                             "aws:ResourceTag/Owner": "IoTDeviceTester"
                         }
                     },
                     "Action": [
                         "ec2:TerminateInstances",
                         "ec2:DeleteSecurityGroup",
                         "ec2:AuthorizeSecurityGroupIngress",
                         "ec2:RevokeSecurityGroupIngress"
                     ],
                     "Resource": [
                         "*"
                     ]
                 }
             ]
         }
         ```

------

------
#### [ Beijing and Ningxia Regions ]

         下列政策範本可用於北京和寧夏區域。

------

      1. 完成時，請選擇 **Review policy (檢閱政策)**。

      1. 輸入 **IDTFreeRTOSIAMPermissions** 做為政策名稱。

      1. 選擇**建立政策**。

1.  將 **AWSIoTDeviceTesterForFreeRTOSFullAccess** 連接至您的 IAM 角色。

   1. 若要將必要的許可連接至您的 IAM 角色：

      1. 在**許可**頁面上，選擇**新增許可**。

      1. 選擇**連接政策**。

      1. 搜尋 **AWSIoTDeviceTesterForFreeRTOSFullAccess** 政策。勾選方塊。

   1. 選擇**新增許可**。

1. 匯出 IDT 的登入資料。如需詳細資訊，請參閱[取得 CLI 存取的 IAM 角色登入](https://docs.aws.amazon.com/singlesignon/latest/userguide/howtogetcredentials.html)資料。

## AWS IoT Device Tester 受管政策
<a name="managed-policy"></a>

`AWSIoTDeviceTesterForFreeRTOSFullAccess` 受管政策包含下列版本檢查、自動更新功能和指標集合的 AWS IoT Device Tester 許可。
+ `iot-device-tester:SupportedVersion`

   AWS IoT Device Tester 准許擷取支援的產品、測試套件和 IDT 版本清單。
+ `iot-device-tester:LatestIdt`

   AWS IoT Device Tester 准許擷取可供下載的最新 IDT 版本。
+ `iot-device-tester:CheckVersion`

   AWS IoT Device Tester 准許檢查 IDT、測試套件和產品的版本相容性。
+ `iot-device-tester:DownloadTestSuite`

   AWS IoT Device Tester 准許下載測試套件更新。
+ `iot-device-tester:SendMetrics`

   AWS 准許收集有關 AWS IoT Device Tester 內部使用的指標。

## （選用） 安裝 AWS Command Line Interface
<a name="install-cli"></a>

您可能偏好使用 AWS CLI 來執行一些操作。如果您沒有 AWS CLI 安裝 ，請遵循[安裝 AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/installing.html)中的指示。

**aws configure** 從命令列執行， AWS CLI 為您要使用的 AWS 區域設定 。如需支援 IDT for FreeRTOS AWS 的區域資訊，請參閱[AWS 區域和端點](https://docs.aws.amazon.com/general/latest/gr/rande.html#amazon-freertos-ota-control)。如需詳細資訊，**aws configure**請參閱[使用 進行快速組態**aws configure**](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-config)。