Skip to content

Commit 0b801ca

Browse files
authored
Merge pull request #133 from pkendall64/esp32c3-support
ESP32C3 support for TX backpack
2 parents e870b89 + 464001b commit 0b801ca

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

python/binary_flash.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ def upload_esp32_uart(args):
9292
args.port = serials_find.get_serial_port()
9393
try:
9494
dir = os.path.dirname(args.file.name)
95-
esptool.main(['--chip', 'esp32', '--port', args.port, '--baud', str(args.baud), '--after', 'hard_reset', 'write_flash', '-z', '--flash_mode', 'dio', '--flash_freq', '40m', '--flash_size', 'detect', '0x1000', os.path.join(dir, 'bootloader.bin'), '0x8000', os.path.join(dir, 'partitions.bin'), '0xe000', os.path.join(dir, 'boot_app0.bin'), '0x10000', args.file.name])
95+
start_addr = '0x0000' if args.platform.startswith('esp32-c') else '0x1000'
96+
esptool.main(['--chip', args.platform.replace('-', ''), '--port', args.port, '--baud', str(args.baud), '--after', 'hard_reset', 'write_flash', '-z', '--flash_mode', 'dio', '--flash_freq', '40m', '--flash_size', 'detect', start_addr, os.path.join(dir, 'bootloader.bin'), '0x8000', os.path.join(dir, 'partitions.bin'), '0xe000', os.path.join(dir, 'boot_app0.bin'), '0x10000', args.file.name])
9697
except:
9798
return ElrsUploadResult.ErrorGeneral
9899
return ElrsUploadResult.Success
@@ -102,7 +103,8 @@ def upload_esp32_etx(args):
102103
args.port = serials_find.get_serial_port()
103104
try:
104105
dir = os.path.dirname(args.file.name)
105-
esptool.main(['--passthrough', '--chip', 'esp32', '--port', args.port, '--baud', '460800', '--before', 'etx', '--after', 'hard_reset', 'write_flash', '-z', '--flash_mode', 'dio', '--flash_freq', '40m', '--flash_size', 'detect', '0x1000', os.path.join(dir, 'bootloader.bin'), '0x8000', os.path.join(dir, 'partitions.bin'), '0xe000', os.path.join(dir, 'boot_app0.bin'), '0x10000', args.file.name])
106+
start_addr = '0x0000' if args.platform.startswith('esp32-c') else '0x1000'
107+
esptool.main(['--passthrough', '--chip', args.platform.replace('-', ''), '--port', args.port, '--baud', '460800', '--before', 'etx', '--after', 'hard_reset', 'write_flash', '-z', '--flash_mode', 'dio', '--flash_freq', '40m', '--flash_size', 'detect', start_addr, os.path.join(dir, 'bootloader.bin'), '0x8000', os.path.join(dir, 'partitions.bin'), '0xe000', os.path.join(dir, 'boot_app0.bin'), '0x10000', args.file.name])
106108
except:
107109
return ElrsUploadResult.ErrorGeneral
108110
return ElrsUploadResult.Success
@@ -112,7 +114,8 @@ def upload_esp32_passthru(args):
112114
args.port = serials_find.get_serial_port()
113115
try:
114116
dir = os.path.dirname(args.file.name)
115-
esptool.main(['--passthrough', '--chip', 'esp32', '--port', args.port, '--baud', '230400', '--before', 'passthru', '--after', 'hard_reset', 'write_flash', '-z', '--flash_mode', 'dio', '--flash_freq', '40m', '--flash_size', 'detect', '0x1000', os.path.join(dir, 'bootloader.bin'), '0x8000', os.path.join(dir, 'partitions.bin'), '0xe000', os.path.join(dir, 'boot_app0.bin'), '0x10000', args.file.name])
117+
start_addr = '0x0000' if args.platform.startswith('esp32-c') else '0x1000'
118+
esptool.main(['--passthrough', '--chip', args.platform.replace('-', ''), '--port', args.port, '--baud', '230400', '--before', 'passthru', '--after', 'hard_reset', 'write_flash', '-z', '--flash_mode', 'dio', '--flash_freq', '40m', '--flash_size', 'detect', start_addr, os.path.join(dir, 'bootloader.bin'), '0x8000', os.path.join(dir, 'partitions.bin'), '0xe000', os.path.join(dir, 'boot_app0.bin'), '0x10000', args.file.name])
116119
except:
117120
return ElrsUploadResult.ErrorGeneral
118121
return ElrsUploadResult.Success

targets/common.ini

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,19 @@ board_build.f_cpu = 240000000L
4747
build_flags =
4848
-D PLATFORM_ESP32=1
4949

50+
# ------------------------- COMMON ESP32 DEFINITIONS -----------------
51+
[env_common_esp32c3]
52+
53+
board = esp32-c3-devkitm-1
54+
board_build.partitions = min_spiffs.csv
55+
upload_speed = 460800
56+
monitor_speed = 460800
57+
upload_resetmethod = nodemcu
58+
board_build.f_cpu = 240000000L
59+
build_flags =
60+
-D PLATFORM_ESP32=1
61+
lib_ignore = STM32UPDATE
62+
5063
# ------------------------- COMMON TX-BACKPACK DEFINITIONS -----------------
5164
[tx_backpack_common]
5265
build_flags =

targets/txbp_esp.ini

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,26 @@ extends = env:ESP_TX_Backpack_via_UART
2323
extends = env:ESP_TX_Backpack_via_UART
2424
upload_speed = 230400
2525
upload_command = python "$PROJECT_DIR/python/external/esptool/esptool.py" --passthrough -b $UPLOAD_SPEED ${UPLOAD_PORT and "-p "+UPLOAD_PORT} -c esp8266 --before passthru --after hard_reset write_flash 0x0000 "$SOURCE"
26+
27+
28+
[env:ESP32C3_TX_Backpack_via_UART]
29+
extends = env_common_esp32c3, tx_backpack_common
30+
build_flags =
31+
${env_common_esp32c3.build_flags}
32+
${tx_backpack_common.build_flags}
33+
-D PIN_BUTTON=9
34+
-D PIN_LED=8
35+
upload_resetmethod = nodemcu
36+
37+
[env:ESP32C3_TX_Backpack_via_ETX]
38+
extends = env:ESP32C3_TX_Backpack_via_UART
39+
upload_speed = 460800
40+
upload_command = python "$PROJECT_DIR/python/external/esptool/esptool.py" --passthrough -b $UPLOAD_SPEED ${UPLOAD_PORT and "-p "+UPLOAD_PORT} -c esp32c3 --before etx --after hard_reset write_flash 0x0000 "$BUILD_DIR/bootloader.bin" 0x8000 "$BUILD_DIR/partitions.bin" 0xe000 "$BUILD_DIR/boot_app0.bin" 0x10000 "$SOURCE"
41+
42+
[env:ESP32C3_TX_Backpack_via_WIFI]
43+
extends = env:ESP32C3_TX_Backpack_via_UART
44+
45+
[env:ESP32C3_TX_Backpack_via_PASSTHRU]
46+
extends = env:ESP32C3_TX_Backpack_via_UART
47+
upload_speed = 230400
48+
upload_command = python "$PROJECT_DIR/python/external/esptool/esptool.py" --passthrough -b $UPLOAD_SPEED ${UPLOAD_PORT and "-p "+UPLOAD_PORT} -c esp32c3 --before passthru --after hard_reset write_flash 0x0000 "$BUILD_DIR/bootloader.bin" 0x8000 "$BUILD_DIR/partitions.bin" 0xe000 "$BUILD_DIR/boot_app0.bin" 0x10000 "$SOURCE"

0 commit comments

Comments
 (0)