Skip to content

Commit 5bd87dc

Browse files
author
Marek Matej
committed
scripts: update the CI requirements for Espressif port
Updated twister.yaml workflow to fetch esptool for the CI. Fix format of the arguments used in the esptool-5.0.2. Check that esptool is available on build time. Update runners for esp32. Signed-off-by: Marek Matej <marek.matej@espressif.com>
1 parent 650286a commit 5bd87dc

File tree

3 files changed

+27
-30
lines changed

3 files changed

+27
-30
lines changed

.github/workflows/twister.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ jobs:
6262
if: github.event_name == 'pull_request'
6363
run: |
6464
pip install -r scripts/requirements-actions.txt --require-hashes
65+
west packages pip --install
6566
6667
- name: Setup Zephyr project
6768
if: github.event_name == 'pull_request'

scripts/west_commands/runners/esp32.py

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
#
44
# SPDX-License-Identifier: Apache-2.0
55

6-
'''Runner for flashing ESP32 devices with esptool/espidf.'''
6+
'''Runner for flashing ESP32 devices with esptool.'''
77

88
import os
9-
import sys
10-
from os import path
119

1210
from runners.core import RunnerCaps, ZephyrBinaryRunner
1311

@@ -18,7 +16,7 @@ class Esp32BinaryRunner(ZephyrBinaryRunner):
1816
def __init__(self, cfg, device, boot_address, part_table_address,
1917
app_address, erase=False, reset=False, baud=921600,
2018
flash_size='detect', flash_freq='40m', flash_mode='dio',
21-
espidf='espidf', bootloader_bin=None, partition_table_bin=None,
19+
espidf=None, bootloader_bin=None, partition_table_bin=None,
2220
encrypt=False, no_stub=False):
2321
super().__init__(cfg)
2422
self.elf = cfg.elf_file
@@ -71,10 +69,6 @@ def do_add_parser(cls, parser):
7169
help='flash frequency, default "40m"')
7270
parser.add_argument('--esp-flash-mode', default='dio',
7371
help='flash mode, default "dio"')
74-
parser.add_argument(
75-
'--esp-tool',
76-
help='''if given, complete path to espidf. default is to search for
77-
it in [ESP_IDF_PATH]/tools/esptool_py/esptool.py''')
7872
parser.add_argument('--esp-flash-bootloader',
7973
help='Bootloader image to flash')
8074
parser.add_argument('--esp-flash-partition_table',
@@ -88,44 +82,37 @@ def do_add_parser(cls, parser):
8882

8983
@classmethod
9084
def do_create(cls, cfg, args):
91-
if args.esp_tool:
92-
espidf = args.esp_tool
93-
else:
94-
espidf = path.join(args.esp_idf_path, 'tools', 'esptool_py',
95-
'esptool.py')
9685

9786
return Esp32BinaryRunner(
9887
cfg, args.esp_device, boot_address=args.esp_boot_address,
9988
part_table_address=args.esp_partition_table_address,
10089
app_address=args.esp_app_address, erase=args.erase, reset=args.reset,
10190
baud=args.esp_baud_rate, flash_size=args.esp_flash_size,
10291
flash_freq=args.esp_flash_freq, flash_mode=args.esp_flash_mode,
103-
espidf=espidf, bootloader_bin=args.esp_flash_bootloader,
92+
espidf=args.esp_idf_path, bootloader_bin=args.esp_flash_bootloader,
10493
partition_table_bin=args.esp_flash_partition_table,
10594
encrypt=args.esp_encrypt, no_stub=args.esp_no_stub)
10695

10796
def do_run(self, command, **kwargs):
108-
self.require(self.espidf)
10997

110-
# Add Python interpreter
111-
cmd_flash = [sys.executable, self.espidf, '--chip', 'auto']
98+
cmd_flash = ['esptool']
11299

113100
if self.device is not None:
114101
cmd_flash.extend(['--port', self.device])
115102

116103
if self.erase is True:
117-
cmd_erase = cmd_flash + ['erase_flash']
104+
cmd_erase = cmd_flash + ['erase-flash']
118105
self.check_call(cmd_erase)
119106

120107
if self.no_stub is True:
121108
cmd_flash.extend(['--no-stub'])
122109
cmd_flash.extend(['--baud', self.baud])
123-
cmd_flash.extend(['--before', 'default_reset'])
110+
cmd_flash.extend(['--before', 'default-reset'])
124111
if self.reset:
125-
cmd_flash.extend(['--after', 'hard_reset', 'write_flash', '-u'])
126-
cmd_flash.extend(['--flash_mode', self.flash_mode])
127-
cmd_flash.extend(['--flash_freq', self.flash_freq])
128-
cmd_flash.extend(['--flash_size', self.flash_size])
112+
cmd_flash.extend(['--after', 'hard-reset', 'write-flash', '-u'])
113+
cmd_flash.extend(['--flash-mode', self.flash_mode])
114+
cmd_flash.extend(['--flash-freq', self.flash_freq])
115+
cmd_flash.extend(['--flash-size', self.flash_size])
129116

130117
if self.encrypt:
131118
cmd_flash.extend(['--encrypt'])

soc/espressif/common/CMakeLists.txt

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
# Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
22
# SPDX-License-Identifier: Apache-2.0
33

4+
# Make sure the esptool package is available
5+
find_program(ESPTOOL_EXECUTABLE esptool)
6+
7+
if(NOT ESPTOOL_EXECUTABLE)
8+
message(FATAL_ERROR
9+
"esptool>=5.0.2 not found in PATH.\n"
10+
"Please install it using:\n"
11+
" west packages pip --install")
12+
endif()
13+
14+
# Continue to prepare the build environment
415
zephyr_include_directories(include)
516

617
if(NOT CONFIG_MCUBOOT AND NOT CONFIG_SOC_ESP32_APPCPU AND NOT CONFIG_SOC_ESP32S3_APPCPU)
@@ -20,20 +31,17 @@ message("-- Espressif HAL path: ${ESP_IDF_PATH}")
2031

2132
if((CONFIG_ESP_SIMPLE_BOOT OR CONFIG_MCUBOOT) AND NOT CONFIG_SOC_ESP32C6_LPCORE)
2233
if(CONFIG_BUILD_OUTPUT_BIN)
23-
set(ESPTOOL_PY ${ESP_IDF_PATH}/tools/esptool_py/esptool.py)
24-
message("-- Use the esptool.py: ${ESPTOOL_PY}")
25-
2634
set(ELF2IMAGE_ARG "")
2735
if(NOT CONFIG_MCUBOOT)
2836
set(ELF2IMAGE_ARG "--ram-only-header")
2937
endif()
3038

3139
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
32-
COMMAND ${PYTHON_EXECUTABLE} ${ESPTOOL_PY}
40+
COMMAND esptool
3341
ARGS --chip ${CONFIG_SOC} elf2image ${ELF2IMAGE_ARG}
34-
--flash_mode dio
35-
--flash_freq ${CONFIG_ESPTOOLPY_FLASHFREQ}
36-
--flash_size ${esptoolpy_flashsize}MB
42+
--flash-mode dio
43+
--flash-freq ${CONFIG_ESPTOOLPY_FLASHFREQ}
44+
--flash-size ${esptoolpy_flashsize}MB
3745
-o ${CMAKE_BINARY_DIR}/zephyr/${KERNEL_BIN_NAME}
3846
${CMAKE_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME})
3947
endif()
@@ -55,6 +63,7 @@ board_runner_args(esp32 "--esp-app-address=${image_off}")
5563
board_runner_args(esp32 "--esp-flash-size=${esptoolpy_flashsize}MB")
5664
board_runner_args(esp32 "--esp-flash-freq=${CONFIG_ESPTOOLPY_FLASHFREQ}")
5765
board_runner_args(esp32 "--esp-flash-mode=${CONFIG_ESPTOOLPY_FLASHMODE}")
66+
board_runner_args(esp32 "--esp-idf-path=${ESP_IDF_PATH}")
5867
board_finalize_runner_args(esp32 "--esp-monitor-baud=${monitor_baud}")
5968

6069
message(STATUS "Image partition address: ${image_off}")

0 commit comments

Comments
 (0)