

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# OTA PAL 포트의 버전 1에서 버전 3으로 마이그레이션
<a name="porting-migration-ota-pal"></a>

무선 업데이트(OTA) 라이브러리에서는 라이브러리 및 데모 애플리케이션에 필요한 폴더 구조와 구성 배치에 몇 가지 변경 사항을 도입했습니다. v1.2.0에서 작동하도록 설계된 OTA 애플리케이션을 라이브러리 v3.0.0으로 마이그레이션하려면 이 마이그레이션 가이드에 설명된 대로 PAL 포트 함수 서명을 업데이트하고 추가 구성 파일을 포함해야 합니다.

## OTA PAL 변경 사항
<a name="porting-migration-ota-pal-changes"></a>
+ OTA PAL 포트 디렉터리 이름이 `ota`에서 `ota_pal_for_aws`로 업데이트되었습니다. 이 폴더에는 두 개의 파일 `ota_pal.c` 및 `ota_pal.h`가 있어야 합니다. PAL 헤더 파일 `libraries/freertos_plus/aws/ota/src/aws_iot_ota_pal.h`가 OTA 라이브러리에서 삭제되었으므로 포트 내부에서 정의해야 합니다.
+ 반환 코드(`OTA_Err_t`)가 열거형 `OTAMainStatus_t`로 변환됩니다. 변환된 반환 코드는 [ota\$1platform\$1interface.h](https://github.com/aws/ota-for-aws-iot-embedded-sdk/blob/v3.0.0/source/include/ota_platform_interface.h#L68-L90)를 참조하세요. [ 또한 `OtaPalMainStatus` 및 `OtaPalSubStatus` 코드를 결합하고 `OtaPalStatus` 등에서 `OtaMainStatus`를 추출할 수 있는 헬퍼 매크로](https://github.com/aws/ota-for-aws-iot-embedded-sdk/blob/666241d0f643b07d5146a3715b649d80f8135e0b/source/include/ota_platform_interface.h#L105-L111)도 제공됩니다.
+ PAL 로그인 
  + `DEFINE_OTA_METHOD_NAME` 매크로를 제거했습니다.
  + 업데이트 전: `OTA_LOG_L1( "[%s] Receive file created.\r\n", OTA_METHOD_NAME );`.
  + 업데이트 후: `LogInfo(( "Receive file created."));` 적절한 로그를 위해 `LogDebug`, `LogWarn` 및 `LogError`를 사용합니다.
+ 변수 `cOTA_JSON_FileSignatureKey`를 `OTA_JsonFileSignatureKey`로 변경했습니다.

### 함수
<a name="porting-migration-ota-pal-functions"></a>

함수 서명은 `ota_pal.h`에서 정의되며 접두사 `prvPAL` 대신 `otaPal`로 시작합니다.

**참고**  
PAL의 정확한 이름은 기술적으로 공개되어 있지만 검증 테스트와 호환되려면 아래에 지정된 이름을 따라야 합니다.


****  

|  버전 1   |  버전 3   |  노트   | 
| --- | --- | --- | 
|  `OTA_Err_t prvPAL_CreateFileForRx( OTA_FileContext_t * const *C* );`  |  `OtaPalStatus_t otaPal_CreateFileForRx( OtaFileContext_t * const *pFileContext* );`  |  데이터 청크가 들어오는 대로 새 수신 파일을 생성합니다.  | 
|  `int16_t prvPAL_WriteBlock( OTA_FileContext_t * const C, uint32_t ulOffset, uint8_t * const pcData, uint32_t ulBlockSize );`  |  `int16_t otaPal_WriteBlock( OtaFileContext_t * const pFileContext, uint32_t ulOffset, uint8_t * const pData, uint32_t ulBlockSize );`  |  지정된 파일의 지정된 오프셋에 데이터 블록을 씁니다.  | 
|  `OTA_Err_t prvPAL_ActivateNewImage( void );`  |  `OtaPalStatus_t otaPal_ActivateNewImage( OtaFileContext_t * const *pFileContext* );`  |  OTA를 통해 수신한 최신 MCU 이미지를 활성화합니다.  | 
|  `OTA_Err_t prvPAL_ResetDevice( void );`  |  `OtaPalStatus_t otaPal_ResetDevice( OtaFileContext_t * const *pFileContext* );`  |  디바이스를 재설정합니다.  | 
|  `OTA_Err_t prvPAL_CloseFile( OTA_FileContext_t * const *C* );`  |  `OtaPalStatus_t otaPal_CloseFile( OtaFileContext_t * const *pFileContext* );`  |  지정된 OTA 컨텍스트에서 기본 수신 파일을 인증하고 닫습니다.  | 
|  `OTA_Err_t prvPAL_Abort( OTA_FileContext_t * const *C* );`  |  `OtaPalStatus_t otaPal_Abort( OtaFileContext_t * const *pFileContext* );`  |  OTA 전송을 중지합니다.  | 
|  `OTA_Err_t prvPAL_SetPlatformImageState( OTA_ImageState_t *eState* );`  |  `OtaPalStatus_t otaPal_SetPlatformImageState( OtaFileContext_t * const pFileContext, OtaImageState_t eState );`  |  OTA 업데이트 이미지의 상태를 설정하려고 시도합니다.  | 
|  `OTA_PAL_ImageState_t prvPAL_GetPlatformImageState( void );`  |  `OtaPalImageState_t otaPal_GetPlatformImageState( OtaFileContext_t * const *pFileContext* );`  |  OTA 업데이트 이미지의 상태를 가져옵니다.  | 
+ 버전 1: `OTA_Err_t prvPAL_CreateFileForRx( OTA_FileContext_t * const *C* );`

  버전 3: `OtaPalStatus_t otaPal_CreateFileForRx( OtaFileContext_t * const *pFileContext* );`

  참고: 데이터 청크가 들어오는 대로 새 수신 파일을 생성합니다.
+ 버전 1: `int16_t prvPAL_WriteBlock( OTA_FileContext_t * const C, uint32_t ulOffset, uint8_t * const pcData, uint32_t ulBlockSize );`

  버전 3: `int16_t otaPal_WriteBlock( OtaFileContext_t * const pFileContext, uint32_t ulOffset, uint8_t * const pData, uint32_t ulBlockSize );`

  참고: 지정된 파일의 지정된 오프셋에 데이터 블록을 씁니다.
+ 버전 1: `OTA_Err_t prvPAL_ActivateNewImage( void );`

  버전 3: `OtaPalStatus_t otaPal_ActivateNewImage( OtaFileContext_t * const *pFileContext* );`

  참고: OTA를 통해 수신한 최신 MCU 이미지를 활성화합니다.
+ 버전 1: `OTA_Err_t prvPAL_ResetDevice( void );`

  버전 3: `OtaPalStatus_t otaPal_ResetDevice( OtaFileContext_t * const *pFileContext* );`

  참고: 디바이스를 재설정합니다.
+ 버전 1: `OTA_Err_t prvPAL_CloseFile( OTA_FileContext_t * const *C* );`

  버전 3: `OtaPalStatus_t otaPal_CloseFile( OtaFileContext_t * const *pFileContext* );`

  참고: 지정된 OTA 컨텍스트에서 기본 수신 파일을 인증하고 닫습니다.
+ 버전 1: `OTA_Err_t prvPAL_Abort( OTA_FileContext_t * const *C* );`

  버전 3: `OtaPalStatus_t otaPal_Abort( OtaFileContext_t * const *pFileContext* );`

  참고: OTA 전송을 중지합니다.
+ 버전 1: `OTA_Err_t prvPAL_SetPlatformImageState( OTA_ImageState_t *eState* );`

  버전 3: `OtaPalStatus_t otaPal_SetPlatformImageState( OtaFileContext_t * const pFileContext, OtaImageState_t eState );`

  참고: OTA 업데이트 이미지의 상태를 설정하려고 시도합니다.
+ 버전 1: `OTA_PAL_ImageState_t prvPAL_GetPlatformImageState( void );`

  버전 3: `OtaPalImageState_t otaPal_GetPlatformImageState( OtaFileContext_t * const *pFileContext* );`

  참고: OTA 업데이트 이미지의 상태를 가져옵니다.

### 데이터 타입
<a name="porting-migration-ota-pal-data-types"></a>


****  

|  버전 1   |  파일  |  버전 3   |  파일  |  노트   | 
| --- | --- | --- | --- | --- | 
|  `OTA_PAL_ImageState_t`  |  `aws_iot_ota_agent.h`  |  `OtaPalImageState_t`  |  `ota_private.h`  |  *플랫폼 구현이 설정한 이미지 상태입니다.*  | 
|  `OTA_Err_t`  |  `aws_iot_ota_agent.h`  |  `OtaErr_t OtaPalStatus_t (combination of OtaPalMainStatus_t and OtaPalSubStatus_t)`  |  `ota.h`, `ota_platform_interface.h`  |  v1: 32개의 부호 없는 정수를 정의하는 매크로였습니다. v3: 오류 유형을 나타내고 오류 코드와 연결된 특수 열거형입니다.  | 
|  `OTA_FileContext_t`  |  `aws_iot_ota_agent.h`  |  `OtaFileContext_t`  |  `ota_private.h`  |  v1: 데이터에 대한 열거형 및 버퍼를 포함합니다. v3: 추가 데이터 길이 변수를 포함합니다.  | 
|  `OTA_ImageState_t`  |  `aws_iot_ota_agent.h`  |  `OtaImageState_t`  |  `ota_private.h`  |  *OTA 이미지 상태*  | 
+ 버전 1: `OTA_PAL_ImageState_t`

  파일: `aws_iot_ota_agent.h`

  버전 3: `OtaPalImageState_t`

  파일: `ota_private.h`

  참고: *플랫폼 구현이 설정한 이미지 상태입니다.*
+ 버전 1: `OTA_Err_t`

  파일: `aws_iot_ota_agent.h`

  버전 3: `OtaErr_t OtaPalStatus_t (combination of OtaPalMainStatus_t and OtaPalSubStatus_t)`

  파일: `ota.h`, `ota_platform_interface.h` 

  참고: v1: 32개의 부호 없는 정수를 정의하는 매크로였습니다. v3: 오류 유형을 나타내고 오류 코드와 연결된 특수 열거형입니다.
+ 버전 1: `OTA_FileContext_t`

  파일: `aws_iot_ota_agent.h`

  버전 3: `OtaFileContext_t`

  파일: `ota_private.h`

  참고: v1: 데이터에 대한 열거형 및 버퍼를 포함합니다. v3: 추가 데이터 길이 변수를 포함합니다.
+ 버전 1: `OTA_ImageState_t`

  파일: `aws_iot_ota_agent.h`

  버전 3: `OtaImageState_t`

  파일: `ota_private.h`

  참고: *OTA 이미지 상태*

### 구성 변경
<a name="porting-migration-ota-pal-config-changes"></a>

파일 이름 `aws_ota_agent_config.h`가 [https://github.com/aws/amazon-freertos/blob/main/vendors/pc/boards/windows/aws_demos/config_files/ota_config.h](https://github.com/aws/amazon-freertos/blob/main/vendors/pc/boards/windows/aws_demos/config_files/ota_config.h)로 변경되어 포함 가드가 `_AWS_OTA_AGENT_CONFIG_H_`에서 `OTA_CONFIG_H_`로 변경되었습니다.
+ 파일 `aws_ota_codesigner_certificate.h`가 삭제되었습니다.
+ 디버그 메시지를 인쇄하기 위한 새 로깅 스택이 포함되었습니다.

  ```
  /**************************************************/
  /******* DO NOT CHANGE the following order ********/
  /**************************************************/
  
  /* Logging related header files are required to be included in the following order:
   * 1. Include the header file "logging_levels.h".
   * 2. Define LIBRARY_LOG_NAME and  LIBRARY_LOG_LEVEL.
   * 3. Include the header file "logging_stack.h".
   */
  
  /* Include header that defines log levels. */
  #include "logging_levels.h"
  
  /* Configure name and log level for the OTA library. */
  #ifndef LIBRARY_LOG_NAME
      #define LIBRARY_LOG_NAME     "OTA"
  #endif
  #ifndef LIBRARY_LOG_LEVEL
      #define LIBRARY_LOG_LEVEL    LOG_INFO
  #endif
  
  #include "logging_stack.h"
  
  /************ End of logging configuration ****************/
  ```
+ 상수 구성 추가:

  ```
  /** * @brief Size of the file data block message (excluding the header). */   
  #define otaconfigFILE_BLOCK_SIZE ( 1UL << otaconfigLOG2_FILE_BLOCK_SIZE )
  ```

**새 파일:** [https://github.com/aws/amazon-freertos/blob/main/vendors/pc/boards/windows/aws_demos/config_files/ota_demo_config.h](https://github.com/aws/amazon-freertos/blob/main/vendors/pc/boards/windows/aws_demos/config_files/ota_demo_config.h)가 코드 서명 인증서 및 애플리케이션 버전과 같이 OTA 데모에 필요한 구성을 포함합니다.
+ `demos/include/aws_ota_codesigner_certificate.h`에서 정의된 `ota_demo_config.h`가 `signingcredentialSIGNING_CERTIFICATE_PEM`의 `otapalconfigCODE_SIGNING_CERTIFICATE`로 이동되었으며 PAL 파일에서 다음과 같이 액세스할 수 있습니다.

  ```
  static const char codeSigningCertificatePEM[] = otapalconfigCODE_SIGNING_CERTIFICATE;
  ```

  파일 `aws_ota_codesigner_certificate.h`가 삭제되었습니다.
+ 매크로 `APP_VERSION_BUILD`, `APP_VERSION_MINOR`, `APP_VERSION_MAJOR`이 `ota_demo_config.h`에 추가되었습니다. 버전 정보가 들어 있는 이전 파일이 제거되었습니다(예: `tests/include/aws_application_version.h`, `libraries/c_sdk/standard/common/include/iot_appversion32.h`, `demos/demo_runner/aws_demo_version.c`).

## OTA PAL 테스트 변경 사항
<a name="porting-migration-ota-pal-test-changes"></a>
+ 'Full\$1OTA\$1Agent' 테스트 그룹 및 모든 관련 파일을 제거했습니다. 이전에는 검증에 이 테스트 그룹이 필요했습니다. 이들 테스트는 OTA 라이브러리를 대상으로 했으며 OTA PAL 포트에만 국한되지 않았습니다. 이제 OTA 라이브러리에는 OTA 리포지토리에서 호스팅되는 전체 테스트 범위가 제공되므로 이 테스트 그룹은 더 이상 필요하지 않습니다.
+ 'Full\$1OTA\$1CBOR' 및 'Quarantine\$1OTA\$1CBOR" 테스트 그룹 및 모든 관련 파일을 제거했습니다. 이러한 테스트는 검증 테스트의 일부가 아닙니다. 이 테스트에서 다룬 기능은 현재 OTA 리포지토리에서 테스트되고 있습니다.
+ 테스트 파일을 라이브러리 디렉터리에서 `tests/integration_tests/ota_pal` 디렉터리로 이동했습니다.
+ OTA PAL 검증 테스트가 OTA 라이브러리 API v3.0.0을 사용하도록 업데이트되었습니다.
+ OTA PAL 테스트가 테스트용 코드 서명 인증서에 액세스하는 방법을 업데이트했습니다. 이전에는 코드 서명 보안 인증을 위한 전용 헤더 파일이 있었습니다. 새 버전의 라이브러리에서는 더 이상 그렇지 않습니다. 테스트 코드에서는 이 변수가 `ota_pal.c`에 정의되어야 합니다. 값은 플랫폼별 OTA 구성 파일에 정의된 매크로에 할당됩니다.

## 체크리스트
<a name="porting-migration-ota-pal-test-checklist"></a>

이 체크리스트를 사용하여 마이그레이션에 필요한 단계를 따르고 있는지 확인합니다.
+ ota pal port 폴더의 이름을 `ota`에서 `ota_pal_for_aws`로 업데이트합니다.
+ 위에서 언급한 기능이 포함된 `ota_pal.h` 파일을 추가합니다. 예제 `ota_pal.h` 파일은 [GitHub](https://github.com/aws/amazon-freertos/blob/main/vendors/pc/boards/windows/ports/ota_pal_for_aws/ota_pal.h)를 참조하세요.
+ 구성 파일 추가:
  + 파일 이름을 `aws_ota_agent_config.h`에서 `ota_config.h`로 변경(또는 생성)합니다.
    + 추가:

      ```
      otaconfigFILE_BLOCK_SIZE ( 1UL << otaconfigLOG2_FILE_BLOCK_SIZE )
      ```
    + 포함:

      ```
      #include "ota_demo_config.h"
      ```
  + 위 파일을 `aws_test config` 폴더에 복사하고 `ota_demo_config.h`의 포함 항목을 `aws_test_ota_config.h`로 바꿉니다.
  + `ota_demo_config.h` 파일을 추가합니다.
  + `aws_test_ota_config.h` 파일을 추가합니다.
+ `ota_pal.c`을 다음과 같이 변경합니다.
  + 포함 항목을 최신 OTA 라이브러리 파일 이름으로 업데이트합니다.
  + `DEFINE_OTA_METHOD_NAME` 매크로를 제거합니다.
  + OTA PAL 함수의 서명을 업데이트합니다.
  + 파일 컨텍스트 변수의 이름을 `C`에서 `pFileContext`로 업데이트합니다.
  + `OTA_FileContext_t` 구조체 및 모든 관련 변수를 업데이트합니다.
  + `cOTA_JSON_FileSignatureKey`를 `OTA_JsonFileSignatureKey`로 업데이트합니다.
  + `OTA_PAL_ImageState_t` 및 `Ota_ImageState_t` 유형을 업데이트합니다.
  + 오류 유형 및 값을 업데이트합니다.
  + 로깅 스택을 사용하도록 인쇄 매크로를 업데이트합니다.
  + `signingcredentialSIGNING_CERTIFICATE_PEM`를 `otapalconfigCODE_SIGNING_CERTIFICATE`로 업데이트합니다.
  + `otaPal_CheckFileSignature` 및 `otaPal_ReadAndAssumeCertificate` 함수 주석을 업데이트합니다.
+ [https://github.com/aws/amazon-freertos/pull/3208/commits/432e13fcb8dfbfeb6de25110a3d2ea14ccaf1b9a](https://github.com/aws/amazon-freertos/pull/3208/commits/432e13fcb8dfbfeb6de25110a3d2ea14ccaf1b9a) 파일을 업데이트합니다.
+ IDE 프로젝트를 업데이트합니다.