Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restyle ESP32: Add support for flashing using .flash.py #7998

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions examples/all-clusters-app/esp32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,38 @@ endif()
project(chip-all-clusters-app)
idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++14;-Os;-DLWIP_IPV6_SCOPES=0;-DCHIP_HAVE_CONFIG_H" APPEND)
idf_build_set_property(C_COMPILE_OPTIONS "-Os;-DLWIP_IPV6_SCOPES=0" APPEND)

idf_build_get_property(build_dir BUILD_DIR)
idf_build_get_property(project_path PROJECT_DIR)
idf_build_get_property(sdkconfig SDKCONFIG)
idf_build_get_property(idf_path IDF_PATH)

add_custom_command(OUTPUT "${build_dir}/firmware_utils.py"
COMMAND ${CMAKE_COMMAND} ARGS -E copy "${project_path}/third_party/connectedhomeip/scripts/flashing/firmware_utils.py" "${build_dir}/"
WORKING_DIRECTORY ${build_dir}
VERBATIM)

add_custom_command(OUTPUT "${build_dir}/esp32_firmware_utils.py"
COMMAND ${CMAKE_COMMAND} ARGS -E copy "${project_path}/third_party/connectedhomeip/scripts/flashing/esp32_firmware_utils.py" "${build_dir}/"
WORKING_DIRECTORY ${build_dir}
VERBATIM)

add_custom_command(OUTPUT "${build_dir}/${CMAKE_PROJECT_NAME}.flash.py"
COMMAND ${python}
"${project_path}/../../../scripts/flashing/gen_flashing_script.py" esp32
--output "${build_dir}/${CMAKE_PROJECT_NAME}.flash.py"
--port "$ENV{ESPPORT}"
--baud "$ENV{ESPBAUD}"
--before ${CONFIG_ESPTOOLPY_BEFORE}
--after ${CONFIG_ESPTOOLPY_AFTER}
--application "${CMAKE_PROJECT_NAME}.bin"
--bootloader "bootloader/bootloader.bin"
--partition "partition_table/partition-table.bin"
--use-partition-file "${build_dir}/partition_table/partition-table.bin"
--use-parttool ${idf_path}/components/partition_table/parttool.py
--use-sdkconfig ${project_path}/sdkconfig
WORKING_DIRECTORY ${build_dir}
COMMENT "To flash ${build_dir}/${CMAKE_PROJECT_NAME}.bin run ./build/${CMAKE_PROJECT_NAME}.flash.py"
VERBATIM)

add_custom_target(flashing_script DEPENDS "${build_dir}/${CMAKE_PROJECT_NAME}.bin" "${build_dir}/${CMAKE_PROJECT_NAME}.flash.py" "${build_dir}/esp32_firmware_utils.py" "${build_dir}/firmware_utils.py")
13 changes: 13 additions & 0 deletions examples/all-clusters-app/esp32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ control.
- [Setting up Python Controller](#setting-up-python-controller)
- [Commissioning over BLE](#commissioning-over-ble)
- [Cluster control](#cluster-control)
- [Flashing app using script](#flashing-app-using-script)
- [Note](#note)

---
Expand Down Expand Up @@ -214,6 +215,18 @@ commissioning and cluster control.

`chip-device-ctrl > zcl OnOff Off 135246 1 0`

### Flashing app using script

- Follow these steps to use `${app_name}.flash.py`.

```
$ export ESPPORT=/dev/tty.SLAB_USBtoUART
$ export ESPBAUD=${baud_value}
$ idf.py build
$ idf.py flashing_script
$ python ${app_name}.flash.py
```

### Note

This demo app illustrates controlling OnOff cluster (Server) attributes of an
Expand Down
35 changes: 35 additions & 0 deletions examples/persistent-storage/esp32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,38 @@ set(EXTRA_COMPONENT_DIRS
project(persistent-storage)
idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++14;-Os;-DLWIP_IPV6_SCOPES=0;-DCHIP_HAVE_CONFIG_H" APPEND)
idf_build_set_property(C_COMPILE_OPTIONS "-Os;-DLWIP_IPV6_SCOPES=0" APPEND)

idf_build_get_property(build_dir BUILD_DIR)
idf_build_get_property(project_path PROJECT_DIR)
idf_build_get_property(sdkconfig SDKCONFIG)
idf_build_get_property(idf_path IDF_PATH)

add_custom_command(OUTPUT "${build_dir}/firmware_utils.py"
COMMAND ${CMAKE_COMMAND} ARGS -E copy "${project_path}/third_party/connectedhomeip/scripts/flashing/firmware_utils.py" "${build_dir}/"
WORKING_DIRECTORY ${build_dir}
VERBATIM)

add_custom_command(OUTPUT "${build_dir}/esp32_firmware_utils.py"
COMMAND ${CMAKE_COMMAND} ARGS -E copy "${project_path}/third_party/connectedhomeip/scripts/flashing/esp32_firmware_utils.py" "${build_dir}/"
WORKING_DIRECTORY ${build_dir}
VERBATIM)

add_custom_command(OUTPUT "${build_dir}/${CMAKE_PROJECT_NAME}.flash.py"
COMMAND ${python}
"${project_path}/../../../scripts/flashing/gen_flashing_script.py" esp32
--output "${build_dir}/${CMAKE_PROJECT_NAME}.flash.py"
--port "$ENV{ESPPORT}"
--baud "$ENV{ESPBAUD}"
--before ${CONFIG_ESPTOOLPY_BEFORE}
--after ${CONFIG_ESPTOOLPY_AFTER}
--application "${CMAKE_PROJECT_NAME}.bin"
--bootloader "bootloader/bootloader.bin"
--partition "partition_table/partition-table.bin"
--use-partition-file "${build_dir}/partition_table/partition-table.bin"
--use-parttool ${idf_path}/components/partition_table/parttool.py
--use-sdkconfig ${project_path}/sdkconfig
WORKING_DIRECTORY ${build_dir}
COMMENT "To flash ${build_dir}/${CMAKE_PROJECT_NAME}.bin run ./build/${CMAKE_PROJECT_NAME}.flash.py"
VERBATIM)

add_custom_target(flashing_script DEPENDS "${build_dir}/${CMAKE_PROJECT_NAME}.bin" "${build_dir}/${CMAKE_PROJECT_NAME}.flash.py" "${build_dir}/esp32_firmware_utils.py" "${build_dir}/firmware_utils.py")
45 changes: 45 additions & 0 deletions examples/pigweed-app/esp32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,48 @@ set(EXTRA_COMPONENT_DIRS
project(chip-pigweed-app)
idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++17;-Os;-DLWIP_IPV6_SCOPES=0;-DCHIP_HAVE_CONFIG_H" APPEND)
idf_build_set_property(C_COMPILE_OPTIONS "-Os;-DLWIP_IPV6_SCOPES=0" APPEND)

idf_build_get_property(build_dir BUILD_DIR)
idf_build_get_property(project_path PROJECT_DIR)
idf_build_get_property(sdkconfig SDKCONFIG)
idf_build_get_property(idf_path IDF_PATH)

add_custom_command(OUTPUT "${build_dir}/firmware_utils.py"
COMMAND ${CMAKE_COMMAND} ARGS -E copy "${project_path}/third_party/connectedhomeip/scripts/flashing/firmware_utils.py" "${build_dir}/"
WORKING_DIRECTORY ${build_dir}
VERBATIM)

add_custom_command(OUTPUT "${build_dir}/esp32_firmware_utils.py"
COMMAND ${CMAKE_COMMAND} ARGS -E copy "${project_path}/third_party/connectedhomeip/scripts/flashing/esp32_firmware_utils.py" "${build_dir}/"
WORKING_DIRECTORY ${build_dir}
VERBATIM)

add_custom_command(OUTPUT "${build_dir}/echo_test.py"
COMMAND ${CMAKE_COMMAND} ARGS -E copy "${project_path}/../mobly_tests/echo_test.py" "${build_dir}/"
WORKING_DIRECTORY ${build_dir}
VERBATIM)

add_custom_command(OUTPUT "${build_dir}/echo_test_config.yml"
COMMAND ${CMAKE_COMMAND} ARGS -E copy "${project_path}/echo_test_config.yml" "${build_dir}/"
WORKING_DIRECTORY ${build_dir}
VERBATIM)

add_custom_command(OUTPUT "${build_dir}/${CMAKE_PROJECT_NAME}.flash.py"
COMMAND ${python}
"${project_path}/../../../scripts/flashing/gen_flashing_script.py" esp32
--output "${build_dir}/${CMAKE_PROJECT_NAME}.flash.py"
--port "$ENV{ESPPORT}"
--baud "$ENV{ESPBAUD}"
--before ${CONFIG_ESPTOOLPY_BEFORE}
--after ${CONFIG_ESPTOOLPY_AFTER}
--application "${CMAKE_PROJECT_NAME}.bin"
--bootloader "bootloader/bootloader.bin"
--partition "partition_table/partition-table.bin"
--use-partition-file "${build_dir}/partition_table/partition-table.bin"
--use-parttool ${idf_path}/components/partition_table/parttool.py
--use-sdkconfig ${project_path}/sdkconfig
WORKING_DIRECTORY ${build_dir}
COMMENT "To flash ${build_dir}/${CMAKE_PROJECT_NAME}.bin run ./build/${CMAKE_PROJECT_NAME}.flash.py"
VERBATIM)

add_custom_target(flashing_script DEPENDS "${build_dir}/${CMAKE_PROJECT_NAME}.bin" "${build_dir}/${CMAKE_PROJECT_NAME}.flash.py" "${build_dir}/esp32_firmware_utils.py" "${build_dir}/firmware_utils.py" "${build_dir}/echo_test.py" "${build_dir}/echo_test_config.yml")
35 changes: 35 additions & 0 deletions examples/temperature-measurement-app/esp32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,38 @@ set(EXTRA_COMPONENT_DIRS
project(chip-temperature-measurement-app)
idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++14;-Os;-DLWIP_IPV6_SCOPES=0;-DCHIP_HAVE_CONFIG_H" APPEND)
idf_build_set_property(C_COMPILE_OPTIONS "-Os;-DLWIP_IPV6_SCOPES=0" APPEND)

idf_build_get_property(build_dir BUILD_DIR)
idf_build_get_property(project_path PROJECT_DIR)
idf_build_get_property(sdkconfig SDKCONFIG)
idf_build_get_property(idf_path IDF_PATH)

add_custom_command(OUTPUT "${build_dir}/firmware_utils.py"
COMMAND ${CMAKE_COMMAND} ARGS -E copy "${project_path}/third_party/connectedhomeip/scripts/flashing/firmware_utils.py" "${build_dir}/"
WORKING_DIRECTORY ${build_dir}
VERBATIM)

add_custom_command(OUTPUT "${build_dir}/esp32_firmware_utils.py"
COMMAND ${CMAKE_COMMAND} ARGS -E copy "${project_path}/third_party/connectedhomeip/scripts/flashing/esp32_firmware_utils.py" "${build_dir}/"
WORKING_DIRECTORY ${build_dir}
VERBATIM)

add_custom_command(OUTPUT "${build_dir}/${CMAKE_PROJECT_NAME}.flash.py"
COMMAND ${python}
"${project_path}/../../../scripts/flashing/gen_flashing_script.py" esp32
--output "${build_dir}/${CMAKE_PROJECT_NAME}.flash.py"
--port "$ENV{ESPPORT}"
--baud "$ENV{ESPBAUD}"
--before ${CONFIG_ESPTOOLPY_BEFORE}
--after ${CONFIG_ESPTOOLPY_AFTER}
--application "${CMAKE_PROJECT_NAME}.bin"
--bootloader "bootloader/bootloader.bin"
--partition "partition_table/partition-table.bin"
--use-partition-file "${build_dir}/partition_table/partition-table.bin"
--use-parttool ${idf_path}/components/partition_table/parttool.py
--use-sdkconfig ${project_path}/sdkconfig
WORKING_DIRECTORY ${build_dir}
COMMENT "To flash ${build_dir}/${CMAKE_PROJECT_NAME}.bin run ./build/${CMAKE_PROJECT_NAME}.flash.py"
VERBATIM)

add_custom_target(flashing_script DEPENDS "${build_dir}/${CMAKE_PROJECT_NAME}.bin" "${build_dir}/${CMAKE_PROJECT_NAME}.flash.py" "${build_dir}/esp32_firmware_utils.py" "${build_dir}/firmware_utils.py")
3 changes: 2 additions & 1 deletion scripts/flashing/esp32_firmware_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,11 @@
},
'bootloader_offset': {
'help': 'Bootloader offset',
'default': '0x1000',
'default': None,
'argparse': {
'metavar': 'OFFSET'
},
'sdkconfig': 'CONFIG_BOOTLOADER_OFFSET_IN_FLASH',
},
'partition': {
'help': 'Partition table image',
Expand Down