diff --git a/python/binary_flash.py b/python/binary_flash.py index 3b4aa2f..e68f92f 100644 --- a/python/binary_flash.py +++ b/python/binary_flash.py @@ -92,7 +92,8 @@ def upload_esp32_uart(args): args.port = serials_find.get_serial_port() try: dir = os.path.dirname(args.file.name) - 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]) + start_addr = '0x0000' if args.platform.startswith('esp32-c') else '0x1000' + 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]) except: return ElrsUploadResult.ErrorGeneral return ElrsUploadResult.Success @@ -102,7 +103,8 @@ def upload_esp32_etx(args): args.port = serials_find.get_serial_port() try: dir = os.path.dirname(args.file.name) - 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]) + start_addr = '0x0000' if args.platform.startswith('esp32-c') else '0x1000' + 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]) except: return ElrsUploadResult.ErrorGeneral return ElrsUploadResult.Success @@ -112,7 +114,8 @@ def upload_esp32_passthru(args): args.port = serials_find.get_serial_port() try: dir = os.path.dirname(args.file.name) - 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]) + start_addr = '0x0000' if args.platform.startswith('esp32-c') else '0x1000' + 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]) except: return ElrsUploadResult.ErrorGeneral return ElrsUploadResult.Success diff --git a/targets/common.ini b/targets/common.ini index e02d548..3fa89f2 100644 --- a/targets/common.ini +++ b/targets/common.ini @@ -47,6 +47,19 @@ board_build.f_cpu = 240000000L build_flags = -D PLATFORM_ESP32=1 +# ------------------------- COMMON ESP32 DEFINITIONS ----------------- +[env_common_esp32c3] +platform = espressif32@6.4.0 +board = esp32-c3-devkitm-1 +board_build.partitions = min_spiffs.csv +upload_speed = 460800 +monitor_speed = 460800 +upload_resetmethod = nodemcu +board_build.f_cpu = 240000000L +build_flags = + -D PLATFORM_ESP32=1 +lib_ignore = STM32UPDATE + # ------------------------- COMMON TX-BACKPACK DEFINITIONS ----------------- [tx_backpack_common] build_flags = diff --git a/targets/txbp_esp.ini b/targets/txbp_esp.ini index 91fe55e..c9afc8f 100644 --- a/targets/txbp_esp.ini +++ b/targets/txbp_esp.ini @@ -23,3 +23,26 @@ extends = env:ESP_TX_Backpack_via_UART extends = env:ESP_TX_Backpack_via_UART upload_speed = 230400 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" + + +[env:ESP32C3_TX_Backpack_via_UART] +extends = env_common_esp32c3, tx_backpack_common +build_flags = + ${env_common_esp32c3.build_flags} + ${tx_backpack_common.build_flags} + -D PIN_BUTTON=9 + -D PIN_LED=8 +upload_resetmethod = nodemcu + +[env:ESP32C3_TX_Backpack_via_ETX] +extends = env:ESP32C3_TX_Backpack_via_UART +upload_speed = 460800 +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" + +[env:ESP32C3_TX_Backpack_via_WIFI] +extends = env:ESP32C3_TX_Backpack_via_UART + +[env:ESP32C3_TX_Backpack_via_PASSTHRU] +extends = env:ESP32C3_TX_Backpack_via_UART +upload_speed = 230400 +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"