【求助】如何编译OTA时的加密固件

linshc
Posts: 59
Joined: Mon Feb 21, 2022 2:06 am

【求助】如何编译OTA时的加密固件

Postby linshc » Sun Jan 28, 2024 10:39 am

使用的IDF为5.1.2,在新版OTA例程中,有个pre_encrypted_ota示例,是用来加密OTA的固件的。我将他整合到了自己的工程中。
问题:
1.添加了加密组件之后,我再main->CMakeLists.txt中添加以下生成加密OTA固件的命令。第一次编译时能够生成加密固件。但第一次之后,再编译固件时,就生成不了加密固件了。请问我该怎么解决,达到每次编译都能生成最新的加密固件?

Code: Select all

create_esp_enc_img(${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.bin
    ${project_dir}/rsa_key/ota_private.pem ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}_secure.bin app)

ESP_WangYX
Posts: 97
Joined: Mon Jun 28, 2021 12:48 pm

Re: 【求助】如何编译OTA时的加密固件

Postby ESP_WangYX » Mon Jan 29, 2024 7:04 am

每次编译前都删除 build/ 目录呢?
请参考示例添加 cmake、yml 文件中的内容。 https://github.com/espressif/esp-idf/tr ... d_ota/main

linshc
Posts: 59
Joined: Mon Feb 21, 2022 2:06 am

Re: 【求助】如何编译OTA时的加密固件

Postby linshc » Mon Jan 29, 2024 7:20 am

1.每次都删除build目录,编译时间太长了。我之前尝试删除xxx_secure.bin文件,可以每次都生成最新加密固件,但现在又不行了。我看到编译时,不会每次都运行main/CMakeLists.txt这个文件
2.我是按照示例添加的cmake和yml文件,你看下是否有问题
yml

Code: Select all

## IDF Component Manager Manifest File
dependencies:
  espressif/nghttp: "^1.52.0"
  espressif/esp_encrypted_img: "^2.0.1"
  ## Required IDF version
  idf:
    version: ">=4.1.0"
  # # Put list of dependencies here
  # # For components maintained by Espressif:
  # component: "~1.0.0"
  # # For 3rd party components:
  # username/component: ">=1.0.0,<2.0.0"
  # username2/component2:
  #   version: "~1.0.0"
  #   # For transient dependencies `public` flag can be set.
  #   # `public` flag doesn't have an effect dependencies of the `main` component.
  #   # All dependencies of `main` are public by default.
  #   public: true
CMakeLists

Code: Select all

idf_build_get_property(project_dir PROJECT_DIR)
idf_component_register(SRCS "brs_main.c"
                    INCLUDE_DIRS "."
                    EMBED_FILES "favicon.ico" "upload_script.html"
                    ${project_dir}/rsa_key/ota_private.pem
                    )

file(REMOVE ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}_secure.bin)

create_esp_enc_img(${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.bin
    ${project_dir}/rsa_key/ota_private.pem ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}_secure.bin app)

icyTwist
Posts: 1
Joined: Thu Mar 21, 2024 8:25 pm

Re: 【求助】如何编译OTA时的加密固件

Postby icyTwist » Thu Mar 21, 2024 8:32 pm

您好请问这个问题有没有跟进?
我在测试这个example https://github.com/espressif/esp-iot-so ... th/ble_ota
也遇到了同样的问题:除非删除加密固件,否则在编译时加密固件不会自动更新。

ESP_MacChu
Posts: 47
Joined: Tue Nov 21, 2023 7:53 am

Re: 【求助】如何编译OTA时的加密固件

Postby ESP_MacChu » Wed Mar 27, 2024 9:52 am

linshc wrote:
Mon Jan 29, 2024 7:20 am
1.每次都删除build目录,编译时间太长了。我之前尝试删除xxx_secure.bin文件,可以每次都生成最新加密固件,但现在又不行了。我看到编译时,不会每次都运行main/CMakeLists.txt这个文件
2.我是按照示例添加的cmake和yml文件,你看下是否有问题
yml

Code: Select all

## IDF Component Manager Manifest File
dependencies:
  espressif/nghttp: "^1.52.0"
  espressif/esp_encrypted_img: "^2.0.1"
  ## Required IDF version
  idf:
    version: ">=4.1.0"
  # # Put list of dependencies here
  # # For components maintained by Espressif:
  # component: "~1.0.0"
  # # For 3rd party components:
  # username/component: ">=1.0.0,<2.0.0"
  # username2/component2:
  #   version: "~1.0.0"
  #   # For transient dependencies `public` flag can be set.
  #   # `public` flag doesn't have an effect dependencies of the `main` component.
  #   # All dependencies of `main` are public by default.
  #   public: true
CMakeLists

Code: Select all

idf_build_get_property(project_dir PROJECT_DIR)
idf_component_register(SRCS "brs_main.c"
                    INCLUDE_DIRS "."
                    EMBED_FILES "favicon.ico" "upload_script.html"
                    ${project_dir}/rsa_key/ota_private.pem
                    )

file(REMOVE ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}_secure.bin)

create_esp_enc_img(${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.bin
    ${project_dir}/rsa_key/ota_private.pem ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}_secure.bin app)
想每次都运行 CMakeList 可以把 “idf.py build” 改成 “idf.py reconfigure build”

Who is online

Users browsing this forum: Baidu [Spider] and 31 guests