Skip to content

Commit fd3696a

Browse files
sylvioalvescfriedt
authored andcommitted
cmake: esp32: use zephyr defined python tool
This configures esptool, partition generator and external bootloader build to use python tool defined in Zephyr's context environment. This fixes error regarding missing /usr/bin/python when python2.7 is not installed in users's machine. Partition table offset is also updated as part of this change. Signed-off-by: Sylvio Alves <[email protected]>
1 parent 0794bdd commit fd3696a

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

boards/riscv/esp32c3_devkitm/CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ if(CONFIG_BOOTLOADER_ESP_IDF)
2424
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
2525
-DCMAKE_ASM_COMPILER=${CMAKE_ASM_COMPILER}
2626
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
27+
-DPYTHON=${PYTHON_EXECUTABLE}
2728
BUILD_COMMAND
2829
${CMAKE_COMMAND} --build .
2930
INSTALL_COMMAND "" # This particular build system has no install command
@@ -35,20 +36,20 @@ if(CONFIG_BOOTLOADER_ESP_IDF)
3536
BINARY_DIR ${espidf_build_dir}
3637
CONFIGURE_COMMAND ""
3738
BUILD_COMMAND
38-
python ${ESP_IDF_PATH}/components/partition_table/gen_esp32part.py -q
39-
--offset 0x1000 --flash-size 4MB ${ESP_IDF_PATH}/components/partition_table/partitions_singleapp.csv ${espidf_build_dir}/partitions_singleapp.bin
39+
${PYTHON_EXECUTABLE} ${ESP_IDF_PATH}/components/partition_table/gen_esp32part.py -q
40+
--offset 0x8000 --flash-size 4MB ${ESP_IDF_PATH}/components/partition_table/partitions_singleapp.csv ${espidf_build_dir}/partitions_singleapp.bin
4041
INSTALL_COMMAND ""
4142
)
4243

4344
if(CONFIG_BUILD_OUTPUT_BIN)
4445
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
45-
COMMAND python ${ESP_IDF_PATH}/components/esptool_py/esptool/esptool.py
46+
COMMAND ${PYTHON_EXECUTABLE} ${ESP_IDF_PATH}/components/esptool_py/esptool/esptool.py
4647
ARGS --chip esp32c3 elf2image --flash_mode dio --flash_freq 40m
4748
-o ${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.bin
4849
${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.elf)
4950
endif()
5051

51-
set_property(TARGET bintools PROPERTY disassembly_flag_inline_source)
52+
set_property(TARGET bintools PROPERTY disassembly_flag_inline_source)
5253

5354
add_dependencies(app EspIdfBootloader EspPartitionTable)
5455

boards/xtensa/esp32/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ if(CONFIG_BOOTLOADER_ESP_IDF)
2323
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
2424
-DCMAKE_ASM_COMPILER=${CMAKE_ASM_COMPILER}
2525
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
26+
-DPYTHON=${PYTHON_EXECUTABLE}
2627
BUILD_COMMAND
2728
${CMAKE_COMMAND} --build .
2829
INSTALL_COMMAND "" # This particular build system has no install command
@@ -34,14 +35,14 @@ if(CONFIG_BOOTLOADER_ESP_IDF)
3435
BINARY_DIR ${espidf_build_dir}
3536
CONFIGURE_COMMAND ""
3637
BUILD_COMMAND
37-
python ${ESP_IDF_PATH}/components/partition_table/gen_esp32part.py -q
38-
--offset 0x1000 --flash-size 4MB ${ESP_IDF_PATH}/components/partition_table/partitions_singleapp.csv ${espidf_build_dir}/partitions_singleapp.bin
38+
${PYTHON_EXECUTABLE} ${ESP_IDF_PATH}/components/partition_table/gen_esp32part.py -q
39+
--offset 0x8000 --flash-size 4MB ${ESP_IDF_PATH}/components/partition_table/partitions_singleapp.csv ${espidf_build_dir}/partitions_singleapp.bin
3940
INSTALL_COMMAND ""
4041
)
4142

4243
if(CONFIG_BUILD_OUTPUT_BIN)
4344
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
44-
COMMAND python ${ESP_IDF_PATH}/components/esptool_py/esptool/esptool.py
45+
COMMAND ${PYTHON_EXECUTABLE} ${ESP_IDF_PATH}/components/esptool_py/esptool/esptool.py
4546
ARGS --chip esp32 elf2image --flash_mode dio --flash_freq 40m
4647
-o ${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.bin
4748
${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.elf)

boards/xtensa/esp32s2_saola/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ if(CONFIG_BOOTLOADER_ESP_IDF)
2323
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
2424
-DCMAKE_ASM_COMPILER=${CMAKE_ASM_COMPILER}
2525
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
26+
-DPYTHON=${PYTHON_EXECUTABLE}
2627
BUILD_COMMAND
2728
${CMAKE_COMMAND} --build .
2829
INSTALL_COMMAND "" # This particular build system has no install command
@@ -34,14 +35,14 @@ if(CONFIG_BOOTLOADER_ESP_IDF)
3435
BINARY_DIR ${espidf_build_dir}
3536
CONFIGURE_COMMAND ""
3637
BUILD_COMMAND
37-
python ${ESP_IDF_PATH}/components/partition_table/gen_esp32part.py -q
38-
--offset 0x1000 --flash-size 4MB ${ESP_IDF_PATH}/components/partition_table/partitions_singleapp.csv ${espidf_build_dir}/partitions_singleapp.bin
38+
${PYTHON_EXECUTABLE} ${ESP_IDF_PATH}/components/partition_table/gen_esp32part.py -q
39+
--offset 0x8000 --flash-size 4MB ${ESP_IDF_PATH}/components/partition_table/partitions_singleapp.csv ${espidf_build_dir}/partitions_singleapp.bin
3940
INSTALL_COMMAND ""
4041
)
4142

4243
if(CONFIG_BUILD_OUTPUT_BIN)
4344
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
44-
COMMAND python ${ESP_IDF_PATH}/components/esptool_py/esptool/esptool.py
45+
COMMAND ${PYTHON_EXECUTABLE} ${ESP_IDF_PATH}/components/esptool_py/esptool/esptool.py
4546
ARGS --chip esp32s2 elf2image --flash_mode dio --flash_freq 40m
4647
-o ${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.bin
4748
${CMAKE_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.elf)

0 commit comments

Comments
 (0)