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

Trace #1

Merged
merged 2 commits into from
Apr 9, 2024
Merged
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
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ if(CMAKE_BUILD_TYPE STREQUAL Release)
-DINPUT_libjpeg=no
-DINPUT_libmd4c=no)
elseif(CMAKE_SYSTEM_NAME STREQUAL Windows)
# Install Qt6 for host
# Install Qt6 for host using https://github.com/miurahr/aqtinstall
find_package(Python3 REQUIRED COMPONENTS Interpreter)
execute_process(
COMMAND
Expand Down Expand Up @@ -410,6 +410,8 @@ cpmaddpackage(
GITHUB_REPOSITORY
higaski/esp-serial-flasher
GIT_TAG
# TODO actual tag once #103 got merged
# https://github.com/espressif/esp-serial-flasher/pull/103
928dd73850c2c2cd689ecdeb854afe7b2b159622
VERSION
1.3.0
Expand Down Expand Up @@ -458,7 +460,7 @@ if(CMAKE_BUILD_TYPE STREQUAL Release)
URL
https://github.com/dejavu-fonts/dejavu-fonts/releases/download/version_2_37/dejavu-fonts-ttf-2.37.zip
VERSION
${ARG_VERSION}
2.37
DOWNLOAD_ONLY
TRUE)
add_custom_command(
Expand Down Expand Up @@ -528,7 +530,6 @@ if(CMAKE_BUILD_TYPE STREQUAL Release)
-targetDir ${TARGET_DIR} #
-verbose 3 #
-platform win_x86_64 #
-icon ${CMAKE_CURRENT_SOURCE_DIR}/data/images/icon.ico #
)
endif()

Expand Down
34 changes: 19 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ It currently supports the following ESP microcontrollers:
- [ESP32H2](https://www.espressif.com/en/products/socs/esp32-h2)
- [ESP32C6](https://www.espressif.com/en/products/socs/esp32-c6)

### [Latest release](https://github.com/higaski/QtESPFlasher/releases/latest)

<details>
<summary>Table of contents</summary>
<ol>
Expand All @@ -25,7 +23,7 @@ It currently supports the following ESP microcontrollers:
<li><a href="#reset-modes">Reset modes</a></li>
<li><a href="#disabling-the-stub-loader">Disabling the stub loader</a></li>
<li><a href="#trace">Trace</a></li>
<li><a href="#chip-type">Trace</a></li>
<li><a href="#chip-type">Chip type</a></li>
<li><a href="#serial-port">Serial port</a></li>
<li><a href="#baud-rate">Baud rate</a></li>
</ul>
Expand All @@ -39,7 +37,7 @@ It currently supports the following ESP microcontrollers:

## Features
- GUI flashes either
- an [esp-idf](https://github.com/espressif/esp-idf) build folder
- an [ESP-IDF](https://github.com/espressif/esp-idf) build directory
- a [flasher_args.json](https://github.com/espressif/esp-idf/blob/master/components/esptool_py/flasher_args.json.in) file
- a .zip archive
- single/multiple loose binaries
Expand All @@ -51,20 +49,21 @@ Most options are supported equally by CLI and GUI. The following table contains
| Option | Description |
| --------------- | --------------------------------------------------------------- |
| `-c`, `--chip` | Target chip type |
| `-p`, `--port` | Serial port baud rate |
| `-p`, `--port` | Serial port device |
| `-b`, `--baud` | Serial port baud rate |
| `--before` | What to do before connecting to the chip |
| `-a`, `--after` | What to do after QtESPFlasher is finished |
| `--no-stub` | Disable launching the flasher stub, only talk to ROM bootloader |
| `-t`, `--trace` | Enable trace-level output of QtESPFlasher interactions |
| `-l`, `--list` | List all available serial interfaces |
| `-l`, `--list` | List all available serial devices |

The following screenshot shows the GUI options.
And this screenshot shows how the options are displayed in the GUI.
![options](data/images/options.png)

### Reset modes
By default, QtESPFlasher tries to hard reset the chip into bootloader mode before it starts and hard resets the chip to run the normal program once it is complete. The `--before` and `--after` options allow this behavior to be changed.

#### Reset before operation
#### Reset before operation
The `--before` argument allows you to specify whether the chip needs resetting into bootloader mode before QtESPFlasher talks to it.
- `--before default_reset` is the default, which uses DTR & RTS serial control lines to try to reset the chip into bootloader mode.
- `--before no_reset` will skip DTR/RTS control signal assignments and just start sending a serial synchronization command to the chip. This is useful if your chip doesn't have DTR/RTS, or for some serial interfaces (like Arduino board onboard serial) which behave differently when DTR/RTS are toggled.
Expand All @@ -78,7 +77,7 @@ The `--after` argument allows you to specify whether the chip should be reset af
The `--no-stub` option disables uploading of a software "stub loader" that manages flash operations, and only talks directly to the loader in ROM.

### Trace
QtESPFlasher has a `--trace` option which can be supplied in the first group of arguments (before the command). This will dump all traffic sent and received via the serial port to a log file next to the executable called `trace.txt`.
QtESPFlasher has a `--trace` option which can be supplied in the first group of arguments (before the command). This will dump all traffic sent and received via the serial port to a log file called `trace.txt` in the application root directory.

### Chip type
The target chip type can be selected using the `-c`, `--chip` option. If no `-c` option is specified, QtESPFlasher automatically detects the chip type when connecting.
Expand All @@ -87,7 +86,7 @@ The target chip type can be selected using the `-c`, `--chip` option. If no `-c`
The serial port is selected using the `-p`, `--port` option. If no `-p` option is specified, QtESPFlasher will enumerate all connected serial ports and try each one until it finds an Espressif device connected.

### Baud rate
The default QtESPFlasher baud rate is 115200. Slower rates may be set using `-b`, `--baud`. It is recommend to only set the baud rate if you're experiencing transmission errors during flashing. If left at default QtESPFlasher tries to change the baud rate to 460800 when running.
The default QtESPFlasher baud rate is 115200. Slower rates may be set using `-b`, `--baud`. It is **recommend** to only set the baud rate if you're experiencing transmission errors during flashing. If left at default QtESPFlasher tries to change the baud rate to 460800 when running to considerably reduce flash times.

## Usage
### CLI
Expand Down Expand Up @@ -126,11 +125,16 @@ Done
```

### GUI
#### Add folder
![usage add dir](data/images/usage_add_dir.gif)
QtESPFlasher offers a few different ways to select binaries for flashing.

#### Add binaries
![usage add bin](data/images/usage_add_bin.gif)
#### Add directory
The build directory of an ESP-IDF project can be selected directly using the ![folder open](data/images/folder_open.png) symbol. ESP-IDF builds generate a file called flasher_args.json which contains project flash information in JSON format. This file is red by QtESPFlasher to obtain all of the projects binaries and their offsets.
![usage add dir](data/images/usage_add_dir.gif)

#### Add .zip archive
![usage add zip](data/images/usage_add_zip.gif)
A zipped ESP-IDF build directory can also be selected directly using the ![file](data/images/file.png) symbol. The .zip file must contain a flasher_args.json file, just like when adding a directory.
![usage add zip](data/images/usage_add_zip.gif)

#### Add binaries
If there is no flasher_args.json file available, binaries can also be added directly. This is done by selecting .bin files with the ![file](data/images/file.png) symbol. Please note that in this case the offset must be entered **manually**. Offsets in the C language convention, such as “0x” for base 16 or “0b” for base 2, are supported.
![usage add bin](data/images/usage_add_bin.gif)
Binary file added data/images/file.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/folder_open.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/esp_flasher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ void EspFlasher::transfer_debug_print(uint8_t const* data,
if (_trace != "trace") return;

static auto const log_path{
QCoreApplication::applicationDirPath().toStdString() + "/trace.txt"};
QCoreApplication::applicationDirPath().toStdString() + "/../trace.log"};
static auto fd{fopen(log_path.c_str(), "w")};
static gsl::final_action close{[&fd] { fclose(fd); }};

Expand Down