client: flash animation only on a terminal, exit 1 on failure

Since cd5906674 the flash animation runs whatever stdout is, and a
redirected flash of fullimage.elf wrote a 7 MB log.

flash_pm3() replaced a flash error with the result of
flash_stop_flashing(), always PM3_SUCCESS, so a failed flash ended with
"All done". main() exited 0 after --flash, --dumpmem and
--reboot-to-bootloader whatever happened. dumpmem printed its negative
error code with %u.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Gabriele GristinaandClaude Opus 5.5 committed 2026-11-06 22:15:28 +01:00
1 parent 04cac2724b
commit 49e444b773
3 files changed
+20 -12

No files matched your search

+6 -4
View File
@@ -1027,7 +1027,9 @@ int flash_write(flash_file_t *ctx, flash_dev_t *flash_dev) {
void (*old_sigint)(int) = SIG_ERR;
void (*old_sigwinch)(int) = SIG_ERR;
if (blocks > 50) {
// escape sequences only where they work, not in a redirected stdout
bool animate = (blocks > 50) && g_session.stdoutOnTTY;
if (animate) {
old_sigint = signal(SIGINT, hadouken_on_sigint);
#ifndef _WIN32
@@ -1045,7 +1047,7 @@ int flash_write(flash_file_t *ctx, flash_dev_t *flash_dev) {
}
if (write_block(baddr, ctx->ver_info->magic, data, block_size, flash_dev) < 0) {
if (blocks > 50) {
if (animate) {
hadouken_stop();
restore_progress_signals(old_sigint, old_sigwinch);
}
@@ -1058,13 +1060,13 @@ int flash_write(flash_file_t *ctx, flash_dev_t *flash_dev) {
length -= block_size;
block++;
if (blocks > 50) {
if (animate) {
pct = (int)(block * 100) / blocks;
hadouken_set_progress(pct);
}
}
if (blocks > 50) {
if (animate) {
hadouken_stop();
restore_progress_signals(old_sigint, old_sigwinch);
}